import { StoryObj } from '@storybook/react-webpack5'; import { userEvent, within } from 'storybook/test'; import { createSandboxStory, globalScope, } from '../../../.storybook/components/sandbox/SandboxEditor'; import TextareaWithDisplayFormat from '..'; import Field from '../../Field/Field'; export default { component: TextareaWithDisplayFormat, title: 'Forms/TextareaWithDisplayFormat', }; type Story = StoryObj; export const Sandbox = createSandboxStory({ code: `const App = () => { const [value, setValue] = React.useState(''); return ( setValue(event.target.value)} /> ); };`, scope: globalScope, }); export const Basic: Story = { render: () => { const label = 'Textarea with display format'; const id = label.replaceAll(' ', '-').toLowerCase(); return ( ); }, // intentionally use interactive typing (over init value via `value` prop) // to trigger event handlers in the component play: async ({ canvasElement }) => { const canvas = within(canvasElement); await userEvent.type(canvas.getByRole('textbox'), '111122223333', { initialSelectionStart: Number.MAX_SAFE_INTEGER, }); }, };