{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "odometer-grouping-demo",
  "type": "registry:block",
  "title": "Odometer: Indian Grouping",
  "description": "Animated Number Counter example, Indian Grouping: A rupee fundraiser that keeps ticking up. Switch between the Indian system of lakhs and crores (₹2,45,67,890) and international thousands (₹24,567,890): the commas roll to their new places while every digit stays put. A take on the number counter (count up). Fits stats, pricing, hero and app UI sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "stats",
    "pricing",
    "hero",
    "app-ui",
    "number-counter",
    "number",
    "data",
    "motion"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/odometer#odometer-grouping-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/odometer.json"
  ],
  "files": [
    {
      "path": "components/odometer-grouping-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, useInView } from \"motion/react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { Odometer } from \"@/components/ui/odometer\";\n\ntype Grouping = \"indian\" | \"international\";\n\nconst inr: Intl.NumberFormatOptions = { style: \"currency\", currency: \"INR\", maximumFractionDigits: 0 };\nconst GOAL = 5_00_00_000; // ₹5 crore\n\nconst systems: { id: Grouping; label: string; sample: string }[] = [\n  { id: \"indian\", label: \"Indian\", sample: \"12,34,567\" },\n  { id: \"international\", label: \"International\", sample: \"1,234,567\" },\n];\n\n// Gifts keep rolling in while the card is on screen. Switching the system\n// only moves the commas: no digit turns.\nexport function OdometerGroupingDemo() {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const live = useInView(ref, { amount: 0.4 });\n  const [grouping, setGrouping] = React.useState<Grouping>(\"indian\");\n  const [raised, setRaised] = React.useState(2_45_67_890);\n  const [donors, setDonors] = React.useState(18_342);\n\n  React.useEffect(() => {\n    if (!live) return;\n    let timer = 0;\n    const tick = () => {\n      // Mostly small gifts, now and then a big one.\n      const gift = Math.random() < 0.15 ? 25_000 + Math.random() * 2_00_000 : 500 + Math.random() * 9_500;\n      setRaised((r) => Math.min(GOAL, r + Math.round(gift / 10) * 10));\n      setDonors((d) => d + 1);\n      timer = window.setTimeout(tick, 1400 + Math.random() * 1200);\n    };\n    timer = window.setTimeout(tick, 1200);\n    return () => window.clearTimeout(timer);\n  }, [live]);\n\n  const index = systems.findIndex((s) => s.id === grouping);\n\n  return (\n    <div ref={ref} className=\"flex w-full max-w-md flex-col items-center\">\n      <div className=\"w-full rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm shadow-zinc-950/[0.03] sm:p-7 dark:border-zinc-800 dark:bg-zinc-900 dark:shadow-none\">\n        <div className=\"flex items-center justify-between gap-4\">\n          <p className=\"text-sm text-zinc-500 dark:text-zinc-400\">Raised for village libraries</p>\n          <span className=\"inline-flex items-center gap-1.5 text-xs text-zinc-500 dark:text-zinc-400\">\n            <span className=\"relative flex size-1.5\">\n              {live ? (\n                <span className=\"absolute inline-flex size-full animate-ping rounded-full bg-emerald-500 opacity-60\" />\n              ) : null}\n              <span className=\"relative inline-flex size-1.5 rounded-full bg-emerald-500\" />\n            </span>\n            Live\n          </span>\n        </div>\n\n        <p className=\"mt-3 text-[clamp(2.25rem,9vw,3.25rem)] leading-none font-semibold tracking-[-0.04em] text-zinc-950 dark:text-zinc-50\">\n          <Odometer value={raised} format={inr} grouping={grouping} />\n        </p>\n\n        <div className=\"mt-6 h-1.5 overflow-hidden rounded-full bg-zinc-100 dark:bg-zinc-800\">\n          <motion.div\n            className=\"h-full origin-left rounded-full bg-emerald-500\"\n            initial={false}\n            animate={{ scaleX: raised / GOAL }}\n            transition={{ type: \"spring\", stiffness: 120, damping: 24 }}\n          />\n        </div>\n        <div className=\"mt-3 flex flex-wrap justify-between gap-x-4 gap-y-1 text-sm text-zinc-500 dark:text-zinc-400\">\n          <span>\n            <Odometer\n              value={donors}\n              grouping={grouping}\n              className=\"font-medium text-zinc-950 dark:text-zinc-50\"\n            />{\" \"}\n            donors\n          </span>\n          <span>\n            of{\" \"}\n            <Odometer\n              value={GOAL}\n              format={inr}\n              grouping={grouping}\n              className=\"font-medium text-zinc-950 dark:text-zinc-50\"\n            />{\" \"}\n            goal\n          </span>\n        </div>\n      </div>\n\n      <div\n        role=\"radiogroup\"\n        aria-label=\"Comma grouping\"\n        className=\"relative mt-5 grid grid-cols-2 rounded-full border border-zinc-200 bg-zinc-100 p-1 dark:border-zinc-800 dark:bg-zinc-900\"\n      >\n        <motion.span\n          aria-hidden\n          className=\"absolute inset-y-1 left-1 w-[calc(50%-0.25rem)] rounded-full bg-white shadow-sm ring-1 shadow-zinc-950/10 ring-zinc-950/5 dark:bg-zinc-700 dark:ring-white/10\"\n          initial={false}\n          animate={{ x: `${index * 100}%` }}\n          transition={{ type: \"spring\", stiffness: 520, damping: 42 }}\n        />\n        {systems.map((system) => (\n          <button\n            key={system.id}\n            type=\"button\"\n            role=\"radio\"\n            aria-checked={system.id === grouping}\n            onClick={() => setGrouping(system.id)}\n            className={cn(\n              \"relative flex items-baseline justify-center gap-2 rounded-full px-4 py-1.5 text-sm font-medium whitespace-nowrap transition-colors duration-200 outline-none focus-visible:ring-2 focus-visible:ring-zinc-400\",\n              system.id === grouping\n                ? \"text-zinc-950 dark:text-zinc-50\"\n                : \"text-zinc-500 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200\",\n            )}\n          >\n            {system.label}\n            <span className=\"font-mono text-xs font-normal opacity-60\">{system.sample}</span>\n          </button>\n        ))}\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}