This commit is contained in:
Nathan Bierema 2021-06-06 23:48:59 -04:00
parent 41f82fe7f8
commit 1bb2b39423
2 changed files with 23 additions and 7 deletions

View File

@ -4,13 +4,22 @@ import Select from '../Select';
import Slider from '../Slider';
/* eslint-disable react/prop-types */
const SelectWidget: Widget = ({ options, onChange, value, ...rest }) => (
<Select
options={options.enumOptions}
onChange={(option: { value: string }) => {
onChange(option.value);
const SelectWidget: Widget = ({
options,
onChange,
value,
onBlur,
defaultValue,
tabIndex,
onFocus,
...rest
}) => (
<Select<{ label: string; value: string }>
options={options.enumOptions as { label: string; value: string }[]}
onChange={(option) => {
onChange(option?.value);
}}
value={(options.enumOptions as { value: string }[]).find(
value={(options.enumOptions as { label: string; value: string }[]).find(
(option) => option.value === value
)}
{...rest}

View File

@ -81,11 +81,18 @@ export class Select<
};
}
interface ExternalSelectProps<
Option extends OptionTypeBase = OptionTypeBase,
IsMulti extends boolean = false
> extends Omit<ReactSelectProps<Option, IsMulti>, 'theme'> {
theme?: Theme;
}
type SelectComponent = <
Option extends OptionTypeBase = OptionTypeBase,
IsMulti extends boolean = false
>(
props: SelectProps<Option, IsMulti>
props: ExternalSelectProps<Option, IsMulti>
) => ReactElement;
export default createThemedComponent(Select) as SelectComponent & {