{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "list-activity-filters",
  "type": "registry:component",
  "title": "Filterable Activity Timeline",
  "description": "A team timeline with a stacked weekly histogram on top: click a day bar to narrow to that day, toggle event types with counted chips and filter by people. Counts and bars recompute as filters combine, and entries cascade back in.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "lists",
    "timeline",
    "filters",
    "activity",
    "histogram",
    "audit",
    "chips"
  ],
  "docs": "https://hyperblur.dev/effects/list-activity-filters",
  "files": [
    {
      "path": "registry/hyperblur/list-activity-filters.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/list-activity-filters.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type ActivityType = \"code\" | \"review\" | \"deploy\" | \"incident\" | \"docs\";\n\nexport interface ActivityEvent {\n  id: string;\n  type: ActivityType;\n  actor: string;\n  action: string;\n  target: string;\n  day: number;\n  time: string;\n  detail?: string;\n}\n\nexport interface ActivityFilterState {\n  types: ActivityType[];\n  people: string[];\n  day: number | null;\n}\n\nexport interface ListActivityFiltersProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\" | \"onChange\"> {\n  events?: ActivityEvent[];\n  dayLabels?: string[];\n  accent?: string;\n  defaultFilters?: Partial<ActivityFilterState>;\n  onFiltersChange?: (filters: ActivityFilterState) => void;\n  maxHeight?: number;\n}\n\nconst typeMeta: Record<ActivityType, { label: string; color: string; path: string }> = {\n  code: { label: \"Commits\", color: \"#2f7bff\", path: \"M4.5 4 1.8 7l2.7 3M9.5 4l2.7 3-2.7 3M8 2.5 6 11.5\" },\n  review: { label: \"Reviews\", color: \"#a78bfa\", path: \"M1.5 7s2-4 5.5-4 5.5 4 5.5 4-2 4-5.5 4-5.5-4-5.5-4ZM7 8.6a1.6 1.6 0 1 0 0-3.2 1.6 1.6 0 0 0 0 3.2Z\" },\n  deploy: { label: \"Deploys\", color: \"#22c3a6\", path: \"M7 1.8v7.4M3.8 6 7 9.2 10.2 6M2.5 12h9\" },\n  incident: { label: \"Incidents\", color: \"#ff7a6b\", path: \"M7 1.8 12.6 11.6H1.4zM7 5.6v2.6M7 9.9v.1\" },\n  docs: { label: \"Docs\", color: \"#f5b544\", path: \"M3.5 1.8h4.8l2.2 2.2v8.2h-7zM8.2 1.8V4h2.3M5.2 7h3.6M5.2 9.2h3.6\" },\n};\n\nconst defaultDays = [\"Sun 1\", \"Mon 2\", \"Tue 3\", \"Wed 4\", \"Thu 5\", \"Fri 6\", \"Sat 7\"];\n\nconst defaultEvents: ActivityEvent[] = [\n  { id: \"e1\", type: \"deploy\", actor: \"Maya Chen\", action: \"deployed\", target: \"api v2.41 to production\", day: 6, time: \"4:12 PM\", detail: \"Canary 10% for 20 min, then full rollout. No error budget burn.\" },\n  { id: \"e2\", type: \"incident\", actor: \"Jonah Reyes\", action: \"resolved\", target: \"INC-311 checkout latency\", day: 6, time: \"11:48 AM\", detail: \"Root cause: cold cache after the Redis failover. Added a warmup job.\" },\n  { id: \"e3\", type: \"review\", actor: \"Priya Raman\", action: \"approved\", target: \"#1856 Audit log export\", day: 6, time: \"10:05 AM\" },\n  { id: \"e4\", type: \"code\", actor: \"Leo Marsh\", action: \"pushed 6 commits to\", target: \"feat/billing-empty-states\", day: 5, time: \"6:31 PM\" },\n  { id: \"e5\", type: \"docs\", actor: \"Priya Raman\", action: \"published\", target: \"SSO setup guide\", day: 5, time: \"2:20 PM\", detail: \"Covers SAML metadata upload, SCIM tokens and test sign-in.\" },\n  { id: \"e6\", type: \"incident\", actor: \"Jonah Reyes\", action: \"opened\", target: \"INC-311 checkout latency\", day: 5, time: \"9:02 AM\" },\n  { id: \"e7\", type: \"review\", actor: \"Maya Chen\", action: \"requested changes on\", target: \"#1851 Dark mode tokens\", day: 4, time: \"5:44 PM\", detail: \"Contrast of muted text drops below 4.5:1 on the card surface.\" },\n  { id: \"e8\", type: \"code\", actor: \"Kenji Watanabe\", action: \"merged\", target: \"#1849 Retry webhooks with backoff\", day: 4, time: \"1:15 PM\" },\n  { id: \"e9\", type: \"deploy\", actor: \"Kenji Watanabe\", action: \"deployed\", target: \"worker v1.19 to staging\", day: 3, time: \"3:50 PM\" },\n  { id: \"e10\", type: \"code\", actor: \"Maya Chen\", action: \"pushed 3 commits to\", target: \"fix/export-rate-limit\", day: 3, time: \"11:27 AM\" },\n  { id: \"e11\", type: \"docs\", actor: \"Leo Marsh\", action: \"updated\", target: \"Billing FAQ\", day: 2, time: \"4:03 PM\" },\n  { id: \"e12\", type: \"review\", actor: \"Kenji Watanabe\", action: \"approved\", target: \"#1842 Faster search index\", day: 2, time: \"10:40 AM\" },\n  { id: \"e13\", type: \"code\", actor: \"Priya Raman\", action: \"merged\", target: \"#1842 Faster search index\", day: 2, time: \"12:02 PM\" },\n  { id: \"e14\", type: \"deploy\", actor: \"Maya Chen\", action: \"rolled back\", target: \"web v4.17\", day: 1, time: \"7:18 PM\", detail: \"Hydration error on Safari 17. Fixed in v4.18 the next morning.\" },\n];\n\nfunction hueOf(n: string) {\n  let h = 7;\n  for (let i = 0; i < n.length; i++) h = (Math.imul(h, 31) + n.charCodeAt(i)) >>> 0;\n  return h % 360;\n}\n\nconst css = `\n.hb-wi8 {\n  --hb-wi8-a: #2f7bff;\n  container-type: inline-size;\n  position: relative;\n  width: 100%;\n  box-sizing: border-box;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 12.5px;\n}\n.hb-wi8 *, .hb-wi8 *::before, .hb-wi8 *::after { box-sizing: border-box; }\n.hb-wi8-hist { display: grid; grid-template-columns: repeat(var(--hb-wi8-n, 7), 1fr); gap: 4px; height: 52px; margin-bottom: 10px; }\n.hb-wi8-day {\n  position: relative;\n  display: flex;\n  flex-direction: column;\n  justify-content: flex-end;\n  align-items: stretch;\n  gap: 4px;\n  padding: 0;\n  border: 0;\n  background: transparent;\n  color: #5f5f5f;\n  font: inherit;\n  font-size: 9.5px;\n  cursor: pointer;\n  border-radius: 6px;\n}\n.hb-wi8-day:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(127, 179, 255, 0.7); }\n.hb-wi8-stack { display: flex; flex-direction: column-reverse; gap: 1px; height: 34px; justify-content: flex-start; border-radius: 4px; overflow: hidden; background: #131313; }\n.hb-wi8-stack i { display: block; flex: none; transform-origin: bottom; animation: hb-wi8-rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both; animation-delay: var(--hb-wi8-d, 0ms); transition: opacity 0.25s ease; }\n@keyframes hb-wi8-rise { from { transform: scaleY(0); } }\n.hb-wi8-day span { text-align: center; white-space: nowrap; transition: color 0.2s ease; }\n.hb-wi8-day:hover span { color: #a1a1a1; }\n.hb-wi8-day[aria-pressed=\"true\"] span { color: #ededed; font-weight: 600; }\n.hb-wi8-day[aria-pressed=\"true\"] .hb-wi8-stack { box-shadow: 0 0 0 1.5px var(--hb-wi8-a); }\n.hb-wi8[data-dayfilter=\"true\"] .hb-wi8-day[aria-pressed=\"false\"] .hb-wi8-stack i { opacity: 0.3; }\n.hb-wi8-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; overflow-x: auto; scrollbar-width: none; }\n.hb-wi8-bar::-webkit-scrollbar { display: none; }\n.hb-wi8-chip {\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  flex: none;\n  height: 26px;\n  padding: 0 9px 0 7px;\n  border-radius: 999px;\n  border: 1px solid #262626;\n  background: #111;\n  color: #a1a1a1;\n  font: inherit;\n  font-size: 11.5px;\n  cursor: pointer;\n  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.6, 0.64, 1);\n}\n.hb-wi8-chip:hover { color: #ededed; border-color: #333; }\n.hb-wi8-chip:active { transform: scale(0.96); }\n.hb-wi8-chip:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(127, 179, 255, 0.7); }\n.hb-wi8-chip[aria-pressed=\"true\"] { color: #ededed; border-color: color-mix(in srgb, var(--hb-wi8-c) 50%, #262626); background: color-mix(in srgb, var(--hb-wi8-c) 12%, #111); }\n.hb-wi8-chip svg { color: var(--hb-wi8-c); }\n.hb-wi8-chip b { font-weight: 500; font-size: 10.5px; color: #6f6f6f; font-variant-numeric: tabular-nums; }\n.hb-wi8-chip[aria-pressed=\"true\"] b { color: color-mix(in srgb, var(--hb-wi8-c) 70%, #fff); }\n.hb-wi8-people { display: flex; align-items: center; margin-left: auto; padding-left: 6px; flex: none; }\n.hb-wi8-person {\n  width: 24px;\n  height: 24px;\n  margin-left: -5px;\n  border-radius: 50%;\n  border: 2px solid #0a0a0a;\n  display: grid;\n  place-items: center;\n  font-size: 9px;\n  font-weight: 700;\n  color: #fff;\n  cursor: pointer;\n  padding: 0;\n  font-family: inherit;\n  transition: transform 0.25s cubic-bezier(0.34, 1.6, 0.64, 1), opacity 0.2s ease, box-shadow 0.2s ease;\n}\n.hb-wi8-person:hover { transform: translateY(-2px); z-index: 1; }\n.hb-wi8-person:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(127, 179, 255, 0.8); z-index: 1; }\n.hb-wi8[data-peoplefilter=\"true\"] .hb-wi8-person[aria-pressed=\"false\"] { opacity: 0.35; }\n.hb-wi8-person[aria-pressed=\"true\"] { box-shadow: 0 0 0 2px var(--hb-wi8-a); z-index: 1; }\n.hb-wi8-scroll { max-height: var(--hb-wi8-mh, 360px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #2a2a2a transparent; }\n.hb-wi8-list { position: relative; margin: 0; padding: 0 0 0 4px; list-style: none; }\n.hb-wi8-list::before { content: \"\"; position: absolute; left: 17px; top: 8px; bottom: 8px; width: 1px; background: linear-gradient(#262626, #1a1a1a 80%, transparent); }\n.hb-wi8-sep { position: relative; padding: 8px 0 6px 36px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: #6f6f6f; }\n.hb-wi8-ev { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; padding: 5px 0; animation: hb-wi8-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) both; animation-delay: var(--hb-wi8-d, 0ms); }\n@keyframes hb-wi8-in { from { opacity: 0; transform: translateX(-8px); } }\n.hb-wi8-node { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: #121212; border: 1px solid color-mix(in srgb, var(--hb-wi8-c) 35%, #262626); box-shadow: 0 0 0 4px #0a0a0a, inset 0 1px 0 rgba(255, 255, 255, 0.04); color: var(--hb-wi8-c); }\n.hb-wi8-body { min-width: 0; padding-top: 2px; }\n.hb-wi8-line { margin: 0; line-height: 1.35; color: #a1a1a1; }\n.hb-wi8-line b { color: #ededed; font-weight: 550; }\n.hb-wi8-line span { color: #d4d4d4; }\n.hb-wi8-time { font-size: 11px; color: #5f5f5f; font-variant-numeric: tabular-nums; }\n.hb-wi8-detail { margin-top: 6px; padding: 8px 10px; border-radius: 8px; border: 1px solid #1f1f1f; background: #101010; font-size: 11.5px; line-height: 1.45; color: #a1a1a1; }\n.hb-wi8-none { padding: 26px 0; text-align: center; color: #6f6f6f; font-size: 12px; }\n.hb-wi8-clear { margin-left: 6px; padding: 0; border: 0; background: none; color: #7fb3ff; font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }\n.hb-wi8-clear:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(127, 179, 255, 0.7); border-radius: 3px; }\n.hb-wi8-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@container (max-width: 380px) {\n  .hb-wi8-chip span { display: none; }\n  .hb-wi8-chip { padding: 0 8px; }\n  .hb-wi8-detail { display: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-wi8-stack i, .hb-wi8-ev { animation: none; }\n  .hb-wi8-chip, .hb-wi8-person { transition: none; }\n}\n`;\n\nconst types = Object.keys(typeMeta) as ActivityType[];\n\nexport function ListActivityFilters({\n  events = defaultEvents,\n  dayLabels = defaultDays,\n  accent = \"#2f7bff\",\n  defaultFilters,\n  onFiltersChange,\n  maxHeight = 360,\n  className,\n  style,\n  ...rest\n}: ListActivityFiltersProps) {\n  const [filters, setFilters] = React.useState<ActivityFilterState>({ types: defaultFilters?.types ?? [], people: defaultFilters?.people ?? [], day: defaultFilters?.day ?? null });\n  const [version, setVersion] = React.useState(0);\n\n  const update = (next: ActivityFilterState) => {\n    setFilters(next);\n    setVersion((v) => v + 1);\n    onFiltersChange?.(next);\n  };\n\n  const people = React.useMemo(() => [...new Set(events.map((e) => e.actor))], [events]);\n  const byPeople = (e: ActivityEvent) => filters.people.length === 0 || filters.people.includes(e.actor);\n  const byType = (e: ActivityEvent) => filters.types.length === 0 || filters.types.includes(e.type);\n  const byDay = (e: ActivityEvent) => filters.day === null || e.day === filters.day;\n  const shown = events.filter((e) => byPeople(e) && byType(e) && byDay(e)).sort((a, b) => b.day - a.day);\n  const histBase = events.filter((e) => byPeople(e) && byType(e));\n  const maxDay = Math.max(1, ...dayLabels.map((_, d) => histBase.filter((e) => e.day === d).length), ...dayLabels.map((_, d) => events.filter((e) => e.day === d).length));\n  const active = filters.types.length > 0 || filters.people.length > 0 || filters.day !== null;\n\n  const toggleIn = <T,>(list: T[], v: T) => (list.includes(v) ? list.filter((x) => x !== v) : [...list, v]);\n\n  return (\n    <div\n      {...rest}\n      className={[\"hb-wi8\", className].filter(Boolean).join(\" \")}\n      style={{ ...style, [\"--hb-wi8-a\" as string]: accent, [\"--hb-wi8-n\" as string]: dayLabels.length, [\"--hb-wi8-mh\" as string]: `${maxHeight}px` } as React.CSSProperties}\n      data-dayfilter={filters.day !== null}\n      data-peoplefilter={filters.people.length > 0}\n    >\n      <style href=\"hb-list-activity-filters\" precedence=\"default\">{css}</style>\n      <div className=\"hb-wi8-hist\" role=\"group\" aria-label=\"Filter by day\">\n        {dayLabels.map((label, d) => {\n          const dayEvents = histBase.filter((e) => e.day === d);\n          return (\n            <button\n              key={label}\n              type=\"button\"\n              className=\"hb-wi8-day\"\n              aria-pressed={filters.day === d}\n              aria-label={`${label}, ${dayEvents.length} events`}\n              onClick={() => update({ ...filters, day: filters.day === d ? null : d })}\n            >\n              <span className=\"hb-wi8-stack\" aria-hidden=\"true\">\n                {types.map((t) => {\n                  const c = dayEvents.filter((e) => e.type === t).length;\n                  if (!c) return null;\n                  return <i key={`${t}-${version}`} style={{ height: `${((c / maxDay) * 100).toFixed(1)}%`, background: typeMeta[t].color, [\"--hb-wi8-d\" as string]: `${d * 50}ms` } as React.CSSProperties} />;\n                })}\n              </span>\n              <span>{label}</span>\n            </button>\n          );\n        })}\n      </div>\n      <div className=\"hb-wi8-bar\">\n        {types.map((t) => {\n          const count = events.filter((e) => e.type === t && byPeople(e) && byDay(e)).length;\n          return (\n            <button key={t} type=\"button\" className=\"hb-wi8-chip\" aria-pressed={filters.types.includes(t)} aria-label={`${typeMeta[t].label}, ${count}`} style={{ [\"--hb-wi8-c\" as string]: typeMeta[t].color } as React.CSSProperties} onClick={() => update({ ...filters, types: toggleIn(filters.types, t) })}>\n              <svg width=\"13\" height=\"13\" viewBox=\"0 0 14 14\" aria-hidden=\"true\">\n                <path d={typeMeta[t].path} fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.3\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n              </svg>\n              <span>{typeMeta[t].label}</span>\n              <b>{count}</b>\n            </button>\n          );\n        })}\n        <div className=\"hb-wi8-people\" role=\"group\" aria-label=\"Filter by person\">\n          {people.map((p) => (\n            <button\n              key={p}\n              type=\"button\"\n              className=\"hb-wi8-person\"\n              aria-pressed={filters.people.includes(p)}\n              aria-label={p}\n              title={p}\n              style={{ background: `linear-gradient(135deg, hsl(${hueOf(p)} 60% 52%), hsl(${(hueOf(p) + 30) % 360} 55% 38%))` }}\n              onClick={() => update({ ...filters, people: toggleIn(filters.people, p) })}\n            >\n              {p\n                .split(\" \")\n                .map((w) => w[0])\n                .join(\"\")}\n            </button>\n          ))}\n        </div>\n      </div>\n      <div className=\"hb-wi8-scroll\">\n        {shown.length ? (\n          <ol className=\"hb-wi8-list\" key={version}>\n            {shown.map((e, idx) => {\n              const sep = idx === 0 || shown[idx - 1].day !== e.day;\n              const tm = typeMeta[e.type];\n              const delay = Math.min(10, idx) * 35;\n              return (\n                <React.Fragment key={e.id}>\n                  {sep ? (\n                    <li className=\"hb-wi8-sep\" aria-hidden=\"true\">\n                      {dayLabels[e.day] ?? `Day ${e.day + 1}`}\n                    </li>\n                  ) : null}\n                  <li className=\"hb-wi8-ev\" style={{ [\"--hb-wi8-c\" as string]: tm.color, [\"--hb-wi8-d\" as string]: `${delay}ms` } as React.CSSProperties}>\n                    <span className=\"hb-wi8-node\" aria-hidden=\"true\">\n                      <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\">\n                        <path d={tm.path} fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.3\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                      </svg>\n                    </span>\n                    <div className=\"hb-wi8-body\">\n                      <p className=\"hb-wi8-line\">\n                        <b>{e.actor}</b> {e.action} <span>{e.target}</span>\n                      </p>\n                      <span className=\"hb-wi8-time\">\n                        {tm.label.replace(/s$/, \"\")} · {e.time}\n                      </span>\n                      {e.detail ? <div className=\"hb-wi8-detail\">{e.detail}</div> : null}\n                    </div>\n                  </li>\n                </React.Fragment>\n              );\n            })}\n          </ol>\n        ) : (\n          <div className=\"hb-wi8-none\">\n            No activity matches these filters.\n            <button type=\"button\" className=\"hb-wi8-clear\" onClick={() => update({ types: [], people: [], day: null })}>\n              Clear filters\n            </button>\n          </div>\n        )}\n      </div>\n      <div className=\"hb-wi8-sr\" aria-live=\"polite\">\n        {active ? `${shown.length} events shown` : \"\"}\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}