{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-swipe-dissolve",
  "type": "registry:component",
  "title": "Button Swipe Dissolve",
  "description": "A list row you drag left over a red well whose bin pops once you pass the threshold. On release the row dissolves into drifting particles from right to left, then the space collapses.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "swipe",
    "delete",
    "row",
    "particles",
    "list",
    "gesture"
  ],
  "docs": "https://hyperblur.dev/effects/button-swipe-dissolve",
  "files": [
    {
      "path": "registry/hyperblur/button-swipe-dissolve.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-swipe-dissolve.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonSwipeDissolveProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\" | \"title\"> {\n  title?: string;\n  subtitle?: string;\n  meta?: string;\n  initials?: string;\n  avatarColor?: string;\n  threshold?: number;\n  accent?: string;\n  resetAfter?: number;\n  disabled?: boolean;\n  onDelete?: () => void;\n}\n\nconst css = `\n@property --hb-xd11-m {\n  syntax: \"<percentage>\";\n  inherits: false;\n  initial-value: 112%;\n}\n.hb-xd11 {\n  --hb-xd11-x: 0px;\n  --hb-xd11-p: 0;\n  display: grid;\n  grid-template-rows: 1fr;\n  box-sizing: border-box;\n  width: 100%;\n  font-family: inherit;\n  font-size: 0.8125rem;\n  color: #ededed;\n  transition: grid-template-rows 0.38s cubic-bezier(0.6, 0, 0.2, 1), opacity 0.3s ease;\n}\n.hb-xd11 *, .hb-xd11 *::before, .hb-xd11 *::after { box-sizing: border-box; }\n.hb-xd11[data-phase=\"gone\"] { grid-template-rows: 0fr; opacity: 0; }\n.hb-xd11-clip { position: relative; min-height: 0; overflow: hidden; border-radius: 12px; }\n.hb-xd11-well {\n  position: absolute;\n  inset: 0;\n  display: flex;\n  align-items: center;\n  justify-content: flex-end;\n  gap: 8px;\n  padding-right: 18px;\n  font-weight: 600;\n  color: #fff;\n  border-radius: 12px;\n  background:\n    radial-gradient(80% 140% at 100% 50%, color-mix(in srgb, var(--hb-xd11-c) 85%, #fff 0%), transparent 75%),\n    linear-gradient(90deg, color-mix(in srgb, var(--hb-xd11-c) 10%, #120808), color-mix(in srgb, var(--hb-xd11-c) 70%, #200a0b));\n  opacity: calc(0.25 + var(--hb-xd11-p) * 0.75);\n}\n.hb-xd11[data-phase=\"dissolving\"] .hb-xd11-well { opacity: 0; transition: opacity 0.5s ease 0.2s; }\n.hb-xd11-hint {\n  opacity: 0;\n  transform: translateX(8px);\n  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);\n}\n.hb-xd11[data-past=\"true\"] .hb-xd11-hint { opacity: 1; transform: none; }\n.hb-xd11-bin {\n  width: 20px;\n  height: 20px;\n  transform: scale(calc(0.7 + var(--hb-xd11-p) * 0.4));\n  transition: transform 0.3s cubic-bezier(0.3, 1.8, 0.5, 1);\n}\n.hb-xd11[data-past=\"true\"] .hb-xd11-bin { transform: scale(1.22) rotate(-8deg); }\n.hb-xd11-row {\n  position: relative;\n  display: flex;\n  align-items: center;\n  gap: 11px;\n  padding: 10px 10px 10px 11px;\n  background: linear-gradient(180deg, #171717, #131313);\n  border: 1px solid #242424;\n  border-radius: 12px;\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);\n  transform: translateX(var(--hb-xd11-x));\n  touch-action: pan-y;\n  cursor: grab;\n  outline: none;\n  transition: transform 0.5s cubic-bezier(0.25, 1.35, 0.4, 1), border-color 0.2s ease;\n  -webkit-mask-image: linear-gradient(90deg, #000 calc(var(--hb-xd11-m) - 12%), transparent var(--hb-xd11-m));\n  mask-image: linear-gradient(90deg, #000 calc(var(--hb-xd11-m) - 12%), transparent var(--hb-xd11-m));\n}\n.hb-xd11[data-drag=\"true\"] .hb-xd11-row { cursor: grabbing; transition: border-color 0.2s ease; }\n.hb-xd11-row:focus-visible { border-color: color-mix(in srgb, var(--hb-xd11-c) 60%, #242424); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-xd11-c) 22%, transparent); }\n.hb-xd11[data-phase=\"dissolving\"] .hb-xd11-row { animation: hb-xd11-wipe 0.62s cubic-bezier(0.5, 0, 0.6, 1) forwards; transition: none; }\n.hb-xd11-av {\n  display: grid;\n  place-items: center;\n  flex: none;\n  width: 34px;\n  height: 34px;\n  font-size: 0.75rem;\n  font-weight: 700;\n  color: #fff;\n  border-radius: 999px;\n  background: linear-gradient(135deg, color-mix(in srgb, var(--hb-xd11-av) 85%, #fff), color-mix(in srgb, var(--hb-xd11-av) 75%, #000));\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);\n}\n.hb-xd11-txt { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }\n.hb-xd11-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }\n.hb-xd11-top b { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }\n.hb-xd11-top time { flex: none; font-size: 0.7rem; color: #737373; font-variant-numeric: tabular-nums; }\n.hb-xd11-sub { overflow: hidden; color: #8f8f8f; text-overflow: ellipsis; white-space: nowrap; }\n.hb-xd11-del {\n  display: grid;\n  place-items: center;\n  flex: none;\n  width: 28px;\n  height: 28px;\n  margin: 0;\n  padding: 0;\n  color: #8f8f8f;\n  background: transparent;\n  border: 1px solid transparent;\n  border-radius: 8px;\n  cursor: pointer;\n  opacity: 0;\n  transition: opacity 0.2s ease, color 0.2s ease, background 0.2s ease, border-color 0.2s ease;\n}\n.hb-xd11-row:hover .hb-xd11-del, .hb-xd11-row:focus-within .hb-xd11-del { opacity: 1; }\n.hb-xd11-del:hover { color: #fff; background: color-mix(in srgb, var(--hb-xd11-c) 22%, transparent); border-color: color-mix(in srgb, var(--hb-xd11-c) 40%, transparent); }\n.hb-xd11-del:focus-visible { opacity: 1; outline: 2px solid var(--hb-xd11-c); outline-offset: 1px; }\n.hb-xd11-dust {\n  position: absolute;\n  inset: 0;\n  transform: translateX(var(--hb-xd11-x));\n  pointer-events: none;\n}\n.hb-xd11-dust i {\n  position: absolute;\n  width: var(--hb-xd11-s);\n  height: var(--hb-xd11-s);\n  border-radius: 1px;\n  font-style: normal;\n  background: var(--hb-xd11-k);\n  opacity: 0;\n  animation: hb-xd11-fly 0.75s cubic-bezier(0.2, 0.6, 0.35, 1) var(--hb-xd11-d) forwards;\n}\n.hb-xd11-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@keyframes hb-xd11-wipe {\n  from { --hb-xd11-m: 112%; }\n  to { --hb-xd11-m: 0%; }\n}\n@keyframes hb-xd11-fly {\n  0% { opacity: 0; transform: translate(0, 0) scale(1); }\n  12% { opacity: 1; }\n  100% { opacity: 0; transform: translate(var(--hb-xd11-dx), var(--hb-xd11-dy)) scale(0.2) rotate(var(--hb-xd11-r)); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-xd11, .hb-xd11-row, .hb-xd11-bin, .hb-xd11-hint { transition: none; }\n  .hb-xd11[data-phase=\"dissolving\"] .hb-xd11-row { animation: none; opacity: 0; }\n  .hb-xd11-dust i { animation: none; }\n}\n`;\n\nfunction hash(n: number) {\n  let h = Math.imul(n + 0x9e37, 2654435761);\n  h = Math.imul(h ^ (h >>> 16), 2246822519);\n  h = Math.imul(h ^ (h >>> 13), 3266489917);\n  return (h ^ (h >>> 16)) >>> 0;\n}\n\nexport function ButtonSwipeDissolve({\n  title = \"Priya Raman\",\n  subtitle = \"Re: Q3 vendor contracts, final redlines attached\",\n  meta = \"9:41\",\n  initials = \"PR\",\n  avatarColor = \"#7c5cff\",\n  threshold = 0.42,\n  accent = \"#ef4444\",\n  resetAfter = 2400,\n  disabled = false,\n  onDelete,\n  className = \"\",\n  style,\n  ...rest\n}: ButtonSwipeDissolveProps) {\n  const clipRef = React.useRef<HTMLDivElement>(null);\n  const drag = React.useRef<{ id: number; start: number; startY: number; live: boolean } | null>(null);\n  const latest = React.useRef(onDelete);\n  const [x, setX] = React.useState(0);\n  const [width, setWidth] = React.useState(300);\n  const [dragging, setDragging] = React.useState(false);\n  const [phase, setPhase] = React.useState<\"idle\" | \"dissolving\" | \"gone\">(\"idle\");\n\n  React.useEffect(() => {\n    latest.current = onDelete;\n  }, [onDelete]);\n\n  React.useEffect(() => {\n    const el = clipRef.current;\n    if (!el) return;\n    const measure = () => setWidth(Math.max(120, el.clientWidth));\n    measure();\n    const ro = new ResizeObserver(measure);\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n\n  React.useEffect(() => {\n    if (phase === \"dissolving\") {\n      const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n      const t = window.setTimeout(() => setPhase(\"gone\"), reduce ? 0 : 900);\n      return () => window.clearTimeout(t);\n    }\n    if (phase === \"gone\") {\n      const t1 = window.setTimeout(() => latest.current?.(), 380);\n      const t2 = resetAfter > 0 ? window.setTimeout(() => {\n        setX(0);\n        setPhase(\"idle\");\n      }, resetAfter) : 0;\n      return () => {\n        window.clearTimeout(t1);\n        window.clearTimeout(t2);\n      };\n    }\n  }, [phase, resetAfter]);\n\n  const p = Math.min(1, -x / width);\n  const past = p >= threshold;\n  const locked = disabled || phase !== \"idle\";\n\n  const dissolve = () => {\n    if (locked) return;\n    setPhase(\"dissolving\");\n  };\n\n  const dust = React.useMemo(\n    () =>\n      Array.from({ length: 70 }, (_, i) => {\n        const h = hash(i);\n        const left = (h % 1000) / 10;\n        const top = ((h >>> 10) % 1000) / 10;\n        const tone = (h >>> 20) % 5;\n        return {\n          left: `${left.toFixed(1)}%`,\n          top: `${top.toFixed(1)}%`,\n          s: `${(2 + ((h >>> 3) % 3)).toFixed(0)}px`,\n          d: `${((100 - left) * 5.2).toFixed(0)}ms`,\n          dx: `${(14 + ((h >>> 6) % 46)).toFixed(0)}px`,\n          dy: `${(-6 - ((h >>> 14) % 26)).toFixed(0)}px`,\n          r: `${((h >>> 8) % 180).toFixed(0)}deg`,\n          k: tone === 0 ? \"var(--hb-xd11-c)\" : tone === 1 ? \"#8f8f8f\" : tone === 2 ? \"var(--hb-xd11-av)\" : \"#d4d4d4\",\n        };\n      }),\n    [],\n  );\n\n  return (\n    <div\n      className={`hb-xd11 ${className}`.trim()}\n      data-phase={phase}\n      data-drag={dragging}\n      data-past={past && phase === \"idle\"}\n      style={{ \"--hb-xd11-c\": accent, \"--hb-xd11-av\": avatarColor, \"--hb-xd11-x\": `${x.toFixed(1)}px`, \"--hb-xd11-p\": p.toFixed(3), ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-button-swipe-dissolve\" precedence=\"default\">{css}</style>\n      <div ref={clipRef} className=\"hb-xd11-clip\">\n        <div className=\"hb-xd11-well\" aria-hidden=\"true\">\n          <span className=\"hb-xd11-hint\">Release to delete</span>\n          <svg className=\"hb-xd11-bin\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n            <path d=\"M4 7h16M9 7V4.5h6V7M6 7l1 13h10l1-13M10 11v5M14 11v5\" />\n          </svg>\n        </div>\n        <div\n          className=\"hb-xd11-row\"\n          tabIndex={phase === \"idle\" ? 0 : -1}\n          role=\"group\"\n          aria-roledescription=\"swipeable row\"\n          aria-label={`${title}. ${subtitle}. Swipe left or press Delete to remove.`}\n          aria-keyshortcuts=\"Delete Backspace\"\n          onPointerDown={(e) => {\n            if (locked || e.button !== 0) return;\n            if ((e.target as HTMLElement).closest(\"button\")) return;\n            drag.current = { id: e.pointerId, start: e.clientX, startY: e.clientY, live: false };\n          }}\n          onPointerMove={(e) => {\n            const d = drag.current;\n            if (!d || d.id !== e.pointerId) return;\n            const dx = e.clientX - d.start;\n            if (!d.live) {\n              if (Math.abs(dx) < 6) return;\n              if (Math.abs(e.clientY - d.startY) > Math.abs(dx)) {\n                drag.current = null;\n                return;\n              }\n              d.live = true;\n              e.currentTarget.setPointerCapture(e.pointerId);\n              setDragging(true);\n            }\n            const limit = width * 0.7;\n            const raw = Math.min(0, dx);\n            const next = raw < -limit ? -limit + (raw + limit) * 0.25 : raw > 0 ? raw * 0.2 : raw;\n            setX(next);\n          }}\n          onPointerUp={(e) => {\n            const d = drag.current;\n            drag.current = null;\n            if (!d || d.id !== e.pointerId || !d.live) return;\n            setDragging(false);\n            if (-x / width >= threshold) dissolve();\n            else setX(0);\n          }}\n          onPointerCancel={() => {\n            drag.current = null;\n            setDragging(false);\n            setX(0);\n          }}\n          onKeyDown={(e) => {\n            if (e.target !== e.currentTarget) return;\n            if (e.key === \"Delete\" || e.key === \"Backspace\") {\n              e.preventDefault();\n              dissolve();\n            }\n          }}\n        >\n          <span className=\"hb-xd11-av\" aria-hidden=\"true\">{initials}</span>\n          <span className=\"hb-xd11-txt\">\n            <span className=\"hb-xd11-top\">\n              <b>{title}</b>\n              <time>{meta}</time>\n            </span>\n            <span className=\"hb-xd11-sub\">{subtitle}</span>\n          </span>\n          <button type=\"button\" className=\"hb-xd11-del\" aria-label={`Delete ${title}`} tabIndex={phase === \"idle\" ? 0 : -1} onClick={dissolve}>\n            <svg viewBox=\"0 0 24 24\" width=\"15\" height=\"15\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M4 7h16M9 7V4.5h6V7M6 7l1 13h10l1-13\" />\n            </svg>\n          </button>\n        </div>\n        {phase === \"dissolving\" && (\n          <div className=\"hb-xd11-dust\" aria-hidden=\"true\">\n            {dust.map((q, i) => (\n              <i\n                key={i}\n                style={{ left: q.left, top: q.top, \"--hb-xd11-s\": q.s, \"--hb-xd11-d\": q.d, \"--hb-xd11-dx\": q.dx, \"--hb-xd11-dy\": q.dy, \"--hb-xd11-r\": q.r, \"--hb-xd11-k\": q.k } as React.CSSProperties}\n              />\n            ))}\n          </div>\n        )}\n      </div>\n      <span className=\"hb-xd11-sr\" role=\"status\" aria-live=\"polite\">{phase !== \"idle\" ? `${title} deleted` : \"\"}</span>\n    </div>\n  );\n}\n"
    }
  ]
}