2023-09-27 19:48:59 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { useState } from '@wordpress/element';
|
|
|
|
import { TreeSelectControl } from '@woocommerce/components';
|
|
|
|
|
|
|
|
export const RegionPicker = ( { options, initialValues } ) => {
|
|
|
|
const [ selected, setSelected ] = useState( initialValues );
|
|
|
|
const onChange = ( value ) => {
|
|
|
|
document.body.dispatchEvent(
|
|
|
|
new CustomEvent( 'wc_region_picker_update', { detail: value } )
|
|
|
|
);
|
|
|
|
setSelected( value );
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<TreeSelectControl
|
|
|
|
value={ selected }
|
|
|
|
onChange={ onChange }
|
|
|
|
options={ options }
|
|
|
|
placeholder="Start typing to filter zones"
|
|
|
|
selectAllLabel="Select all countries"
|
|
|
|
individuallySelectParent
|
2023-09-28 04:49:17 +00:00
|
|
|
maxVisibleTags={ 5 }
|
2023-09-27 19:48:59 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|