CTA.js
5 years ago
CheckboxControl.js
5 years ago
CodeMirror.js
3 years ago
ColorPicker.js
5 years ago
ComboboxControl.js
3 years ago
Disabled.js
5 years ago
Fields.js
5 years ago
Group.js
3 years ago
Groups.js
5 years ago
Integration.js
5 years ago
Loading.js
5 years ago
Media.js
3 years ago
Notices.js
3 years ago
NullView.js
5 years ago
Page.js
5 years ago
SaveButton.js
3 years ago
SelectControl.js
5 years ago
TextControl.js
5 years ago
ToggleControl.js
5 years ago
ComboboxControl.js
23 lines
| 1 | const { ComboboxControl } = wp.components; |
| 2 | const { useState } = wp.element; |
| 3 | const { dispatch } = wp.data; |
| 4 | import classNames from "classnames"; |
| 5 | |
| 6 | export default ({ value, options, onChange, ...rest }) => { |
| 7 | const [filteredOptions, setFilteredOptions] = useState(options || []); |
| 8 | return ( |
| 9 | <ComboboxControl |
| 10 | options={filteredOptions} |
| 11 | onFilterValueChange={(inputValue) => |
| 12 | setFilteredOptions( |
| 13 | options.filter((option) => |
| 14 | value.label.toLowerCase().startsWith(inputValue.toLowerCase()) |
| 15 | ) |
| 16 | ) |
| 17 | } |
| 18 | onChange={onChange} |
| 19 | {...props} |
| 20 | /> |
| 21 | ); |
| 22 | }; |
| 23 |