{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "collapsible",
  "title": "collapsible",
  "description": "Content that opens and closes under a trigger. plain has no look: the trigger is a Button through asChild, as a show-more control. card is a bordered card whose header row opens it, for reference entries and questions; with forceMount, closed text stays in the server HTML and shows when script is off.",
  "dependencies": [
    "@radix-ui/react-collapsible",
    "class-variance-authority@^0.7"
  ],
  "registryDependencies": [
    "@dwellir/dwellir-theme",
    "@dwellir/utils",
    "@dwellir/rune-icons"
  ],
  "files": [
    {
      "path": "components/ui/collapsible.tsx",
      "content": "'use client';\n\nimport * as CollapsiblePrimitive from '@radix-ui/react-collapsible';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport {\n  type ComponentProps,\n  cloneElement,\n  createContext,\n  isValidElement,\n  type ReactNode,\n  useContext,\n} from 'react';\nimport { RuneChevronDown } from '@/components/brand/rune-icons';\nimport { cn } from '@/lib/utils';\n\nconst collapsibleVariants = cva('', {\n  variants: {\n    variant: {\n      /*\n       * Upstream: no look of its own. Give the trigger a Button through asChild.\n       * Closed content unmounts; with forceMount it stays on screen, and the\n       * caller trims it by data-state, as the footer's list of chains.\n       */\n      plain: '',\n      /*\n       * A card that opens: a header row with a chevron over the body, as a\n       * reference entry or a question. With forceMount on the content, closed\n       * text stays in the server HTML and shows when script is off.\n       */\n      card: 'group/collapsible collapsible-card',\n    },\n  },\n  defaultVariants: { variant: 'plain' },\n});\n\ntype CollapsibleVariant = NonNullable<VariantProps<typeof collapsibleVariants>['variant']>;\n\nconst CollapsibleVariantContext = createContext<CollapsibleVariant>('plain');\n\nfunction Collapsible({\n  className,\n  variant,\n  ...props\n}: ComponentProps<typeof CollapsiblePrimitive.Root> & VariantProps<typeof collapsibleVariants>) {\n  return (\n    <CollapsibleVariantContext.Provider value={variant ?? 'plain'}>\n      <CollapsiblePrimitive.Root\n        data-slot=\"collapsible\"\n        className={cn(collapsibleVariants({ variant }), className) || undefined}\n        {...props}\n      />\n    </CollapsibleVariantContext.Provider>\n  );\n}\n\nconst chevron = (\n  <span data-slot=\"collapsible-chevron\" className=\"collapsible-chevron\">\n    <RuneChevronDown aria-hidden=\"true\" className=\"size-4\" />\n  </span>\n);\n\n/*\n * The card's chevron goes inside the trigger. With asChild, Radix needs the\n * caller's one element, so the chevron joins that element's children.\n */\nfunction cardTriggerChildren(children: ReactNode, asChild: boolean | undefined) {\n  if (!asChild) {\n    return (\n      <>\n        {children}\n        {chevron}\n      </>\n    );\n  }\n  if (!isValidElement<{ children?: ReactNode }>(children)) return children;\n  return cloneElement(children, undefined, children.props.children, chevron);\n}\n\nfunction CollapsibleTrigger({\n  className,\n  children,\n  asChild,\n  ...props\n}: ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {\n  const variant = useContext(CollapsibleVariantContext);\n  return (\n    <CollapsiblePrimitive.CollapsibleTrigger\n      data-slot=\"collapsible-trigger\"\n      asChild={asChild}\n      className={cn(variant === 'card' && 'collapsible-card-trigger', className)}\n      {...props}\n    >\n      {variant === 'card' ? cardTriggerChildren(children, asChild) : children}\n    </CollapsiblePrimitive.CollapsibleTrigger>\n  );\n}\n\nfunction CollapsibleContent({\n  className,\n  ...props\n}: ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {\n  const variant = useContext(CollapsibleVariantContext);\n  return (\n    <CollapsiblePrimitive.CollapsibleContent\n      data-slot=\"collapsible-content\"\n      className={cn(variant === 'card' && 'collapsible-card-content', className)}\n      {...props}\n    />\n  );\n}\n\nexport { Collapsible, CollapsibleContent, CollapsibleTrigger, collapsibleVariants };\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}