import { StoryFn, StoryObj } from '@storybook/react-webpack5'; import React from 'react'; import Button from '../button'; import SegmentedControl from './SegmentedControl'; export default { component: SegmentedControl, title: 'Forms/SegmentedControl', }; type Story = StoryObj; const Template: Story = { render: (args) => { const [segments, setSegments] = React.useState([ { id: 'CUPCAKE', label: 'Cupcakes', value: 'cupcakes' }, { id: 'SPONGECAKE', label: 'Sponge cake', value: 'spongecake' }, { id: 'CARROT_CAKE', label: 'Carrot cake', value: 'carrotcake' }, ]); const [segmentsWithControls, setSegmentsWithControls] = React.useState([ { id: 'CUPCAKE', label: 'Cupcakes', value: 'cupcakes', controls: 'aControlId' }, { id: 'SPONGECAKE', label: 'Sponge cake', value: 'spongecake', controls: 'aControlId' }, { id: 'CARROT_CAKE', label: 'Carrot cake', value: 'carrotcake', controls: 'aControlId' }, ]); const [value, setValue] = React.useState(segments[0].value); console.log('render: segments.length', segments.length); return (

Selected value: {value}

Force the selectedValue to be one of the following:

); }, }; export const SegmentedControlDefault: Story = { ...Template, args: { mode: 'input', }, }; export const SegmentedControlView: Story = { ...Template, args: { mode: 'view', }, };