{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"shadcnblocks/counter-button","title":"Counter Button - Animated count stepper","description":"A minus and plus control that increments a number with a vertical slide animation between min and max.","dependencies":["lucide-react","motion","cn"],"registryDependencies":[],"files":[{"path":"components/shadcnblocks/counter-button.tsx","content":"\"use client\";\n\nimport { Minus, Plus } from \"lucide-react\";\nimport { motion, AnimatePresence } from \"motion/react\";\nimport * as React from \"react\";\nimport { cn } from \"cn\";\n\nexport interface CounterButtonProps {\n  initialCount?: number;\n  min?: number;\n  max?: number;\n  onChange?: (count: number) => void;\n  className?: string;\n}\n\nexport const CounterButton = ({\n  initialCount = 0,\n  min = 0,\n  max = 99,\n  onChange,\n  className,\n}: CounterButtonProps) => {\n  const [count, setCount] = React.useState(initialCount);\n  const [direction, setDirection] = React.useState<1 | -1>(1);\n\n  const increment = () => {\n    if (count >= max) return;\n    setDirection(1);\n    const next = count + 1;\n    setCount(next);\n    onChange?.(next);\n  };\n\n  const decrement = () => {\n    if (count <= min) return;\n    setDirection(-1);\n    const next = count - 1;\n    setCount(next);\n    onChange?.(next);\n  };\n\n  return (\n    <div\n      className={cn(\n        \"inline-flex h-9 items-center rounded-md border border-input bg-background\",\n        className,\n      )}\n    >\n      <button\n        type=\"button\"\n        onClick={decrement}\n        disabled={count <= min}\n        className=\"flex h-full w-9 items-center justify-center rounded-l-md transition-colors hover:bg-accent disabled:pointer-events-none disabled:opacity-50\"\n      >\n        <Minus className=\"size-3.5\" />\n      </button>\n      <div className=\"flex h-full w-10 items-center justify-center overflow-hidden border-x border-input text-sm font-medium\">\n        <AnimatePresence mode=\"popLayout\" initial={false}>\n          <motion.span\n            key={count}\n            initial={{ y: direction * 20, opacity: 0 }}\n            animate={{ y: 0, opacity: 1 }}\n            exit={{ y: direction * -20, opacity: 0 }}\n            transition={{ duration: 0.15, ease: \"easeOut\" }}\n          >\n            {count}\n          </motion.span>\n        </AnimatePresence>\n      </div>\n      <button\n        type=\"button\"\n        onClick={increment}\n        disabled={count >= max}\n        className=\"flex h-full w-9 items-center justify-center rounded-r-md transition-colors hover:bg-accent disabled:pointer-events-none disabled:opacity-50\"\n      >\n        <Plus className=\"size-3.5\" />\n      </button>\n    </div>\n  );\n};\n","type":"registry:component"}],"type":"registry:component","meta":{"license":"https://www.shadcnblocks.com/license"}}