{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "goals-04",
  "description": "Small daily goals as rings, with what is left to do or how far past the goal each one is.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/ring.json",
    "https://www.dashboardblocks.com/r/radix/status-label.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/goals/goals-04.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  SkeletonText,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { Ring } from '@/registry/components/dashboardblocks/ring'\nimport { StatusLabel } from '@/registry/components/dashboardblocks/status-label'\nimport { formatNumber, formatPercent } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface DailyGoal {\n  current: number\n  label: string\n  target: number\n  unit: string\n}\n\ninterface Goals4Props extends BlockStateProps {\n  description: string\n  /** Leave out, or pass none, to show the empty state. */\n  goals?: DailyGoal[]\n  /** How many rings to sketch while loading. @default 3 */\n  placeholders?: number\n  title: string\n}\n\nconst exampleProps: Goals4Props = {\n  description: 'Resets at midnight.',\n  goals: [\n    { current: 42, label: 'Calls', target: 50, unit: 'calls' },\n    { current: 18, label: 'Demos', target: 15, unit: 'demos' },\n    { current: 7, label: 'Proposals', target: 12, unit: 'proposals' },\n  ],\n  title: 'Daily activity goals',\n}\n\nconst Goals4 = (props: Goals4Props) => {\n  const { description, goals = [], placeholders = 3, errorMessage, status, title } = props\n  const state = getBlockState(status, goals)\n  const met = goals.filter((goal) => goal.current >= goal.target).length\n\n  return (\n    <Card>\n      <CardContent>\n        <BlockStateProvider errorMessage={errorMessage} state={state}>\n          <section className='@container flex flex-col gap-4'>\n            <header className='flex flex-col gap-0.5'>\n              <h2 className='font-semibold tracking-tight'>{title}</h2>\n              <p className='text-muted-foreground text-sm'>\n                <BlockReady className='text-sm'>\n                  <span className='tabular-nums'>\n                    {met} of {goals.length}\n                  </span>{' '}\n                  met so far today.{' '}\n                </BlockReady>\n                {description}\n              </p>\n            </header>\n            {state === 'loading' && (\n              <ul\n                aria-hidden\n                className='grid grid-cols-1 gap-4 border-t pt-5 @sm:grid-cols-3'\n              >\n                {Array.from({ length: placeholders }, (_, index) => (\n                  <li\n                    key={index}\n                    className='flex items-center gap-4 @sm:flex-col @sm:gap-3 @sm:text-center'\n                  >\n                    <Ring\n                      className='size-20 @sm:size-24'\n                      percentage={0}\n                      strokeWidth={8}\n                    />\n                    <div className='flex w-full flex-col gap-0.5 @sm:items-center'>\n                      <span className='text-sm'>\n                        <SkeletonText className='w-20' />\n                      </span>\n                      <span className='text-xs'>\n                        <SkeletonText className='w-28' />\n                      </span>\n                    </div>\n                  </li>\n                ))}\n              </ul>\n            )}\n            {(state === 'empty' || state === 'error') && (\n              <BlockStateRows className='border-t pt-4' />\n            )}\n            {!state && (\n              <ul className='grid grid-cols-1 gap-4 border-t pt-5 @sm:grid-cols-3'>\n                {goals.map((goal) => {\n                  const share = goal.target > 0 ? goal.current / goal.target : 0\n                  const done = goal.current >= goal.target\n                  return (\n                    <li\n                      key={goal.label}\n                      className='flex items-center gap-4 @sm:flex-col @sm:gap-3 @sm:text-center'\n                    >\n                      <Ring\n                        ariaLabel={`${goal.label}: ${formatNumber(goal.current)} of ${formatNumber(goal.target)} ${goal.unit}`}\n                        className='size-20 @sm:size-24'\n                        percentage={Math.min(100, share * 100)}\n                        ringColor='var(--color-chart-2)'\n                        strokeWidth={8}\n                      >\n                        <span\n                          aria-hidden\n                          className='text-lg font-light tracking-tight tabular-nums'\n                        >\n                          {formatPercent(share, { maximumFractionDigits: 0 })}\n                        </span>\n                      </Ring>\n                      <div className='flex flex-col gap-0.5 @sm:items-center'>\n                        <span className='text-sm font-medium'>{goal.label}</span>\n                        <span className='text-muted-foreground text-xs tabular-nums'>\n                          {formatNumber(goal.current)} of {formatNumber(goal.target)}{' '}\n                          {goal.unit}\n                        </span>\n                        {done ? (\n                          <StatusLabel variant='text' className='text-xs' tone='good'>\n                            Met\n                            {goal.current > goal.target &&\n                              `, ${formatNumber(goal.current - goal.target)} over`}\n                          </StatusLabel>\n                        ) : (\n                          <span className='text-muted-foreground text-xs tabular-nums'>\n                            {formatNumber(goal.target - goal.current)} to go\n                          </span>\n                        )}\n                      </div>\n                    </li>\n                  )\n                })}\n              </ul>\n            )}\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport { Goals4, exampleProps as goals4ExampleProps, type Goals4Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/goals/goals-04.tsx"
    }
  ],
  "meta": {
    "shows": "Small daily goals as rings, with what is left to do or how far past the goal each one is.",
    "size": "half",
    "usedWith": [
      "progress-kpi-03",
      "goals-02",
      "checklist-01"
    ],
    "component": "Goals4",
    "props": "{ description: string; goals?: { current: number; label: string; target: number; unit: string }[]; placeholders?: number; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
