Select: Allow custom value for selects (#19775)

* WIP: simple poc of allow custom value for selects

* Add support for custom value in segment

* Update snapshots
This commit is contained in:
Torkel Ödegaard
2019-10-15 15:08:56 +02:00
committed by GitHub
parent 7963422df0
commit d0d59b8001
12 changed files with 128 additions and 3 deletions

View File

@ -36,3 +36,30 @@ SelectStories.add('default', () => {
</UseState>
);
});
SelectStories.add('With allowCustomValue', () => {
const intialState: SelectableValue<string> = { label: 'A label', value: 'A value' };
const value = object<SelectableValue<string>>('Selected Value:', intialState);
const options = object<Array<SelectableValue<string>>>('Options:', [
intialState,
{ label: 'Another label', value: 'Another value' },
]);
return (
<UseState initialState={value}>
{(value, updateValue) => {
return (
<Select
value={value}
options={options}
allowCustomValue={true}
onChange={value => {
action('onChanged fired')(value);
updateValue(value);
}}
/>
);
}}
</UseState>
);
});