{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "list-expandable-rows",
  "type": "registry:component",
  "title": "List Expandable Rows",
  "description": "Rows that open in place to reveal details with a smooth height transition, one at a time or several at once.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "lists",
    "list",
    "expand",
    "rows",
    "accordion",
    "details",
    "invoices"
  ],
  "docs": "https://hyperblur.dev/effects/list-expandable-rows",
  "files": [
    {
      "path": "registry/hyperblur/list-expandable-rows.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/list-expandable-rows.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nconst ICONS = {\n  receipt: \"M5 3h10v14l-2-1.3-1.5 1.3L10 15.7 8.5 17 7 15.7 5 17zM7.5 7.5h5M7.5 10.5h5\",\n  plane: \"M3 11l14-6-4 11-3-4.5zM10 11.5L17 5\",\n  box: \"M3.5 6.5L10 3l6.5 3.5v7L10 17l-6.5-3.5zM3.5 6.5L10 10l6.5-3.5M10 10v7\",\n  card: \"M3.5 5.5h13a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1h-13a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1zM2.5 8.5h15M5.5 12h3\",\n  user: \"M10 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM3.8 16.5c.6-2.8 3-4.3 6.2-4.3s5.6 1.5 6.2 4.3\",\n  bolt: \"M11 3L4.5 11h4.5l-1 6 6.5-8H10z\",\n} as const;\n\nexport type ExpandableRowIconName = keyof typeof ICONS;\n\nexport interface ExpandableRow {\n  id: string;\n  title: string;\n  subtitle?: string;\n  meta?: string;\n  icon?: ExpandableRowIconName;\n  color?: string;\n  details?: React.ReactNode;\n}\n\nexport interface ListExpandableRowsProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\" | \"children\" | \"defaultValue\"> {\n  items?: ExpandableRow[];\n  value?: string[];\n  defaultValue?: string[];\n  onChange?: (open: string[]) => void;\n  multiple?: boolean;\n  rowHeight?: number;\n  accent?: string;\n}\n\nexport interface ListExpandableDetailsProps {\n  rows: { label: string; value: React.ReactNode }[];\n}\n\nexport function ListExpandableDetails({ rows }: ListExpandableDetailsProps) {\n  return (\n    <dl className=\"hb-yc9-dl\">\n      {rows.map((row) => (\n        <React.Fragment key={row.label}>\n          <dt>{row.label}</dt>\n          <dd>{row.value}</dd>\n        </React.Fragment>\n      ))}\n    </dl>\n  );\n}\n\nconst defaultItems: ExpandableRow[] = [\n  {\n    id: \"inv-1048\",\n    title: \"Northwind Studio\",\n    subtitle: \"INV-1048\",\n    meta: \"$2,400.00\",\n    icon: \"receipt\",\n    color: \"#2f7bff\",\n    details: (\n      <ListExpandableDetails\n        rows={[\n          { label: \"Issued\", value: \"Oct 28, 2026\" },\n          { label: \"Due\", value: \"Nov 12, 2026\" },\n          { label: \"Paid with\", value: \"Visa ending 4821\" },\n        ]}\n      />\n    ),\n  },\n  {\n    id: \"inv-1047\",\n    title: \"Fable Labs\",\n    subtitle: \"INV-1047\",\n    meta: \"$890.00\",\n    icon: \"receipt\",\n    color: \"#8b5cf6\",\n    details: (\n      <ListExpandableDetails\n        rows={[\n          { label: \"Issued\", value: \"Oct 14, 2026\" },\n          { label: \"Due\", value: \"Oct 29, 2026\" },\n          { label: \"Status\", value: \"Paid\" },\n        ]}\n      />\n    ),\n  },\n  {\n    id: \"inv-1046\",\n    title: \"Atlas & Oak\",\n    subtitle: \"INV-1046\",\n    meta: \"$5,125.00\",\n    icon: \"receipt\",\n    color: \"#30a46c\",\n    details: (\n      <ListExpandableDetails\n        rows={[\n          { label: \"Issued\", value: \"Oct 02, 2026\" },\n          { label: \"Due\", value: \"Oct 17, 2026\" },\n          { label: \"Status\", value: \"Paid\" },\n        ]}\n      />\n    ),\n  },\n];\n\nconst css = `\n.hb-yc9 {\n  --hb-yc9-a: #2f7bff;\n  --hb-yc9-row: 48px;\n  display: flex;\n  flex-direction: column;\n  gap: 4px;\n  box-sizing: border-box;\n  width: 100%;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 13px;\n  line-height: 18px;\n}\n.hb-yc9 *, .hb-yc9 *::before, .hb-yc9 *::after { box-sizing: border-box; }\n.hb-yc9-row {\n  overflow: hidden;\n  border: 1px solid #232323;\n  border-radius: 12px;\n  background: #121212;\n  transition: background-color .2s ease, border-color .2s ease, box-shadow .25s ease;\n}\n.hb-yc9-row:hover { border-color: #2c2c2c; }\n.hb-yc9-row[data-open=\"true\"] {\n  border-color: color-mix(in srgb, var(--hb-yc9-a) 38%, #232323);\n  background: #141414;\n  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);\n}\n.hb-yc9-head {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  width: 100%;\n  height: var(--hb-yc9-row);\n  margin: 0;\n  padding: 0 12px 0 10px;\n  border: 0;\n  background: transparent;\n  color: inherit;\n  font: inherit;\n  text-align: left;\n  cursor: pointer;\n}\n.hb-yc9-head:focus-visible { outline: 2px solid var(--hb-yc9-a); outline-offset: -2px; border-radius: 11px; }\n.hb-yc9-tile {\n  display: grid;\n  flex: none;\n  place-items: center;\n  width: 28px;\n  height: 28px;\n  border-radius: 8px;\n  background: color-mix(in srgb, var(--hb-yc9-c, #2f7bff) 18%, transparent);\n  color: var(--hb-yc9-c, #2f7bff);\n  transition: transform .3s cubic-bezier(.3, 1.4, .5, 1), background-color .2s ease;\n}\n.hb-yc9-tile svg { width: 15px; height: 15px; }\n.hb-yc9-row[data-open=\"true\"] .hb-yc9-tile { transform: scale(1.06) rotate(-4deg); background: color-mix(in srgb, var(--hb-yc9-c, #2f7bff) 28%, transparent); }\n.hb-yc9-txt { flex: 1; min-width: 0; }\n.hb-yc9-name { display: block; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }\n.hb-yc9-sub { display: block; overflow: hidden; color: #77777f; font-size: 11.5px; line-height: 15px; text-overflow: ellipsis; white-space: nowrap; }\n.hb-yc9-meta { flex: none; color: #d4d4d4; font-size: 12.5px; font-variant-numeric: tabular-nums; font-weight: 600; }\n.hb-yc9-chev { width: 14px; height: 14px; flex: none; color: #6f6f6f; transition: transform .32s cubic-bezier(.2, .9, .2, 1), color .15s ease; }\n.hb-yc9-head:hover .hb-yc9-chev { color: #ededed; }\n.hb-yc9-row[data-open=\"true\"] .hb-yc9-chev { color: var(--hb-yc9-a); transform: rotate(180deg); }\n.hb-yc9-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s cubic-bezier(.2, .9, .2, 1); }\n.hb-yc9-row[data-open=\"true\"] .hb-yc9-panel { grid-template-rows: 1fr; }\n.hb-yc9-cut { min-height: 0; overflow: hidden; }\n.hb-yc9-body {\n  margin: 0 10px 10px 48px;\n  padding-top: 8px;\n  border-top: 1px solid #232323;\n  color: #b4b4b4;\n  font-size: 12px;\n  line-height: 17px;\n  opacity: 0;\n  transform: translateY(-4px);\n  transition: opacity .22s ease, transform .3s cubic-bezier(.2, .9, .2, 1);\n}\n.hb-yc9-row[data-open=\"true\"] .hb-yc9-body { opacity: 1; transform: none; transition-delay: .07s; }\n.hb-yc9-dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 0; }\n.hb-yc9-dl dt { color: #77777f; }\n.hb-yc9-dl dd { margin: 0; overflow: hidden; color: #ededed; text-align: right; text-overflow: ellipsis; white-space: nowrap; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-yc9-row, .hb-yc9-tile, .hb-yc9-chev, .hb-yc9-panel, .hb-yc9-body { transition: none; }\n}\n`;\n\nexport function ListExpandableRows({\n  items = defaultItems,\n  value,\n  defaultValue = [],\n  onChange,\n  multiple = false,\n  rowHeight = 48,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  onKeyDown,\n  ...rest\n}: ListExpandableRowsProps) {\n  const uid = React.useId();\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const [inner, setInner] = React.useState(defaultValue);\n  const openIds = value ?? inner;\n\n  function toggle(id: string) {\n    const has = openIds.includes(id);\n    const next = has ? openIds.filter((x) => x !== id) : multiple ? [...openIds, id] : [id];\n    if (value === undefined) setInner(next);\n    onChange?.(next);\n  }\n\n  function handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>) {\n    onKeyDown?.(e);\n    if (e.defaultPrevented) return;\n    const target = e.target as HTMLElement;\n    if (!target.hasAttribute(\"data-yc9-head\")) return;\n    const id = target.dataset.yc9Head ?? \"\";\n    if (e.key === \"Escape\") {\n      if (openIds.includes(id)) {\n        e.preventDefault();\n        toggle(id);\n      } else target.blur();\n      return;\n    }\n    const heads = Array.from(rootRef.current?.querySelectorAll<HTMLElement>(\"[data-yc9-head]\") ?? []);\n    const at = heads.indexOf(target);\n    let next = -1;\n    if (e.key === \"ArrowDown\") next = Math.min(heads.length - 1, at + 1);\n    else if (e.key === \"ArrowUp\") next = Math.max(0, at - 1);\n    else if (e.key === \"Home\") next = 0;\n    else if (e.key === \"End\") next = heads.length - 1;\n    if (next >= 0) {\n      e.preventDefault();\n      heads[next]?.focus();\n    }\n  }\n\n  const vars = { \"--hb-yc9-a\": accent, \"--hb-yc9-row\": `${rowHeight}px`, ...style } as React.CSSProperties;\n\n  return (\n    <div ref={rootRef} className={`hb-yc9 ${className}`} style={vars} onKeyDown={handleKeyDown} {...rest}>\n      <style href=\"hb-list-expandable-rows\" precedence=\"default\">{css}</style>\n      {items.map((item) => {\n        const isOpen = openIds.includes(item.id);\n        const panelId = `${uid}-${item.id}`;\n        const hasDetails = item.details !== undefined && item.details !== null;\n        return (\n          <div key={item.id} className=\"hb-yc9-row\" data-open={isOpen && hasDetails}>\n            <button\n              type=\"button\"\n              className=\"hb-yc9-head\"\n              data-yc9-head={item.id}\n              aria-expanded={hasDetails ? isOpen : undefined}\n              aria-controls={hasDetails ? panelId : undefined}\n              onClick={() => hasDetails && toggle(item.id)}\n            >\n              <span className=\"hb-yc9-tile\" style={item.color ? ({ \"--hb-yc9-c\": item.color } as React.CSSProperties) : undefined} aria-hidden=\"true\">\n                <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                  <path d={ICONS[item.icon ?? \"receipt\"]} />\n                </svg>\n              </span>\n              <span className=\"hb-yc9-txt\">\n                <span className=\"hb-yc9-name\">{item.title}</span>\n                {item.subtitle ? <span className=\"hb-yc9-sub\">{item.subtitle}</span> : null}\n              </span>\n              {item.meta ? <span className=\"hb-yc9-meta\">{item.meta}</span> : null}\n              {hasDetails ? (\n                <svg className=\"hb-yc9-chev\" viewBox=\"0 0 14 14\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                  <path d=\"M3.5 5.5L7 9l3.5-3.5\" />\n                </svg>\n              ) : null}\n            </button>\n            {hasDetails ? (\n              <div id={panelId} className=\"hb-yc9-panel\" role=\"region\" aria-label={item.title}>\n                <div className=\"hb-yc9-cut\" inert={!isOpen}>\n                  <div className=\"hb-yc9-body\">{item.details}</div>\n                </div>\n              </div>\n            ) : null}\n          </div>\n        );\n      })}\n    </div>\n  );\n}\n"
    }
  ]
}