import { Flag } from '@wise/art'; import { createSandboxStory, globalScope, } from '../../../.storybook/components/sandbox/SandboxEditor'; import RadioGroup, { RadioGroupProps, RadioGroupRadio } from '..'; import Field from '../../Field/Field'; import { Meta, StoryObj } from '@storybook/react-webpack5'; import { fn } from 'storybook/test'; import { useState } from 'react'; import AvatarView from '../../AvatarView'; const meta = { component: RadioGroup, title: 'Forms/RadioGroup', } satisfies Meta; export default meta; type Story = StoryObj>; export const Sandbox = createSandboxStory({ code: `const App = () => { const [selectedValue, setSelectedValue] = React.useState('radio-1'); return ( setSelectedValue(value)} radios={[ { value: 'radio-1', label: 'Option 1', secondary: 'Description for option 1' }, { value: 'radio-2', label: 'Option 2', secondary: 'Description for option 2' }, { value: 'radio-3', label: 'Option 3', secondary: 'Description for option 3' }, ]} /> ); };`, scope: globalScope, }); export const Basic: Story = { args: { selectedValue: 'radio-2', name: 'radio-group', radios: [ { value: 'radio-1', label: 'Radio1', secondary: 'Secondary line 1', disabled: false, }, { value: 'radio-2', label: 'Radio2', disabled: false, }, { value: 'radio-3', label: 'Radio3', secondary: 'Secondary line 3', disabled: true, }, ], onChange: fn(), }, } satisfies Story; export const WithAvatars = { ...Basic, args: { ...Basic.args, radios: Basic?.args?.radios?.map( (radio) => ({ ...radio, avatar: ( ), }) satisfies RadioGroupRadio, ), }, } satisfies Story; export const WithinField = { ...Basic, render: function Render(args) { const [selectedValue, setSelectedValue] = useState('radio-2'); const hasError = selectedValue === 'radio-2'; return ( ); }, } satisfies Story;