{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rolling-number-ticker",
  "type": "registry:ui",
  "title": "Rolling Number Ticker",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Wise and Robinhood-style vertical rolling cylinder odometer number ticker with independent digit strips, smooth Hooke's Law spring physics, customizable currency prefix, and decimal formatting.",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/rolling-number-ticker.tsx",
      "content": "\"use client\";\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { motion } from \"framer-motion\";\nimport { ArrowUpRight, ArrowDownRight } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface RollingNumberTickerProps {\n  /** Target numeric value to display */\n  value?: number;\n  /** Currency symbol or prefix (e.g. \"$\", \"€\") */\n  currency?: string;\n  /** Decimal precision (default: 2) */\n  decimalPlaces?: number;\n  /** Font size scale variant */\n  fontSize?: \"sm\" | \"md\" | \"lg\" | \"xl\";\n  /** Spring physics stiffness (default: 260) */\n  stiffness?: number;\n  /** Spring physics damping (default: 26) */\n  damping?: number;\n  className?: string;\n}\n\nconst DIGITS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\n\ninterface SingleDigitColumnProps {\n  digit: number;\n  itemHeight: number;\n  stiffness: number;\n  damping: number;\n}\n\nfunction SingleDigitColumn({\n  digit,\n  itemHeight,\n  stiffness,\n  damping,\n}: SingleDigitColumnProps) {\n  return (\n    <div\n      style={{\n        position: \"relative\",\n        display: \"inline-block\",\n        height: itemHeight,\n        overflow: \"hidden\",\n        verticalAlign: \"top\",\n      }}\n      className=\"font-mono font-bold select-none\"\n    >\n      <motion.div\n        initial={false}\n        animate={{ y: -digit * itemHeight }}\n        transition={{ type: \"spring\", stiffness, damping, mass: 0.8 }}\n        style={{ display: \"block\" }}\n      >\n        {DIGITS.map((d) => (\n          <div\n            key={d}\n            style={{\n              height: itemHeight,\n              lineHeight: `${itemHeight}px`,\n              textAlign: \"center\",\n            }}\n          >\n            {d}\n          </div>\n        ))}\n      </motion.div>\n    </div>\n  );\n}\n\nexport function RollingNumberTicker({\n  value = 48932.18,\n  currency = \"$\",\n  decimalPlaces = 2,\n  fontSize = \"xl\",\n  stiffness = 260,\n  damping = 26,\n  className,\n}: RollingNumberTickerProps) {\n  const [lastDirection, setLastDirection] = useState<\"up\" | \"down\" | null>(null);\n  const prevValRef = useRef(value);\n\n  useEffect(() => {\n    if (value === prevValRef.current) return;\n    setLastDirection(value > prevValRef.current ? \"up\" : \"down\");\n    prevValRef.current = value;\n\n    const timer = setTimeout(() => setLastDirection(null), 900);\n    return () => clearTimeout(timer);\n  }, [value]);\n\n  const formattedString = value.toLocaleString(\"en-US\", {\n    minimumFractionDigits: decimalPlaces,\n    maximumFractionDigits: decimalPlaces,\n  });\n\n  const chars = formattedString.split(\"\");\n  const itemHeight =\n    fontSize === \"sm\" ? 36 : fontSize === \"md\" ? 44 : fontSize === \"lg\" ? 54 : 64;\n\n  const fontClasses =\n    fontSize === \"sm\"\n      ? \"text-xl sm:text-2xl\"\n      : fontSize === \"md\"\n        ? \"text-2xl sm:text-3xl\"\n        : fontSize === \"lg\"\n          ? \"text-3xl sm:text-4xl\"\n          : \"text-3xl sm:text-5xl\";\n\n  return (\n    <div\n      data-fullscreen-scroll\n      className={cn(\n        \"relative inline-flex flex-col items-center justify-center select-none\",\n        className\n      )}\n    >\n      {/* Status indicator: fixed-height slot so the layout never jumps */}\n      <div className=\"mb-2 flex h-4 items-center justify-center gap-1 text-xs font-medium\">\n        {lastDirection === \"up\" && (\n          <motion.span\n            initial={{ opacity: 0, y: 4 }}\n            animate={{ opacity: 1, y: 0 }}\n            className=\"inline-flex items-center gap-1 text-emerald-400 font-mono text-[11px]\"\n          >\n            <ArrowUpRight className=\"h-3 w-3\" />\n            <span>Increased</span>\n          </motion.span>\n        )}\n        {lastDirection === \"down\" && (\n          <motion.span\n            initial={{ opacity: 0, y: -4 }}\n            animate={{ opacity: 1, y: 0 }}\n            className=\"inline-flex items-center gap-1 text-rose-400 font-mono text-[11px]\"\n          >\n            <ArrowDownRight className=\"h-3 w-3\" />\n            <span>Decreased</span>\n          </motion.span>\n        )}\n      </div>\n\n      {/* Odometer frame */}\n      <div\n        aria-label={`${currency}${formattedString}`}\n        role=\"text\"\n        className=\"relative flex items-center justify-center rounded-2xl border border-neutral-800 bg-neutral-900/90 px-6 py-3 shadow-2xl backdrop-blur-md\"\n      >\n        {/* Shading masks */}\n        <div className=\"pointer-events-none absolute inset-x-0 top-0 z-10 h-3 rounded-t-2xl bg-gradient-to-b from-neutral-900 via-neutral-900/80 to-transparent\" />\n        <div className=\"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-3 rounded-b-2xl bg-gradient-to-t from-neutral-900 via-neutral-900/80 to-transparent\" />\n\n        {/* Currency prefix */}\n        {currency && (\n          <span\n            aria-hidden\n            style={{ height: itemHeight, lineHeight: `${itemHeight}px` }}\n            className={cn(\"mr-1.5 font-mono font-extrabold text-neutral-400\", fontClasses)}\n          >\n            {currency}\n          </span>\n        )}\n\n        {/* Rolling columns (keys count from the right so they stay stable) */}\n        <div\n          aria-hidden\n          className={cn(\"flex items-center font-extrabold text-white\", fontClasses)}\n        >\n          {chars.map((char, index) => {\n            const fromRight = chars.length - index;\n            const digit = parseInt(char, 10);\n\n            if (isNaN(digit)) {\n              return (\n                <span\n                  key={`static-${fromRight}`}\n                  style={{ height: itemHeight, lineHeight: `${itemHeight}px` }}\n                  className=\"inline-flex items-center justify-center px-0.5 font-mono text-neutral-400\"\n                >\n                  {char}\n                </span>\n              );\n            }\n\n            return (\n              <SingleDigitColumn\n                key={`col-${fromRight}`}\n                digit={digit}\n                itemHeight={itemHeight}\n                stiffness={stiffness}\n                damping={damping}\n              />\n            );\n          })}\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport default RollingNumberTicker;",
      "type": "registry:ui",
      "target": "components/ui/rolling-number-ticker.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport async function copyToClipboard(text: string): Promise<boolean> {\n  if (typeof window === \"undefined\") return false;\n\n  try {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(text);\n      return true;\n    }\n\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";\n    textArea.style.left = \"-999999px\";\n    textArea.style.top = \"-999999px\";\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n    const succeeded = document.execCommand(\"copy\");\n    textArea.remove();\n    return succeeded;\n  } catch {\n    return false;\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/utils.ts"
    }
  ]
}
