{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dashboard-header-04",
  "description": "A dashboard header with a description, the time of the last update and a refresh button beside the date range and export.",
  "registryDependencies": [
    "button",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/dashboard-header.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/dashboard-header/dashboard-header-04.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateText,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  CompareToggle,\n  DashboardHeaderTitle,\n  type DateRangePreset,\n  DateRangePicker,\n  ExportMenu,\n} from '@/registry/components/dashboardblocks/dashboard-header'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { startTransition, useState } from 'react'\n\nimport { Button } from '@/components/ui/button'\n\nimport { cn } from '@/lib/utils'\n\ninterface DashboardHeader4Props extends BlockStateProps {\n  defaultPreset?: DateRangePreset\n  /** Leave out to show the empty state. */\n  description?: string\n  lastUpdated: string\n  onExport?: (format: string) => void\n  onRefresh?: () => Promise<void>\n  title: string\n  /** The last day of every date range preset. */\n  today: Date\n}\n\nconst exampleProps: DashboardHeader4Props = {\n  defaultPreset: '30d',\n  description: '4,812 subscriptions across every plan, bringing in $96,240 a month.',\n  lastUpdated: '5 min ago',\n  onRefresh: () => new Promise((resolve) => setTimeout(resolve, 1200)),\n  title: 'Subscriptions',\n  today: new Date(Date.UTC(2026, 8, 25)),\n}\n\nconst DashboardHeader4 = (props: DashboardHeader4Props) => {\n  const {\n    defaultPreset = '30d',\n    description,\n    lastUpdated,\n    onExport = () => {},\n    onRefresh = async () => {},\n    errorMessage,\n    status,\n    title,\n    today,\n  } = props\n  const state = getBlockState(status, description)\n  const [preset, setPreset] = useState<DateRangePreset>(defaultPreset)\n  const [compare, setCompare] = useState(true)\n  const [refreshing, setRefreshing] = useState(false)\n  const [updated, setUpdated] = useState(lastUpdated)\n\n  const refresh = async () => {\n    setRefreshing(true)\n    try {\n      await onRefresh()\n      startTransition(() => setUpdated('just now'))\n    } finally {\n      startTransition(() => setRefreshing(false))\n    }\n  }\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <header className='@container'>\n        <div className='flex flex-col gap-4 @3xl:flex-row @3xl:items-end @3xl:justify-between'>\n          <div className='flex flex-col gap-2'>\n            <DashboardHeaderTitle\n              title={title}\n              description={state ? <BlockStateText /> : description}\n            />\n            <BlockReady className='flex h-6 items-center text-xs'>\n              <div className='text-muted-foreground flex items-center gap-1.5 text-xs'>\n                <span\n                  aria-hidden\n                  className={cn(\n                    'size-1.5 shrink-0 rounded-full bg-emerald-500',\n                    refreshing && 'motion-safe:animate-pulse',\n                  )}\n                />\n                <span aria-live='polite'>\n                  {refreshing ? 'Refreshing…' : `Updated ${updated}`}\n                </span>\n                <Button disabled={refreshing} onClick={refresh} size='xs' variant='ghost'>\n                  <IconPlaceholder\n                    lucide='RefreshCwIcon'\n                    tabler='IconRefresh'\n                    hugeicons='RefreshIcon'\n                    phosphor='ArrowClockwiseIcon'\n                    remixicon='RiRefreshLine'\n                    className={cn(refreshing && 'motion-safe:animate-spin')}\n                  />\n                  Refresh\n                </Button>\n              </div>\n            </BlockReady>\n          </div>\n          <div className='flex flex-wrap items-center gap-2'>\n            <CompareToggle\n              checked={compare}\n              onCheckedChange={setCompare}\n              className='basis-full @md:mr-2 @md:basis-auto'\n            />\n            <DateRangePicker onValueChange={setPreset} today={today} value={preset} />\n            <ExportMenu disabled={state !== undefined} onExport={onExport} />\n          </div>\n        </div>\n      </header>\n    </BlockStateProvider>\n  )\n}\n\nexport {\n  DashboardHeader4,\n  exampleProps as dashboardHeader4ExampleProps,\n  type DashboardHeader4Props,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/dashboard-header/dashboard-header-04.tsx"
    }
  ],
  "meta": {
    "shows": "A dashboard header with a description, the time of the last update and a refresh button beside the date range and export.",
    "size": "full",
    "usedWith": [
      "realtime-01",
      "stat-group-02"
    ],
    "component": "DashboardHeader4",
    "props": "{ defaultPreset?: \"24h\" | \"today\" | \"7d\" | \"30d\" | \"90d\"; description?: string; lastUpdated: string; onExport?: (format: string) => void; onRefresh?: () => Promise<void>; title: string; today: Date; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
