wp-ultimate-post-grid
/
vendor
/
bv-settings
/
assets
/
js
/
admin
/
settings
/
setting
/
DropdownMultiselect.js
DropdownMultiselect.js in WP Ultimate Post Grid 4.0.1, at vendor/bv-settings/assets/js/admin/settings/setting/DropdownMultiselect.js
| 1 | import React from 'react'; |
| 2 | import PropTypes from 'prop-types'; |
| 3 | import Select from 'react-select'; |
| 4 | |
| 5 | |
| 6 | const SettingDropdownMultiselect = (props) => { |
| 7 | let selectOptions = []; |
| 8 | |
| 9 | for (let option in props.setting.options) { |
| 10 | selectOptions.push({ |
| 11 | value: option, |
| 12 | label: props.setting.options[option], |
| 13 | }); |
| 14 | } |
| 15 | |
| 16 | return ( |
| 17 | <Select |
| 18 | className="bvs-setting-input" |
| 19 | value={selectOptions.filter(({value}) => props.value.includes(value))} |
| 20 | isMulti |
| 21 | onChange={(options) => { |
| 22 | const selected = Array.isArray(options) ? options : [options]; |
| 23 | return props.onValueChange(selected.map(option => option.value)); |
| 24 | }} |
| 25 | options={selectOptions} |
| 26 | styles={{ |
| 27 | menu: (provided) => ({ |
| 28 | ...provided, |
| 29 | zIndex: '10', |
| 30 | }), |
| 31 | }} |
| 32 | /> |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | SettingDropdownMultiselect.propTypes = { |
| 37 | setting: PropTypes.object.isRequired, |
| 38 | value: PropTypes.any.isRequired, |
| 39 | onValueChange: PropTypes.func.isRequired, |
| 40 | } |
| 41 | |
| 42 | export default SettingDropdownMultiselect; |