{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "kinetic-rolling-counter",
  "type": "registry:ui",
  "title": "Kinetic Rolling Counter",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Mechanical odometer numeric ticker where each digit column spins independently along a vertical 0-9 reel using Hooke's Law springs.",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/kinetic-rolling-counter.tsx",
      "content": "\"use client\";\n\nimport React, { useState } from \"react\";\nimport { motion, useReducedMotion } from \"framer-motion\";\nimport { Minus, Plus } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface KineticRollingCounterProps {\n  /** Initial integer value. Default: 1248 */\n  defaultValue?: number;\n  /** Increment step size. Default: 17 */\n  step?: number;\n  /** Hooke's Law spring stiffness coefficient for digit reel rotation. Default: 340 */\n  stiffness?: number;\n  /** Spring damping coefficient for digit reel rotation. Default: 26 */\n  damping?: number;\n  className?: string;\n}\n\nconst DIGITS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\n\ninterface DigitReelColumnProps {\n  digit: number;\n  stiffness: number;\n  damping: number;\n  shouldReduceMotion: boolean;\n}\n\nfunction DigitReelColumn({\n  digit,\n  stiffness,\n  damping,\n  shouldReduceMotion,\n}: DigitReelColumnProps) {\n  return (\n    <div\n      aria-hidden=\"true\"\n      className=\"relative h-9 w-6 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-50 font-mono text-lg font-bold tabular-nums text-black dark:border-[#262626] dark:bg-[#141414] dark:text-white\"\n    >\n      <motion.div\n        animate={{ y: `-${digit * 10}%` }}\n        transition={\n          shouldReduceMotion\n            ? { duration: 0 }\n            : { type: \"spring\", stiffness, damping }\n        }\n        className=\"flex flex-col items-center\"\n      >\n        {DIGITS.map((n) => (\n          <span\n            key={n}\n            className=\"flex h-9 w-6 items-center justify-center leading-none\"\n          >\n            {n}\n          </span>\n        ))}\n      </motion.div>\n    </div>\n  );\n}\n\nexport function KineticRollingCounter({\n  defaultValue = 1248,\n  step = 17,\n  stiffness = 340,\n  damping = 26,\n  className,\n}: KineticRollingCounterProps) {\n  const shouldReduceMotion = useReducedMotion() ?? false;\n  const [count, setCount] = useState<number>(Math.max(0, defaultValue));\n\n  const formatted = String(Math.max(0, count)).padStart(4, \"0\");\n  const digitArray = formatted.split(\"\").map((ch) => Number(ch) || 0);\n\n  return (\n    <div\n      className={cn(\n        \"inline-flex items-center gap-3 rounded-2xl border border-neutral-200 bg-white px-4 py-3 shadow-sm dark:border-[#222222] dark:bg-[#0A0A0A]\",\n        className\n      )}\n    >\n      <button\n        type=\"button\"\n        aria-label={`Decrease counter by ${step}`}\n        onClick={() => setCount((c) => Math.max(0, c - step))}\n        className=\"flex h-8 w-8 items-center justify-center rounded-xl border border-neutral-200 text-neutral-600 transition-colors hover:border-black hover:text-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black dark:border-[#262626] dark:text-neutral-300 dark:hover:border-white dark:hover:text-white dark:focus-visible:ring-white\"\n      >\n        <Minus className=\"h-3.5 w-3.5\" />\n      </button>\n\n      {/* Screen-reader live region */}\n      <span className=\"sr-only\" role=\"status\" aria-live=\"polite\">\n        Current value: {count}\n      </span>\n\n      {/* Mechanical Odometer Digit Reels */}\n      <div className=\"flex items-center gap-1\">\n        {digitArray.map((d, idx) => (\n          <DigitReelColumn\n            key={idx}\n            digit={d}\n            stiffness={stiffness}\n            damping={damping}\n            shouldReduceMotion={shouldReduceMotion}\n          />\n        ))}\n      </div>\n\n      <button\n        type=\"button\"\n        aria-label={`Increase counter by ${step}`}\n        onClick={() => setCount((c) => c + step)}\n        className=\"flex h-8 w-8 items-center justify-center rounded-xl border border-black bg-black text-white transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black dark:border-white dark:bg-white dark:text-black dark:focus-visible:ring-white\"\n      >\n        <Plus className=\"h-3.5 w-3.5\" />\n      </button>\n    </div>\n  );\n}\n\nexport default KineticRollingCounter;\n",
      "type": "registry:ui",
      "target": "components/ui/kinetic-rolling-counter.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"
    }
  ]
}
