{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "breadcrumb",
  "title": "Breadcrumb",
  "description": "Where a page sits: ancestor link cells and a cobalt cell for here; earlier levels fold into a menu by count or width.",
  "dependencies": [
    "@base-ui/react@1.9.0",
    "class-variance-authority"
  ],
  "registryDependencies": [
    "@keyline-ui/keyline",
    "utils",
    "@keyline-ui/menu"
  ],
  "files": [
    {
      "path": "src/registry/keyline/ui/breadcrumb.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { cva } from \"class-variance-authority\";\n\nimport { cn } from \"@/lib/utils\";\nimport { Menu, MenuTrigger, MenuPopup, MenuItem } from \"./menu\";\n\ntype Crumb = {\n  label: React.ReactNode;\n  href?: string;\n  /** A router link instead of <a>: render={<Link to=\"…\" />}. Props and refs merge (Base UI useRender). */\n  render?: React.ReactElement;\n};\n\ntype BreadcrumbProps = Omit<React.ComponentProps<\"nav\">, \"children\"> & {\n  /** Ancestors first; the last item is the current page (not a link). */\n  items: Crumb[];\n  /** Above this many items the ones before the parent fold into a \"…\" cell with a menu. Default 4. */\n  maxItems?: number;\n  /** control: its own 2px frame. cell: a row of an enclosing frame (a panel's or page header's top cell). */\n  layout?: \"control\" | \"cell\";\n  /** Name of the \"…\" menu trigger. */\n  moreLabel?: string;\n};\n\n/*\n * BREADCRUMB: the frame hugs its crumbs (inline), up to the width it is given. Seams sit on each crumb's end edge,\n * so folding a crumb away never leaves a doubled edge. The nav is the size container (kl-crumbs) the folding measures,\n * and the outermost Keyline element (kl-type). The frame keeps the cut's room, so it holds whichever crumb is first.\n */\nconst listVariants = cva(\n  \"kl-ctl kl-cells m-0 box-border max-w-full list-none p-0 ps-[calc(var(--kl-c,0px)*0.35)] align-top\",\n  {\n    variants: {\n      // a cell gives its background to the enclosing frame (the foundation's layout=\"cell\") and fills the row\n      layout: { control: \"inline-flex min-h-(--kl-ctl) bg-kl-cell\", cell: \"flex min-h-(--kl-row)\" },\n    },\n    defaultVariants: { layout: \"control\" },\n  },\n);\n\n/** A crumb: a cell of the frame that gives up room before the current page does. */\nconst crumb = \"flex min-w-0 flex-[0_3_auto] border-s-0 not-last:border-e-(length:--kl-k1) not-last:border-e-kl-seam\";\n/** Folded away by count (data-kl-folded on the nav) or by width (under 480px of the nav's own width). */\nconst early = \"group-data-kl-folded/breadcrumb:hidden [@container_kl-crumbs_(max-width:480px)]:hidden\";\nconst link = cn(\n  \"group/breadcrumb-link kl-cell kl-key min-h-0 gap-1.5 text-(length:--kl-text-body) text-kl-ink no-underline\",\n);\nconst text = \"min-w-0 truncate\";\n\nfunction Chevron({ className }: { className?: string }) {\n  return (\n    <svg\n      data-slot=\"breadcrumb-separator\"\n      className={cn(\"flex-none text-kl-ink-3 kl-rtl:-scale-x-100\", className)}\n      viewBox=\"0 0 16 16\"\n      width=\"12\"\n      height=\"12\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"1.75\"\n      strokeLinecap=\"square\"\n      aria-hidden\n    >\n      <path d=\"m6 4 4 4-4 4\" />\n    </svg>\n  );\n}\n\nfunction CrumbLink({ crumb: c }: { crumb: Crumb }) {\n  return useRender({\n    render: c.render ?? <a href={c.href} />,\n    props: {\n      \"data-slot\": \"breadcrumb-link\",\n      className: cn(link, \"max-w-[22ch] [@container_kl-crumbs_(max-width:480px)]:max-w-[14ch]\"),\n      children: (\n        <>\n          <span\n            className={cn(text, \"group-hover/breadcrumb-link:underline group-hover/breadcrumb-link:underline-offset-3\")}\n          >\n            {c.label}\n          </span>\n          <Chevron />\n        </>\n      ),\n    },\n  });\n}\n\n/**\n * Where this page sits, as cells in one frame:\n *\n *   ┌─────────┬──────────┬───┬───────────┬━━━━━━━━━━━━━━━━━━━━┓\n *   │ Network ›│ Europe › │ … │ Rotterdam ›│ ECT Delta (here)  ┃   ancestors are link cells; here is cobalt\n *   └─────────┴──────────┴───┴───────────┴━━━━━━━━━━━━━━━━━━━━┛\n *\n * - The current page is the cobalt cell (location, as in Nav and Tabs), aria-current=\"page\", not a link.\n * - Each ancestor ends in a chevron that mirrors in RTL. Long labels truncate inside their cell; the\n *   current page keeps the most room.\n * - Folding: more than `maxItems`, or less than 480px of its own width, folds every ancestor before the\n *   parent into a \"…\" cell whose menu lists them in order. The parent and the page itself always show.\n */\nfunction Breadcrumb({\n  items,\n  maxItems = 4,\n  layout = \"control\",\n  moreLabel = \"Earlier levels\",\n  className,\n  ...props\n}: BreadcrumbProps): React.ReactElement {\n  const n = items.length;\n  const current = items[n - 1];\n  const parentIndex = n - 2;\n  const earlier = items.slice(0, Math.max(0, parentIndex));\n  const folded = n > maxItems;\n  return (\n    <nav\n      aria-label=\"Breadcrumb\"\n      data-kl-layout={layout}\n      data-kl-folded={folded || undefined}\n      className={cn(\"group/breadcrumb kl-type @container/kl-crumbs min-w-0\", className)}\n      {...props}\n      data-slot=\"breadcrumb\"\n    >\n      <ol data-slot=\"breadcrumb-list\" data-kl-layout={layout} className={cn(listVariants({ layout }))}>\n        {earlier.length ? (\n          <li\n            data-slot=\"breadcrumb-more\"\n            className={cn(\n              crumb,\n              \"hidden group-data-kl-folded/breadcrumb:flex [@container_kl-crumbs_(max-width:480px)]:flex\",\n            )}\n          >\n            <Menu>\n              <MenuTrigger\n                className={cn(\n                  link,\n                  \"font-(--kl-weight-strong) data-popup-open:bg-kl-inverse data-popup-open:text-kl-on-inverse\",\n                )}\n                aria-label={`${moreLabel} (${earlier.length})`}\n              >\n                <span aria-hidden>…</span>\n                <Chevron className=\"group-data-popup-open/breadcrumb-link:text-inherit\" />\n              </MenuTrigger>\n              <MenuPopup attachWeight={layout === \"cell\" ? 1 : 2}>\n                {earlier.map((c, i) => (\n                  <MenuItem key={i} code={i + 1} render={c.render ?? <a href={c.href} />}>\n                    {c.label}\n                  </MenuItem>\n                ))}\n              </MenuPopup>\n            </Menu>\n          </li>\n        ) : null}\n        {items.slice(0, -1).map((c, i) => (\n          <li\n            key={i}\n            data-slot=\"breadcrumb-item\"\n            data-kl-early={i < parentIndex || undefined}\n            className={cn(crumb, i < parentIndex && early)}\n          >\n            <CrumbLink crumb={c} />\n          </li>\n        ))}\n        {current ? (\n          <li data-slot=\"breadcrumb-item\" className={cn(crumb, \"flex-[0_1_auto]\")}>\n            <span\n              data-slot=\"breadcrumb-page\"\n              aria-current=\"page\"\n              className={cn(\n                \"kl-cell min-h-0 bg-kl-cobalt text-(length:--kl-text-body) font-(--kl-weight-strong) text-kl-on-cobalt\",\n                \"forced-colors:bg-[Highlight] forced-colors:text-[HighlightText] forced-colors:forced-color-adjust-none\",\n              )}\n            >\n              <span className={text}>{current.label}</span>\n            </span>\n          </li>\n        ) : null}\n      </ol>\n    </nav>\n  );\n}\n\nexport { Breadcrumb, type Crumb, type BreadcrumbProps };\n",
      "type": "registry:ui",
      "target": "components/keyline/ui/breadcrumb.tsx"
    }
  ],
  "type": "registry:ui"
}