import type { Meta, StoryObj } from '@storybook/react-vite'; import { useForm } from 'react-hook-form'; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from './form'; import { Button } from '../button/button'; import { Input } from '../input/input'; import { Switch } from '../switch/switch'; import { toast } from '../toast/toast'; const meta = { title: 'Components/Form', parameters: { layout: 'centered', docs: { description: { component: '`react-hook-form` bindings. It is an **optional peer dependency** — install it in your app if you import this subpath; the rest of the kit works without it. The value here is the wiring: `FormControl` links the input to its label, hint and error through `aria-describedby` and sets `aria-invalid`, so validation is announced rather than only shown.', }, }, }, tags: ['autodocs'], } satisfies Meta; export default meta; type Story = StoryObj; type Values = { username: string; email: string; newsletter: boolean; }; export const Default: Story = { render: function FormStory() { const form = useForm({ defaultValues: { username: '', email: '', newsletter: true }, mode: 'onBlur', }); return (
toast.success('Submitted', { description: JSON.stringify(values) }) )} > ( Username This is your public display name. )} /> ( Email )} /> (
Product updates About one email a month.
)} /> ); }, };