{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "states-01",
  "description": "Grey placeholders shaped like a row of stats, shown while data loads so nothing shifts when it arrives.",
  "registryDependencies": [
    "card",
    "button",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/stat-group.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/states/states-01.tsx",
      "content": "'use client'\n\nimport {\n  BlockStateProvider,\n  type BlockStatus,\n  type LoadStatus,\n  useBlockData,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  Stat,\n  StatChange,\n  StatGroup,\n  StatLabel,\n  type StatMetric,\n  StatValue,\n  formatStatValue,\n  getStatPlaceholders,\n} from '@/registry/components/dashboardblocks/stat-group'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { formatCurrency, formatPercent } from '@/registry/lib/dashboardblocks/format'\n\nimport { Button } from '@/components/ui/button'\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface States1Props {\n  /** Follows the change, such as `the previous 30 days`. */\n  comparison: string\n  description: string\n  load: () => Promise<StatMetric[]>\n  placeholders?: number\n  title: string\n}\n\nconst exampleProps: States1Props = {\n  comparison: 'the previous 30 days',\n  description: 'The last 30 days, compared with the 30 days before.',\n  load: () =>\n    new Promise((resolve) =>\n      setTimeout(\n        () =>\n          resolve([\n            {\n              formatter: (value) => formatCurrency(value),\n              key: 'revenue',\n              label: 'Revenue',\n              previous: 42_890,\n              value: 48_210,\n            },\n            { key: 'orders', label: 'Orders', previous: 1_210, value: 1_284 },\n            {\n              changeType: 'points',\n              formatter: (value) => formatPercent(value / 100),\n              goodDirection: 'down',\n              key: 'refunds',\n              label: 'Refund rate',\n              previous: 2.1,\n              value: 1.8,\n            },\n          ]),\n        1_500,\n      ),\n    ),\n  placeholders: 3,\n  title: 'Overview',\n}\n\nfunction toBlockStatus(status: LoadStatus): BlockStatus | undefined {\n  if (status === 'idle' || status === 'loading') return 'loading'\n  if (status === 'error') return 'error'\n  return undefined\n}\n\nconst States1 = (props: States1Props) => {\n  const { comparison, description, load, placeholders = 3, title } = props\n  const { data = [], reload, status: loadStatus } = useBlockData(load)\n  const status = toBlockStatus(loadStatus)\n  const loading = status === 'loading'\n  const shown = loading ? getStatPlaceholders(placeholders) : data\n\n  return (\n    <BlockStateProvider state={getBlockState(status, data)}>\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              <Button\n                variant='outline'\n                size='sm'\n                disabled={loading}\n                onClick={() => void reload({ clear: true })}\n              >\n                <IconPlaceholder\n                  lucide='RefreshCwIcon'\n                  tabler='IconRefresh'\n                  hugeicons='RefreshIcon'\n                  phosphor='ArrowClockwiseIcon'\n                  remixicon='RiRefreshLine'\n                />\n                Reload\n              </Button>\n            </header>\n            <StatGroup className='@xl:grid-cols-3'>\n              {shown.map((metric) => (\n                <Stat key={metric.key}>\n                  <StatLabel>{metric.label}</StatLabel>\n                  <StatValue>{formatStatValue(metric)}</StatValue>\n                  <StatChange comparison={comparison} metric={metric} variant='short' />\n                </Stat>\n              ))}\n            </StatGroup>\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { States1, exampleProps as states1ExampleProps, type States1Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/states/states-01.tsx"
    }
  ],
  "meta": {
    "shows": "Grey placeholders shaped like a row of stats, shown while data loads so nothing shifts when it arrives.",
    "size": "full",
    "usedWith": [
      "stat-group-02",
      "states-04"
    ],
    "component": "States1",
    "props": "{ comparison: string; description: string; load: () => Promise<{ changeType?: \"percent\" | \"points\" | \"count\"; detail?: ReactNode; formatter?: (value: number) => string; goodDirection?: \"up\" | \"down\"; key: string; label: string; previous?: number; tone?: \"warning\" | \"bad\"; value: number }[]>; placeholders?: number; title: string }"
  },
  "type": "registry:component"
}
