{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-form-group",
  "type": "registry:ui",
  "title": "react-tw/form-group.tsx",
  "description": "Carbon `FormGroup` as a React + Tailwind component, the look and rules of `<ui-form-group>`: a Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [],
  "registryDependencies": [
    "@kanok-ui/tw-field",
    "@kanok-ui/tw-theme",
    "@kanok-ui/tw-utils"
  ],
  "files": [
    {
      "path": "src/react-tw/form-group.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/form-group.tsx",
      "content": "import { useId, type ReactNode, type ComponentProps } from 'react';\nimport { GroupDisabledProvider, fieldLabelClasses, useFieldDisabled } from './field.tsx';\nimport { cn } from './lib/utils.ts';\n\nexport interface FormGroupProps extends Omit<ComponentProps<'fieldset'>, 'legend' | 'disabled' | 'invalid' | 'message' | 'className' | 'children'> {\n    /** The group's label (the fieldset's legend). */\n    legend: ReactNode;\n    /** Disables every field inside: native controls through the fieldset, the React fields through context. */\n    disabled?: boolean;\n    invalid?: boolean;\n    /** Helper / error text under the group. */\n    message?: ReactNode;\n    className?: string;\n    /** The fields. */\n    children?: ReactNode;\n}\n\n/**\n * Carbon `FormGroup` as a React + Tailwind component, the look and rules of `<ui-form-group>`: a\n * `<fieldset>` with a Carbon label as its legend, for related fields (an address, a date range).\n * `disabled` disables every field inside; `message` shows under the group, red when `invalid`.\n */\nexport function FormGroup({ legend, disabled: ownDisabled, invalid = false, message, className, children, ...rest }: Readonly<FormGroupProps>) {\n    const disabled = useFieldDisabled(ownDisabled);\n    const id = useId();\n    return (\n        <fieldset {...rest} disabled={disabled} aria-invalid={invalid || undefined} aria-describedby={message ? `${id}-message` : undefined} className={cn('m-0 block min-w-0 border-0 p-0 font-sans', className)}>\n            <legend id={`${id}-legend`} className={cn(fieldLabelClasses, 'p-0', disabled && 'text-ink-disabled')}>\n                {legend}\n            </legend>\n            <GroupDisabledProvider value={disabled}>{children}</GroupDisabledProvider>\n            {message ? (\n                <div id={`${id}-message`} className={cn('mt-2 text-ink-muted type-caption', invalid && 'text-error-text', disabled && 'text-ink-disabled')}>\n                    {message}\n                </div>\n            ) : null}\n        </fieldset>\n    );\n}\n"
    }
  ]
}
