{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "radial-progress",
  "type": "registry:component",
  "title": "Radial Progress",
  "description": "A ring gauge for one value against a limit, with the value and a label in the centre.",
  "categories": [
    "viz"
  ],
  "dependencies": [],
  "registryDependencies": [
    "@rivier-ui/theme",
    "@rivier-ui/chart",
    "@rivier-ui/cn"
  ],
  "files": [
    {
      "path": "registry/viz/radial-progress.tsx",
      "type": "registry:component",
      "target": "components/viz/radial-progress.tsx",
      "content": "\"use client\";\n/**\n * @name radial-progress\n * @category viz\n * @description A ring gauge for one value against a limit, with the value and a label in the centre.\n * @when One ratio: a quota used, a score, a goal reached. Size it with a width class (`w-32` by default). For several ratios side by side use a list of bars (bar-chart horizontal), not a ring each; for parts of a whole use donut-chart.\n * @example\n * <RadialProgress value={72} label=\"Storage used\" />\n * <RadialProgress value={3} max={5} label=\"Steps done\" formatValue={(value) => `${value} of 5`} className=\"w-40\" />\n */\nimport type { ComponentProps, CSSProperties, ReactNode } from \"react\";\nimport { cn } from \"@/lib/cn\";\nimport { chartSeries, formatNumber } from \"@/components/viz/chart\";\n\nexport type RadialProgressProps = Omit<ComponentProps<\"div\">, \"children\"> & {\n  value: number;\n  min?: number;\n  max?: number;\n  /** What is measured. Shown under the value, and the gauge's accessible name. */\n  label: string;\n  /** The text in the centre. Default: the share of the range as a percentage. */\n  formatValue?: (value: number) => string;\n  /** A BCP 47 locale for the default percentage. Default \"en-US\". */\n  locale?: string;\n  /** Ring thickness, as a percentage of the gauge's width. */\n  thickness?: number;\n  /** The ends of the filled arc. */\n  cap?: \"round\" | \"butt\";\n  /** Which series colour, 0-based. Default 0, the highlight. */\n  series?: number;\n  /** Replaces the centre (the value and the label) with your own content. */\n  children?: ReactNode;\n};\n\n/**\n * A client component although it holds no state: it calls helpers from chart, which is a client module, and a\n * server component cannot call a client module's functions.\n */\nexport function RadialProgress({ value, min = 0, max = 100, label, formatValue, locale, thickness = 8, cap = \"round\", series = 0, children, className, ...props }: RadialProgressProps) {\n  const span = max - min;\n  const share = span > 0 && Number.isFinite(value) ? Math.max(0, Math.min(1, (value - min) / span)) : 0;\n  const text = formatValue ? formatValue(value) : formatNumber(share, locale, { style: \"percent\", maximumFractionDigits: 0 });\n  const stroke = Math.max(1, Math.min(30, thickness));\n  const radius = 50 - stroke / 2;\n  const length = 2 * Math.PI * radius;\n  const style = chartSeries(series);\n\n  return (\n    <div\n      data-slot=\"radial-progress\"\n      role=\"meter\"\n      aria-label={label}\n      aria-valuemin={min}\n      aria-valuemax={max}\n      aria-valuenow={Number.isFinite(value) ? Math.max(min, Math.min(max, value)) : min}\n      aria-valuetext={text}\n      className={cn(\"relative aspect-square w-32\", className)}\n      {...props}\n    >\n      <svg aria-hidden=\"true\" viewBox=\"0 0 100 100\" className=\"block size-full -rotate-90\">\n        {/* The track is the same colour, fainter, so the ring reads as one thing. */}\n        <circle cx={50} cy={50} r={radius} fill=\"none\" className={style.stroke} strokeOpacity={0.16} strokeWidth={stroke} />\n        {share > 0 ? (\n          <circle\n            cx={50}\n            cy={50}\n            r={radius}\n            fill=\"none\"\n            // The arc is one dash as long as the circle, shifted back by what is not filled. It fills once on\n            // mount by animating stroke-dashoffset, from the whole length (set as --rui-ring-length for the\n            // rui-ring-in keyframes in the theme) to its place. stroke-dashoffset is a paint-only property: it\n            // moves no layout, so it is the one exception here to \"only transform and opacity\". Under reduced\n            // motion, and until those keyframes are in the stylesheet, the ring is simply drawn filled.\n            className={cn(style.stroke, \"motion-safe:animate-[rui-ring-in_var(--duration-scene)_var(--ease)_both]\")}\n            style={{ \"--rui-ring-length\": length } as CSSProperties}\n            strokeWidth={stroke}\n            strokeLinecap={cap}\n            strokeDasharray={`${length} ${length}`}\n            strokeDashoffset={length * (1 - share)}\n          />\n        ) : null}\n      </svg>\n      <div data-slot=\"radial-progress-center\" className=\"absolute inset-0 flex flex-col items-center justify-center px-4 text-center\">\n        {children ?? (\n          <>\n            <span className=\"text-xl font-semibold text-foreground\">{text}</span>\n            <span className=\"text-xs text-muted-foreground\">{label}</span>\n          </>\n        )}\n      </div>\n    </div>\n  );\n}\n"
    }
  ],
  "meta": {
    "category": "viz",
    "when": "One ratio: a quota used, a score, a goal reached. Size it with a width class (`w-32` by default). For several ratios side by side use a list of bars (bar-chart horizontal), not a ring each; for parts of a whole use donut-chart.",
    "example": "<RadialProgress value={72} label=\"Storage used\" />\n<RadialProgress value={3} max={5} label=\"Steps done\" formatValue={(value) => `${value} of 5`} className=\"w-40\" />",
    "client": true
  }
}
