{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "gauge-04",
  "description": "A satisfaction score on an arc with a target tick, the change since last period and the gap to target.",
  "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-04.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  Gauge,\n  GaugeTargetKey,\n  GaugeToneLabel,\n  GaugeValue,\n} from '@/registry/components/dashboardblocks/gauge'\nimport { KPIChange } from '@/registry/components/dashboardblocks/kpi'\nimport {\n  formatNumber,\n  formatPercent,\n  formatPoints,\n} from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Gauge4Props extends BlockStateProps {\n  /** Follows the previous value in the change, such as `in August`. */\n  comparison: string\n  description: string\n  footnote?: string\n  formatter?: (value: number) => string\n  /** @default 100 */\n  max?: number\n  /** @default 0 */\n  min?: number\n  previous?: number\n  scaleFormatter?: (value: number) => string\n  target: number\n  title: string\n  /** Leave out to show the empty state. */\n  value?: number\n}\n\nconst exampleProps: Gauge4Props = {\n  comparison: 'in August',\n  description: 'Share of 4 and 5 star ratings in September, from 2,318 surveys.',\n  formatter: (value) => formatPercent(value / 100, { minimumFractionDigits: 1 }),\n  previous: 81.2,\n  scaleFormatter: (value) => formatPercent(value / 100),\n  target: 85,\n  title: 'Customer satisfaction',\n  value: 83.6,\n}\n\nconst Gauge4 = (props: Gauge4Props) => {\n  const {\n    comparison,\n    description,\n    footnote,\n    formatter = (value) => formatNumber(value),\n    max = 100,\n    min = 0,\n    previous,\n    scaleFormatter = formatter,\n    errorMessage,\n    status,\n    target,\n    title,\n  } = props\n  const state = getBlockState(status, props.value)\n  const value = props.value ?? min\n  const gap = Math.abs(value - target)\n  const met = value >= target\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 items-start justify-between gap-3'>\n              <div className='flex min-w-0 flex-col gap-0.5'>\n                <h2 className='font-semibold tracking-tight'>{title}</h2>\n                <p className='text-muted-foreground text-sm'>{description}</p>\n              </div>\n              {!state && (\n                <GaugeToneLabel\n                  className='mt-0.5'\n                  label={met ? 'Target met' : 'Below target'}\n                  tone={met ? 'positive' : 'caution'}\n                />\n              )}\n            </header>\n            <div className='flex flex-col items-center gap-6 border-t pt-5 @md:flex-row @md:items-end'>\n              <Gauge\n                className='w-full max-w-56 @md:w-52'\n                formatScale={scaleFormatter}\n                label={title}\n                max={max}\n                min={min}\n                target={target}\n                value={value}\n                valueText={`${formatter(value)}, target ${formatter(target)}`}\n              >\n                <GaugeValue className='text-4xl'>{formatter(value)}</GaugeValue>\n              </Gauge>\n              <div className='flex w-full min-w-0 flex-col gap-3 @md:pb-6'>\n                <KPIChange\n                  changeType='points'\n                  comparison={comparison}\n                  previous={previous}\n                  value={value}\n                />\n                <BlockReady className='text-sm'>\n                  <p className='text-sm'>\n                    <span className='font-medium tabular-nums'>\n                      {formatPoints(gap, { minimumFractionDigits: 1 })}\n                    </span>{' '}\n                    <span className='text-muted-foreground'>\n                      {met ? 'above' : 'to go to'} the{' '}\n                      <span className='tabular-nums'>{formatter(target)}</span> target.\n                    </span>\n                  </p>\n                </BlockReady>\n                <GaugeTargetKey />\n              </div>\n            </div>\n            {footnote && (!state || state === 'loading') && (\n              <div className='border-t pt-3'>\n                <BlockReady className='text-xs'>\n                  <p className='text-muted-foreground text-xs'>{footnote}</p>\n                </BlockReady>\n              </div>\n            )}\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport { Gauge4, exampleProps as gauge4ExampleProps, type Gauge4Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/gauge/gauge-04.tsx"
    }
  ],
  "meta": {
    "shows": "A satisfaction score on an arc with a target tick, the change since last period and the gap to target.",
    "size": "half",
    "usedWith": [
      "gauge-01",
      "feedback-02",
      "goals-01"
    ],
    "component": "Gauge4",
    "props": "{ comparison: string; description: string; footnote?: string; formatter?: (value: number) => string; max?: number; min?: number; previous?: number; scaleFormatter?: (value: number) => string; target: number; title: string; value?: number; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
