AutoSaveField: Change the story to use Combobox instead of Select (#101922)

This commit is contained in:
Laura Fernández
2025-03-11 11:59:55 +02:00
committed by GitHub
parent dd5db23123
commit da25d97ffd
@@ -1,10 +1,10 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/react';
import { useState } from 'react'; import { useState } from 'react';
import { Combobox } from '../Combobox/Combobox';
import { Checkbox } from '../Forms/Checkbox'; import { Checkbox } from '../Forms/Checkbox';
import { RadioButtonGroup } from '../Forms/RadioButtonGroup/RadioButtonGroup'; import { RadioButtonGroup } from '../Forms/RadioButtonGroup/RadioButtonGroup';
import { Input } from '../Input/Input'; import { Input } from '../Input/Input';
import { Select } from '../Select/Select';
import { Switch } from '../Switch/Switch'; import { Switch } from '../Switch/Switch';
import { TextArea } from '../TextArea/TextArea'; import { TextArea } from '../TextArea/TextArea';
@@ -97,11 +97,12 @@ Basic.args = {
}; };
export const AllComponents: StoryFn = (args) => { export const AllComponents: StoryFn = (args) => {
const [selected, setSelected] = useState('');
const [checkBoxTest, setCheckBoxTest] = useState(false);
const [textAreaValue, setTextAreaValue] = useState('');
const [inputTextValue, setInputTextValue] = useState(''); const [inputTextValue, setInputTextValue] = useState('');
const [switchTest, setSwitchTest] = useState(false); const [comoboboxValue, setComboboxValue] = useState('');
const [radioButtonValue, setRadioButtonValue] = useState('');
const [checkBoxValue, setCheckBoxValue] = useState(false);
const [textAreaValue, setTextAreaValue] = useState('');
const [switchValue, setSwitchValue] = useState(false);
return ( return (
<div> <div>
@@ -117,13 +118,14 @@ export const AllComponents: StoryFn = (args) => {
/> />
)} )}
</AutoSaveField> </AutoSaveField>
<AutoSaveField onFinishChange={args.inputSuccessful ? getSuccess : getError} label="Select as child" {...args}> <AutoSaveField onFinishChange={args.inputSuccessful ? getSuccess : getError} label="Combobox as child" {...args}>
{(onChange) => ( {(onChange) => (
<Select <Combobox
options={themeOptions} options={themeOptions}
value={args.weekPickerValue} value={comoboboxValue}
onChange={(v) => { onChange={(v) => {
onChange(v.value); onChange(v.value);
setComboboxValue(v.value);
}} }}
/> />
)} )}
@@ -136,9 +138,9 @@ export const AllComponents: StoryFn = (args) => {
{(onChange) => ( {(onChange) => (
<RadioButtonGroup <RadioButtonGroup
options={themeOptions} options={themeOptions}
value={selected} value={radioButtonValue}
onChange={(themeOption) => { onChange={(themeOption) => {
setSelected(themeOption); setRadioButtonValue(themeOption);
onChange(themeOption); onChange(themeOption);
}} }}
/> />
@@ -154,11 +156,11 @@ export const AllComponents: StoryFn = (args) => {
label="Checkbox test" label="Checkbox test"
description="This is a checkbox input" description="This is a checkbox input"
name="checkbox-test" name="checkbox-test"
value={checkBoxTest} value={checkBoxValue}
onChange={(e) => { onChange={(e) => {
const value = e.currentTarget.checked; const value = e.currentTarget.checked;
onChange(value); onChange(value);
setCheckBoxTest(value); setCheckBoxValue(value);
}} }}
/> />
)} )}
@@ -188,10 +190,10 @@ export const AllComponents: StoryFn = (args) => {
<Switch <Switch
label="Switch test" label="Switch test"
name="switch-test" name="switch-test"
value={switchTest} value={switchValue}
onChange={(e) => { onChange={(e) => {
onChange(e.currentTarget.checked); onChange(e.currentTarget.checked);
setSwitchTest(e.currentTarget.checked); setSwitchValue(e.currentTarget.checked);
}} }}
/> />
)} )}