@carbon/ai-chat-components 1.12.0-rc.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/custom-elements.json +7789 -7657
  2. package/es/components/prompt-line/autocomplete/index.d.ts +1 -1
  3. package/es/components/prompt-line/autocomplete/src/autocomplete.d.ts +6 -0
  4. package/es/components/prompt-line/autocomplete/src/autocomplete.js +37 -11
  5. package/es/components/prompt-line/autocomplete/src/autocomplete.js.map +1 -1
  6. package/es/components/prompt-line/src/autocomplete-controller-element.d.ts +16 -0
  7. package/es/components/prompt-line/src/autocomplete-controller-element.js +41 -0
  8. package/es/components/prompt-line/src/autocomplete-controller-element.js.map +1 -1
  9. package/es/components/prompt-line/src/autocomplete-controller.js +13 -0
  10. package/es/components/prompt-line/src/autocomplete-controller.js.map +1 -1
  11. package/es/components/prompt-line/src/send-control.d.ts +7 -0
  12. package/es/components/prompt-line/src/send-control.js +53 -5
  13. package/es/components/prompt-line/src/send-control.js.map +1 -1
  14. package/es/components/prompt-line/src/tiptap/carbon-autocomplete.js +20 -20
  15. package/es/components/prompt-line/src/tiptap/carbon-autocomplete.js.map +1 -1
  16. package/es/components/prompt-line/src/tiptap/carbon-mention.js +1 -1
  17. package/es/components/prompt-line/src/tiptap/carbon-mention.js.map +1 -1
  18. package/es/components/prompt-line/src/tiptap/trigger-utils.d.ts +12 -8
  19. package/es/components/prompt-line/src/tiptap/trigger-utils.js +16 -1
  20. package/es/components/prompt-line/src/tiptap/trigger-utils.js.map +1 -1
  21. package/es/react/hooks/useChatAutocomplete.d.ts +5 -0
  22. package/es/react/hooks/useChatAutocomplete.js +26 -1
  23. package/es/react/hooks/useChatAutocomplete.js.map +1 -1
  24. package/es-custom/components/prompt-line/autocomplete/index.d.ts +1 -1
  25. package/es-custom/components/prompt-line/autocomplete/src/autocomplete.d.ts +6 -0
  26. package/es-custom/components/prompt-line/autocomplete/src/autocomplete.js +37 -11
  27. package/es-custom/components/prompt-line/autocomplete/src/autocomplete.js.map +1 -1
  28. package/es-custom/components/prompt-line/src/autocomplete-controller-element.d.ts +16 -0
  29. package/es-custom/components/prompt-line/src/autocomplete-controller-element.js +41 -0
  30. package/es-custom/components/prompt-line/src/autocomplete-controller-element.js.map +1 -1
  31. package/es-custom/components/prompt-line/src/autocomplete-controller.js +13 -0
  32. package/es-custom/components/prompt-line/src/autocomplete-controller.js.map +1 -1
  33. package/es-custom/components/prompt-line/src/send-control.d.ts +7 -0
  34. package/es-custom/components/prompt-line/src/send-control.js +53 -5
  35. package/es-custom/components/prompt-line/src/send-control.js.map +1 -1
  36. package/es-custom/components/prompt-line/src/tiptap/carbon-autocomplete.js +20 -20
  37. package/es-custom/components/prompt-line/src/tiptap/carbon-autocomplete.js.map +1 -1
  38. package/es-custom/components/prompt-line/src/tiptap/carbon-mention.js +1 -1
  39. package/es-custom/components/prompt-line/src/tiptap/carbon-mention.js.map +1 -1
  40. package/es-custom/components/prompt-line/src/tiptap/trigger-utils.d.ts +12 -8
  41. package/es-custom/components/prompt-line/src/tiptap/trigger-utils.js +16 -1
  42. package/es-custom/components/prompt-line/src/tiptap/trigger-utils.js.map +1 -1
  43. package/es-custom/react/hooks/useChatAutocomplete.d.ts +5 -0
  44. package/es-custom/react/hooks/useChatAutocomplete.js +26 -1
  45. package/es-custom/react/hooks/useChatAutocomplete.js.map +1 -1
  46. package/package.json +2 -2
  47. package/telemetry.yml +3 -0
@@ -41,6 +41,10 @@ import { AutocompleteController, itemsToGroups } from './autocomplete-controller
41
41
  * after a suggestion item is selected. Fired in addition to type-specific callbacks.
42
42
  * @fires cds-custom-aichat-autocomplete-item-send — `{ text: string }` when the
43
43
  * per-item send button is clicked inside the suggestion list.
44
+ * @fires cds-custom-aichat-list-navigated — `{ navigated: boolean }` when the user
45
+ * starts or stops navigating the suggestion list with arrow keys. WC
46
+ * consumers should use this to disable their send control while `navigated`
47
+ * is `true` (the `listNavigated` getter reflects the same state).
44
48
  */
45
49
  let AutocompleteControllerElement = class AutocompleteControllerElement extends LitElement {
46
50
  constructor() {
@@ -48,6 +52,12 @@ let AutocompleteControllerElement = class AutocompleteControllerElement extends
48
52
  /** When true, starter selection inserts text without firing the send event. */
49
53
  this.isSendDisabled = false;
50
54
  this._state = { trigger: null, items: [] };
55
+ /**
56
+ * Tracks whether the user is actively navigating inside the autocomplete
57
+ * list. When `true`, the send button should be disabled so that Enter
58
+ * confirms the highlighted item rather than submitting the prompt.
59
+ */
60
+ this._listNavigated = false;
51
61
  this._controller = null;
52
62
  /**
53
63
  * Ancestor we subscribed `cds-custom-aichat-trigger-change` on. Scoping the
@@ -60,10 +70,27 @@ let AutocompleteControllerElement = class AutocompleteControllerElement extends
60
70
  // Prevent the autocomplete list from stealing focus from the editor.
61
71
  event.preventDefault();
62
72
  };
73
+ this._handleAutocompleteNavigated = (event) => {
74
+ const { navigated } = event.detail;
75
+ if (this._listNavigated === navigated) {
76
+ return;
77
+ }
78
+ this._listNavigated = navigated;
79
+ // Re-fire a composed event so parent elements (e.g. a WC integration shell)
80
+ // can disable their send control while the user navigates the list.
81
+ this.dispatchEvent(new CustomEvent('cds-custom-aichat-list-navigated', { detail: { navigated }, bubbles: true, composed: true }));
82
+ };
63
83
  this._handleTriggerChange = (event) => {
64
84
  this._controller?.handleTriggerChangeEvent(event);
65
85
  };
66
86
  }
87
+ /**
88
+ * Returns `true` while the user is navigating inside the autocomplete list.
89
+ * Consumers can use this to disable their send control.
90
+ */
91
+ get listNavigated() {
92
+ return this._listNavigated;
93
+ }
67
94
  // Render in light DOM so consumers' page-level CSS / portals can reach
68
95
  // any custom list element they've slotted in via renderCustomList.
69
96
  createRenderRoot() {
@@ -72,6 +99,7 @@ let AutocompleteControllerElement = class AutocompleteControllerElement extends
72
99
  connectedCallback() {
73
100
  super.connectedCallback();
74
101
  this.addEventListener('mousedown', this._handleMousedown);
102
+ this.addEventListener('cds-custom-aichat-autocomplete-navigated', this._handleAutocompleteNavigated);
75
103
  this._controller = new AutocompleteController({
76
104
  mention: this.mention,
77
105
  command: this.command,
@@ -98,6 +126,7 @@ let AutocompleteControllerElement = class AutocompleteControllerElement extends
98
126
  }
99
127
  disconnectedCallback() {
100
128
  this.removeEventListener('mousedown', this._handleMousedown);
129
+ this.removeEventListener('cds-custom-aichat-autocomplete-navigated', this._handleAutocompleteNavigated);
101
130
  this._eventSource?.removeEventListener('cds-custom-aichat-trigger-change', this._handleTriggerChange);
102
131
  this._eventSource = null;
103
132
  this._controller?.destroy();
@@ -140,6 +169,15 @@ let AutocompleteControllerElement = class AutocompleteControllerElement extends
140
169
  render() {
141
170
  const { trigger, items, renderCustomList, disableDirectSend } = this._state;
142
171
  if (!trigger || items.length === 0) {
172
+ // List is gone — reset navigation state so the send button is unblocked.
173
+ // This covers cases where the list is removed without an autocomplete
174
+ // dismiss/select/send event (e.g. the user deletes the trigger character).
175
+ if (this._listNavigated) {
176
+ this._listNavigated = false;
177
+ this.dispatchEvent(new CustomEvent('cds-custom-aichat-list-navigated', { detail: { navigated: false }, bubbles: true, composed: true }));
178
+ // Also fire the lower-level event so send-control's shell listener fires.
179
+ this.dispatchEvent(new CustomEvent('cds-custom-aichat-autocomplete-navigated', { detail: { navigated: false }, bubbles: true, composed: true }));
180
+ }
143
181
  return nothing;
144
182
  }
145
183
  if (renderCustomList) {
@@ -212,6 +250,9 @@ __decorate([
212
250
  __decorate([
213
251
  state()
214
252
  ], AutocompleteControllerElement.prototype, "_state", void 0);
253
+ __decorate([
254
+ state()
255
+ ], AutocompleteControllerElement.prototype, "_listNavigated", void 0);
215
256
  AutocompleteControllerElement = __decorate([
216
257
  carbonElement(`${prefix}-autocomplete-controller`)
217
258
  ], AutocompleteControllerElement);
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete-controller-element.js","sources":["../../../../src/components/prompt-line/src/autocomplete-controller-element.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport prefix from '../../../globals/settings.js';\n\nimport '../autocomplete/src/autocomplete.js';\nimport {\n AutocompleteController,\n itemsToGroups,\n type AutocompleteControllerState,\n} from './autocomplete-controller.js';\nimport type {\n AutocompleteConfig,\n StartersConfig,\n SuggestionItem,\n TriggerSuggestionConfig,\n} from './tiptap/types.js';\n\n/**\n * `<cds-custom-aichat-autocomplete-controller>` — drops the autocomplete overlay\n * lifecycle into a `<cds-custom-aichat-prompt-line-shell>`'s `autocomplete-content` slot.\n *\n * Listens for `cds-custom-aichat-trigger-change` events bubbling up from the\n * enclosing prompt-line-shell (the events are `composed: true, bubbles: true`, so\n * they reach here from inside the prompt-line's shadow root). Scoping the\n * listener to the shell — rather than `window` — keeps multiple\n * shell/controller pairs on the same page from cross-talking. Renders the\n * built-in `<cds-custom-aichat-autocomplete>` or the active config's\n * `renderCustomList` output. Selection routes back into the originating\n * prompt-line.\n *\n * @element cds-custom-aichat-autocomplete-controller\n * @fires cds-custom-aichat-starter-selected — `{ text: string }` after a starter is\n * inserted into the editor; consumer triggers send.\n * @fires cds-custom-aichat-autocomplete-item-selected — `{ item: SuggestionItem }`\n * after a suggestion item is selected. Fired in addition to type-specific callbacks.\n * @fires cds-custom-aichat-autocomplete-item-send — `{ text: string }` when the\n * per-item send button is clicked inside the suggestion list.\n */\n@carbonElement(`${prefix}-autocomplete-controller`)\nclass AutocompleteControllerElement extends LitElement {\n /** `@`-style mention trigger config. */\n @property({ attribute: false })\n mention?: TriggerSuggestionConfig;\n\n /** `/`-style command trigger config. */\n @property({ attribute: false })\n command?: TriggerSuggestionConfig;\n\n /** Live-typeahead autocomplete config (no trigger character). */\n @property({ attribute: false })\n autocomplete?: AutocompleteConfig;\n\n /** Starter prompts shown when the editor is empty + focused + editable. */\n @property({ attribute: false })\n starters?: StartersConfig;\n\n /** When true, starter selection inserts text without firing the send event. */\n @property({ type: Boolean, attribute: 'is-send-disabled' })\n isSendDisabled = false;\n\n @state()\n private _state: AutocompleteControllerState = { trigger: null, items: [] };\n\n private _controller: AutocompleteController | null = null;\n /**\n * Ancestor we subscribed `cds-custom-aichat-trigger-change` on. Scoping the\n * listener to the enclosing `<cds-custom-aichat-prompt-line-shell>` (rather than\n * `window`) keeps a second shell/controller pair on the same page from\n * receiving each other's events.\n */\n private _eventSource: EventTarget | null = null;\n\n // Render in light DOM so consumers' page-level CSS / portals can reach\n // any custom list element they've slotted in via renderCustomList.\n protected override createRenderRoot(): this {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('mousedown', this._handleMousedown);\n this._controller = new AutocompleteController({\n mention: this.mention,\n command: this.command,\n autocomplete: this.autocomplete,\n starters: this.starters,\n isSendDisabled: this.isSendDisabled,\n onStarterSelected: (text) => {\n this.dispatchEvent(\n new CustomEvent('cds-custom-aichat-starter-selected', {\n detail: { text },\n bubbles: true,\n composed: true,\n })\n );\n },\n onChange: (next) => {\n this._state = next;\n },\n });\n // Scope to the enclosing prompt-line-shell so multiple shell/controller pairs\n // on the same page don't cross-talk. Falls back to `this` if the\n // controller is used outside a shell — in that case the consumer\n // should make sure their prompt-line bubbles events into this element.\n this._eventSource = this.closest('cds-custom-aichat-prompt-line-shell') ?? this;\n this._eventSource.addEventListener(\n 'cds-custom-aichat-trigger-change',\n this._handleTriggerChange as EventListener\n );\n }\n\n override disconnectedCallback(): void {\n this.removeEventListener('mousedown', this._handleMousedown);\n this._eventSource?.removeEventListener(\n 'cds-custom-aichat-trigger-change',\n this._handleTriggerChange as EventListener\n );\n this._eventSource = null;\n this._controller?.destroy();\n this._controller = null;\n super.disconnectedCallback();\n }\n\n override updated(changed: Map<string, unknown>): void {\n if (!this._controller) {\n return;\n }\n if (\n changed.has('mention') ||\n changed.has('command') ||\n changed.has('autocomplete') ||\n changed.has('starters') ||\n changed.has('isSendDisabled')\n ) {\n this._controller.setConfigs({\n mention: this.mention,\n command: this.command,\n autocomplete: this.autocomplete,\n starters: this.starters,\n isSendDisabled: this.isSendDisabled,\n });\n }\n // Register the currently-rendered list element with the controller so\n // arrow / Enter / Escape on the editor get forwarded into it.\n const listEl =\n this.querySelector<HTMLElement>('cds-custom-aichat-autocomplete') ??\n (this.firstElementChild instanceof HTMLElement\n ? this.firstElementChild\n : null);\n this._controller.setListElement(listEl);\n\n // Pass the editor DOM as anchorElement so the autocomplete's outside-click\n // guard treats clicks on the editor as inside-clicks (not dismissals).\n const editorDom = this._controller.getPromptLine()?.getEditor()?.view\n .dom as Element | undefined;\n const autocompleteEl = this.querySelector<\n HTMLElement & { anchorElement?: Element | null }\n >('cds-custom-aichat-autocomplete');\n if (autocompleteEl) {\n autocompleteEl.anchorElement = editorDom ?? null;\n }\n }\n\n override render() {\n const { trigger, items, renderCustomList, disableDirectSend } = this._state;\n if (!trigger || items.length === 0) {\n return nothing;\n }\n if (renderCustomList) {\n const result = renderCustomList({\n items,\n query: trigger.query,\n onDismiss: () => this._controller?.dismiss(),\n onSelect: (item) => this._selectItem(item),\n onSend: (text) => this._sendItem(text),\n });\n if (result instanceof HTMLElement) {\n return html`${result}`;\n }\n // Custom renderer returned something other than an HTMLElement (e.g.\n // a React node). Surface it on a side-channel event so React adapters\n // can portal it into place themselves.\n this.dispatchEvent(\n new CustomEvent('cds-custom-aichat-custom-list-render', {\n detail: { reactNode: result },\n bubbles: true,\n composed: true,\n })\n );\n return nothing;\n }\n const { items: flatItems, groups } = itemsToGroups(items);\n return html`\n <cds-custom-aichat-autocomplete\n .items=${flatItems}\n .groups=${groups}\n .disableDirectSend=${disableDirectSend}\n @cds-custom-aichat-autocomplete-select=${(\n e: CustomEvent<{ item: SuggestionItem }>\n ) => this._selectItem(e.detail.item)}\n @cds-custom-aichat-autocomplete-send=${(e: CustomEvent<{ text: string }>) =>\n this._sendItem(e.detail.text)}\n @cds-custom-aichat-autocomplete-dismiss=${() => this._controller?.dismiss()}></cds-custom-aichat-autocomplete>\n `;\n }\n\n private _selectItem(item: SuggestionItem): void {\n this._controller?.select(item);\n this.dispatchEvent(\n new CustomEvent('cds-custom-aichat-autocomplete-item-selected', {\n detail: { item },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n private _sendItem(text: string): void {\n if (this.isSendDisabled) {\n return;\n }\n this._controller?.dismiss(true);\n this.dispatchEvent(\n new CustomEvent('cds-custom-aichat-autocomplete-item-send', {\n detail: { text },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n private _handleMousedown = (event: MouseEvent): void => {\n // Prevent the autocomplete list from stealing focus from the editor.\n event.preventDefault();\n };\n\n private _handleTriggerChange = (event: Event): void => {\n this._controller?.handleTriggerChangeEvent(\n event as CustomEvent<\n Parameters<AutocompleteController['handleTriggerChange']>[0]\n >\n );\n };\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-custom-aichat-autocomplete-controller': AutocompleteControllerElement;\n }\n}\n\nexport default AutocompleteControllerElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAqBH;;;;;;;;;;;;;;;;;;;;AAoBG;AAEH,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,UAAU,CAAA;AAAtD,IAAA,WAAA,GAAA;;;QAmBE,IAAA,CAAA,cAAc,GAAG,KAAK;QAGd,IAAA,CAAA,MAAM,GAAgC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;QAElE,IAAA,CAAA,WAAW,GAAkC,IAAI;AACzD;;;;;AAKG;QACK,IAAA,CAAA,YAAY,GAAuB,IAAI;AAiKvC,QAAA,IAAA,CAAA,gBAAgB,GAAG,CAAC,KAAiB,KAAU;;YAErD,KAAK,CAAC,cAAc,EAAE;AACxB,QAAA,CAAC;AAEO,QAAA,IAAA,CAAA,oBAAoB,GAAG,CAAC,KAAY,KAAU;AACpD,YAAA,IAAI,CAAC,WAAW,EAAE,wB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AA,EAAA,6BAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAI1B,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE;AACnC,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,MAAA,CAAA;AAGf,UAAA,CAAA;AADP,IAAA,KAAK;AACqE,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAtBvE,6BAA6B,GAAA,UAAA,CAAA;AADlC,IAAA,aAAa,CAAC,CAAA,EAAG,MAAM,CAAA,wBAAA,CAA0B;AAC5C,CAAA,EAAA,6BAA6B,CA4MlC;AAQD,4CAAe,6BAA6B;;"}
1
+ {"version":3,"file":"autocomplete-controller-element.js","sources":["../../../../src/components/prompt-line/src/autocomplete-controller-element.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport prefix from '../../../globals/settings.js';\n\nimport '../autocomplete/src/autocomplete.js';\nimport type { AutocompleteNavigatedEventDetail } from '../autocomplete/src/autocomplete.js';\nimport {\n AutocompleteController,\n itemsToGroups,\n type AutocompleteControllerState,\n} from './autocomplete-controller.js';\nimport type {\n AutocompleteConfig,\n StartersConfig,\n SuggestionItem,\n TriggerSuggestionConfig,\n} from './tiptap/types.js';\n\n/**\n * `<cds-custom-aichat-autocomplete-controller>` — drops the autocomplete overlay\n * lifecycle into a `<cds-custom-aichat-prompt-line-shell>`'s `autocomplete-content` slot.\n *\n * Listens for `cds-custom-aichat-trigger-change` events bubbling up from the\n * enclosing prompt-line-shell (the events are `composed: true, bubbles: true`, so\n * they reach here from inside the prompt-line's shadow root). Scoping the\n * listener to the shell — rather than `window` — keeps multiple\n * shell/controller pairs on the same page from cross-talking. Renders the\n * built-in `<cds-custom-aichat-autocomplete>` or the active config's\n * `renderCustomList` output. Selection routes back into the originating\n * prompt-line.\n *\n * @element cds-custom-aichat-autocomplete-controller\n * @fires cds-custom-aichat-starter-selected — `{ text: string }` after a starter is\n * inserted into the editor; consumer triggers send.\n * @fires cds-custom-aichat-autocomplete-item-selected — `{ item: SuggestionItem }`\n * after a suggestion item is selected. Fired in addition to type-specific callbacks.\n * @fires cds-custom-aichat-autocomplete-item-send — `{ text: string }` when the\n * per-item send button is clicked inside the suggestion list.\n * @fires cds-custom-aichat-list-navigated — `{ navigated: boolean }` when the user\n * starts or stops navigating the suggestion list with arrow keys. WC\n * consumers should use this to disable their send control while `navigated`\n * is `true` (the `listNavigated` getter reflects the same state).\n */\n@carbonElement(`${prefix}-autocomplete-controller`)\nclass AutocompleteControllerElement extends LitElement {\n /** `@`-style mention trigger config. */\n @property({ attribute: false })\n mention?: TriggerSuggestionConfig;\n\n /** `/`-style command trigger config. */\n @property({ attribute: false })\n command?: TriggerSuggestionConfig;\n\n /** Live-typeahead autocomplete config (no trigger character). */\n @property({ attribute: false })\n autocomplete?: AutocompleteConfig;\n\n /** Starter prompts shown when the editor is empty + focused + editable. */\n @property({ attribute: false })\n starters?: StartersConfig;\n\n /** When true, starter selection inserts text without firing the send event. */\n @property({ type: Boolean, attribute: 'is-send-disabled' })\n isSendDisabled = false;\n\n @state()\n private _state: AutocompleteControllerState = { trigger: null, items: [] };\n\n /**\n * Tracks whether the user is actively navigating inside the autocomplete\n * list. When `true`, the send button should be disabled so that Enter\n * confirms the highlighted item rather than submitting the prompt.\n */\n @state()\n private _listNavigated = false;\n\n /**\n * Returns `true` while the user is navigating inside the autocomplete list.\n * Consumers can use this to disable their send control.\n */\n get listNavigated(): boolean {\n return this._listNavigated;\n }\n\n private _controller: AutocompleteController | null = null;\n /**\n * Ancestor we subscribed `cds-custom-aichat-trigger-change` on. Scoping the\n * listener to the enclosing `<cds-custom-aichat-prompt-line-shell>` (rather than\n * `window`) keeps a second shell/controller pair on the same page from\n * receiving each other's events.\n */\n private _eventSource: EventTarget | null = null;\n\n // Render in light DOM so consumers' page-level CSS / portals can reach\n // any custom list element they've slotted in via renderCustomList.\n protected override createRenderRoot(): this {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('mousedown', this._handleMousedown);\n this.addEventListener(\n 'cds-custom-aichat-autocomplete-navigated',\n this._handleAutocompleteNavigated as EventListener\n );\n this._controller = new AutocompleteController({\n mention: this.mention,\n command: this.command,\n autocomplete: this.autocomplete,\n starters: this.starters,\n isSendDisabled: this.isSendDisabled,\n onStarterSelected: (text) => {\n this.dispatchEvent(\n new CustomEvent('cds-custom-aichat-starter-selected', {\n detail: { text },\n bubbles: true,\n composed: true,\n })\n );\n },\n onChange: (next) => {\n this._state = next;\n },\n });\n // Scope to the enclosing prompt-line-shell so multiple shell/controller pairs\n // on the same page don't cross-talk. Falls back to `this` if the\n // controller is used outside a shell — in that case the consumer\n // should make sure their prompt-line bubbles events into this element.\n this._eventSource = this.closest('cds-custom-aichat-prompt-line-shell') ?? this;\n this._eventSource.addEventListener(\n 'cds-custom-aichat-trigger-change',\n this._handleTriggerChange as EventListener\n );\n }\n\n override disconnectedCallback(): void {\n this.removeEventListener('mousedown', this._handleMousedown);\n this.removeEventListener(\n 'cds-custom-aichat-autocomplete-navigated',\n this._handleAutocompleteNavigated as EventListener\n );\n this._eventSource?.removeEventListener(\n 'cds-custom-aichat-trigger-change',\n this._handleTriggerChange as EventListener\n );\n this._eventSource = null;\n this._controller?.destroy();\n this._controller = null;\n super.disconnectedCallback();\n }\n\n override updated(changed: Map<string, unknown>): void {\n if (!this._controller) {\n return;\n }\n if (\n changed.has('mention') ||\n changed.has('command') ||\n changed.has('autocomplete') ||\n changed.has('starters') ||\n changed.has('isSendDisabled')\n ) {\n this._controller.setConfigs({\n mention: this.mention,\n command: this.command,\n autocomplete: this.autocomplete,\n starters: this.starters,\n isSendDisabled: this.isSendDisabled,\n });\n }\n // Register the currently-rendered list element with the controller so\n // arrow / Enter / Escape on the editor get forwarded into it.\n const listEl =\n this.querySelector<HTMLElement>('cds-custom-aichat-autocomplete') ??\n (this.firstElementChild instanceof HTMLElement\n ? this.firstElementChild\n : null);\n this._controller.setListElement(listEl);\n\n // Pass the editor DOM as anchorElement so the autocomplete's outside-click\n // guard treats clicks on the editor as inside-clicks (not dismissals).\n const editorDom = this._controller.getPromptLine()?.getEditor()?.view\n .dom as Element | undefined;\n const autocompleteEl = this.querySelector<\n HTMLElement & { anchorElement?: Element | null }\n >('cds-custom-aichat-autocomplete');\n if (autocompleteEl) {\n autocompleteEl.anchorElement = editorDom ?? null;\n }\n }\n\n override render() {\n const { trigger, items, renderCustomList, disableDirectSend } = this._state;\n if (!trigger || items.length === 0) {\n // List is gone — reset navigation state so the send button is unblocked.\n // This covers cases where the list is removed without an autocomplete\n // dismiss/select/send event (e.g. the user deletes the trigger character).\n if (this._listNavigated) {\n this._listNavigated = false;\n this.dispatchEvent(\n new CustomEvent<AutocompleteNavigatedEventDetail>(\n 'cds-custom-aichat-list-navigated',\n { detail: { navigated: false }, bubbles: true, composed: true }\n )\n );\n // Also fire the lower-level event so send-control's shell listener fires.\n this.dispatchEvent(\n new CustomEvent<AutocompleteNavigatedEventDetail>(\n 'cds-custom-aichat-autocomplete-navigated',\n { detail: { navigated: false }, bubbles: true, composed: true }\n )\n );\n }\n return nothing;\n }\n if (renderCustomList) {\n const result = renderCustomList({\n items,\n query: trigger.query,\n onDismiss: () => this._controller?.dismiss(),\n onSelect: (item) => this._selectItem(item),\n onSend: (text) => this._sendItem(text),\n });\n if (result instanceof HTMLElement) {\n return html`${result}`;\n }\n // Custom renderer returned something other than an HTMLElement (e.g.\n // a React node). Surface it on a side-channel event so React adapters\n // can portal it into place themselves.\n this.dispatchEvent(\n new CustomEvent('cds-custom-aichat-custom-list-render', {\n detail: { reactNode: result },\n bubbles: true,\n composed: true,\n })\n );\n return nothing;\n }\n const { items: flatItems, groups } = itemsToGroups(items);\n return html`\n <cds-custom-aichat-autocomplete\n .items=${flatItems}\n .groups=${groups}\n .disableDirectSend=${disableDirectSend}\n @cds-custom-aichat-autocomplete-select=${(\n e: CustomEvent<{ item: SuggestionItem }>\n ) => this._selectItem(e.detail.item)}\n @cds-custom-aichat-autocomplete-send=${(e: CustomEvent<{ text: string }>) =>\n this._sendItem(e.detail.text)}\n @cds-custom-aichat-autocomplete-dismiss=${() => this._controller?.dismiss()}></cds-custom-aichat-autocomplete>\n `;\n }\n\n private _selectItem(item: SuggestionItem): void {\n this._controller?.select(item);\n this.dispatchEvent(\n new CustomEvent('cds-custom-aichat-autocomplete-item-selected', {\n detail: { item },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n private _sendItem(text: string): void {\n if (this.isSendDisabled) {\n return;\n }\n this._controller?.dismiss(true);\n this.dispatchEvent(\n new CustomEvent('cds-custom-aichat-autocomplete-item-send', {\n detail: { text },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n private _handleMousedown = (event: MouseEvent): void => {\n // Prevent the autocomplete list from stealing focus from the editor.\n event.preventDefault();\n };\n\n private _handleAutocompleteNavigated = (event: Event): void => {\n const { navigated } = (\n event as CustomEvent<AutocompleteNavigatedEventDetail>\n ).detail;\n if (this._listNavigated === navigated) {\n return;\n }\n this._listNavigated = navigated;\n // Re-fire a composed event so parent elements (e.g. a WC integration shell)\n // can disable their send control while the user navigates the list.\n this.dispatchEvent(\n new CustomEvent<AutocompleteNavigatedEventDetail>(\n 'cds-custom-aichat-list-navigated',\n { detail: { navigated }, bubbles: true, composed: true }\n )\n );\n };\n\n private _handleTriggerChange = (event: Event): void => {\n this._controller?.handleTriggerChangeEvent(\n event as CustomEvent<\n Parameters<AutocompleteController['handleTriggerChange']>[0]\n >\n );\n };\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-custom-aichat-autocomplete-controller': AutocompleteControllerElement;\n }\n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,SAAA,CAAC,CACH;IACH;CAgCD;AAtQC,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AACI,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAIlC,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AACI,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAIlC,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AACI,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAIlC,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AACJ,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAI1B,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE;AACnC,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,MAAA,CAAA;AAGf,UAAA,CAAA;AADP,IAAA,KAAK;AACqE,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAQnE,UAAA,CAAA;AADP,IAAA,KAAK;AACyB,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,MAAA,CAAA;AA9B3B,6BAA6B,GAAA,UAAA,CAAA;AADlC,IAAA,aAAa,CAAC,CAAA,EAAG,MAAM,CAAA,wBAAA,CAA0B;AAC5C,CAAA,EAAA,6BAA6B,CAyQlC;AAQD,4CAAe,6BAA6B;;"}
@@ -36,6 +36,9 @@ import { resetTriggerChangeState } from './tiptap/trigger-utils.js';
36
36
  * import check in [../../../react/__tests__/autocomplete-controller-imports.test.ts]
37
37
  * fails if either comes back.
38
38
  */
39
+ function isNavigableListElement(el) {
40
+ return typeof el.hasNavigated === 'function';
41
+ }
39
42
  class AutocompleteController {
40
43
  constructor(options) {
41
44
  this._trigger = null;
@@ -69,6 +72,7 @@ class AutocompleteController {
69
72
  this._handleEditorKeyDown = (event) => {
70
73
  if (event.key !== 'ArrowUp' &&
71
74
  event.key !== 'ArrowDown' &&
75
+ event.key !== 'Tab' &&
72
76
  event.key !== 'Enter' &&
73
77
  event.key !== 'Escape') {
74
78
  return;
@@ -77,6 +81,15 @@ class AutocompleteController {
77
81
  if (!listEl || !this._trigger) {
78
82
  return;
79
83
  }
84
+ if (event.key === 'Enter') {
85
+ const navigated = isNavigableListElement(listEl)
86
+ ? listEl.hasNavigated()
87
+ : true;
88
+ if (!navigated) {
89
+ this.dismiss();
90
+ return; // let carbonChatEnter send the typed text
91
+ }
92
+ }
80
93
  // Stop Tiptap and the editor from acting on the same key. `capture: true`
81
94
  // (when listening) plus stopPropagation here gets us in ahead of
82
95
  // ProseMirror's own keydown handler.
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete-controller.js","sources":["../../../../src/components/prompt-line/src/autocomplete-controller.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * Framework-agnostic controller for the chat-input autocomplete overlay:\n * trigger-state tracking, async item resolution with stale-result protection,\n * dismissal, and selection routing back through the editor (mention/command\n * chip insertion, plain-text autocomplete, starter insert-and-send).\n *\n * Wrapped by [../../../react/hooks/useChatAutocomplete.tsx] (React hook) and\n * by the `<cds-custom-aichat-autocomplete-controller>` element in\n * [./autocomplete-controller-element.ts] — same logic, two surfaces.\n *\n * This module stays free of `lit` and of custom-element registration. The\n * React hook imports the controller directly, so a Lit import here would hand\n * every React consumer a runtime and an element it never renders. A static\n * import check in [../../../react/__tests__/autocomplete-controller-imports.test.ts]\n * fails if either comes back.\n */\n\nimport { writeStarterStorage } from './tiptap/carbon-starter-trigger.js';\nimport { resolveShowTriggerInChip } from './tiptap/carbon-mention.js';\nimport { stripPresentationFields } from './tiptap/strip-presentation-fields.js';\nimport { resolveConfigItems } from './tiptap/resolve-config-items.js';\nimport { projectRawValue } from './tiptap/json-utils.js';\nimport { resetTriggerChangeState } from './tiptap/trigger-utils.js';\nimport type PromptLineElement from './prompt-line.js';\nimport type {\n AutocompleteConfig,\n BaseSuggestionConfig,\n CustomListProps,\n StartersConfig,\n SuggestionItem,\n SuggestionItemGroup,\n TriggerChangeEventDetail,\n TriggerSuggestionConfig,\n} from './tiptap/types.js';\n\nexport interface AutocompleteControllerOptions {\n mention?: TriggerSuggestionConfig;\n command?: TriggerSuggestionConfig;\n autocomplete?: AutocompleteConfig;\n starters?: StartersConfig;\n /** When true, starter selection inserts text without firing onStarterSelected. */\n isSendDisabled?: boolean;\n /** Called after a starter is selected and inserted; consumer triggers send. */\n onStarterSelected?: (text: string) => void;\n /** Notified whenever the overlay shape (trigger / items) changes. */\n onChange: (state: AutocompleteControllerState) => void;\n}\n\nexport interface AutocompleteControllerState {\n trigger: TriggerChangeEventDetail | null;\n items: SuggestionItem[];\n /** Consumer's `renderCustomList`, if any — resolved from the active trigger. */\n renderCustomList?: (props: CustomListProps) => HTMLElement | unknown;\n /** Forwarded from the active trigger config's `disableDirectSend`. */\n disableDirectSend?: boolean;\n}\n\nexport class AutocompleteController {\n private _mention?: TriggerSuggestionConfig;\n private _command?: TriggerSuggestionConfig;\n private _autocomplete?: AutocompleteConfig;\n private _starters?: StartersConfig;\n private _isSendDisabled: boolean;\n private _onStarterSelected?: (text: string) => void;\n private _onChange: (state: AutocompleteControllerState) => void;\n\n private _trigger: TriggerChangeEventDetail | null = null;\n private _items: SuggestionItem[] = [];\n\n /**\n * Identifies the source prompt-line of the active trigger. Set from the\n * trigger event's target (when feeding via `handleTriggerChangeEvent`) or\n * via `setPromptLine` (e.g. by the React hook, which has a stable ref).\n */\n private _promptLine: PromptLineElement | null = null;\n\n /**\n * The active suggestion-list element. Surface wrappers (React hook, WC\n * element) register this so the controller can forward Arrow/Enter/Escape\n * key events from the prompt-line editor without the user having to Tab\n * to the list.\n */\n private _listElement: HTMLElement | null = null;\n\n /**\n * Editor DOM the key-forwarding handler is currently attached to, or null\n * if not attached. Tracked separately from `_promptLine` so we always\n * detach from the exact node we attached to (the editor view can be\n * recreated underneath us).\n */\n private _editorDomBound: HTMLElement | null = null;\n\n /**\n * Monotonic counter — incremented on every new trigger / dismiss so an\n * in-flight async resolve from an older trigger cannot clobber state.\n */\n private _resolveToken = 0;\n private _destroyed = false;\n\n constructor(options: AutocompleteControllerOptions) {\n this._mention = options.mention;\n this._command = options.command;\n this._autocomplete = options.autocomplete;\n this._starters = options.starters;\n this._isSendDisabled = Boolean(options.isSendDisabled);\n this._onStarterSelected = options.onStarterSelected;\n this._onChange = options.onChange;\n }\n\n // ---------------------------------------------------------------------\n // Config / prompt-line wiring\n // ---------------------------------------------------------------------\n\n /**\n * Update any subset of configs. The active trigger (if any) is re-resolved\n * against the new configs so the visible item list stays current.\n */\n setConfigs(\n next: Partial<\n Pick<\n AutocompleteControllerOptions,\n | 'mention'\n | 'command'\n | 'autocomplete'\n | 'starters'\n | 'isSendDisabled'\n | 'onStarterSelected'\n >\n >\n ): void {\n if ('mention' in next) {\n this._mention = next.mention;\n }\n if ('command' in next) {\n this._command = next.command;\n }\n if ('autocomplete' in next) {\n this._autocomplete = next.autocomplete;\n }\n if ('starters' in next) {\n const prevIsOn = this._starters?.isOn !== false;\n const isOn = next.starters?.isOn !== false;\n this._starters = next.starters;\n // isOn toggled: push the new value into the Tiptap extension storage.\n // onTransaction is gated on editor.isFocused, so re-evaluation happens\n // immediately when the editor is focused, and on the next focus otherwise.\n if (prevIsOn !== isOn) {\n writeStarterStorage(this._promptLine?.getEditor(), { isOn });\n }\n }\n if ('isSendDisabled' in next) {\n this._isSendDisabled = Boolean(next.isSendDisabled);\n }\n if ('onStarterSelected' in next) {\n this._onStarterSelected = next.onStarterSelected;\n }\n if (this._trigger) {\n // Re-resolve items against the new configs.\n this._kickoffResolve(this._trigger);\n }\n }\n\n /** Set or clear the active prompt-line. */\n setPromptLine(promptLine: PromptLineElement | null): void {\n if (this._promptLine === promptLine) {\n return;\n }\n this._promptLine = promptLine;\n // Reconcile the isOn flag into the newly attached prompt-line's storage.\n if (promptLine) {\n writeStarterStorage(promptLine.getEditor(), {\n isOn: this._starters?.isOn !== false,\n });\n }\n // Re-evaluate the key-forwarding handler — the editor DOM we were bound\n // to may now be gone, or a new one may need binding.\n this._refreshEditorKeyHandler();\n }\n\n /** Read the currently associated prompt-line. */\n getPromptLine(): PromptLineElement | null {\n return this._promptLine;\n }\n\n /**\n * Set the active suggestion-list element. When both this and an active\n * trigger are present, ArrowUp/ArrowDown/Enter/Escape on the prompt-line\n * editor are forwarded to the list as synthetic `keydown` events.\n */\n setListElement(el: HTMLElement | null): void {\n if (this._listElement === el) {\n return;\n }\n this._listElement = el;\n this._refreshEditorKeyHandler();\n }\n\n // ---------------------------------------------------------------------\n // Trigger handling\n // ---------------------------------------------------------------------\n\n /**\n * Feed a raw `cds-custom-aichat-trigger-change` event. The event's `target` is the\n * originating prompt-line (since the event is `composed: true, bubbles:\n * true`), so we capture it here for later selection-routing.\n */\n handleTriggerChangeEvent(\n event: CustomEvent<TriggerChangeEventDetail | null>\n ): void {\n const target = findPromptLineFromTarget(event.composedPath());\n if (target) {\n this._promptLine = target;\n }\n this.handleTriggerChange(event.detail ?? null);\n }\n\n /**\n * Feed a trigger-change detail directly. Use this when the caller already\n * has the detail object and a separate way to know which prompt-line it\n * belongs to (e.g. the React hook holds a ref).\n */\n handleTriggerChange(detail: TriggerChangeEventDetail | null): void {\n if (this._destroyed) {\n return;\n }\n this._trigger = detail;\n if (!detail) {\n this._items = [];\n this._resolveToken++;\n this._refreshEditorKeyHandler();\n this._emit();\n return;\n }\n this._kickoffResolve(detail);\n this._refreshEditorKeyHandler();\n }\n\n /**\n * Clear active trigger + items.\n *\n * @param keepCoalesced - When `true`, skip `resetTriggerChangeState` so the\n * trigger-utils coalescing layer stays active. Use this when the dismissal\n * is from a send action where the editor stays empty and focused — without\n * it, the starter trigger would immediately re-fire on the next transaction.\n */\n dismiss(keepCoalesced = false): void {\n if (this._destroyed) {\n return;\n }\n if (!this._trigger && this._items.length === 0) {\n return;\n }\n this._trigger = null;\n this._items = [];\n this._resolveToken++;\n this._refreshEditorKeyHandler();\n this._emit();\n if (!keepCoalesced) {\n const editor = this._promptLine?.getEditor();\n if (editor) {\n resetTriggerChangeState(editor);\n }\n }\n }\n\n // ---------------------------------------------------------------------\n // Selection\n // ---------------------------------------------------------------------\n\n /**\n * Apply a user selection. Routes by trigger type:\n * - starter → insert text + (if not send-disabled) fire onStarterSelected\n * - mention / command → insert chip node at trigger range\n * - autocomplete → insert plain text at trigger range\n */\n select(item: SuggestionItem): void {\n if (this._destroyed) {\n return;\n }\n const trigger = this._trigger;\n const promptLine = this._promptLine;\n const editor = promptLine?.getEditor() ?? null;\n if (!trigger || !editor) {\n this.dismiss();\n return;\n }\n\n if (trigger.type === 'starter') {\n const text = item.value ?? item.label;\n editor.commands.insertContent(text);\n this.dismiss();\n if (!this._isSendDisabled) {\n this._onStarterSelected?.(projectRawValue(editor));\n }\n return;\n }\n\n if (trigger.type === 'mention' || trigger.type === 'command') {\n const config = this._configForTrigger(trigger.type);\n const nodeName = trigger.type;\n const range = {\n from: trigger.triggerOffset,\n to: editor.state.selection.from,\n };\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n {\n type: nodeName,\n attrs: {\n id: item.id,\n label: item.label,\n value: item.value ?? item.label,\n trigger: resolveShowTriggerInChip(\n item,\n config ?? {},\n trigger.type === 'command'\n )\n ? config?.trigger\n : null,\n data: stripPresentationFields(item),\n },\n },\n { type: 'text', text: ' ' },\n ])\n .run();\n config?.onSelect?.(item);\n } else if (trigger.type === 'autocomplete') {\n const text = item.value ?? item.label;\n const range = {\n from: trigger.triggerOffset,\n to: editor.state.selection.from,\n };\n editor\n .chain()\n .focus()\n .insertContentAt(range, [{ type: 'text', text }])\n .run();\n this._autocomplete?.onSelect?.(item);\n }\n\n this.dismiss();\n }\n\n // ---------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------\n\n destroy(): void {\n this._detachEditorKeyHandler();\n this._destroyed = true;\n this._resolveToken++;\n this._trigger = null;\n this._items = [];\n this._promptLine = null;\n this._listElement = null;\n }\n\n // ---------------------------------------------------------------------\n // Editor-DOM key forwarding\n // ---------------------------------------------------------------------\n\n /**\n * When a trigger and a list element are both active, bind a keydown\n * handler to the prompt-line editor DOM so ArrowUp / ArrowDown / Enter /\n * Escape pressed while typing get re-dispatched on the list — same effect\n * as if the list had focus, without taking focus from the editor.\n */\n private _refreshEditorKeyHandler(): void {\n if (this._destroyed) {\n this._detachEditorKeyHandler();\n return;\n }\n const editorDom =\n this._trigger && this._listElement\n ? ((this._promptLine?.getEditor()?.view.dom as HTMLElement) ?? null)\n : null;\n if (editorDom === this._editorDomBound) {\n return;\n }\n this._detachEditorKeyHandler();\n if (editorDom) {\n editorDom.addEventListener('keydown', this._handleEditorKeyDown, true);\n editorDom.addEventListener('focusout', this._handleEditorFocusOut);\n this._editorDomBound = editorDom;\n }\n }\n\n private _detachEditorKeyHandler(): void {\n if (this._editorDomBound) {\n this._editorDomBound.removeEventListener(\n 'keydown',\n this._handleEditorKeyDown,\n true\n );\n this._editorDomBound.removeEventListener(\n 'focusout',\n this._handleEditorFocusOut\n );\n this._editorDomBound = null;\n }\n }\n\n private _handleEditorKeyDown = (event: KeyboardEvent): void => {\n if (\n event.key !== 'ArrowUp' &&\n event.key !== 'ArrowDown' &&\n event.key !== 'Enter' &&\n event.key !== 'Escape'\n ) {\n return;\n }\n const listEl = this._listElement;\n if (!listEl || !this._trigger) {\n return;\n }\n // Stop Tiptap and the editor from acting on the same key. `capture: true`\n // (when listening) plus stopPropagation here gets us in ahead of\n // ProseMirror's own keydown handler.\n event.preventDefault();\n event.stopPropagation();\n listEl.dispatchEvent(\n new KeyboardEvent('keydown', {\n key: event.key,\n bubbles: true,\n cancelable: true,\n })\n );\n };\n\n private _handleEditorFocusOut = (event: FocusEvent): void => {\n const relatedTarget = event.relatedTarget as Node | null;\n // If focus moved into the list element (or inside it), keep the overlay\n // open — the user is interacting with it.\n if (relatedTarget && this._listElement?.contains(relatedTarget)) {\n return;\n }\n this.dismiss();\n };\n\n // ---------------------------------------------------------------------\n // Internals\n // ---------------------------------------------------------------------\n\n private _kickoffResolve(trigger: TriggerChangeEventDetail): void {\n const token = ++this._resolveToken;\n void (async () => {\n const items = await this._resolveItems(trigger);\n if (this._destroyed || this._resolveToken !== token) {\n return;\n }\n this._items = items;\n this._emit();\n })();\n }\n\n /**\n * The config backing a trigger type, or `undefined` for a type no config\n * covers. Single lookup for the class: a new trigger type is one case here,\n * not a hunt through every method that names the types.\n *\n * Callers reach the fields every config shares. The `mention`/`command`\n * overload returns the narrower type, which is what `select()` needs to read\n * `trigger` — a field `BaseSuggestionConfig` does not carry.\n */\n private _configForTrigger(\n type: 'mention' | 'command'\n ): TriggerSuggestionConfig | undefined;\n private _configForTrigger(type: string): BaseSuggestionConfig | undefined;\n private _configForTrigger(type: string): BaseSuggestionConfig | undefined {\n switch (type) {\n case 'starter':\n return this._starters;\n case 'mention':\n return this._mention;\n case 'command':\n return this._command;\n case 'autocomplete':\n return this._autocomplete;\n default:\n return undefined;\n }\n }\n\n private async _resolveItems(\n trigger: TriggerChangeEventDetail\n ): Promise<SuggestionItem[]> {\n // Starters are a fixed list shown on an empty editor, so they skip the\n // query gating and filtering every other trigger runs through.\n if (trigger.type === 'starter') {\n return this._starters?.items ?? [];\n }\n const config = this._configForTrigger(trigger.type);\n if (!config) {\n return [];\n }\n return resolveConfigItems(config, trigger.query);\n }\n\n private _resolveRenderCustomList():\n ((props: CustomListProps) => HTMLElement | unknown) | undefined {\n const trigger = this._trigger;\n if (!trigger) {\n return undefined;\n }\n return this._configForTrigger(trigger.type)?.renderCustomList;\n }\n\n private _resolveDisableDirectSend(): boolean | undefined {\n const trigger = this._trigger;\n\n if (!trigger) {\n return undefined;\n }\n\n // Mention and command always insert a chip rather than send, which is why\n // TriggerSuggestionConfig omits the field rather than defaulting it.\n if (trigger.type === 'mention' || trigger.type === 'command') {\n return true;\n }\n\n return this._configForTrigger(trigger.type)?.disableDirectSend;\n }\n\n private _emit(): void {\n this._onChange({\n trigger: this._trigger,\n items: this._items,\n renderCustomList: this._resolveRenderCustomList(),\n disableDirectSend: this._resolveDisableDirectSend(),\n });\n }\n}\n\n// ---------------------------------------------------------------------------\n// Controller helpers\n// ---------------------------------------------------------------------------\n\n/** Walks an event's composedPath looking for a `cds-custom-aichat-prompt-line`. */\nfunction findPromptLineFromTarget(\n path: EventTarget[]\n): PromptLineElement | null {\n for (const target of path) {\n if (\n target instanceof HTMLElement &&\n target.tagName === 'CDS-AICHAT-PROMPT-LINE'\n ) {\n return target as unknown as PromptLineElement;\n }\n }\n return null;\n}\n\n/**\n * Partition a flat `SuggestionItem[]` into ungrouped items and derived\n * `SuggestionItemGroup[]` for the `<cds-custom-aichat-autocomplete>` element.\n * Items with no `groupId` go into `items`; items with a `groupId` are\n * bucketed into groups preserving first-occurrence order. The group title\n * is taken from the first item in the bucket that carries a `groupTitle`.\n */\nexport function itemsToGroups(flat: SuggestionItem[]): {\n items: SuggestionItem[];\n groups: SuggestionItemGroup[];\n} {\n const items: SuggestionItem[] = [];\n const groupMap = new Map<string, SuggestionItemGroup>();\n const groupOrder: string[] = [];\n\n for (const item of flat) {\n if (!item.groupId) {\n items.push(item);\n continue;\n }\n let group = groupMap.get(item.groupId);\n if (!group) {\n group = {\n id: item.groupId,\n title: item.groupTitle ?? '',\n items: [],\n };\n groupMap.set(item.groupId, group);\n groupOrder.push(item.groupId);\n }\n group.items.push(item);\n }\n\n return {\n items,\n groups: groupOrder\n .map((id) => groupMap.get(id))\n .filter((g): g is SuggestionItemGroup => g !== undefined),\n };\n}\n"],"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AAE;AACL,aAAA,GAAG,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;aAC5B,MAAM,CAAC,CAAC,CAAC,KAA+B,CAAC,KAAK,SAAS,CAAC;KAC5D;AACH;;"}
1
+ {"version":3,"file":"autocomplete-controller.js","sources":["../../../../src/components/prompt-line/src/autocomplete-controller.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * Framework-agnostic controller for the chat-input autocomplete overlay:\n * trigger-state tracking, async item resolution with stale-result protection,\n * dismissal, and selection routing back through the editor (mention/command\n * chip insertion, plain-text autocomplete, starter insert-and-send).\n *\n * Wrapped by [../../../react/hooks/useChatAutocomplete.tsx] (React hook) and\n * by the `<cds-custom-aichat-autocomplete-controller>` element in\n * [./autocomplete-controller-element.ts] — same logic, two surfaces.\n *\n * This module stays free of `lit` and of custom-element registration. The\n * React hook imports the controller directly, so a Lit import here would hand\n * every React consumer a runtime and an element it never renders. A static\n * import check in [../../../react/__tests__/autocomplete-controller-imports.test.ts]\n * fails if either comes back.\n */\n\nimport { writeStarterStorage } from './tiptap/carbon-starter-trigger.js';\nimport { resolveShowTriggerInChip } from './tiptap/carbon-mention.js';\nimport { stripPresentationFields } from './tiptap/strip-presentation-fields.js';\nimport { resolveConfigItems } from './tiptap/resolve-config-items.js';\nimport { projectRawValue } from './tiptap/json-utils.js';\nimport { resetTriggerChangeState } from './tiptap/trigger-utils.js';\nimport type PromptLineElement from './prompt-line.js';\nimport type {\n AutocompleteConfig,\n BaseSuggestionConfig,\n CustomListProps,\n StartersConfig,\n SuggestionItem,\n SuggestionItemGroup,\n TriggerChangeEventDetail,\n TriggerSuggestionConfig,\n} from './tiptap/types.js';\n\nexport interface AutocompleteControllerOptions {\n mention?: TriggerSuggestionConfig;\n command?: TriggerSuggestionConfig;\n autocomplete?: AutocompleteConfig;\n starters?: StartersConfig;\n /** When true, starter selection inserts text without firing onStarterSelected. */\n isSendDisabled?: boolean;\n /** Called after a starter is selected and inserted; consumer triggers send. */\n onStarterSelected?: (text: string) => void;\n /** Notified whenever the overlay shape (trigger / items) changes. */\n onChange: (state: AutocompleteControllerState) => void;\n}\n\nexport interface AutocompleteControllerState {\n trigger: TriggerChangeEventDetail | null;\n items: SuggestionItem[];\n /** Consumer's `renderCustomList`, if any — resolved from the active trigger. */\n renderCustomList?: (props: CustomListProps) => HTMLElement | unknown;\n /** Forwarded from the active trigger config's `disableDirectSend`. */\n disableDirectSend?: boolean;\n}\n\n/** Structural contract for a list element that tracks explicit keyboard navigation. */\ninterface NavigableListElement {\n hasNavigated(): boolean;\n}\n\nfunction isNavigableListElement(\n el: HTMLElement\n): el is HTMLElement & NavigableListElement {\n return typeof (el as any).hasNavigated === 'function';\n}\n\nexport class AutocompleteController {\n private _mention?: TriggerSuggestionConfig;\n private _command?: TriggerSuggestionConfig;\n private _autocomplete?: AutocompleteConfig;\n private _starters?: StartersConfig;\n private _isSendDisabled: boolean;\n private _onStarterSelected?: (text: string) => void;\n private _onChange: (state: AutocompleteControllerState) => void;\n\n private _trigger: TriggerChangeEventDetail | null = null;\n private _items: SuggestionItem[] = [];\n\n /**\n * Identifies the source prompt-line of the active trigger. Set from the\n * trigger event's target (when feeding via `handleTriggerChangeEvent`) or\n * via `setPromptLine` (e.g. by the React hook, which has a stable ref).\n */\n private _promptLine: PromptLineElement | null = null;\n\n /**\n * The active suggestion-list element. Surface wrappers (React hook, WC\n * element) register this so the controller can forward Arrow/Enter/Escape\n * key events from the prompt-line editor without the user having to Tab\n * to the list.\n */\n private _listElement: HTMLElement | null = null;\n\n /**\n * Editor DOM the key-forwarding handler is currently attached to, or null\n * if not attached. Tracked separately from `_promptLine` so we always\n * detach from the exact node we attached to (the editor view can be\n * recreated underneath us).\n */\n private _editorDomBound: HTMLElement | null = null;\n\n /**\n * Monotonic counter — incremented on every new trigger / dismiss so an\n * in-flight async resolve from an older trigger cannot clobber state.\n */\n private _resolveToken = 0;\n private _destroyed = false;\n\n constructor(options: AutocompleteControllerOptions) {\n this._mention = options.mention;\n this._command = options.command;\n this._autocomplete = options.autocomplete;\n this._starters = options.starters;\n this._isSendDisabled = Boolean(options.isSendDisabled);\n this._onStarterSelected = options.onStarterSelected;\n this._onChange = options.onChange;\n }\n\n // ---------------------------------------------------------------------\n // Config / prompt-line wiring\n // ---------------------------------------------------------------------\n\n /**\n * Update any subset of configs. The active trigger (if any) is re-resolved\n * against the new configs so the visible item list stays current.\n */\n setConfigs(\n next: Partial<\n Pick<\n AutocompleteControllerOptions,\n | 'mention'\n | 'command'\n | 'autocomplete'\n | 'starters'\n | 'isSendDisabled'\n | 'onStarterSelected'\n >\n >\n ): void {\n if ('mention' in next) {\n this._mention = next.mention;\n }\n if ('command' in next) {\n this._command = next.command;\n }\n if ('autocomplete' in next) {\n this._autocomplete = next.autocomplete;\n }\n if ('starters' in next) {\n const prevIsOn = this._starters?.isOn !== false;\n const isOn = next.starters?.isOn !== false;\n this._starters = next.starters;\n // isOn toggled: push the new value into the Tiptap extension storage.\n // onTransaction is gated on editor.isFocused, so re-evaluation happens\n // immediately when the editor is focused, and on the next focus otherwise.\n if (prevIsOn !== isOn) {\n writeStarterStorage(this._promptLine?.getEditor(), { isOn });\n }\n }\n if ('isSendDisabled' in next) {\n this._isSendDisabled = Boolean(next.isSendDisabled);\n }\n if ('onStarterSelected' in next) {\n this._onStarterSelected = next.onStarterSelected;\n }\n if (this._trigger) {\n // Re-resolve items against the new configs.\n this._kickoffResolve(this._trigger);\n }\n }\n\n /** Set or clear the active prompt-line. */\n setPromptLine(promptLine: PromptLineElement | null): void {\n if (this._promptLine === promptLine) {\n return;\n }\n this._promptLine = promptLine;\n // Reconcile the isOn flag into the newly attached prompt-line's storage.\n if (promptLine) {\n writeStarterStorage(promptLine.getEditor(), {\n isOn: this._starters?.isOn !== false,\n });\n }\n // Re-evaluate the key-forwarding handler — the editor DOM we were bound\n // to may now be gone, or a new one may need binding.\n this._refreshEditorKeyHandler();\n }\n\n /** Read the currently associated prompt-line. */\n getPromptLine(): PromptLineElement | null {\n return this._promptLine;\n }\n\n /**\n * Set the active suggestion-list element. When both this and an active\n * trigger are present, ArrowUp/ArrowDown/Enter/Escape on the prompt-line\n * editor are forwarded to the list as synthetic `keydown` events.\n */\n setListElement(el: HTMLElement | null): void {\n if (this._listElement === el) {\n return;\n }\n this._listElement = el;\n this._refreshEditorKeyHandler();\n }\n\n // ---------------------------------------------------------------------\n // Trigger handling\n // ---------------------------------------------------------------------\n\n /**\n * Feed a raw `cds-custom-aichat-trigger-change` event. The event's `target` is the\n * originating prompt-line (since the event is `composed: true, bubbles:\n * true`), so we capture it here for later selection-routing.\n */\n handleTriggerChangeEvent(\n event: CustomEvent<TriggerChangeEventDetail | null>\n ): void {\n const target = findPromptLineFromTarget(event.composedPath());\n if (target) {\n this._promptLine = target;\n }\n this.handleTriggerChange(event.detail ?? null);\n }\n\n /**\n * Feed a trigger-change detail directly. Use this when the caller already\n * has the detail object and a separate way to know which prompt-line it\n * belongs to (e.g. the React hook holds a ref).\n */\n handleTriggerChange(detail: TriggerChangeEventDetail | null): void {\n if (this._destroyed) {\n return;\n }\n this._trigger = detail;\n if (!detail) {\n this._items = [];\n this._resolveToken++;\n this._refreshEditorKeyHandler();\n this._emit();\n return;\n }\n this._kickoffResolve(detail);\n this._refreshEditorKeyHandler();\n }\n\n /**\n * Clear active trigger + items.\n *\n * @param keepCoalesced - When `true`, skip `resetTriggerChangeState` so the\n * trigger-utils coalescing layer stays active. Use this when the dismissal\n * is from a send action where the editor stays empty and focused — without\n * it, the starter trigger would immediately re-fire on the next transaction.\n */\n dismiss(keepCoalesced = false): void {\n if (this._destroyed) {\n return;\n }\n if (!this._trigger && this._items.length === 0) {\n return;\n }\n this._trigger = null;\n this._items = [];\n this._resolveToken++;\n this._refreshEditorKeyHandler();\n this._emit();\n if (!keepCoalesced) {\n const editor = this._promptLine?.getEditor();\n if (editor) {\n resetTriggerChangeState(editor);\n }\n }\n }\n\n // ---------------------------------------------------------------------\n // Selection\n // ---------------------------------------------------------------------\n\n /**\n * Apply a user selection. Routes by trigger type:\n * - starter → insert text + (if not send-disabled) fire onStarterSelected\n * - mention / command → insert chip node at trigger range\n * - autocomplete → insert plain text at trigger range\n */\n select(item: SuggestionItem): void {\n if (this._destroyed) {\n return;\n }\n const trigger = this._trigger;\n const promptLine = this._promptLine;\n const editor = promptLine?.getEditor() ?? null;\n if (!trigger || !editor) {\n this.dismiss();\n return;\n }\n\n if (trigger.type === 'starter') {\n const text = item.value ?? item.label;\n editor.commands.insertContent(text);\n this.dismiss();\n if (!this._isSendDisabled) {\n this._onStarterSelected?.(projectRawValue(editor));\n }\n return;\n }\n\n if (trigger.type === 'mention' || trigger.type === 'command') {\n const config = this._configForTrigger(trigger.type);\n const nodeName = trigger.type;\n const range = {\n from: trigger.triggerOffset,\n to: editor.state.selection.from,\n };\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n {\n type: nodeName,\n attrs: {\n id: item.id,\n label: item.label,\n value: item.value ?? item.label,\n trigger: resolveShowTriggerInChip(\n item,\n config ?? {},\n trigger.type === 'command'\n )\n ? config?.trigger\n : null,\n data: stripPresentationFields(item),\n },\n },\n { type: 'text', text: ' ' },\n ])\n .run();\n config?.onSelect?.(item);\n } else if (trigger.type === 'autocomplete') {\n const text = item.value ?? item.label;\n const range = {\n from: trigger.triggerOffset,\n to: editor.state.selection.from,\n };\n editor\n .chain()\n .focus()\n .insertContentAt(range, [{ type: 'text', text }])\n .run();\n this._autocomplete?.onSelect?.(item);\n }\n\n this.dismiss();\n }\n\n // ---------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------\n\n destroy(): void {\n this._detachEditorKeyHandler();\n this._destroyed = true;\n this._resolveToken++;\n this._trigger = null;\n this._items = [];\n this._promptLine = null;\n this._listElement = null;\n }\n\n // ---------------------------------------------------------------------\n // Editor-DOM key forwarding\n // ---------------------------------------------------------------------\n\n /**\n * When a trigger and a list element are both active, bind a keydown\n * handler to the prompt-line editor DOM so ArrowUp / ArrowDown / Enter /\n * Escape pressed while typing get re-dispatched on the list — same effect\n * as if the list had focus, without taking focus from the editor.\n */\n private _refreshEditorKeyHandler(): void {\n if (this._destroyed) {\n this._detachEditorKeyHandler();\n return;\n }\n const editorDom =\n this._trigger && this._listElement\n ? ((this._promptLine?.getEditor()?.view.dom as HTMLElement) ?? null)\n : null;\n if (editorDom === this._editorDomBound) {\n return;\n }\n this._detachEditorKeyHandler();\n if (editorDom) {\n editorDom.addEventListener('keydown', this._handleEditorKeyDown, true);\n editorDom.addEventListener('focusout', this._handleEditorFocusOut);\n this._editorDomBound = editorDom;\n }\n }\n\n private _detachEditorKeyHandler(): void {\n if (this._editorDomBound) {\n this._editorDomBound.removeEventListener(\n 'keydown',\n this._handleEditorKeyDown,\n true\n );\n this._editorDomBound.removeEventListener(\n 'focusout',\n this._handleEditorFocusOut\n );\n this._editorDomBound = null;\n }\n }\n\n private _handleEditorKeyDown = (event: KeyboardEvent): void => {\n if (\n event.key !== 'ArrowUp' &&\n event.key !== 'ArrowDown' &&\n event.key !== 'Tab' &&\n event.key !== 'Enter' &&\n event.key !== 'Escape'\n ) {\n return;\n }\n const listEl = this._listElement;\n if (!listEl || !this._trigger) {\n return;\n }\n\n if (event.key === 'Enter') {\n const navigated = isNavigableListElement(listEl)\n ? listEl.hasNavigated()\n : true;\n if (!navigated) {\n this.dismiss();\n return; // let carbonChatEnter send the typed text\n }\n }\n\n // Stop Tiptap and the editor from acting on the same key. `capture: true`\n // (when listening) plus stopPropagation here gets us in ahead of\n // ProseMirror's own keydown handler.\n event.preventDefault();\n event.stopPropagation();\n listEl.dispatchEvent(\n new KeyboardEvent('keydown', {\n key: event.key,\n bubbles: true,\n cancelable: true,\n })\n );\n };\n\n private _handleEditorFocusOut = (event: FocusEvent): void => {\n const relatedTarget = event.relatedTarget as Node | null;\n // If focus moved into the list element (or inside it), keep the overlay\n // open — the user is interacting with it.\n if (relatedTarget && this._listElement?.contains(relatedTarget)) {\n return;\n }\n this.dismiss();\n };\n\n // ---------------------------------------------------------------------\n // Internals\n // ---------------------------------------------------------------------\n\n private _kickoffResolve(trigger: TriggerChangeEventDetail): void {\n const token = ++this._resolveToken;\n void (async () => {\n const items = await this._resolveItems(trigger);\n if (this._destroyed || this._resolveToken !== token) {\n return;\n }\n this._items = items;\n this._emit();\n })();\n }\n\n /**\n * The config backing a trigger type, or `undefined` for a type no config\n * covers. Single lookup for the class: a new trigger type is one case here,\n * not a hunt through every method that names the types.\n *\n * Callers reach the fields every config shares. The `mention`/`command`\n * overload returns the narrower type, which is what `select()` needs to read\n * `trigger` — a field `BaseSuggestionConfig` does not carry.\n */\n private _configForTrigger(\n type: 'mention' | 'command'\n ): TriggerSuggestionConfig | undefined;\n private _configForTrigger(type: string): BaseSuggestionConfig | undefined;\n private _configForTrigger(type: string): BaseSuggestionConfig | undefined {\n switch (type) {\n case 'starter':\n return this._starters;\n case 'mention':\n return this._mention;\n case 'command':\n return this._command;\n case 'autocomplete':\n return this._autocomplete;\n default:\n return undefined;\n }\n }\n\n private async _resolveItems(\n trigger: TriggerChangeEventDetail\n ): Promise<SuggestionItem[]> {\n // Starters are a fixed list shown on an empty editor, so they skip the\n // query gating and filtering every other trigger runs through.\n if (trigger.type === 'starter') {\n return this._starters?.items ?? [];\n }\n const config = this._configForTrigger(trigger.type);\n if (!config) {\n return [];\n }\n return resolveConfigItems(config, trigger.query);\n }\n\n private _resolveRenderCustomList():\n ((props: CustomListProps) => HTMLElement | unknown) | undefined {\n const trigger = this._trigger;\n if (!trigger) {\n return undefined;\n }\n return this._configForTrigger(trigger.type)?.renderCustomList;\n }\n\n private _resolveDisableDirectSend(): boolean | undefined {\n const trigger = this._trigger;\n\n if (!trigger) {\n return undefined;\n }\n\n // Mention and command always insert a chip rather than send, which is why\n // TriggerSuggestionConfig omits the field rather than defaulting it.\n if (trigger.type === 'mention' || trigger.type === 'command') {\n return true;\n }\n\n return this._configForTrigger(trigger.type)?.disableDirectSend;\n }\n\n private _emit(): void {\n this._onChange({\n trigger: this._trigger,\n items: this._items,\n renderCustomList: this._resolveRenderCustomList(),\n disableDirectSend: this._resolveDisableDirectSend(),\n });\n }\n}\n\n// ---------------------------------------------------------------------------\n// Controller helpers\n// ---------------------------------------------------------------------------\n\n/** Walks an event's composedPath looking for a `cds-custom-aichat-prompt-line`. */\nfunction findPromptLineFromTarget(\n path: EventTarget[]\n): PromptLineElement | null {\n for (const target of path) {\n if (\n target instanceof HTMLElement &&\n target.tagName === 'CDS-AICHAT-PROMPT-LINE'\n ) {\n return target as unknown as PromptLineElement;\n }\n }\n return null;\n}\n\n/**\n * Partition a flat `SuggestionItem[]` into ungrouped items and derived\n * `SuggestionItemGroup[]` for the `<cds-custom-aichat-autocomplete>` element.\n * Items with no `groupId` go into `items`; items with a `groupId` are\n * bucketed into groups preserving first-occurrence order. The group title\n * is taken from the first item in the bucket that carries a `groupTitle`.\n */\nexport function itemsToGroups(flat: SuggestionItem[]): {\n items: SuggestionItem[];\n groups: SuggestionItemGroup[];\n} {\n const items: SuggestionItem[] = [];\n const groupMap = new Map<string, SuggestionItemGroup>();\n const groupOrder: string[] = [];\n\n for (const item of flat) {\n if (!item.groupId) {\n items.push(item);\n continue;\n }\n let group = groupMap.get(item.groupId);\n if (!group) {\n group = {\n id: item.groupId,\n title: item.groupTitle ?? '',\n items: [],\n };\n groupMap.set(item.groupId, group);\n groupOrder.push(item.groupId);\n }\n group.items.push(item);\n }\n\n return {\n items,\n groups: groupOrder\n .map((id) => groupMap.get(id))\n .filter((g): g is SuggestionItemGroup => g !== undefined),\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAEH;;;;;;;;;;;;;;;AAeG;AA+CH,SAAS,sBAAsB,CAC7B,EAAe,EAAA;AAEf,IAAA,OAAO,OAAQ,EAAU,CAAC,YAAY,KAAK,UAAU;AACvD;MAEa,sBA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EAAE,KAAK,CAAC;AACjC,YAAA,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QAC/B;AACA,QAAA,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IACxB;IAEA,OAAO;QACL,KAAK;AACL,QAAA,MAAM,EAAE;AACL,aAAA,GAAG,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;aAC5B,MAAM,CAAC,CAAC,CAAC,KAA+B,CAAC,KAAK,SAAS,CAAC;KAC5D;AACH;;"}
@@ -34,6 +34,13 @@ declare class InputSendControlElement extends LitElement {
34
34
  stopResponseLabel: string;
35
35
  /** Test identifier. */
36
36
  testId?: string;
37
+ private _autocompleteListNavigated;
38
+ private _navigatedAtPointerdown;
39
+ private _autocompleteEventSource;
40
+ connectedCallback(): void;
41
+ disconnectedCallback(): void;
42
+ private _handleAutocompleteNavigated;
43
+ private _handleDocumentPointerdown;
37
44
  private _handleSendClick;
38
45
  private _handleStopStreamingClick;
39
46
  render(): import("lit-html").TemplateResult<1>;
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { __decorate } from 'tslib';
9
9
  import { unsafeCSS, css, LitElement, html } from 'lit';
10
- import { property } from 'lit/decorators.js';
10
+ import { property, state } from 'lit/decorators.js';
11
11
  import { ifDefined } from 'lit/directives/if-defined.js';
12
12
  import { carbonElement } from '../../../globals/decorators/carbon-element.js';
13
13
  import prefix from '../../../globals/settings.js';
@@ -51,8 +51,34 @@ let InputSendControlElement = class InputSendControlElement extends LitElement {
51
51
  this.buttonLabel = 'Send';
52
52
  /** Label for the stop streaming button tooltip. */
53
53
  this.stopResponseLabel = 'Stop response';
54
- this._handleSendClick = () => {
55
- if (this.disabled || this.disableSend || !this.hasValidInput) {
54
+ this._autocompleteListNavigated = false;
55
+ // Latches navigated state at gesture start; focusout can clear the live flag
56
+ // before click fires, so this preserves the blocked state through click.
57
+ this._navigatedAtPointerdown = false;
58
+ // Autocomplete is a sibling; listen on the shared shell ancestor.
59
+ this._autocompleteEventSource = null;
60
+ this._handleAutocompleteNavigated = (event) => {
61
+ this._autocompleteListNavigated = event.detail.navigated;
62
+ };
63
+ this._handleDocumentPointerdown = (event) => {
64
+ if (!event.composedPath().includes(this)) {
65
+ return;
66
+ }
67
+ const navigated = this._autocompleteListNavigated;
68
+ // Sync on every gesture so a cancelled gesture doesn't leave a stale latch.
69
+ this._navigatedAtPointerdown = navigated;
70
+ if (navigated) {
71
+ // Suppress focus-activation so the editor stays focused and the live flag
72
+ // remains true through the subsequent click.
73
+ event.preventDefault();
74
+ }
75
+ };
76
+ this._handleSendClick = (event) => {
77
+ // detail === 0 for keyboard/assistive clicks — don't block those.
78
+ const blocked = (event.detail > 0 && this._navigatedAtPointerdown) ||
79
+ this._autocompleteListNavigated;
80
+ this._navigatedAtPointerdown = false;
81
+ if (this.disabled || this.disableSend || blocked || !this.hasValidInput) {
56
82
  return;
57
83
  }
58
84
  this.dispatchEvent(new CustomEvent('cds-custom-aichat-input-send', {
@@ -67,10 +93,29 @@ let InputSendControlElement = class InputSendControlElement extends LitElement {
67
93
  }));
68
94
  };
69
95
  }
96
+ connectedCallback() {
97
+ super.connectedCallback();
98
+ this._autocompleteEventSource =
99
+ this.closest(`${prefix}-prompt-line-shell`) ?? this.parentElement;
100
+ this._autocompleteEventSource?.addEventListener('cds-custom-aichat-autocomplete-navigated', this._handleAutocompleteNavigated);
101
+ // Capture phase: fires before focus-activation and before pointer-events:none
102
+ // on the disabled button suppresses the event.
103
+ document.addEventListener('pointerdown', this._handleDocumentPointerdown, {
104
+ capture: true,
105
+ });
106
+ }
107
+ disconnectedCallback() {
108
+ super.disconnectedCallback();
109
+ this._autocompleteEventSource?.removeEventListener('cds-custom-aichat-autocomplete-navigated', this._handleAutocompleteNavigated);
110
+ this._autocompleteEventSource = null;
111
+ document.removeEventListener('pointerdown', this._handleDocumentPointerdown, { capture: true });
112
+ }
70
113
  render() {
71
- // Check if RTL direction is set
72
114
  const isRTL = document.dir === 'rtl' || document.documentElement.dir === 'rtl';
73
- const showDisabledSend = !this.hasValidInput || this.disabled || this.disableSend;
115
+ const showDisabledSend = !this.hasValidInput ||
116
+ this.disabled ||
117
+ this.disableSend ||
118
+ this._autocompleteListNavigated;
74
119
  if (this.isStopStreamingButtonVisible) {
75
120
  return html `
76
121
  <cds-custom-aichat-stop-streaming-button
@@ -127,6 +172,9 @@ __decorate([
127
172
  __decorate([
128
173
  property({ type: String, attribute: 'test-id' })
129
174
  ], InputSendControlElement.prototype, "testId", void 0);
175
+ __decorate([
176
+ state()
177
+ ], InputSendControlElement.prototype, "_autocompleteListNavigated", void 0);
130
178
  InputSendControlElement = __decorate([
131
179
  carbonElement(`${prefix}-input-send-control`)
132
180
  ], InputSendControlElement);
@@ -1 +1 @@
1
- {"version":3,"file":"send-control.js","sources":["../../../../src/components/prompt-line/src/send-control.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css, html, LitElement, unsafeCSS } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport prefix from '../../../globals/settings.js';\n\nimport '@carbon/web-components/es-custom/components/button/index.js';\n\nimport { iconLoader } from '@carbon/web-components/es-custom/globals/internal/icon-loader.js';\nimport Send16 from '@carbon/icons/es/send/16.js';\nimport SendFilled16 from '@carbon/icons/es/send--filled/16.js';\n\nimport {\n BUTTON_KIND,\n BUTTON_SIZE,\n BUTTON_TYPE,\n BUTTON_TOOLTIP_ALIGNMENT,\n BUTTON_TOOLTIP_POSITION,\n} from '@carbon/web-components/es-custom/components/button/defs.js';\n\nimport './stop-streaming-button.js';\n\nimport styles from './send-control.scss?lit';\n\n/**\n * Send control component — renders the send button or stop streaming button.\n *\n * @element cds-custom-aichat-input-send-control\n * @fires {CustomEvent} cds-custom-aichat-input-send - Fired when the send button is clicked\n * @fires {CustomEvent} cds-custom-aichat-input-stop-streaming - Fired when the stop streaming button is clicked\n */\n@carbonElement(`${prefix}-input-send-control`)\nclass InputSendControlElement extends LitElement {\n static styles = css`\n ${unsafeCSS(styles)}\n `;\n\n /** Whether the input has valid content that can be sent. */\n @property({ type: Boolean, attribute: 'has-valid-input' })\n hasValidInput = false;\n\n /** Whether the entire input is disabled. */\n @property({ type: Boolean, attribute: 'disabled' })\n disabled = false;\n\n /** Whether sending is disabled (separate from overall disabled state). */\n @property({ type: Boolean, attribute: 'disable-send' })\n disableSend = false;\n\n /** Show the stop streaming button instead of the send button. */\n @property({ type: Boolean, attribute: 'show-stop-streaming' })\n isStopStreamingButtonVisible = false;\n\n /** Whether the stop streaming button is disabled. */\n @property({ type: Boolean, attribute: 'disable-stop-streaming' })\n isStopStreamingButtonDisabled = false;\n\n /** Label for the send button tooltip. */\n @property({ type: String, attribute: 'button-label' })\n buttonLabel = 'Send';\n\n /** Label for the stop streaming button tooltip. */\n @property({ type: String, attribute: 'stop-response-label' })\n stopResponseLabel = 'Stop response';\n\n /** Test identifier. */\n @property({ type: String, attribute: 'test-id' })\n testId?: string;\n\n private _handleSendClick = () => {\n if (this.disabled || this.disableSend || !this.hasValidInput) {\n return;\n }\n\n this.dispatchEvent(\n new CustomEvent('cds-custom-aichat-input-send', {\n bubbles: true,\n composed: true,\n })\n );\n };\n\n private _handleStopStreamingClick = () => {\n this.dispatchEvent(\n new CustomEvent('cds-custom-aichat-input-stop-streaming', {\n bubbles: true,\n composed: true,\n })\n );\n };\n\n render() {\n // Check if RTL direction is set\n const isRTL =\n document.dir === 'rtl' || document.documentElement.dir === 'rtl';\n\n const showDisabledSend =\n !this.hasValidInput || this.disabled || this.disableSend;\n\n if (this.isStopStreamingButtonVisible) {\n return html`\n <cds-custom-aichat-stop-streaming-button\n label=\"${this.stopResponseLabel}\"\n ?disabled=\"${this.isStopStreamingButtonDisabled}\"\n tooltip-alignment=\"${isRTL ? 'top-left' : 'top-right'}\"\n @click=\"${this._handleStopStreamingClick}\"></cds-custom-aichat-stop-streaming-button>\n `;\n }\n\n return html`\n <cds-custom-button\n class=\"${prefix}--input-send-button\"\n kind=\"${BUTTON_KIND.GHOST}\"\n size=\"${BUTTON_SIZE.SMALL}\"\n type=\"${BUTTON_TYPE.BUTTON}\"\n ?disabled=\"${showDisabledSend}\"\n tooltip-text=\"${this.buttonLabel}\"\n tooltip-alignment=\"${\n isRTL ? BUTTON_TOOLTIP_ALIGNMENT.START : BUTTON_TOOLTIP_ALIGNMENT.END\n }\"\n tooltip-position=\"${BUTTON_TOOLTIP_POSITION.TOP}\"\n @click=\"${this._handleSendClick}\"\n aria-label=\"${this.buttonLabel}\"\n data-testid=\"${ifDefined(this.testId)}\">\n ${\n this.hasValidInput\n ? iconLoader(SendFilled16, { slot: 'icon' })\n : iconLoader(Send16, { slot: 'icon' })\n }\n </cds-custom-button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-custom-aichat-input-send-control': InputSendControlElement;\n }\n}\n\nexport default InputSendControlElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AA2BH;;;;;;AAMG;AAEH,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,UAAU,CAAA;AAAhD,IAAA,WAAA,GAAA;;;QAOE,IAAA,CAAA,aAAa,GAAG,KAAK;;QAIrB,IAAA,CAAA,QAAQ,GAAG,KAAK;;QAIhB,IAAA,CAAA,WAAW,GAAG,KAAK;;QAInB,IAAA,CAAA,4BAA4B,GAAG,KAAK;;QAIpC,IAAA,CAAA,6BAA6B,GAAG,KAAK;;QAIrC,IAAA,CAAA,WAAW,GAAG,MAAM;;QAIpB,IAAA,CAAA,iBAAiB,GAAG,eAAe;QAM3B,IAAA,CAAA,gBAAgB,GAAG,MAAK;AAC9B,YAAA,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,C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E;AAC1B,CAAA,EAAA,uBAAA,CAAA,SAAA,EAAA,+BAAA,EAAA,MAAA,CAAA;AAItC,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE;AAChC,CAAA,EAAA,uBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAIrB,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,qBAAqB,EAAE;AACxB,CAAA,EAAA,uBAAA,CAAA,SAAA,EAAA,mBAAA,EAAA,MAAA,CAAA;AAIpC,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE;AAChC,CAAA,EAAA,uBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAnCZ,uBAAuB,GAAA,UAAA,CAAA;AAD5B,IAAA,aAAa,CAAC,CAAA,EAAG,MAAM,CAAA,mBAAA,CAAqB;AACvC,CAAA,EAAA,uBAAuB,CAoG5B;AAQD,gCAAe,uBAAuB;;"}
1
+ {"version":3,"file":"send-control.js","sources":["../../../../src/components/prompt-line/src/send-control.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { css, html, LitElement, unsafeCSS } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport prefix from '../../../globals/settings.js';\n\nimport '@carbon/web-components/es-custom/components/button/index.js';\n\nimport { iconLoader } from '@carbon/web-components/es-custom/globals/internal/icon-loader.js';\nimport Send16 from '@carbon/icons/es/send/16.js';\nimport SendFilled16 from '@carbon/icons/es/send--filled/16.js';\n\nimport {\n BUTTON_KIND,\n BUTTON_SIZE,\n BUTTON_TYPE,\n BUTTON_TOOLTIP_ALIGNMENT,\n BUTTON_TOOLTIP_POSITION,\n} from '@carbon/web-components/es-custom/components/button/defs.js';\n\nimport './stop-streaming-button.js';\n\nimport styles from './send-control.scss?lit';\n\n/**\n * Send control component — renders the send button or stop streaming button.\n *\n * @element cds-custom-aichat-input-send-control\n * @fires {CustomEvent} cds-custom-aichat-input-send - Fired when the send button is clicked\n * @fires {CustomEvent} cds-custom-aichat-input-stop-streaming - Fired when the stop streaming button is clicked\n */\n@carbonElement(`${prefix}-input-send-control`)\nclass InputSendControlElement extends LitElement {\n static styles = css`\n ${unsafeCSS(styles)}\n `;\n\n /** Whether the input has valid content that can be sent. */\n @property({ type: Boolean, attribute: 'has-valid-input' })\n hasValidInput = false;\n\n /** Whether the entire input is disabled. */\n @property({ type: Boolean, attribute: 'disabled' })\n disabled = false;\n\n /** Whether sending is disabled (separate from overall disabled state). */\n @property({ type: Boolean, attribute: 'disable-send' })\n disableSend = false;\n\n /** Show the stop streaming button instead of the send button. */\n @property({ type: Boolean, attribute: 'show-stop-streaming' })\n isStopStreamingButtonVisible = false;\n\n /** Whether the stop streaming button is disabled. */\n @property({ type: Boolean, attribute: 'disable-stop-streaming' })\n isStopStreamingButtonDisabled = false;\n\n /** Label for the send button tooltip. */\n @property({ type: String, attribute: 'button-label' })\n buttonLabel = 'Send';\n\n /** Label for the stop streaming button tooltip. */\n @property({ type: String, attribute: 'stop-response-label' })\n stopResponseLabel = 'Stop response';\n\n /** Test identifier. */\n @property({ type: String, attribute: 'test-id' })\n testId?: string;\n\n @state()\n private _autocompleteListNavigated = false;\n\n // Latches navigated state at gesture start; focusout can clear the live flag\n // before click fires, so this preserves the blocked state through click.\n private _navigatedAtPointerdown = false;\n\n // Autocomplete is a sibling; listen on the shared shell ancestor.\n private _autocompleteEventSource: EventTarget | null = null;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this._autocompleteEventSource =\n this.closest(`${prefix}-prompt-line-shell`) ?? this.parentElement;\n this._autocompleteEventSource?.addEventListener(\n 'cds-custom-aichat-autocomplete-navigated',\n this._handleAutocompleteNavigated as EventListener\n );\n // Capture phase: fires before focus-activation and before pointer-events:none\n // on the disabled button suppresses the event.\n document.addEventListener('pointerdown', this._handleDocumentPointerdown, {\n capture: true,\n });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._autocompleteEventSource?.removeEventListener(\n 'cds-custom-aichat-autocomplete-navigated',\n this._handleAutocompleteNavigated as EventListener\n );\n this._autocompleteEventSource = null;\n document.removeEventListener(\n 'pointerdown',\n this._handleDocumentPointerdown,\n { capture: true }\n );\n }\n\n private _handleAutocompleteNavigated = (event: Event): void => {\n this._autocompleteListNavigated = (\n event as CustomEvent<{ navigated: boolean }>\n ).detail.navigated;\n };\n\n private _handleDocumentPointerdown = (event: PointerEvent): void => {\n if (!event.composedPath().includes(this)) {\n return;\n }\n const navigated = this._autocompleteListNavigated;\n // Sync on every gesture so a cancelled gesture doesn't leave a stale latch.\n this._navigatedAtPointerdown = navigated;\n if (navigated) {\n // Suppress focus-activation so the editor stays focused and the live flag\n // remains true through the subsequent click.\n event.preventDefault();\n }\n };\n\n private _handleSendClick = (event: MouseEvent) => {\n // detail === 0 for keyboard/assistive clicks — don't block those.\n const blocked =\n (event.detail > 0 && this._navigatedAtPointerdown) ||\n this._autocompleteListNavigated;\n this._navigatedAtPointerdown = false;\n if (this.disabled || this.disableSend || blocked || !this.hasValidInput) {\n return;\n }\n this.dispatchEvent(\n new CustomEvent('cds-custom-aichat-input-send', {\n bubbles: true,\n composed: true,\n })\n );\n };\n\n private _handleStopStreamingClick = () => {\n this.dispatchEvent(\n new CustomEvent('cds-custom-aichat-input-stop-streaming', {\n bubbles: true,\n composed: true,\n })\n );\n };\n\n render() {\n const isRTL =\n document.dir === 'rtl' || document.documentElement.dir === 'rtl';\n\n const showDisabledSend =\n !this.hasValidInput ||\n this.disabled ||\n this.disableSend ||\n this._autocompleteListNavigated;\n\n if (this.isStopStreamingButtonVisible) {\n return html`\n <cds-custom-aichat-stop-streaming-button\n label=\"${this.stopResponseLabel}\"\n ?disabled=\"${this.isStopStreamingButtonDisabled}\"\n tooltip-alignment=\"${isRTL ? 'top-left' : 'top-right'}\"\n @click=\"${this._handleStopStreamingClick}\"></cds-custom-aichat-stop-streaming-button>\n `;\n }\n\n return html`\n <cds-custom-button\n class=\"${prefix}--input-send-button\"\n kind=\"${BUTTON_KIND.GHOST}\"\n size=\"${BUTTON_SIZE.SMALL}\"\n type=\"${BUTTON_TYPE.BUTTON}\"\n ?disabled=\"${showDisabledSend}\"\n tooltip-text=\"${this.buttonLabel}\"\n tooltip-alignment=\"${\n isRTL ? BUTTON_TOOLTIP_ALIGNMENT.START : BUTTON_TOOLTIP_ALIGNMENT.END\n }\"\n tooltip-position=\"${BUTTON_TOOLTIP_POSITION.TOP}\"\n @click=\"${this._handleSendClick}\"\n aria-label=\"${this.buttonLabel}\"\n data-testid=\"${ifDefined(this.testId)}\">\n ${\n this.hasValidInput\n ? iconLoader(SendFilled16, { slot: 'icon' })\n : iconLoader(Send16, { slot: 'icon' })\n }\n </cds-custom-button>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-custom-aichat-input-send-control': InputSendControlElement;\n }\n}\n\nexport default InputSendControlElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AA2BH;;;;;;AAMG;AAEH,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,UAAU,CAAA;AAAhD,IAAA,WAAA,GAAA;;;QAOE,IAAA,CAAA,aAAa,GAAG,KAAK;;QAIrB,IAAA,CAAA,QAAQ,GAAG,KAAK;;QAIhB,IAAA,CAAA,WAAW,GAAG,KAAK;;QAInB,IAAA,CAAA,4BAA4B,GAAG,KAAK;;QAIpC,IAAA,CAAA,6BAA6B,GAAG,KAAK;;QAIrC,IAAA,CAAA,WAAW,GAAG,MAAM;;QAIpB,IAAA,CAAA,iBAAiB,G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carbonAutocomplete(excludeTriggers = []) {
47
47
  if (!text || text.length === 0) {
48
48
  return null;
49
49
  }
50
- // Restrict the query to the trailing word (split on whitespace).
51
- const trailing = /\S+$/.exec(text);
52
- if (!trailing) {
53
- return null;
54
- }
55
- const query = trailing[0];
56
50
  // Yield to co-installed mention/command extensions so they win
57
- // when their trigger char is active.
58
- for (const excluded of excludeTriggers) {
59
- if (!query.startsWith(excluded.char)) {
60
- continue;
61
- }
62
- if (excluded.position === 'anywhere') {
63
- return null;
64
- }
65
- if (text === query) {
66
- return null;
51
+ // when their trigger char is the active (trailing) word.
52
+ const trailing = /\S+$/.exec(text);
53
+ if (trailing) {
54
+ const trailingWord = trailing[0];
55
+ for (const excluded of excludeTriggers) {
56
+ if (!trailingWord.startsWith(excluded.char)) {
57
+ continue;
58
+ }
59
+ if (excluded.position === 'anywhere') {
60
+ return null;
61
+ }
62
+ // text matches an excluded trigger
63
+ if (text === trailingWord) {
64
+ return null;
65
+ }
67
66
  }
68
67
  }
69
- const matchStart = $position.start() + $position.parentOffset - query.length;
68
+ // Use the full paragraph text as the query so spaces are included.
69
+ const matchStart = $position.start();
70
70
  return {
71
71
  range: {
72
72
  from: matchStart,
73
73
  to: $position.start() + $position.parentOffset,
74
74
  },
75
- query,
76
- text: query,
75
+ query: text,
76
+ text,
77
77
  };
78
78
  },
79
79
  render: () => ({
@@ -98,7 +98,7 @@ function carbonAutocomplete(excludeTriggers = []) {
98
98
  },
99
99
  onExit: (props) => {
100
100
  lastQuery = null;
101
- dispatchTriggerChange(props.editor, null);
101
+ dispatchTriggerChange(props.editor, null, 'autocomplete');
102
102
  },
103
103
  onKeyDown: () => false,
104
104
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"carbon-autocomplete.js","sources":["../../../../../src/components/prompt-line/src/tiptap/carbon-autocomplete.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * `carbonAutocomplete` factory. Wraps `@tiptap/suggestion` directly (no\n * Mention node). Activates whenever the input has any non-empty text (the\n * legacy autocomplete contract).\n *\n * Dispatches `cds-custom-aichat-trigger-change` with `type: \"autocomplete\"` from\n * the suggestion-render lifecycle via the shared `dispatchTriggerChange`\n * helper. Selection is routed through `AutocompleteController.select()` —\n * the `@tiptap/suggestion` `command` hook is intentionally unused.\n */\n\nimport { Extension } from '@tiptap/core';\nimport { PluginKey } from '@tiptap/pm/state';\nimport Suggestion from '@tiptap/suggestion';\n\nimport { dispatchTriggerChange } from './trigger-utils.js';\nimport type { SuggestionItem } from './types.js';\n\n/**\n * A trigger character that autocomplete stands down for, so a co-installed\n * mention or command picker wins while its trigger is active. Pass a list of\n * these as the only argument to {@link carbonAutocomplete}.\n */\nexport interface ExcludedTrigger {\n /** The character to stand down for, such as `\"@\"` or `\"/\"`. */\n char: string;\n /**\n * Where that character has to sit. `\"anywhere\"` stands down for any word\n * starting with it; `\"start\"` stands down only when that word starts the\n * line. Mirrors the picker's own\n * {@link TriggerSuggestionConfig.triggerPosition}.\n */\n position: 'anywhere' | 'start';\n}\n\nexport function carbonAutocomplete(\n excludeTriggers: ExcludedTrigger[] = []\n): Extension {\n const pluginKey = new PluginKey('carbonAutocompleteSuggestion');\n\n return Extension.create({\n name: 'carbonAutocomplete',\n\n addProseMirrorPlugins() {\n const editor = this.editor;\n let lastQuery: string | null = null;\n\n return [\n Suggestion<SuggestionItem>({\n editor,\n char: '',\n pluginKey,\n // Match any non-empty text as the autocomplete query.\n allowedPrefixes: null,\n findSuggestionMatch: ({ $position }) => {\n const text = $position.parent.textBetween(\n 0,\n $position.parentOffset,\n '\\n',\n '\\0'\n );\n if (!text || text.length === 0) {\n return null;\n }\n // Restrict the query to the trailing word (split on whitespace).\n const trailing = /\\S+$/.exec(text);\n if (!trailing) {\n return null;\n }\n const query = trailing[0];\n // Yield to co-installed mention/command extensions so they win\n // when their trigger char is active.\n for (const excluded of excludeTriggers) {\n if (!query.startsWith(excluded.char)) {\n continue;\n }\n if (excluded.position === 'anywhere') {\n return null;\n }\n if (text === query) {\n return null;\n }\n }\n const matchStart =\n $position.start() + $position.parentOffset - query.length;\n return {\n range: {\n from: matchStart,\n to: $position.start() + $position.parentOffset,\n },\n query,\n text: query,\n };\n },\n render: () => ({\n onStart: (props) => {\n lastQuery = props.query;\n dispatchTriggerChange(props.editor, {\n type: 'autocomplete',\n query: props.query,\n triggerOffset: props.range.from,\n });\n },\n onUpdate: (props) => {\n if (props.query === lastQuery) {\n return;\n }\n lastQuery = props.query;\n dispatchTriggerChange(props.editor, {\n type: 'autocomplete',\n query: props.query,\n triggerOffset: props.range.from,\n });\n },\n onExit: (props) => {\n lastQuery = null;\n dispatchTriggerChange(props.editor, null);\n },\n onKeyDown: () => false,\n }),\n }),\n ];\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;AAOG;AAEH;;;;;;;;;AASG;AA0BG,SAAU,kBAAkB,CAChC,eAAA,GAAqC,EAAE,EAAA;AAEvC,IAAA,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,8BAA8B,CAAC;IAE/D,OAAO,SAAS,CAAC,MAAM,CAAC;AACtB,QAAA,IAAI,EAAE,oBAAoB;QAE1B,qBAAqB,GAAA;AACnB,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM;YAC1B,IAAI,SAAS,GAAkB,IAAI;YAEnC,OAAO;AACL,gBAAA,UAAU,CAAiB;oBACzB,MAAM;AACN,oBAAA,IAAI,EAAE,EAAE;oBACR,SAAS;;AAET,oBAAA,eAAe,EAAE,IAAI;AACrB,oBAAA,mBAAmB,EAAE,CAAC,EAAE,SAAS,EAAE,KAAI;AACrC,wBAAA,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,WAAW,CACvC,CAAC,EACD,SAAS,CAAC,YAAY,EACtB,IAAI,EACJ,IAAI,CACL;wBACD,IAAI,CAAC,IAAI,IAAI,IAAI,CAA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ClB,4BAAA,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE;gCAC7B;4BACF;AACA,4BAAA,SAAS,GAAG,KAAK,CAAC,KAAK;AACvB,4BAAA,qBAAqB,CAAC,KAAK,CAAC,MAAM,EAAE;AAClC,gCAAA,IAAI,EAAE,cAAc;gCACpB,KAAK,EAAE,KAAK,CAAC,KAAK;AAClB,gCAAA,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI;AAChC,6BAAA,CAAC;wBACJ,CAAC;AACD,wBAAA,MAAM,EAAE,CAAC,KAAK,KAAI;4BAChB,SAAS,GAAG,IAAI;AAChB,4BAAA,qBAAqB,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC;wBAC3C,CAAC;AACD,wBAAA,SAAS,EAAE,MAAM,KAAK;qBACvB,CAAC;iBACH,CAAC;aACH;QACH,CAAC;AACF,KAAA,CAAC;AACJ;;"}
1
+ {"version":3,"file":"carbon-autocomplete.js","sources":["../../../../../src/components/prompt-line/src/tiptap/carbon-autocomplete.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * `carbonAutocomplete` factory. Wraps `@tiptap/suggestion` directly (no\n * Mention node). Activates whenever the input has any non-empty text (the\n * legacy autocomplete contract).\n *\n * Dispatches `cds-custom-aichat-trigger-change` with `type: \"autocomplete\"` from\n * the suggestion-render lifecycle via the shared `dispatchTriggerChange`\n * helper. Selection is routed through `AutocompleteController.select()` —\n * the `@tiptap/suggestion` `command` hook is intentionally unused.\n */\n\nimport { Extension } from '@tiptap/core';\nimport { PluginKey } from '@tiptap/pm/state';\nimport Suggestion from '@tiptap/suggestion';\n\nimport { dispatchTriggerChange } from './trigger-utils.js';\nimport type { SuggestionItem } from './types.js';\n\n/**\n * A trigger character that autocomplete stands down for, so a co-installed\n * mention or command picker wins while its trigger is active. Pass a list of\n * these as the only argument to {@link carbonAutocomplete}.\n */\nexport interface ExcludedTrigger {\n /** The character to stand down for, such as `\"@\"` or `\"/\"`. */\n char: string;\n /**\n * Where that character has to sit. `\"anywhere\"` stands down for any word\n * starting with it; `\"start\"` stands down only when that word starts the\n * line. Mirrors the picker's own\n * {@link TriggerSuggestionConfig.triggerPosition}.\n */\n position: 'anywhere' | 'start';\n}\n\nexport function carbonAutocomplete(\n excludeTriggers: ExcludedTrigger[] = []\n): Extension {\n const pluginKey = new PluginKey('carbonAutocompleteSuggestion');\n\n return Extension.create({\n name: 'carbonAutocomplete',\n\n addProseMirrorPlugins() {\n const editor = this.editor;\n let lastQuery: string | null = null;\n\n return [\n Suggestion<SuggestionItem>({\n editor,\n char: '',\n pluginKey,\n // Match any non-empty text as the autocomplete query.\n allowedPrefixes: null,\n findSuggestionMatch: ({ $position }) => {\n const text = $position.parent.textBetween(\n 0,\n $position.parentOffset,\n '\\n',\n '\\0'\n );\n if (!text || text.length === 0) {\n return null;\n }\n // Yield to co-installed mention/command extensions so they win\n // when their trigger char is the active (trailing) word.\n const trailing = /\\S+$/.exec(text);\n if (trailing) {\n const trailingWord = trailing[0];\n for (const excluded of excludeTriggers) {\n if (!trailingWord.startsWith(excluded.char)) {\n continue;\n }\n if (excluded.position === 'anywhere') {\n return null;\n }\n // text matches an excluded trigger\n if (text === trailingWord) {\n return null;\n }\n }\n }\n // Use the full paragraph text as the query so spaces are included.\n const matchStart = $position.start();\n return {\n range: {\n from: matchStart,\n to: $position.start() + $position.parentOffset,\n },\n query: text,\n text,\n };\n },\n render: () => ({\n onStart: (props) => {\n lastQuery = props.query;\n dispatchTriggerChange(props.editor, {\n type: 'autocomplete',\n query: props.query,\n triggerOffset: props.range.from,\n });\n },\n onUpdate: (props) => {\n if (props.query === lastQuery) {\n return;\n }\n lastQuery = props.query;\n dispatchTriggerChange(props.editor, {\n type: 'autocomplete',\n query: props.query,\n triggerOffset: props.range.from,\n });\n },\n onExit: (props) => {\n lastQuery = null;\n dispatchTriggerCh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