{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "date-grouped-activity-list",
  "title": "Date Grouped Activity List",
  "description": "An activity feed grouped under Today, Yesterday and dated headings with sticky headings, relative times and an index that jumps between days. Use this when a phone shows a history ordered by time, such as activity, transactions or messages, and people look for a day.",
  "registryDependencies": [
    "@tealmac/section-list"
  ],
  "files": [
    {
      "path": "registry/patterns/date-grouped-activity-list/date-grouped-activity-list.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { SectionList } from \"@/components/ui/section-list\"\n\nexport interface ActivityEvent {\n  id: string\n  title: string\n  at: Date\n}\n\nexport interface DateGroupedActivityListProps {\n  events: ActivityEvent[]\n  now?: Date\n  className?: string\n}\n\nfunction dayKey(date: Date) {\n  return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`\n}\n\nexport function DateGroupedActivityList({\n  events,\n  now = new Date(),\n  className,\n}: DateGroupedActivityListProps) {\n  const sections = React.useMemo(() => {\n    const today = dayKey(now)\n    const yesterday = dayKey(new Date(now.getTime() - 86_400_000))\n    const map = new Map<\n      string,\n      { title: string; short: string; items: ActivityEvent[] }\n    >()\n    for (const event of events) {\n      const key = dayKey(event.at)\n      const title =\n        key === today\n          ? \"Today\"\n          : key === yesterday\n            ? \"Yesterday\"\n            : new Intl.DateTimeFormat(undefined, {\n                weekday: \"long\",\n                day: \"numeric\",\n                month: \"short\",\n              }).format(event.at)\n      const entry = map.get(key) ?? {\n        title,\n        short: title.slice(0, 1),\n        items: [],\n      }\n      entry.items.push(event)\n      map.set(key, entry)\n    }\n    return [...map].map(([key, v]) => ({\n      id: key,\n      title: v.title,\n      items: v.items,\n    }))\n  }, [events, now])\n\n  return (\n    <SectionList\n      label=\"Activity\"\n      className={className}\n      sections={sections}\n      getKey={(e) => e.id}\n      renderItem={(event) => (\n        <div className=\"flex min-h-12 items-center justify-between gap-3 px-4\">\n          <span>{event.title}</span>\n          <time\n            dateTime={event.at.toISOString()}\n            title={event.at.toLocaleString()}\n            className=\"text-muted-foreground text-sm tabular-nums\"\n          >\n            {event.at.toLocaleTimeString(undefined, {\n              hour: \"numeric\",\n              minute: \"2-digit\",\n            })}\n          </time>\n        </div>\n      )}\n    />\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}