{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "list-feed-windowed",
  "type": "registry:component",
  "title": "Windowed Activity Feed",
  "description": "A long activity feed that only renders the rows in view, with a pinned date header pushed away by the next day. A date scrubber on the edge jumps through weeks and shows the current day in a bubble while scrolling.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "lists",
    "feed",
    "virtual",
    "windowing",
    "sticky",
    "scrubber",
    "activity"
  ],
  "docs": "https://hyperblur.dev/effects/list-feed-windowed",
  "files": [
    {
      "path": "registry/hyperblur/list-feed-windowed.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/list-feed-windowed.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type FeedKind = \"deploy\" | \"comment\" | \"payment\" | \"alert\" | \"signup\" | \"merge\";\n\nexport interface FeedEntry {\n  id: string;\n  day: string;\n  time: string;\n  kind: FeedKind;\n  actor: string;\n  text: string;\n  meta?: string;\n}\n\nexport interface ListFeedWindowedProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n  items?: FeedEntry[];\n  height?: number;\n  rowHeight?: number;\n  headerHeight?: number;\n  overscan?: number;\n  accent?: string;\n  showScrubber?: boolean;\n  onItemClick?: (item: FeedEntry) => void;\n}\n\nconst months = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\nconst monthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\nconst weekdays = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\nfunction hash(n: number) {\n  let x = (n ^ 0x9e3779b9) >>> 0;\n  x = Math.imul(x ^ (x >>> 16), 0x85ebca6b) >>> 0;\n  x = Math.imul(x ^ (x >>> 13), 0xc2b2ae35) >>> 0;\n  return (x ^ (x >>> 16)) >>> 0;\n}\n\nconst actors = [\"Maya Chen\", \"Jonah Reyes\", \"Priya Raman\", \"Leo Marsh\", \"Amara Okafor\", \"Kenji Watanabe\", \"Sofia Lind\", \"Tomás Herrera\"];\nconst templates: Record<FeedKind, { text: string[]; meta: string[] }> = {\n  deploy: { text: [\"deployed api to production\", \"rolled out web v4.18\", \"promoted worker build to staging\", \"deployed billing service\"], meta: [\"2m 14s\", \"1m 52s\", \"3m 07s\", \"48s\"] },\n  comment: { text: [\"commented on Checkout redesign\", \"replied in Q4 planning\", \"left feedback on Onboarding copy\", \"mentioned you in Pricing FAQ\"], meta: [\"3 replies\", \"1 reply\", \"thread\", \"resolved\"] },\n  payment: { text: [\"paid invoice INV-2291\", \"upgraded Larkspur to Scale\", \"refunded order 10482\", \"added a card for Tidewater\"], meta: [\"$4,320.00\", \"$1,280.00\", \"$89.00\", \"Visa 4242\"] },\n  alert: { text: [\"p95 latency above 800 ms\", \"error rate spike on /checkout\", \"disk 91% on db-replica-2\", \"certificate renews in 7 days\"], meta: [\"resolved\", \"acknowledged\", \"open\", \"scheduled\"] },\n  signup: { text: [\"joined from Northbeam Labs\", \"accepted the workspace invite\", \"started a Growth trial\", \"verified the team domain\"], meta: [\"Growth\", \"Member\", \"Trial\", \"SSO\"] },\n  merge: { text: [\"merged #1842 Faster search index\", \"merged #1839 Fix timezone drift\", \"merged #1851 Dark mode tokens\", \"merged #1856 Audit log export\"], meta: [\"+412 −88\", \"+36 −12\", \"+904 −310\", \"+128 −4\"] },\n};\nconst kinds: FeedKind[] = [\"deploy\", \"comment\", \"payment\", \"alert\", \"signup\", \"merge\"];\n\nfunction buildDefault(): FeedEntry[] {\n  const out: FeedEntry[] = [];\n  let y = 2026;\n  let m = 10;\n  let d = 7;\n  let wd = 6;\n  for (let day = 0; day < 45; day++) {\n    const label = day === 0 ? \"Today\" : day === 1 ? \"Yesterday\" : `${weekdays[wd]}, ${months[m]} ${d}`;\n    const count = 3 + (hash(day * 7 + 1) % 10);\n    let minute = 23 * 60 + 40;\n    for (let k = 0; k < count; k++) {\n      const h = hash(day * 131 + k * 17 + 5);\n      minute -= 20 + (h % 90);\n      if (minute < 0) minute = 5;\n      const kind = kinds[h % kinds.length];\n      const t = templates[kind];\n      const hh = Math.floor(minute / 60);\n      const mm = minute % 60;\n      out.push({\n        id: `f${day}-${k}`,\n        day: label,\n        time: `${((hh + 11) % 12) + 1}:${String(mm).padStart(2, \"0\")} ${hh < 12 ? \"AM\" : \"PM\"}`,\n        kind,\n        actor: actors[(h >>> 3) % actors.length],\n        text: t.text[(h >>> 6) % t.text.length],\n        meta: t.meta[(h >>> 9) % t.meta.length],\n      });\n    }\n    d -= 1;\n    wd = (wd + 6) % 7;\n    if (d === 0) {\n      m -= 1;\n      if (m < 0) {\n        m = 11;\n        y -= 1;\n      }\n      d = monthDays[m] + (m === 1 && y % 4 === 0 ? 1 : 0);\n    }\n  }\n  return out;\n}\n\nconst defaultItems = buildDefault();\n\nconst kindColor: Record<FeedKind, string> = {\n  deploy: \"#2f7bff\",\n  comment: \"#a78bfa\",\n  payment: \"#4ade80\",\n  alert: \"#ff7a6b\",\n  signup: \"#f5b544\",\n  merge: \"#22c3a6\",\n};\n\nconst kindPath: Record<FeedKind, string> = {\n  deploy: \"M7 1.5c2.2 1.3 3.3 3.5 3 6.3L8.4 9.4H5.6L4 7.8C3.7 5 4.8 2.8 7 1.5ZM5.6 9.4 4.5 12M8.4 9.4 9.5 12\",\n  comment: \"M2 3.2c0-.7.5-1.2 1.2-1.2h7.6c.7 0 1.2.5 1.2 1.2v5.1c0 .7-.5 1.2-1.2 1.2H6L3.4 11.8V9.5h-.2C2.5 9.5 2 9 2 8.3Z\",\n  payment: \"M1.8 4h10.4v6.4H1.8zM1.8 6.2h10.4M4 8.5h2\",\n  alert: \"M7 1.8 12.6 11.6H1.4zM7 5.6v2.6M7 9.9v.1\",\n  signup: \"M7 6.6a2.2 2.2 0 1 0 0-4.4 2.2 2.2 0 0 0 0 4.4ZM2.8 12c.4-2.3 2-3.6 4.2-3.6s3.8 1.3 4.2 3.6\",\n  merge: \"M4 2.2v9.6M4 5.4c0 2.4 6 1.6 6 4.4M4 2.2a.1.1 0 1 0 0 .1M10 11.8a.1.1 0 1 0 0 .1\",\n};\n\ntype Row = { type: \"head\"; day: string; count: number; top: number; h: number; gi: number } | { type: \"item\"; item: FeedEntry; top: number; h: number; index: number };\n\nconst css = `\n.hb-wi6 {\n  --hb-wi6-a: #2f7bff;\n  position: relative;\n  width: 100%;\n  box-sizing: border-box;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 12.5px;\n  border: 1px solid #262626;\n  border-radius: 12px;\n  background: #0d0d0d;\n  overflow: hidden;\n}\n.hb-wi6 *, .hb-wi6 *::before, .hb-wi6 *::after { box-sizing: border-box; }\n.hb-wi6-scroll {\n  position: relative;\n  height: var(--hb-wi6-h, 320px);\n  overflow-y: auto;\n  overscroll-behavior: contain;\n  scrollbar-width: none;\n  outline: none;\n}\n.hb-wi6-scroll::-webkit-scrollbar { display: none; }\n.hb-wi6-scroll:focus-visible { box-shadow: inset 0 0 0 2px rgba(127, 179, 255, 0.6); }\n.hb-wi6-space { position: relative; width: 100%; }\n.hb-wi6-head, .hb-wi6-pin {\n  position: absolute;\n  left: 0;\n  right: 0;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  padding: 0 40px 0 14px;\n  font-size: 11px;\n  font-weight: 600;\n  letter-spacing: 0.04em;\n  text-transform: uppercase;\n  color: #a1a1a1;\n  background: rgba(13, 13, 13, 0.92);\n  backdrop-filter: blur(8px);\n  border-bottom: 1px solid #1c1c1c;\n}\n.hb-wi6-head span, .hb-wi6-pin span { font-weight: 500; letter-spacing: 0; text-transform: none; color: #5f5f5f; font-variant-numeric: tabular-nums; }\n.hb-wi6-pin { top: 0; z-index: 3; pointer-events: none; color: #ededed; box-shadow: 0 6px 14px -8px rgba(0, 0, 0, 0.8); }\n.hb-wi6-item {\n  position: absolute;\n  left: 0;\n  right: 0;\n  display: grid;\n  grid-template-columns: 28px minmax(0, 1fr) auto;\n  align-items: center;\n  gap: 10px;\n  padding: 0 40px 0 14px;\n  border: 0;\n  background: transparent;\n  color: inherit;\n  font: inherit;\n  text-align: left;\n  cursor: pointer;\n  transition: background 0.15s ease;\n}\n.hb-wi6-item::after { content: \"\"; position: absolute; left: 27px; top: 0; bottom: 0; width: 1px; background: #1c1c1c; z-index: -1; }\n.hb-wi6-item:hover { background: rgba(255, 255, 255, 0.025); }\n.hb-wi6-item:focus-visible { outline: none; background: rgba(127, 179, 255, 0.06); box-shadow: inset 2px 0 0 var(--hb-wi6-a); }\n.hb-wi6-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: #141414; border: 1px solid #242424; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04); }\n.hb-wi6-tx { min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 1.25; }\n.hb-wi6-tx p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #bdbdbd; }\n.hb-wi6-tx p b { color: #ededed; font-weight: 550; }\n.hb-wi6-tx small { font-size: 11px; color: #5f5f5f; font-variant-numeric: tabular-nums; }\n.hb-wi6-meta { font-size: 11px; color: #8f8f8f; font-variant-numeric: tabular-nums; white-space: nowrap; padding: 2px 7px; border-radius: 6px; background: #141414; border: 1px solid #222; }\n.hb-wi6-rail {\n  position: absolute;\n  top: 8px;\n  bottom: 8px;\n  right: 6px;\n  width: 22px;\n  z-index: 4;\n  touch-action: none;\n  cursor: ns-resize;\n  outline: none;\n}\n.hb-wi6-rail:focus-visible { box-shadow: 0 0 0 2px rgba(127, 179, 255, 0.6); border-radius: 6px; }\n.hb-wi6-tick { position: absolute; right: 8px; width: 6px; height: 1px; background: #333; transition: width 0.2s ease, background 0.2s ease; }\n.hb-wi6-tick[data-week=\"true\"] { width: 10px; background: #4a4a4a; }\n.hb-wi6-tick[data-on=\"true\"] { width: 14px; background: var(--hb-wi6-a); }\n.hb-wi6-thumb {\n  position: absolute;\n  right: 6px;\n  width: 4px;\n  min-height: 14px;\n  border-radius: 2px;\n  background: rgba(255, 255, 255, 0.22);\n  transition: background 0.2s ease, width 0.2s ease;\n}\n.hb-wi6-rail:hover .hb-wi6-thumb, .hb-wi6[data-scrub=\"true\"] .hb-wi6-thumb { background: var(--hb-wi6-a); width: 5px; }\n.hb-wi6-bubble {\n  position: absolute;\n  right: 30px;\n  z-index: 5;\n  padding: 5px 9px;\n  border-radius: 8px;\n  background: #ededed;\n  color: #0a0a0a;\n  font-size: 11.5px;\n  font-weight: 600;\n  white-space: nowrap;\n  pointer-events: none;\n  transform: translate(6px, -50%);\n  opacity: 0;\n  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);\n  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);\n}\n.hb-wi6-bubble::after { content: \"\"; position: absolute; right: -4px; top: 50%; width: 8px; height: 8px; background: #ededed; transform: translateY(-50%) rotate(45deg); border-radius: 1px; }\n.hb-wi6[data-moving=\"true\"] .hb-wi6-bubble { opacity: 1; transform: translate(0, -50%); }\n.hb-wi6-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-wi6-bubble, .hb-wi6-tick, .hb-wi6-thumb, .hb-wi6-item { transition: none; }\n}\n`;\n\nexport function ListFeedWindowed({\n  items = defaultItems,\n  height = 320,\n  rowHeight = 54,\n  headerHeight = 30,\n  overscan = 6,\n  accent = \"#2f7bff\",\n  showScrubber = true,\n  onItemClick,\n  className,\n  style,\n  ...rest\n}: ListFeedWindowedProps) {\n  const scrollRef = React.useRef<HTMLDivElement>(null);\n  const railRef = React.useRef<HTMLDivElement>(null);\n  const idleRef = React.useRef(0);\n  const [top, setTop] = React.useState(0);\n  const [moving, setMoving] = React.useState(false);\n  const [scrub, setScrub] = React.useState(false);\n\n  const model = React.useMemo(() => {\n    const rows: Row[] = [];\n    const groups: { day: string; top: number; count: number }[] = [];\n    let y = 0;\n    let index = 0;\n    let i = 0;\n    while (i < items.length) {\n      const day = items[i].day;\n      let j = i;\n      while (j < items.length && items[j].day === day) j++;\n      rows.push({ type: \"head\", day, count: j - i, top: y, h: headerHeight, gi: groups.length });\n      groups.push({ day, top: y, count: j - i });\n      y += headerHeight;\n      for (let k = i; k < j; k++) {\n        rows.push({ type: \"item\", item: items[k], top: y, h: rowHeight, index: index++ });\n        y += rowHeight;\n      }\n      i = j;\n    }\n    return { rows, groups, total: y };\n  }, [items, rowHeight, headerHeight]);\n\n  const viewH = height;\n  const find = (y: number) => {\n    let lo = 0;\n    let hi = model.rows.length - 1;\n    while (lo < hi) {\n      const mid = (lo + hi + 1) >> 1;\n      if (model.rows[mid].top <= y) lo = mid;\n      else hi = mid - 1;\n    }\n    return lo;\n  };\n  const first = Math.max(0, find(top) - overscan);\n  const last = Math.min(model.rows.length - 1, find(top + viewH) + overscan);\n  const visible = model.rows.slice(first, last + 1);\n\n  let gi = 0;\n  for (let k = 0; k < model.groups.length; k++) if (model.groups[k].top <= top) gi = k;\n  const nextTop = model.groups[gi + 1]?.top ?? Infinity;\n  const push = Math.min(0, nextTop - top - headerHeight);\n  const current = model.groups[gi];\n\n  const ping = () => {\n    setMoving(true);\n    window.clearTimeout(idleRef.current);\n    idleRef.current = window.setTimeout(() => setMoving(false), 700);\n  };\n\n  React.useEffect(() => () => window.clearTimeout(idleRef.current), []);\n\n  const onScroll = () => {\n    const el = scrollRef.current;\n    if (!el) return;\n    setTop(el.scrollTop);\n    ping();\n  };\n\n  const maxScroll = Math.max(1, model.total - viewH);\n  const scrubTo = (clientY: number) => {\n    const rail = railRef.current;\n    const el = scrollRef.current;\n    if (!rail || !el) return;\n    const r = rail.getBoundingClientRect();\n    const t = Math.min(1, Math.max(0, (clientY - r.top) / r.height));\n    el.scrollTop = t * maxScroll;\n  };\n\n  const jumpGroup = (dir: number) => {\n    const el = scrollRef.current;\n    const g = model.groups[Math.min(model.groups.length - 1, Math.max(0, gi + dir))];\n    if (el && g) el.scrollTop = g.top;\n  };\n\n  const thumbH = Math.max(6, (viewH / Math.max(viewH, model.total)) * 100);\n  const thumbTop = (top / maxScroll) * (100 - thumbH);\n  const bubbleTop = Math.min(92, Math.max(8, (top / maxScroll) * 100));\n  const weekly = Math.max(1, Math.round(model.groups.length / 12));\n\n  return (\n    <div\n      {...rest}\n      className={[\"hb-wi6\", className].filter(Boolean).join(\" \")}\n      style={{ ...style, [\"--hb-wi6-a\" as string]: accent, [\"--hb-wi6-h\" as string]: `${height}px` } as React.CSSProperties}\n      data-moving={moving}\n      data-scrub={scrub}\n    >\n      <style href=\"hb-list-feed-windowed\" precedence=\"default\">{css}</style>\n      <div\n        ref={scrollRef}\n        className=\"hb-wi6-scroll\"\n        tabIndex={0}\n        role=\"list\"\n        aria-label={`Activity, ${items.length} events`}\n        onScroll={onScroll}\n        onKeyDown={(e) => {\n          const el = scrollRef.current;\n          if (!el) return;\n          if (e.key === \"ArrowDown\" || e.key === \"j\") {\n            e.preventDefault();\n            el.scrollTop += rowHeight;\n          } else if (e.key === \"ArrowUp\" || e.key === \"k\") {\n            e.preventDefault();\n            el.scrollTop -= rowHeight;\n          } else if (e.key === \"]\") {\n            jumpGroup(1);\n          } else if (e.key === \"[\") {\n            jumpGroup(-1);\n          }\n        }}\n      >\n        <div className=\"hb-wi6-space\" style={{ height: model.total }}>\n          {visible.map((r) =>\n            r.type === \"head\" ? (\n              <div key={`h-${r.day}`} className=\"hb-wi6-head\" style={{ top: r.top, height: r.h }} aria-hidden=\"true\">\n                {r.day}\n                <span>{r.count} events</span>\n              </div>\n            ) : (\n              <button\n                key={r.item.id}\n                type=\"button\"\n                role=\"listitem\"\n                aria-setsize={items.length}\n                aria-posinset={r.index + 1}\n                className=\"hb-wi6-item\"\n                style={{ top: r.top, height: r.h }}\n                tabIndex={-1}\n                onClick={() => onItemClick?.(r.item)}\n              >\n                <span className=\"hb-wi6-ic\" aria-hidden=\"true\">\n                  <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\">\n                    <path d={kindPath[r.item.kind]} fill=\"none\" stroke={kindColor[r.item.kind]} strokeWidth=\"1.3\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                  </svg>\n                </span>\n                <span className=\"hb-wi6-tx\">\n                  <p>\n                    <b>{r.item.actor}</b> {r.item.text}\n                  </p>\n                  <small>\n                    {r.item.day} · {r.item.time}\n                  </small>\n                </span>\n                {r.item.meta ? <span className=\"hb-wi6-meta\">{r.item.meta}</span> : null}\n              </button>\n            ),\n          )}\n        </div>\n      </div>\n      {current ? (\n        <div className=\"hb-wi6-pin\" style={{ height: headerHeight, transform: `translateY(${push.toFixed(1)}px)` }} aria-hidden=\"true\">\n          {current.day}\n          <span>{current.count} events</span>\n        </div>\n      ) : null}\n      {showScrubber ? (\n        <div\n          ref={railRef}\n          className=\"hb-wi6-rail\"\n          role=\"slider\"\n          tabIndex={0}\n          aria-label=\"Jump to date\"\n          aria-valuemin={0}\n          aria-valuemax={model.groups.length - 1}\n          aria-valuenow={gi}\n          aria-valuetext={current?.day}\n          onPointerDown={(e) => {\n            e.currentTarget.setPointerCapture(e.pointerId);\n            setScrub(true);\n            scrubTo(e.clientY);\n          }}\n          onPointerMove={(e) => {\n            if (scrub) scrubTo(e.clientY);\n          }}\n          onPointerUp={() => setScrub(false)}\n          onPointerCancel={() => setScrub(false)}\n          onKeyDown={(e) => {\n            if (e.key === \"ArrowDown\" || e.key === \"ArrowRight\") {\n              e.preventDefault();\n              jumpGroup(1);\n            } else if (e.key === \"ArrowUp\" || e.key === \"ArrowLeft\") {\n              e.preventDefault();\n              jumpGroup(-1);\n            } else if (e.key === \"Home\") {\n              e.preventDefault();\n              if (scrollRef.current) scrollRef.current.scrollTop = 0;\n            } else if (e.key === \"End\") {\n              e.preventDefault();\n              if (scrollRef.current) scrollRef.current.scrollTop = maxScroll;\n            }\n          }}\n        >\n          {model.groups.map((g, k) => (\n            <span key={g.day} className=\"hb-wi6-tick\" data-week={k % weekly === 0} data-on={k === gi} style={{ top: `${((Math.min(g.top, maxScroll) / maxScroll) * 100).toFixed(2)}%` }} />\n          ))}\n          <span className=\"hb-wi6-thumb\" style={{ top: `${thumbTop.toFixed(2)}%`, height: `${thumbH.toFixed(2)}%` }} />\n          <span className=\"hb-wi6-bubble\" style={{ top: `${bubbleTop.toFixed(2)}%` }}>\n            {current?.day}\n          </span>\n        </div>\n      ) : null}\n      <div className=\"hb-wi6-sr\" aria-live=\"polite\">\n        {current?.day}\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}