{
  "name": "mention-input",
  "type": "ui:component",
  "title": "MentionInput",
  "description": "Textarea with live @mention trigger popover for tagging teammates or resources.",
  "dependencies": [],
  "registryDependencies": [
    "theme"
  ],
  "files": [
    {
      "path": "src/ui/mention-input.tsx",
      "target": "src/ui/mention-input.tsx",
      "sha256": "69afbbcedce59c175c6ec70cf1eb67603a6805fd710a64d6ec7502eee675237c",
      "content": "import './theme.css';\nimport { scope, type Ctx } from '@fierst/aster';\n\nconst mScope = scope`\n  :scope { position: relative; display: grid; gap: 0.375rem; font-family: var(--aster-font-sans); }\n  .m-label { font-size: 0.84rem; font-weight: 500; color: var(--aster-on-surface); }\n  textarea {\n    width: 100%;\n    min-height: 82px;\n    padding: 0.6rem 0.75rem;\n    border-radius: var(--aster-radius-control);\n    border: 1px solid var(--aster-input-border);\n    background: var(--aster-surface);\n    color: var(--aster-on-surface);\n    box-shadow: var(--aster-shadow-xs);\n    font: inherit;\n    font-size: 0.875rem;\n    resize: vertical;\n    outline: none;\n  }\n  textarea:focus { border-color: var(--aster-primary); box-shadow: var(--aster-focus-ring); }\n  .m-menu {\n    position: absolute;\n    z-index: 45;\n    top: calc(100% + 4px);\n    left: 0;\n    width: min(260px, 100%);\n    padding: 0.3rem;\n    border-radius: var(--aster-radius-md);\n    display: grid;\n    gap: 2px;\n  }\n  .m-opt {\n    width: 100%;\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    padding: 0.42rem 0.6rem;\n    border: none;\n    border-radius: var(--aster-radius-xs);\n    background: transparent;\n    color: var(--aster-on-surface);\n    font: inherit;\n    font-size: 0.84rem;\n    cursor: pointer;\n    text-align: left;\n  }\n  .m-opt:hover { background: var(--aster-surface-muted); }\n  .m-handle { font-family: var(--aster-font-mono); font-size: 0.76rem; color: var(--aster-on-surface-subtle); }\n`;\n\nexport interface MentionCandidate {\n  handle: string;\n  name: string;\n}\n\nlet mSeq = 0;\n\nexport function* MentionInput(\n  props: {\n    label?: string;\n    candidates: readonly MentionCandidate[];\n    value?: string;\n    defaultValue?: string;\n    placeholder?: string;\n    onChange?: (val: string) => void;\n    class?: string;\n  },\n  ctx: Ctx,\n) {\n  const uid = `aster-mention-${++mSeq}`;\n  let internal = props.defaultValue ?? '';\n\n  for (props of ctx) {\n    const isControlled = props.value !== undefined;\n    const current = isControlled ? props.value! : internal;\n    const match = current.match(/(?:^|\\s)@([a-zA-Z0-9_-]*)$/);\n    const query = match ? match[1].toLowerCase() : null;\n    const hits =\n      query !== null\n        ? props.candidates.filter(\n            (c) => c.handle.toLowerCase().includes(query) || c.name.toLowerCase().includes(query),\n          )\n        : [];\n\n    const setVal = (next: string) => {\n      if (!isControlled) internal = next;\n      props.onChange?.(next);\n    };\n\n    const insertMention = (handle: string) => {\n      if (!match) return;\n      const next = current.replace(/@([a-zA-Z0-9_-]*)$/, `@${handle} `);\n      setVal(next);\n    };\n\n    yield (\n      <div class={[mScope, props.class].filter(Boolean).join(' ')}>\n        {props.label ? (\n          <label class=\"m-label\" for={uid}>\n            {props.label}\n          </label>\n        ) : null}\n        <textarea\n          id={uid}\n          value={current}\n          placeholder={props.placeholder ?? 'Type @ to mention a teammate…'}\n          onInput={(e: Event) => setVal((e.target as HTMLTextAreaElement).value)}\n        />\n        {hits.length > 0 ? (\n          <div role=\"group\" aria-label=\"Mention suggestions\" class=\"aster-surface-popover m-menu\">\n            {hits.map((c) => (\n              <button\n                key={c.handle}\n                type=\"button\"\n                class=\"m-opt\"\n                on:mousedown={(e: Event) => e.preventDefault()}\n                onClick={() => {\n                  insertMention(c.handle);\n                  document.getElementById(uid)?.focus();\n                }}\n              >\n                <span>{c.name}</span>\n                <span class=\"m-handle\">@{c.handle}</span>\n              </button>\n            ))}\n          </div>\n        ) : null}\n      </div>\n    );\n  }\n}\n"
    }
  ]
}
