{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ripple-click-effect",
  "title": "Ripple Click Effect",
  "description": "A wrapper that makes any surface ripple where it's pressed: the wave grows while the pointer is held and fades when it lets go, several can overlap, icon buttons can ripple from the centre, and Enter or Space ripples for keyboard users.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/ripple-click-effect/ripple-click-effect.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface RippleProps {\n  children?: React.ReactNode;\n  /** Ripple colour (use currentColor to follow the text colour). */\n  color?: string;\n  /** Peak opacity of the ripple. */\n  opacity?: number;\n  /** Seconds for a ripple to spread across the surface. */\n  duration?: number;\n  /** Always start from the middle (good for icon buttons). */\n  center?: boolean;\n  disabled?: boolean;\n  className?: string;\n  style?: React.CSSProperties;\n}\n\ntype Wave = { id: number; x: number; y: number; size: number; held: boolean };\n\n/**\n * Wraps any surface and draws a ripple from where it's pressed. The wave grows while the pointer\n * is held and fades once it's released; Enter and Space make one from the centre.\n */\nexport function Ripple({ children, color = \"currentColor\", opacity = 0.22, duration = 0.55, center = false, disabled = false, className, style }: RippleProps) {\n  const reduce = Boolean(useReducedMotion());\n  const ref = React.useRef<HTMLDivElement>(null);\n  const [waves, setWaves] = React.useState<Wave[]>([]);\n  const next = React.useRef(0);\n\n  const spawn = (clientX?: number, clientY?: number) => {\n    const el = ref.current;\n    if (!el || disabled) return;\n    const r = el.getBoundingClientRect();\n    const x = center || clientX === undefined ? r.width / 2 : clientX - r.left;\n    const y = center || clientY === undefined ? r.height / 2 : clientY - r.top;\n    // Big enough to cover the farthest corner from the press point.\n    const size = 2 * Math.hypot(Math.max(x, r.width - x), Math.max(y, r.height - y));\n    const id = next.current++;\n    setWaves((w) => [...w, { id, x, y, size, held: true }]);\n    return id;\n  };\n  const release = () => setWaves((w) => w.map((v) => ({ ...v, held: false })));\n  const drop = (id: number) => setWaves((w) => w.filter((v) => v.id !== id));\n\n  return (\n    <div\n      ref={ref}\n      className={cn(\"relative isolate overflow-hidden\", className)}\n      style={style}\n      onPointerDown={(e) => {\n        if (e.button === 0) spawn(e.clientX, e.clientY);\n      }}\n      onPointerUp={release}\n      onPointerLeave={release}\n      onPointerCancel={release}\n      onKeyDown={(e) => {\n        if ((e.key === \"Enter\" || e.key === \" \") && !e.repeat) spawn();\n      }}\n      onKeyUp={release}\n    >\n      {children}\n      <span aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 z-10 overflow-hidden rounded-[inherit]\">\n        <AnimatePresence>\n          {waves.map((w) =>\n            reduce ? (\n              <motion.span key={w.id} className=\"absolute inset-0\" style={{ background: color }} initial={{ opacity: opacity * 0.6 }} animate={{ opacity: 0 }} transition={{ duration: 0.3 }} onAnimationComplete={() => drop(w.id)} />\n            ) : (\n              <motion.span\n                key={w.id}\n                className=\"absolute rounded-full\"\n                style={{ left: w.x - w.size / 2, top: w.y - w.size / 2, width: w.size, height: w.size, background: color }}\n                initial={{ scale: 0, opacity }}\n                animate={w.held ? { scale: 1, opacity } : { scale: 1, opacity: 0 }}\n                transition={{ scale: { duration, ease: [0.22, 1, 0.36, 1] }, opacity: { duration: w.held ? 0 : 0.45, delay: w.held ? 0 : Math.min(0.15, duration / 3) } }}\n                onAnimationComplete={() => {\n                  if (!w.held) drop(w.id);\n                }}\n              />\n            ),\n          )}\n        </AnimatePresence>\n      </span>\n    </div>\n  );\n}\n\nexport const RippleClickEffect = Ripple;\nexport default Ripple;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}