{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "collapsible",
  "title": "Collapsible",
  "description": "One panel shown and hidden from a header row whose chevron turns down, on the Accordion’s motion: it turns back from where it is when pressed midway, and content that grows while open moves the panel with it.",
  "dependencies": [
    "@ui-sdk/react",
    "@ui-sdk/core"
  ],
  "registryDependencies": [
    "https://kinoui.com/r/resize.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/collapsible.tsx",
      "content": "'use client'\n\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { collapseClassName, followPanelContent } from '@/registry/lib/resize'\nimport {\n  CollapsiblePanel as CollapsiblePanelPrimitive,\n  Collapsible as CollapsiblePrimitive,\n  CollapsibleTrigger as CollapsibleTriggerPrimitive,\n} from '@ui-sdk/react/collapsible'\nimport { type ComponentProps, useEffect, useRef } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/* A header row whose leading chevron turns down as its panel opens. */\n\nfunction Collapsible({\n  className,\n  ...props\n}: Omit<ComponentProps<typeof CollapsiblePrimitive>, 'className'> & {\n  className?: string\n}) {\n  return (\n    <CollapsiblePrimitive className={cn('flex min-w-0 flex-col', className)} {...props} />\n  )\n}\n\n/**\n * A row as tall as a control for one line; a label that wraps grows it, its\n * icons level with the first line. A tree's rows share it.\n */\nconst collapsibleRowClassName =\n  \"flex w-full min-w-0 items-start gap-2 rounded-(--control-radius-capped) px-(--control-padding) py-[calc((var(--control-height)-1lh)/2)] text-start text-sm wrap-anywhere [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&>svg]:mt-0.5\"\n\n/**\n * Rows nested under a row, as a tree's branch and a sidebar's section: a\n * line runs down beside them and their labels line up with the parent's.\n * Add where the line runs, under the parent's chevron or icon, as `before:start-*`.\n */\nconst collapsibleNestedClassName =\n  'before:bg-border forced-colors:before:bg-[CanvasText] relative flex min-w-0 flex-col gap-px pt-px ps-6 before:pointer-events-none before:absolute before:inset-y-0 before:w-px'\n\n/**\n * The chevron that turns down as its panel opens, for a row that carries\n * `group/collapsible-trigger` and ui-sdk's `data-open`. Mirrored in right to\n * left, it points to the start and turns the other way to point down.\n */\nfunction CollapsibleIndicator({\n  className,\n  open,\n}: {\n  className?: string\n  /** Whether what it opens is open, for an indicator outside a `CollapsibleTrigger`, such as the Table's `TableExpand`. */\n  open?: boolean\n}) {\n  return (\n    <IconPlaceholder\n      lucide='ChevronRightIcon'\n      tabler='IconChevronRight'\n      hugeicons='ArrowRight01Icon'\n      phosphor='CaretRightIcon'\n      remixicon='RiArrowRightSLine'\n      data-slot='collapsible-indicator'\n      data-open={open ? '' : undefined}\n      aria-hidden\n      className={cn(\n        'text-muted-foreground group-hover/collapsible-trigger:text-foreground group-data-disabled/collapsible-trigger:text-foreground/30 transition-[color,rotate] duration-(--motion-layout-duration) ease-[var(--motion-layout-fade-easing),var(--motion-layout-easing)] group-data-open/collapsible-trigger:rotate-90 motion-reduce:transition-[color] motion-reduce:ease-(--motion-layout-fade-easing) rtl:-scale-x-100 rtl:group-data-open/collapsible-trigger:-rotate-90 data-open:rotate-90 rtl:data-open:-rotate-90',\n        className,\n      )}\n    />\n  )\n}\n\nfunction CollapsibleTrigger({\n  className,\n  children,\n  ...props\n}: Omit<ComponentProps<typeof CollapsibleTriggerPrimitive>, 'className' | 'children'> & {\n  className?: string\n  children?: ComponentProps<'button'>['children']\n}) {\n  return (\n    <CollapsibleTriggerPrimitive\n      className={cn(\n        collapsibleRowClassName,\n        'group/collapsible-trigger text-foreground hover:bg-muted focus-visible:ring-ring/50 data-disabled:text-foreground/40 font-medium transition-[color,background-color,box-shadow] duration-(--motion-press-duration) ease-(--motion-press-fade-easing) focus-visible:ring-3 focus-visible:outline-hidden data-disabled:hover:bg-transparent',\n        className,\n      )}\n      {...props}\n    >\n      <CollapsibleIndicator />\n      {children}\n    </CollapsibleTriggerPrimitive>\n  )\n}\n\n/**\n * The content's own box, which mounts with the panel. ui-sdk sizes the panel\n * while it opens and closes and leaves it at `auto` once open, so content\n * that grows or shrinks after that would jump: this moves the panel to the\n * new height on the same transition.\n */\nfunction CollapsiblePanelContent(props: ComponentProps<'div'>) {\n  const ref = useRef<HTMLDivElement>(null)\n\n  useEffect(() => {\n    const inner = ref.current\n    const panel = inner?.parentElement\n    if (!inner || !panel) return\n    return followPanelContent(panel, inner, '--collapsible-panel-height')\n  }, [])\n\n  return <div ref={ref} data-slot='collapsible-panel-content' {...props} />\n}\n\n/**\n * `className` goes on the content's own box, which lines its start up with\n * the trigger's label; the other props go to ui-sdk's panel.\n */\nfunction CollapsiblePanel({\n  className,\n  children,\n  ...props\n}: Omit<ComponentProps<typeof CollapsiblePanelPrimitive>, 'className' | 'children'> & {\n  className?: string\n  children?: ComponentProps<'div'>['children']\n}) {\n  return (\n    <CollapsiblePanelPrimitive\n      // Clipped down the page only, so a focus ring inside keeps its sides.\n      className={cn(\n        collapseClassName,\n        'overflow-y-clip text-sm [--collapse-height:var(--collapsible-panel-height)]',\n      )}\n      {...props}\n    >\n      <CollapsiblePanelContent\n        className={cn(\n          'min-w-0 pt-1 pe-(--control-padding) pb-(--row-padding) ps-[calc(var(--control-padding)+--spacing(6))] wrap-break-word',\n          className,\n        )}\n      >\n        {children}\n      </CollapsiblePanelContent>\n    </CollapsiblePanelPrimitive>\n  )\n}\n\nexport {\n  Collapsible,\n  CollapsibleTrigger,\n  CollapsiblePanel,\n  CollapsibleIndicator,\n  collapsibleNestedClassName,\n  collapsibleRowClassName,\n}\n",
      "type": "registry:component",
      "target": "@components/kino/collapsible.tsx"
    }
  ],
  "type": "registry:component"
}