{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "gauge-01",
  "description": "A net promoter score on its full −100 to 100 scale, with the split of promoters, passives and detractors.",
  "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/gauge.json",
    "https://www.dashboardblocks.com/r/radix/kpi.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/gauge/gauge-01.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  type BlockStateProps,\n  Skeleton,\n  SkeletonText,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  Gauge,\n  GaugeValue,\n  type NpsResponses,\n  getNps,\n} from '@/registry/components/dashboardblocks/gauge'\nimport { KPIChange } from '@/registry/components/dashboardblocks/kpi'\nimport {\n  formatNumber,\n  formatPercent,\n  formatSigned,\n} from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\nimport { cn } from '@/lib/utils'\n\ninterface Gauge1Props extends BlockStateProps {\n  /** Follows the response count in the description, such as `over the last 90 days`. */\n  period: string\n  previous?: number\n  /** Leave out to show the empty state. */\n  responses?: NpsResponses\n  title: string\n}\n\nconst exampleProps: Gauge1Props = {\n  period: 'over the last 90 days, across all plans',\n  previous: 31,\n  responses: { detractors: 211, passives: 381, promoters: 692 },\n  title: 'Net Promoter Score',\n}\n\nconst formatScore = (value: number) => formatSigned(value)\nconst formatShare = (share: number) => formatPercent(share, { maximumFractionDigits: 0 })\n\nconst GROUPS = [\n  { className: 'bg-emerald-600', key: 'promoters', label: 'Promoters', range: '9–10' },\n  {\n    className: 'bg-muted-foreground/40',\n    key: 'passives',\n    label: 'Passives',\n    range: '7–8',\n  },\n  { className: 'bg-red-600', key: 'detractors', label: 'Detractors', range: '0–6' },\n] as const\n\nconst Gauge1 = (props: Gauge1Props) => {\n  const { period, previous, responses, errorMessage, status, title } = props\n  const state = getBlockState(status, responses)\n  const counts = responses ?? { detractors: 0, passives: 0, promoters: 0 }\n  const nps = getNps(counts)\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              <BlockReady className='text-sm'>\n                <p className='text-muted-foreground text-sm'>\n                  {formatNumber(nps.total)} responses {period}.\n                </p>\n              </BlockReady>\n            </header>\n            <div className='flex flex-col items-center gap-2 border-t pt-5'>\n              <Gauge\n                className='w-full max-w-60'\n                formatScale={formatScore}\n                label={title}\n                max={100}\n                min={-100}\n                origin={0}\n                value={nps.score}\n                valueText={`${formatScore(nps.score)}${\n                  previous !== undefined ? `, ${formatScore(previous)} last period` : ''\n                }`}\n              >\n                <GaugeValue className='text-4xl'>{formatScore(nps.score)}</GaugeValue>\n              </Gauge>\n              {(state === 'loading' || previous !== undefined) && (\n                <KPIChange\n                  changeType='points'\n                  comparison='last period'\n                  previous={previous}\n                  value={nps.score}\n                />\n              )}\n            </div>\n            {state === 'loading' && (\n              <div className='flex flex-col gap-3 border-t pt-4'>\n                <Skeleton className='h-2 w-full rounded-full' />\n                <ul aria-hidden className='grid grid-cols-3 gap-2'>\n                  {GROUPS.map((group) => (\n                    <li key={group.key} className='flex min-w-0 flex-col gap-0.5'>\n                      <span className='text-muted-foreground truncate text-xs'>\n                        {group.label}\n                      </span>\n                      <span className='text-2xl font-light'>\n                        <SkeletonText className='w-[2.5em]' />\n                      </span>\n                      <span className='text-xs'>\n                        <SkeletonText className='w-2/3' />\n                      </span>\n                    </li>\n                  ))}\n                </ul>\n              </div>\n            )}\n            {!state && (\n              <div className='flex flex-col gap-3 border-t pt-4'>\n                <div aria-hidden className='flex h-2 w-full gap-0.5'>\n                  {GROUPS.map((group) => (\n                    <span\n                      key={group.key}\n                      className={cn(\n                        'h-full first:rounded-l-full last:rounded-r-full',\n                        group.className,\n                      )}\n                      style={{ width: `${nps[group.key] * 100}%` }}\n                    />\n                  ))}\n                </div>\n                <ul className='grid grid-cols-3 gap-2'>\n                  {GROUPS.map((group) => (\n                    <li key={group.key} className='flex min-w-0 flex-col gap-0.5'>\n                      <span className='text-muted-foreground flex items-center gap-1.5 text-xs'>\n                        <span\n                          aria-hidden\n                          className={cn('size-2 shrink-0 rounded-full', group.className)}\n                        />\n                        <span className='truncate'>{group.label}</span>\n                      </span>\n                      <span className='text-2xl font-light tracking-tight tabular-nums'>\n                        {formatShare(nps[group.key])}\n                      </span>\n                      <span className='text-muted-foreground text-xs tabular-nums'>\n                        {formatNumber(counts[group.key])} scored {group.range}\n                      </span>\n                    </li>\n                  ))}\n                </ul>\n                <p className='text-muted-foreground text-xs'>\n                  NPS is the share of promoters minus the share of detractors:{' '}\n                  <span className='tabular-nums'>\n                    {formatShare(nps.promoters)} − {formatShare(nps.detractors)}\n                  </span>\n                  .\n                </p>\n              </div>\n            )}\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport { Gauge1, exampleProps as gauge1ExampleProps, type Gauge1Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/gauge/gauge-01.tsx"
    }
  ],
  "meta": {
    "shows": "A net promoter score on its full −100 to 100 scale, with the split of promoters, passives and detractors.",
    "size": "compact",
    "usedWith": [
      "feedback-01",
      "gauge-04",
      "chart-panel-01"
    ],
    "component": "Gauge1",
    "props": "{ period: string; previous?: number; responses?: { detractors: number; passives: number; promoters: number }; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
