{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "progress-kpi-01",
  "description": "Progress to a monthly target, with the projected total hatched ahead of it and a line where an even pace would be by today.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/kpi.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/kpi/progress-kpi-01.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  KPI,\n  KPIChange,\n  KPIContent,\n  KPITitle,\n  type KPIFormat,\n  KPIValue,\n  getKPIFormatter,\n} from '@/registry/components/dashboardblocks/kpi'\nimport { formatPercent } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\nimport { cn } from '@/lib/utils'\n\ninterface ProgressKPI1Props extends BlockStateProps {\n  comparison: string\n  daysElapsed: number\n  daysInPeriod: number\n  format?: KPIFormat\n  previous?: number\n  target: number\n  title: string\n  /** Leave out to show the empty state. */\n  value?: number\n}\n\nconst exampleProps: ProgressKPI1Props = {\n  comparison: 'last month',\n  daysElapsed: 18,\n  daysInPeriod: 30,\n  format: 'currency',\n  previous: 81_400,\n  target: 160_000,\n  title: 'Revenue',\n  value: 87_500,\n}\n\nconst ProgressKPI1 = (props: ProgressKPI1Props) => {\n  const {\n    comparison,\n    daysElapsed,\n    daysInPeriod,\n    format,\n    previous,\n    errorMessage,\n    status,\n    target,\n    title,\n    value,\n  } = props\n  const ready = status === undefined && value !== undefined\n  const reached = ready ? value : 0\n  const formatter = getKPIFormatter(format)\n  const share = target > 0 ? reached / target : 0\n  const expected = Math.min(100, (daysElapsed / daysInPeriod) * 100)\n  const projected = daysElapsed > 0 ? (reached / daysElapsed) * daysInPeriod : reached\n  const projectedShare = target > 0 ? Math.min(100, (projected / target) * 100) : 0\n  const gap = projected - target\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={getBlockState(status, value)}>\n      <Card>\n        <CardContent>\n          <KPI>\n            <KPIContent className='gap-1'>\n              <KPITitle>{title}</KPITitle>\n              <KPIValue value={value} format={format} animated />\n              <KPIChange comparison={comparison} previous={previous} value={value} />\n              <div className='mt-5 flex flex-col gap-2'>\n                <div className='text-muted-foreground flex items-baseline justify-between gap-2 text-sm'>\n                  <BlockReady className='w-1/2'>\n                    <span>\n                      <span className='text-foreground font-medium tabular-nums'>\n                        {formatPercent(share, { maximumFractionDigits: 0 })}\n                      </span>{' '}\n                      of {formatter(target)}\n                    </span>\n                  </BlockReady>\n                  <span className='ml-auto text-xs tabular-nums'>\n                    Day {daysElapsed} of {daysInPeriod}\n                  </span>\n                </div>\n                <div\n                  aria-hidden\n                  className={cn(\n                    'bg-muted relative h-2 rounded-full',\n                    status === 'loading' && 'animate-pulse motion-reduce:animate-none',\n                  )}\n                >\n                  <span\n                    className='absolute inset-y-0 left-0 rounded-full bg-[repeating-linear-gradient(135deg,color-mix(in_oklab,var(--color-chart-2)_45%,transparent)_0_2px,transparent_2px_5px)]'\n                    style={{ width: `${projectedShare}%` }}\n                  />\n                  <span\n                    className='bg-chart-2 absolute inset-y-0 left-0 rounded-full'\n                    style={{ width: `${Math.min(100, share * 100)}%` }}\n                  />\n                  <span\n                    className='bg-foreground absolute -top-1 -bottom-1 w-0.5 -translate-x-1/2 rounded-full'\n                    style={{ left: `${expected}%` }}\n                  />\n                </div>\n                <BlockReady className='text-xs'>\n                  <p className='text-muted-foreground text-xs'>\n                    On pace for{' '}\n                    <span\n                      className={cn(\n                        'font-medium tabular-nums',\n                        gap >= 0\n                          ? 'text-emerald-700 dark:text-emerald-400'\n                          : 'text-orange-700 dark:text-orange-400',\n                      )}\n                    >\n                      {formatter(projected)}\n                    </span>\n                    , {formatter(Math.abs(gap))} {gap >= 0 ? 'over' : 'short of'} target.\n                    The hatched bar is the projection, the line an even pace.\n                  </p>\n                </BlockReady>\n              </div>\n            </KPIContent>\n          </KPI>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { ProgressKPI1, exampleProps as progressKpi1ExampleProps, type ProgressKPI1Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/kpi/progress-kpi-01.tsx"
    }
  ],
  "meta": {
    "shows": "Progress to a monthly target, with the projected total hatched ahead of it and a line where an even pace would be by today.",
    "size": "compact",
    "usedWith": [
      "goals-01",
      "forecast-03",
      "kpi-01"
    ],
    "component": "ProgressKPI1",
    "props": "{ comparison: string; daysElapsed: number; daysInPeriod: number; format?: \"number\" | \"compact\" | \"currency\" | \"currency-compact\" | \"percent\"; previous?: number; target: number; title: string; value?: number; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
