{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "retro-field",
  "title": "RetroField",
  "description": "Mac OS 9 form layout primitives with shadcn Field API parity: RetroField (vertical/horizontal/responsive), RetroFieldLabel, RetroFieldDescription, RetroFieldError, RetroFieldGroup, RetroFieldSet (plain or etched OS9 group box), RetroFieldLegend, RetroFieldSeparator, RetroFieldContent and RetroFieldTitle. No form-library dependency.",
  "dependencies": [
    "class-variance-authority"
  ],
  "registryDependencies": [
    "https://nostalgia-ui.com/r/nostalgia-theme.json",
    "https://nostalgia-ui.com/r/retro-label.json"
  ],
  "files": [
    {
      "path": "registry/new-york/ui/retro-field.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\nimport { RetroLabel } from \"@/registry/new-york/ui/retro-label\"\n\n/* ------------------------------------------------------------------ */\n/*  RetroFieldSet                                                      */\n/* ------------------------------------------------------------------ */\n\nconst retroFieldSetVariants = cva(\n  [\"flex min-w-0 flex-col gap-[12px]\", \"text-os9-black\"],\n  {\n    variants: {\n      variant: {\n        /** Plain grouping, no chrome. */\n        default: \"border-0 p-0 m-0\",\n        /**\n         * Classic OS9 group box: an etched (gray + white) 1px frame with the\n         * legend sitting on the top edge.\n         */\n        group: [\n          \"m-0 px-[10px] pb-[10px] pt-[6px]\",\n          \"border border-os9-gray-700\",\n          \"shadow-[1px_1px_0_var(--os9-white),inset_1px_1px_0_var(--os9-white)]\",\n        ],\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n    },\n  }\n)\n\ntype RetroFieldSetProps = React.ComponentProps<\"fieldset\"> &\n  VariantProps<typeof retroFieldSetVariants>\n\nconst RetroFieldSet = React.forwardRef<HTMLFieldSetElement, RetroFieldSetProps>(\n  function RetroFieldSet({ className, variant, ...props }, ref) {\n    return (\n      <fieldset\n        ref={ref}\n        data-slot=\"field-set\"\n        data-variant={variant ?? \"default\"}\n        className={cn(\n          retroFieldSetVariants({ variant }),\n          \"has-[>[data-slot=checkbox-group]]:gap-[6px] has-[>[data-slot=radio-group]]:gap-[6px]\",\n          \"disabled:opacity-50\",\n          className\n        )}\n        {...props}\n      />\n    )\n  }\n)\nRetroFieldSet.displayName = \"RetroFieldSet\"\n\n/* ------------------------------------------------------------------ */\n/*  RetroFieldLegend                                                   */\n/* ------------------------------------------------------------------ */\n\ntype RetroFieldLegendProps = React.ComponentProps<\"legend\"> & {\n  variant?: \"legend\" | \"label\"\n}\n\nconst RetroFieldLegend = React.forwardRef<\n  HTMLLegendElement,\n  RetroFieldLegendProps\n>(function RetroFieldLegend({ className, variant = \"legend\", ...props }, ref) {\n  return (\n    <legend\n      ref={ref}\n      data-slot=\"field-legend\"\n      data-variant={variant}\n      className={cn(\n        \"mb-[8px] p-0 text-os9-black\",\n        \"font-[family-name:var(--os9-font-heading)] tracking-[0.42px] leading-[0.98]\",\n        \"data-[variant=legend]:text-[12px] data-[variant=label]:text-[10px]\",\n        // Inside a group box the legend sits on the frame, knocked out of it.\n        \"[[data-variant=group]>&]:mb-0 [[data-variant=group]>&]:-ml-[4px] [[data-variant=group]>&]:bg-os9-gray-200 [[data-variant=group]>&]:px-[4px]\",\n        className\n      )}\n      {...props}\n    />\n  )\n})\nRetroFieldLegend.displayName = \"RetroFieldLegend\"\n\n/* ------------------------------------------------------------------ */\n/*  RetroFieldGroup                                                    */\n/* ------------------------------------------------------------------ */\n\nconst RetroFieldGroup = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(function RetroFieldGroup({ className, ...props }, ref) {\n  return (\n    <div\n      ref={ref}\n      data-slot=\"field-group\"\n      className={cn(\n        \"group/field-group @container/field-group flex w-full flex-col gap-[14px]\",\n        \"data-[slot=checkbox-group]:gap-[6px]\",\n        \"[&>[data-slot=field-group]]:gap-[8px]\",\n        className\n      )}\n      {...props}\n    />\n  )\n})\nRetroFieldGroup.displayName = \"RetroFieldGroup\"\n\n/* ------------------------------------------------------------------ */\n/*  RetroField                                                         */\n/* ------------------------------------------------------------------ */\n\nconst retroFieldVariants = cva(\n  [\n    \"group/field flex w-full gap-[6px]\",\n    \"text-os9-black\",\n    \"data-[invalid=true]:text-[#cc0000]\",\n  ],\n  {\n    variants: {\n      orientation: {\n        vertical: [\"flex-col\", \"[&>*]:w-full [&>.sr-only]:w-auto\"],\n        horizontal: [\n          \"flex-row items-center gap-[8px]\",\n          \"[&>[data-field-label]]:flex-auto\",\n          \"has-[>[data-slot=field-content]]:items-start\",\n          \"has-[>[data-slot=field-content]]:[&>[role=checkbox]]:mt-[1px]\",\n        ],\n        responsive: [\n          \"flex-col [&>*]:w-full [&>.sr-only]:w-auto\",\n          \"@md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto\",\n          \"@md/field-group:[&>[data-field-label]]:flex-auto\",\n          \"@md/field-group:has-[>[data-slot=field-content]]:items-start\",\n        ],\n      },\n    },\n    defaultVariants: {\n      orientation: \"vertical\",\n    },\n  }\n)\n\ntype RetroFieldProps = React.ComponentProps<\"div\"> &\n  VariantProps<typeof retroFieldVariants>\n\nconst RetroField = React.forwardRef<HTMLDivElement, RetroFieldProps>(\n  function RetroField({ className, orientation = \"vertical\", ...props }, ref) {\n    return (\n      <div\n        ref={ref}\n        role=\"group\"\n        data-slot=\"field\"\n        data-orientation={orientation}\n        className={cn(retroFieldVariants({ orientation }), className)}\n        {...props}\n      />\n    )\n  }\n)\nRetroField.displayName = \"RetroField\"\n\n/* ------------------------------------------------------------------ */\n/*  RetroFieldContent                                                  */\n/* ------------------------------------------------------------------ */\n\nconst RetroFieldContent = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(function RetroFieldContent({ className, ...props }, ref) {\n  return (\n    <div\n      ref={ref}\n      data-slot=\"field-content\"\n      className={cn(\n        \"group/field-content flex min-w-0 flex-1 flex-col gap-[3px] leading-snug\",\n        className\n      )}\n      {...props}\n    />\n  )\n})\nRetroFieldContent.displayName = \"RetroFieldContent\"\n\n/* ------------------------------------------------------------------ */\n/*  RetroFieldLabel                                                    */\n/* ------------------------------------------------------------------ */\n\nconst RetroFieldLabel = React.forwardRef<\n  React.ComponentRef<typeof RetroLabel>,\n  React.ComponentPropsWithoutRef<typeof RetroLabel>\n>(function RetroFieldLabel({ className, ...props }, ref) {\n  return (\n    <RetroLabel\n      ref={ref}\n      data-slot=\"field-label\"\n      /* UI SDK's Label owns data-slot (\"label\"); this marker survives */\n      data-field-label=\"\"\n      className={cn(\n        \"group/field-label peer/field-label flex w-fit items-center gap-[6px] leading-snug\",\n        \"group-data-[invalid=true]/field:text-[#cc0000]\",\n        \"group-data-[disabled=true]/field:opacity-50\",\n        // A label wrapping a whole <RetroField> becomes a selectable option card.\n        \"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col\",\n        \"has-[>[data-slot=field]]:border has-[>[data-slot=field]]:border-os9-black\",\n        \"has-[>[data-slot=field]]:bg-os9-gray-300\",\n        \"has-[>[data-slot=field]]:shadow-[inset_1px_1px_0_var(--os9-white),inset_-1px_-1px_0_var(--os9-gray-700)]\",\n        \"[&>*]:data-[slot=field]:p-[8px]\",\n        \"has-[[data-checked]]:bg-os9-lavender!\",\n        className\n      )}\n      {...props}\n    />\n  )\n})\nRetroFieldLabel.displayName = \"RetroFieldLabel\"\n\n/* ------------------------------------------------------------------ */\n/*  RetroFieldTitle                                                    */\n/* ------------------------------------------------------------------ */\n\nconst RetroFieldTitle = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(function RetroFieldTitle({ className, ...props }, ref) {\n  return (\n    <div\n      ref={ref}\n      data-slot=\"field-label\"\n      className={cn(\n        \"flex w-fit items-center gap-[6px]\",\n        \"font-[family-name:var(--os9-font-heading)] text-[12px] tracking-[0.42px] leading-[0.98]\",\n        \"group-data-[disabled=true]/field:opacity-50\",\n        className\n      )}\n      {...props}\n    />\n  )\n})\nRetroFieldTitle.displayName = \"RetroFieldTitle\"\n\n/* ------------------------------------------------------------------ */\n/*  RetroFieldDescription                                              */\n/* ------------------------------------------------------------------ */\n\nconst RetroFieldDescription = React.forwardRef<\n  HTMLParagraphElement,\n  React.ComponentProps<\"p\">\n>(function RetroFieldDescription({ className, ...props }, ref) {\n  return (\n    <p\n      ref={ref}\n      data-slot=\"field-description\"\n      className={cn(\n        \"font-[family-name:var(--os9-font-sans)] text-[9px] leading-[1.4] text-os9-gray-700\",\n        \"group-has-[[data-orientation=horizontal]]/field:text-balance\",\n        \"last:mt-0 nth-last-2:-mt-[2px]\",\n        \"[&>a]:underline [&>a]:underline-offset-2 [&>a:hover]:text-os9-azul\",\n        className\n      )}\n      {...props}\n    />\n  )\n})\nRetroFieldDescription.displayName = \"RetroFieldDescription\"\n\n/* ------------------------------------------------------------------ */\n/*  RetroFieldSeparator                                                */\n/* ------------------------------------------------------------------ */\n\nconst RetroFieldSeparator = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(function RetroFieldSeparator({ children, className, ...props }, ref) {\n  return (\n    <div\n      ref={ref}\n      data-slot=\"field-separator\"\n      data-content={!!children}\n      className={cn(\n        \"relative -my-[4px] flex h-[14px] items-center\",\n        \"font-[family-name:var(--os9-font-sans)] text-[9px]\",\n        className\n      )}\n      {...props}\n    >\n      {/* 2px etched line: dark over light */}\n      <div\n        aria-hidden\n        className=\"absolute inset-x-0 top-1/2 h-[2px] -translate-y-1/2 border-t border-os9-gray-700 border-b border-b-os9-white\"\n      />\n      {children && (\n        <span\n          data-slot=\"field-separator-content\"\n          className=\"relative mx-auto block bg-os9-gray-200 px-[6px] text-os9-gray-700\"\n        >\n          {children}\n        </span>\n      )}\n    </div>\n  )\n})\nRetroFieldSeparator.displayName = \"RetroFieldSeparator\"\n\n/* ------------------------------------------------------------------ */\n/*  RetroFieldError                                                    */\n/* ------------------------------------------------------------------ */\n\ntype RetroFieldErrorProps = React.ComponentProps<\"div\"> & {\n  /** Accepts the shape produced by most validators: `{ message?: string }`. */\n  errors?: Array<{ message?: string } | undefined>\n}\n\nconst RetroFieldError = React.forwardRef<HTMLDivElement, RetroFieldErrorProps>(\n  function RetroFieldError({ className, children, errors, ...props }, ref) {\n    let content: React.ReactNode = children\n\n    if (!content && errors?.length) {\n      const messages = [\n        ...new Set(errors.map((error) => error?.message).filter(Boolean)),\n      ] as string[]\n\n      if (messages.length === 1) {\n        content = messages[0]\n      } else if (messages.length > 1) {\n        content = (\n          <ul className=\"ml-[12px] flex list-disc flex-col gap-[2px]\">\n            {messages.map((message) => (\n              <li key={message}>{message}</li>\n            ))}\n          </ul>\n        )\n      }\n    }\n\n    if (!content) {\n      return null\n    }\n\n    return (\n      <div\n        ref={ref}\n        role=\"alert\"\n        data-slot=\"field-error\"\n        className={cn(\n          \"font-[family-name:var(--os9-font-sans)] text-[10px] font-bold text-[#cc0000]\",\n          className\n        )}\n        {...props}\n      >\n        {content}\n      </div>\n    )\n  }\n)\nRetroFieldError.displayName = \"RetroFieldError\"\n\n/* ------------------------------------------------------------------ */\n/*  Exports                                                            */\n/* ------------------------------------------------------------------ */\n\nexport {\n  RetroField,\n  RetroFieldLabel,\n  RetroFieldDescription,\n  RetroFieldError,\n  RetroFieldGroup,\n  RetroFieldLegend,\n  RetroFieldSeparator,\n  RetroFieldSet,\n  RetroFieldContent,\n  RetroFieldTitle,\n  retroFieldVariants,\n  retroFieldSetVariants,\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}