CTA.js
5 years ago
CheckboxControl.js
5 years ago
CodeMirror.js
5 years ago
ColorPicker.js
5 years ago
ComboboxControl.js
5 years ago
Disabled.js
5 years ago
Fields.js
5 years ago
Group.js
5 years ago
Groups.js
5 years ago
Integration.js
5 years ago
Loading.js
5 years ago
Media.js
5 years ago
NullView.js
5 years ago
Page.js
5 years ago
SaveButton.js
5 years ago
SelectControl.js
5 years ago
TextControl.js
5 years ago
ToggleControl.js
5 years ago
ComboboxControl.js
35 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 ({ option, options, value, optionName, className }) => { |
| 7 | const [filteredOptions, setFilteredOptions] = useState(options || []); |
| 8 | return ( |
| 9 | <ComboboxControl |
| 10 | className={classNames( |
| 11 | className, |
| 12 | "presto-settings__setting is-combo-control" |
| 13 | )} |
| 14 | label={option?.name} |
| 15 | value={value} |
| 16 | help={option?.help} |
| 17 | options={filteredOptions} |
| 18 | onFilterValueChange={(inputValue) => |
| 19 | setFilteredOptions( |
| 20 | options.filter((option) => |
| 21 | option.label.toLowerCase().startsWith(inputValue.toLowerCase()) |
| 22 | ) |
| 23 | ) |
| 24 | } |
| 25 | onChange={(value) => |
| 26 | dispatch("presto-player/settings").updateSetting( |
| 27 | option.id, |
| 28 | value, |
| 29 | optionName |
| 30 | ) |
| 31 | } |
| 32 | /> |
| 33 | ); |
| 34 | }; |
| 35 |