{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "progress-kpi-03",
  "description": "A count against a goal as a ring, with how many are left and how many a day that takes.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/animated-number.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/kpi.json",
    "https://www.dashboardblocks.com/r/radix/ring.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/kpi/progress-kpi-03.tsx",
      "content": "'use client'\n\nimport { AnimatedNumber } from '@/registry/components/dashboardblocks/animated-number'\nimport {\n  BlockReady,\n  BlockStateProvider,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  KPI,\n  KPIContent,\n  KPITitle,\n  KPIValue,\n} from '@/registry/components/dashboardblocks/kpi'\nimport { Ring } from '@/registry/components/dashboardblocks/ring'\nimport { formatNumber, formatPercent } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface ProgressKPI3Props extends BlockStateProps {\n  /** Leave out to show the empty state. */\n  current?: number\n  /** Days left in the period. Leave it out to skip the daily rate needed. */\n  daysLeft?: number\n  goal: number\n  title: string\n  unit: string\n}\n\nconst exampleProps: ProgressKPI3Props = {\n  current: 7_500,\n  daysLeft: 9,\n  goal: 10_000,\n  title: 'Monthly goal',\n  unit: 'sales',\n}\n\nconst count = (value: number) => formatNumber(Math.ceil(value))\nconst wholePercent = (value: number) =>\n  formatPercent(value / 100, { maximumFractionDigits: 0 })\n\nconst ProgressKPI3 = (props: ProgressKPI3Props) => {\n  const { current, daysLeft, goal, errorMessage, status, title, unit } = props\n  const reached = current ?? 0\n  const percentage = goal > 0 ? Math.min(100, Math.max(0, (reached / goal) * 100)) : 0\n  const remaining = Math.max(0, goal - reached)\n\n  return (\n    <BlockStateProvider\n      errorMessage={errorMessage}\n      state={getBlockState(status, current)}\n    >\n      <Card>\n        <CardContent>\n          <KPI>\n            <KPIContent className='flex-row items-center justify-between gap-4'>\n              <div className='flex min-w-0 flex-col gap-1'>\n                <KPITitle>{title}</KPITitle>\n                <KPIValue value={current} animated />\n                <p className='text-muted-foreground text-sm'>\n                  of <span className='tabular-nums'>{count(goal)}</span> {unit}\n                </p>\n                <BlockReady className='mt-3 text-xs'>\n                  <p className='text-muted-foreground mt-3 text-xs'>\n                    {remaining === 0 ? (\n                      'Goal reached.'\n                    ) : (\n                      <>\n                        <span className='text-foreground font-medium tabular-nums'>\n                          {count(remaining)}\n                        </span>{' '}\n                        to go\n                        {daysLeft !== undefined && daysLeft > 0 && (\n                          <>\n                            {' '}\n                            in {daysLeft} {daysLeft === 1 ? 'day' : 'days'}, about{' '}\n                            <span className='text-foreground font-medium tabular-nums'>\n                              {count(remaining / daysLeft)}\n                            </span>{' '}\n                            a day\n                          </>\n                        )}\n                        .\n                      </>\n                    )}\n                  </p>\n                </BlockReady>\n              </div>\n              <Ring\n                ariaLabel={`${wholePercent(percentage)} of goal`}\n                className='size-28 sm:size-32'\n                percentage={percentage}\n                ringColor='var(--color-chart-2)'\n                strokeWidth={6}\n              >\n                <AnimatedNumber\n                  className='text-2xl font-light tracking-tight tabular-nums'\n                  value={Math.round(percentage)}\n                  formatter={wholePercent}\n                />\n              </Ring>\n            </KPIContent>\n          </KPI>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { ProgressKPI3, exampleProps as progressKpi3ExampleProps, type ProgressKPI3Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/kpi/progress-kpi-03.tsx"
    }
  ],
  "meta": {
    "shows": "A count against a goal as a ring, with how many are left and how many a day that takes.",
    "size": "compact",
    "usedWith": [
      "progress-kpi-01",
      "goals-04",
      "kpi-01"
    ],
    "component": "ProgressKPI3",
    "props": "{ current?: number; daysLeft?: number; goal: number; title: string; unit: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
