{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-slide-delete",
  "type": "registry:component",
  "title": "Button Slide Delete",
  "description": "A slide-to-delete track where the thumb eats the label as it travels and the bin at the end opens its lid. Release past the threshold and the thumb drops into the bin while a red pill wipes in.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "slider",
    "delete",
    "swipe",
    "confirm",
    "trash",
    "mobile"
  ],
  "docs": "https://hyperblur.dev/effects/button-slide-delete",
  "files": [
    {
      "path": "registry/hyperblur/button-slide-delete.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-slide-delete.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonSlideDeleteProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\" | \"onChange\" | \"onProgress\"> {\n  label?: string;\n  doneLabel?: string;\n  threshold?: number;\n  accent?: string;\n  resetAfter?: number;\n  disabled?: boolean;\n  onConfirm?: () => void;\n  onProgress?: (value: number) => void;\n}\n\nconst css = `\n.hb-xd2 {\n  --hb-xd2-h: 3.25rem;\n  --hb-xd2-t: 2.625rem;\n  --hb-xd2-x: 0px;\n  --hb-xd2-p: 0;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  max-width: 320px;\n  height: var(--hb-xd2-h);\n  padding: 5px;\n  font-family: inherit;\n  font-size: 0.875rem;\n  border-radius: 999px;\n  background:\n    linear-gradient(180deg, rgba(0,0,0,0.35), rgba(255,255,255,0.02)),\n    #120909;\n  border: 1px solid color-mix(in srgb, var(--hb-xd2-c) 22%, #241415);\n  box-shadow: inset 0 2px 6px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.04);\n  overflow: hidden;\n  user-select: none;\n  -webkit-user-select: none;\n  isolation: isolate;\n  transition: border-color 0.3s ease;\n}\n.hb-xd2 *, .hb-xd2 *::before, .hb-xd2 *::after { box-sizing: border-box; }\n.hb-xd2[data-disabled=\"true\"] { opacity: 0.45; }\n.hb-xd2-fill {\n  position: absolute;\n  inset: 0 auto 0 0;\n  z-index: -1;\n  width: calc(var(--hb-xd2-x) + var(--hb-xd2-t) + 10px);\n  border-radius: 999px;\n  background: linear-gradient(90deg, color-mix(in srgb, var(--hb-xd2-c) 6%, transparent), color-mix(in srgb, var(--hb-xd2-c) 46%, transparent));\n  box-shadow: inset -12px 0 18px -10px color-mix(in srgb, var(--hb-xd2-c) 80%, transparent);\n}\n.hb-xd2-label {\n  position: absolute;\n  inset: 0;\n  display: grid;\n  place-items: center;\n  padding-left: calc(var(--hb-xd2-t) + 8px);\n  padding-right: 44px;\n  font-weight: 500;\n  letter-spacing: 0.01em;\n  white-space: nowrap;\n  color: transparent;\n  background: linear-gradient(100deg, #6f5a5b 0%, #6f5a5b 40%, #ffe3e4 50%, #6f5a5b 60%, #6f5a5b 100%);\n  background-size: 240% 100%;\n  -webkit-background-clip: text;\n  background-clip: text;\n  clip-path: inset(0 0 0 calc(var(--hb-xd2-x) + var(--hb-xd2-t) * 0.5 + 5px));\n  opacity: calc(1 - var(--hb-xd2-p) * 0.9);\n  animation: hb-xd2-shine 2.6s cubic-bezier(0.45, 0, 0.3, 1) infinite;\n}\n.hb-xd2-bin {\n  position: absolute;\n  top: 50%;\n  right: 15px;\n  width: 22px;\n  height: 22px;\n  margin-top: -11px;\n  color: color-mix(in srgb, var(--hb-xd2-c) 40%, #6f5a5b);\n  transform: scale(calc(1 + var(--hb-xd2-p) * 0.18));\n  transition: color 0.2s ease;\n}\n.hb-xd2[data-near=\"true\"] .hb-xd2-bin { color: color-mix(in srgb, var(--hb-xd2-c) 70%, #fff); }\n.hb-xd2-lid {\n  transform-box: fill-box;\n  transform-origin: 85% 100%;\n  transform: rotate(calc(var(--hb-xd2-p) * -38deg)) translateY(calc(var(--hb-xd2-p) * -1px));\n}\n.hb-xd2-thumb {\n  position: relative;\n  z-index: 2;\n  display: grid;\n  place-items: center;\n  width: var(--hb-xd2-t);\n  height: var(--hb-xd2-t);\n  margin: 0;\n  padding: 0;\n  color: #fff;\n  border: 0;\n  border-radius: 999px;\n  background:\n    radial-gradient(120% 90% at 30% 20%, rgba(255,255,255,0.35), rgba(255,255,255,0) 50%),\n    linear-gradient(180deg, color-mix(in srgb, var(--hb-xd2-c) 88%, #fff), color-mix(in srgb, var(--hb-xd2-c) 85%, #000));\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 4px 12px -2px color-mix(in srgb, var(--hb-xd2-c) 70%, transparent), 0 1px 2px rgba(0,0,0,0.6);\n  transform: translateX(var(--hb-xd2-x));\n  cursor: grab;\n  touch-action: none;\n  transition: transform 0.55s cubic-bezier(0.25, 1.4, 0.4, 1), opacity 0.3s ease, scale 0.3s ease;\n}\n.hb-xd2[data-drag=\"true\"] .hb-xd2-thumb { cursor: grabbing; transition: none; }\n.hb-xd2-thumb:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }\n.hb-xd2-chev { display: flex; }\n.hb-xd2-chev svg:last-child { margin-left: -7px; opacity: 0.55; }\n.hb-xd2[data-phase=\"done\"] .hb-xd2-thumb { scale: 0.2; opacity: 0; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease 0.15s, scale 0.35s ease 0.1s; }\n.hb-xd2-done {\n  position: absolute;\n  inset: 0;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  gap: 0.5em;\n  font-weight: 600;\n  color: #fff;\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-xd2-c) 90%, #fff), var(--hb-xd2-c));\n  border-radius: 999px;\n  opacity: 0;\n  clip-path: inset(0 0 0 100% round 999px);\n  transition: clip-path 0.5s cubic-bezier(0.7, 0, 0.2, 1) 0.15s, opacity 0.2s ease 0.15s;\n}\n.hb-xd2[data-phase=\"done\"] .hb-xd2-done { opacity: 1; clip-path: inset(0 0 0 0 round 999px); }\n.hb-xd2[data-phase=\"done\"] .hb-xd2-bin, .hb-xd2[data-phase=\"done\"] .hb-xd2-label { opacity: 0; }\n.hb-xd2-done svg path { stroke-dasharray: 24; stroke-dashoffset: 24; }\n.hb-xd2[data-phase=\"done\"] .hb-xd2-done svg path { animation: hb-xd2-tick 0.4s ease 0.55s forwards; }\n@keyframes hb-xd2-shine {\n  0% { background-position: 100% 0; }\n  100% { background-position: 0% 0; }\n}\n@keyframes hb-xd2-tick { to { stroke-dashoffset: 0; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xd2-label { animation: none; color: #8a7475; background: none; }\n  .hb-xd2-thumb, .hb-xd2-done, .hb-xd2[data-phase=\"done\"] .hb-xd2-thumb { transition: none; }\n  .hb-xd2-done svg path { stroke-dashoffset: 0; }\n  .hb-xd2[data-phase=\"done\"] .hb-xd2-done svg path { animation: none; }\n}\n`;\n\nexport function ButtonSlideDelete({\n  label = \"Slide to delete\",\n  doneLabel = \"Deleted\",\n  threshold = 0.88,\n  accent = \"#ef4444\",\n  resetAfter = 2600,\n  disabled = false,\n  onConfirm,\n  onProgress,\n  className = \"\",\n  style,\n  ...rest\n}: ButtonSlideDeleteProps) {\n  const trackRef = React.useRef<HTMLDivElement>(null);\n  const thumbRef = React.useRef<HTMLButtonElement>(null);\n  const drag = React.useRef<{ id: number; start: number; from: number } | null>(null);\n  const latest = React.useRef({ onConfirm, onProgress });\n  const [x, setX] = React.useState(0);\n  const [max, setMax] = React.useState(1);\n  const [dragging, setDragging] = React.useState(false);\n  const [phase, setPhase] = React.useState<\"idle\" | \"done\">(\"idle\");\n\n  React.useEffect(() => {\n    latest.current = { onConfirm, onProgress };\n  }, [onConfirm, onProgress]);\n\n  React.useEffect(() => {\n    const el = trackRef.current;\n    const th = thumbRef.current;\n    if (!el || !th) return;\n    const measure = () => setMax(Math.max(1, el.clientWidth - th.offsetWidth - 10));\n    measure();\n    const ro = new ResizeObserver(measure);\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n\n  React.useEffect(() => {\n    if (phase !== \"done\" || resetAfter <= 0) return;\n    const t = window.setTimeout(() => {\n      setX(0);\n      setPhase(\"idle\");\n    }, resetAfter);\n    return () => window.clearTimeout(t);\n  }, [phase, resetAfter]);\n\n  const p = Math.min(1, x / max);\n\n  const update = (next: number) => {\n    const v = Math.max(0, Math.min(max, next));\n    setX(v);\n    latest.current.onProgress?.(v / max);\n  };\n\n  const complete = () => {\n    setX(max);\n    setPhase(\"done\");\n    latest.current.onConfirm?.();\n  };\n\n  const locked = disabled || phase === \"done\";\n\n  return (\n    <div\n      ref={trackRef}\n      className={`hb-xd2 ${className}`.trim()}\n      data-phase={phase}\n      data-drag={dragging}\n      data-near={p >= threshold}\n      data-disabled={disabled}\n      style={{ \"--hb-xd2-c\": accent, \"--hb-xd2-x\": `${x.toFixed(1)}px`, \"--hb-xd2-p\": p.toFixed(3), ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-button-slide-delete\" precedence=\"default\">{css}</style>\n      <span className=\"hb-xd2-fill\" aria-hidden=\"true\" />\n      <span className=\"hb-xd2-label\" aria-hidden=\"true\">{p >= threshold ? \"Release to delete\" : label}</span>\n      <svg className=\"hb-xd2-bin\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.9\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n        <g className=\"hb-xd2-lid\">\n          <path d=\"M3.5 6.5h17\" />\n          <path d=\"M9 6.5V4.5h6v2\" />\n        </g>\n        <path d=\"M5.5 9l1 11h11l1-11\" />\n        <path d=\"M10 12v5M14 12v5\" />\n      </svg>\n      <button\n        ref={thumbRef}\n        type=\"button\"\n        role=\"slider\"\n        className=\"hb-xd2-thumb\"\n        aria-label={label}\n        aria-valuemin={0}\n        aria-valuemax={100}\n        aria-valuenow={Math.round(p * 100)}\n        aria-valuetext={phase === \"done\" ? doneLabel : `${Math.round(p * 100)}%`}\n        aria-disabled={locked || undefined}\n        tabIndex={phase === \"done\" ? -1 : 0}\n        onPointerDown={(e) => {\n          if (locked || e.button !== 0) return;\n          e.currentTarget.setPointerCapture(e.pointerId);\n          drag.current = { id: e.pointerId, start: e.clientX, from: x };\n          setDragging(true);\n        }}\n        onPointerMove={(e) => {\n          const d = drag.current;\n          if (!d || d.id !== e.pointerId) return;\n          update(d.from + e.clientX - d.start);\n        }}\n        onPointerUp={(e) => {\n          const d = drag.current;\n          if (!d || d.id !== e.pointerId) return;\n          drag.current = null;\n          setDragging(false);\n          if (x / max >= threshold) complete();\n          else update(0);\n        }}\n        onPointerCancel={() => {\n          drag.current = null;\n          setDragging(false);\n          update(0);\n        }}\n        onKeyDown={(e) => {\n          if (locked) return;\n          if (e.key === \"ArrowRight\" || e.key === \"ArrowUp\") {\n            e.preventDefault();\n            const next = x + max * 0.1;\n            if (next / max >= 1) complete();\n            else update(next);\n          } else if (e.key === \"ArrowLeft\" || e.key === \"ArrowDown\" || e.key === \"Home\" || e.key === \"Escape\") {\n            e.preventDefault();\n            update(e.key === \"ArrowLeft\" || e.key === \"ArrowDown\" ? x - max * 0.1 : 0);\n          } else if (e.key === \"End\" || e.key === \"Enter\") {\n            e.preventDefault();\n            complete();\n          }\n        }}\n      >\n        <span className=\"hb-xd2-chev\" aria-hidden=\"true\">\n          <svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M9 6l6 6-6 6\" /></svg>\n          <svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\"><path d=\"M9 6l6 6-6 6\" /></svg>\n        </span>\n      </button>\n      <span className=\"hb-xd2-done\" role=\"status\" aria-live=\"polite\">\n        {phase === \"done\" && (\n          <>\n            <svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\" /></svg>\n            {doneLabel}\n          </>\n        )}\n      </span>\n    </div>\n  );\n}\n"
    }
  ]
}