{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"breadcrumb","type":"registry:block","title":"Breadcrumb","description":"A breadcrumb trail that folds long paths behind an expanding ellipsis, with real links, a current-page marker and a lens dot.","dependencies":["motion","lucide-react"],"registryDependencies":["utils"],"files":[{"path":"registry/prequel/breadcrumb/breadcrumb.tsx","type":"registry:component","content":"\"use client\";\n\nimport { useRef, useState } from \"react\";\nimport { MotionConfig, motion, useInView, useReducedMotion } from \"motion/react\";\nimport { ChevronRight, MoreHorizontal } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nconst EASE: [number, number, number, number] = [0.22, 1, 0.36, 1];\n\n/* ------------------------------------------------------------------ */\n/* types                                                               */\n/* ------------------------------------------------------------------ */\n\nexport type BreadcrumbItem = {\n  label: string;\n  /** Omit for the current page or for a record that has no route. */\n  href?: string;\n};\n\nexport type BreadcrumbProps = {\n  className?: string;\n  items?: BreadcrumbItem[];\n  /** Collapse the middle of the trail when it holds more than this many crumbs. */\n  maxItems?: number;\n  title?: string;\n  description?: string;\n  status?: string;\n  meta?: string;\n};\n\n/* ------------------------------------------------------------------ */\n/* deterministic demo data                                             */\n/* ------------------------------------------------------------------ */\n\nconst DEFAULT_ITEMS: BreadcrumbItem[] = [\n  { label: \"Home\", href: \"/\" },\n  { label: \"Showcase\", href: \"/showcase\" },\n  { label: \"Origin\", href: \"/dashboards/origin\" },\n  { label: \"Customers\", href: \"/dashboards/origin/customers\" },\n  { label: \"Northwind Labs\" },\n  { label: \"INV-2481\" },\n];\n\n/* ------------------------------------------------------------------ */\n/* helpers                                                             */\n/* ------------------------------------------------------------------ */\n\ntype Crumb =\n  | { type: \"item\"; item: BreadcrumbItem; index: number }\n  | { type: \"ellipsis\" };\n\nfunction buildCrumbs(\n  items: BreadcrumbItem[],\n  maxItems: number,\n  expanded: boolean\n): Crumb[] {\n  const head = items[0];\n  if (!head) return [];\n\n  const tailCount = Math.max(2, maxItems - 1);\n  const hiddenCount = items.length - 1 - tailCount;\n  const collapsed = !expanded && hiddenCount > 1;\n\n  const crumbs: Crumb[] = [{ type: \"item\", item: head, index: 0 }];\n\n  if (collapsed) {\n    crumbs.push({ type: \"ellipsis\" });\n  } else {\n    for (let index = 1; index < items.length - tailCount; index += 1) {\n      crumbs.push({ type: \"item\", item: items[index], index });\n    }\n  }\n\n  for (let index = Math.max(1, items.length - tailCount); index < items.length; index += 1) {\n    crumbs.push({ type: \"item\", item: items[index], index });\n  }\n\n  return crumbs;\n}\n\n/* ------------------------------------------------------------------ */\n/* block                                                               */\n/* ------------------------------------------------------------------ */\n\nexport function Breadcrumb({\n  className,\n  items = DEFAULT_ITEMS,\n  maxItems = 3,\n  title = \"INV-2481\",\n  description = \"Issued 26 Oct 2026 for Northwind Labs. $4,820.00 due on 25 Nov, net 30.\",\n  status = \"Paid\",\n  meta = \"2 Nov 2026 · Visa ending 4412\",\n}: BreadcrumbProps) {\n  const ref = useRef<HTMLDivElement>(null);\n  const inView = useInView(ref, { once: true, margin: \"-10% 0px\" });\n  const reduce = Boolean(useReducedMotion());\n  const [expanded, setExpanded] = useState(false);\n\n  const crumbs = buildCrumbs(items, maxItems, expanded);\n  const lastIndex = items.length - 1;\n  const canCollapse = items.length - Math.max(2, maxItems - 1) - 1 > 1;\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <motion.div\n        ref={ref}\n        initial={{ opacity: 0, y: reduce ? 0 : 16 }}\n        animate={{ opacity: inView ? 1 : 0, y: 0 }}\n        transition={{ duration: reduce ? 0 : 0.55, ease: EASE }}\n        className={cn(\n          \"w-full rounded-xl border border-border bg-card p-5 text-card-foreground shadow-sm sm:p-6\",\n          className\n        )}\n      >\n        <motion.nav\n          aria-label=\"Breadcrumb\"\n          initial={{ opacity: 0 }}\n          animate={{ opacity: inView ? 1 : 0 }}\n          transition={{ duration: reduce ? 0 : 0.5, ease: EASE, delay: reduce ? 0 : 0.05 }}\n        >\n          <div className=\"flex items-start justify-between gap-3\">\n            <ol className=\"flex min-w-0 flex-1 flex-wrap items-center gap-x-0.5 gap-y-1 text-[12.5px]\">\n              {crumbs.map((crumb, position) => {\n                const separator =\n                  position > 0 ? (\n                    <ChevronRight\n                      aria-hidden=\"true\"\n                      className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground/60\"\n                      strokeWidth={2}\n                    />\n                  ) : null;\n\n                if (crumb.type === \"ellipsis\") {\n                  return (\n                    <li key=\"ellipsis\" className=\"flex items-center gap-0.5\">\n                      {separator}\n                      <button\n                        type=\"button\"\n                        onClick={() => setExpanded(true)}\n                        aria-label={`Show ${items.length - crumbs.length + 1} hidden breadcrumbs`}\n                        aria-expanded={expanded}\n                        className=\"inline-flex h-6 items-center gap-1 rounded-md px-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\"\n                      >\n                        <MoreHorizontal className=\"h-4 w-4\" aria-hidden=\"true\" />\n                      </button>\n                    </li>\n                  );\n                }\n\n                const { item, index } = crumb;\n                const current = index === lastIndex;\n                const content = current ? (\n                  <span\n                    aria-current=\"page\"\n                    className=\"inline-flex items-center gap-1.5 px-1 text-[13px] font-medium text-foreground\"\n                  >\n                    <span\n                      aria-hidden=\"true\"\n                      className=\"relative flex h-2.5 w-2.5 items-center justify-center rounded-full border border-foreground/50\"\n                    >\n                      <span className=\"absolute right-[1px] top-[1px] h-[2px] w-[2px] rounded-full bg-foreground/70\" />\n                    </span>\n                    <span className=\"truncate\">{item.label}</span>\n                  </span>\n                ) : item.href ? (\n                  <a\n                    href={item.href}\n                    className=\"rounded-sm px-1 py-0.5 text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\"\n                  >\n                    {item.label}\n                  </a>\n                ) : (\n                  <span className=\"px-1 text-muted-foreground\">{item.label}</span>\n                );\n\n                return (\n                  <li\n                    key={`${item.label}-${index}`}\n                    className=\"flex min-w-0 items-center gap-0.5\"\n                  >\n                    {separator}\n                    <motion.span\n                      initial={reduce ? false : { opacity: 0, y: 2 }}\n                      animate={{ opacity: 1, y: 0 }}\n                      transition={{\n                        duration: reduce ? 0 : 0.3,\n                        ease: EASE,\n                        delay: reduce ? 0 : 0.08 + position * 0.035,\n                      }}\n                      className=\"inline-flex min-w-0 items-center\"\n                    >\n                      {content}\n                    </motion.span>\n                  </li>\n                );\n              })}\n            </ol>\n            {canCollapse && expanded ? (\n              <button\n                type=\"button\"\n                onClick={() => setExpanded(false)}\n                className=\"mt-0.5 inline-flex h-6 shrink-0 items-center rounded-md px-1.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\"\n              >\n                Less\n              </button>\n            ) : null}\n          </div>\n        </motion.nav>\n\n        <div className=\"mt-4 h-px w-full bg-border\" />\n\n        <motion.div\n          initial={{ opacity: 0, y: reduce ? 0 : 8 }}\n          animate={{ opacity: inView ? 1 : 0, y: 0 }}\n          transition={{ duration: reduce ? 0 : 0.5, ease: EASE, delay: reduce ? 0 : 0.12 }}\n        >\n          <div className=\"mt-4 flex flex-wrap items-start justify-between gap-3\">\n            <div className=\"min-w-0\">\n              <h2 className=\"text-[19px] font-semibold tracking-tight\">{title}</h2>\n              <p className=\"mt-1 max-w-md text-pretty text-[13px] leading-5 text-muted-foreground\">\n                {description}\n              </p>\n            </div>\n            <span className=\"inline-flex shrink-0 items-center gap-1.5 rounded-full border border-success/25 bg-success/10 px-2.5 py-1 text-[11px] font-medium text-success\">\n              <span aria-hidden=\"true\" className=\"h-1.5 w-1.5 rounded-full bg-success\" />\n              {status}\n            </span>\n          </div>\n\n          <p className=\"mt-4 text-[11.5px] tabular-nums text-muted-foreground\">{meta}</p>\n        </motion.div>\n      </motion.div>\n    </MotionConfig>\n  );\n}\n\nexport default Breadcrumb;\n"}]}