(props: Props)
| 17 | } |
| 18 | |
| 19 | export const MetricSelect = (props: Props) => { |
| 20 | const { value, placeholder, className, isSearchable, onChange } = props; |
| 21 | const options = useMatcherSelectOptions(props); |
| 22 | const selected = useSelectedOption(options, value); |
| 23 | const onChangeValue = useCallback((selectable: SelectableValue<string>) => onChange(selectable.value), [onChange]); |
| 24 | |
| 25 | return ( |
| 26 | <Select |
| 27 | className={className} |
| 28 | isMulti={false} |
| 29 | isClearable={false} |
| 30 | backspaceRemovesValue={false} |
| 31 | onChange={onChangeValue} |
| 32 | options={options} |
| 33 | isSearchable={isSearchable} |
| 34 | maxMenuHeight={500} |
| 35 | placeholder={placeholder} |
| 36 | noOptionsMessage={t('metric-select.noOptionsMessage-no-options-found', 'No options found')} |
| 37 | value={selected} |
| 38 | /> |
| 39 | ); |
| 40 | }; |
| 41 | |
| 42 | const useMatcherSelectOptions = ({ variables = [], options }: Props): Array<SelectableValue<string>> => { |
| 43 | return useMemo(() => { |
nothing calls this directly
no test coverage detected