{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "animate-number",
  "title": "Animate Number",
  "description": "Pricing/stats counter — digits tween as numbers with easeOutSoft. Reduced motion jumps to final.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "@atroui/motion",
    "@atroui/utils"
  ],
  "files": [
    {
      "path": "registry/default/ui/animate-number.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useReducedMotion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport type AnimateNumberFormat =\n  | Intl.NumberFormatOptions\n  | ((value: number) => string)\n\nexport type AnimateNumberProps = {\n  value: number\n  /** Start value on mount / when first set. Defaults to `value` (no enter tween). */\n  from?: number\n  /** Tween duration in seconds. Soft settle — ~0.6–0.8s. */\n  duration?: number\n  /** Intl options or a formatter. Default: rounded `toLocaleString`. */\n  format?: AnimateNumberFormat\n  locale?: string\n  prefix?: string\n  suffix?: string\n  className?: string\n}\n\nfunction resolveFormat(\n  format: AnimateNumberFormat | undefined,\n  locale?: string\n): (n: number) => string {\n  if (typeof format === \"function\") return format\n  if (format) {\n    const nf = new Intl.NumberFormat(locale, format)\n    return (n) => nf.format(n)\n  }\n  return (n) => Math.round(n).toLocaleString(locale)\n}\n\n/** easeOutSoft-ish cubic (matches Family Values chrome settle). */\nfunction easeOutCubic(t: number) {\n  return 1 - Math.pow(1 - t, 3)\n}\n\n/**\n * Pricing / stats counter — digits tween as numbers (not split-text scramble).\n * Family Values: ease-out settle, no spring overshoot; reduced motion jumps to final.\n * Uses rAF (not MotionValue children) so the digit always paints in React 19.\n */\nexport function AnimateNumber({\n  value,\n  from,\n  duration = 0.7,\n  format,\n  locale,\n  prefix = \"\",\n  suffix = \"\",\n  className,\n}: AnimateNumberProps) {\n  const reduce = useReducedMotion()\n  const formatFn = React.useMemo(\n    () => resolveFormat(format, locale),\n    [format, locale]\n  )\n\n  const start = from ?? value\n  const label = `${prefix}${formatFn(value)}${suffix}`\n  const [text, setText] = React.useState(label)\n\n  React.useEffect(() => {\n    if (reduce || start === value || duration <= 0) {\n      setText(label)\n      return\n    }\n\n    setText(`${prefix}${formatFn(start)}${suffix}`)\n    let raf = 0\n    const t0 = performance.now()\n    const ms = duration * 1000\n\n    const tick = (now: number) => {\n      const t = Math.min(1, (now - t0) / ms)\n      const latest = start + (value - start) * easeOutCubic(t)\n      setText(`${prefix}${formatFn(latest)}${suffix}`)\n      if (t < 1) {\n        raf = requestAnimationFrame(tick)\n      } else {\n        setText(label)\n      }\n    }\n\n    raf = requestAnimationFrame(tick)\n    return () => cancelAnimationFrame(raf)\n  }, [start, value, duration, reduce, label, prefix, suffix, formatFn])\n\n  return (\n    <span className={cn(\"tabular-nums\", className)} aria-label={label}>\n      {text}\n    </span>\n  )\n}\n",
      "type": "registry:ui",
      "target": "components/ui/animate-number.tsx"
    }
  ],
  "type": "registry:ui"
}