{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "accordion",
  "title": "Accordion",
  "description": "Stacked sections in one frame: header rows on shared keylines, panels unfold from the header's keyline; one or many open.",
  "dependencies": [
    "@base-ui/react@1.9.0",
    "class-variance-authority"
  ],
  "registryDependencies": [
    "@keyline-ui/keyline",
    "utils",
    "@keyline-ui/keyline-render"
  ],
  "files": [
    {
      "path": "src/registry/keyline/ui/accordion.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Accordion as AccordionPrimitive } from \"@base-ui/react/accordion\";\nimport { cva } from \"class-variance-authority\";\n\nimport { cn } from \"@/lib/utils\";\nimport { resolveClassName } from \"../lib/keyline-render\";\n\n/*\n * ACCORDION: rows on shared keylines in one frame. Header rows are cells; a panel unfolds from its header's bottom\n * keyline. Only the caret column is divided, so it runs the full height.\n */\nconst rootVariants = cva(\"kl-ctl flex min-w-0 flex-col\", {\n  variants: {\n    // a cell leaves the surface to its frame (the foundation's layout=\"cell\" clears the background)\n    layout: { control: \"bg-kl-cell\", cell: \"\" },\n  },\n  defaultVariants: { layout: \"control\" },\n});\n\n/** A row after the first draws the seam above it. */\nconst item = \"not-first:border-t-(length:--kl-k1) not-first:border-t-kl-seam\";\n\nconst header = \"m-0 [font:inherit]\";\n\n/*\n * The header row is a cell: its ring sits inside, clear of the keylines. A disabled row is out of service: hatched,\n * and every voice in it (description, meta, caret) in the disabled ink.\n */\nconst trigger = cn(\n  \"group/accordion-trigger kl-key m-0 grid min-h-(--kl-row) w-full cursor-pointer grid-cols-[minmax(0,1fr)_auto_40px] items-stretch\",\n  \"bg-transparent p-0 text-start font-(family-name:--kl-font) text-inherit\",\n  \"hover:not-data-disabled:bg-kl-tint focus-visible:outline-offset-(--kl-ring-in) active:not-data-disabled:bg-kl-press\",\n  \"data-disabled:cursor-not-allowed data-disabled:bg-(image:--kl-hatch) data-disabled:text-kl-dis\",\n  \"forced-colors:focus-visible:outline-[3px] forced-colors:focus-visible:-outline-offset-4 forced-colors:focus-visible:outline-[Highlight] forced-colors:focus-visible:outline-solid\",\n);\n\nconst title = \"grid min-w-0 content-center gap-0.5 px-(--kl-inset) py-[9px] leading-[1.3] wrap-anywhere\";\nconst descriptionClass =\n  \"text-(length:--kl-text-label) text-kl-ink-2 group-data-disabled/accordion-trigger:text-kl-dis\";\nconst metaClass = cn(\n  \"flex items-center gap-2 pe-(--kl-inset) text-(length:--kl-text-label) whitespace-nowrap text-kl-ink-2 tabular-nums\",\n  \"group-data-disabled/accordion-trigger:text-kl-dis\",\n);\n/* the caret turns on the unfold timing, as the table's expand cell does */\nconst caret = cn(\n  \"col-start-3 grid place-items-center border-s-(length:--kl-k1) border-s-kl-seam text-kl-ink-2\",\n  \"group-data-disabled/accordion-trigger:text-kl-dis group-data-panel-open/accordion-trigger:group-not-data-disabled/accordion-trigger:text-kl-ink\",\n);\nconst caretIcon = cn(\n  \"transition-[rotate] duration-(--kl-t-fold) ease-(--kl-ease-in)\",\n  \"group-data-panel-open/accordion-trigger:rotate-180 group-data-panel-open/accordion-trigger:duration-(--kl-t-unfold) group-data-panel-open/accordion-trigger:ease-(--kl-ease-out)\",\n);\n\n/*\n * UNFOLD from the header's keyline: Base UI measures the panel (--accordion-panel-height) and marks the start and\n * end of the transition; reduced motion makes both durations 0. The seam lives on the content, inside the clip, so\n * it folds away with it and never doubles the next row's rule.\n */\nconst panel = cn(\n  \"h-(--accordion-panel-height) overflow-hidden transition-[height] duration-(--kl-t-unfold) ease-(--kl-ease-out)\",\n  \"data-ending-style:h-0 data-ending-style:duration-(--kl-t-fold) data-ending-style:ease-(--kl-ease-in) data-starting-style:h-0\",\n);\nconst content = cn(\n  \"border-t-(length:--kl-k1) border-t-kl-seam p-(--kl-inset) pb-[calc(var(--kl-inset)+4px)] text-(length:--kl-text-body)/[1.5]\",\n  \"[&>:first-child]:mt-0 [&>:last-child]:mb-0\",\n);\n\ntype AccordionRootProps<V> = AccordionPrimitive.Root.Props<V> & {\n  /** control: its own 2px frame. cell: the rows sit directly in an enclosing frame (a panel body, an inspector). */\n  layout?: \"control\" | \"cell\";\n};\n\n/**\n * Stacked sections in one frame. Each item is a header row and a panel; rows share keylines (one edge,\n * one owner), and an open panel UNFOLDS from its header's bottom keyline (160ms, folds back in 120ms; the\n * header row never moves). Opening does not also flood: the caret turns, the panel arrives.\n *\n *   ┌─────────────────────────────────────────┬────┐\n *   │ Customs documents             3 files   │ ⌃  │   title (+ description) and meta · caret cell\n *   ├─────────────────────────────────────────┴────┤\n *   │ panel content                                │\n *   ├─────────────────────────────────────────┬────┤\n *   │ Billing                                 │ ⌄  │\n *   └─────────────────────────────────────────┴────┘\n *\n * The caret cell is the only divided column, so it runs straight down the frame whether or not a row\n * has meta (a column, once started, runs the full height).\n *\n * One or many open (`multiple`), controlled or not, keyboard (Tab between headers, as the current APG\n * pattern has it; Enter and Space toggle), heading semantics and find-in-page (`hiddenUntilFound`) are Base UI\n * Accordion's.\n */\nfunction AccordionRoot<V>({ className, layout = \"control\", ...props }: AccordionRootProps<V>): React.ReactElement {\n  return (\n    <AccordionPrimitive.Root<V>\n      data-kl-layout={layout}\n      className={resolveClassName(cn(rootVariants({ layout })), className)}\n      {...props}\n      data-slot=\"accordion\"\n    />\n  );\n}\n\n/** A section: its header row and its panel (Base UI Accordion.Item). */\nfunction AccordionItem({ className, ...props }: AccordionPrimitive.Item.Props): React.ReactElement {\n  return (\n    <AccordionPrimitive.Item className={resolveClassName(item, className)} {...props} data-slot=\"accordion-item\" />\n  );\n}\n\n/* Set inside an AccordionHeader, so a trigger composed in one doesn't render a second. */\nconst HeaderContext = React.createContext(false);\n\ntype AccordionHeaderProps = AccordionPrimitive.Header.Props & {\n  /** Heading level (default 3). */\n  level?: 2 | 3 | 4 | 5 | 6;\n};\n\n/** The heading that holds a trigger (Base UI Accordion.Header). AccordionTrigger renders one when it has none. */\nfunction AccordionHeader({ className, level = 3, render, ...props }: AccordionHeaderProps): React.ReactElement {\n  return (\n    <HeaderContext.Provider value>\n      <AccordionPrimitive.Header\n        render={render ?? React.createElement(`h${level}`)}\n        className={resolveClassName(header, className)}\n        {...props}\n        data-slot=\"accordion-header\"\n      />\n    </HeaderContext.Provider>\n  );\n}\n\ntype AccordionTriggerProps = AccordionPrimitive.Trigger.Props & {\n  description?: React.ReactNode;\n  /** Trailing text before the caret cell: a count, a status, a short code. It never wraps; the title does. */\n  meta?: React.ReactNode;\n  /** Heading level of the header it renders when it is not inside an AccordionHeader (default 3). */\n  level?: 2 | 3 | 4 | 5 | 6;\n};\n\n/** The header row (Base UI Accordion.Trigger): title, description and meta, and the caret cell. */\nfunction AccordionTrigger({\n  className,\n  children,\n  description,\n  meta,\n  level = 3,\n  ...props\n}: AccordionTriggerProps): React.ReactElement {\n  const inHeader = React.useContext(HeaderContext);\n  const row = (\n    <AccordionPrimitive.Trigger\n      className={resolveClassName(trigger, className)}\n      {...props}\n      data-slot=\"accordion-trigger\"\n    >\n      <span data-slot=\"accordion-title\" className={title}>\n        <span className=\"text-(length:--kl-text-lead) font-(--kl-weight-strong)\">{children}</span>\n        {description ? (\n          <small data-slot=\"accordion-description\" className={descriptionClass}>\n            {description}\n          </small>\n        ) : null}\n      </span>\n      {meta != null ? (\n        <span data-slot=\"accordion-meta\" className={metaClass}>\n          {meta}\n        </span>\n      ) : null}\n      <span data-slot=\"accordion-caret\" className={caret} aria-hidden>\n        <svg\n          className={caretIcon}\n          viewBox=\"0 0 16 16\"\n          width=\"16\"\n          height=\"16\"\n          fill=\"none\"\n          stroke=\"currentColor\"\n          strokeWidth=\"1.75\"\n          strokeLinecap=\"square\"\n        >\n          <path d=\"m4 6 4 4 4-4\" />\n        </svg>\n      </span>\n    </AccordionPrimitive.Trigger>\n  );\n  return inHeader ? row : <AccordionHeader level={level}>{row}</AccordionHeader>;\n}\n\ntype AccordionPanelProps = AccordionPrimitive.Panel.Props & {\n  /** Drop the content's inset, for content that brings its own cells (an item list, a key/value grid). */\n  flush?: boolean;\n  /** Classes for the content inside the panel's clip (its layout: `grid gap-4`). */\n  contentClassName?: string;\n};\n\n/** The section's content (Base UI Accordion.Panel). It unfolds; its content sits inside the clip. */\nfunction AccordionPanel({\n  className,\n  contentClassName,\n  children,\n  flush,\n  ...props\n}: AccordionPanelProps): React.ReactElement {\n  return (\n    <AccordionPrimitive.Panel className={resolveClassName(panel, className)} {...props} data-slot=\"accordion-panel\">\n      <div\n        data-slot=\"accordion-content\"\n        data-flush={flush || undefined}\n        className={cn(content, flush && \"p-0\", contentClassName)}\n      >\n        {children}\n      </div>\n    </AccordionPrimitive.Panel>\n  );\n}\n\n/** The root under its short name, as before the parts were named after Base UI's. */\nconst Accordion = AccordionRoot;\n\nexport {\n  Accordion,\n  AccordionRoot,\n  AccordionItem,\n  AccordionHeader,\n  AccordionTrigger,\n  AccordionPanel,\n  type AccordionRootProps,\n  type AccordionHeaderProps,\n  type AccordionTriggerProps,\n  type AccordionPanelProps,\n};\n",
      "type": "registry:ui",
      "target": "components/keyline/ui/accordion.tsx"
    }
  ],
  "type": "registry:ui"
}