'use client'; import * as React from 'react'; import { cva, type VariantProps } from '@/lib/cva'; import { cn } from '@/lib/utils'; import { Label } from '@/components/label/label'; const fieldVariants = cva('group/field flex w-full gap-2 data-[invalid=true]:text-destructive', { variants: { orientation: { /** Label above the control. The default for most forms. */ vertical: 'flex-col [&>*]:w-full [&>.sr-only]:w-auto', /** Label beside the control — suits checkboxes and switches. */ horizontal: 'flex-row items-center gap-3 [&>[data-slot=field-label]]:flex-auto', }, }, defaultVariants: { orientation: 'vertical', }, }); export interface FieldProps extends React.ComponentProps<'div'>, VariantProps { /** Marks the whole group invalid, tinting the label and error text. */ invalid?: boolean; } /** * Layout for one form control and its supporting text, without a form library. * * Use this when you manage state yourself; use the `form` subpath instead when * you are on react-hook-form, since that version also wires up `aria-invalid` * and `aria-describedby` from the validation state. * * You still own the accessible wiring here: give the control an `id` and point * `FieldLabel`'s `htmlFor` at it. * * ```tsx * * Email * * We never share it. * * ``` */ function Field({ className, orientation, invalid, ...props }: FieldProps) { return (
); } function FieldLabel({ className, ...props }: React.ComponentProps) { return (