{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stacked-list",
  "title": "Stacked List",
  "description": "A stacked A to Z contact list: sticky letter headings that light up as you scroll, an alphabet index on the side that jumps to a letter, search, rows with avatar or initials, tags and last contact, arrow-key navigation, and rows that open to show email and call actions.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/stacked-list/stacked-list.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface StackedContact {\n  id: string;\n  name: string;\n  company: string;\n  email: string;\n  phone: string;\n  avatar?: string;\n  lastContact: string;\n  tags?: string[];\n}\n\nexport interface StackedListProps {\n  title?: string;\n  contacts?: StackedContact[];\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.62)\", faint: \"rgba(245,244,241,0.36)\", card: \"#121212\", head: \"#151515\", border: \"rgba(255,255,255,0.08)\", chip: \"rgba(255,255,255,0.06)\", hover: \"rgba(255,255,255,0.035)\", sel: \"rgba(255,255,255,0.06)\", on: \"#F5F4F1\", onText: \"#0A0A0A\", accent: \"#FB923C\", ring: \"rgba(245,244,241,0.6)\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.4)\", card: \"#FFFFFF\", head: \"#F7F7F4\", border: \"rgba(10,10,10,0.08)\", chip: \"rgba(10,10,10,0.05)\", hover: \"rgba(10,10,10,0.025)\", sel: \"rgba(10,10,10,0.04)\", on: \"#0A0A0A\", onText: \"#FAFAF8\", accent: \"#EA580C\", ring: \"rgba(10,10,10,0.5)\" },\n};\n\nconst NAMES: [string, string, string?][] = [\n  [\"Amara Diallo\", \"Halcyon\", \"/demo/45.webp\"],\n  [\"Ben Carter\", \"Kestrel\"],\n  [\"Bianca Rossi\", \"Lumen\", \"/demo/49.webp\"],\n  [\"Chen Wei\", \"Oakline\"],\n  [\"Daniel Reyes\", \"Nexora\", \"/demo/42.webp\"],\n  [\"Diego Alvarez\", \"Fieldnote\"],\n  [\"Elena Vargas\", \"Copperleaf\", \"/demo/50.webp\"],\n  [\"Farah Khan\", \"Tessellate\"],\n  [\"Hana Sato\", \"Halcyon\", \"/demo/54.webp\"],\n  [\"Isaac Moreau\", \"Brightline\"],\n  [\"Jonas Weber\", \"Kestrel\"],\n  [\"Lena Brandt\", \"Nexora\", \"/demo/55.webp\"],\n  [\"Lucas Moreau\", \"Oakline\"],\n  [\"Mara Okafor\", \"Nexora\", \"/demo/44.webp\"],\n  [\"Marco Bellini\", \"Morrow Labs\", \"/demo/51.webp\"],\n  [\"Noor Haddad\", \"Nexora\", \"/demo/46.webp\"],\n  [\"Priya Nair\", \"Halcyon\", \"/demo/41.webp\"],\n  [\"Rafael Costa\", \"Lumen\"],\n  [\"Samuel Osei\", \"Brightline\", \"/demo/53.webp\"],\n  [\"Sofia Rossi\", \"Fieldnote\"],\n  [\"Tomás Ferreira\", \"Nexora\", \"/demo/43.webp\"],\n  [\"Yuki Tanaka\", \"Tessellate\"],\n  [\"Zara Ahmed\", \"Copperleaf\"],\n];\nconst DEFAULT_CONTACTS: StackedContact[] = NAMES.map(([name, company, avatar], i) => ({\n  id: String(i + 1),\n  name,\n  company,\n  avatar,\n  email: `${name.split(\" \")[0].toLowerCase().normalize(\"NFD\").replace(/[̀-ͯ]/g, \"\")}@${company.toLowerCase().replace(/\\s/g, \"\")}.com`,\n  phone: `+49 30 5550 ${String(200 + i * 7).padStart(3, \"0\")}`,\n  lastContact: [\"Today\", \"Yesterday\", \"3 days ago\", \"Last week\", \"2 weeks ago\", \"Last month\"][i % 6],\n  tags: [[\"Customer\"], [\"Lead\"], [\"Partner\"], [\"Customer\", \"VIP\"], [\"Lead\"], []][i % 6],\n}));\nconst TAG_COLOR: Record<string, string> = { Customer: \"#4ADE80\", Lead: \"#60A5FA\", Partner: \"#A78BFA\", VIP: \"#FB923C\" };\n\nexport function StackedList({ title = \"Contacts\", contacts = DEFAULT_CONTACTS, theme = \"dark\", className }: StackedListProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId().replace(/:/g, \"\");\n  const [q, setQ] = React.useState(\"\");\n  const [open, setOpen] = React.useState<string | null>(null);\n  const [activeLetter, setActiveLetter] = React.useState<string | null>(null);\n  const scroller = React.useRef<HTMLDivElement>(null);\n  const jumpTarget = React.useRef<string | null>(null);\n\n  const query = q.trim().toLowerCase();\n  const filtered = contacts.filter((c) => !query || `${c.name} ${c.company} ${c.email}`.toLowerCase().includes(query)).sort((a, b) => a.name.localeCompare(b.name));\n  const groups: { letter: string; items: StackedContact[] }[] = [];\n  filtered.forEach((c) => {\n    const l = c.name[0].toUpperCase();\n    const g = groups[groups.length - 1];\n    if (g?.letter === l) g.items.push(c);\n    else groups.push({ letter: l, items: [c] });\n  });\n  const letters = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".split(\"\");\n  const has = new Set(groups.map((g) => g.letter));\n\n  const jump = (l: string) => {\n    const el = scroller.current?.querySelector<HTMLElement>(`#${uid}-${l}`);\n    if (!el || !scroller.current) return;\n    jumpTarget.current = l;\n    scroller.current.scrollTo({ top: el.offsetTop, behavior: reduce ? \"auto\" : \"smooth\" });\n    setActiveLetter(l);\n  };\n  const onScroll = () => {\n    const sc = scroller.current;\n    if (!sc) return;\n    const atBottom = sc.scrollTop + sc.clientHeight >= sc.scrollHeight - 2;\n    // While a letter jump scrolls the list, ignore the letters passed on the way.\n    if (jumpTarget.current) {\n      const t = sc.querySelector<HTMLElement>(`#${uid}-${jumpTarget.current}`);\n      if (atBottom || !t || Math.abs(t.offsetTop - sc.scrollTop) <= 4) jumpTarget.current = null;\n      return;\n    }\n    let cur: string | null = null;\n    for (const g of groups) {\n      const el = sc.querySelector<HTMLElement>(`#${uid}-${g.letter}`);\n      if (el && el.offsetTop - sc.scrollTop <= 4) cur = g.letter;\n    }\n    // At the very bottom the last sections can't reach the top: keep the current letter if it is on screen.\n    if (atBottom) {\n      setActiveLetter((prev) => {\n        const el = prev ? sc.querySelector<HTMLElement>(`#${uid}-${prev}`) : null;\n        return el && el.offsetTop - sc.scrollTop < sc.clientHeight ? prev : (groups[groups.length - 1]?.letter ?? null);\n      });\n      return;\n    }\n    setActiveLetter(cur ?? groups[0]?.letter ?? null);\n  };\n  const moveFocus = (e: React.KeyboardEvent<HTMLButtonElement>, dir: 1 | -1) => {\n    const all = Array.from(scroller.current?.querySelectorAll<HTMLButtonElement>(\"[data-row]\") ?? []);\n    const i = all.indexOf(e.currentTarget);\n    const next = all[i + dir];\n    if (next) {\n      e.preventDefault();\n      next.focus();\n      next.scrollIntoView({ block: \"nearest\" });\n    }\n  };\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.card } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const current = activeLetter && has.has(activeLetter) ? activeLetter : groups[0]?.letter;\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"mx-auto max-w-3xl px-4 py-10 @[640px]:px-6 @[640px]:py-14\">\n        <div className=\"overflow-hidden rounded-2xl border\" style={{ background: p.card, borderColor: p.border }}>\n          <div className=\"flex items-center justify-between gap-3 border-b p-4\" style={{ borderColor: p.border }}>\n            <h2 className=\"m-0 text-[17px] font-semibold tracking-[-0.01em]\">\n              {title} <span className=\"text-[13px] font-normal tabular-nums\" style={{ color: p.faint }}>{filtered.length}</span>\n            </h2>\n            <label className=\"relative w-48 @[560px]:w-60\">\n              <span className=\"sr-only\">Search contacts</span>\n              <svg className=\"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2\" width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\" style={{ color: p.faint }}>\n                <circle cx=\"11\" cy=\"11\" r=\"7\" />\n                <path d=\"m20 20-3.5-3.5\" />\n              </svg>\n              <input\n                type=\"search\"\n                value={q}\n                onChange={(e) => {\n                  setQ(e.target.value);\n                  setActiveLetter(null);\n                  scroller.current?.scrollTo({ top: 0 });\n                }} placeholder=\"Search\" className={cn(\"h-9 w-full rounded-lg border pr-3 pl-8 text-[13px]\", focus)} style={{ borderColor: p.border, background: \"transparent\", color: p.text, ...ring }} />\n            </label>\n          </div>\n          <div className=\"relative flex\">\n            <div ref={scroller} onScroll={onScroll} className=\"relative h-[520px] min-w-0 flex-1 overflow-y-auto\" role=\"region\" aria-label={`${title} list`} tabIndex={-1}>\n              {groups.map((g) => (\n                <section key={g.letter} id={`${uid}-${g.letter}`} aria-labelledby={`${uid}-h-${g.letter}`}>\n                  <h3 id={`${uid}-h-${g.letter}`} className=\"sticky top-0 z-10 m-0 border-y px-5 py-1.5 text-[12px] font-semibold backdrop-blur\" style={{ background: `${p.head}E6`, borderColor: p.border, color: current === g.letter ? p.accent : p.faint }}>\n                    {g.letter}\n                  </h3>\n                  <ul className=\"m-0 list-none p-0\">\n                    {g.items.map((c) => {\n                      const isOpen = open === c.id;\n                      return (\n                        <li key={c.id} className=\"border-b last:border-b-0\" style={{ borderColor: p.border }}>\n                          <button\n                            type=\"button\"\n                            data-row\n                            aria-expanded={isOpen}\n                            aria-controls={`${uid}-d-${c.id}`}\n                            onClick={() => setOpen(isOpen ? null : c.id)}\n                            onKeyDown={(e) => {\n                              if (e.key === \"ArrowDown\") moveFocus(e, 1);\n                              if (e.key === \"ArrowUp\") moveFocus(e, -1);\n                            }}\n                            className={cn(\"flex w-full cursor-pointer items-center gap-3 border-0 px-5 py-3 text-left transition-colors hover:bg-[var(--sl-h)]\", focus, \"focus-visible:ring-inset\")}\n                            style={{ background: isOpen ? p.sel : \"transparent\", color: p.text, [\"--sl-h\" as string]: p.hover, ...ring }}\n                          >\n                            {c.avatar ? (\n                              // eslint-disable-next-line @next/next/no-img-element\n                              <img src={c.avatar} alt=\"\" className=\"h-10 w-10 shrink-0 rounded-full object-cover\" />\n                            ) : (\n                              <span className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-full text-[13px] font-semibold\" style={{ background: p.chip, color: p.muted }} aria-hidden=\"true\">\n                                {c.name\n                                  .split(\" \")\n                                  .map((w) => w[0])\n                                  .join(\"\")}\n                              </span>\n                            )}\n                            <span className=\"min-w-0 flex-1\">\n                              <span className=\"flex items-center gap-2\">\n                                <span className=\"truncate text-[14px] font-medium\">{c.name}</span>\n                                {c.tags?.map((t) => (\n                                  <span key={t} className=\"hidden rounded px-1.5 text-[10.5px] font-medium @[480px]:inline\" style={{ background: p.chip, color: TAG_COLOR[t] ?? p.muted }}>\n                                    {t}\n                                  </span>\n                                ))}\n                              </span>\n                              <span className=\"block truncate text-[12.5px]\" style={{ color: p.faint }}>\n                                {c.company} · {c.email}\n                              </span>\n                            </span>\n                            <span className=\"hidden shrink-0 text-[12px] @[560px]:block\" style={{ color: p.faint }}>\n                              {c.lastContact}\n                            </span>\n                            <motion.svg width=\"13\" height=\"13\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"shrink-0\" style={{ color: p.faint }} animate={{ rotate: isOpen ? 90 : 0 }} aria-hidden=\"true\">\n                              <path d=\"m6 3 5 5-5 5\" />\n                            </motion.svg>\n                          </button>\n                          <AnimatePresence initial={false}>\n                            {isOpen && (\n                              <motion.div id={`${uid}-d-${c.id}`} initial={reduce ? false : { height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={reduce ? undefined : { height: 0, opacity: 0 }} transition={{ duration: 0.2 }} className=\"overflow-hidden\" style={{ background: p.sel }}>\n                                <div className=\"flex flex-wrap items-center gap-2 px-5 pb-4 pl-[72px]\">\n                                  <a href={`mailto:${c.email}`} className={cn(\"flex h-8 items-center gap-1.5 rounded-lg border px-3 text-[12.5px] no-underline\", focus)} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                                    <svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                                      <path d=\"M3 7l9 6 9-6M4 5h16v14H4z\" />\n                                    </svg>\n                                    Email\n                                  </a>\n                                  <a href={`tel:${c.phone.replace(/\\s/g, \"\")}`} className={cn(\"flex h-8 items-center gap-1.5 rounded-lg border px-3 text-[12.5px] no-underline\", focus)} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                                    <svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                                      <path d=\"M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2Z\" />\n                                    </svg>\n                                    {c.phone}\n                                  </a>\n                                  <span className=\"text-[12px]\" style={{ color: p.faint }}>\n                                    Last contact: {c.lastContact}\n                                  </span>\n                                </div>\n                              </motion.div>\n                            )}\n                          </AnimatePresence>\n                        </li>\n                      );\n                    })}\n                  </ul>\n                </section>\n              ))}\n              {groups.length === 0 && (\n                <p className=\"m-0 px-6 py-16 text-center text-[13.5px]\" style={{ color: p.muted }}>\n                  No contacts match “{q}”.\n                </p>\n              )}\n            </div>\n            {/* A–Z index */}\n            <nav aria-label=\"Jump to letter\" className=\"flex w-7 shrink-0 flex-col items-center justify-center border-l py-2\" style={{ borderColor: p.border }}>\n              {letters.map((l) => (\n                <button key={l} type=\"button\" disabled={!has.has(l)} onClick={() => jump(l)} aria-label={`Jump to ${l}`} aria-current={current === l ? \"true\" : undefined} className={cn(\"relative flex h-[18px] w-6 cursor-pointer items-center justify-center rounded border-0 bg-transparent p-0 text-[10px] font-semibold disabled:cursor-default\", focus)} style={{ color: current === l ? p.onText : has.has(l) ? p.muted : p.faint, opacity: has.has(l) ? 1 : 0.35, ...ring }}>\n                  {current === l && <motion.span layoutId={`${uid}-letter`} className=\"absolute inset-0 rounded\" style={{ background: p.accent }} transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 500, damping: 38 }} />}\n                  <span className=\"relative\">{l}</span>\n                </button>\n              ))}\n            </nav>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default StackedList;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}