{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "field",
  "type": "registry:ui",
  "registryDependencies": [
    "@gc-solid/label",
    "@gc-solid/separator"
  ],
  "files": [
    {
      "path": "ui/field.tsx",
      "content": "import {\n  type Component,\n  type ComponentProps,\n  createMemo,\n  For,\n  mergeProps,\n  Show,\n  splitProps\n} from \"solid-js\"\n\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Label } from \"@/components/ui/label\"\nimport { Separator } from \"@/components/ui/separator\"\n\nconst FieldSet: Component<ComponentProps<\"fieldset\">> = (props) => {\n  const [local, others] = splitProps(props, [\"class\"])\n  return (\n    <fieldset\n      class={cn(\n        \"flex flex-col gap-6\",\n        \"has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3\",\n        local.class\n      )}\n      data-slot=\"field-set\"\n      {...others}\n    />\n  )\n}\n\ntype FieldLegendProps = ComponentProps<\"legend\"> & {\n  variant?: \"legend\" | \"label\"\n}\n\nconst FieldLegend: Component<FieldLegendProps> = (props) => {\n  const [local, others] = splitProps(props, [\"class\", \"variant\"])\n  return (\n    <legend\n      class={cn(\n        \"mb-3 font-medium\",\n        \"data-[variant=legend]:text-base\",\n        \"data-[variant=label]:text-sm\",\n        local.class\n      )}\n      data-slot=\"field-legend\"\n      data-variant={local.variant}\n      {...others}\n    />\n  )\n}\n\nconst FieldGroup: Component<ComponentProps<\"div\">> = (props) => {\n  const [local, others] = splitProps(props, [\"class\"])\n  return (\n    <div\n      class={cn(\n        \"group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4\",\n        local.class\n      )}\n      data-slot=\"field-group\"\n      {...others}\n    />\n  )\n}\n\nconst fieldVariants = cva(\"group/field flex w-full gap-3 data-[invalid=true]:text-destructive\", {\n  variants: {\n    orientation: {\n      vertical: [\"flex-col [&>*]:w-full [&>.sr-only]:w-auto\"],\n      horizontal: [\n        \"flex-row items-center\",\n        \"[&>[data-slot=field-label]]:flex-auto\",\n        \"has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px\"\n      ],\n      responsive: [\n        \"@md/field-group:flex-row flex-col @md/field-group:items-center @md/field-group:[&>*]:w-auto [&>*]:w-full [&>.sr-only]:w-auto\",\n        \"@md/field-group:[&>[data-slot=field-label]]:flex-auto\",\n        \"@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px\"\n      ]\n    }\n  },\n  defaultVariants: {\n    orientation: \"vertical\"\n  }\n})\n\ntype FieldProps = ComponentProps<\"div\"> & VariantProps<typeof fieldVariants>\n\nconst Field: Component<FieldProps> = (rawProps) => {\n  const props = mergeProps<FieldProps[]>({ orientation: \"vertical\" }, rawProps)\n  const [local, others] = splitProps(props, [\"class\", \"orientation\"])\n  return (\n    <div\n      class={cn(fieldVariants({ orientation: local.orientation }), local.class)}\n      data-orientation={local.orientation}\n      data-slot=\"field\"\n      role=\"group\"\n      {...others}\n    />\n  )\n}\n\nconst FieldContent: Component<ComponentProps<\"div\">> = (props) => {\n  const [local, others] = splitProps(props, [\"class\"])\n  return (\n    <div\n      class={cn(\"group/field-content flex flex-1 flex-col gap-1.5 leading-snug\", local.class)}\n      data-slot=\"field-content\"\n      {...others}\n    />\n  )\n}\n\nconst FieldLabel: Component<ComponentProps<typeof Label>> = (props) => {\n  const [local, others] = splitProps(props, [\"class\"])\n  return (\n    <Label\n      class={cn(\n        \"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled]/field:opacity-50\",\n        \"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4\",\n        \"has-data-[checked]:border-primary has-data-[checked]:bg-primary/5 dark:has-data-[checked]:bg-primary/10\",\n        local.class\n      )}\n      data-slot=\"field-label\"\n      {...others}\n    />\n  )\n}\n\nconst FieldTitle: Component<ComponentProps<\"div\">> = (props) => {\n  const [local, others] = splitProps(props, [\"class\"])\n  return (\n    <div\n      class={cn(\n        \"flex w-fit items-center gap-2 font-medium text-sm leading-snug group-data-[disabled]/field:opacity-50\",\n        local.class\n      )}\n      data-slot=\"field-label\"\n      {...others}\n    />\n  )\n}\n\nconst FieldDescription: Component<ComponentProps<\"p\">> = (props) => {\n  const [local, others] = splitProps(props, [\"class\"])\n  return (\n    <p\n      class={cn(\n        \"font-normal text-muted-foreground text-sm leading-normal group-has-[[data-orientation=horizontal]]/field:text-balance\",\n        \"nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5 last:mt-0\",\n        \"[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4\",\n        local.class\n      )}\n      data-slot=\"field-description\"\n      {...others}\n    />\n  )\n}\n\nconst FieldSeparator: Component<ComponentProps<\"div\">> = (props) => {\n  const [local, others] = splitProps(props, [\"class\", \"children\"])\n  return (\n    <div\n      class={cn(\n        \"-my-2 group-data-[variant=outline]/field-group:-mb-2 relative h-5 text-sm\",\n        local.class\n      )}\n      data-content={!!local.children}\n      data-slot=\"field-separator\"\n      {...others}\n    >\n      <Separator class=\"absolute inset-0 top-1/2\" />\n      {local.children && (\n        <span\n          class=\"relative mx-auto block w-fit bg-background px-2 text-muted-foreground\"\n          data-slot=\"field-separator-content\"\n        >\n          {local.children}\n        </span>\n      )}\n    </div>\n  )\n}\n\ntype FieldErrorProps = ComponentProps<\"div\"> & {\n  errors?: Array<{ message?: string } | undefined>\n}\n\nconst FieldError: Component<FieldErrorProps> = (props) => {\n  const [local, others] = splitProps(props, [\"class\", \"children\", \"errors\"])\n\n  const content = createMemo(() => {\n    if (local.children) {\n      return local.children\n    }\n\n    if (!local.errors?.length) {\n      return null\n    }\n\n    const uniqueErrors = [...new Map(local.errors.map((error) => [error?.message, error])).values()]\n\n    if (uniqueErrors?.length === 1) {\n      return uniqueErrors[0]?.message\n    }\n\n    return (\n      <ul class=\"ml-4 flex list-disc flex-col gap-1\">\n        <For each={uniqueErrors}>\n          {(error) => <Show when={error?.message}>{(message) => <li>{message()}</li>}</Show>}\n        </For>\n      </ul>\n    )\n  })\n\n  return (\n    <Show when={content()}>\n      {(content) => (\n        <div\n          class={cn(\"font-normal text-destructive text-sm\", local.class)}\n          data-slot=\"field-error\"\n          role=\"alert\"\n          {...others}\n        >\n          {content()}\n        </div>\n      )}\n    </Show>\n  )\n}\n\nexport {\n  Field,\n  FieldLabel,\n  FieldDescription,\n  FieldError,\n  FieldGroup,\n  FieldLegend,\n  FieldSeparator,\n  FieldSet,\n  FieldContent,\n  FieldTitle\n}\n",
      "type": "registry:ui"
    }
  ]
}