{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "fieldset",
  "title": "Fieldset",
  "description": "A grouped form section on the native fieldset: the legend sits in a notch in the border, the group folds away to a one-line summary, a tick appears once it's complete, an error outlines it in coral, and disabling it disables every control inside.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/fieldset/fieldset.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface FieldsetProps {\n  legend?: string;\n  description?: string;\n  children?: React.ReactNode;\n  /** Let people fold the group away to its legend (and summary). */\n  collapsible?: boolean;\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  /** Shown beside the legend while collapsed, e.g. what was filled in. */\n  summary?: React.ReactNode;\n  /** Disables every control inside (native fieldset behaviour). */\n  disabled?: boolean;\n  /** Marks the group invalid and shows this message under it. */\n  error?: string;\n  /** A small tick in the legend once the group is complete. */\n  complete?: boolean;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.55)\", border: \"rgba(255,255,255,0.12)\", borderHover: \"rgba(255,255,255,0.22)\", panel: \"#0E0E0E\", error: \"#FF7A6B\", done: \"#3FBF7F\", input: \"rgba(255,255,255,0.03)\", focus: \"rgba(245,244,241,0.85)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.55)\", border: \"rgba(10,10,10,0.14)\", borderHover: \"rgba(10,10,10,0.26)\", panel: \"#FFFFFF\", error: \"#E5484D\", done: \"#1F9D5C\", input: \"#FFFFFF\", focus: \"rgba(10,10,10,0.85)\" },\n};\n\nfunction DemoField({ label, value, type = \"text\", p }: { label: string; value: string; type?: string; p: (typeof PALETTES)[\"dark\"] }) {\n  const id = React.useId();\n  return (\n    <div className=\"flex flex-col\" style={{ gap: 6 }}>\n      <label htmlFor={id} className=\"text-[13px] font-medium\" style={{ color: p.text }}>\n        {label}\n      </label>\n      <input id={id} type={type} defaultValue={value} className=\"h-10 w-full rounded-xl px-3 text-[14px] outline-none focus-visible:ring-2 disabled:opacity-50\" style={{ background: p.input, border: `1px solid ${p.border}`, color: p.text, [\"--tw-ring-color\" as string]: p.focus }} />\n    </div>\n  );\n}\n\nexport function Fieldset({ legend = \"Account details\", description = \"Used on receipts and when we need to reach you.\", children, collapsible = true, open, defaultOpen = true, onOpenChange, summary, disabled = false, error, complete = false, theme = \"dark\", className }: FieldsetProps) {\n  const p = PALETTES[theme];\n  const reduce = Boolean(useReducedMotion());\n  const uid = React.useId();\n  const [internal, setInternal] = React.useState(defaultOpen);\n  const isOpen = !collapsible || (open ?? internal);\n  const toggle = () => {\n    if (open === undefined) setInternal(!isOpen);\n    onOpenChange?.(!isOpen);\n  };\n\n  const content = children ?? (\n    <div className=\"grid gap-4 sm:grid-cols-2\">\n      <DemoField label=\"Full name\" value=\"Maya Chen\" p={p} />\n      <DemoField label=\"Email\" value=\"maya@northwind.app\" type=\"email\" p={p} />\n      <div className=\"sm:col-span-2\">\n        <DemoField label=\"Company\" value=\"Northwind Ltd\" p={p} />\n      </div>\n    </div>\n  );\n  const shownSummary = summary ?? (children ? null : \"Maya Chen · maya@northwind.app\");\n\n  const borderColor = error ? p.error : p.border;\n\n  return (\n    <div className={cn(\"flex w-full flex-col\", className)} style={{ gap: 8, fontFamily: \"Inter, sans-serif\", color: p.text }}>\n      <fieldset\n        disabled={disabled}\n        aria-invalid={error ? true : undefined}\n        aria-describedby={[description && isOpen ? `${uid}-desc` : \"\", error ? `${uid}-err` : \"\"].filter(Boolean).join(\" \") || undefined}\n        className=\"m-0 min-w-0 transition-colors duration-200\"\n        style={{ border: `1px solid ${borderColor}`, borderRadius: 16, padding: \"4px 20px 20px\", background: p.panel, opacity: disabled ? 0.7 : 1 }}\n      >\n        <legend className=\"flex items-center\" style={{ gap: 8, padding: \"0 8px\", marginLeft: -8 }}>\n          {collapsible ? (\n            <button type=\"button\" onClick={toggle} aria-expanded={isOpen} aria-controls={`${uid}-body`} className=\"flex cursor-pointer items-center rounded-md border-none bg-transparent p-0 text-[14.5px] font-semibold tracking-[-0.01em] outline-none focus-visible:ring-2\" style={{ gap: 8, color: error ? p.error : p.text, [\"--tw-ring-color\" as string]: p.focus }}>\n              <motion.svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" initial={false} animate={{ rotate: isOpen ? 90 : 0 }} transition={{ duration: reduce ? 0 : 0.2 }}>\n                <path d=\"m9 6 6 6-6 6\" />\n              </motion.svg>\n              {legend}\n            </button>\n          ) : (\n            <span className=\"text-[14.5px] font-semibold tracking-[-0.01em]\" style={{ color: error ? p.error : p.text }}>\n              {legend}\n            </span>\n          )}\n          <AnimatePresence initial={false}>\n            {complete && !error && (\n              <motion.span key=\"done\" className=\"flex items-center justify-center rounded-full\" style={{ width: 16, height: 16, background: p.done }} initial={{ scale: 0 }} animate={{ scale: 1 }} exit={{ scale: 0 }} transition={{ type: \"spring\", stiffness: 600, damping: 26 }} aria-label=\"Complete\" role=\"img\">\n                <svg width=\"9\" height=\"9\" viewBox=\"0 0 12 12\" fill=\"none\" aria-hidden=\"true\">\n                  <path d=\"M2.4 6.3 4.9 8.7 9.6 3.4\" stroke=\"#0A0A0A\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                </svg>\n              </motion.span>\n            )}\n          </AnimatePresence>\n        </legend>\n\n        <AnimatePresence initial={false} mode=\"popLayout\">\n          {!isOpen && shownSummary && (\n            <motion.p key=\"summary\" className=\"m-0 truncate text-[13px]\" style={{ color: p.muted, paddingTop: 6 }} initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ duration: reduce ? 0 : 0.15 }}>\n              {shownSummary}\n            </motion.p>\n          )}\n        </AnimatePresence>\n\n        <AnimatePresence initial={false}>\n          {isOpen && (\n            <motion.div key=\"body\" id={`${uid}-body`} className=\"overflow-hidden\" initial={{ height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={{ height: 0, opacity: 0 }} transition={{ duration: reduce ? 0 : 0.28, ease: [0.22, 1, 0.36, 1] }}>\n              <div className=\"flex flex-col\" style={{ gap: 16, paddingTop: 8 }}>\n                {description && (\n                  <p id={`${uid}-desc`} className=\"m-0 text-[13px] leading-relaxed\" style={{ color: p.muted }}>\n                    {description}\n                  </p>\n                )}\n                {content}\n              </div>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </fieldset>\n      <AnimatePresence initial={false}>\n        {error && (\n          <motion.span key=\"err\" id={`${uid}-err`} role=\"alert\" className=\"text-[12.5px] font-medium\" style={{ color: p.error, paddingLeft: 4 }} initial={{ opacity: 0, y: -4 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0 }}>\n            {error}\n          </motion.span>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\nexport default Fieldset;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}