{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-centre",
  "title": "Chart centre",
  "description": "The words in the middle of a chart drawn round a centre: a value that rolls to each new one over a caption that swaps in place, sized to the hole. The Donut and Radial charts draw on it.",
  "dependencies": [],
  "registryDependencies": [
    "https://kinoui.com/r/animated-number.json",
    "https://kinoui.com/r/chart-root.json",
    "https://kinoui.com/r/swap.json"
  ],
  "files": [
    {
      "path": "registry/lib/chart-centre.tsx",
      "content": "'use client'\n\nimport { AnimatedNumber } from '@/registry/components/kino/animated-number'\nimport type { ChartFormat } from '@/registry/lib/chart-root'\nimport { Swap } from '@/registry/lib/swap'\nimport type { ReactNode } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * The words in the middle of a chart drawn round a centre, the Donut's and\n * the Radial chart's: a value that rolls to each new one, over a caption\n * that swaps in place and wraps, both sized to the hole they sit in, `--centre-hole`,\n * set by the layer around them.\n */\n\nfunction ChartCentreText({\n  value,\n  caption,\n  format,\n  locale,\n  className,\n}: {\n  value: number\n  caption: ReactNode\n  format?: ChartFormat\n  locale: Intl.LocalesArgument\n  /** The value's own classes, such as a colour for a warning. */\n  className?: string\n}) {\n  // Sized to the hole, between the body text and the size of a page's figure.\n  const size =\n    'text-[clamp(1rem,calc(var(--centre-hole)*0.2),1.875rem)] font-medium tracking-tight'\n  return (\n    // As wide as most of the hole, so the text never reaches the ring.\n    <div className='flex w-[calc(var(--centre-hole)*0.78)] min-w-0 flex-col items-center gap-0.5 text-center'>\n      {typeof format === 'function' ? (\n        <span className={cn(size, 'tabular-nums', className)}>\n          <Swap roll>{format(value)}</Swap>\n        </span>\n      ) : (\n        <AnimatedNumber\n          value={value}\n          locale={locale}\n          format={format}\n          className={cn('max-w-full', size, className)}\n        />\n      )}\n      {/*\n       * The caption wraps rather than cutting, since nothing around it can show it whole, and\n       * steps aside in a hole too small for a word.\n       */}\n      <div className='@container w-full'>\n        <span className='text-muted-foreground hidden max-w-full justify-center text-center text-xs text-balance [overflow-wrap:anywhere] @min-[3.5rem]:flex'>\n          <Swap block>{caption}</Swap>\n        </span>\n      </div>\n    </div>\n  )\n}\n\nexport { ChartCentreText }\n",
      "type": "registry:lib",
      "target": "@lib/chart-centre.tsx"
    }
  ],
  "type": "registry:lib"
}