| 1 |
/** |
| 2 |
* External dependencies |
| 3 |
*/ |
| 4 |
import Select from 'react-select'; |
| 5 |
|
| 6 |
/** |
| 7 |
* WordPress dependencies |
| 8 |
*/ |
| 9 |
import { withInstanceId } from '@wordpress/compose'; |
| 10 |
import { BaseControl } from '@wordpress/components'; |
| 11 |
|
| 12 |
const CustomSelectControl = ({ |
| 13 |
label, |
| 14 |
value, |
| 15 |
options, |
| 16 |
onChange, |
| 17 |
searchable = true, |
| 18 |
clearable = true, |
| 19 |
placeholder = '', |
| 20 |
multiple = false, |
| 21 |
instanceId |
| 22 |
}) => { |
| 23 |
const id = `select-control-${instanceId}`; |
| 24 |
return ( |
| 25 |
<BaseControl id={id} label={label}> |
| 26 |
<Select |
| 27 |
id={id} |
| 28 |
classNamePrefix="gkits" |
| 29 |
value={value} |
| 30 |
onChange={data => onChange(data)} |
| 31 |
options={options} |
| 32 |
unstyled={true} |
| 33 |
isSearchable={searchable} |
| 34 |
isClearable={clearable} |
| 35 |
placeholder={placeholder} |
| 36 |
isMulti={multiple} |
| 37 |
/> |
| 38 |
</BaseControl> |
| 39 |
); |
| 40 |
}; |
| 41 |
|
| 42 |
export default withInstanceId(CustomSelectControl); |
| 43 |
|