{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "realtime-03",
  "description": "Orders, sign-ups, refunds and messages as they arrive, newest first, with a pause button.",
  "registryDependencies": [
    "card",
    "button",
    "https://www.dashboardblocks.com/r/radix/activity-feed.json",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/realtime.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/realtime/realtime-03.tsx",
      "content": "'use client'\n\nimport {\n  ActivityFeed,\n  ActivityFeedItem,\n  ActivityIcon,\n  type ActivityTone,\n} from '@/registry/components/dashboardblocks/activity-feed'\nimport {\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { LiveBadge, formatAgo } from '@/registry/components/dashboardblocks/realtime'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { type ReactNode, useState } from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport { Card, CardContent } from '@/components/ui/card'\n\nimport { cn } from '@/lib/utils'\n\ntype LiveEventKind = 'order' | 'signup' | 'refund' | 'message'\n\ninterface LiveEvent {\n  at: Date\n  detail: string\n  id: string\n  kind: LiveEventKind\n  label: string\n}\n\ninterface Realtime3Props extends BlockStateProps {\n  description: string\n  /** Newest first. Leave out, or pass none, to show the empty state. */\n  events?: LiveEvent[]\n  limit?: number\n  /** Pass a fixed date, so the block renders the same on the server and in the browser. */\n  now: Date\n  title: string\n}\n\nconst noEvents: LiveEvent[] = []\n\nconst kindConfig: Record<LiveEventKind, { icon: ReactNode; tone: ActivityTone }> = {\n  message: {\n    tone: 'neutral',\n    icon: (\n      <IconPlaceholder\n        lucide='MessageSquareIcon'\n        tabler='IconMessage'\n        hugeicons='MessageIcon'\n        phosphor='ChatCircleIcon'\n        remixicon='RiChat1Line'\n        aria-hidden\n      />\n    ),\n  },\n  order: {\n    tone: 'success',\n    icon: (\n      <IconPlaceholder\n        lucide='CreditCardIcon'\n        tabler='IconCreditCard'\n        hugeicons='CreditCardIcon'\n        phosphor='CreditCardIcon'\n        remixicon='RiBankCardLine'\n        aria-hidden\n      />\n    ),\n  },\n  refund: {\n    tone: 'warning',\n    icon: (\n      <IconPlaceholder\n        lucide='Undo2Icon'\n        tabler='IconArrowBackUp'\n        hugeicons='Undo02Icon'\n        phosphor='ArrowUUpLeftIcon'\n        remixicon='RiArrowGoBackLine'\n        aria-hidden\n      />\n    ),\n  },\n  signup: {\n    tone: 'info',\n    icon: (\n      <IconPlaceholder\n        lucide='UserPlusIcon'\n        tabler='IconUserPlus'\n        hugeicons='UserAdd01Icon'\n        phosphor='UserPlusIcon'\n        remixicon='RiUserAddLine'\n        aria-hidden\n      />\n    ),\n  },\n}\n\nconst NOW = new Date(Date.UTC(2026, 8, 26, 14, 30, 0))\nconst secondsAgo = (seconds: number) => new Date(NOW.getTime() - seconds * 1000)\n\nconst exampleProps: Realtime3Props = {\n  description: 'Every order, sign-up, refund and support chat as it happens.',\n  events: [\n    {\n      at: secondsAgo(3),\n      detail: '$84.00, 2 items',\n      id: 'e6',\n      kind: 'order',\n      label: 'Order #10482',\n    },\n    {\n      at: secondsAgo(18),\n      detail: 'Pro trial, from Google',\n      id: 'e5',\n      kind: 'signup',\n      label: 'New sign-up',\n    },\n    {\n      at: secondsAgo(41),\n      detail: '\"Can I change my plan mid-cycle?\"',\n      id: 'e4',\n      kind: 'message',\n      label: 'Support chat',\n    },\n    {\n      at: secondsAgo(75),\n      detail: '$212.50, 5 items',\n      id: 'e3',\n      kind: 'order',\n      label: 'Order #10481',\n    },\n    {\n      at: secondsAgo(130),\n      detail: '$39.00, damaged in transit',\n      id: 'e2',\n      kind: 'refund',\n      label: 'Refund #3310',\n    },\n    {\n      at: secondsAgo(205),\n      detail: 'Team plan, from a referral',\n      id: 'e1',\n      kind: 'signup',\n      label: 'New sign-up',\n    },\n  ],\n  now: NOW,\n  title: 'Live activity',\n}\n\nconst Realtime3 = (props: Realtime3Props) => {\n  const {\n    description,\n    events: loadedEvents = noEvents,\n    limit = 6,\n    errorMessage,\n    status,\n    title,\n  } = props\n  const [held, setHeld] = useState<{ events: LiveEvent[]; now: Date } | null>(null)\n  const [firstIds] = useState(() => new Set(loadedEvents.map((event) => event.id)))\n  const paused = held !== null\n  const events = held?.events ?? loadedEvents.slice(0, limit)\n  const now = held?.now ?? props.now\n  const state = getBlockState(status, events)\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <Card>\n        <CardContent>\n          <section className='@container flex flex-col gap-4'>\n            <header className='flex items-start justify-between gap-3'>\n              <div className='flex min-w-0 flex-col gap-0.5'>\n                <h2 className='font-semibold tracking-tight'>{title}</h2>\n                <p className='text-muted-foreground text-sm'>{description}</p>\n              </div>\n              <div className='flex shrink-0 items-center gap-3'>\n                {!state && <LiveBadge paused={paused} />}\n                <Button\n                  disabled={Boolean(state)}\n                  size='sm'\n                  variant='outline'\n                  onClick={() => setHeld(paused ? null : { events, now })}\n                >\n                  {paused ? (\n                    <IconPlaceholder\n                      lucide='PlayIcon'\n                      tabler='IconPlayerPlayFilled'\n                      hugeicons='PlayIcon'\n                      phosphor='PlayIcon'\n                      remixicon='RiPlayFill'\n                      className='fill-current'\n                      data-icon='inline-start'\n                    />\n                  ) : (\n                    <IconPlaceholder\n                      lucide='PauseIcon'\n                      tabler='IconPlayerPauseFilled'\n                      hugeicons='PauseIcon'\n                      phosphor='PauseIcon'\n                      remixicon='RiPauseFill'\n                      className='fill-current'\n                      data-icon='inline-start'\n                    />\n                  )}\n                  {paused ? 'Resume' : 'Pause'}\n                </Button>\n              </div>\n            </header>\n            {state && (\n              <div className='border-t'>\n                <BlockStateRows rows={limit} />\n              </div>\n            )}\n            {!state && (\n              <ActivityFeed className='border-t pt-1'>\n                {events.map((event, index) => {\n                  const config = kindConfig[event.kind]\n                  return (\n                    <ActivityFeedItem\n                      key={event.id}\n                      className={cn(\n                        'items-center border-b py-2.5 last:border-b-0',\n                        index === 0 &&\n                          !firstIds.has(event.id) &&\n                          'motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-top-1',\n                      )}\n                    >\n                      <ActivityIcon icon={config.icon} tone={config.tone} />\n                      <div className='flex min-w-0 flex-1 flex-col'>\n                        <span className='truncate text-sm font-medium'>\n                          {event.label}\n                        </span>\n                        <span className='text-muted-foreground truncate text-sm'>\n                          {event.detail}\n                        </span>\n                      </div>\n                      <time\n                        className='text-muted-foreground shrink-0 text-xs tabular-nums'\n                        dateTime={event.at.toISOString()}\n                      >\n                        {formatAgo(event.at, now)}\n                      </time>\n                    </ActivityFeedItem>\n                  )\n                })}\n              </ActivityFeed>\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport {\n  Realtime3,\n  exampleProps as realtime3ExampleProps,\n  type LiveEvent,\n  type Realtime3Props,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/realtime/realtime-03.tsx"
    }
  ],
  "meta": {
    "shows": "Orders, sign-ups, refunds and messages as they arrive, newest first, with a pause button.",
    "size": "half",
    "usedWith": [
      "realtime-04",
      "activity-feed-01"
    ],
    "component": "Realtime3",
    "props": "{ description: string; events?: { at: Date; detail: string; id: string; kind: \"order\" | \"signup\" | \"refund\" | \"message\"; label: string }[]; limit?: number; now: Date; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
