{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "audit-trail",
  "type": "registry:component",
  "title": "Audit trail",
  "description": "A readable event history with actors, timestamps and expandable field changes.",
  "categories": [
    "tables-&-lists"
  ],
  "dependencies": [
    "@tabler/icons-react"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/registry/overtrue/audit-trail.tsx",
      "type": "registry:component",
      "target": "components/overtrue/audit-trail.tsx",
      "content": "import { useId, type ReactNode } from \"react\";\nimport {\n  IconChevronRight,\n  IconActivity,\n  IconCheck,\n  IconAlertTriangle,\n} from \"@tabler/icons-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface AuditEvent {\n  id: string;\n  actor: string;\n  action: string;\n  target?: string;\n  time: string;\n  dateTime?: string;\n  image?: string;\n  outcome?: \"success\" | \"warning\" | \"neutral\";\n  context?: ReactNode;\n  changes?: readonly { field: string; before: string; after: string }[];\n}\n\nexport function AuditTrail({\n  events,\n  label = \"Activity history\",\n  className,\n}: {\n  events: readonly AuditEvent[];\n  label?: string;\n  className?: string;\n}) {\n  const id = useId();\n  return (\n    <div\n      data-slot=\"audit-trail\"\n      className={cn(\"min-w-0 text-foreground\", className)}\n    >\n      <ol aria-label={label} className=\"m-0 list-none p-0\">\n        {events.map((event, index) => {\n          const Icon =\n            event.outcome === \"warning\"\n              ? IconAlertTriangle\n              : event.outcome === \"success\"\n                ? IconCheck\n                : IconActivity;\n          return (\n            <li\n              key={event.id}\n              data-slot=\"audit-event\"\n              className=\"relative flex gap-3 pb-5 last:pb-0\"\n            >\n              {index < events.length - 1 && (\n                <span\n                  aria-hidden=\"true\"\n                  className=\"absolute start-[15px] top-9 bottom-1 w-px bg-border\"\n                />\n              )}\n              <span className=\"relative flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full border border-border bg-card text-muted-foreground\">\n                {event.image ? (\n                  <img\n                    src={event.image}\n                    alt=\"\"\n                    className=\"size-full object-cover\"\n                  />\n                ) : (\n                  <Icon size={15} stroke={1.5} aria-hidden=\"true\" />\n                )}\n              </span>\n              <div className=\"min-w-0 flex-1 pt-0.5\">\n                <div className=\"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1\">\n                  <p className=\"m-0 text-sm leading-5 [overflow-wrap:anywhere]\">\n                    <strong className=\"font-medium\">{event.actor}</strong>{\" \"}\n                    <span className=\"text-muted-foreground\">\n                      {event.action}\n                    </span>\n                    {event.target && (\n                      <>\n                        {\" \"}\n                        <span className=\"font-medium\">{event.target}</span>\n                      </>\n                    )}\n                  </p>\n                  <time\n                    dateTime={event.dateTime}\n                    className=\"shrink-0 text-[11px] text-muted-foreground\"\n                  >\n                    {event.time}\n                  </time>\n                </div>\n                {event.context && (\n                  <div className=\"mt-1 text-xs leading-5 text-muted-foreground\">\n                    {event.context}\n                  </div>\n                )}\n                {event.changes?.length ? (\n                  <details className=\"group/audit mt-2 rounded-lg border border-border bg-card\">\n                    <summary className=\"flex cursor-pointer list-none items-center gap-1.5 rounded-lg px-3 py-2 text-xs text-muted-foreground focus-visible:outline-2 focus-visible:outline-ring [&::-webkit-details-marker]:hidden\">\n                      <IconChevronRight\n                        className=\"size-3.5 transition-transform group-open/audit:rotate-90\"\n                        aria-hidden=\"true\"\n                      />\n                      {event.changes.length}{\" \"}\n                      {event.changes.length === 1 ? \"change\" : \"changes\"}\n                      <span className=\"sr-only\"> in {event.id}</span>\n                    </summary>\n                    <dl\n                      aria-label={`Changes in ${event.id}`}\n                      className=\"m-0 border-t border-border px-3 py-1\"\n                    >\n                      {event.changes.map((change, changeIndex) => (\n                        <div\n                          key={`${id}-${index}-${changeIndex}`}\n                          className=\"grid gap-1 border-b border-border py-2 text-xs last:border-0 sm:grid-cols-[100px_minmax(0,1fr)]\"\n                        >\n                          <dt className=\"font-medium\">{change.field}</dt>\n                          <dd className=\"m-0 flex min-w-0 flex-wrap gap-x-2 gap-y-1 [overflow-wrap:anywhere]\">\n                            <span className=\"text-muted-foreground line-through\">\n                              {change.before || \"Empty\"}\n                            </span>\n                            <span aria-hidden=\"true\">→</span>\n                            <span className=\"sr-only\">changed to</span>\n                            <span>{change.after || \"Empty\"}</span>\n                          </dd>\n                        </div>\n                      ))}\n                    </dl>\n                  </details>\n                ) : null}\n              </div>\n            </li>\n          );\n        })}\n      </ol>\n      {!events.length && (\n        <p className=\"m-0 py-8 text-center text-sm text-muted-foreground\">\n          No activity to show.\n        </p>\n      )}\n    </div>\n  );\n}\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/components/audit-trail. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
