/** * The wrapper around a nested group of fields (object, array, or union). At the * form root it lays children out in a plain stack; below the root it renders a * heading, an optional description, an optional error — the ERROR mark beside * the message, never a hue on its own — and the nested group surface. */ import type { ReactNode } from 'react'; import { useId } from 'react'; import { XCircleIcon } from '../components/icons'; import { groupClass, groupHeaderClass, stackClass } from './styles'; export function FieldGroup({ heading, description, error, atRoot, children, }: { heading: string; description: string | undefined; error: string | undefined; atRoot: boolean; children: ReactNode; }): ReactNode { const baseId = useId(); const headingId = `${baseId}-heading`; const descriptionId = `${baseId}-desc`; const errorId = `${baseId}-err`; if (atRoot) { return