{
  "title": "Rolling Number",
  "description": "A smooth rolling number component powered by GSAP.",
  "name": "gsap-rolling-number",
  "dependencies": [
    "gsap",
    "@gsap/react"
  ],
  "registryDependencies": [
    "button"
  ],
  "type": "registry:ui",
  "files": [
    {
      "path": "components/demo/gsap/rolling-number/default.tsx",
      "type": "registry:ui",
      "content": "import { useState } from \"react\";\n\nimport { Button } from \"@/components/ui/button\";\nimport { RollingNumber } from \"@/components/paceui/gsap/rolling-number\";\n\nexport const Demo = () => {\n    const [count, setCount] = useState(48291);\n\n    return (\n        <div className=\"flex flex-col items-center justify-center gap-4 py-6\">\n            <div className=\"font-mono text-3xl font-bold tracking-wider sm:text-4xl\">\n                <RollingNumber targetNumber={count} height={40} />\n            </div>\n            <Button variant=\"outline\" size=\"sm\" onClick={() => setCount(Math.floor(10000 + Math.random() * 90000))}>\n                Randomize\n            </Button>\n        </div>\n    );\n};\n"
    },
    {
      "path": "components/paceui/gsap/rolling-number.tsx",
      "type": "registry:ui",
      "content": "import { useEffect, useRef } from \"react\";\n\nimport { useGSAP } from \"@gsap/react\";\nimport gsap from \"gsap\";\n\nimport { cn } from \"@/lib/utils\";\n\ntype RollingDigitProps = {\n    digit: string;\n    duration?: number;\n    height?: number;\n};\n\nconst RollingDigit = ({ digit, duration = 1, height = 32 }: RollingDigitProps) => {\n    const containerRef = useRef<HTMLDivElement>(null);\n    const num = parseInt(digit, 10);\n    const isNumber = !isNaN(num);\n\n    useGSAP(\n        () => {\n            if (!isNumber || !containerRef.current) return;\n            gsap.to(containerRef.current, {\n                y: -height * (num + 1),\n                duration: duration,\n                ease: \"power4.out\",\n            });\n        },\n        { dependencies: [num, height, duration, isNumber] },\n    );\n\n    if (!isNumber) {\n        return (\n            <div\n                className=\"inline-flex items-center justify-center select-none\"\n                style={{ height, lineHeight: `${height}px` }}>\n                {digit}\n            </div>\n        );\n    }\n\n    return (\n        <div className=\"relative inline-block overflow-hidden select-none\" style={{ height }}>\n            <div\n                ref={containerRef}\n                className=\"flex flex-col items-center\"\n                style={{ transform: `translateY(-${height}px)` }}>\n                <span style={{ height, lineHeight: `${height}px` }} className=\"flex items-center justify-center\">\n                    9\n                </span>\n                {[...Array(10).keys()].map((n) => (\n                    <span\n                        key={n}\n                        style={{ height, lineHeight: `${height}px` }}\n                        className=\"flex items-center justify-center\">\n                        {n}\n                    </span>\n                ))}\n                <span style={{ height, lineHeight: `${height}px` }} className=\"flex items-center justify-center\">\n                    0\n                </span>\n            </div>\n        </div>\n    );\n};\n\ntype RollingNumberProps = {\n    targetNumber: number | string;\n    duration?: number;\n    height?: number;\n    onComplete?: () => void;\n    className?: string;\n};\n\nexport const RollingNumber = ({\n    targetNumber,\n    duration = 1,\n    height = 32,\n    onComplete,\n    className,\n}: RollingNumberProps) => {\n    const digits = String(targetNumber).split(\"\");\n\n    useEffect(() => {\n        const timer = setTimeout(() => {\n            onComplete?.();\n        }, duration * 1000);\n        return () => clearTimeout(timer);\n    }, [duration, onComplete, targetNumber]);\n\n    return (\n        <div className={cn(\"inline-flex items-center\", className)}>\n            {digits.map((digit, i) => (\n                <RollingDigit key={i} digit={digit} duration={duration} height={height} />\n            ))}\n        </div>\n    );\n};\n"
    }
  ],
  "mcp": {
    "description": "Provides refined UI interactions and accessible controls. A smooth rolling number component powered by GSAP. Relies on gsap, @gsap/react. Optimal for building reusable interface elements and user input flows.",
    "tags": [
      "component",
      "gsap",
      "animation"
    ]
  }
}