{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "transaction-list",
  "type": "registry:component",
  "title": "Transaction List",
  "description": "Transactions grouped under sticky day headings, with merchant tiles, status chips, tabular amounts and an expandable detail row with a copy button.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "lists",
    "transactions",
    "finance",
    "banking",
    "activity",
    "sticky",
    "copy"
  ],
  "docs": "https://hyperblur.dev/effects/transaction-list",
  "files": [
    {
      "path": "registry/hyperblur/transaction-list.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/transaction-list.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type TransactionStatus = \"pending\" | \"posted\";\n\nexport interface Transaction {\n  id: string;\n  day: string;\n  merchant: string;\n  category: string;\n  time: string;\n  amount: number;\n  status?: TransactionStatus;\n  reference?: string;\n  account?: string;\n}\n\nexport const defaultTransactions: Transaction[] = [\n  { id: \"t1\", day: \"Today\", merchant: \"Blue Bottle Coffee\", category: \"Dining\", time: \"8:42 AM\", amount: -6.5, reference: \"TXN-84F2-19C7\", account: \"Visa 4821\" },\n  { id: \"t2\", day: \"Today\", merchant: \"Stripe Payout\", category: \"Income\", time: \"7:15 AM\", amount: 3240, reference: \"PO-5521-A0E3\", account: \"Checking 0917\" },\n  { id: \"t3\", day: \"Today\", merchant: \"Spotify\", category: \"Subscriptions\", time: \"6:03 AM\", amount: -11.99, status: \"pending\", reference: \"TXN-71B0-44D8\", account: \"Visa 4821\" },\n  { id: \"t4\", day: \"Yesterday\", merchant: \"Whole Foods\", category: \"Groceries\", time: \"6:20 PM\", amount: -84.37, reference: \"TXN-62A9-0B15\", account: \"Visa 4821\" },\n  { id: \"t5\", day: \"Yesterday\", merchant: \"Uber\", category: \"Transport\", time: \"11:05 PM\", amount: -23.1, reference: \"TXN-5D18-77AE\", account: \"Visa 4821\" },\n  { id: \"t6\", day: \"Yesterday\", merchant: \"Figma\", category: \"Software\", time: \"9:00 AM\", amount: -15, reference: \"TXN-4C03-91F6\", account: \"Visa 4821\" },\n  { id: \"t7\", day: \"Oct 28\", merchant: \"Delta Air Lines\", category: \"Travel\", time: \"2:48 PM\", amount: -412.8, reference: \"TXN-3B77-C2D0\", account: \"Amex 1009\" },\n  { id: \"t8\", day: \"Oct 28\", merchant: \"Refund: Apple\", category: \"Income\", time: \"10:12 AM\", amount: 129, reference: \"RF-2A64-8E51\", account: \"Visa 4821\" },\n];\n\nexport interface TransactionListProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onCopy\"> {\n  transactions?: Transaction[];\n  currency?: string;\n  maxHeight?: number;\n  surface?: string;\n  accent?: string;\n  defaultExpanded?: string;\n  onCopy?: (transaction: Transaction) => void;\n}\n\nconst css = `\n.hb-trx {\n  --hb-trx-accent: #2f7bff;\n  --hb-trx-bg: #111111;\n  container-type: inline-size;\n  width: 100%;\n  min-width: 0;\n  max-height: var(--hb-trx-h, 360px);\n  overflow-y: auto;\n  overscroll-behavior: contain;\n  box-sizing: border-box;\n  font-family: inherit;\n  font-size: 13px;\n  line-height: 1.4;\n  color: #ededed;\n  scrollbar-width: thin;\n  scrollbar-color: #2a2a2a transparent;\n}\n.hb-trx *, .hb-trx *::before, .hb-trx *::after { box-sizing: border-box; font-family: inherit; }\n.hb-trx-group { margin: 0; padding: 0; list-style: none; }\n.hb-trx-day {\n  position: sticky;\n  top: 0;\n  z-index: 2;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  padding: 7px 10px 6px;\n  background: var(--hb-trx-bg);\n  border-bottom: 1px solid #1f1f1f;\n  font-size: 11px;\n  font-weight: 500;\n  letter-spacing: .06em;\n  text-transform: uppercase;\n  color: #8f8f8f;\n}\n.hb-trx-net { font-weight: 400; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; color: #6b6b6b; }\n.hb-trx-items { margin: 0; padding: 2px 0; list-style: none; }\n.hb-trx-item { position: relative; border-radius: 10px; animation: hb-trx-in .36s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--hb-trx-i, 0) * 40ms); }\n.hb-trx-row {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  width: 100%;\n  min-width: 0;\n  padding: 7px 10px;\n  border: 0;\n  border-radius: 10px;\n  background: none;\n  color: inherit;\n  font: inherit;\n  text-align: left;\n  cursor: pointer;\n  transition: background-color .15s ease;\n}\n.hb-trx-row:hover { background: rgba(255, 255, 255, .045); }\n.hb-trx-item[data-open=\"true\"] .hb-trx-row { background: color-mix(in srgb, var(--hb-trx-accent) 11%, transparent); }\n.hb-trx-row:focus-visible, .hb-trx-copy:focus-visible {\n  outline: 2px solid color-mix(in srgb, var(--hb-trx-accent) 80%, transparent);\n  outline-offset: -2px;\n}\n.hb-trx-tile {\n  flex: none;\n  display: grid;\n  place-items: center;\n  width: 32px;\n  height: 32px;\n  border-radius: 10px;\n  background: var(--hb-trx-bg1);\n  border: 1px solid var(--hb-trx-bd);\n  color: var(--hb-trx-fg);\n  font-size: 13px;\n  font-weight: 600;\n}\n.hb-trx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }\n.hb-trx-merchant { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 500; }\n.hb-trx-merchant-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.hb-trx-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #8f8f8f; }\n.hb-trx-chip {\n  flex: none;\n  padding: 0 6px;\n  border-radius: 999px;\n  font-size: 10px;\n  font-weight: 500;\n  line-height: 16px;\n  color: #f5a524;\n  background: rgba(245, 165, 36, .14);\n  border: 1px solid rgba(245, 165, 36, .3);\n}\n.hb-trx-amount { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }\n.hb-trx-amount[data-income=\"true\"] { color: #3ecf8e; }\n.hb-trx-drawer {\n  display: grid;\n  grid-template-rows: 0fr;\n  transition: grid-template-rows .3s cubic-bezier(.2, .8, .2, 1);\n}\n.hb-trx-item[data-open=\"true\"] .hb-trx-drawer { grid-template-rows: 1fr; }\n.hb-trx-drawer-in { min-height: 0; overflow: hidden; }\n.hb-trx-detail {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 10px;\n  margin: 2px 10px 6px 52px;\n  padding: 8px 10px;\n  border: 1px solid #222222;\n  border-radius: 9px;\n  background: #0d0d0d;\n  opacity: 0;\n  transform: translateY(-4px);\n  transition: opacity .25s ease .05s, transform .25s ease .05s;\n}\n.hb-trx-item[data-open=\"true\"] .hb-trx-detail { opacity: 1; transform: none; }\n.hb-trx-field { min-width: 0; display: flex; flex-direction: column; }\n.hb-trx-label { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: #6b6b6b; }\n.hb-trx-ref {\n  overflow: hidden;\n  text-overflow: ellipsis;\n  white-space: nowrap;\n  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n  font-size: 12px;\n  color: #ededed;\n}\n.hb-trx-copy {\n  flex: none;\n  display: inline-flex;\n  align-items: center;\n  gap: 5px;\n  height: 26px;\n  padding: 0 9px;\n  border: 1px solid #2a2a2a;\n  border-radius: 8px;\n  background: #171717;\n  color: #ededed;\n  font-size: 12px;\n  cursor: pointer;\n  transition: background-color .15s ease, border-color .15s ease, color .15s ease;\n}\n.hb-trx-copy svg { width: 12px; height: 12px; }\n.hb-trx-copy:hover { background: #1f1f1f; border-color: #3a3a3a; }\n.hb-trx-copy[data-copied=\"true\"] { color: #3ecf8e; border-color: rgba(62, 207, 142, .4); }\n.hb-trx-sr {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  margin: -1px;\n  overflow: hidden;\n  clip: rect(0 0 0 0);\n  white-space: nowrap;\n}\n@container (max-width: 300px) {\n  .hb-trx-detail { margin-left: 10px; }\n  .hb-trx-tile { display: none; }\n}\n@keyframes hb-trx-in {\n  from { opacity: 0; transform: translateY(6px); }\n  to { opacity: 1; transform: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-trx-item { animation: none !important; }\n  .hb-trx-row, .hb-trx-drawer, .hb-trx-detail, .hb-trx-copy { transition: none !important; }\n}\n`;\n\nfunction hash(input: string) {\n  let h = 0;\n  for (let i = 0; i < input.length; i++) h = (Math.imul(h, 31) + input.charCodeAt(i)) >>> 0;\n  return h;\n}\n\nfunction glyphOf(merchant: string) {\n  const colon = merchant.indexOf(\":\");\n  const clean = (colon >= 0 ? merchant.slice(colon + 1) : merchant).trim();\n  return (clean[0] ?? \"?\").toUpperCase();\n}\n\nexport function TransactionList({\n  transactions = defaultTransactions,\n  currency = \"USD\",\n  maxHeight = 360,\n  surface = \"#111111\",\n  accent = \"#2f7bff\",\n  defaultExpanded,\n  onCopy,\n  className = \"\",\n  style,\n  ...rest\n}: TransactionListProps) {\n  const [openId, setOpenId] = React.useState<string | null>(defaultExpanded ?? null);\n  const [copiedId, setCopiedId] = React.useState<string | null>(null);\n  const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n  React.useEffect(() => {\n    return () => {\n      if (timer.current) clearTimeout(timer.current);\n    };\n  }, []);\n\n  const money = new Intl.NumberFormat(\"en-US\", { style: \"currency\", currency });\n  const format = (value: number) => `${value < 0 ? \"−\" : value > 0 ? \"+\" : \"\"}${money.format(Math.abs(value))}`;\n\n  const groups: { day: string; items: Transaction[] }[] = [];\n  for (const tx of transactions) {\n    const last = groups[groups.length - 1];\n    const existing = last && last.day === tx.day ? last : groups.find((g) => g.day === tx.day);\n    if (existing) existing.items.push(tx);\n    else groups.push({ day: tx.day, items: [tx] });\n  }\n\n  const copy = async (tx: Transaction) => {\n    const text = tx.reference ?? tx.id;\n    try {\n      await navigator.clipboard.writeText(text);\n    } catch {\n      const area = document.createElement(\"textarea\");\n      area.value = text;\n      area.setAttribute(\"readonly\", \"\");\n      area.style.position = \"fixed\";\n      area.style.opacity = \"0\";\n      document.body.appendChild(area);\n      area.select();\n      try {\n        document.execCommand(\"copy\");\n      } catch {\n        return;\n      } finally {\n        document.body.removeChild(area);\n      }\n    }\n    setCopiedId(tx.id);\n    if (timer.current) clearTimeout(timer.current);\n    timer.current = setTimeout(() => setCopiedId(null), 1600);\n    onCopy?.(tx);\n  };\n\n  const vars = {\n    \"--hb-trx-accent\": accent,\n    \"--hb-trx-bg\": surface,\n    \"--hb-trx-h\": `${maxHeight}px`,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <div className={`hb-trx ${className}`} style={vars} {...rest}>\n      <style href=\"hb-transaction-list\" precedence=\"default\">{css}</style>\n      <span className=\"hb-trx-sr\" role=\"status\" aria-live=\"polite\">\n        {copiedId ? \"Reference copied\" : \"\"}\n      </span>\n      {groups.map((group) => {\n        const net = group.items.reduce((sum, t) => sum + t.amount, 0);\n        return (\n          <section key={group.day} className=\"hb-trx-group\" aria-label={group.day}>\n            <h3 className=\"hb-trx-day\" style={{ margin: 0 }}>\n              <span>{group.day}</span>\n              <span className=\"hb-trx-net\">{format(net)}</span>\n            </h3>\n            <ul className=\"hb-trx-items\">\n              {group.items.map((tx) => {\n                const open = openId === tx.id;\n                const hue = hash(tx.merchant) % 360;\n                const tile = {\n                  \"--hb-trx-bg1\": `hsl(${hue} 38% 17%)`,\n                  \"--hb-trx-bd\": `hsl(${hue} 38% 26%)`,\n                  \"--hb-trx-fg\": `hsl(${hue} 75% 78%)`,\n                  \"--hb-trx-i\": transactions.indexOf(tx),\n                } as React.CSSProperties;\n                const drawerId = `hb-trx-d-${tx.id}`;\n                return (\n                  <li key={tx.id} className=\"hb-trx-item\" data-open={open} style={tile}>\n                    <button\n                      type=\"button\"\n                      className=\"hb-trx-row\"\n                      aria-expanded={open}\n                      aria-controls={drawerId}\n                      onClick={() => setOpenId(open ? null : tx.id)}\n                    >\n                      <span className=\"hb-trx-tile\" aria-hidden=\"true\">\n                        {glyphOf(tx.merchant)}\n                      </span>\n                      <span className=\"hb-trx-main\">\n                        <span className=\"hb-trx-merchant\">\n                          <span className=\"hb-trx-merchant-text\">{tx.merchant}</span>\n                          {tx.status === \"pending\" && <span className=\"hb-trx-chip\">Pending</span>}\n                        </span>\n                        <span className=\"hb-trx-sub\">{`${tx.category} · ${tx.time}`}</span>\n                      </span>\n                      <span className=\"hb-trx-amount\" data-income={tx.amount > 0}>\n                        {format(tx.amount)}\n                      </span>\n                    </button>\n                    <div className=\"hb-trx-drawer\" id={drawerId} role=\"region\" aria-label={`${tx.merchant} details`} inert={!open}>\n                      <div className=\"hb-trx-drawer-in\">\n                        <div className=\"hb-trx-detail\">\n                          <span className=\"hb-trx-field\">\n                            <span className=\"hb-trx-label\">Reference</span>\n                            <span className=\"hb-trx-ref\">{tx.reference ?? tx.id}</span>\n                          </span>\n                          {tx.account && (\n                            <span className=\"hb-trx-field\">\n                              <span className=\"hb-trx-label\">Account</span>\n                              <span className=\"hb-trx-ref\">{tx.account}</span>\n                            </span>\n                          )}\n                          <button type=\"button\" className=\"hb-trx-copy\" data-copied={copiedId === tx.id} onClick={() => copy(tx)}>\n                            {copiedId === tx.id ? (\n                              <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                                <path d=\"M2.4 6.4l2.3 2.3 4.9-5\" />\n                              </svg>\n                            ) : (\n                              <svg viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.4\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                                <rect x=\"4\" y=\"4\" width=\"6.5\" height=\"6.5\" rx=\"1.4\" />\n                                <path d=\"M8 4V2.9A1.4 1.4 0 0 0 6.6 1.5H2.9A1.4 1.4 0 0 0 1.5 2.9v3.7A1.4 1.4 0 0 0 2.9 8H4\" />\n                              </svg>\n                            )}\n                            {copiedId === tx.id ? \"Copied\" : \"Copy\"}\n                          </button>\n                        </div>\n                      </div>\n                    </div>\n                  </li>\n                );\n              })}\n            </ul>\n          </section>\n        );\n      })}\n    </div>\n  );\n}\n"
    }
  ]
}