{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "form-feedback",
  "type": "registry:component",
  "title": "Feedback Widget",
  "description": "A launcher pill that opens a feedback panel with a face whose mouth and brows morph across a five step mood scale. Category, note and page URL go out in one tap.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "forms",
    "form",
    "feedback",
    "widget",
    "rating",
    "emoji",
    "launcher"
  ],
  "docs": "https://hyperblur.dev/effects/form-feedback",
  "files": [
    {
      "path": "registry/hyperblur/form-feedback.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/form-feedback.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface FormFeedbackValues {\n  rating: number;\n  category: string;\n  message: string;\n  page?: string;\n}\n\nexport interface FormFeedbackProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onSubmit\" | \"title\"> {\n  title?: string;\n  categories?: string[];\n  page?: string;\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  floating?: boolean;\n  defaultRating?: number;\n  accent?: string;\n  delay?: number;\n  onSubmit?: (values: FormFeedbackValues) => void | Promise<void>;\n}\n\nconst moods = [\"Frustrated\", \"Not great\", \"Okay\", \"Good\", \"Love it\"];\nconst hues = [\"#f0525f\", \"#f5864a\", \"#f5c542\", \"#9be15d\", \"#3ddc84\"];\n\nconst css = `\n.hb-xh7 {\n  --hb-xh7-a: #3ddc84;\n  box-sizing: border-box;\n  font-family: inherit;\n  color: #ededed;\n  display: flex;\n  flex-direction: column;\n  align-items: flex-end;\n  gap: 10px;\n  width: 100%;\n  max-width: 340px;\n  margin-left: auto;\n}\n.hb-xh7 *, .hb-xh7 *::before, .hb-xh7 *::after { box-sizing: border-box; }\n.hb-xh7[data-floating=\"true\"] { position: fixed; right: 20px; bottom: 20px; z-index: 60; width: calc(100vw - 40px); max-height: calc(100dvh - 40px); }\n.hb-xh7-panel {\n  width: 100%;\n  overflow: hidden;\n  border: 1px solid #2a2a2a;\n  border-radius: 18px;\n  background: linear-gradient(180deg, #161616, #0f0f0f);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 30px 60px -20px rgba(0,0,0,0.9);\n  transform-origin: bottom right;\n  animation: hb-xh7-open 0.42s cubic-bezier(0.22, 1, 0.36, 1);\n}\n.hb-xh7-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 0 16px; }\n.hb-xh7-title { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }\n.hb-xh7-x { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: #8a8a8a; cursor: pointer; transition: background 0.2s ease, color 0.2s ease; }\n.hb-xh7-x:hover { background: #222; color: #fff; }\n.hb-xh7-x:focus-visible { outline: 2px solid var(--hb-xh7-c); }\n.hb-xh7-x svg { width: 14px; height: 14px; }\n.hb-xh7-body { display: grid; gap: 12px; padding: 10px 16px 16px; }\n.hb-xh7-mood { display: flex; align-items: center; gap: 14px; }\n.hb-xh7-face { flex: none; width: 58px; height: 58px; }\n.hb-xh7-face circle.hb-xh7-skin { fill: var(--hb-xh7-c); transition: fill 0.4s ease; }\n.hb-xh7-face .hb-xh7-feat { fill: none; stroke: #121212; stroke-width: 3.2; stroke-linecap: round; transition: d 0.45s cubic-bezier(0.34, 1.4, 0.64, 1); }\n.hb-xh7-face .hb-xh7-eye { fill: #121212; transition: ry 0.35s ease, cy 0.35s ease; }\n.hb-xh7-face .hb-xh7-cheek { fill: #ff7aa2; opacity: var(--hb-xh7-ch); transition: opacity 0.4s ease; }\n.hb-xh7-scale { flex: 1; display: grid; gap: 7px; min-width: 0; }\n.hb-xh7-word { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--hb-xh7-c); transition: color 0.4s ease; }\n.hb-xh7-dots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }\n.hb-xh7-dot { height: 8px; padding: 0; border: 0; border-radius: 999px; background: #262626; cursor: pointer; transition: background 0.3s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }\n.hb-xh7-dot[data-on=\"true\"] { background: var(--hb-xh7-c); }\n.hb-xh7-dot:hover { transform: scaleY(1.5); }\n.hb-xh7-dot:focus-visible { outline: 2px solid var(--hb-xh7-c); outline-offset: 2px; }\n.hb-xh7-cats { display: flex; gap: 6px; }\n.hb-xh7-cat { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; border: 1px solid #272727; border-radius: 9px; background: #121212; color: #a6a6a6; font: inherit; font-size: 12px; cursor: pointer; transition: all 0.2s ease; }\n.hb-xh7-cat:hover { border-color: #383838; color: #e5e5e5; }\n.hb-xh7-cat[aria-checked=\"true\"] { border-color: color-mix(in srgb, var(--hb-xh7-c) 60%, #272727); color: #fff; background: color-mix(in srgb, var(--hb-xh7-c) 10%, #121212); }\n.hb-xh7-cat:focus-visible { outline: 2px solid var(--hb-xh7-c); outline-offset: 1px; }\n.hb-xh7-cat svg { width: 13px; height: 13px; }\n.hb-xh7-area { width: 100%; height: 74px; padding: 9px 11px; border: 1px solid #272727; border-radius: 11px; background: #0b0b0b; color: #ededed; font: inherit; font-size: 13px; line-height: 1.45; resize: none; outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; }\n.hb-xh7-area::placeholder { color: #545454; }\n.hb-xh7-area:focus { border-color: var(--hb-xh7-c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-xh7-c) 18%, transparent); }\n.hb-xh7-area[aria-invalid=\"true\"] { border-color: #f05260; }\n.hb-xh7-err { margin: -6px 0 0; font-size: 11.5px; color: #ff8a95; }\n.hb-xh7-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }\n.hb-xh7-page { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-size: 11.5px; color: #7a7a7a; cursor: pointer; }\n.hb-xh7-page input { width: 14px; height: 14px; margin: 0; accent-color: var(--hb-xh7-c); }\n.hb-xh7-page code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px; color: #a1a1a1; }\n.hb-xh7-send { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border: 0; border-radius: 9px; background: #f2f2f2; color: #0a0a0a; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: transform 0.15s cubic-bezier(0.3, 0.7, 0.4, 1), background 0.2s ease; }\n.hb-xh7-send:hover { background: #fff; }\n.hb-xh7-send:active { transform: scale(0.96); }\n.hb-xh7-send:focus-visible { outline: 2px solid var(--hb-xh7-c); outline-offset: 2px; }\n.hb-xh7-spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(0,0,0,0.2); border-top-color: #0a0a0a; animation: hb-xh7-rot 0.7s linear infinite; }\n.hb-xh7-done { display: grid; justify-items: center; gap: 8px; padding: 8px 18px 22px; text-align: center; }\n.hb-xh7-done .hb-xh7-face { width: 72px; height: 72px; animation: hb-xh7-bounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1); }\n.hb-xh7-done h4 { margin: 4px 0 0; font-size: 15px; font-weight: 600; }\n.hb-xh7-done p { margin: 0; font-size: 12.5px; color: #8f8f8f; line-height: 1.5; }\n.hb-xh7-launch { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px 0 12px; border: 1px solid #2c2c2c; border-radius: 999px; background: linear-gradient(180deg, #1c1c1c, #141414); color: #ededed; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,0.07), 0 10px 24px -10px rgba(0,0,0,0.9); transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease; animation: hb-xh7-open 0.35s cubic-bezier(0.22, 1, 0.36, 1); }\n.hb-xh7-launch:hover { transform: translateY(-2px); border-color: #3a3a3a; }\n.hb-xh7-launch:focus-visible { outline: 2px solid var(--hb-xh7-a); outline-offset: 2px; }\n.hb-xh7-launch svg { width: 20px; height: 20px; }\n@keyframes hb-xh7-open { from { opacity: 0; transform: translateY(10px) scale(0.94); } to { opacity: 1; transform: none; } }\n@keyframes hb-xh7-rot { to { transform: rotate(360deg); } }\n@keyframes hb-xh7-bounce { 0% { transform: scale(0.5) rotate(-20deg); } 100% { transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xh7 *, .hb-xh7 *::before, .hb-xh7 *::after { animation: none !important; transition: none !important; }\n}\n`;\n\nfunction Face({ rating }: { rating: number }) {\n  const t = (rating - 1) / 4;\n  const curve = (-9 + t * 21).toFixed(1);\n  const mouthY = (44 - t * 2).toFixed(1);\n  const mouth = `M19 ${mouthY} Q32 ${(Number(mouthY) + Number(curve)).toFixed(1)} 45 ${mouthY}`;\n  const browTilt = ((1 - t) * 4).toFixed(1);\n  const browL = `M17 ${(21 - Number(browTilt)).toFixed(1)} L26 ${(22 + Number(browTilt) * 0.4).toFixed(1)}`;\n  const browR = `M38 ${(22 + Number(browTilt) * 0.4).toFixed(1)} L47 ${(21 - Number(browTilt)).toFixed(1)}`;\n  const eyeRy = rating === 5 ? 1.6 : 3.4;\n  return (\n    <svg className=\"hb-xh7-face\" viewBox=\"0 0 64 64\" aria-hidden=\"true\" style={{ \"--hb-xh7-ch\": rating >= 4 ? 0.55 : 0 } as React.CSSProperties}>\n      <circle className=\"hb-xh7-skin\" cx=\"32\" cy=\"32\" r=\"30\" />\n      <circle cx=\"32\" cy=\"32\" r=\"30\" fill=\"none\" stroke=\"rgba(255,255,255,0.25)\" strokeWidth=\"1\" />\n      <ellipse className=\"hb-xh7-cheek\" cx=\"15\" cy=\"38\" rx=\"5\" ry=\"3\" />\n      <ellipse className=\"hb-xh7-cheek\" cx=\"49\" cy=\"38\" rx=\"5\" ry=\"3\" />\n      <ellipse className=\"hb-xh7-eye\" cx=\"23\" cy=\"29\" rx=\"3\" ry={eyeRy} />\n      <ellipse className=\"hb-xh7-eye\" cx=\"41\" cy=\"29\" rx=\"3\" ry={eyeRy} />\n      <path className=\"hb-xh7-feat\" d={browL} style={{ d: `path(\"${browL}\")` } as React.CSSProperties} opacity={rating <= 2 ? 1 : 0} />\n      <path className=\"hb-xh7-feat\" d={browR} style={{ d: `path(\"${browR}\")` } as React.CSSProperties} opacity={rating <= 2 ? 1 : 0} />\n      <path className=\"hb-xh7-feat\" d={mouth} style={{ d: `path(\"${mouth}\")` } as React.CSSProperties} />\n    </svg>\n  );\n}\n\nconst catIcons: Record<string, React.ReactNode> = {\n  Bug: <path d=\"M8 5a3 3 0 0 1 3 3v2a3 3 0 0 1-6 0V8a3 3 0 0 1 3-3Zm0 0V3M5 9H2.5M13.5 9H11M5.5 12.5l-2 1.5M10.5 12.5l2 1.5M5.5 6 3.5 4.5M10.5 6l2-1.5\" />,\n  Idea: <path d=\"M6 13h4M6.5 15h3M8 1.5a4.5 4.5 0 0 0-2.6 8.2c.4.3.6.7.6 1.2V11h4v-.1c0-.5.2-.9.6-1.2A4.5 4.5 0 0 0 8 1.5Z\" />,\n  Praise: <path d=\"M8 14s-5.5-3.2-5.5-7A3 3 0 0 1 8 5a3 3 0 0 1 5.5 2c0 3.8-5.5 7-5.5 7Z\" />,\n};\n\nexport function FormFeedback({\n  title = \"Share feedback\",\n  categories = [\"Bug\", \"Idea\", \"Praise\"],\n  page = \"/dashboard/reports\",\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  floating = false,\n  defaultRating = 4,\n  accent = \"#3ddc84\",\n  delay = 800,\n  onSubmit,\n  className,\n  style,\n  ...rest\n}: FormFeedbackProps) {\n  const uid = React.useId();\n  const [inner, setInner] = React.useState(defaultOpen);\n  const isOpen = open ?? inner;\n  const [rating, setRating] = React.useState(Math.min(5, Math.max(1, defaultRating)));\n  const [category, setCategory] = React.useState(categories[1] ?? categories[0] ?? \"\");\n  const [message, setMessage] = React.useState(\"\");\n  const [attach, setAttach] = React.useState(true);\n  const [tried, setTried] = React.useState(false);\n  const [status, setStatus] = React.useState<\"idle\" | \"sending\" | \"sent\">(\"idle\");\n  const launcher = React.useRef<HTMLButtonElement>(null);\n  const area = React.useRef<HTMLTextAreaElement>(null);\n  const timer = React.useRef<number | undefined>(undefined);\n\n  React.useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  const setOpen = (next: boolean) => {\n    if (open === undefined) setInner(next);\n    onOpenChange?.(next);\n    if (!next) window.requestAnimationFrame(() => launcher.current?.focus());\n  };\n\n  const color = hues[rating - 1];\n  const error = message.trim().length < 10 ? \"Add a sentence or two so we can act on it.\" : \"\";\n\n  const submit = async (e: React.FormEvent) => {\n    e.preventDefault();\n    if (status === \"sending\") return;\n    if (error) {\n      setTried(true);\n      area.current?.focus();\n      return;\n    }\n    setStatus(\"sending\");\n    try {\n      await Promise.all([\n        Promise.resolve(onSubmit?.({ rating, category, message: message.trim(), page: attach ? page : undefined })),\n        new Promise((r) => window.setTimeout(r, delay)),\n      ]);\n      setStatus(\"sent\");\n    } catch {\n      setStatus(\"idle\");\n    }\n  };\n\n  const reset = () => {\n    setStatus(\"idle\");\n    setMessage(\"\");\n    setTried(false);\n  };\n\n  return (\n    <div\n      className={[\"hb-xh7\", className].filter(Boolean).join(\" \")}\n      data-floating={floating}\n      style={{ ...style, \"--hb-xh7-a\": accent, \"--hb-xh7-c\": color } as React.CSSProperties}\n      onKeyDown={(e) => { if (e.key === \"Escape\" && isOpen) setOpen(false); }}\n      {...rest}\n    >\n      <style href=\"hb-form-feedback\" precedence=\"default\">{css}</style>\n      {isOpen ? (\n        <div className=\"hb-xh7-panel\" role=\"dialog\" aria-labelledby={`${uid}-t`}>\n          <div className=\"hb-xh7-top\">\n            <h3 className=\"hb-xh7-title\" id={`${uid}-t`}>{title}</h3>\n            <button type=\"button\" className=\"hb-xh7-x\" aria-label=\"Close feedback\" onClick={() => { setOpen(false); if (status === \"sent\") reset(); }}>\n              <svg viewBox=\"0 0 14 14\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" aria-hidden=\"true\"><path d=\"m3 3 8 8M11 3l-8 8\" /></svg>\n            </button>\n          </div>\n          {status === \"sent\" ? (\n            <div className=\"hb-xh7-done\" role=\"status\" style={{ \"--hb-xh7-c\": hues[4] } as React.CSSProperties}>\n              <Face rating={5} />\n              <h4>Thanks, it is on our board.</h4>\n              <p>Your {category.toLowerCase()} note reached the team that owns this page.</p>\n              <button type=\"button\" className=\"hb-xh7-send\" onClick={reset}>Send another</button>\n            </div>\n          ) : (\n            <form className=\"hb-xh7-body\" onSubmit={submit} noValidate>\n              <div className=\"hb-xh7-mood\">\n                <Face rating={rating} />\n                <div className=\"hb-xh7-scale\">\n                  <span className=\"hb-xh7-word\" aria-live=\"polite\">{moods[rating - 1]}</span>\n                  <div className=\"hb-xh7-dots\" role=\"radiogroup\" aria-label=\"How do you feel about this page?\">\n                    {moods.map((m, i) => (\n                      <button\n                        key={m}\n                        type=\"button\"\n                        role=\"radio\"\n                        aria-checked={rating === i + 1}\n                        aria-label={m}\n                        tabIndex={rating === i + 1 ? 0 : -1}\n                        className=\"hb-xh7-dot\"\n                        data-on={i < rating}\n                        onClick={() => setRating(i + 1)}\n                        onKeyDown={(e) => {\n                          const d = e.key === \"ArrowRight\" || e.key === \"ArrowUp\" ? 1 : e.key === \"ArrowLeft\" || e.key === \"ArrowDown\" ? -1 : 0;\n                          if (!d) return;\n                          e.preventDefault();\n                          const next = Math.min(5, Math.max(1, rating + d));\n                          setRating(next);\n                          const group = e.currentTarget.parentElement;\n                          window.requestAnimationFrame(() => (group?.children[next - 1] as HTMLElement | undefined)?.focus());\n                        }}\n                      />\n                    ))}\n                  </div>\n                </div>\n              </div>\n              <div className=\"hb-xh7-cats\" role=\"radiogroup\" aria-label=\"Type of feedback\">\n                {categories.map((c) => (\n                  <button key={c} type=\"button\" role=\"radio\" aria-checked={category === c} className=\"hb-xh7-cat\" onClick={() => setCategory(c)}>\n                    {catIcons[c] ? (\n                      <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">{catIcons[c]}</svg>\n                    ) : null}\n                    {c}\n                  </button>\n                ))}\n              </div>\n              <textarea\n                ref={area}\n                className=\"hb-xh7-area\"\n                aria-label=\"Your feedback\"\n                placeholder={category === \"Bug\" ? \"What happened, and what did you expect?\" : category === \"Praise\" ? \"What made your day?\" : \"What would make this page better?\"}\n                value={message}\n                onChange={(e) => setMessage(e.target.value.slice(0, 1000))}\n                aria-invalid={tried && error ? true : undefined}\n                aria-describedby={tried && error ? `${uid}-e` : undefined}\n              />\n              {tried && error ? <p className=\"hb-xh7-err\" id={`${uid}-e`}>{error}</p> : null}\n              <div className=\"hb-xh7-foot\">\n                <label className=\"hb-xh7-page\">\n                  <input type=\"checkbox\" checked={attach} onChange={(e) => setAttach(e.target.checked)} />\n                  <code>{page}</code>\n                </label>\n                <button type=\"submit\" className=\"hb-xh7-send\" aria-busy={status === \"sending\"}>\n                  {status === \"sending\" ? <span className=\"hb-xh7-spin\" aria-hidden=\"true\" /> : null}\n                  {status === \"sending\" ? \"Sending\" : \"Send\"}\n                </button>\n              </div>\n            </form>\n          )}\n        </div>\n      ) : null}\n      <button ref={launcher} type=\"button\" className=\"hb-xh7-launch\" aria-expanded={isOpen} onClick={() => setOpen(!isOpen)}>\n        <svg viewBox=\"0 0 20 20\" aria-hidden=\"true\">\n          <circle cx=\"10\" cy=\"10\" r=\"9\" fill={color} />\n          <circle cx=\"7\" cy=\"8.5\" r=\"1.2\" fill=\"#121212\" />\n          <circle cx=\"13\" cy=\"8.5\" r=\"1.2\" fill=\"#121212\" />\n          <path d=\"M6.5 12.2q3.5 3 7 0\" fill=\"none\" stroke=\"#121212\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n        </svg>\n        {isOpen ? \"Close\" : \"Feedback\"}\n      </button>\n    </div>\n  );\n}\n"
    }
  ]
}