{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "number-ticker",
  "title": "Number Ticker",
  "author": "VenusUI",
  "description": "Counts up to a number when it scrolls into view, with locale-aware formatting.",
  "files": [
    {
      "path": "registry/default/ui/number-ticker.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface NumberTickerProps extends Omit<React.ComponentProps<\"span\">, \"children\"> {\n  /** Number to count up (or down) to. */\n  value: number\n  /** Number to start from. */\n  from?: number\n  /** Animation length in milliseconds. */\n  duration?: number\n  /** Digits after the decimal point. */\n  decimals?: number\n  /** BCP 47 locale for formatting, e.g. `en-IN`. Defaults to the visitor's locale. */\n  locale?: string\n  /** Extra `Intl.NumberFormat` options, e.g. `{ style: \"currency\", currency: \"USD\" }`. */\n  formatOptions?: Intl.NumberFormatOptions\n}\n\nconst easeOutExpo = (t: number) => (t === 1 ? 1 : 1 - Math.pow(2, -10 * t))\n\n/**\n * Counts from `from` to `value` the first time it scrolls into view.\n * Updates the DOM directly (no re-render per frame). Screen readers get the\n * final value; with reduced motion the final value shows immediately.\n */\nfunction NumberTicker({\n  value,\n  from = 0,\n  duration = 2000,\n  decimals = 0,\n  locale,\n  formatOptions,\n  className,\n  ...props\n}: NumberTickerProps) {\n  const ref = React.useRef<HTMLSpanElement>(null)\n  const format = React.useMemo(() => {\n    const formatter = new Intl.NumberFormat(locale, {\n      minimumFractionDigits: decimals,\n      maximumFractionDigits: decimals,\n      ...formatOptions,\n    })\n    return (n: number) => formatter.format(n)\n  }, [locale, decimals, formatOptions])\n\n  React.useEffect(() => {\n    const node = ref.current\n    if (!node) return\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n      node.textContent = format(value)\n      return\n    }\n    let frame = 0\n    const observer = new IntersectionObserver(\n      ([entry]) => {\n        if (!entry?.isIntersecting) return\n        observer.disconnect()\n        const start = performance.now()\n        const tick = (now: number) => {\n          const progress = Math.min((now - start) / duration, 1)\n          node.textContent = format(from + (value - from) * easeOutExpo(progress))\n          if (progress < 1) frame = requestAnimationFrame(tick)\n        }\n        frame = requestAnimationFrame(tick)\n      },\n      { threshold: 0.4 }\n    )\n    observer.observe(node)\n    return () => {\n      observer.disconnect()\n      cancelAnimationFrame(frame)\n    }\n  }, [value, from, duration, format])\n\n  return (\n    <span data-slot=\"number-ticker\" className={cn(\"inline-block tabular-nums\", className)} {...props}>\n      <span ref={ref} aria-hidden=\"true\">\n        {format(from)}\n      </span>\n      <span className=\"sr-only\">{format(value)}</span>\n    </span>\n  )\n}\n\nexport { NumberTicker, type NumberTickerProps }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "text",
    "animations"
  ],
  "type": "registry:ui"
}