{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "micro-spring-stepper",
  "type": "registry:component",
  "title": "Spring Stepper",
  "description": "A stepper whose value pill works like a spring joystick: pull it left or right and it counts, faster the farther you pull, then snaps back. Hitting a limit bumps the number and buzzes on phones.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "micro",
    "stepper",
    "counter",
    "spring",
    "drag",
    "haptic",
    "micro"
  ],
  "docs": "https://hyperblur.dev/effects/micro-spring-stepper",
  "files": [
    {
      "path": "registry/hyperblur/micro-spring-stepper.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/micro-spring-stepper.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface MicroSpringStepperProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\" | \"children\"> {\n  value?: number;\n  defaultValue?: number;\n  min?: number;\n  max?: number;\n  step?: number;\n  label?: string;\n  unit?: string;\n  accent?: string;\n  disabled?: boolean;\n  haptics?: boolean;\n  onChange?: (value: number) => void;\n}\n\nconst css = `\n.hb-wf3 {\n  --hb-wf3-c: #2f7bff;\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  padding: 6px;\n  box-sizing: border-box;\n  border-radius: 20px;\n  background: linear-gradient(180deg, #161616 0%, #0f0f0f 100%);\n  border: 1px solid #262626;\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 10px 24px -12px rgba(0,0,0,0.9);\n  font-family: inherit;\n  color: #ededed;\n  user-select: none;\n  -webkit-user-select: none;\n}\n.hb-wf3 *, .hb-wf3 *::before, .hb-wf3 *::after { box-sizing: border-box; }\n.hb-wf3[data-disabled=\"true\"] { opacity: 0.45; pointer-events: none; }\n.hb-wf3-b {\n  display: grid;\n  place-items: center;\n  width: 38px;\n  height: 38px;\n  margin: 0;\n  padding: 0;\n  border: 1px solid #2a2a2a;\n  border-radius: 14px;\n  background: linear-gradient(180deg, #1f1f1f, #171717);\n  color: #cfcfcf;\n  cursor: pointer;\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 2px 0 #050505;\n  transition: transform 0.28s cubic-bezier(0.3, 1.8, 0.4, 1), background 0.2s ease, color 0.2s ease, box-shadow 0.15s ease;\n}\n.hb-wf3-b:hover { background: linear-gradient(180deg, #252525, #1b1b1b); color: #fff; }\n.hb-wf3-b:active { transform: translateY(2px) scale(0.94, 0.88); box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 0 0 #050505; transition-duration: 0.06s; }\n.hb-wf3-b:focus-visible { outline: 2px solid var(--hb-wf3-c); outline-offset: 2px; }\n.hb-wf3-b:disabled { opacity: 0.3; cursor: not-allowed; }\n.hb-wf3-b svg { width: 16px; height: 16px; }\n.hb-wf3-well {\n  position: relative;\n  width: 108px;\n  height: 46px;\n  border-radius: 14px;\n  background: #080808;\n  box-shadow: inset 0 2px 6px rgba(0,0,0,0.8), inset 0 0 0 1px #1c1c1c;\n}\n.hb-wf3-gl {\n  position: absolute;\n  top: 50%;\n  width: 18px;\n  height: 18px;\n  margin-top: -9px;\n  color: #3a3a3a;\n  transition: color 0.2s ease, transform 0.2s ease;\n}\n.hb-wf3-gl[data-d=\"-1\"] { left: 4px; }\n.hb-wf3-gl[data-d=\"1\"] { right: 4px; }\n.hb-wf3-gl[data-hot=\"true\"] { color: var(--hb-wf3-c); }\n.hb-wf3-gl svg { width: 100%; height: 100%; }\n.hb-wf3-pill {\n  position: absolute;\n  left: 20px;\n  right: 20px;\n  top: 4px;\n  bottom: 4px;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  border-radius: 11px;\n  background: linear-gradient(180deg, #262626 0%, #1b1b1b 100%);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.09), 0 3px 8px rgba(0,0,0,0.6);\n  cursor: grab;\n  touch-action: none;\n  overflow: hidden;\n  outline: none;\n  transition: transform 0.5s cubic-bezier(0.25, 1.9, 0.4, 1), box-shadow 0.2s ease;\n}\n.hb-wf3-pill:focus-visible { box-shadow: inset 0 1px 0 rgba(255,255,255,0.09), 0 0 0 2px var(--hb-wf3-c); }\n.hb-wf3[data-drag=\"true\"] .hb-wf3-pill { cursor: grabbing; transition: none; }\n.hb-wf3-in[data-bump=\"1\"] { animation: hb-wf3-bumpr 0.32s cubic-bezier(0.3, 1.6, 0.5, 1); }\n.hb-wf3-in[data-bump=\"-1\"] { animation: hb-wf3-bumpl 0.32s cubic-bezier(0.3, 1.6, 0.5, 1); }\n@keyframes hb-wf3-bumpr { 0% { translate: 0 0; } 30% { translate: 5px 0; } 60% { translate: -2px 0; } 100% { translate: 0 0; } }\n@keyframes hb-wf3-bumpl { 0% { translate: 0 0; } 30% { translate: -5px 0; } 60% { translate: 2px 0; } 100% { translate: 0 0; } }\n.hb-wf3-in { display: flex; flex-direction: column; align-items: center; }\n.hb-wf3-num {\n  position: relative;\n  height: 20px;\n  font-family: var(--font-mono), ui-monospace, monospace;\n  font-size: 17px;\n  font-weight: 600;\n  line-height: 20px;\n  font-variant-numeric: tabular-nums;\n  letter-spacing: -0.02em;\n}\n.hb-wf3-num span { display: block; }\n.hb-wf3-num[data-dir=\"1\"] span { animation: hb-wf3-up 0.26s cubic-bezier(0.2, 1.3, 0.4, 1); }\n.hb-wf3-num[data-dir=\"-1\"] span { animation: hb-wf3-down 0.26s cubic-bezier(0.2, 1.3, 0.4, 1); }\n@keyframes hb-wf3-up { from { transform: translateY(70%); opacity: 0; filter: blur(2px); } to { transform: none; opacity: 1; filter: none; } }\n@keyframes hb-wf3-down { from { transform: translateY(-70%); opacity: 0; filter: blur(2px); } to { transform: none; opacity: 1; filter: none; } }\n.hb-wf3-u { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: #7c7c7c; line-height: 1; margin-top: 1px; }\n.hb-wf3-rate {\n  position: absolute;\n  left: 0;\n  bottom: 0;\n  height: 2px;\n  background: var(--hb-wf3-c);\n  border-radius: 2px;\n  opacity: 0.85;\n  transition: width 0.12s ease;\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-wf3-b, .hb-wf3-pill, .hb-wf3-gl, .hb-wf3-rate { transition: none; }\n  .hb-wf3-num span, .hb-wf3-in[data-bump] { animation: none; }\n}\n`;\n\nconst reach = 26;\n\nexport function MicroSpringStepper({\n  value,\n  defaultValue = 2,\n  min = 0,\n  max = 12,\n  step = 1,\n  label = \"Guests\",\n  unit = \"guests\",\n  accent = \"#2f7bff\",\n  disabled = false,\n  haptics = true,\n  onChange,\n  className = \"\",\n  style,\n  ...rest\n}: MicroSpringStepperProps) {\n  const [inner, setInner] = React.useState(defaultValue);\n  const v = value ?? inner;\n  const [dir, setDir] = React.useState(0);\n  const [tick, setTick] = React.useState(0);\n  const [bump, setBump] = React.useState<{ d: number; n: number }>({ d: 0, n: 0 });\n  const [off, setOff] = React.useState(0);\n  const [dragging, setDragging] = React.useState(false);\n  const live = React.useRef({ v, off: 0, acc: 0, last: 0, raf: 0, startX: 0 });\n  const handlers = React.useRef({ onChange, haptics, value, min, max, step });\n\n  React.useEffect(() => {\n    handlers.current = { onChange, haptics, value, min, max, step };\n    live.current.v = v;\n  });\n\n  const nudge = React.useCallback((d: number) => {\n    const h = handlers.current;\n    const cur = live.current.v;\n    const next = Math.min(h.max, Math.max(h.min, cur + d * h.step));\n    if (next === cur) {\n      setBump((b) => ({ d, n: b.n + 1 }));\n      if (h.haptics && typeof navigator !== \"undefined\" && navigator.vibrate) navigator.vibrate([4, 30, 4]);\n      return;\n    }\n    live.current.v = next;\n    if (h.value === undefined) setInner(next);\n    setDir(Math.sign(d));\n    setTick((t) => t + 1);\n    if (h.haptics && typeof navigator !== \"undefined\" && navigator.vibrate) navigator.vibrate(6);\n    h.onChange?.(next);\n  }, []);\n\n  React.useEffect(() => {\n    if (!dragging) return;\n    const s = live.current;\n    s.last = performance.now();\n    s.acc = 0;\n    const loop = (t: number) => {\n      const dt = t - s.last;\n      s.last = t;\n      const mag = Math.abs(s.off) / reach;\n      if (mag > 0.3) {\n        const interval = 460 - 390 * Math.min(1, (mag - 0.3) / 0.65);\n        s.acc += dt;\n        if (s.acc >= interval) {\n          s.acc = 0;\n          nudge(s.off > 0 ? 1 : -1);\n        }\n      } else {\n        s.acc = 380;\n      }\n      s.raf = requestAnimationFrame(loop);\n    };\n    s.raf = requestAnimationFrame(loop);\n    return () => cancelAnimationFrame(s.raf);\n  }, [dragging, nudge]);\n\n  const end = () => {\n    live.current.off = 0;\n    setOff(0);\n    setDragging(false);\n  };\n\n  const mag = Math.min(1, Math.abs(off) / reach);\n  const hotDir = mag > 0.3 ? (off > 0 ? 1 : -1) : 0;\n\n  return (\n    <div\n      className={`hb-wf3 ${className}`}\n      data-drag={dragging}\n      data-disabled={disabled}\n      style={{ ...style, [\"--hb-wf3-c\" as string]: accent }}\n      {...rest}\n    >\n      <style href=\"hb-micro-spring-stepper\" precedence=\"default\">\n        {css}\n      </style>\n      <button type=\"button\" className=\"hb-wf3-b\" aria-label={`Fewer ${unit}`} disabled={disabled || v <= min} onClick={() => nudge(-1)}>\n        <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\">\n          <path d=\"M3.5 8h9\" />\n        </svg>\n      </button>\n      <div className=\"hb-wf3-well\">\n        <span className=\"hb-wf3-gl\" data-d=\"-1\" data-hot={hotDir === -1} aria-hidden=\"true\">\n          <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n            <path d=\"M10 4L6 8l4 4\" />\n          </svg>\n        </span>\n        <span className=\"hb-wf3-gl\" data-d=\"1\" data-hot={hotDir === 1} aria-hidden=\"true\">\n          <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n            <path d=\"M6 4l4 4-4 4\" />\n          </svg>\n        </span>\n        <div\n          role=\"spinbutton\"\n          tabIndex={disabled ? -1 : 0}\n          aria-label={label}\n          aria-valuenow={v}\n          aria-valuemin={min}\n          aria-valuemax={max}\n          aria-valuetext={`${v} ${unit}`}\n          className=\"hb-wf3-pill\"\n          style={{ transform: `translateX(${off.toFixed(2)}px) scaleX(${(1 - mag * 0.06).toFixed(3)})` }}\n          onPointerDown={(e) => {\n            if (disabled) return;\n            e.currentTarget.setPointerCapture(e.pointerId);\n            live.current.startX = e.clientX;\n            setDragging(true);\n          }}\n          onPointerMove={(e) => {\n            if (!dragging) return;\n            const dx = e.clientX - live.current.startX;\n            const o = Math.sign(dx) * reach * (1 - Math.exp(-Math.abs(dx) / (reach * 1.6)));\n            live.current.off = o;\n            setOff(o);\n          }}\n          onPointerUp={end}\n          onPointerCancel={end}\n          onKeyDown={(e) => {\n            if (e.key === \"ArrowUp\" || e.key === \"ArrowRight\") {\n              e.preventDefault();\n              nudge(1);\n            } else if (e.key === \"ArrowDown\" || e.key === \"ArrowLeft\") {\n              e.preventDefault();\n              nudge(-1);\n            } else if (e.key === \"PageUp\") {\n              e.preventDefault();\n              for (let i = 0; i < 5; i++) nudge(1);\n            } else if (e.key === \"PageDown\") {\n              e.preventDefault();\n              for (let i = 0; i < 5; i++) nudge(-1);\n            } else if (e.key === \"Home\") {\n              e.preventDefault();\n              nudge(-(v - min) / step);\n            } else if (e.key === \"End\") {\n              e.preventDefault();\n              nudge((max - v) / step);\n            }\n          }}\n        >\n          <span key={`b${bump.n}`} className=\"hb-wf3-in\" data-bump={bump.n ? bump.d : undefined}>\n            <span className=\"hb-wf3-num\" data-dir={dir}>\n              <span key={tick}>{v}</span>\n            </span>\n            <span className=\"hb-wf3-u\">{unit}</span>\n          </span>\n          <span className=\"hb-wf3-rate\" style={{ width: `${(mag * 100).toFixed(0)}%`, left: off < 0 ? \"auto\" : 0, right: off < 0 ? 0 : \"auto\" }} />\n        </div>\n      </div>\n      <button type=\"button\" className=\"hb-wf3-b\" aria-label={`More ${unit}`} disabled={disabled || v >= max} onClick={() => nudge(1)}>\n        <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\">\n          <path d=\"M3.5 8h9M8 3.5v9\" />\n        </svg>\n      </button>\n    </div>\n  );\n}\n"
    }
  ]
}