{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "message-composer",
  "type": "registry:item",
  "title": "Message Composer",
  "description": "Writing a message: Enter sends, Shift+Enter adds a line, the box grows with the text, an emoji menu inserts at the caret, and a message being replied to shows above.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "app"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/message-composer.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/message-composer.js",
      "content": "// Generated by zubra from message-composer.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { emit } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"message-composer\";\n\nexport default $define(tag, {\n  props: {\n    \"placeholder\": { attribute: \"placeholder\", default: \"Message\", required: false },\n    \"disabled\": { attribute: \"disabled\", default: false, required: false },\n    \"replyto\": { attribute: \"replyto\", default: null, required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [],\n  events: [\"typing\", \"send\", \"replycancel\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (message-composer) to ([data-zb-slotted=\\\"message-composer\\\"]) {\\n  :scope { display: block; }\\n  .reply { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.75rem; border: 1px solid var(--border, #d9dce3); border-bottom: 0; border-radius: 0.75rem 0.75rem 0 0; background: var(--accent, #f2f4f8); font-size: 0.8125rem; color: var(--muted-foreground, #667085); }\\n  .reply b { color: var(--foreground, #1d2130); }\\n  .reply span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\\n  .reply button { border: 0; background: none; color: inherit; cursor: pointer; font: inherit; }\\n  .box { position: relative; display: flex; align-items: flex-end; gap: 0.25rem; padding: 0.4rem; border: 1px solid var(--border, #d9dce3); border-radius: calc(var(--radius, 0.625rem) * 1.2); background: var(--card, #ffffff); }\\n  .reply + .box { border-radius: 0 0 0.75rem 0.75rem; }\\n  .box:focus-within { border-color: var(--primary, #2563eb); }\\n  textarea { flex: 1; min-height: 2.25rem; max-height: 10rem; padding: 0.45rem 0.5rem; border: 0; outline: 0; resize: none; background: none; color: inherit; font: inherit; line-height: 1.4; }\\n  button.icon, button.send { flex: none; width: 2.25rem; height: 2.25rem; border: 0; border-radius: calc(var(--radius, 0.625rem) * 0.88); background: none; color: var(--muted-foreground, #667085); font-size: 1.15rem; cursor: pointer; }\\n  button.send { background: var(--primary, #2563eb); color: white; font-size: 1rem; }\\n  button.send:disabled { background: var(--border, #d9dce3); color: var(--muted-foreground, #667085); cursor: default; }\\n  .picker { position: absolute; bottom: calc(100% + 0.4rem); right: 0; display: grid; grid-template-columns: repeat(6, 2rem); gap: 0.15rem; padding: 0.4rem; border: 1px solid var(--border, #d9dce3); border-radius: calc(var(--radius, 0.625rem) * 1.2); background: var(--card, #ffffff); box-shadow: 0 8px 24px #0003; }\\n  .picker button { border: 0; background: none; border-radius: calc(var(--radius, 0.625rem) * 0.64); font-size: 1.2rem; cursor: pointer; }\\n  .picker button:hover { background: var(--accent, #f2f4f8); }\\n  .hint { margin: 0.3rem 0.25rem 0; font-size: 0.7rem; color: var(--muted-foreground, #667085); }\\n}\\n}\\n\",\n  template: \"\\n  <!--[--><!--]-->\\n  <div class=\\\"box\\\">\\n    <textarea rows=\\\"1\\\"></textarea>\\n    <button type=\\\"button\\\" class=\\\"icon emoji\\\" aria-label=\\\"Insert emoji\\\">☺</button>\\n    <button type=\\\"button\\\" class=\\\"send\\\" aria-label=\\\"Send\\\">➤</button>\\n    <!--[--><!--]-->\\n  </div>\\n  <p class=\\\"hint\\\">Enter to send · Shift+Enter for a new line</p>\\n\",\n  setup($p, $emit) {\n    const emit = $emit;\nfunction __zubraAssign(signal, value) { signal.set(value); return value }\nfunction __zubraUpdate(signal, delta, prefix) { const old = signal.get(); signal.set(old + delta); return prefix ? old + delta : old }\n                                       \n\n  const EMOJI = [\"😀\", \"😂\", \"😍\", \"🤔\", \"👍\", \"🙏\", \"🎉\", \"🔥\", \"🚀\", \"✅\", \"👀\", \"☕\"]\n  const box = __zubraState(null)\n  const emojiButton = __zubraState(null)\n  // Escape in the picker closes it and puts focus back on its button (the picker's buttons go away).\n  function closePicker() {\n    __zubraAssign(picking, false)\n    emojiButton.get()?.focus()\n  }\n  const text = __zubraState(\"\")\n  const picking = __zubraState(false)\n  const lastTyping = __zubraState(0)\n  const empty = __zubraComputed(() => (text.get().trim() === \"\"))\n\n  function grow() {\n    box.get().style.height = \"auto\"\n    box.get().style.height = `${Math.min(box.get().scrollHeight, 160)}px`\n  }\n  function input(event) {\n    __zubraAssign(text, event.target.value)\n    grow()\n    if (Date.now() - lastTyping.get() > 2000) {\n      __zubraAssign(lastTyping, Date.now())\n      emit('typing')\n    }\n  }\n  function send() {\n    if (empty.get() || $p.disabled) return\n    emit('send', text.get().trim())\n    __zubraAssign(text, \"\")\n    __zubraAssign(lastTyping, 0)\n    queueMicrotask(grow)\n  }\n  function enter(event) {\n    // (While an input method is composing, Enter belongs to it.)\n    if (event.isComposing) return\n    event.preventDefault()\n    send()\n  }\n  function insert(emoji) {\n    const at = box.get().selectionStart ?? text.get().length\n    __zubraAssign(text, text.get().slice(0, at) + emoji + text.get().slice(box.get().selectionEnd ?? at))\n    __zubraAssign(picking, false)\n    queueMicrotask(() => {\n      box.get().focus()\n      box.get().setSelectionRange(at + emoji.length, at + emoji.length)\n    })\n  }\n    return [\n      { path: [0], when: () => $p.replyto, blocks: [{ template: \"<div class=\\\"reply\\\"><span>Replying to <b></b><!----></span><button type=\\\"button\\\" class=\\\"cancel-reply\\\" aria-label=\\\"Cancel reply\\\">×</button></div>\", parts: () => [{ path: [0, 0, 0], text: () => $t($p.replyto?.author) }, { path: [0, 0, 1], anchor: () => \": \" + $t($p.replyto?.text) }, { path: [0, 1], on: \"click\", handler: () => (() => emit('replycancel')) }] }, null] },\n      { path: [1, 0], attribute: \"aria-label\", value: () => $p.placeholder },\n      { path: [1, 0], attribute: \"placeholder\", value: () => $p.placeholder },\n      { path: [1, 0], attribute: \"disabled\", boolean: true, value: () => $p.disabled },\n      { path: [1, 0], attribute: \"value\", value: () => $r(text) },\n      { path: [1, 0], ref: () => (($el) => (__zubraAssign(box, $el))) },\n      { path: [1, 0], on: \"input\", handler: () => $r(input) },\n      { path: [1, 0], on: \"keydown\", handler: () => $r(enter), modifiers: { keys: [\"Enter\"] } },\n      { path: [1, 0], on: \"keydown\", handler: () => (() => $p.replyto && emit('replycancel')), modifiers: { keys: [\"Escape\"] } },\n      { path: [1, 1], ref: () => (($el) => (__zubraAssign(emojiButton, $el))) },\n      { path: [1, 1], attribute: \"aria-expanded\", value: () => ($r(picking) ? \"true\" : \"false\") },\n      { path: [1, 1], on: \"click\", handler: () => (() => (__zubraAssign(picking, !picking.get()))) },\n      { path: [1, 2], attribute: \"disabled\", boolean: true, value: () => ($r(empty) || $p.disabled) },\n      { path: [1, 2], on: \"click\", handler: () => $r(send) },\n      { path: [1, 3], when: () => $r(picking), blocks: [{ template: \"<div class=\\\"picker\\\" role=\\\"group\\\" aria-label=\\\"Emoji\\\"><!--[--><!--]--></div>\", parts: () => [{ path: [0], on: \"keydown\", handler: () => $r(closePicker), modifiers: { keys: [\"Escape\"] } }, { path: [0, 0], each: () => $r(EMOJI), key: (emoji, $index) => $r(emoji), block: { template: \"<button type=\\\"button\\\"></button>\", parts: (emoji, $index) => [{ path: [0], on: \"click\", handler: () => (() => insert($r(emoji))) }, { path: [0], text: () => $t($r(emoji)) }] } }] }, null] },\n    ];\n  },\n});\n"
    }
  ]
}
