import React from 'react' import { type Meta, type StoryObj } from '@storybook/react' import { Checkbox, type CheckedStatus } from '../index' const meta = { title: 'Components/MultiSelect/Checkbox', component: Checkbox, args: { 'checkedStatus': 'unchecked', 'readOnly': false, 'aria-label': 'Checkbox label', }, } satisfies Meta export default meta type Story = StoryObj export const Playground: Story = { render: ({ readOnly, onChange, checkedStatus, ...args }) => { const [status, setStatus] = React.useState(checkedStatus) const handleChange: React.ChangeEventHandler = (e) => { if (status === 'unchecked') { setStatus('indeterminate') } else if (status === 'indeterminate') { setStatus('checked') } else if (status === 'checked') { setStatus('unchecked') } onChange?.(e) } React.useEffect(() => { setStatus(checkedStatus) }, [checkedStatus]) const props = readOnly ? { ...args, readOnly } : { ...args, onChange: handleChange } return }, parameters: { docs: { canvas: { sourceState: 'shown', }, }, }, } export const Interactive: Story = { render: Playground.render, args: { readOnly: undefined, }, parameters: { controls: { disable: true }, }, }