{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "collapsible",
  "type": "registry:ui",
  "title": "Collapsible",
  "description": "Collapsible provides its canonical documented behavior.",
  "dependencies": [
    "@base-ui/react@1.8.0",
    "lucide-react@0.561.0"
  ],
  "registryDependencies": [
    "https://ghost-ui.com/r/ghost-tokens.json",
    "https://ghost-ui.com/r/foundation.json",
    "https://ghost-ui.com/r/base-styled.json",
    "https://ghost-ui.com/r/shared-background.json"
  ],
  "files": [
    {
      "path": "src/components/ui/collapsible.tsx",
      "type": "registry:component",
      "target": "@ui/collapsible.tsx",
      "content": "\"use client\";\n\nimport { Collapsible as BaseCollapsible } from \"@base-ui/react/collapsible\";\nimport { ChevronRight } from \"lucide-react\";\n\nimport { styled } from \"./base-styled\";\nimport { SharedBackground } from \"./shared-background\";\nimport * as React from \"react\";\nimport \"./collapsible.css\";\n\nexport type CollapsibleVariant = \"default\" | \"inline\" | \"plain\";\ntype RootProps = React.ComponentPropsWithoutRef<typeof BaseCollapsible.Root> & {\n  variant?: CollapsibleVariant;\n  /** Shows pointer-hover backgrounds. Keyboard focus and open feedback remain. */\n  hoverBackground?: boolean;\n  /** Keep the open panel but suppress its persistent surface and indicator fill. */\n  expandedBackground?: boolean;\n};\n\nconst VariantContext = React.createContext<CollapsibleVariant>(\"plain\");\n\nconst CollapsibleRoot = React.forwardRef<HTMLDivElement, RootProps>(\n  function CollapsibleRoot({ variant = \"default\", hoverBackground = true, expandedBackground = true, className, disabled, children, ...props }, ref) {\n    const rootClass = variant === \"plain\" ? \"ui-collapsible\" : \"ui-stack ui-collapsible\";\n    const rootClassName: RootProps[\"className\"] =\n      typeof className === \"function\"\n        ? (state) => [rootClass, className(state)].filter(Boolean).join(\" \")\n        : [rootClass, className].filter(Boolean).join(\" \");\n\n    if (variant === \"plain\") {\n      return (\n        <VariantContext.Provider value=\"plain\">\n          <BaseCollapsible.Root\n            {...props}\n            ref={ref}\n            disabled={disabled}\n            data-variant={variant}\n            data-hover-background={hoverBackground ? undefined : \"false\"}\n            data-expanded-background={expandedBackground ? undefined : \"false\"}\n            className={rootClassName}\n          >\n            {children}\n          </BaseCollapsible.Root>\n        </VariantContext.Provider>\n      );\n    }\n\n    return (\n      <VariantContext.Provider value={variant}>\n        <BaseCollapsible.Root\n          {...props}\n          ref={ref}\n          disabled={disabled}\n          data-variant={variant}\n          data-hover-background={hoverBackground ? undefined : \"false\"}\n          data-expanded-background={expandedBackground ? undefined : \"false\"}\n          className={rootClassName}\n        >\n          <SharedBackground\n            className=\"ui-disclosure-surface\"\n            surface=\"secondary\"\n            inset={0}\n            targetSelector=\"[data-ui-shared-background-row]\"\n          >\n            <div className=\"ui-disclosure-item\" data-disabled={disabled ? \"\" : undefined}>\n              {children}\n            </div>\n          </SharedBackground>\n        </BaseCollapsible.Root>\n      </VariantContext.Provider>\n    );\n  },\n);\n\nconst StyledTrigger = styled(BaseCollapsible.Trigger, \"ui-disclosure\");\ntype TriggerProps = React.ComponentPropsWithoutRef<typeof BaseCollapsible.Trigger> & {\n  /** Override the decorative indicator, or pass null to omit it. */\n  indicator?: React.ReactNode;\n};\n\nconst Trigger = React.forwardRef<HTMLButtonElement, TriggerProps>(\n  function Trigger({ children, indicator, ...props }, ref) {\n    const variant = React.useContext(VariantContext);\n    const showDefaultIndicator = variant !== \"plain\" && indicator === undefined;\n    const resolvedIndicator = showDefaultIndicator ? <Indicator /> : indicator;\n    const content = variant === \"plain\"\n      ? <>{children}{resolvedIndicator}</>\n      : <><span className=\"ui-disclosure-label\">{children}</span>{resolvedIndicator}</>;\n\n    const TriggerPart = variant === \"plain\" ? BaseCollapsible.Trigger : StyledTrigger;\n    return <TriggerPart {...props} ref={ref}>{content}</TriggerPart>;\n  },\n);\n\nconst Indicator = React.forwardRef<HTMLSpanElement, React.HTMLAttributes<HTMLSpanElement>>(\n  function Indicator({ className, children, ...props }, ref) {\n    return (\n      <span\n        {...props}\n        ref={ref}\n        aria-hidden=\"true\"\n        className={[\"ui-disclosure-indicator\", className].filter(Boolean).join(\" \")}\n      >\n        {children ?? <ChevronRight aria-hidden=\"true\" />}\n      </span>\n    );\n  },\n);\n\nexport const Collapsible = {\n  ...BaseCollapsible,\n  Root: CollapsibleRoot,\n  Trigger,\n  Panel: /* @__PURE__ */ styled(BaseCollapsible.Panel, \"ui-disclosure-panel\"),\n  Indicator,\n};\n"
    },
    {
      "path": "src/components/ui/collapsible.css",
      "type": "registry:file",
      "target": "@ui/collapsible.css",
      "content": ".ui-collapsible:where([data-variant=\"plain\"]) {\n  display: flex;\n  flex-direction: column;\n  gap: var(--space-1);\n  min-width: 0;\n}\n\n/* Opt out of persistent expanded feedback without changing existing defaults.\n   Direct ownership prevents a parent opt-out from overriding nested roots. */\n.ui-collapsible[data-expanded-background=\"false\"] > .ui-disclosure-surface > .ui-disclosure-item > .ui-disclosure[data-panel-open] > .ui-disclosure-indicator,\n.ui-collapsible[data-expanded-background=\"false\"] > .ui-disclosure[data-panel-open] > .ui-disclosure-indicator {\n  background: transparent;\n}\n.ui-collapsible[data-expanded-background=\"false\"] > .ui-disclosure-surface > .ui-disclosure-item > .ui-disclosure[data-panel-open]:is(:hover, :focus-visible) > .ui-disclosure-indicator,\n.ui-collapsible[data-expanded-background=\"false\"] > .ui-disclosure[data-panel-open]:is(:hover, :focus-visible) > .ui-disclosure-indicator {\n  background: var(--ui-disclosure-open-icon-hover, var(--control-selected-hover));\n}\n"
    }
  ]
}
