import { useEffect, useState } from 'react'; import { Meta, StoryObj } from '@storybook/react-webpack5'; import { createSandboxStory, globalScope, } from '../../../../.storybook/components/sandbox/SandboxEditor'; import Field from '../../../Field'; import { Sentiment } from '../../../common'; import { TextArea } from '../TextArea'; /** * TextArea must be the only input with `maxLength` inside a given Field. * The character counter uses shared context — multiple TextAreas with maxLength * in the same Field will race to set the counter state. */ const meta: Meta = { title: 'Forms/TextArea', component: TextArea, argTypes: { value: { control: 'text', }, maxLength: { control: 'number', }, placeholder: { control: 'text', }, disabled: { control: 'boolean', }, rows: { control: 'number', }, }, }; export default meta; type Story = StoryObj; /** Explore all props via the controls panel. */ export const Playground: Story = { args: { value: '', maxLength: 200, placeholder: 'Type something...', }, render: (args) => { const [value, setValue] = useState(args.value ?? ''); useEffect(() => setValue(args.value ?? ''), [args.value]); return (