import { createElement, Component } from '@wordpress/element' import { maybeTransformUnorderedChoices } from '../helpers/parse-choices.js' import Downshift from 'downshift' import classnames from 'classnames' const Select = ({ value, option: { choices, placeholder }, onChange }) => { const orderedChoices = maybeTransformUnorderedChoices(choices) return ( onChange(selection)} itemToString={item => item ? orderedChoices.find(({ key }) => key === item).value : '' }> {({ getInputProps, getItemProps, getLabelProps, getMenuProps, isOpen, inputValue, highlightedIndex, selectedItem, openMenu }) => (
openMenu(), onClick: () => openMenu() })} placeholder={placeholder || 'Select value...'} readOnly /> {isOpen && (
{orderedChoices.map((item, index) => (
{item.value}
))}
)}
)}
) } export default Select