@nswds/ui 9.6.4 → 9.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,14 @@
1
1
  import * as React from 'react';
2
2
  import { Drawer as Drawer$1 } from 'vaul';
3
3
 
4
- declare function Drawer({ ...props }: React.ComponentProps<typeof Drawer$1.Root>): React.JSX.Element;
4
+ /**
5
+ * `autoFocus` defaults to true, so opening moves focus into the drawer and
6
+ * closing returns it to the trigger, as Dialog and Sheet do. Vaul's own
7
+ * default is false, which left focus on the trigger — inside the page the open
8
+ * drawer hides from assistive tech (#251). Pass `autoFocus={false}` only when
9
+ * something else moves focus in.
10
+ */
11
+ declare function Drawer({ autoFocus, ...props }: React.ComponentProps<typeof Drawer$1.Root>): React.JSX.Element;
5
12
  declare function DrawerTrigger({ ...props }: React.ComponentProps<typeof Drawer$1.Trigger>): React.JSX.Element;
6
13
  declare function DrawerPortal({ children, ...props }: React.ComponentProps<typeof Drawer$1.Portal>): React.JSX.Element;
7
14
  declare function DrawerClose({ ...props }: React.ComponentProps<typeof Drawer$1.Close>): React.JSX.Element;
@@ -5,8 +5,8 @@ import { overlayScrim } from '../lib/overlay.js';
5
5
  import { PortalBoundary } from '../lib/portal-boundary.js';
6
6
  import { cn } from '../lib/utils.js';
7
7
 
8
- function Drawer({ ...props }) {
9
- return /* @__PURE__ */ jsx(Drawer$1.Root, { "data-slot": "drawer", ...props });
8
+ function Drawer({ autoFocus = true, ...props }) {
9
+ return /* @__PURE__ */ jsx(Drawer$1.Root, { "data-slot": "drawer", autoFocus, ...props });
10
10
  }
11
11
  function DrawerTrigger({ ...props }) {
12
12
  return /* @__PURE__ */ jsx(Drawer$1.Trigger, { "data-slot": "drawer-trigger", ...props });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/drawer.tsx"],"names":["DrawerPrimitive"],"mappings":";;;;;;AASA,SAAS,MAAA,CAAO,EAAE,GAAG,KAAA,EAAM,EAAsD;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A;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,oBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,uCAAA,EAAyC,SAAS,CAAA;AAAA,MAC/D,GAAG;AAAA;AAAA,GACN;AAEJ","file":"drawer.js","sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Drawer as DrawerPrimitive } from 'vaul'\n\nimport { overlayScrim } from '../lib/overlay.js'\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Drawer({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) {\n return <DrawerPrimitive.Root data-slot='drawer' {...props} />\n}\n\nfunction DrawerTrigger({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {\n return <DrawerPrimitive.Trigger data-slot='drawer-trigger' {...props} />\n}\n\nfunction DrawerPortal({ children, ...props }: React.ComponentProps<typeof DrawerPrimitive.Portal>) {\n return (\n <DrawerPrimitive.Portal data-slot='drawer-portal' {...props}>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>{children}</PortalBoundary>\n </DrawerPrimitive.Portal>\n )\n}\n\nfunction DrawerClose({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Close>) {\n return <DrawerPrimitive.Close data-slot='drawer-close' {...props} />\n}\n\nfunction DrawerOverlay({\n className,\n ...props\n}: React.ComponentProps<typeof DrawerPrimitive.Overlay>) {\n return (\n <DrawerPrimitive.Overlay\n data-slot='drawer-overlay'\n className={cn(\n 'fixed inset-0 z-50 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',\n overlayScrim,\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DrawerContent({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof DrawerPrimitive.Content>) {\n return (\n <DrawerPortal data-slot='drawer-portal'>\n <DrawerOverlay />\n <DrawerPrimitive.Content\n data-slot='drawer-content'\n className={cn(\n 'group/drawer-content fixed z-50 flex h-auto flex-col bg-transparent p-2 text-xs/relaxed text-popover-foreground before:absolute before:inset-2 before:-z-10 before:rounded-md before:border before:border-border before:bg-popover data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:start-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:end-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=left]:sm:max-w-sm data-[vaul-drawer-direction=right]:sm:max-w-sm',\n className,\n )}\n {...props}\n >\n <div className='mx-auto mt-4 hidden h-1.5 w-[100px] shrink-0 rounded-full bg-muted group-data-[vaul-drawer-direction=bottom]/drawer-content:block' />\n {children}\n </DrawerPrimitive.Content>\n </DrawerPortal>\n )\n}\n\nfunction DrawerHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='drawer-header'\n className={cn(\n 'flex flex-col gap-1 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:text-start',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DrawerFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='drawer-footer'\n className={cn('mt-auto flex flex-col gap-2 p-4', className)}\n {...props}\n />\n )\n}\n\nfunction DrawerTitle({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Title>) {\n return (\n <DrawerPrimitive.Title\n data-slot='drawer-title'\n className={cn('text-sm font-medium text-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction DrawerDescription({\n className,\n ...props\n}: React.ComponentProps<typeof DrawerPrimitive.Description>) {\n return (\n <DrawerPrimitive.Description\n data-slot='drawer-description'\n className={cn('text-xs/relaxed text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nexport {\n Drawer,\n DrawerClose,\n DrawerContent,\n DrawerDescription,\n DrawerFooter,\n DrawerHeader,\n DrawerOverlay,\n DrawerPortal,\n DrawerTitle,\n DrawerTrigger,\n}\n"]}
1
+ {"version":3,"sources":["../../src/components/drawer.tsx"],"names":["DrawerPrimitive"],"mappings":";;;;;;AAgBA,SAAS,OAAO,EAAE,SAAA,GAAY,IAAA,EAAM,GAAG,OAAM,EAAsD;AACjG,EAAA,uBAAO,GAAA,CAACA,SAAgB,IAAA,EAAhB,EAAqB,aAAU,QAAA,EAAS,SAAA,EAAuB,GAAG,KAAA,EAAO,CAAA;AACnF;AAEA,SAAS,aAAA,CAAc,EAAE,GAAG,KAAA,EAAM,EAAyD;AACzF,EAAA,2BAAQA,QAAA,CAAgB,OAAA,EAAhB,EAAwB,WAAA,EAAU,gBAAA,EAAkB,GAAG,KAAA,EAAO,CAAA;AACxE;AAEA,SAAS,YAAA,CAAa,EAAE,QAAA,EAAU,GAAG,OAAM,EAAwD;AACjG,EAAA,uBACE,GAAA,CAACA,QAAA,CAAgB,MAAA,EAAhB,EAAuB,WAAA,EAAU,eAAA,EAAiB,GAAG,KAAA,EAEpD,QAAA,kBAAA,GAAA,CAAC,cAAA,EAAA,EAAgB,QAAA,EAAS,CAAA,EAC5B,CAAA;AAEJ;AAEA,SAAS,WAAA,CAAY,EAAE,GAAG,KAAA,EAAM,EAAuD;AACrF,EAAA,2BAAQA,QAAA,CAAgB,KAAA,EAAhB,EAAsB,WAAA,EAAU,cAAA,EAAgB,GAAG,KAAA,EAAO,CAAA;AACpE;AAEA,SAAS,aAAA,CAAc;AAAA,EACrB,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAyD;AACvD,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,OAAA;AAAA,IA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AAEA,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAuD;AAChG,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,KAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,qCAAA,EAAuC,SAAS,CAAA;AAAA,MAC7D,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,iBAAA,CAAkB;AAAA,EACzB,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAA6D;AAC3D,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,WAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,oBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,uCAAA,EAAyC,SAAS,CAAA;AAAA,MAC/D,GAAG;AAAA;AAAA,GACN;AAEJ","file":"drawer.js","sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Drawer as DrawerPrimitive } from 'vaul'\n\nimport { overlayScrim } from '../lib/overlay.js'\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * `autoFocus` defaults to true, so opening moves focus into the drawer and\n * closing returns it to the trigger, as Dialog and Sheet do. Vaul's own\n * default is false, which left focus on the trigger — inside the page the open\n * drawer hides from assistive tech (#251). Pass `autoFocus={false}` only when\n * something else moves focus in.\n */\nfunction Drawer({ autoFocus = true, ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) {\n return <DrawerPrimitive.Root data-slot='drawer' autoFocus={autoFocus} {...props} />\n}\n\nfunction DrawerTrigger({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {\n return <DrawerPrimitive.Trigger data-slot='drawer-trigger' {...props} />\n}\n\nfunction DrawerPortal({ children, ...props }: React.ComponentProps<typeof DrawerPrimitive.Portal>) {\n return (\n <DrawerPrimitive.Portal data-slot='drawer-portal' {...props}>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>{children}</PortalBoundary>\n </DrawerPrimitive.Portal>\n )\n}\n\nfunction DrawerClose({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Close>) {\n return <DrawerPrimitive.Close data-slot='drawer-close' {...props} />\n}\n\nfunction DrawerOverlay({\n className,\n ...props\n}: React.ComponentProps<typeof DrawerPrimitive.Overlay>) {\n return (\n <DrawerPrimitive.Overlay\n data-slot='drawer-overlay'\n className={cn(\n 'fixed inset-0 z-50 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',\n overlayScrim,\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DrawerContent({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof DrawerPrimitive.Content>) {\n return (\n <DrawerPortal data-slot='drawer-portal'>\n <DrawerOverlay />\n <DrawerPrimitive.Content\n data-slot='drawer-content'\n className={cn(\n 'group/drawer-content fixed z-50 flex h-auto flex-col bg-transparent p-2 text-xs/relaxed text-popover-foreground before:absolute before:inset-2 before:-z-10 before:rounded-md before:border before:border-border before:bg-popover data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:start-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:end-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=left]:sm:max-w-sm data-[vaul-drawer-direction=right]:sm:max-w-sm',\n className,\n )}\n {...props}\n >\n <div className='mx-auto mt-4 hidden h-1.5 w-[100px] shrink-0 rounded-full bg-muted group-data-[vaul-drawer-direction=bottom]/drawer-content:block' />\n {children}\n </DrawerPrimitive.Content>\n </DrawerPortal>\n )\n}\n\nfunction DrawerHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='drawer-header'\n className={cn(\n 'flex flex-col gap-1 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:text-start',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DrawerFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='drawer-footer'\n className={cn('mt-auto flex flex-col gap-2 p-4', className)}\n {...props}\n />\n )\n}\n\nfunction DrawerTitle({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Title>) {\n return (\n <DrawerPrimitive.Title\n data-slot='drawer-title'\n className={cn('text-sm font-medium text-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction DrawerDescription({\n className,\n ...props\n}: React.ComponentProps<typeof DrawerPrimitive.Description>) {\n return (\n <DrawerPrimitive.Description\n data-slot='drawer-description'\n className={cn('text-xs/relaxed text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nexport {\n Drawer,\n DrawerClose,\n DrawerContent,\n DrawerDescription,\n DrawerFooter,\n DrawerHeader,\n DrawerOverlay,\n DrawerPortal,\n DrawerTitle,\n DrawerTrigger,\n}\n"]}
@@ -64,7 +64,11 @@ const fieldVariants = cva(
64
64
  // `data-invalid:` (presence) matches the `data-invalid` attribute Base UI's
65
65
  // Field.Root sets when the field is invalid (via the `invalid` prop or native
66
66
  // validation) — replacing the old hand-set `data-[invalid=true]`.
67
- "group/field flex w-full gap-2 data-invalid:text-destructive",
67
+ //
68
+ // The invalid ink is `--danger-text`, not `text-destructive`: `--destructive`
69
+ // is the danger FILL, which measures 3.81:1 as text on the dark page (#253).
70
+ // The role token is the one made for text and flips with the theme.
71
+ "group/field flex w-full gap-2 data-invalid:text-(--danger-text)",
68
72
  {
69
73
  variants: {
70
74
  orientation: {
@@ -239,7 +243,7 @@ function FieldError({
239
243
  if (!content) {
240
244
  return null;
241
245
  }
242
- const errorClassName = cn("text-sm/relaxed font-normal text-destructive", className);
246
+ const errorClassName = cn("text-sm/relaxed font-normal text-(--danger-text)", className);
243
247
  if (!insideField) {
244
248
  return /* @__PURE__ */ jsx("div", { ref, role: "alert", "data-slot": "field-error", className: errorClassName, ...props, children: content });
245
249
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/field.tsx"],"names":["FieldPrimitive"],"mappings":";;;;;;;;AAuDA,MAAM,kBAAA,GAAqB,KAAA,CAAM,aAAA,CAAc,KAAK,CAAA;AAEpD,SAAS,SAAS,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAAqC;AAChF,EAAA,uBACE,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,WAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,kGAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,WAAA,CAAY;AAAA,EACnB,SAAA;AAAA,EACA,OAAA,GAAU,QAAA;AAAA,EACV,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAsE;AACpE,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,cAAA;AAAA,MACV,cAAA,EAAc,OAAA;AAAA,MACd,SAAA,EAAW,EAAA;AAAA,QACT,qFAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,WAAW,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAAgC;AAC7E,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,aAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA;AAAA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U,aAAA,EAAc,SAAA,EAAW,cAAA,EAAiB,GAAG,KAAA,EAChF,QAAA,EAAA,OAAA,EACH,CAAA;AAAA,EAEJ;AAEA,EAAA,uBACE,GAAA;AAAA,IAACA,OAAA,CAAe,KAAA;AAAA,IAAf;AAAA,MACC,GAAA;AAAA,MAKA,KAAA,EAAK,IAAA;AAAA,MACL,IAAA,EAAK,OAAA;AAAA,MACL,WAAA,EAAU,aAAA;AAAA,MACV,SAAA,EAAW,cAAA;AAAA,MACV,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"field.js","sourcesContent":["'use client'\n\nimport { Field as FieldPrimitive } from '@base-ui/react/field'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { Label } from '../components/label.js'\nimport { Separator } from '../components/separator.js'\nimport { cn } from '../lib/utils.js'\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Base UI Field\n// ─────────────────────────────────────────────────────────────────────────────\n//\n// `Field`, `FieldLabel`, `FieldDescription`, and `FieldError` wrap Base UI's\n// Field primitive (@base-ui/react/field). Base UI owns the accessible wiring:\n// the label is associated with the control, and any description/error ids are\n// added to the control's `aria-describedby` automatically — no manual\n// `htmlFor` / `aria-describedby` / `aria-invalid` plumbing required. Set\n// `invalid` on `Field` (e.g. from react-hook-form) and the control receives\n// `aria-invalid` and the wrapper gets `data-invalid` for free.\n//\n// Base UI's Field parts must live inside a `Field.Root`. To keep the previous\n// behaviour where a label/description/error could also be used standalone\n// (e.g. a group-level FieldDescription directly inside a FieldSet), FieldLabel/\n// FieldDescription/FieldError opt into the Base UI part only when they detect a\n// surrounding `Field` (via `InsideFieldContext`) and otherwise render the plain\n// element they did before. Inside a Field they gain the automatic association;\n// outside one they are unchanged.\n//\n// `FieldSet` / `FieldLegend` stay native `<fieldset>` / `<legend>` (already\n// accessible for grouping); `FieldGroup` / `FieldContent` / `FieldSeparator` /\n// `FieldTitle` remain layout-only primitives.\n//\n// ─────────────────────────────────────────────────────────────────────────────\n// Typography hierarchy (deliberate, do not collapse to a single size)\n// ─────────────────────────────────────────────────────────────────────────────\n//\n// FieldLabel inherits its font-size from the Label primitive (`text-base/\n// relaxed` = 16px) — the primary form text users read when scanning a form,\n// kept at the 16px ideal for body copy.\n// Every supporting element in this file uses `text-sm/relaxed` (14px). That\n// is below the 16px body-copy ideal but comfortably above the 12px floor\n// older versions used, so it still reads clearly as secondary information.\n// The 16/14 gap is intentional: it preserves a scannable visual hierarchy\n// (label > description / error / metadata) without shrinking supporting text\n// back down to the previous 12px.\n//\n// If you find yourself wanting to bump these to text-base, do it in\n// `label.tsx` so FieldLabel moves with the family. If you want to drop\n// them to text-xs, please raise that as a design decision — 12px is below\n// the NSW Government digital service standards minimum body-text size.\n// ─────────────────────────────────────────────────────────────────────────────\n\n// True for descendants of our <Field> (which renders Base UI's Field.Root).\nconst InsideFieldContext = React.createContext(false)\n\nfunction FieldSet({ className, ref, ...props }: React.ComponentProps<'fieldset'>) {\n return (\n <fieldset\n ref={ref}\n data-slot='field-set'\n className={cn(\n 'flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction FieldLegend({\n className,\n variant = 'legend',\n ref,\n ...props\n}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {\n return (\n <legend\n ref={ref}\n data-slot='field-legend'\n data-variant={variant}\n className={cn(\n 'mb-2 font-medium data-[variant=label]:text-sm/relaxed data-[variant=legend]:text-sm',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction FieldGroup({ className, ref, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n ref={ref}\n data-slot='field-group'\n className={cn(\n // `has-[>[data-slot=…]]:gap-3` matches when FieldGroup CONTAINS a\n // checkbox/radio group child. The original `data-[slot=checkbox-group]:gap-3`\n // was self-referential (this element's slot is `field-group`) and\n // could never apply. Mirrors the rule on FieldSet above.\n 'group/field-group @container/field-group flex w-full flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3 *:data-[slot=field-group]:gap-4',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldVariants = cva(\n // `data-invalid:` (presence) matches the `data-invalid` attribute Base UI's\n // Field.Root sets when the field is invalid (via the `invalid` prop or native\n // validation) — replacing the old hand-set `data-[invalid=true]`.\n 'group/field flex w-full gap-2 data-invalid:text-destructive',\n {\n variants: {\n orientation: {\n vertical: 'flex-col *:w-full [&>.sr-only]:w-auto',\n horizontal:\n 'flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n responsive:\n '@max-md/field-group:flex-col @max-md/field-group:*:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n },\n },\n)\n\nfunction Field({\n className,\n orientation = 'vertical',\n ref,\n children,\n ...props\n}: React.ComponentProps<typeof FieldPrimitive.Root> & VariantProps<typeof fieldVariants>) {\n return (\n <FieldPrimitive.Root\n ref={ref}\n // Preserve the explicit group role + data-orientation the layout and the\n // accessibility tests rely on; Base UI's Root renders a bare <div>.\n role='group'\n data-slot='field'\n data-orientation={orientation}\n className={cn(fieldVariants({ orientation }), className)}\n {...props}\n >\n <InsideFieldContext.Provider value={true}>{children}</InsideFieldContext.Provider>\n </FieldPrimitive.Root>\n )\n}\n\nfunction FieldContent({ className, ref, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n ref={ref}\n data-slot='field-content'\n className={cn('group/field-content flex flex-1 flex-col gap-0.5 leading-snug', className)}\n {...props}\n />\n )\n}\n\n// Radio/checkbox options need their own label scope inside a shared Field.\n// Base UI keeps the outer validation state while associating each option label.\nfunction FieldItem({ ref, ...props }: React.ComponentProps<typeof FieldPrimitive.Item>) {\n return <FieldPrimitive.Item ref={ref} data-slot='field-item' {...props} />\n}\n\nconst fieldLabelClassName = cn(\n 'group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-disabled/field:opacity-50 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-2 dark:has-data-checked:bg-primary/10',\n 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',\n)\n\nfunction FieldLabel({ className, ref, ...props }: React.ComponentProps<typeof Label>) {\n const insideField = React.useContext(InsideFieldContext)\n\n // Standalone (no surrounding Field): render the styled Label directly, as\n // before. Base UI's Field.Label would throw without a Field.Root ancestor.\n if (!insideField) {\n return (\n <Label\n ref={ref}\n data-slot='field-label'\n className={cn(fieldLabelClassName, className)}\n {...props}\n />\n )\n }\n\n return (\n <FieldPrimitive.Label\n // Base UI's Field.Label types its ref as HTMLElement (it can render a\n // non-label); here it always renders our <Label>, so the ref is an\n // HTMLLabelElement at runtime.\n ref={ref as React.Ref<HTMLElement>}\n // Render through our styled Label so FieldLabel keeps the Label\n // primitive's typography + data-slot, while Base UI supplies the\n // automatic `htmlFor` association with the field control.\n render={<Label />}\n data-slot='field-label'\n className={cn(fieldLabelClassName, className)}\n {...props}\n />\n )\n}\n\nfunction FieldTitle({ className, ref, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n ref={ref}\n data-slot='field-label'\n className={cn(\n 'flex w-fit items-center gap-2 text-sm/relaxed font-medium group-data-disabled/field:opacity-50',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldDescriptionClassName = cn(\n // `group-data-[orientation=horizontal]/field:` matches the\n // `data-orientation=\"horizontal\"` attribute Field emits.\n 'text-start text-sm/relaxed leading-normal font-normal text-muted-foreground group-data-[orientation=horizontal]/field:text-balance [[data-variant=legend]+&]:-mt-1.5',\n 'last:mt-0 nth-last-2:-mt-1',\n '[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',\n)\n\nfunction FieldDescription({ className, ref, ...props }: React.ComponentProps<'p'>) {\n const insideField = React.useContext(InsideFieldContext)\n\n // Standalone (e.g. a group-level description inside a FieldSet): a plain\n // <p>, as before. Inside a Field, Base UI links it to the control via\n // aria-describedby.\n if (!insideField) {\n return (\n <p\n ref={ref}\n data-slot='field-description'\n className={cn(fieldDescriptionClassName, className)}\n {...props}\n />\n )\n }\n\n return (\n <FieldPrimitive.Description\n ref={ref}\n data-slot='field-description'\n className={cn(fieldDescriptionClassName, className)}\n {...props}\n />\n )\n}\n\nfunction FieldSeparator({\n children,\n className,\n ref,\n ...props\n}: React.ComponentProps<'div'> & {\n children?: React.ReactNode\n}) {\n return (\n <div\n ref={ref}\n data-slot='field-separator'\n data-content={!!children}\n className={cn(\n 'relative -my-2 h-5 text-sm/relaxed group-data-[variant=outline]/field-group:-mb-2',\n className,\n )}\n {...props}\n >\n <Separator className='absolute inset-0 top-1/2' />\n {children && (\n <span\n className='relative mx-auto block w-fit bg-background px-2 text-muted-foreground'\n data-slot='field-separator-content'\n >\n {children}\n </span>\n )}\n </div>\n )\n}\n\nfunction FieldError({\n className,\n children,\n errors,\n ref,\n ...props\n}: React.ComponentProps<'div'> & {\n errors?: Array<{ message?: string } | undefined>\n}) {\n const insideField = React.useContext(InsideFieldContext)\n\n const content = React.useMemo(() => {\n if (children) {\n return children\n }\n\n if (!errors?.length) {\n return null\n }\n\n const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()]\n\n if (uniqueErrors?.length === 1) {\n return uniqueErrors[0]?.message\n }\n\n return (\n <ul className='ms-4 flex list-disc flex-col gap-1'>\n {uniqueErrors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}\n </ul>\n )\n }, [children, errors])\n\n if (!content) {\n return null\n }\n\n const errorClassName = cn('text-sm/relaxed font-normal text-destructive', className)\n\n // Standalone: a plain alert region, as before. Inside a Field, Base UI links\n // it to the control via aria-describedby.\n if (!insideField) {\n return (\n <div ref={ref} role='alert' data-slot='field-error' className={errorClassName} {...props}>\n {content}\n </div>\n )\n }\n\n return (\n <FieldPrimitive.Error\n ref={ref}\n // `match` lets the `errors` array / external library drive visibility\n // instead of the control's native ValidityState. We only render this when\n // there IS content, so force it visible; Base UI then adds its id to the\n // control's `aria-describedby`.\n match\n role='alert'\n data-slot='field-error'\n className={errorClassName}\n {...props}\n >\n {content}\n </FieldPrimitive.Error>\n )\n}\n\nexport {\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldItem,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldTitle,\n}\n\n// Derived prop types — exact component props for consumers wrapping these.\nexport type FieldProps = React.ComponentProps<typeof Field>\nexport type FieldSetProps = React.ComponentProps<typeof FieldSet>\nexport type FieldLegendProps = React.ComponentProps<typeof FieldLegend>\nexport type FieldGroupProps = React.ComponentProps<typeof FieldGroup>\nexport type FieldItemProps = React.ComponentProps<typeof FieldItem>\nexport type FieldContentProps = React.ComponentProps<typeof FieldContent>\nexport type FieldLabelProps = React.ComponentProps<typeof FieldLabel>\nexport type FieldTitleProps = React.ComponentProps<typeof FieldTitle>\nexport type FieldDescriptionProps = React.ComponentProps<typeof FieldDescription>\nexport type FieldSeparatorProps = React.ComponentProps<typeof FieldSeparator>\nexport type FieldErrorProps = React.ComponentProps<typeof FieldError>\n"]}
1
+ {"version":3,"sources":["../../src/components/field.tsx"],"names":["FieldPrimitive"],"mappings":";;;;;;;;AAuDA,MAAM,kBAAA,GAAqB,KAAA,CAAM,aAAA,CAAc,KAAK,CAAA;AAEpD,SAAS,SAAS,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAAqC;AAChF,EAAA,uBACE,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,WAAA;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AA,CAAE,QAAQ,CAAA;AAEzF,IAAA,IAAI,YAAA,EAAc,WAAW,CAAA,EAAG;AAC9B,MAAA,OAAO,YAAA,CAAa,CAAC,CAAA,EAAG,OAAA;AAAA,IAC1B;AAEA,IAAA,2BACG,IAAA,EAAA,EAAG,SAAA,EAAU,oCAAA,EACX,QAAA,EAAA,YAAA,CAAa,IAAI,CAAC,KAAA,EAAO,KAAA,KAAU,KAAA,EAAO,2BAAW,GAAA,CAAC,IAAA,EAAA,EAAgB,gBAAM,OAAA,EAAA,EAAd,KAAsB,CAAK,CAAA,EAC5F,CAAA;AAAA,EAEJ,CAAA,EAAG,CAAC,QAAA,EAAU,MAAM,CAAC,CAAA;AAErB,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,MAAM,cAAA,GAAiB,EAAA,CAAG,kDAAA,EAAoD,SAAS,CAAA;AAIvF,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA,uBACE,GAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAU,IAAA,EAAK,OAAA,EAAQ,WAAA,EAAU,aAAA,EAAc,SAAA,EAAW,cAAA,EAAiB,GAAG,KAAA,EAChF,QAAA,EAAA,OAAA,EACH,CAAA;AAAA,EAEJ;AAEA,EAAA,uBACE,GAAA;AAAA,IAACA,OAAA,CAAe,KAAA;AAAA,IAAf;AAAA,MACC,GAAA;AAAA,MAKA,KAAA,EAAK,IAAA;AAAA,MACL,IAAA,EAAK,OAAA;AAAA,MACL,WAAA,EAAU,aAAA;AAAA,MACV,SAAA,EAAW,cAAA;AAAA,MACV,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"field.js","sourcesContent":["'use client'\n\nimport { Field as FieldPrimitive } from '@base-ui/react/field'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { Label } from '../components/label.js'\nimport { Separator } from '../components/separator.js'\nimport { cn } from '../lib/utils.js'\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Base UI Field\n// ─────────────────────────────────────────────────────────────────────────────\n//\n// `Field`, `FieldLabel`, `FieldDescription`, and `FieldError` wrap Base UI's\n// Field primitive (@base-ui/react/field). Base UI owns the accessible wiring:\n// the label is associated with the control, and any description/error ids are\n// added to the control's `aria-describedby` automatically — no manual\n// `htmlFor` / `aria-describedby` / `aria-invalid` plumbing required. Set\n// `invalid` on `Field` (e.g. from react-hook-form) and the control receives\n// `aria-invalid` and the wrapper gets `data-invalid` for free.\n//\n// Base UI's Field parts must live inside a `Field.Root`. To keep the previous\n// behaviour where a label/description/error could also be used standalone\n// (e.g. a group-level FieldDescription directly inside a FieldSet), FieldLabel/\n// FieldDescription/FieldError opt into the Base UI part only when they detect a\n// surrounding `Field` (via `InsideFieldContext`) and otherwise render the plain\n// element they did before. Inside a Field they gain the automatic association;\n// outside one they are unchanged.\n//\n// `FieldSet` / `FieldLegend` stay native `<fieldset>` / `<legend>` (already\n// accessible for grouping); `FieldGroup` / `FieldContent` / `FieldSeparator` /\n// `FieldTitle` remain layout-only primitives.\n//\n// ─────────────────────────────────────────────────────────────────────────────\n// Typography hierarchy (deliberate, do not collapse to a single size)\n// ─────────────────────────────────────────────────────────────────────────────\n//\n// FieldLabel inherits its font-size from the Label primitive (`text-base/\n// relaxed` = 16px) — the primary form text users read when scanning a form,\n// kept at the 16px ideal for body copy.\n// Every supporting element in this file uses `text-sm/relaxed` (14px). That\n// is below the 16px body-copy ideal but comfortably above the 12px floor\n// older versions used, so it still reads clearly as secondary information.\n// The 16/14 gap is intentional: it preserves a scannable visual hierarchy\n// (label > description / error / metadata) without shrinking supporting text\n// back down to the previous 12px.\n//\n// If you find yourself wanting to bump these to text-base, do it in\n// `label.tsx` so FieldLabel moves with the family. If you want to drop\n// them to text-xs, please raise that as a design decision — 12px is below\n// the NSW Government digital service standards minimum body-text size.\n// ─────────────────────────────────────────────────────────────────────────────\n\n// True for descendants of our <Field> (which renders Base UI's Field.Root).\nconst InsideFieldContext = React.createContext(false)\n\nfunction FieldSet({ className, ref, ...props }: React.ComponentProps<'fieldset'>) {\n return (\n <fieldset\n ref={ref}\n data-slot='field-set'\n className={cn(\n 'flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction FieldLegend({\n className,\n variant = 'legend',\n ref,\n ...props\n}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {\n return (\n <legend\n ref={ref}\n data-slot='field-legend'\n data-variant={variant}\n className={cn(\n 'mb-2 font-medium data-[variant=label]:text-sm/relaxed data-[variant=legend]:text-sm',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction FieldGroup({ className, ref, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n ref={ref}\n data-slot='field-group'\n className={cn(\n // `has-[>[data-slot=…]]:gap-3` matches when FieldGroup CONTAINS a\n // checkbox/radio group child. The original `data-[slot=checkbox-group]:gap-3`\n // was self-referential (this element's slot is `field-group`) and\n // could never apply. Mirrors the rule on FieldSet above.\n 'group/field-group @container/field-group flex w-full flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3 *:data-[slot=field-group]:gap-4',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldVariants = cva(\n // `data-invalid:` (presence) matches the `data-invalid` attribute Base UI's\n // Field.Root sets when the field is invalid (via the `invalid` prop or native\n // validation) — replacing the old hand-set `data-[invalid=true]`.\n //\n // The invalid ink is `--danger-text`, not `text-destructive`: `--destructive`\n // is the danger FILL, which measures 3.81:1 as text on the dark page (#253).\n // The role token is the one made for text and flips with the theme.\n 'group/field flex w-full gap-2 data-invalid:text-(--danger-text)',\n {\n variants: {\n orientation: {\n vertical: 'flex-col *:w-full [&>.sr-only]:w-auto',\n horizontal:\n 'flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n responsive:\n '@max-md/field-group:flex-col @max-md/field-group:*:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n },\n },\n)\n\nfunction Field({\n className,\n orientation = 'vertical',\n ref,\n children,\n ...props\n}: React.ComponentProps<typeof FieldPrimitive.Root> & VariantProps<typeof fieldVariants>) {\n return (\n <FieldPrimitive.Root\n ref={ref}\n // Preserve the explicit group role + data-orientation the layout and the\n // accessibility tests rely on; Base UI's Root renders a bare <div>.\n role='group'\n data-slot='field'\n data-orientation={orientation}\n className={cn(fieldVariants({ orientation }), className)}\n {...props}\n >\n <InsideFieldContext.Provider value={true}>{children}</InsideFieldContext.Provider>\n </FieldPrimitive.Root>\n )\n}\n\nfunction FieldContent({ className, ref, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n ref={ref}\n data-slot='field-content'\n className={cn('group/field-content flex flex-1 flex-col gap-0.5 leading-snug', className)}\n {...props}\n />\n )\n}\n\n// Radio/checkbox options need their own label scope inside a shared Field.\n// Base UI keeps the outer validation state while associating each option label.\nfunction FieldItem({ ref, ...props }: React.ComponentProps<typeof FieldPrimitive.Item>) {\n return <FieldPrimitive.Item ref={ref} data-slot='field-item' {...props} />\n}\n\nconst fieldLabelClassName = cn(\n 'group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-disabled/field:opacity-50 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-2 dark:has-data-checked:bg-primary/10',\n 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',\n)\n\nfunction FieldLabel({ className, ref, ...props }: React.ComponentProps<typeof Label>) {\n const insideField = React.useContext(InsideFieldContext)\n\n // Standalone (no surrounding Field): render the styled Label directly, as\n // before. Base UI's Field.Label would throw without a Field.Root ancestor.\n if (!insideField) {\n return (\n <Label\n ref={ref}\n data-slot='field-label'\n className={cn(fieldLabelClassName, className)}\n {...props}\n />\n )\n }\n\n return (\n <FieldPrimitive.Label\n // Base UI's Field.Label types its ref as HTMLElement (it can render a\n // non-label); here it always renders our <Label>, so the ref is an\n // HTMLLabelElement at runtime.\n ref={ref as React.Ref<HTMLElement>}\n // Render through our styled Label so FieldLabel keeps the Label\n // primitive's typography + data-slot, while Base UI supplies the\n // automatic `htmlFor` association with the field control.\n render={<Label />}\n data-slot='field-label'\n className={cn(fieldLabelClassName, className)}\n {...props}\n />\n )\n}\n\nfunction FieldTitle({ className, ref, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n ref={ref}\n data-slot='field-label'\n className={cn(\n 'flex w-fit items-center gap-2 text-sm/relaxed font-medium group-data-disabled/field:opacity-50',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldDescriptionClassName = cn(\n // `group-data-[orientation=horizontal]/field:` matches the\n // `data-orientation=\"horizontal\"` attribute Field emits.\n 'text-start text-sm/relaxed leading-normal font-normal text-muted-foreground group-data-[orientation=horizontal]/field:text-balance [[data-variant=legend]+&]:-mt-1.5',\n 'last:mt-0 nth-last-2:-mt-1',\n '[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',\n)\n\nfunction FieldDescription({ className, ref, ...props }: React.ComponentProps<'p'>) {\n const insideField = React.useContext(InsideFieldContext)\n\n // Standalone (e.g. a group-level description inside a FieldSet): a plain\n // <p>, as before. Inside a Field, Base UI links it to the control via\n // aria-describedby.\n if (!insideField) {\n return (\n <p\n ref={ref}\n data-slot='field-description'\n className={cn(fieldDescriptionClassName, className)}\n {...props}\n />\n )\n }\n\n return (\n <FieldPrimitive.Description\n ref={ref}\n data-slot='field-description'\n className={cn(fieldDescriptionClassName, className)}\n {...props}\n />\n )\n}\n\nfunction FieldSeparator({\n children,\n className,\n ref,\n ...props\n}: React.ComponentProps<'div'> & {\n children?: React.ReactNode\n}) {\n return (\n <div\n ref={ref}\n data-slot='field-separator'\n data-content={!!children}\n className={cn(\n 'relative -my-2 h-5 text-sm/relaxed group-data-[variant=outline]/field-group:-mb-2',\n className,\n )}\n {...props}\n >\n <Separator className='absolute inset-0 top-1/2' />\n {children && (\n <span\n className='relative mx-auto block w-fit bg-background px-2 text-muted-foreground'\n data-slot='field-separator-content'\n >\n {children}\n </span>\n )}\n </div>\n )\n}\n\nfunction FieldError({\n className,\n children,\n errors,\n ref,\n ...props\n}: React.ComponentProps<'div'> & {\n errors?: Array<{ message?: string } | undefined>\n}) {\n const insideField = React.useContext(InsideFieldContext)\n\n const content = React.useMemo(() => {\n if (children) {\n return children\n }\n\n if (!errors?.length) {\n return null\n }\n\n const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()]\n\n if (uniqueErrors?.length === 1) {\n return uniqueErrors[0]?.message\n }\n\n return (\n <ul className='ms-4 flex list-disc flex-col gap-1'>\n {uniqueErrors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}\n </ul>\n )\n }, [children, errors])\n\n if (!content) {\n return null\n }\n\n // The danger text role, for the same reason as the invalid label above.\n const errorClassName = cn('text-sm/relaxed font-normal text-(--danger-text)', className)\n\n // Standalone: a plain alert region, as before. Inside a Field, Base UI links\n // it to the control via aria-describedby.\n if (!insideField) {\n return (\n <div ref={ref} role='alert' data-slot='field-error' className={errorClassName} {...props}>\n {content}\n </div>\n )\n }\n\n return (\n <FieldPrimitive.Error\n ref={ref}\n // `match` lets the `errors` array / external library drive visibility\n // instead of the control's native ValidityState. We only render this when\n // there IS content, so force it visible; Base UI then adds its id to the\n // control's `aria-describedby`.\n match\n role='alert'\n data-slot='field-error'\n className={errorClassName}\n {...props}\n >\n {content}\n </FieldPrimitive.Error>\n )\n}\n\nexport {\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldItem,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldTitle,\n}\n\n// Derived prop types — exact component props for consumers wrapping these.\nexport type FieldProps = React.ComponentProps<typeof Field>\nexport type FieldSetProps = React.ComponentProps<typeof FieldSet>\nexport type FieldLegendProps = React.ComponentProps<typeof FieldLegend>\nexport type FieldGroupProps = React.ComponentProps<typeof FieldGroup>\nexport type FieldItemProps = React.ComponentProps<typeof FieldItem>\nexport type FieldContentProps = React.ComponentProps<typeof FieldContent>\nexport type FieldLabelProps = React.ComponentProps<typeof FieldLabel>\nexport type FieldTitleProps = React.ComponentProps<typeof FieldTitle>\nexport type FieldDescriptionProps = React.ComponentProps<typeof FieldDescription>\nexport type FieldSeparatorProps = React.ComponentProps<typeof FieldSeparator>\nexport type FieldErrorProps = React.ComponentProps<typeof FieldError>\n"]}