import { action } from 'storybook/actions'; import { Meta, StoryObj } from '@storybook/react-webpack5'; import React, { useState } from 'react'; import { RadioGroup, RadioGroupProps, } from '../../src/lib/components/radio/RadioGroup.component'; import { Form, FormGroup, FormSection, } from '../../src/lib/components/form/Form.component'; type RadioGroupStory = StoryObj; const retentionOptions = [ { value: 'governance', label: 'Governance' }, { value: 'compliance', label: 'Compliance' }, { value: 'none', label: 'None' }, ]; const meta: Meta = { title: 'Components/Inputs/Radio', component: RadioGroup, }; export default meta; export const Playground: RadioGroupStory = { args: { name: 'playground', label: 'Retention mode', value: 'governance', options: retentionOptions, onChange: action('RadioGroup changed'), }, }; export const RadioGroupExample: RadioGroupStory = { render: () => { const [selected, setSelected] = useState('governance'); return ( ); }, }; export const Horizontal: RadioGroupStory = { render: () => { const [selected, setSelected] = useState('small'); return ( ); }, }; export const AllStates: RadioGroupStory = { render: () => (
{}} options={[{ value: 'a', label: 'Unchecked' }]} /> {}} options={[{ value: 'a', label: 'Checked' }]} /> {}} options={[{ value: 'a', label: 'Disabled', disabled: true }]} /> {}} options={[{ value: 'a', label: 'Disabled checked', disabled: true }]} />
), }; export const DisabledGroup: RadioGroupStory = { render: () => ( {}} disabled options={[ { value: 'a', label: 'Option A' }, { value: 'b', label: 'Option B' }, ]} /> ), }; export const WithDisabledReason: RadioGroupStory = { render: () => { const [selected, setSelected] = useState('governance'); return ( ); }, }; export const WithoutVisibleLabel: RadioGroupStory = { render: () => { const [selected, setSelected] = useState('a'); return ( ); }, }; export const FormGroupExample: RadioGroupStory = { render: () => { const [retention, setRetention] = useState('governance'); return (
} />
); }, };