{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "micro-reaction-picker",
  "type": "registry:component",
  "title": "Reaction Picker",
  "description": "Hover or press and hold to open a tray of drawn reactions that magnify like a dock as you slide across them. Release on one to pick it and it pops into the button.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "micro",
    "reaction",
    "emoji",
    "picker",
    "press and hold",
    "social",
    "micro"
  ],
  "docs": "https://hyperblur.dev/effects/micro-reaction-picker",
  "files": [
    {
      "path": "registry/hyperblur/micro-reaction-picker.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/micro-reaction-picker.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface MicroReaction {\n  id: string;\n  label: string;\n  icon?: React.ReactNode;\n  color?: string;\n}\n\nexport interface MicroReactionPickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\" | \"children\" | \"defaultValue\"> {\n  reactions?: MicroReaction[];\n  value?: string | null;\n  defaultValue?: string | null;\n  count?: number;\n  idle?: boolean;\n  accent?: string;\n  onChange?: (id: string | null) => void;\n}\n\nfunction Face({ mouth, brows, tear, from, to }: { mouth: React.ReactNode; brows?: React.ReactNode; tear?: boolean; from: string; to: string }) {\n  const id = React.useId().replace(/:/g, \"\");\n  return (\n    <svg viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n      <defs>\n        <radialGradient id={`g${id}`} cx=\"40%\" cy=\"30%\" r=\"75%\">\n          <stop offset=\"0\" stopColor={from} />\n          <stop offset=\"1\" stopColor={to} />\n        </radialGradient>\n      </defs>\n      <circle cx=\"16\" cy=\"16\" r=\"14\" fill={`url(#g${id})`} />\n      {brows}\n      {mouth}\n      {tear ? <path d=\"M22.5 17.5c1.6 2.4 1.9 3.6 1.2 4.6a1.6 1.6 0 0 1-2.6 0c-.6-1 .1-2.3 1.4-4.6z\" fill=\"#7cc4ff\" /> : null}\n    </svg>\n  );\n}\n\nexport const defaultReactions: MicroReaction[] = [\n  {\n    id: \"like\",\n    label: \"Like\",\n    color: \"#2f7bff\",\n    icon: (\n      <svg viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n        <circle cx=\"16\" cy=\"16\" r=\"14\" fill=\"#2f7bff\" />\n        <path d=\"M10 15h3v8h-3zM14.5 15.2l3.2-5.4c.9-1.4 2.8-.6 2.5 1l-.6 3.2h3.6c1.2 0 2 1.1 1.7 2.2l-1.4 5.2c-.3 1-1.1 1.6-2.1 1.6h-6.9z\" fill=\"#fff\" />\n      </svg>\n    ),\n  },\n  {\n    id: \"love\",\n    label: \"Love\",\n    color: \"#ff4d6d\",\n    icon: (\n      <svg viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n        <circle cx=\"16\" cy=\"16\" r=\"14\" fill=\"#ff4d6d\" />\n        <path d=\"M16 23.2s-6.6-3.9-6.6-8.4c0-2.2 1.6-3.8 3.6-3.8 1.3 0 2.4.7 3 1.8.6-1.1 1.7-1.8 3-1.8 2 0 3.6 1.6 3.6 3.8 0 4.5-6.6 8.4-6.6 8.4z\" fill=\"#fff\" />\n      </svg>\n    ),\n  },\n  {\n    id: \"haha\",\n    label: \"Haha\",\n    color: \"#ffb020\",\n    icon: (\n      <Face\n        from=\"#ffe27a\"\n        to=\"#ffb020\"\n        brows={<path d=\"M9.5 12.5l3 1.5-3 1.5M22.5 12.5l-3 1.5 3 1.5\" fill=\"none\" stroke=\"#5a3a00\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />}\n        mouth={<path d=\"M9.5 18.5h13a6.5 6.5 0 0 1-13 0z\" fill=\"#5a3a00\" />}\n      />\n    ),\n  },\n  {\n    id: \"wow\",\n    label: \"Wow\",\n    color: \"#ffb020\",\n    icon: (\n      <Face\n        from=\"#ffe27a\"\n        to=\"#ffb020\"\n        brows={\n          <>\n            <circle cx=\"11.5\" cy=\"13.5\" r=\"1.7\" fill=\"#5a3a00\" />\n            <circle cx=\"20.5\" cy=\"13.5\" r=\"1.7\" fill=\"#5a3a00\" />\n            <path d=\"M9 9.8l3-1M23 9.8l-3-1\" stroke=\"#5a3a00\" strokeWidth=\"1.4\" strokeLinecap=\"round\" />\n          </>\n        }\n        mouth={<ellipse cx=\"16\" cy=\"21\" rx=\"3\" ry=\"3.8\" fill=\"#5a3a00\" />}\n      />\n    ),\n  },\n  {\n    id: \"sad\",\n    label: \"Sad\",\n    color: \"#ffb020\",\n    icon: (\n      <Face\n        from=\"#ffe27a\"\n        to=\"#f2a01a\"\n        tear\n        brows={\n          <>\n            <circle cx=\"11.5\" cy=\"14.5\" r=\"1.6\" fill=\"#5a3a00\" />\n            <circle cx=\"20.5\" cy=\"14.5\" r=\"1.6\" fill=\"#5a3a00\" />\n            <path d=\"M9 11.5l3.4-1.4M23 11.5l-3.4-1.4\" stroke=\"#5a3a00\" strokeWidth=\"1.4\" strokeLinecap=\"round\" />\n          </>\n        }\n        mouth={<path d=\"M12 22.5c2.4-2.2 5.6-2.2 8 0\" fill=\"none\" stroke=\"#5a3a00\" strokeWidth=\"1.8\" strokeLinecap=\"round\" />}\n      />\n    ),\n  },\n  {\n    id: \"fire\",\n    label: \"Fire\",\n    color: \"#ff6a2b\",\n    icon: (\n      <svg viewBox=\"0 0 32 32\" aria-hidden=\"true\">\n        <circle cx=\"16\" cy=\"16\" r=\"14\" fill=\"#2a1408\" />\n        <path d=\"M16 5.5c1 3.6 6.5 6.4 6.5 12a6.5 6.5 0 0 1-13 0c0-2.8 1.6-4.4 2.8-5.6.2 1.8.9 2.9 1.9 3.4-.2-3.6.6-6.6 1.8-9.8z\" fill=\"#ff6a2b\" />\n        <path d=\"M16 14.5c.6 2 3.2 3.2 3.2 5.8a3.2 3.2 0 0 1-6.4 0c0-1.6 1-2.6 1.7-3.2.2 1 .6 1.4 1 1.6-.1-1.6.1-2.9.5-4.2z\" fill=\"#ffd24a\" />\n      </svg>\n    ),\n  },\n];\n\nconst css = `\n.hb-wf5 {\n  --hb-wf5-c: #2f7bff;\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  gap: 10px;\n  box-sizing: border-box;\n  font-family: inherit;\n  color: #ededed;\n}\n.hb-wf5 *, .hb-wf5 *::before, .hb-wf5 *::after { box-sizing: border-box; }\n.hb-wf5-tr {\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  height: 34px;\n  padding: 0 13px 0 9px;\n  margin: 0;\n  border: 1px solid #2a2a2a;\n  border-radius: 999px;\n  background: linear-gradient(180deg, #1c1c1c, #151515);\n  color: #bdbdbd;\n  font: inherit;\n  font-size: 13px;\n  font-weight: 500;\n  cursor: pointer;\n  touch-action: none;\n  -webkit-tap-highlight-color: transparent;\n  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);\n}\n.hb-wf5-tr:hover { border-color: #3a3a3a; color: #fff; }\n.hb-wf5-tr:active { transform: scale(0.95); }\n.hb-wf5-tr:focus-visible { outline: 2px solid var(--hb-wf5-c); outline-offset: 3px; }\n.hb-wf5-tr[data-set=\"true\"] { color: var(--hb-wf5-rc); border-color: color-mix(in srgb, var(--hb-wf5-rc) 40%, #2a2a2a); background: color-mix(in srgb, var(--hb-wf5-rc) 10%, #151515); }\n.hb-wf5-ti { display: grid; place-items: center; width: 20px; height: 20px; }\n.hb-wf5-ti svg { width: 100%; height: 100%; display: block; }\n.hb-wf5-ti[data-pop=\"true\"] { animation: hb-wf5-pop 0.55s cubic-bezier(0.2, 1.8, 0.4, 1); }\n@keyframes hb-wf5-pop { 0% { transform: scale(0.2) rotate(-25deg); } 60% { transform: scale(1.35) rotate(8deg); } 100% { transform: none; } }\n.hb-wf5-ct { font-family: var(--font-mono), ui-monospace, monospace; font-size: 11.5px; color: #8a8a8a; font-variant-numeric: tabular-nums; }\n.hb-wf5-tray {\n  position: absolute;\n  left: -4px;\n  bottom: calc(100% + 10px);\n  display: flex;\n  align-items: flex-end;\n  gap: 4px;\n  height: 48px;\n  padding: 6px;\n  border-radius: 999px;\n  background: linear-gradient(180deg, #1f1f1f, #161616);\n  border: 1px solid #2c2c2c;\n  box-shadow: 0 16px 34px -10px rgba(0,0,0,0.9), inset 0 1px 0 rgba(255,255,255,0.06);\n  transform-origin: 24px 100%;\n  transform: translateY(8px) scale(0.6);\n  opacity: 0;\n  pointer-events: none;\n  transition: transform 0.32s cubic-bezier(0.3, 1.5, 0.5, 1), opacity 0.18s ease;\n  z-index: 5;\n}\n.hb-wf5[data-open=\"true\"] .hb-wf5-tray { transform: none; opacity: 1; pointer-events: auto; }\n.hb-wf5-it {\n  position: relative;\n  flex: none;\n  width: 36px;\n  height: 36px;\n  padding: 0;\n  margin: 0;\n  border: 0;\n  background: none;\n  cursor: pointer;\n  transform-origin: 50% 100%;\n  transition: transform 0.18s cubic-bezier(0.3, 1.4, 0.5, 1);\n  opacity: 0;\n}\n.hb-wf5[data-open=\"true\"] .hb-wf5-it { animation: hb-wf5-in 0.42s cubic-bezier(0.2, 1.6, 0.4, 1) both; animation-delay: calc(var(--hb-wf5-i) * 35ms); }\n@keyframes hb-wf5-in { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }\n.hb-wf5-it svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 3px 4px rgba(0,0,0,0.45)); }\n.hb-wf5-it:focus-visible { outline: 2px solid var(--hb-wf5-c); outline-offset: 2px; border-radius: 50%; }\n.hb-wf5-lb {\n  position: absolute;\n  left: 50%;\n  bottom: calc(100% + 6px);\n  padding: 3px 7px;\n  border-radius: 6px;\n  background: rgba(10,10,10,0.92);\n  border: 1px solid #2c2c2c;\n  font-size: 10px;\n  font-weight: 600;\n  color: #fff;\n  white-space: nowrap;\n  transform: translateX(-50%) scale(0.8);\n  opacity: 0;\n  transition: opacity 0.12s ease, transform 0.18s ease;\n  pointer-events: none;\n}\n.hb-wf5-it[data-hot=\"true\"] .hb-wf5-lb { opacity: 1; transform: translateX(-50%) scale(1); }\n@media (prefers-reduced-motion: reduce) {\n  .hb-wf5-tray, .hb-wf5-it, .hb-wf5-tr, .hb-wf5-lb { transition: none; }\n  .hb-wf5[data-open=\"true\"] .hb-wf5-it { animation: none; opacity: 1; }\n  .hb-wf5-ti[data-pop=\"true\"] { animation: none; }\n}\n`;\n\nconst slot = 40;\n\nexport function MicroReactionPicker({\n  reactions = defaultReactions,\n  value,\n  defaultValue = null,\n  count = 0,\n  idle = false,\n  accent = \"#2f7bff\",\n  onChange,\n  className = \"\",\n  style,\n  onPointerEnter,\n  onPointerLeave,\n  ...rest\n}: MicroReactionPickerProps) {\n  const [inner, setInner] = React.useState<string | null>(defaultValue);\n  const cur = value === undefined ? inner : value;\n  const [open, setOpen] = React.useState(false);\n  const [px, setPx] = React.useState<number | null>(null);\n  const [focusIdx, setFocusIdx] = React.useState(-1);\n  const [pop, setPop] = React.useState(0);\n  const [awake, setAwake] = React.useState(false);\n  const trayRef = React.useRef<HTMLDivElement>(null);\n  const itemRefs = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const timers = React.useRef({ open: 0, close: 0, hold: false, held: false });\n\n  const active = reactions.find((r) => r.id === cur) ?? null;\n\n  const pick = (id: string | null) => {\n    if (value === undefined) setInner(id);\n    onChange?.(id);\n    setOpen(false);\n    setPx(null);\n    setFocusIdx(-1);\n    if (id) setPop((n) => n + 1);\n  };\n\n  React.useEffect(() => {\n    if (!idle || awake) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    let t = 0;\n    const id = window.setInterval(() => {\n      t += 1;\n      const phase = t % 90;\n      if (phase === 10) setOpen(true);\n      if (phase > 18 && phase < 62) {\n        const k = (phase - 18) / 44;\n        setPx(6 + 18 + (reactions.length - 1) * slot * (0.5 - 0.5 * Math.cos(k * Math.PI)));\n      }\n      if (phase === 66) {\n        setPx(null);\n        setOpen(false);\n      }\n    }, 50);\n    return () => window.clearInterval(id);\n  }, [idle, awake, reactions.length]);\n\n  const wake = () => {\n    if (!awake) {\n      setAwake(true);\n      setOpen(false);\n      setPx(null);\n    }\n  };\n\n  const hotIndex = (x: number | null) => {\n    if (x === null) return -1;\n    const i = Math.floor((x - 6) / slot);\n    return i >= 0 && i < reactions.length ? i : -1;\n  };\n\n  const relX = (clientX: number) => {\n    const el = trayRef.current;\n    if (!el) return null;\n    const r = el.getBoundingClientRect();\n    return clientX - r.left;\n  };\n\n  const hot = focusIdx >= 0 ? focusIdx : hotIndex(px);\n\n  return (\n    <div\n      className={`hb-wf5 ${className}`}\n      data-open={open}\n      style={{ ...style, [\"--hb-wf5-c\" as string]: accent, [\"--hb-wf5-rc\" as string]: active?.color ?? accent }}\n      onPointerEnter={(e) => {\n        onPointerEnter?.(e);\n        wake();\n        if (e.pointerType !== \"mouse\") return;\n        window.clearTimeout(timers.current.close);\n        timers.current.open = window.setTimeout(() => setOpen(true), 380);\n      }}\n      onPointerLeave={(e) => {\n        onPointerLeave?.(e);\n        window.clearTimeout(timers.current.open);\n        if (timers.current.hold) return;\n        timers.current.close = window.setTimeout(() => {\n          setOpen(false);\n          setPx(null);\n        }, 260);\n      }}\n      onKeyDown={(e) => {\n        if (!open) return;\n        if (e.key === \"Escape\") {\n          e.preventDefault();\n          setOpen(false);\n          setFocusIdx(-1);\n        }\n      }}\n      {...rest}\n    >\n      <style href=\"hb-micro-reaction-picker\" precedence=\"default\">\n        {css}\n      </style>\n      <div ref={trayRef} className=\"hb-wf5-tray\" role=\"menu\" aria-label=\"Reactions\" onPointerMove={(e) => setPx(relX(e.clientX))} onPointerLeave={() => setPx(null)}>\n        {reactions.map((r, i) => {\n          const center = 6 + i * slot + 18;\n          const d = px === null ? 999 : Math.abs(px - center);\n          const s = focusIdx >= 0 ? (i === focusIdx ? 1.45 : 1) : 1 + 0.55 * Math.max(0, 1 - d / 62);\n          return (\n            <button\n              key={r.id}\n              ref={(el) => {\n                itemRefs.current[i] = el;\n              }}\n              type=\"button\"\n              role=\"menuitemradio\"\n              aria-checked={cur === r.id}\n              aria-label={r.label}\n              tabIndex={open ? 0 : -1}\n              className=\"hb-wf5-it\"\n              data-hot={hot === i}\n              style={{ [\"--hb-wf5-i\" as string]: i, transform: `translateY(${(-(s - 1) * 14).toFixed(2)}px) scale(${s.toFixed(3)})` }}\n              onClick={() => pick(cur === r.id ? null : r.id)}\n              onFocus={() => setFocusIdx(i)}\n              onBlur={() => setFocusIdx(-1)}\n              onKeyDown={(e) => {\n                if (e.key === \"ArrowRight\" || e.key === \"ArrowLeft\") {\n                  e.preventDefault();\n                  const n = (i + (e.key === \"ArrowRight\" ? 1 : -1) + reactions.length) % reactions.length;\n                  itemRefs.current[n]?.focus();\n                }\n              }}\n            >\n              {r.icon}\n              <span className=\"hb-wf5-lb\">{r.label}</span>\n            </button>\n          );\n        })}\n      </div>\n      <button\n        type=\"button\"\n        className=\"hb-wf5-tr\"\n        data-set={!!active}\n        aria-haspopup=\"menu\"\n        aria-expanded={open}\n        onPointerDown={(e) => {\n          wake();\n          if (e.pointerType === \"mouse\") return;\n          e.currentTarget.setPointerCapture(e.pointerId);\n          timers.current.hold = true;\n          timers.current.held = false;\n          timers.current.open = window.setTimeout(() => {\n            timers.current.held = true;\n            setOpen(true);\n          }, 320);\n        }}\n        onPointerMove={(e) => {\n          if (timers.current.hold && timers.current.held) setPx(relX(e.clientX));\n        }}\n        onPointerUp={(e) => {\n          if (!timers.current.hold) return;\n          timers.current.hold = false;\n          window.clearTimeout(timers.current.open);\n          if (timers.current.held) {\n            e.preventDefault();\n            const i = hotIndex(px);\n            if (i >= 0) pick(reactions[i].id);\n            else {\n              setOpen(false);\n              setPx(null);\n            }\n          }\n        }}\n        onClick={(e) => {\n          if (timers.current.held) {\n            timers.current.held = false;\n            e.preventDefault();\n            return;\n          }\n          pick(cur ? null : reactions[0].id);\n        }}\n        onKeyDown={(e) => {\n          if (e.key === \"ArrowUp\") {\n            e.preventDefault();\n            wake();\n            setOpen(true);\n            window.setTimeout(() => itemRefs.current[0]?.focus(), 30);\n          }\n        }}\n      >\n        <span key={pop} className=\"hb-wf5-ti\" data-pop={pop > 0}>\n          {active ? (\n            active.icon\n          ) : (\n            <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <circle cx=\"10\" cy=\"10\" r=\"7.5\" />\n              <path d=\"M7 12c1.6 1.7 4.4 1.7 6 0\" />\n              <circle cx=\"7.5\" cy=\"8.2\" r=\"0.6\" fill=\"currentColor\" />\n              <circle cx=\"12.5\" cy=\"8.2\" r=\"0.6\" fill=\"currentColor\" />\n            </svg>\n          )}\n        </span>\n        {active ? active.label : \"React\"}\n        {count > 0 ? <span className=\"hb-wf5-ct\">{count + (active ? 1 : 0)}</span> : null}\n      </button>\n    </div>\n  );\n}\n"
    }
  ]
}