import type { Meta, StoryObj } from '@storybook/react-vite'; import { Field, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSet, } from './field'; import { Input } from '../input/input'; import { Switch } from '../switch/switch'; const meta = { title: 'Components/Field', component: Field, parameters: { layout: 'centered', docs: { description: { component: 'Layout for a control and its supporting text, without a form library. Use the `form` subpath instead when you are on react-hook-form — that version also derives `aria-invalid` and `aria-describedby` from validation state. Here you own the wiring: give the control an `id` and point `FieldLabel` at it.', }, }, }, tags: ['autodocs'], decorators: [(Story) =>
], } satisfies Meta; export default meta; type Story = StoryObj; export const Default: Story = { render: () => ( Email We never share it. ), }; export const Invalid: Story = { render: () => ( Display name Must be at least three characters. ), }; /** Horizontal orientation suits controls that read as a single line. */ export const Horizontal: Story = { render: () => ( Join the beta programme ), }; export const Grouped: Story = { render: () => (
Contact details First name Last name
), }; /** * CBAR's `.isRequired?` slot. The asterisk is `aria-hidden` — it draws, it does * not announce. Set `required` on the control as well so assistive technology * hears it from the place it already looks. */ export const Required: Story = { render: () => ( Email We only use it to send the receipt. ), };