{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "goals-02",
  "description": "Several goals for the same period, each with its own pace.",
  "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/goals.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/goals/goals-02.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  GoalProgress,\n  GoalProgressKey,\n  PaceLabel,\n  getPace,\n} from '@/registry/components/dashboardblocks/goals'\nimport { formatNumber, formatPercent } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Goal {\n  current: number\n  formatter?: (value: number) => string\n  label: string\n  owner: string\n  target: number\n}\n\ninterface Goals2Props extends BlockStateProps {\n  description: string\n  /** Share of the period that has passed, 0–1. */\n  elapsed: number\n  /** Leave out, or pass none, to show the empty state. */\n  goals?: Goal[]\n  title: string\n}\n\nconst exampleProps: Goals2Props = {\n  description: 'Q3, week 12 of 13.',\n  elapsed: 12 / 13,\n  goals: [\n    {\n      current: 1_184,\n      label: 'New paying customers',\n      owner: 'Growth',\n      target: 1_200,\n    },\n    {\n      current: 71,\n      formatter: (value) => formatNumber(value, { maximumFractionDigits: 0 }),\n      label: 'Enterprise deals closed',\n      owner: 'Sales',\n      target: 60,\n    },\n    {\n      current: 2_140,\n      label: 'Support tickets resolved',\n      owner: 'Support',\n      target: 2_400,\n    },\n    {\n      current: 9,\n      formatter: (value) => formatNumber(value, { maximumFractionDigits: 0 }),\n      label: 'Integrations shipped',\n      owner: 'Platform',\n      target: 12,\n    },\n  ],\n  title: 'Team goals',\n}\n\nconst Goals2 = (props: Goals2Props) => {\n  const { description, elapsed, goals = [], errorMessage, status, title } = props\n  const rows = goals.map((goal) => ({\n    format:\n      goal.formatter ??\n      ((value: number) => formatNumber(value, { maximumFractionDigits: 0 })),\n    goal,\n    pace: getPace({ current: goal.current, elapsed, target: goal.target }),\n  }))\n  const onPace = rows.filter((row) => row.pace.status !== 'behind').length\n\n  return (\n    <Card>\n      <CardContent>\n        <BlockStateProvider\n          errorMessage={errorMessage}\n          state={getBlockState(status, goals)}\n        >\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                {description}{' '}\n                <BlockReady className='text-sm'>\n                  <span className='tabular-nums'>\n                    {onPace} of {goals.length}\n                  </span>{' '}\n                  {goals.length === 1 ? 'goal is' : 'goals are'} on pace or better.\n                </BlockReady>\n              </p>\n            </header>\n            <BlockStateRows\n              className='border-t data-[slot=block-state-rows]:border-b'\n              rows={goals.length || 4}\n            />\n            {!status && goals.length > 0 && (\n              <ul className='flex flex-col divide-y border-y'>\n                {rows.map(({ format, goal, pace }) => (\n                  <li key={goal.label} className='flex flex-col gap-2 py-3'>\n                    <div className='flex items-start justify-between gap-3'>\n                      <p className='flex min-w-0 flex-col'>\n                        <span className='text-sm font-medium'>{goal.label}</span>\n                        <span className='text-muted-foreground text-xs'>\n                          {goal.owner}\n                        </span>\n                      </p>\n                      <PaceLabel className='text-xs' status={pace.status} />\n                    </div>\n                    <GoalProgress\n                      current={goal.current}\n                      expected={pace.status === 'met' ? undefined : pace.expected}\n                      size='sm'\n                      target={goal.target}\n                    />\n                    <p className='text-muted-foreground flex justify-between gap-3 text-xs tabular-nums'>\n                      <span>\n                        <span className='text-foreground font-medium'>\n                          {format(goal.current)}\n                        </span>{' '}\n                        of {format(goal.target)}\n                      </span>\n                      <span>\n                        {formatPercent(goal.current / goal.target, {\n                          maximumFractionDigits: 0,\n                        })}\n                      </span>\n                    </p>\n                  </li>\n                ))}\n              </ul>\n            )}\n            <GoalProgressKey />\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport { Goals2, exampleProps as goals2ExampleProps, type Goals2Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/goals/goals-02.tsx"
    }
  ],
  "meta": {
    "shows": "Several goals for the same period, each with its own pace.",
    "size": "half",
    "usedWith": [
      "goals-01",
      "metric-list-03",
      "forecast-02"
    ],
    "component": "Goals2",
    "props": "{ description: string; elapsed: number; goals?: { current: number; formatter?: (value: number) => string; label: string; owner: string; target: number }[]; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
