{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-activity-feed",
  "title": "Activity Feed",
  "description": "Feed cronológico de eventos e trilha de auditoria com avatar, badge de status e timestamp relativo.",
  "dependencies": [
    "date-fns"
  ],
  "registryDependencies": [
    "@lema-ds/avatar",
    "@lema-ds/badge",
    "@lema-ds/button",
    "@lema-ds/skeleton",
    "@lema-ds/ui-i18n",
    "@lema-ds/ds-locale-provider",
    "@lema-ds/tokens"
  ],
  "files": [
    {
      "path": "components/ds/ds-activity-feed.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { format, type Locale } from \"date-fns\"\nimport { ptBR, enUS, es, fr } from \"date-fns/locale\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Avatar, AvatarFallback, AvatarImage } from \"@/components/ui/avatar\"\nimport { Badge } from \"@/components/ui/badge\"\nimport { Button } from \"@/components/ui/button\"\nimport { Skeleton } from \"@/components/ui/skeleton\"\nimport { UI_I18N, type UILocale } from \"@/lib/ui-i18n\"\nimport { useUILocale } from \"@/components/ui/ds-locale-provider\"\n\nconst dateFnsLocales: Record<UILocale, Locale> = {\n  \"pt-BR\": ptBR,\n  \"en-US\": enUS,\n  \"es-ES\": es,\n  \"fr-FR\": fr,\n}\n\n// ── Types ──\n\nexport interface ActivityFeedItem {\n  /**\n   * Unique item identifier.\n   */\n  id: string\n  /**\n   * Actor performing the action.\n   */\n  actor: {\n    name: string\n    avatarUrl?: string\n    initials?: string\n  }\n  /**\n   * Action phrase describing the event (e.g. \"updated the model\").\n   */\n  action: string\n  /**\n   * Target resource name.\n   */\n  target?: string\n  /**\n   * Optional link to target resource.\n   */\n  targetHref?: string\n  /**\n   * Timestamp string or Date object.\n   */\n  timestamp: string | Date\n  /**\n   * Optional status severity.\n   */\n  status?: \"default\" | \"success\" | \"warning\" | \"destructive\"\n  /**\n   * Status label displayed in a Badge.\n   */\n  statusLabel?: string\n  /**\n   * Custom icon placed over or next to the node.\n   */\n  icon?: React.ReactNode\n  /**\n   * Extended description, code diff, or payload summary.\n   */\n  description?: React.ReactNode\n}\n\nexport interface ActivityFeedProps extends React.HTMLAttributes<HTMLDivElement> {\n  /**\n   * Chronological list of events.\n   */\n  items: ActivityFeedItem[]\n  /**\n   * Loading state.\n   */\n  loading?: boolean\n  /**\n   * Message shown when items list is empty.\n   */\n  emptyMessage?: string\n  /**\n   * Callback fired when clicking the view more button.\n   */\n  onViewMore?: () => void\n  /**\n   * Locale for date formatting and labels.\n   */\n  locale?: UILocale\n}\n\n// ── Component ──\n\nexport const ActivityFeed = React.forwardRef<HTMLDivElement, ActivityFeedProps>(\n  (\n    {\n      items,\n      loading = false,\n      emptyMessage,\n      onViewMore,\n      locale: localeProp,\n      className,\n      ...props\n    },\n    ref\n  ) => {\n    const locale = useUILocale(localeProp)\n    const t = UI_I18N[locale].activityFeed\n    const dfLocale = dateFnsLocales[locale]\n\n    const formatTimestamp = (ts: string | Date) => {\n      if (typeof ts === \"string\") return ts\n      return format(ts, \"PPp\", { locale: dfLocale })\n    }\n\n    if (loading) {\n      return (\n        <div\n          ref={ref}\n          className={cn(\"flex flex-col gap-6\", className)}\n          {...props}\n        >\n          {[1, 2, 3].map((i) => (\n            <div key={i} className=\"relative flex items-start gap-3\">\n              <Skeleton className=\"size-7 shrink-0 rounded-full\" />\n              <div className=\"flex flex-1 flex-col gap-1.5 pt-0.5\">\n                <div className=\"flex items-center gap-2\">\n                  <Skeleton className=\"h-4 w-28\" />\n                  <Skeleton className=\"h-4 w-44\" />\n                </div>\n                <Skeleton className=\"h-3 w-20\" />\n              </div>\n            </div>\n          ))}\n        </div>\n      )\n    }\n\n    if (items.length === 0) {\n      return (\n        <div\n          ref={ref}\n          className={cn(\n            \"rounded-lg border border-dashed border-border p-6 text-center text-xs text-muted-foreground\",\n            className\n          )}\n          {...props}\n        >\n          {emptyMessage ?? t.empty}\n        </div>\n      )\n    }\n\n    const getInitials = (name: string, initials?: string) => {\n      if (initials) return initials\n      const parts = name.trim().split(\" \")\n      if (parts.length === 1) return parts[0].substring(0, 2).toUpperCase()\n      return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase()\n    }\n\n    return (\n      <div\n        ref={ref}\n        aria-label=\"Activity feed\"\n        className={cn(\"relative flex flex-col\", className)}\n        {...props}\n      >\n        <ul className=\"m-0 flex list-none flex-col p-0\">\n          {items.map((item, index) => {\n            const isLast = index === items.length - 1\n\n            return (\n              <li key={item.id} className=\"relative flex gap-3 pb-6 last:pb-0\">\n                {!isLast && (\n                  <span\n                    className=\"absolute top-7 -bottom-0 left-3.5 w-px -translate-x-1/2 bg-border\"\n                    aria-hidden=\"true\"\n                  />\n                )}\n\n                <div className=\"relative z-10 shrink-0\">\n                  <Avatar className=\"size-7 border border-background\">\n                    {item.actor.avatarUrl && (\n                      <AvatarImage\n                        src={item.actor.avatarUrl}\n                        alt={item.actor.name}\n                      />\n                    )}\n                    <AvatarFallback className=\"bg-muted text-xs font-medium text-muted-foreground\">\n                      {getInitials(item.actor.name, item.actor.initials)}\n                    </AvatarFallback>\n                  </Avatar>\n                </div>\n\n                <div className=\"flex min-w-0 flex-1 flex-col gap-1 pt-0.5\">\n                  <div className=\"flex flex-wrap items-center gap-1.5 text-xs\">\n                    <span className=\"font-semibold text-foreground\">\n                      {item.actor.name}\n                    </span>\n                    <span className=\"text-muted-foreground\">{item.action}</span>\n                    {item.target &&\n                      (item.targetHref ? (\n                        <a\n                          href={item.targetHref}\n                          className=\"font-medium text-foreground hover:underline\"\n                        >\n                          {item.target}\n                        </a>\n                      ) : (\n                        <span className=\"font-medium text-foreground\">\n                          {item.target}\n                        </span>\n                      ))}\n                    {item.statusLabel && (\n                      <Badge\n                        variant={\n                          item.status === \"destructive\"\n                            ? \"destructive\"\n                            : item.status === \"warning\"\n                              ? \"outline\"\n                              : item.status === \"success\"\n                                ? \"secondary\"\n                                : \"outline\"\n                        }\n                        className={cn(\n                          \"h-4 px-1.5 py-0 text-xs font-normal\",\n                          item.status === \"success\" &&\n                            \"border-success/20 bg-success/15 text-success\",\n                          item.status === \"warning\" &&\n                            \"border-warning text-warning\"\n                        )}\n                      >\n                        {item.statusLabel}\n                      </Badge>\n                    )}\n                  </div>\n\n                  <time className=\"text-xs text-muted-foreground\">\n                    {formatTimestamp(item.timestamp)}\n                  </time>\n\n                  {item.description && (\n                    <div className=\"mt-1.5 rounded-md border border-border bg-muted/40 p-2 text-xs text-foreground\">\n                      {item.description}\n                    </div>\n                  )}\n                </div>\n              </li>\n            )\n          })}\n        </ul>\n\n        {onViewMore && (\n          <div className=\"flex justify-center pt-3\">\n            <Button\n              type=\"button\"\n              variant=\"ghost\"\n              size=\"sm\"\n              onClick={onViewMore}\n              className=\"text-xs text-muted-foreground hover:text-foreground\"\n            >\n              {t.viewMore}\n            </Button>\n          </div>\n        )}\n      </div>\n    )\n  }\n)\n\nActivityFeed.displayName = \"ActivityFeed\"\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
