@carbon/ai-chat-components 1.12.0 → 1.13.0-rc.2
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.
- package/custom-elements.json +4456 -4079
- package/es/components/chat-button/src/chat-button.scss.js +1 -1
- package/es/components/chat-history/src/chat-history.scss.js +1 -1
- package/es/components/chat-history/src/history-panel-item.js +0 -1
- package/es/components/chat-history/src/history-panel-item.js.map +1 -1
- package/es/components/chat-shell/src/panel-manager.d.ts +10 -0
- package/es/components/chat-shell/src/panel-manager.js +116 -1
- package/es/components/chat-shell/src/panel-manager.js.map +1 -1
- package/es/components/chat-shell/src/panel.d.ts +5 -0
- package/es/components/chat-shell/src/panel.js +16 -2
- package/es/components/chat-shell/src/panel.js.map +1 -1
- package/es/components/chat-shell/src/shell.d.ts +4 -0
- package/es/components/chat-shell/src/shell.js +72 -4
- package/es/components/chat-shell/src/shell.js.map +1 -1
- package/es/components/code-snippet/src/code-snippet.d.ts +3 -4
- package/es/components/code-snippet/src/code-snippet.js +4 -6
- package/es/components/code-snippet/src/code-snippet.js.map +1 -1
- package/es/components/code-snippet/src/codemirror/theme.js +2 -6
- package/es/components/code-snippet/src/codemirror/theme.js.map +1 -1
- package/es/components/code-snippet/src/layout-utils.d.ts +1 -3
- package/es/components/code-snippet/src/layout-utils.js.map +1 -1
- package/es/components/conversational-search/index.d.ts +9 -0
- package/es/components/conversational-search/index.js +9 -0
- package/es/components/conversational-search/index.js.map +1 -0
- package/es/components/conversational-search/src/citation-utils.d.ts +24 -0
- package/es/components/conversational-search/src/citation-utils.js +46 -0
- package/es/components/conversational-search/src/citation-utils.js.map +1 -0
- package/es/components/conversational-search/src/conversational-search-shell.d.ts +41 -0
- package/es/components/conversational-search/src/conversational-search-shell.js +116 -0
- package/es/components/conversational-search/src/conversational-search-shell.js.map +1 -0
- package/es/components/conversational-search/src/conversational-search-shell.scss.js +13 -0
- package/es/components/conversational-search/src/conversational-search-shell.scss.js.map +1 -0
- package/es/components/file-uploads/src/file-upload-item.js +3 -3
- package/es/components/file-uploads/src/file-upload-item.js.map +1 -1
- package/es/components/launcher/src/launcher.scss.js +1 -1
- package/es/components/markdown/src/markdown-token-tree.d.ts +2 -2
- package/es/components/markdown/src/markdown-token-tree.js.map +1 -1
- package/es/components/prompt-line/index.js +0 -2
- package/es/components/prompt-line/index.js.map +1 -1
- package/es/components/prompt-line/src/autocomplete-controller.js +13 -7
- package/es/components/prompt-line/src/autocomplete-controller.js.map +1 -1
- package/es/components/prompt-line/src/prompt-line-controller.d.ts +1 -1
- package/es/components/prompt-line/src/prompt-line-rich-loader.d.ts +7 -0
- package/es/components/prompt-line/src/prompt-line-rich-loader.js.map +1 -1
- package/es/components/prompt-line/src/prompt-line-rich-runtime.js +8 -2
- package/es/components/prompt-line/src/prompt-line-rich-runtime.js.map +1 -1
- package/es/components/prompt-line/src/prompt-line-shell.d.ts +42 -0
- package/es/components/prompt-line/src/prompt-line-shell.js +43 -1
- package/es/components/prompt-line/src/prompt-line-shell.js.map +1 -1
- package/es/components/prompt-line/src/prompt-line-shell.scss.js +1 -1
- package/es/components/prompt-line/src/prompt-line.d.ts +8 -2
- package/es/components/prompt-line/src/prompt-line.js +70 -10
- package/es/components/prompt-line/src/prompt-line.js.map +1 -1
- package/es/components/prompt-line/src/tiptap/index.d.ts +0 -2
- package/es/components/prompt-line/src/tiptap/index.js +0 -2
- package/es/components/prompt-line/src/tiptap/index.js.map +1 -1
- package/es/components/prompt-line/src/tiptap/resolve-config-items.d.ts +5 -1
- package/es/components/prompt-line/src/tiptap/resolve-config-items.js +9 -0
- package/es/components/prompt-line/src/tiptap/resolve-config-items.js.map +1 -1
- package/es/components/reasoning-steps/src/reasoning-step.js +2 -2
- package/es/components/reasoning-steps/src/reasoning-step.js.map +1 -1
- package/es/components/reasoning-steps/src/reasoning-step.scss.js +1 -1
- package/es/components/shared/dynamic-css-var-sheet.js +7 -6
- package/es/components/shared/dynamic-css-var-sheet.js.map +1 -1
- package/es/components/table/src/table.js +5 -7
- package/es/components/table/src/table.js.map +1 -1
- package/es/components/workspace-shell/src/workspace-shell.js +15 -5
- package/es/components/workspace-shell/src/workspace-shell.js.map +1 -1
- package/es/components/workspace-shell/src/workspace-shell.scss.js +1 -1
- package/es/globals/utils/iconTransform.d.ts +1 -1
- package/es/globals/utils/iconTransform.js.map +1 -1
- package/es/react/chat-shell.js +3 -0
- package/es/react/chat-shell.js.map +1 -1
- package/es/react/conversational-search-shell.d.ts +12 -0
- package/es/react/conversational-search-shell.js +32 -0
- package/es/react/conversational-search-shell.js.map +1 -0
- package/es-custom/components/chat-button/src/chat-button.scss.js +1 -1
- package/es-custom/components/chat-history/src/chat-history.scss.js +1 -1
- package/es-custom/components/chat-history/src/history-panel-item.js +0 -1
- package/es-custom/components/chat-history/src/history-panel-item.js.map +1 -1
- package/es-custom/components/chat-shell/src/panel-manager.d.ts +10 -0
- package/es-custom/components/chat-shell/src/panel-manager.js +116 -1
- package/es-custom/components/chat-shell/src/panel-manager.js.map +1 -1
- package/es-custom/components/chat-shell/src/panel.d.ts +5 -0
- package/es-custom/components/chat-shell/src/panel.js +16 -2
- package/es-custom/components/chat-shell/src/panel.js.map +1 -1
- package/es-custom/components/chat-shell/src/shell.d.ts +4 -0
- package/es-custom/components/chat-shell/src/shell.js +72 -4
- package/es-custom/components/chat-shell/src/shell.js.map +1 -1
- package/es-custom/components/code-snippet/src/code-snippet.d.ts +3 -4
- package/es-custom/components/code-snippet/src/code-snippet.js +4 -6
- package/es-custom/components/code-snippet/src/code-snippet.js.map +1 -1
- package/es-custom/components/code-snippet/src/codemirror/theme.js +2 -6
- package/es-custom/components/code-snippet/src/codemirror/theme.js.map +1 -1
- package/es-custom/components/code-snippet/src/layout-utils.d.ts +1 -3
- package/es-custom/components/code-snippet/src/layout-utils.js.map +1 -1
- package/es-custom/components/conversational-search/index.d.ts +9 -0
- package/es-custom/components/conversational-search/index.js +9 -0
- package/es-custom/components/conversational-search/index.js.map +1 -0
- package/es-custom/components/conversational-search/src/citation-utils.d.ts +24 -0
- package/es-custom/components/conversational-search/src/citation-utils.js +46 -0
- package/es-custom/components/conversational-search/src/citation-utils.js.map +1 -0
- package/es-custom/components/conversational-search/src/conversational-search-shell.d.ts +41 -0
- package/es-custom/components/conversational-search/src/conversational-search-shell.js +116 -0
- package/es-custom/components/conversational-search/src/conversational-search-shell.js.map +1 -0
- package/es-custom/components/conversational-search/src/conversational-search-shell.scss.js +13 -0
- package/es-custom/components/conversational-search/src/conversational-search-shell.scss.js.map +1 -0
- package/es-custom/components/file-uploads/src/file-upload-item.js +3 -3
- package/es-custom/components/file-uploads/src/file-upload-item.js.map +1 -1
- package/es-custom/components/launcher/src/launcher.scss.js +1 -1
- package/es-custom/components/markdown/src/markdown-token-tree.d.ts +2 -2
- package/es-custom/components/markdown/src/markdown-token-tree.js.map +1 -1
- package/es-custom/components/prompt-line/index.js +0 -2
- package/es-custom/components/prompt-line/index.js.map +1 -1
- package/es-custom/components/prompt-line/src/autocomplete-controller.js +13 -7
- package/es-custom/components/prompt-line/src/autocomplete-controller.js.map +1 -1
- package/es-custom/components/prompt-line/src/prompt-line-controller.d.ts +1 -1
- package/es-custom/components/prompt-line/src/prompt-line-rich-loader.d.ts +7 -0
- package/es-custom/components/prompt-line/src/prompt-line-rich-loader.js.map +1 -1
- package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.js +8 -2
- package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.js.map +1 -1
- package/es-custom/components/prompt-line/src/prompt-line-shell.d.ts +42 -0
- package/es-custom/components/prompt-line/src/prompt-line-shell.js +43 -1
- package/es-custom/components/prompt-line/src/prompt-line-shell.js.map +1 -1
- package/es-custom/components/prompt-line/src/prompt-line-shell.scss.js +1 -1
- package/es-custom/components/prompt-line/src/prompt-line.d.ts +8 -2
- package/es-custom/components/prompt-line/src/prompt-line.js +70 -10
- package/es-custom/components/prompt-line/src/prompt-line.js.map +1 -1
- package/es-custom/components/prompt-line/src/tiptap/index.d.ts +0 -2
- package/es-custom/components/prompt-line/src/tiptap/index.js +0 -2
- package/es-custom/components/prompt-line/src/tiptap/index.js.map +1 -1
- package/es-custom/components/prompt-line/src/tiptap/resolve-config-items.d.ts +5 -1
- package/es-custom/components/prompt-line/src/tiptap/resolve-config-items.js +9 -0
- package/es-custom/components/prompt-line/src/tiptap/resolve-config-items.js.map +1 -1
- package/es-custom/components/reasoning-steps/src/reasoning-step.js +2 -2
- package/es-custom/components/reasoning-steps/src/reasoning-step.js.map +1 -1
- package/es-custom/components/reasoning-steps/src/reasoning-step.scss.js +1 -1
- package/es-custom/components/shared/dynamic-css-var-sheet.js +7 -6
- package/es-custom/components/shared/dynamic-css-var-sheet.js.map +1 -1
- package/es-custom/components/table/src/table.js +5 -7
- package/es-custom/components/table/src/table.js.map +1 -1
- package/es-custom/components/workspace-shell/src/workspace-shell.js +15 -5
- package/es-custom/components/workspace-shell/src/workspace-shell.js.map +1 -1
- package/es-custom/components/workspace-shell/src/workspace-shell.scss.js +1 -1
- package/es-custom/globals/utils/iconTransform.d.ts +1 -1
- package/es-custom/globals/utils/iconTransform.js.map +1 -1
- package/es-custom/react/chat-shell.js +3 -0
- package/es-custom/react/chat-shell.js.map +1 -1
- package/es-custom/react/conversational-search-shell.d.ts +12 -0
- package/es-custom/react/conversational-search-shell.js +32 -0
- package/es-custom/react/conversational-search-shell.js.map +1 -0
- package/package.json +9 -9
- package/telemetry.yml +6 -4
|
@@ -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\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,sBAAsB,CAAA;AA0CjC,IAAA,WAAA,CAAY,OAAsC,EAAA;QAjC1C,IAAA,CAAA,QAAQ,GAAoC,IAAI;QAChD,IAAA,CAAA,MAAM,GAAqB,EAAE;AAErC;;;;AAIG;QACK,IAAA,CAAA,WAAW,GAA6B,IAAI;AAEpD;;;;;AAKG;QACK,IAAA,CAAA,YAAY,GAAuB,IAAI;AAE/C;;;;;AAKG;QACK,IAAA,CAAA,eAAe,GAAuB,IAAI;AAElD;;;AAGG;QACK,IAAA,CAAA,aAAa,GAAG,CAAC;QACjB,IAAA,CAAA,UAAU,GAAG,KAAK;AAmTlB,QAAA,IAAA,CAAA,oBAAoB,GAAG,CAAC,KAAoB,KAAU;AAC5D,YAAA,IACE,KAAK,CAAC,GAAG,KAAK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M,YAAY,WAAW;AAC7B,YAAA,MAAM,CAAC,OAAO,KAAK,wBAAwB,EAC3C;AACA,YAAA,OAAO,MAAsC;QAC/C;IACF;AACA,IAAA,OAAO,IAAI;AACb;AAEA;;;;;;AAMG;AACG,SAAU,aAAa,CAAC,IAAsB,EAAA;IAIlD,MAAM,KAAK,GAAqB,EAAE;AAClC,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA+B;IACvD,MAAM,UAAU,GAAa,EAAE;AAE/B,IAAA,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;AACvB,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;AACjB,YAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAChB;QACF;QACA,IAAI,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;QACtC,IAAI,CAAC,KAAK,EAAE;AACV,YAAA,KAAK,GAAG;gBACN,EAAE,EAAE,IAAI,CAAC,OAAO;AAChB,gBAAA,KAAK,EAAE,IAAI,CAAC,UAAU,IAAI,EAAE;AAC5B,gBAAA,KAAK,EAAE,EAAE;aACV;YACD,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,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;;"}
|
|
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 const { key } = event;\n const whitelist = [\n 'ArrowUp',\n 'ArrowDown',\n 'Tab',\n 'Enter',\n 'Escape',\n 'Home',\n 'End',\n ];\n\n if (!whitelist.includes(key)) {\n return;\n }\n\n const listEl = this._listElement;\n\n if (!listEl || !this._trigger) {\n return;\n }\n\n if (key === 'Enter') {\n const navigated = isNavigableListElement(listEl)\n ? listEl.hasNavigated()\n : true;\n\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,\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,sBAAsB,CAAA;AA0CjC,IAAA,WAAA,CAAY,OAAsC,EAAA;QAjC1C,IAAA,CAAA,QAAQ,GAAoC,IAAI;QAChD,IAAA,CAAA,MAAM,GAAqB,EAAE;AAErC;;;;AAIG;QACK,IAAA,CAAA,WAAW,GAA6B,IAAI;AAEpD;;;;;AAKG;QACK,IAAA,CAAA,YAAY,GAAuB,IAAI;AAE/C;;;;;AAKG;QACK,IAAA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;aAC5B,MAAM,CAAC,CAAC,CAAC,KAA+B,CAAC,KAAK,SAAS,CAAC;KAC5D;AACH;;"}
|
|
@@ -74,7 +74,7 @@ export interface PromptLineController {
|
|
|
74
74
|
/** Live Tiptap editor, or `null` in textarea mode. */
|
|
75
75
|
getEditor(): Editor | null;
|
|
76
76
|
/** Accepts `keyboardFocus`, which when true specifies that a focus ring should be visible around the prompt line text area */
|
|
77
|
-
focus(keyboardFocus: boolean): void;
|
|
77
|
+
focus(keyboardFocus: boolean, synchronous?: boolean): void;
|
|
78
78
|
blur(): void;
|
|
79
79
|
hasFocus(): boolean;
|
|
80
80
|
/** Selection as plain-text offsets (used for seamless transfer). */
|
|
@@ -13,6 +13,13 @@
|
|
|
13
13
|
* bundle, and the synchronous `getRichRuntimeIfLoaded()` lets the shell mount
|
|
14
14
|
* the rich editor on first paint (no textarea→editor flash) once the chunk has
|
|
15
15
|
* been warmed via {@link preloadPromptLineRich}.
|
|
16
|
+
*
|
|
17
|
+
* **Preservation rule:** the eager barrel (`tiptap/index.ts`) must never
|
|
18
|
+
* statically import from `@tiptap/*`. Any such import would appear as a
|
|
19
|
+
* side-effect import in the published entry and pull Tiptap into every
|
|
20
|
+
* consumer's bundle, including lite-mode hosts that never load the rich
|
|
21
|
+
* runtime. All `@tiptap/*` imports belong in this lazy chunk
|
|
22
|
+
* (`prompt-line-rich-runtime.ts`) or modules it imports.
|
|
16
23
|
*/
|
|
17
24
|
type RichRuntimeModule = typeof import('./prompt-line-rich-runtime.js');
|
|
18
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-line-rich-loader.js","sources":["../../../../src/components/prompt-line/src/prompt-line-rich-loader.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 * Lazy loader for the prompt-line's Tiptap runtime. Mirrors\n * [../../code-snippet/src/codemirror/codemirror-loader.ts]: the dynamic\n * `import()` is the split point that keeps `@tiptap/*` out of the default\n * bundle, and the synchronous `getRichRuntimeIfLoaded()` lets the shell mount\n * the rich editor on first paint (no textarea→editor flash) once the chunk has\n * been warmed via {@link preloadPromptLineRich}.\n */\n\ntype RichRuntimeModule = typeof import('./prompt-line-rich-runtime.js');\n\nlet runtimePromise: Promise<RichRuntimeModule> | null = null;\nlet runtime: RichRuntimeModule | null = null;\n\n/**\n * Load (once) the Tiptap runtime chunk. Resolves to `null` outside a browser\n * so server entries never pull Tiptap.\n */\nexport function loadRichRuntime(): Promise<RichRuntimeModule | null> {\n if (typeof window === 'undefined') {\n return Promise.resolve(null);\n }\n if (!runtimePromise) {\n runtimePromise = import('./prompt-line-rich-runtime.js').then((module) => {\n runtime = module;\n return module;\n });\n // Don't memoize a rejection: `ensureEditor()` clears its shared promise on\n // failure so callers can retry, and the retry must reach a fresh import().\n runtimePromise.catch(() => {\n runtimePromise = null;\n });\n }\n return runtimePromise;\n}\n\n/**\n * The runtime module if it has already loaded, else `null`. Synchronous so the\n * shell can decide to mount rich directly on first render.\n */\nexport function getRichRuntimeIfLoaded(): RichRuntimeModule | null {\n return runtime;\n}\n\n/**\n * Warm the Tiptap runtime chunk ahead of render. `@carbon/ai-chat` calls this\n * during boot when the configured editor mode resolves to rich, so the\n * prompt-line mounts in its final mode before the chat leaves hydration.\n */\nexport function preloadPromptLineRich(): Promise<unknown> {\n return loadRichRuntime();\n}\n\nexport type { RichRuntimeModule };\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;
|
|
1
|
+
{"version":3,"file":"prompt-line-rich-loader.js","sources":["../../../../src/components/prompt-line/src/prompt-line-rich-loader.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 * Lazy loader for the prompt-line's Tiptap runtime. Mirrors\n * [../../code-snippet/src/codemirror/codemirror-loader.ts]: the dynamic\n * `import()` is the split point that keeps `@tiptap/*` out of the default\n * bundle, and the synchronous `getRichRuntimeIfLoaded()` lets the shell mount\n * the rich editor on first paint (no textarea→editor flash) once the chunk has\n * been warmed via {@link preloadPromptLineRich}.\n *\n * **Preservation rule:** the eager barrel (`tiptap/index.ts`) must never\n * statically import from `@tiptap/*`. Any such import would appear as a\n * side-effect import in the published entry and pull Tiptap into every\n * consumer's bundle, including lite-mode hosts that never load the rich\n * runtime. All `@tiptap/*` imports belong in this lazy chunk\n * (`prompt-line-rich-runtime.ts`) or modules it imports.\n */\n\ntype RichRuntimeModule = typeof import('./prompt-line-rich-runtime.js');\n\nlet runtimePromise: Promise<RichRuntimeModule> | null = null;\nlet runtime: RichRuntimeModule | null = null;\n\n/**\n * Load (once) the Tiptap runtime chunk. Resolves to `null` outside a browser\n * so server entries never pull Tiptap.\n */\nexport function loadRichRuntime(): Promise<RichRuntimeModule | null> {\n if (typeof window === 'undefined') {\n return Promise.resolve(null);\n }\n if (!runtimePromise) {\n runtimePromise = import('./prompt-line-rich-runtime.js').then((module) => {\n runtime = module;\n return module;\n });\n // Don't memoize a rejection: `ensureEditor()` clears its shared promise on\n // failure so callers can retry, and the retry must reach a fresh import().\n runtimePromise.catch(() => {\n runtimePromise = null;\n });\n }\n return runtimePromise;\n}\n\n/**\n * The runtime module if it has already loaded, else `null`. Synchronous so the\n * shell can decide to mount rich directly on first render.\n */\nexport function getRichRuntimeIfLoaded(): RichRuntimeModule | null {\n return runtime;\n}\n\n/**\n * Warm the Tiptap runtime chunk ahead of render. `@carbon/ai-chat` calls this\n * during boot when the configured editor mode resolves to rich, so the\n * prompt-line mounts in its final mode before the chat leaves hydration.\n */\nexport function preloadPromptLineRich(): Promise<unknown> {\n return loadRichRuntime();\n}\n\nexport type { RichRuntimeModule };\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAoBH,IAAI,cAAc,GAAsC,IAAI;AAC5D,IAAI,OAAO,GAA6B,IAAI;AAE5C;;;AAGG;SACa,eAAe,GAAA;AAC7B,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACjC,QAAA,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;IAC9B;IACA,IAAI,CAAC,cAAc,EAAE;QACnB,cAAc,GAAG,OAAO,+BAA+B,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;YACvE,OAAO,GAAG,MAAM;AAChB,YAAA,OAAO,MAAM;AACf,QAAA,CAAC,CAAC;;;AAGF,QAAA,cAAc,CAAC,KAAK,CAAC,MAAK;YACxB,cAAc,GAAG,IAAI;AACvB,QAAA,CAAC,CAAC;IACJ;AACA,IAAA,OAAO,cAAc;AACvB;AAEA;;;AAGG;SACa,sBAAsB,GAAA;AACpC,IAAA,OAAO,OAAO;AAChB;AAEA;;;;AAIG;SACa,qBAAqB,GAAA;IACnC,OAAO,eAAe,EAAE;AAC1B;;"}
|
|
@@ -168,9 +168,15 @@ class RichController extends MouseFocusController {
|
|
|
168
168
|
getEditor() {
|
|
169
169
|
return this._editor;
|
|
170
170
|
}
|
|
171
|
-
focus(keyboardFocus) {
|
|
171
|
+
focus(keyboardFocus, synchronous = false) {
|
|
172
172
|
this._setNextFocusOrigin(keyboardFocus);
|
|
173
|
-
|
|
173
|
+
if (synchronous) {
|
|
174
|
+
// Reparent restoration must not queue focus that could steal it later.
|
|
175
|
+
this._editor?.view.focus();
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
this._editor?.commands.focus();
|
|
179
|
+
}
|
|
174
180
|
}
|
|
175
181
|
blur() {
|
|
176
182
|
this._editor?.commands.blur();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-line-rich-runtime.js","sources":["../../../../src/components/prompt-line/src/prompt-line-rich-runtime.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 * Tiptap runtime for `<cds-custom-aichat-prompt-line>`'s rich mode. This module is the\n * **only** place the prompt-line stack imports `@tiptap/*` at runtime, and it\n * is reached exclusively through a dynamic `import()` (see\n * [./prompt-line-rich-loader.ts]). A bundler therefore splits Tiptap into its\n * own lazy chunk, keeping it out of the default bundle for chats that never\n * enable advanced input features.\n *\n * `createRichController()` returns a {@link PromptLineController} backed by a\n * Tiptap `Editor`. It installs the Carbon base bundle — schema (`Document` +\n * `Paragraph` + `Text` + `HardBreak`), undo/redo, placeholder, plain-text\n * paste, the chat keymap (`Mod-Enter`/`Escape`), Enter-to-send\n * (`carbonChatEnter`), value-sync, and the typing indicator — and emits the\n * identical\n * `cds-custom-aichat-prompt-*` events so the shell, React wrapper, and `Input`\n * handlers are mode-agnostic.\n */\n\nimport { Editor, type Extension, type JSONContent } from '@tiptap/core';\nimport DocumentNode from '@tiptap/extension-document';\nimport HardBreakNode from '@tiptap/extension-hard-break';\nimport ParagraphNode from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport TextNode from '@tiptap/extension-text';\nimport { UndoRedo } from '@tiptap/extensions';\n\nimport { IS_PHONE } from '../../../globals/utils/browser-utils.js';\nimport { MouseFocusController } from './prompt-line-mouse-focus.js';\nimport type {\n PromptLineController,\n PromptLineControllerInit,\n SetContentUpdater,\n} from './prompt-line-controller.js';\nimport { applyEditorStyles } from './tiptap/editor-styles.js';\nimport { HISTORY_DEFAULTS } from './prompt-line-constants.js';\nimport { writeStarterStorage } from './tiptap/carbon-starter-trigger.js';\nimport {\n areExtensionSetsEquivalent,\n getExtensionSource,\n} from './tiptap/extension-equivalence.js';\nimport { carbonChatEnter } from './tiptap/chat-enter.js';\nimport { Keymap } from './tiptap/keymap.js';\nimport { PlainTextPaste } from './tiptap/plain-text-paste.js';\nimport { TypingIndicator } from './tiptap/typing-indicator.js';\nimport { ValueSync } from './tiptap/value-sync.js';\nimport type { StartersConfig } from './tiptap/types.js';\nimport { textToDoc } from './tiptap/json-utils.js';\nimport { setHostOriginMeta } from './tiptap/origin-meta.js';\n\n/**\n * Tiptap-backed prompt-line controller. Mirrors the editor lifecycle the\n * element owned before the textarea/rich split.\n */\nclass RichController\n extends MouseFocusController\n implements PromptLineController\n{\n private _editor: Editor | null = null;\n private _host: HTMLElement | null = null;\n private _extensions: Extension[] = [];\n /**\n * The set the live editor was built from. `_createEditor` assigns it the same\n * reference as `_extensions`, so the two are normally identical; they diverge\n * only between a `setExtensions` that adopted an equivalent set without\n * rebuilding and the next `_createEditor`. Only `_flushPendingRecreate` needs\n * the distinction: a rebuild withheld for a composition has to be judged\n * against what is installed, not against the set that was pending when the\n * composition began, or a host that changed the config and changed it back\n * loses its undo history for nothing.\n */\n private _installedExtensions: Extension[] = [];\n private _ariaLabel = '';\n private _placeholder = '';\n private _testId = '';\n private _disabled = false;\n private _isComposing = false;\n private _hadFocus = false;\n /** Set when a recreate is withheld during an IME composition. */\n private _pendingRecreate = false;\n private _pendingRecreateTimer: ReturnType<typeof setTimeout> | null = null;\n\n mount(host: HTMLElement, init: PromptLineControllerInit): void {\n this._host = host;\n this._extensions = init.extensions ?? [];\n this._ariaLabel = init.ariaLabel;\n this._placeholder = init.placeholder;\n this._testId = init.testId;\n this._disabled = init.disabled;\n\n host.setAttribute('aria-multiline', 'true');\n host.setAttribute('spellcheck', 'true');\n host.setAttribute('tabindex', '-1');\n\n // Pointer/touch before focus marks the next focus as mouse-driven so we\n // suppress the keyboard-focus outline.\n this._attachMouseFocusListeners(host);\n\n // Prefer a structured `content` seed (mentions / custom nodes); otherwise\n // rebuild a doc from the plain-text value (lossless from the textarea).\n const seed = init.content ?? textToDoc(init.value);\n this._editor = this._createEditor(host, seed);\n this._wireEditorEvents(this._editor);\n applyEditorStyles(this._editor.view.dom as HTMLElement, IS_PHONE);\n this._applyTestIdToEditorDom();\n this._editor.setEditable(!this._disabled);\n }\n\n destroy(): void {\n const host = this._host;\n if (host) {\n this._detachMouseFocusListeners(host);\n }\n if (this._pendingRecreateTimer) {\n clearTimeout(this._pendingRecreateTimer);\n this._pendingRecreateTimer = null;\n }\n this._isComposing = false;\n this._hadFocus = false;\n this._pendingRecreate = false;\n this._editor?.destroy();\n this._editor = null;\n this._host = null;\n }\n\n getValue(): string {\n return this._editor?.getText() ?? '';\n }\n\n setContent(next: JSONContent | string | SetContentUpdater): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n if (typeof next === 'function') {\n const prev = editor.getJSON();\n this._dispatchSetContent((next as SetContentUpdater)(prev));\n return;\n }\n this._dispatchSetContent(next);\n }\n\n insertContent(\n content: JSONContent | string,\n opts: { at?: number } = {}\n ): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n if (typeof opts.at === 'number') {\n editor.commands.insertContentAt(opts.at, content);\n return;\n }\n editor.commands.insertContent(content);\n }\n\n clearContent(): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n // Tag the clear as host-origin so the carbon-mention/command removal plugin\n // treats the post-send wipe as programmatic (not a user edit) and skips\n // firing `onRemove`. Otherwise a send would strip the just-captured\n // mention/command fields from the host's structured_data sidecar before\n // `doSend` merges them. Mirrors `_dispatchSetContent`.\n editor\n .chain()\n .command(({ tr }) => {\n setHostOriginMeta(tr);\n return true;\n })\n .clearContent(true)\n .run();\n }\n\n getEditor(): Editor | null {\n return this._editor;\n }\n\n focus(keyboardFocus: boolean): void {\n this._setNextFocusOrigin(keyboardFocus);\n this._editor?.commands.focus();\n }\n\n blur(): void {\n this._editor?.commands.blur();\n }\n\n hasFocus(): boolean {\n return this._editor?.isFocused ?? false;\n }\n\n getSelection(): { from: number; to: number } {\n const sel = this._editor?.state.selection;\n return sel ? { from: sel.from, to: sel.to } : { from: 0, to: 0 };\n }\n\n setTextSelection(pos: number | { from: number; to: number }): void {\n this._editor?.commands.setTextSelection(pos);\n }\n\n selectAll(): void {\n this._editor?.commands.selectAll();\n }\n\n setEditable(editable: boolean): void {\n this._disabled = !editable;\n this._editor?.setEditable(editable);\n }\n\n setPlaceholder(placeholder: string): void {\n this._placeholder = placeholder;\n // The Placeholder extension reads this back through the resolver installed\n // in `_createEditor`; the empty transaction repaints the decoration so the\n // new text shows without waiting for the next edit.\n const editor = this._editor;\n if (editor) {\n editor.view.dispatch(editor.state.tr);\n }\n }\n\n setAriaLabel(ariaLabel: string): void {\n this._ariaLabel = ariaLabel;\n }\n\n setTestId(testId: string): void {\n this._testId = testId;\n this._applyTestIdToEditorDom();\n }\n\n setExtensions(extensions: Extension[]): void {\n const equivalent = areExtensionSetsEquivalent(this._extensions, extensions);\n // Adopt the new list either way — a later genuine change is compared\n // against what the host most recently supplied.\n this._extensions = extensions;\n if (equivalent) {\n // Starter items / isOn ride on extension storage precisely so they can be\n // swapped without a recreate.\n this._syncStarterStorage();\n return;\n }\n this._recreateEditor();\n }\n\n setComposing(composing: boolean): void {\n this._isComposing = composing;\n if (composing || !this._pendingRecreate || this._pendingRecreateTimer) {\n return;\n }\n // ProseMirror defers the last composed segment to a microtask after\n // compositionend, so recreating here would snapshot the doc without it and\n // lose the character the user just committed. A macrotask runs after that\n // flush.\n this._pendingRecreateTimer = setTimeout(() => {\n this._pendingRecreateTimer = null;\n this._flushPendingRecreate();\n });\n }\n\n /** Push the current starter config onto the live editor's storage. */\n private _syncStarterStorage(): void {\n const source = this._extensions\n .map(getExtensionSource)\n .find((descriptor) => descriptor?.kind === 'starters');\n const config = source?.config as StartersConfig | undefined;\n if (!config) {\n return;\n }\n writeStarterStorage(this._editor, {\n items: config.items,\n isOn: config.isOn !== false,\n });\n }\n\n undo(): boolean {\n return Boolean(this._editor?.commands.undo());\n }\n\n redo(): boolean {\n return Boolean(this._editor?.commands.redo());\n }\n\n // -------------------------------------------------------------------------\n // Internals\n // -------------------------------------------------------------------------\n\n private _flushPendingRecreate(): void {\n // A fresh composition may have started while the flush was queued; its own\n // compositionend re-queues this. A detached host means the element's own\n // deferred teardown is already pending, so rebuilding would raise an editor\n // only to destroy it a task later.\n if (\n !this._host?.isConnected ||\n !this._pendingRecreate ||\n this._isComposing\n ) {\n return;\n }\n // Compare against what is installed, not the set that was pending when the\n // composition began: a host that changed the config and changed it back has\n // nothing left to rebuild, and rebuilding anyway would drop undo history.\n if (\n areExtensionSetsEquivalent(this._installedExtensions, this._extensions)\n ) {\n this._pendingRecreate = false;\n this._syncStarterStorage();\n return;\n }\n this._recreateEditor();\n }\n\n private _createEditor(\n element: HTMLElement,\n content: JSONContent | string | undefined\n ): Editor {\n const baseExtensions: Extension[] = [\n DocumentNode as unknown as Extension,\n ParagraphNode as unknown as Extension,\n TextNode as unknown as Extension,\n HardBreakNode as unknown as Extension,\n UndoRedo.configure({ ...HISTORY_DEFAULTS }),\n // Resolved per decoration build rather than captured, so `setPlaceholder`\n // lands on the live editor. Tiptap snapshots an extension's options when\n // it builds plugins, so a value here could never be updated in place.\n Placeholder.configure({ placeholder: () => this._placeholder }),\n PlainTextPaste,\n Keymap,\n // Plain Enter sends (non-empty); empty Enter falls through to a newline.\n // Baked into the base bundle so the rich editor and the textarea agree on\n // Enter-to-send without the chat layer wiring it per surface.\n carbonChatEnter(),\n ValueSync,\n TypingIndicator,\n ];\n this._installedExtensions = this._extensions;\n return new Editor({\n element,\n extensions: [...baseExtensions, ...this._extensions],\n editorProps: {\n attributes: () => {\n const attrs: Record<string, string> = { role: 'textbox' };\n if (this._ariaLabel) {\n attrs['aria-label'] = this._ariaLabel;\n }\n if (this._placeholder) {\n attrs['aria-placeholder'] = this._placeholder;\n }\n return attrs;\n },\n },\n content: content ?? undefined,\n autofocus: false,\n injectCSS: false,\n });\n }\n\n private _wireEditorEvents(editor: Editor): void {\n editor.on('focus', () => {\n this._hadFocus = true;\n const wasMouseFocus = this._consumeMouseFocus();\n this._dispatch('cds-custom-aichat-prompt-focus', { keyboard: !wasMouseFocus });\n });\n editor.on('blur', () => {\n this._dispatch('cds-custom-aichat-prompt-blur');\n });\n // Forward keydown for hosts wanting raw-key access. ValueSync /\n // TypingIndicator emit their own events; don't re-dispatch update here.\n editor.view.dom.addEventListener('keydown', (event) => {\n this._dispatch('cds-custom-aichat-prompt-keydown', { originalEvent: event });\n });\n }\n\n private _recreateEditor(): void {\n const host = this._host;\n if (!host) {\n return;\n }\n if (this._isComposing) {\n this._pendingRecreate = true;\n return;\n }\n this._pendingRecreate = false;\n const previousJson = this._editor?.getJSON();\n const previousSelection = this._editor\n ? {\n from: this._editor.state.selection.from,\n to: this._editor.state.selection.to,\n }\n : null;\n const wasFocused = this._hadFocus;\n const wasKeyboardFocus = this.getKeyboardFocus();\n this._editor?.destroy();\n this._editor = this._createEditor(host, previousJson);\n this._wireEditorEvents(this._editor);\n applyEditorStyles(this._editor.view.dom as HTMLElement, IS_PHONE);\n this._applyTestIdToEditorDom();\n this._editor.setEditable(!this._disabled);\n if (previousSelection) {\n const { size } = this._editor.state.doc.content;\n const from = Math.min(previousSelection.from, size);\n const to = Math.min(previousSelection.to, size);\n this._editor.commands.setTextSelection({ from, to });\n }\n\n if (wasFocused) {\n this.focus(wasKeyboardFocus);\n }\n }\n\n private _dispatchSetContent(content: JSONContent | string): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n // Chain a no-op command that meta-tags the accumulator tr as host-origin,\n // then setContent on the same tr so downstream readers (typing-indicator)\n // recognize the update.\n editor\n .chain()\n .command(({ tr }) => {\n setHostOriginMeta(tr);\n return true;\n })\n .setContent(content, { emitUpdate: true })\n .run();\n }\n\n // Mirror testId onto the inner ProseMirror contenteditable (not the host\n // wrapper) so Playwright's editable-action helpers (`.fill()`, etc.) accept\n // it. `view.dom` is replaced on each recreate, so re-apply.\n private _applyTestIdToEditorDom(): void {\n const editorDom = this._editor?.view.dom as HTMLElement | undefined;\n if (!editorDom) {\n return;\n }\n if (this._testId) {\n editorDom.setAttribute('data-testid', this._testId);\n } else {\n editorDom.removeAttribute('data-testid');\n }\n }\n\n private _dispatch(name: string, detail?: unknown): void {\n this._host?.dispatchEvent(\n new CustomEvent(name, { detail, bubbles: true, composed: true })\n );\n }\n}\n\n/**\n * Construct a Tiptap-backed prompt-line controller. Called by the shell once\n * the lazily-imported runtime module has resolved.\n */\nexport function createRichController(): PromptLineController {\n return new RichController();\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAEH;;;;;;;;;;;;;;;;AAgBG;AAiCH;;;AAGG;AACH,MAAM,cACJ,SAAQ,oBAAoB,CAAA;AAD9B,IAAA,WAAA,GAAA;;QAIU,IAAA,CAAA,OAAO,GAAkB,IAAI;QAC7B,IAAA,CAAA,KAAK,GAAuB,IAAI;QAChC,IAAA,CAAA,WAAW,GAAgB,EAAE;AACrC;;;;;;;;;AASG;QACK,IAAA,CAAA,oBAAoB,GAAgB,EAAE;QACtC,IAAA,CAAA,UAAU,GAAG,EAAE;QACf,IAAA,CAAA,YAAY,GAAG,EAAE;QACjB,IAAA,CAAA,OAAO,GAAG,EAAE;QACZ,IAAA,CAAA,SAAS,GAAG,KAAK;QACjB,IAAA,CAAA,YAAY,GAAG,KAAK;QACpB,IAAA,CAAA,SAAS,GAAG,KAAK;;QAEjB,IAAA,CAAA,gBAAgB,GAAG,KAAK;QACxB,IAAA,CAAA,qBAAqB,GAAyC,IAAI;IAiX5E;IA/WE,KAAK,CAAC,IAAiB,EAAE,IAA8B,EAAA;AACrD,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI;QACjB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE;AACxC,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS;AAChC,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW;AACpC,QAAA,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM;AAC1B,QAAA,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ;AAE9B,QAAA,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,MAAM,CAAC;AAC3C,QAAA,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,MA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;YACX;QACF;;;;QAIA;AACG,aAAA,KAAK;AACL,aAAA,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,KAAI;YAClB,iBAAiB,CAAC,EAAE,CAAC;AACrB,YAAA,OAAO,IAAI;AACb,QAAA,CAAC;aACA,UAAU,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;AACxC,aAAA,GAAG,EAAE;IACV;;;;IAKQ,uBAAuB,GAAA;QAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,GAA8B;QACnE,IAAI,CAAC,SAAS,EAAE;YACd;QACF;AACA,QAAA,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,SAAS,CAAC,YAAY,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC;QACrD;aAAO;AACL,YAAA,SAAS,CAAC,eAAe,CAAC,aAAa,CAAC;QAC1C;IACF;IAEQ,SAAS,CAAC,IAAY,EAAE,MAAgB,EAAA;QAC9C,IAAI,CAAC,KAAK,EAAE,aAAa,CACvB,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CACjE;IACH;AACD;AAED;;;AAGG;SACa,oBAAoB,GAAA;IAClC,OAAO,IAAI,cAAc,EAAE;AAC7B;;"}
|
|
1
|
+
{"version":3,"file":"prompt-line-rich-runtime.js","sources":["../../../../src/components/prompt-line/src/prompt-line-rich-runtime.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 * Tiptap runtime for `<cds-custom-aichat-prompt-line>`'s rich mode. This module is the\n * **only** place the prompt-line stack imports `@tiptap/*` at runtime, and it\n * is reached exclusively through a dynamic `import()` (see\n * [./prompt-line-rich-loader.ts]). A bundler therefore splits Tiptap into its\n * own lazy chunk, keeping it out of the default bundle for chats that never\n * enable advanced input features.\n *\n * `createRichController()` returns a {@link PromptLineController} backed by a\n * Tiptap `Editor`. It installs the Carbon base bundle — schema (`Document` +\n * `Paragraph` + `Text` + `HardBreak`), undo/redo, placeholder, plain-text\n * paste, the chat keymap (`Mod-Enter`/`Escape`), Enter-to-send\n * (`carbonChatEnter`), value-sync, and the typing indicator — and emits the\n * identical\n * `cds-custom-aichat-prompt-*` events so the shell, React wrapper, and `Input`\n * handlers are mode-agnostic.\n */\n\nimport { Editor, type Extension, type JSONContent } from '@tiptap/core';\nimport DocumentNode from '@tiptap/extension-document';\nimport HardBreakNode from '@tiptap/extension-hard-break';\nimport ParagraphNode from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport TextNode from '@tiptap/extension-text';\nimport { UndoRedo } from '@tiptap/extensions';\n\nimport { IS_PHONE } from '../../../globals/utils/browser-utils.js';\nimport { MouseFocusController } from './prompt-line-mouse-focus.js';\nimport type {\n PromptLineController,\n PromptLineControllerInit,\n SetContentUpdater,\n} from './prompt-line-controller.js';\nimport { applyEditorStyles } from './tiptap/editor-styles.js';\nimport { HISTORY_DEFAULTS } from './prompt-line-constants.js';\nimport { writeStarterStorage } from './tiptap/carbon-starter-trigger.js';\nimport {\n areExtensionSetsEquivalent,\n getExtensionSource,\n} from './tiptap/extension-equivalence.js';\nimport { carbonChatEnter } from './tiptap/chat-enter.js';\nimport { Keymap } from './tiptap/keymap.js';\nimport { PlainTextPaste } from './tiptap/plain-text-paste.js';\nimport { TypingIndicator } from './tiptap/typing-indicator.js';\nimport { ValueSync } from './tiptap/value-sync.js';\nimport type { StartersConfig } from './tiptap/types.js';\nimport { textToDoc } from './tiptap/json-utils.js';\nimport { setHostOriginMeta } from './tiptap/origin-meta.js';\n\n/**\n * Tiptap-backed prompt-line controller. Mirrors the editor lifecycle the\n * element owned before the textarea/rich split.\n */\nclass RichController\n extends MouseFocusController\n implements PromptLineController\n{\n private _editor: Editor | null = null;\n private _host: HTMLElement | null = null;\n private _extensions: Extension[] = [];\n /**\n * The set the live editor was built from. `_createEditor` assigns it the same\n * reference as `_extensions`, so the two are normally identical; they diverge\n * only between a `setExtensions` that adopted an equivalent set without\n * rebuilding and the next `_createEditor`. Only `_flushPendingRecreate` needs\n * the distinction: a rebuild withheld for a composition has to be judged\n * against what is installed, not against the set that was pending when the\n * composition began, or a host that changed the config and changed it back\n * loses its undo history for nothing.\n */\n private _installedExtensions: Extension[] = [];\n private _ariaLabel = '';\n private _placeholder = '';\n private _testId = '';\n private _disabled = false;\n private _isComposing = false;\n private _hadFocus = false;\n /** Set when a recreate is withheld during an IME composition. */\n private _pendingRecreate = false;\n private _pendingRecreateTimer: ReturnType<typeof setTimeout> | null = null;\n\n mount(host: HTMLElement, init: PromptLineControllerInit): void {\n this._host = host;\n this._extensions = init.extensions ?? [];\n this._ariaLabel = init.ariaLabel;\n this._placeholder = init.placeholder;\n this._testId = init.testId;\n this._disabled = init.disabled;\n\n host.setAttribute('aria-multiline', 'true');\n host.setAttribute('spellcheck', 'true');\n host.setAttribute('tabindex', '-1');\n\n // Pointer/touch before focus marks the next focus as mouse-driven so we\n // suppress the keyboard-focus outline.\n this._attachMouseFocusListeners(host);\n\n // Prefer a structured `content` seed (mentions / custom nodes); otherwise\n // rebuild a doc from the plain-text value (lossless from the textarea).\n const seed = init.content ?? textToDoc(init.value);\n this._editor = this._createEditor(host, seed);\n this._wireEditorEvents(this._editor);\n applyEditorStyles(this._editor.view.dom as HTMLElement, IS_PHONE);\n this._applyTestIdToEditorDom();\n this._editor.setEditable(!this._disabled);\n }\n\n destroy(): void {\n const host = this._host;\n if (host) {\n this._detachMouseFocusListeners(host);\n }\n if (this._pendingRecreateTimer) {\n clearTimeout(this._pendingRecreateTimer);\n this._pendingRecreateTimer = null;\n }\n this._isComposing = false;\n this._hadFocus = false;\n this._pendingRecreate = false;\n this._editor?.destroy();\n this._editor = null;\n this._host = null;\n }\n\n getValue(): string {\n return this._editor?.getText() ?? '';\n }\n\n setContent(next: JSONContent | string | SetContentUpdater): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n if (typeof next === 'function') {\n const prev = editor.getJSON();\n this._dispatchSetContent((next as SetContentUpdater)(prev));\n return;\n }\n this._dispatchSetContent(next);\n }\n\n insertContent(\n content: JSONContent | string,\n opts: { at?: number } = {}\n ): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n if (typeof opts.at === 'number') {\n editor.commands.insertContentAt(opts.at, content);\n return;\n }\n editor.commands.insertContent(content);\n }\n\n clearContent(): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n // Tag the clear as host-origin so the carbon-mention/command removal plugin\n // treats the post-send wipe as programmatic (not a user edit) and skips\n // firing `onRemove`. Otherwise a send would strip the just-captured\n // mention/command fields from the host's structured_data sidecar before\n // `doSend` merges them. Mirrors `_dispatchSetContent`.\n editor\n .chain()\n .command(({ tr }) => {\n setHostOriginMeta(tr);\n return true;\n })\n .clearContent(true)\n .run();\n }\n\n getEditor(): Editor | null {\n return this._editor;\n }\n\n focus(keyboardFocus: boolean, synchronous = false): void {\n this._setNextFocusOrigin(keyboardFocus);\n if (synchronous) {\n // Reparent restoration must not queue focus that could steal it later.\n this._editor?.view.focus();\n } else {\n this._editor?.commands.focus();\n }\n }\n\n blur(): void {\n this._editor?.commands.blur();\n }\n\n hasFocus(): boolean {\n return this._editor?.isFocused ?? false;\n }\n\n getSelection(): { from: number; to: number } {\n const sel = this._editor?.state.selection;\n return sel ? { from: sel.from, to: sel.to } : { from: 0, to: 0 };\n }\n\n setTextSelection(pos: number | { from: number; to: number }): void {\n this._editor?.commands.setTextSelection(pos);\n }\n\n selectAll(): void {\n this._editor?.commands.selectAll();\n }\n\n setEditable(editable: boolean): void {\n this._disabled = !editable;\n this._editor?.setEditable(editable);\n }\n\n setPlaceholder(placeholder: string): void {\n this._placeholder = placeholder;\n // The Placeholder extension reads this back through the resolver installed\n // in `_createEditor`; the empty transaction repaints the decoration so the\n // new text shows without waiting for the next edit.\n const editor = this._editor;\n if (editor) {\n editor.view.dispatch(editor.state.tr);\n }\n }\n\n setAriaLabel(ariaLabel: string): void {\n this._ariaLabel = ariaLabel;\n }\n\n setTestId(testId: string): void {\n this._testId = testId;\n this._applyTestIdToEditorDom();\n }\n\n setExtensions(extensions: Extension[]): void {\n const equivalent = areExtensionSetsEquivalent(this._extensions, extensions);\n // Adopt the new list either way — a later genuine change is compared\n // against what the host most recently supplied.\n this._extensions = extensions;\n if (equivalent) {\n // Starter items / isOn ride on extension storage precisely so they can be\n // swapped without a recreate.\n this._syncStarterStorage();\n return;\n }\n this._recreateEditor();\n }\n\n setComposing(composing: boolean): void {\n this._isComposing = composing;\n if (composing || !this._pendingRecreate || this._pendingRecreateTimer) {\n return;\n }\n // ProseMirror defers the last composed segment to a microtask after\n // compositionend, so recreating here would snapshot the doc without it and\n // lose the character the user just committed. A macrotask runs after that\n // flush.\n this._pendingRecreateTimer = setTimeout(() => {\n this._pendingRecreateTimer = null;\n this._flushPendingRecreate();\n });\n }\n\n /** Push the current starter config onto the live editor's storage. */\n private _syncStarterStorage(): void {\n const source = this._extensions\n .map(getExtensionSource)\n .find((descriptor) => descriptor?.kind === 'starters');\n const config = source?.config as StartersConfig | undefined;\n if (!config) {\n return;\n }\n writeStarterStorage(this._editor, {\n items: config.items,\n isOn: config.isOn !== false,\n });\n }\n\n undo(): boolean {\n return Boolean(this._editor?.commands.undo());\n }\n\n redo(): boolean {\n return Boolean(this._editor?.commands.redo());\n }\n\n // -------------------------------------------------------------------------\n // Internals\n // -------------------------------------------------------------------------\n\n private _flushPendingRecreate(): void {\n // A fresh composition may have started while the flush was queued; its own\n // compositionend re-queues this. A detached host means the element's own\n // deferred teardown is already pending, so rebuilding would raise an editor\n // only to destroy it a task later.\n if (\n !this._host?.isConnected ||\n !this._pendingRecreate ||\n this._isComposing\n ) {\n return;\n }\n // Compare against what is installed, not the set that was pending when the\n // composition began: a host that changed the config and changed it back has\n // nothing left to rebuild, and rebuilding anyway would drop undo history.\n if (\n areExtensionSetsEquivalent(this._installedExtensions, this._extensions)\n ) {\n this._pendingRecreate = false;\n this._syncStarterStorage();\n return;\n }\n this._recreateEditor();\n }\n\n private _createEditor(\n element: HTMLElement,\n content: JSONContent | string | undefined\n ): Editor {\n const baseExtensions: Extension[] = [\n DocumentNode as unknown as Extension,\n ParagraphNode as unknown as Extension,\n TextNode as unknown as Extension,\n HardBreakNode as unknown as Extension,\n UndoRedo.configure({ ...HISTORY_DEFAULTS }),\n // Resolved per decoration build rather than captured, so `setPlaceholder`\n // lands on the live editor. Tiptap snapshots an extension's options when\n // it builds plugins, so a value here could never be updated in place.\n Placeholder.configure({ placeholder: () => this._placeholder }),\n PlainTextPaste,\n Keymap,\n // Plain Enter sends (non-empty); empty Enter falls through to a newline.\n // Baked into the base bundle so the rich editor and the textarea agree on\n // Enter-to-send without the chat layer wiring it per surface.\n carbonChatEnter(),\n ValueSync,\n TypingIndicator,\n ];\n this._installedExtensions = this._extensions;\n return new Editor({\n element,\n extensions: [...baseExtensions, ...this._extensions],\n editorProps: {\n attributes: () => {\n const attrs: Record<string, string> = { role: 'textbox' };\n if (this._ariaLabel) {\n attrs['aria-label'] = this._ariaLabel;\n }\n if (this._placeholder) {\n attrs['aria-placeholder'] = this._placeholder;\n }\n return attrs;\n },\n },\n content: content ?? undefined,\n autofocus: false,\n injectCSS: false,\n });\n }\n\n private _wireEditorEvents(editor: Editor): void {\n editor.on('focus', () => {\n this._hadFocus = true;\n const wasMouseFocus = this._consumeMouseFocus();\n this._dispatch('cds-custom-aichat-prompt-focus', { keyboard: !wasMouseFocus });\n });\n editor.on('blur', () => {\n this._dispatch('cds-custom-aichat-prompt-blur');\n });\n // Forward keydown for hosts wanting raw-key access. ValueSync /\n // TypingIndicator emit their own events; don't re-dispatch update here.\n editor.view.dom.addEventListener('keydown', (event) => {\n this._dispatch('cds-custom-aichat-prompt-keydown', { originalEvent: event });\n });\n }\n\n private _recreateEditor(): void {\n const host = this._host;\n if (!host) {\n return;\n }\n if (this._isComposing) {\n this._pendingRecreate = true;\n return;\n }\n this._pendingRecreate = false;\n const previousJson = this._editor?.getJSON();\n const previousSelection = this._editor\n ? {\n from: this._editor.state.selection.from,\n to: this._editor.state.selection.to,\n }\n : null;\n const wasFocused = this._hadFocus;\n const wasKeyboardFocus = this.getKeyboardFocus();\n this._editor?.destroy();\n this._editor = this._createEditor(host, previousJson);\n this._wireEditorEvents(this._editor);\n applyEditorStyles(this._editor.view.dom as HTMLElement, IS_PHONE);\n this._applyTestIdToEditorDom();\n this._editor.setEditable(!this._disabled);\n if (previousSelection) {\n const { size } = this._editor.state.doc.content;\n const from = Math.min(previousSelection.from, size);\n const to = Math.min(previousSelection.to, size);\n this._editor.commands.setTextSelection({ from, to });\n }\n\n if (wasFocused) {\n this.focus(wasKeyboardFocus);\n }\n }\n\n private _dispatchSetContent(content: JSONContent | string): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n // Chain a no-op command that meta-tags the accumulator tr as host-origin,\n // then setContent on the same tr so downstream readers (typing-indicator)\n // recognize the update.\n editor\n .chain()\n .command(({ tr }) => {\n setHostOriginMeta(tr);\n return true;\n })\n .setContent(content, { emitUpdate: true })\n .run();\n }\n\n // Mirror testId onto the inner ProseMirror contenteditable (not the host\n // wrapper) so Playwright's editable-action helpers (`.fill()`, etc.) accept\n // it. `view.dom` is replaced on each recreate, so re-apply.\n private _applyTestIdToEditorDom(): void {\n const editorDom = this._editor?.view.dom as HTMLElement | undefined;\n if (!editorDom) {\n return;\n }\n if (this._testId) {\n editorDom.setAttribute('data-testid', this._testId);\n } else {\n editorDom.removeAttribute('data-testid');\n }\n }\n\n private _dispatch(name: string, detail?: unknown): void {\n this._host?.dispatchEvent(\n new CustomEvent(name, { detail, bubbles: true, composed: true })\n );\n }\n}\n\n/**\n * Construct a Tiptap-backed prompt-line controller. Called by the shell once\n * the lazily-imported runtime module has resolved.\n */\nexport function createRichController(): PromptLineController {\n return new RichController();\n}\n"],"names":[],"mappings":";;;;;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MAAM,EAAE;YACX;QACF;;;;QAIA;AACG,aAAA,KAAK;AACL,aAAA,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,KAAI;YAClB,iBAAiB,CAAC,EAAE,CAAC;AACrB,YAAA,OAAO,IAAI;AACb,QAAA,CAAC;aACA,UAAU,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;AACxC,aAAA,GAAG,EAAE;IACV;;;;IAKQ,uBAAuB,GAAA;QAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,GAA8B;QACnE,IAAI,CAAC,SAAS,EAAE;YACd;QACF;AACA,QAAA,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,SAAS,CAAC,YAAY,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC;QACrD;aAAO;AACL,YAAA,SAAS,CAAC,eAAe,CAAC,aAAa,CAAC;QAC1C;IACF;IAEQ,SAAS,CAAC,IAAY,EAAE,MAAgB,EAAA;QAC9C,IAAI,CAAC,KAAK,EAAE,aAAa,CACvB,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CACjE;IACH;AACD;AAED;;;AAGG;SACa,oBAAoB,GAAA;IAClC,OAAO,IAAI,cAAc,EAAE;AAC7B;;"}
|
|
@@ -23,6 +23,48 @@ import { LitElement, type PropertyValues } from 'lit';
|
|
|
23
23
|
* autocomplete row (e.g. char-count exceeded message).
|
|
24
24
|
* - `send-control` — send / stop-streaming button.
|
|
25
25
|
*
|
|
26
|
+
* ## Styling
|
|
27
|
+
*
|
|
28
|
+
* ### CSS part
|
|
29
|
+
*
|
|
30
|
+
* The input container is exposed as a CSS part so external stylesheets can
|
|
31
|
+
* style the resting frame independently of the outer shell:
|
|
32
|
+
*
|
|
33
|
+
* ```css
|
|
34
|
+
* cds-custom-aichat-prompt-line-shell::part(prompt-container) {
|
|
35
|
+
* border: 1px solid var(--cds-border-subtle-01);
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* When embedded inside `cds-custom-aichat-custom-element`, the part is forwarded
|
|
40
|
+
* through the shadow hierarchy and reachable from the outermost host:
|
|
41
|
+
*
|
|
42
|
+
* ```css
|
|
43
|
+
* cds-custom-aichat-custom-element::part(prompt-container) {
|
|
44
|
+
* border: 1px solid var(--cds-border-subtle-01);
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* ### CSS custom property
|
|
49
|
+
*
|
|
50
|
+
* `--cds-aichat-prompt-border` sets the `border` shorthand on the input
|
|
51
|
+
* container. It inherits through shadow boundaries, so any ancestor of the
|
|
52
|
+
* chat host can set it:
|
|
53
|
+
*
|
|
54
|
+
* ```css
|
|
55
|
+
* cds-custom-aichat-custom-element {
|
|
56
|
+
* --cds-aichat-prompt-border: 1px solid var(--cds-border-subtle-01);
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* Or via `layout.customProperties`:
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* layout: { customProperties: { "prompt-border": "1px solid var(--cds-border-subtle-01)" } }
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* The focus outline and error outline are not affected by either hook.
|
|
67
|
+
*
|
|
26
68
|
* @element cds-custom-aichat-prompt-line-shell
|
|
27
69
|
*/
|
|
28
70
|
declare class PromptLineShellElement extends LitElement {
|
|
@@ -37,6 +37,48 @@ import styles from './prompt-line-shell.scss.js';
|
|
|
37
37
|
* autocomplete row (e.g. char-count exceeded message).
|
|
38
38
|
* - `send-control` — send / stop-streaming button.
|
|
39
39
|
*
|
|
40
|
+
* ## Styling
|
|
41
|
+
*
|
|
42
|
+
* ### CSS part
|
|
43
|
+
*
|
|
44
|
+
* The input container is exposed as a CSS part so external stylesheets can
|
|
45
|
+
* style the resting frame independently of the outer shell:
|
|
46
|
+
*
|
|
47
|
+
* ```css
|
|
48
|
+
* cds-custom-aichat-prompt-line-shell::part(prompt-container) {
|
|
49
|
+
* border: 1px solid var(--cds-border-subtle-01);
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* When embedded inside `cds-custom-aichat-custom-element`, the part is forwarded
|
|
54
|
+
* through the shadow hierarchy and reachable from the outermost host:
|
|
55
|
+
*
|
|
56
|
+
* ```css
|
|
57
|
+
* cds-custom-aichat-custom-element::part(prompt-container) {
|
|
58
|
+
* border: 1px solid var(--cds-border-subtle-01);
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* ### CSS custom property
|
|
63
|
+
*
|
|
64
|
+
* `--cds-aichat-prompt-border` sets the `border` shorthand on the input
|
|
65
|
+
* container. It inherits through shadow boundaries, so any ancestor of the
|
|
66
|
+
* chat host can set it:
|
|
67
|
+
*
|
|
68
|
+
* ```css
|
|
69
|
+
* cds-custom-aichat-custom-element {
|
|
70
|
+
* --cds-aichat-prompt-border: 1px solid var(--cds-border-subtle-01);
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* Or via `layout.customProperties`:
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* layout: { customProperties: { "prompt-border": "1px solid var(--cds-border-subtle-01)" } }
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* The focus outline and error outline are not affected by either hook.
|
|
81
|
+
*
|
|
40
82
|
* @element cds-custom-aichat-prompt-line-shell
|
|
41
83
|
*/
|
|
42
84
|
let PromptLineShellElement = class PromptLineShellElement extends LitElement {
|
|
@@ -148,7 +190,7 @@ let PromptLineShellElement = class PromptLineShellElement extends LitElement {
|
|
|
148
190
|
`;
|
|
149
191
|
return html `
|
|
150
192
|
<div class="${prefix}--prompt-line-shell">
|
|
151
|
-
<div class=${classMap(containerClasses)}>
|
|
193
|
+
<div class=${classMap(containerClasses)} part="prompt-container">
|
|
152
194
|
<div class=${classMap(uploadsRowClasses)}>
|
|
153
195
|
<slot
|
|
154
196
|
name="file-uploads"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-line-shell.js","sources":["../../../../src/components/prompt-line/src/prompt-line-shell.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, type PropertyValues, unsafeCSS } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport prefix from '../../../globals/settings.js';\n\nimport styles from './prompt-line-shell.scss?lit';\n\n/**\n * Layout-only composer chrome for the chat input. The shell defines five\n * named slots and the spacing/border treatment around them — it carries no\n * chat-domain logic, builds no Tiptap extensions, and forwards no editor\n * methods.\n *\n * Consumers compose:\n * - `editor` — a `<cds-custom-aichat-prompt-line>` (or equivalent) the consumer\n * owns directly; the shell does not render a fallback.\n * - `message-actions` — action icons to the left of the text area.\n * - `file-uploads` — visual list of files being uploaded.\n * - `autocomplete-content` — suggestion overlay above the input.\n * - `field-messaging` — inline error / status content beneath the\n * autocomplete row (e.g. char-count exceeded message).\n * - `send-control` — send / stop-streaming button.\n *\n * @element cds-custom-aichat-prompt-line-shell\n */\n@carbonElement(`${prefix}-prompt-line-shell`)\nclass PromptLineShellElement extends LitElement {\n static styles = css`\n ${unsafeCSS(styles)}\n `;\n\n /** Reflects to attribute so consumer CSS can target the rounded variant. */\n @property({ type: Boolean, reflect: true })\n rounded = false;\n\n /**\n * Expanded layout: the editor fills its own full-width row, with the\n * message actions and send control on a second row beneath it (actions to\n * the start, send to the end). Reflects so consumer CSS can target the\n * variant. The reflow is driven purely by a container class — the rendered\n * DOM is identical in both modes.\n */\n @property({ type: Boolean, reflect: true })\n expanded = false;\n\n /** Whether the prompt line is in an error state */\n @property({ type: Boolean, reflect: true, attribute: 'has-error' })\n hasError = false;\n\n /** Whether the prompt-line shell is disabled. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n @state()\n private _hasMessageActions = false;\n\n @state()\n private _hasFileUploads = false;\n\n @state()\n private _editorKeyboardFocus = false;\n\n /** Watches the slotted file-uploads element for `has-uploads` attribute changes. */\n private _fileUploadsObserver: MutationObserver | null = null;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\n 'cds-custom-aichat-prompt-focus',\n this._handlePromptFocus as EventListener\n );\n this.addEventListener(\n 'cds-custom-aichat-prompt-blur',\n this._handlePromptBlur as EventListener\n );\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.removeEventListener(\n 'cds-custom-aichat-prompt-focus',\n this._handlePromptFocus as EventListener\n );\n this.removeEventListener(\n 'cds-custom-aichat-prompt-blur',\n this._handlePromptBlur as EventListener\n );\n this._fileUploadsObserver?.disconnect();\n }\n\n override willUpdate(changedProperties: PropertyValues): void {\n super.willUpdate(changedProperties);\n // Derive `--has-message-actions` from the settled slot assignment on every\n // update. A bare `slotchange` snapshot can latch on a transient state: a\n // consumer projecting content asynchronously (web-component slotting) or\n // toggling writeable content at runtime can momentarily present the\n // prompt-line passthrough as real action content, and the settled assignment\n // may not emit a follow-up `slotchange`. Left stale, that keeps the reduced\n // start inset and strands the prompt line once the content is removed.\n // Deriving here (rather than snapshotting in the handler) re-reads the\n // settled assignment each render, so the occupancy can't latch.\n this._updateHasMessageActions();\n this._updateHasFileUploads();\n }\n\n override render() {\n const containerClasses = {\n [`${prefix}--input-container`]: true,\n [`${prefix}--input-container--has-message-actions`]:\n this._hasMessageActions,\n [`${prefix}--input-container--expanded`]: this.expanded,\n };\n\n const uploadsRowClasses = {\n [`${prefix}--input-uploads-and-autocomplete`]: true,\n [`${prefix}--input-uploads-and-autocomplete--has-uploads`]:\n this._hasFileUploads,\n };\n\n const textAreaClasses = {\n [`${prefix}--input-text-area`]: true,\n [`${prefix}--input-text-area--keyboard-focus`]: this._editorKeyboardFocus,\n };\n\n // In expanded mode, render text-area before message-actions to match visual order\n\n const textAreaContent = html`\n <div class=${classMap(textAreaClasses)}>\n <slot name=\"editor\"></slot>\n </div>\n `;\n\n const messageActionsContent = html`\n <slot\n name=\"message-actions\"\n @slotchange=${this._handleMessageActionsSlotChange}></slot>\n `;\n\n return html`\n <div class=\"${prefix}--prompt-line-shell\">\n <div class=${classMap(containerClasses)}>\n <div class=${classMap(uploadsRowClasses)}>\n <slot\n name=\"file-uploads\"\n @slotchange=${this._handleFileUploadsSlotChange}></slot>\n <slot name=\"autocomplete-content\"></slot>\n </div>\n <div class=\"${prefix}--field-messaging-container\">\n <slot name=\"field-messaging\"></slot>\n </div>\n <div class=\"${prefix}--input-text-and-actions\">\n ${this.expanded ? textAreaContent : messageActionsContent}\n ${this.expanded ? messageActionsContent : textAreaContent}\n </div>\n <div class=\"${prefix}--input-send-control-container\">\n <slot name=\"send-control\"></slot>\n </div>\n </div>\n </div>\n `;\n }\n\n private _handlePromptFocus = (event: CustomEvent): void => {\n // Both the textarea controller and the rich runtime pass `{ keyboard: true }`\n // in the event detail when focus arrived via keyboard navigation (no preceding\n // pointer/touch event).\n this._editorKeyboardFocus =\n (event.detail as { keyboard?: boolean })?.keyboard === true;\n };\n\n private _handlePromptBlur = (): void => {\n this._editorKeyboardFocus = false;\n };\n\n private _handleMessageActionsSlotChange = (): void => {\n // Request an update so `willUpdate()` re-derives occupancy from the settled\n // assignment. Deriving there (not here) avoids latching on a transient\n // assignment this event can fire on (see `willUpdate`).\n this.requestUpdate();\n };\n\n private _handleFileUploadsSlotChange = (): void => {\n // Reconnect the MutationObserver to whatever element is now slotted so we\n // re-render when its `has-uploads` attribute changes (which doesn't fire a\n // slotchange event).\n this._fileUploadsObserver?.disconnect();\n const slot = this.renderRoot?.querySelector(\n `slot[name=\"file-uploads\"]`\n ) as HTMLSlotElement | null;\n const el = slot?.assignedElements()[0];\n if (el) {\n if (!this._fileUploadsObserver) {\n this._fileUploadsObserver = new MutationObserver(() =>\n this.requestUpdate()\n );\n }\n this._fileUploadsObserver.observe(el, {\n attributes: true,\n attributeFilter: ['has-uploads'],\n });\n }\n this.requestUpdate();\n };\n\n /**\n * Derives `_hasMessageActions` from the `message-actions` slot's current\n * occupancy. Consumers may project a writeable passthrough\n * (`data-prompt-line-slot`) into `message-actions`; it is always present even\n * when empty, so only real action content drives the `--has-message-actions`\n * padding treatment.\n */\n private _updateHasMessageActions(): void {\n const slot = this.renderRoot?.querySelector(\n `slot[name=\"message-actions\"]`\n ) as HTMLSlotElement | null;\n this._hasMessageActions = slot\n ? slot\n .assignedElements()\n .some((element) => !element.hasAttribute('data-prompt-line-slot'))\n : false;\n }\n\n private _updateHasFileUploads(): void {\n const slot = this.renderRoot?.querySelector(\n `slot[name=\"file-uploads\"]`\n ) as HTMLSlotElement | null;\n\n this._hasFileUploads = slot\n ? slot.assignedElements().some((el) => el.hasAttribute('has-uploads'))\n : false;\n\n this.toggleAttribute('has-file-uploads', this._hasFileUploads);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-custom-aichat-prompt-line-shell': PromptLineShellElement;\n }\n}\n\nexport default PromptLineShellElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAWH;;;;;;;;;;;;;;;;;AAiBG;AAEH,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,UAAU,CAAA;AAA/C,IAAA,WAAA,GAAA;;;QAOE,IAAA,CAAA,OAAO,GAAG,KAAK;AAEf;;;;;;AAMG;QAEH,IAAA,CAAA,QAAQ,GAAG,KAAK;;QAIhB,IAAA,CAAA,QAAQ,GAAG,KAAK;;QAIhB,IAAA,CAAA,QAAQ,GAAG,KAAK;QAGR,IAAA,CAAA,kBAAkB,GAAG,KAAK;QAG1B,IAAA,CAAA,eAAe,GAAG,KAAK;QAGvB,IAAA,CAAA,oBAAoB,GAAG,KAAK;;QAG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A,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAUhB,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AACzB,CAAA,EAAA,sBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAIjB,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;AACjD,CAAA,EAAA,sBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAIjB,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AACzB,CAAA,EAAA,sBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAGT,UAAA,CAAA;AADP,IAAA,KAAK;AAC6B,CAAA,EAAA,sBAAA,CAAA,SAAA,EAAA,oBAAA,EAAA,MAAA,CAAA;AAG3B,UAAA,CAAA;AADP,IAAA,KAAK;AAC0B,CAAA,EAAA,sBAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,MAAA,CAAA;AAGxB,UAAA,CAAA;AADP,IAAA,KAAK;AAC+B,CAAA,EAAA,sBAAA,CAAA,SAAA,EAAA,sBAAA,EAAA,MAAA,CAAA;AAlCjC,sBAAsB,GAAA,UAAA,CAAA;AAD3B,IAAA,aAAa,CAAC,CAAA,EAAG,MAAM,CAAA,kBAAA,CAAoB;AACtC,CAAA,EAAA,sBAAsB,CA+M3B;AAQD,+BAAe,sBAAsB;;"}
|
|
1
|
+
{"version":3,"file":"prompt-line-shell.js","sources":["../../../../src/components/prompt-line/src/prompt-line-shell.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, type PropertyValues, unsafeCSS } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport prefix from '../../../globals/settings.js';\n\nimport styles from './prompt-line-shell.scss?lit';\n\n/**\n * Layout-only composer chrome for the chat input. The shell defines five\n * named slots and the spacing/border treatment around them — it carries no\n * chat-domain logic, builds no Tiptap extensions, and forwards no editor\n * methods.\n *\n * Consumers compose:\n * - `editor` — a `<cds-custom-aichat-prompt-line>` (or equivalent) the consumer\n * owns directly; the shell does not render a fallback.\n * - `message-actions` — action icons to the left of the text area.\n * - `file-uploads` — visual list of files being uploaded.\n * - `autocomplete-content` — suggestion overlay above the input.\n * - `field-messaging` — inline error / status content beneath the\n * autocomplete row (e.g. char-count exceeded message).\n * - `send-control` — send / stop-streaming button.\n *\n * ## Styling\n *\n * ### CSS part\n *\n * The input container is exposed as a CSS part so external stylesheets can\n * style the resting frame independently of the outer shell:\n *\n * ```css\n * cds-custom-aichat-prompt-line-shell::part(prompt-container) {\n * border: 1px solid var(--cds-border-subtle-01);\n * }\n * ```\n *\n * When embedded inside `cds-custom-aichat-custom-element`, the part is forwarded\n * through the shadow hierarchy and reachable from the outermost host:\n *\n * ```css\n * cds-custom-aichat-custom-element::part(prompt-container) {\n * border: 1px solid var(--cds-border-subtle-01);\n * }\n * ```\n *\n * ### CSS custom property\n *\n * `--cds-aichat-prompt-border` sets the `border` shorthand on the input\n * container. It inherits through shadow boundaries, so any ancestor of the\n * chat host can set it:\n *\n * ```css\n * cds-custom-aichat-custom-element {\n * --cds-aichat-prompt-border: 1px solid var(--cds-border-subtle-01);\n * }\n * ```\n *\n * Or via `layout.customProperties`:\n *\n * ```ts\n * layout: { customProperties: { \"prompt-border\": \"1px solid var(--cds-border-subtle-01)\" } }\n * ```\n *\n * The focus outline and error outline are not affected by either hook.\n *\n * @element cds-custom-aichat-prompt-line-shell\n */\n@carbonElement(`${prefix}-prompt-line-shell`)\nclass PromptLineShellElement extends LitElement {\n static styles = css`\n ${unsafeCSS(styles)}\n `;\n\n /** Reflects to attribute so consumer CSS can target the rounded variant. */\n @property({ type: Boolean, reflect: true })\n rounded = false;\n\n /**\n * Expanded layout: the editor fills its own full-width row, with the\n * message actions and send control on a second row beneath it (actions to\n * the start, send to the end). Reflects so consumer CSS can target the\n * variant. The reflow is driven purely by a container class — the rendered\n * DOM is identical in both modes.\n */\n @property({ type: Boolean, reflect: true })\n expanded = false;\n\n /** Whether the prompt line is in an error state */\n @property({ type: Boolean, reflect: true, attribute: 'has-error' })\n hasError = false;\n\n /** Whether the prompt-line shell is disabled. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n @state()\n private _hasMessageActions = false;\n\n @state()\n private _hasFileUploads = false;\n\n @state()\n private _editorKeyboardFocus = false;\n\n /** Watches the slotted file-uploads element for `has-uploads` attribute changes. */\n private _fileUploadsObserver: MutationObserver | null = null;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\n 'cds-custom-aichat-prompt-focus',\n this._handlePromptFocus as EventListener\n );\n this.addEventListener(\n 'cds-custom-aichat-prompt-blur',\n this._handlePromptBlur as EventListener\n );\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.removeEventListener(\n 'cds-custom-aichat-prompt-focus',\n this._handlePromptFocus as EventListener\n );\n this.removeEventListener(\n 'cds-custom-aichat-prompt-blur',\n this._handlePromptBlur as EventListener\n );\n this._fileUploadsObserver?.disconnect();\n }\n\n override willUpdate(changedProperties: PropertyValues): void {\n super.willUpdate(changedProperties);\n // Derive `--has-message-actions` from the settled slot assignment on every\n // update. A bare `slotchange` snapshot can latch on a transient state: a\n // consumer projecting content asynchronously (web-component slotting) or\n // toggling writeable content at runtime can momentarily present the\n // prompt-line passthrough as real action content, and the settled assignment\n // may not emit a follow-up `slotchange`. Left stale, that keeps the reduced\n // start inset and strands the prompt line once the content is removed.\n // Deriving here (rather than snapshotting in the handler) re-reads the\n // settled assignment each render, so the occupancy can't latch.\n this._updateHasMessageActions();\n this._updateHasFileUploads();\n }\n\n override render() {\n const containerClasses = {\n [`${prefix}--input-container`]: true,\n [`${prefix}--input-container--has-message-actions`]:\n this._hasMessageActions,\n [`${prefix}--input-container--expanded`]: this.expanded,\n };\n\n const uploadsRowClasses = {\n [`${prefix}--input-uploads-and-autocomplete`]: true,\n [`${prefix}--input-uploads-and-autocomplete--has-uploads`]:\n this._hasFileUploads,\n };\n\n const textAreaClasses = {\n [`${prefix}--input-text-area`]: true,\n [`${prefix}--input-text-area--keyboard-focus`]: this._editorKeyboardFocus,\n };\n\n // In expanded mode, render text-area before message-actions to match visual order\n\n const textAreaContent = html`\n <div class=${classMap(textAreaClasses)}>\n <slot name=\"editor\"></slot>\n </div>\n `;\n\n const messageActionsContent = html`\n <slot\n name=\"message-actions\"\n @slotchange=${this._handleMessageActionsSlotChange}></slot>\n `;\n\n return html`\n <div class=\"${prefix}--prompt-line-shell\">\n <div class=${classMap(containerClasses)} part=\"prompt-container\">\n <div class=${classMap(uploadsRowClasses)}>\n <slot\n name=\"file-uploads\"\n @slotchange=${this._handleFileUploadsSlotChange}></slot>\n <slot name=\"autocomplete-content\"></slot>\n </div>\n <div class=\"${prefix}--field-messaging-container\">\n <slot name=\"field-messaging\"></slot>\n </div>\n <div class=\"${prefix}--input-text-and-actions\">\n ${this.expanded ? textAreaContent : messageActionsContent}\n ${this.expanded ? messageActionsContent : textAreaContent}\n </div>\n <div class=\"${prefix}--input-send-control-container\">\n <slot name=\"send-control\"></slot>\n </div>\n </div>\n </div>\n `;\n }\n\n private _handlePromptFocus = (event: CustomEvent): void => {\n // Both the textarea controller and the rich runtime pass `{ keyboard: true }`\n // in the event detail when focus arrived via keyboard navigation (no preceding\n // pointer/touch event).\n this._editorKeyboardFocus =\n (event.detail as { keyboard?: boolean })?.keyboard === true;\n };\n\n private _handlePromptBlur = (): void => {\n this._editorKeyboardFocus = false;\n };\n\n private _handleMessageActionsSlotChange = (): void => {\n // Request an update so `willUpdate()` re-derives occupancy from the settled\n // assignment. Deriving there (not here) avoids latching on a transient\n // assignment this event can fire on (see `willUpdate`).\n this.requestUpdate();\n };\n\n private _handleFileUploadsSlotChange = (): void => {\n // Reconnect the MutationObserver to whatever element is now slotted so we\n // re-render when its `has-uploads` attribute changes (which doesn't fire a\n // slotchange event).\n this._fileUploadsObserver?.disconnect();\n const slot = this.renderRoot?.querySelector(\n `slot[name=\"file-uploads\"]`\n ) as HTMLSlotElement | null;\n const el = slot?.assignedElements()[0];\n if (el) {\n if (!this._fileUploadsObserver) {\n this._fileUploadsObserver = new MutationObserver(() =>\n this.requestUpdate()\n );\n }\n this._fileUploadsObserver.observe(el, {\n attributes: true,\n attributeFilter: ['has-uploads'],\n });\n }\n this.requestUpdate();\n };\n\n /**\n * Derives `_hasMessageActions` from the `message-actions` slot's current\n * occupancy. Consumers may project a writeable passthrough\n * (`data-prompt-line-slot`) into `message-actions`; it is always present even\n * when empty, so only real action content drives the `--has-message-actions`\n * padding treatment.\n */\n private _updateHasMessageActions(): void {\n const slot = this.renderRoot?.querySelector(\n `slot[name=\"message-actions\"]`\n ) as HTMLSlotElement | null;\n this._hasMessageActions = slot\n ? slot\n .assignedElements()\n .some((element) => !element.hasAttribute('data-prompt-line-slot'))\n : false;\n }\n\n private _updateHasFileUploads(): void {\n const slot = this.renderRoot?.querySelector(\n `slot[name=\"file-uploads\"]`\n ) as HTMLSlotElement | null;\n\n this._hasFileUploads = slot\n ? slot.assignedElements().some((el) => el.hasAttribute('has-uploads'))\n : false;\n\n this.toggleAttribute('has-file-uploads', this._hasFileUploads);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-custom-aichat-prompt-line-shell': PromptLineShellElement;\n }\n}\n\nexport default PromptLineShellElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAWH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DG;A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