@carbon/ai-chat-components 1.12.0 → 1.13.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +74 -3
- 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 +74 -3
- 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":"prompt-line.js","sources":["../../../../src/components/prompt-line/src/prompt-line.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 * `<cds-aichat-prompt-line>` — the editing-surface layer of the chat input\n * stack.\n *\n * It renders a lightweight `<textarea>` by default and **never statically\n * imports `@tiptap/*`**, so chats that don't use advanced input features ship\n * no Tiptap. When the `rich` property is set, or `ensureEditor()` is called,\n * the element dynamically imports a Tiptap runtime and upgrades the surface in\n * place — text, caret, and focus carry over because the textarea holds plain\n * text. Host `extensions` alone do not trigger it; they are staged for whichever\n * surface mounts. The upgrade is **sticky**: once rich, the element stays rich\n * for the rest of its life.\n *\n * Both modes expose the same imperative API (`getEditor`, `setContent`,\n * `insertContent`, …) and emit the same events, so the React wrapper and\n * `@carbon/ai-chat`'s `Input` are mode-agnostic. `getEditor()` returns `null`\n * in textarea mode (it's a probe — it never triggers a load); call\n * `ensureEditor()` to force the upgrade and resolve with the live editor.\n *\n * The Carbon Tiptap bundle the rich editor installs — schema, value-sync,\n * typing-indicator, plain-text paste, keymap (`Mod-Enter`/`Enter` →\n * `cds-aichat-prompt-send-intent`), placeholder, undo/redo — lives in\n * [./prompt-line-rich-runtime.ts]. Non-chat hosts wanting Tiptap inside Lit\n * should compose their own element against `@tiptap/core` directly.\n *\n * @element cds-aichat-prompt-line\n *\n * @experimental\n */\n\nimport type { Editor, Extension, JSONContent } from '@tiptap/core';\nimport { css, html, LitElement, unsafeCSS } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport prefix from '../../../globals/settings.js';\nimport { adoptOnRoot } from '../../shared/dynamic-css-var-sheet.js';\nimport type {\n PromptLineController,\n PromptLineControllerInit,\n SetContentUpdater,\n} from './prompt-line-controller.js';\nimport { TextareaController } from './prompt-line-textarea-runtime.js';\nimport {\n getRichRuntimeIfLoaded,\n loadRichRuntime,\n} from './prompt-line-rich-loader.js';\nimport { getRawText, textOffsetToDocPos } from './tiptap/json-utils.js';\n\nimport styles from './prompt-line.scss?lit';\n\n@carbonElement(`${prefix}-prompt-line`)\nclass PromptLineElement extends LitElement {\n static styles = css`\n ${unsafeCSS(styles)}\n `;\n\n /**\n * Host-supplied Tiptap extensions, appended to the carbon bundle when the\n * rich editor mounts. These are *staged*, not a rich-mode trigger: setting\n * them while in textarea mode does not load Tiptap. Select rich explicitly\n * with `rich` or call `ensureEditor()`; the upgrade mounts with these\n * already installed.\n *\n * A new array is compared by value against the set last supplied, so a config\n * update that rebuilds an equivalent one leaves the live editor and its undo\n * history in place, writing any starter `items`/`isOn` through to storage.\n * Only a genuinely different set recreates the editor, preserving content,\n * selection, and focus but resetting history.\n * Extensions built by `buildCarbonExtensions` compare by their source\n * config; anything you supply directly compares by reference, so memoize\n * those (a fresh instance each render reads as a real change).\n */\n @property({ type: Array, attribute: false })\n extensions: Extension[] = [];\n\n /**\n * Initial / current content. Accepts Tiptap-native JSONContent or a plain\n * string. In textarea mode JSONContent is flattened to plain text.\n */\n @property({ type: Object, attribute: false })\n content?: JSONContent | string;\n\n /**\n * Selects the rich Tiptap editor. The element lazy-loads Tiptap and upgrades\n * the textarea in place; the upgrade is sticky (clearing `rich` later keeps\n * the editor). Defaults to the textarea.\n */\n @property({ type: Boolean, reflect: true })\n rich = false;\n\n /** Disables editing. The surface stays mounted but non-editable. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** Placeholder text shown when the surface is empty. */\n @property({ type: String })\n placeholder = '';\n\n /** Accessible label for the editing surface. */\n @property({ type: String, attribute: 'aria-label', reflect: true })\n override ariaLabel = 'Message';\n\n /** Test id, applied to the inner editable element. */\n @property({ type: String, attribute: 'test-id' })\n testId = '';\n\n /** Focus the surface on mount. */\n @property({ type: Boolean })\n override autofocus = false;\n\n private _controller: PromptLineController | null = null;\n private _mode: 'textarea' | 'rich' = 'textarea';\n private _editorHost: HTMLElement | null = null;\n private _lastExtensionsRef: Extension[] | null = null;\n /**\n * The `content` value the current surface was seeded with, and whether that\n * seed is still unconsumed. Both are needed: the value catches the echo, and\n * the latch releases after one `updated()` so a later change back to the same\n * value still lands. Comparing on the value alone suppressed it for the life\n * of the surface, dropping `a` in an `a` -> `b` -> `a` sequence.\n */\n private _seededContent?: JSONContent | string;\n private _seedPending = false;\n /** Pending deferred teardown, cancelled if the element is reattached. */\n private _pendingTeardownTimer: ReturnType<typeof setTimeout> | null = null;\n /** Sticky latch — once rich is wanted it never reverts. */\n private _richLatched = false;\n private _upgrading = false;\n /**\n * The element owns the host's composition listeners for both layers — it\n * gates its own textarea→rich upgrade on this, and pushes the state to the\n * active controller via `setComposing` so rich mode can withhold a recreate.\n * One observer, so the two layers cannot disagree.\n */\n private _isComposing = false;\n private _pendingUpgrade = false;\n /**\n * Shared promise for in-flight `ensureEditor()` callers. Created lazily on the\n * first `ensureEditor()` call that needs an upgrade, settled once the rich\n * editor is mounted (`_swapToRich`) or the upgrade can't complete.\n */\n private _richReady: Promise<Editor> | null = null;\n private _resolveRichReady: ((editor: Editor) => void) | null = null;\n private _rejectRichReady: ((reason: Error) => void) | null = null;\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n override firstUpdated(): void {\n this._initializeSurface();\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this._pendingTeardownTimer !== null) {\n // Reattached before the deferred teardown ran — a move, not an unmount.\n // The controller and its editor host traveled with the element, so the\n // Tiptap instance (and its undo history) survives untouched.\n //\n // Unlike `_teardownSurface`, this deliberately leaves `_isComposing` /\n // `_pendingUpgrade` alone: the host div and its composition listeners are\n // still attached, so a later `compositionend` reaches them and releases\n // whatever was parked. Teardown has to reset eagerly only because it\n // discards the listeners that would otherwise do it.\n clearTimeout(this._pendingTeardownTimer);\n this._pendingTeardownTimer = null;\n const root = this._editorHost?.getRootNode();\n if (root instanceof ShadowRoot || root instanceof Document) {\n adoptOnRoot(root);\n }\n return;\n }\n // Reattached after a real teardown. `firstUpdated` is a one-shot, so\n // without this the element would come back permanently inert.\n if (this._isTornDown()) {\n this._initializeSurface();\n }\n }\n\n override updated(changed: Map<string | number | symbol, unknown>): void {\n if (!this._controller) {\n return;\n }\n if (\n (changed.has('rich') || changed.has('extensions')) &&\n this._wantsRich()\n ) {\n this._richLatched = true;\n if (this._mode === 'textarea') {\n void this._upgradeToRich();\n }\n }\n if (\n changed.has('extensions') &&\n this.extensions !== this._lastExtensionsRef\n ) {\n this._lastExtensionsRef = this.extensions;\n if (this._mode === 'rich') {\n this._controller.setExtensions(this.extensions);\n }\n }\n if (changed.has('disabled')) {\n this._controller.setEditable(!this.disabled);\n }\n // The seed echo is skipped once — re-applying it would emit a spurious\n // host-origin change event. Every later update lands, including one that\n // returns to the seed value, and including one alongside an extensions\n // change (which may no-op or recreate; either way the seed is the previous\n // doc).\n if (changed.has('content')) {\n const echoesSeed =\n this._seedPending && this.content === this._seededContent;\n this._seedPending = false;\n if (!echoesSeed) {\n this._controller.setContent(this.content ?? '');\n }\n }\n if (changed.has('placeholder')) {\n this._controller.setPlaceholder(this.placeholder);\n }\n if (changed.has('testId')) {\n this._controller.setTestId(this.testId);\n }\n if (changed.has('ariaLabel')) {\n this._controller.setAriaLabel(this.ariaLabel);\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (!this._controller || this._pendingTeardownTimer !== null) {\n return;\n }\n // Deferred by a task so a reparent — remove and re-append in the same\n // frame — keeps the live editor instead of destroying and rebuilding it.\n // A macrotask rather than a microtask because the reconnect can be\n // scheduled separately from the removal, and rather than a frame callback\n // because those never fire in a background tab, which would leak the\n // editor of a chat that really was unmounted.\n this._pendingTeardownTimer = setTimeout(() => {\n this._pendingTeardownTimer = null;\n this._teardownSurface();\n }, 0);\n }\n\n /** Destroy the editing surface. Deferred from `disconnectedCallback`. */\n private _teardownSurface(): void {\n this._failRichReady(new Error('Input is not currently rendered'));\n this._controller?.destroy();\n this._controller = null;\n this._editorHost?.remove();\n this._editorHost = null;\n this._lastExtensionsRef = null;\n // Back to the default surface. `_richLatched` is the sticky flag, so a late\n // reconnect still comes back rich; leaving `_mode` on 'rich' with no\n // controller would just be a field outliving what it describes.\n this._mode = 'textarea';\n // The host div (and its composition listeners) is gone, so a composition\n // that was in flight can never fire its `compositionend`. Left set, these\n // would park the first upgrade after a reattach forever.\n this._isComposing = false;\n this._pendingUpgrade = false;\n }\n\n /** Mount the editing surface. Runs on first render and on a late reconnect. */\n private _initializeSurface(): void {\n const host = this._mountEditorHost();\n this._lastExtensionsRef = this.extensions;\n this._seededContent = this.content;\n this._seedPending = true;\n this._richLatched = this._wantsRich();\n\n const warmRuntime = this._richLatched ? getRichRuntimeIfLoaded() : null;\n if (warmRuntime) {\n // Runtime already loaded (e.g. preloaded at boot) — mount rich directly,\n // no textarea flash.\n this._mode = 'rich';\n this._controller = warmRuntime.createRichController();\n this._controller.mount(host, this._makeInit());\n } else {\n this._mode = 'textarea';\n this._controller = new TextareaController();\n this._controller.mount(host, this._makeInit());\n if (this._richLatched) {\n void this._upgradeToRich();\n }\n }\n\n if (this.autofocus) {\n // Defer so consumer listeners are attached first.\n Promise.resolve().then(() => this._controller?.focus(false));\n }\n }\n\n override render() {\n return html`\n <div class=\"frame\">\n <slot name=\"editor\"></slot>\n </div>\n `;\n }\n\n // ---------------------------------------------------------------------------\n // Public methods (delegate to the active controller)\n // ---------------------------------------------------------------------------\n\n /** Returns the live Tiptap editor, or `null` in textarea mode. */\n getEditor(): Editor | null {\n return this._controller?.getEditor() ?? null;\n }\n\n /**\n * Lazily load Tiptap (if not already loaded), upgrade the textarea to the\n * rich editor in place, and resolve with the live editor. Resolves\n * immediately when already rich. Rejects when the surface isn't mounted or\n * the runtime can't load (SSR). Concurrent callers share one in-flight\n * upgrade.\n */\n ensureEditor(): Promise<Editor> {\n if (this._mode === 'rich') {\n const editor = this._controller?.getEditor();\n if (editor) {\n return Promise.resolve(editor);\n }\n }\n // Connected but not yet rendered, or already torn down — nothing to upgrade.\n if (!this._editorHost || !this._controller) {\n return Promise.reject(new Error('Input is not currently rendered'));\n }\n this._richLatched = true;\n if (!this._richReady) {\n this._richReady = new Promise<Editor>((resolve, reject) => {\n this._resolveRichReady = resolve;\n this._rejectRichReady = reject;\n });\n }\n void this._upgradeToRich();\n return this._richReady;\n }\n\n /**\n * Current plain-text value. Works in both modes (in rich mode this mirrors\n * `getEditor()?.getText()`), so callers don't need to branch on `getEditor()`\n * being `null`.\n */\n getValue(): string {\n return this._controller?.getValue() ?? '';\n }\n\n override focus(): void {\n this._controller?.focus(false);\n }\n\n override blur(): void {\n this._controller?.blur();\n }\n\n /** Returns `true` if the editing surface currently holds focus. */\n hasFocus(): boolean {\n return this._controller?.hasFocus() ?? false;\n }\n\n clearContent(): void {\n this._controller?.clearContent();\n }\n\n setContent(next: JSONContent | string | SetContentUpdater): void {\n this._controller?.setContent(next);\n }\n\n insertContent(\n content: JSONContent | string,\n opts: { at?: number } = {}\n ): void {\n this._controller?.insertContent(content, opts);\n }\n\n setTextSelection(pos: number | { from: number; to: number }): void {\n this._controller?.setTextSelection(pos);\n }\n\n selectAll(): void {\n this._controller?.selectAll();\n }\n\n undo(): boolean {\n return this._controller?.undo() ?? false;\n }\n\n redo(): boolean {\n return this._controller?.redo() ?? false;\n }\n\n // ---------------------------------------------------------------------------\n // Internals\n // ---------------------------------------------------------------------------\n\n private _wantsRich(): boolean {\n return this._richLatched || this.rich;\n }\n\n /**\n * Rendered once and then torn down — the element is inert until something\n * re-runs the mount path. Distinct from \"not yet rendered\", where Lit's own\n * `firstUpdated` still has it.\n */\n private _isTornDown(): boolean {\n return this.hasUpdated && !this._controller;\n }\n\n private _mountEditorHost(): HTMLElement {\n const host = document.createElement('div');\n host.setAttribute('slot', 'editor');\n host.dataset.aichatEditorHost = '';\n this.appendChild(host);\n this._editorHost = host;\n\n // Defer an upgrade requested mid-IME-composition so we don't tear the\n // field out from under the user.\n host.addEventListener('compositionstart', this._onCompositionStart);\n host.addEventListener('compositionend', this._onCompositionEnd);\n\n const root = host.getRootNode();\n if (root instanceof ShadowRoot || root instanceof Document) {\n adoptOnRoot(root);\n }\n return host;\n }\n\n private _onCompositionStart = (): void => {\n this._isComposing = true;\n this._controller?.setComposing(true);\n };\n\n private _onCompositionEnd = (): void => {\n this._isComposing = false;\n this._controller?.setComposing(false);\n if (this._pendingUpgrade) {\n this._pendingUpgrade = false;\n void this._upgradeToRich();\n }\n };\n\n /** Build the controller init from current props (rich seed by default). */\n private _makeInit(valueOverride?: string): PromptLineControllerInit {\n const value =\n valueOverride ??\n (typeof this.content === 'string'\n ? this.content\n : this.content\n ? getRawText(this.content)\n : '');\n return {\n value,\n // On an upgrade we seed losslessly from the textarea's plain text, so\n // the structured `content` prop is only used for the initial mount.\n content: valueOverride === undefined ? this.content : undefined,\n placeholder: this.placeholder,\n disabled: this.disabled,\n ariaLabel: this.ariaLabel,\n testId: this.testId,\n extensions: this.extensions,\n };\n }\n\n /** Resolve any pending `ensureEditor()` callers with the live editor. */\n private _settleRichReady(): void {\n const editor = this._controller?.getEditor();\n if (editor && this._resolveRichReady) {\n this._resolveRichReady(editor);\n this._resolveRichReady = null;\n this._rejectRichReady = null;\n }\n }\n\n /**\n * Reject any pending `ensureEditor()` callers and clear the shared promise so\n * a later call can retry.\n */\n private _failRichReady(reason: Error): void {\n if (this._rejectRichReady) {\n this._rejectRichReady(reason);\n }\n this._resolveRichReady = null;\n this._rejectRichReady = null;\n this._richReady = null;\n }\n\n /** Lazily load Tiptap and swap the textarea for the rich editor in place. */\n private async _upgradeToRich(): Promise<void> {\n if (this._mode === 'rich' || this._upgrading) {\n return;\n }\n this._upgrading = true;\n try {\n const module = getRichRuntimeIfLoaded() ?? (await loadRichRuntime());\n // Bail if disconnected or runtime unavailable (SSR). The `_upgrading`\n // latch already prevents a concurrent upgrade.\n if (!module || !this._editorHost || !this._controller) {\n this._failRichReady(\n new Error(\n module\n ? 'Input is not currently rendered'\n : 'Input editor runtime is unavailable'\n )\n );\n return;\n }\n if (this._isComposing) {\n // Defer until composition ends; `_richReady` stays pending and settles\n // when `_onCompositionEnd` re-runs the upgrade.\n this._pendingUpgrade = true;\n return;\n }\n this._swapToRich(module.createRichController());\n } catch (error) {\n // A failed runtime load or mount must reject pending `ensureEditor()`\n // callers rather than leave them hanging.\n this._failRichReady(\n error instanceof Error ? error : new Error(String(error))\n );\n } finally {\n this._upgrading = false;\n }\n }\n\n private _swapToRich(rich: PromptLineController): void {\n const previous = this._controller;\n const host = this._editorHost;\n if (!previous || !host) {\n return;\n }\n const value = previous.getValue();\n const selection = previous.getSelection();\n const hadFocus = previous.hasFocus();\n const hadKeyboardFocus = previous.getKeyboardFocus();\n\n previous.destroy();\n this._controller = rich;\n this._mode = 'rich';\n // Seeded losslessly from the textarea's text, which already reflects\n // `content`, so an in-flight identical `content` update stays a no-op.\n this._seededContent = this.content;\n this._seedPending = true;\n rich.mount(host, this._makeInit(value));\n\n rich.setTextSelection({\n from: textOffsetToDocPos(value, selection.from),\n to: textOffsetToDocPos(value, selection.to),\n });\n if (hadFocus) {\n rich.focus(hadKeyboardFocus);\n }\n this._settleRichReady();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-aichat-prompt-line': PromptLineElement;\n }\n}\n\nexport default PromptLineElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAsDH,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU,CAAA;AAA1C,IAAA,WAAA,GAAA;;AAKE;;;;;;;;;;;;;;;AAeG;QAEH,IAAA,CAAA,UAAU,GAAgB,EAAE;AAS5B;;;;AAIG;QAEH,IAAA,CAAA,IAAI,GAAG,KAAK;;QAIZ,IAAA,CAAA,QAAQ,GAAG,KAAK;;QAIhB,IAAA,CAAA,WAAW,GAAG,EAAE;;QAIP,IAAA,CAAA,SAAS,GAAG,SAAS;;QAI9B,IAAA,CAAA,MAAM,GAAG,EAAE;;QAIF,IAAA,CAAA,SAAS,GAAG,KAAK;QAElB,IAAA,CAAA,WAAW,GAAgC,IAAI;QAC/C,IAAA,CAAA,KAAK,GAAwB,UAAU;QACvC,IAAA,CAAA,WAAW,GAAuB,IAAI;QACtC,IAAA,CAAA,kBAAkB,GAAuB,IAAI;QAS7C,IAAA,CAAA,YAAY,GAAG,KAAK;;QAEpB,IAAA,CAAA,qBAAqB,GAAyC,IAAI;;QAElE,IAAA,CAAA,YA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AAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAIjB,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AACT,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAIR,UAAA,CAAA;AADR,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE;AACnC,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAI/B,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE;AACpC,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAIH,UAAA,CAAA;AADR,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;AACA,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAzDvB,iBAAiB,GAAA,UAAA,CAAA;AADtB,IAAA,aAAa,CAAC,CAAA,EAAG,MAAM,CAAA,YAAA,CAAc;AAChC,CAAA,EAAA,iBAAiB,CAyftB;AAQD,0BAAe,iBAAiB;;"}
|
|
1
|
+
{"version":3,"file":"prompt-line.js","sources":["../../../../src/components/prompt-line/src/prompt-line.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 * `<cds-aichat-prompt-line>` — the editing-surface layer of the chat input\n * stack.\n *\n * It renders a lightweight `<textarea>` by default and **never statically\n * imports `@tiptap/*`**, so chats that don't use advanced input features ship\n * no Tiptap. When the `rich` property is set, or `ensureEditor()` is called,\n * the element dynamically imports a Tiptap runtime and upgrades the surface in\n * place — text, caret, and focus carry over because the textarea holds plain\n * text. Host `extensions` alone do not trigger it; they are staged for whichever\n * surface mounts. The upgrade is **sticky**: once rich, the element stays rich\n * for the rest of its life.\n *\n * Both modes expose the same imperative API (`getEditor`, `setContent`,\n * `insertContent`, …) and emit the same events, so the React wrapper and\n * `@carbon/ai-chat`'s `Input` are mode-agnostic. `getEditor()` returns `null`\n * in textarea mode (it's a probe — it never triggers a load); call\n * `ensureEditor()` to force the upgrade and resolve with the live editor.\n *\n * The Carbon Tiptap bundle the rich editor installs — schema, value-sync,\n * typing-indicator, plain-text paste, keymap (`Mod-Enter`/`Enter` →\n * `cds-aichat-prompt-send-intent`), placeholder, undo/redo — lives in\n * [./prompt-line-rich-runtime.ts]. Non-chat hosts wanting Tiptap inside Lit\n * should compose their own element against `@tiptap/core` directly.\n *\n * @element cds-aichat-prompt-line\n *\n * @experimental\n */\n\nimport type { Editor, Extension, JSONContent } from '@tiptap/core';\nimport { css, html, LitElement, unsafeCSS } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport prefix from '../../../globals/settings.js';\nimport { adoptOnRoot } from '../../shared/dynamic-css-var-sheet.js';\nimport type {\n PromptLineController,\n PromptLineControllerInit,\n SetContentUpdater,\n} from './prompt-line-controller.js';\nimport { TextareaController } from './prompt-line-textarea-runtime.js';\nimport {\n getRichRuntimeIfLoaded,\n loadRichRuntime,\n} from './prompt-line-rich-loader.js';\nimport { getRawText, textOffsetToDocPos } from './tiptap/json-utils.js';\n\nimport styles from './prompt-line.scss?lit';\n\n@carbonElement(`${prefix}-prompt-line`)\nclass PromptLineElement extends LitElement {\n static styles = css`\n ${unsafeCSS(styles)}\n `;\n\n /**\n * Host-supplied Tiptap extensions, appended to the carbon bundle when the\n * rich editor mounts. These are *staged*, not a rich-mode trigger: setting\n * them while in textarea mode does not load Tiptap. Select rich explicitly\n * with `rich` or call `ensureEditor()`; the upgrade mounts with these\n * already installed.\n *\n * A new array is compared by value against the set last supplied, so a config\n * update that rebuilds an equivalent one leaves the live editor and its undo\n * history in place, writing any starter `items`/`isOn` through to storage.\n * Only a genuinely different set recreates the editor, preserving content,\n * selection, and focus but resetting history.\n * Extensions built by `buildCarbonExtensions` compare by their source\n * config; anything you supply directly compares by reference, so memoize\n * those (a fresh instance each render reads as a real change).\n */\n @property({ type: Array, attribute: false })\n extensions: Extension[] = [];\n\n /**\n * Initial / current content. Accepts Tiptap-native JSONContent or a plain\n * string. In textarea mode JSONContent is flattened to plain text.\n */\n @property({ type: Object, attribute: false })\n content?: JSONContent | string;\n\n /**\n * Selects the rich Tiptap editor. The element lazy-loads Tiptap and upgrades\n * the textarea in place; the upgrade is sticky (clearing `rich` later keeps\n * the editor). Defaults to the textarea.\n */\n @property({ type: Boolean, reflect: true })\n rich = false;\n\n /** Disables editing. The surface stays mounted but non-editable. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** Placeholder text shown when the surface is empty. */\n @property({ type: String })\n placeholder = '';\n\n /** Accessible label for the editing surface. */\n @property({ type: String, attribute: 'aria-label', reflect: true })\n override ariaLabel = 'Message';\n\n /** Test id, applied to the inner editable element. */\n @property({ type: String, attribute: 'test-id' })\n testId = '';\n\n /** Focus the surface on mount. */\n @property({ type: Boolean })\n override autofocus = false;\n\n private _controller: PromptLineController | null = null;\n private _mode: 'textarea' | 'rich' = 'textarea';\n private _editorHost: HTMLElement | null = null;\n private _lastExtensionsRef: Extension[] | null = null;\n /**\n * The `content` value the current surface was seeded with, and whether that\n * seed is still unconsumed. Both are needed: the value catches the echo, and\n * the latch releases after one `updated()` so a later change back to the same\n * value still lands. Comparing on the value alone suppressed it for the life\n * of the surface, dropping `a` in an `a` -> `b` -> `a` sequence.\n */\n private _seededContent?: JSONContent | string;\n private _seedPending = false;\n /** Pending deferred teardown, cancelled if the element is reattached. */\n private _pendingTeardownTimer: ReturnType<typeof setTimeout> | null = null;\n private _focusedWithKeyboard: boolean | null = null;\n /** Sticky latch — once rich is wanted it never reverts. */\n private _richLatched = false;\n private _upgrading = false;\n /**\n * The element owns the host's composition listeners for both layers — it\n * gates its own textarea→rich upgrade on this, and pushes the state to the\n * active controller via `setComposing` so rich mode can withhold a recreate.\n * One observer, so the two layers cannot disagree.\n */\n private _isComposing = false;\n private _pendingUpgrade = false;\n /**\n * Shared promise for in-flight `ensureEditor()` callers. Created lazily on the\n * first `ensureEditor()` call that needs an upgrade, settled once the rich\n * editor is mounted (`_swapToRich`) or the upgrade can't complete.\n */\n private _richReady: Promise<Editor> | null = null;\n private _resolveRichReady: ((editor: Editor) => void) | null = null;\n private _rejectRichReady: ((reason: Error) => void) | null = null;\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n override firstUpdated(): void {\n this._initializeSurface();\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (this._pendingTeardownTimer !== null) {\n // Reattached before the deferred teardown ran — a move, not an unmount.\n // The controller and its editor host traveled with the element, so the\n // Tiptap instance (and its undo history) survives untouched.\n //\n // Unlike `_teardownSurface`, this deliberately leaves `_isComposing` /\n // `_pendingUpgrade` alone: the host div and its composition listeners are\n // still attached, so a later `compositionend` reaches them and releases\n // whatever was parked. Teardown has to reset eagerly only because it\n // discards the listeners that would otherwise do it.\n clearTimeout(this._pendingTeardownTimer);\n this._pendingTeardownTimer = null;\n const root = this._editorHost?.getRootNode();\n if (root instanceof ShadowRoot || root instanceof Document) {\n adoptOnRoot(root);\n }\n this._controller?.getEditor()?.view.updateRoot();\n const activeElement = this.ownerDocument.activeElement;\n if (\n this._focusedWithKeyboard !== null &&\n (!activeElement || activeElement === this.ownerDocument.body)\n ) {\n this._controller?.focus(this._focusedWithKeyboard, true);\n } else {\n this._focusedWithKeyboard = null;\n }\n if (this._richLatched && this._mode === 'textarea') {\n void this._requestRichUpgrade();\n }\n return;\n }\n // Reattached after a real teardown. `firstUpdated` is a one-shot, so\n // without this the element would come back permanently inert.\n if (this._isTornDown()) {\n this._initializeSurface();\n }\n }\n\n override updated(changed: Map<string | number | symbol, unknown>): void {\n if (!this._controller) {\n return;\n }\n if (\n (changed.has('rich') || changed.has('extensions')) &&\n this._wantsRich()\n ) {\n this._richLatched = true;\n if (this._mode === 'textarea') {\n void this._requestRichUpgrade();\n }\n }\n if (\n changed.has('extensions') &&\n this.extensions !== this._lastExtensionsRef\n ) {\n this._lastExtensionsRef = this.extensions;\n if (this._mode === 'rich') {\n this._controller.setExtensions(this.extensions);\n }\n }\n if (changed.has('disabled')) {\n this._controller.setEditable(!this.disabled);\n }\n // The seed echo is skipped once — re-applying it would emit a spurious\n // host-origin change event. Every later update lands, including one that\n // returns to the seed value, and including one alongside an extensions\n // change (which may no-op or recreate; either way the seed is the previous\n // doc).\n if (changed.has('content')) {\n const echoesSeed =\n this._seedPending && this.content === this._seededContent;\n this._seedPending = false;\n if (!echoesSeed) {\n this._controller.setContent(this.content ?? '');\n }\n }\n if (changed.has('placeholder')) {\n this._controller.setPlaceholder(this.placeholder);\n }\n if (changed.has('testId')) {\n this._controller.setTestId(this.testId);\n }\n if (changed.has('ariaLabel')) {\n this._controller.setAriaLabel(this.ariaLabel);\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n if (!this._controller || this._pendingTeardownTimer !== null) {\n return;\n }\n // Deferred by a task so a reparent — remove and re-append in the same\n // frame — keeps the live editor instead of destroying and rebuilding it.\n // A macrotask rather than a microtask because the reconnect can be\n // scheduled separately from the removal, and rather than a frame callback\n // because those never fire in a background tab, which would leak the\n // editor of a chat that really was unmounted.\n this._pendingTeardownTimer = setTimeout(() => {\n this._pendingTeardownTimer = null;\n this._teardownSurface();\n }, 0);\n }\n\n /** Destroy the editing surface. Deferred from `disconnectedCallback`. */\n private _teardownSurface(): void {\n this._focusedWithKeyboard = null;\n this._failRichReady(new Error('Input is not currently rendered'));\n this._controller?.destroy();\n this._controller = null;\n this._editorHost?.remove();\n this._editorHost = null;\n this._lastExtensionsRef = null;\n // Back to the default surface. `_richLatched` is the sticky flag, so a late\n // reconnect still comes back rich; leaving `_mode` on 'rich' with no\n // controller would just be a field outliving what it describes.\n this._mode = 'textarea';\n // The host div (and its composition listeners) is gone, so a composition\n // that was in flight can never fire its `compositionend`. Left set, these\n // would park the first upgrade after a reattach forever.\n this._isComposing = false;\n this._pendingUpgrade = false;\n }\n\n /** Mount the editing surface. Runs on first render and on a late reconnect. */\n private _initializeSurface(): void {\n // Guard against Lit running the pending first update on an element that was\n // appended and removed in a single task before the update flushed. Without\n // this check the editor mounts on a detached host with no disconnectedCallback\n // left to clean it up, because the callback already ran before the update.\n if (!this.isConnected) {\n return;\n }\n const host = this._mountEditorHost();\n this._lastExtensionsRef = this.extensions;\n this._seededContent = this.content;\n this._seedPending = true;\n this._richLatched = this._wantsRich();\n\n const warmRuntime = this._richLatched ? getRichRuntimeIfLoaded() : null;\n if (warmRuntime) {\n // Runtime already loaded (e.g. preloaded at boot) — mount rich directly,\n // no textarea flash.\n this._mode = 'rich';\n this._controller = warmRuntime.createRichController();\n this._controller.mount(host, this._makeInit());\n } else {\n this._mode = 'textarea';\n this._controller = new TextareaController();\n this._controller.mount(host, this._makeInit());\n if (this._richLatched) {\n void this._requestRichUpgrade();\n }\n }\n\n if (this.autofocus) {\n // Defer so consumer listeners are attached first.\n Promise.resolve().then(() => this._controller?.focus(false));\n }\n }\n\n override render() {\n return html`\n <div class=\"frame\">\n <slot name=\"editor\"></slot>\n </div>\n `;\n }\n\n // ---------------------------------------------------------------------------\n // Public methods (delegate to the active controller)\n // ---------------------------------------------------------------------------\n\n /** Returns the live Tiptap editor, or `null` in textarea mode. */\n getEditor(): Editor | null {\n return this._controller?.getEditor() ?? null;\n }\n\n /**\n * Lazily load Tiptap (if not already loaded), upgrade the textarea to the\n * rich editor in place, and resolve with the live editor. Resolves\n * immediately when already rich. Rejects when the surface isn't mounted or\n * the runtime can't load (SSR). Concurrent callers share one in-flight\n * upgrade.\n */\n ensureEditor(): Promise<Editor> {\n if (!this.isConnected || this._pendingTeardownTimer !== null) {\n return Promise.reject(new Error('Input is not currently rendered'));\n }\n if (this._mode === 'rich') {\n const editor = this._controller?.getEditor();\n if (editor) {\n return Promise.resolve(editor);\n }\n }\n // Connected but not yet rendered, or already torn down — nothing to upgrade.\n if (!this._editorHost || !this._controller) {\n return Promise.reject(new Error('Input is not currently rendered'));\n }\n this._richLatched = true;\n if (!this._richReady) {\n this._richReady = new Promise<Editor>((resolve, reject) => {\n this._resolveRichReady = resolve;\n this._rejectRichReady = reject;\n });\n }\n // Capture the promise before starting the upgrade: _requestRichUpgrade may\n // run synchronously (warm runtime path) and call _failRichReady, which\n // nulls this._richReady. Returning the captured reference keeps the\n // rejection visible to the caller.\n const promise = this._richReady;\n void this._requestRichUpgrade();\n return promise;\n }\n\n /**\n * Current plain-text value. Works in both modes (in rich mode this mirrors\n * `getEditor()?.getText()`), so callers don't need to branch on `getEditor()`\n * being `null`.\n */\n getValue(): string {\n return this._controller?.getValue() ?? '';\n }\n\n override focus(): void {\n this._controller?.focus(false);\n }\n\n override blur(): void {\n this._focusedWithKeyboard = null;\n this._controller?.blur();\n }\n\n /** Returns `true` if the editing surface currently holds focus. */\n hasFocus(): boolean {\n return this._controller?.hasFocus() ?? false;\n }\n\n clearContent(): void {\n this._controller?.clearContent();\n }\n\n setContent(next: JSONContent | string | SetContentUpdater): void {\n this._controller?.setContent(next);\n }\n\n insertContent(\n content: JSONContent | string,\n opts: { at?: number } = {}\n ): void {\n this._controller?.insertContent(content, opts);\n }\n\n setTextSelection(pos: number | { from: number; to: number }): void {\n this._controller?.setTextSelection(pos);\n }\n\n selectAll(): void {\n this._controller?.selectAll();\n }\n\n undo(): boolean {\n return this._controller?.undo() ?? false;\n }\n\n redo(): boolean {\n return this._controller?.redo() ?? false;\n }\n\n // ---------------------------------------------------------------------------\n // Internals\n // ---------------------------------------------------------------------------\n\n private _wantsRich(): boolean {\n return this._richLatched || this.rich;\n }\n\n /**\n * Rendered once and then torn down — the element is inert until something\n * re-runs the mount path. Distinct from \"not yet rendered\", where Lit's own\n * `firstUpdated` still has it.\n */\n private _isTornDown(): boolean {\n return this.hasUpdated && !this._controller;\n }\n\n private _mountEditorHost(): HTMLElement {\n const host = document.createElement('div');\n host.setAttribute('slot', 'editor');\n host.dataset.aichatEditorHost = '';\n this.appendChild(host);\n this._editorHost = host;\n\n // Defer an upgrade requested mid-IME-composition so we don't tear the\n // field out from under the user.\n host.addEventListener('compositionstart', this._onCompositionStart);\n host.addEventListener('compositionend', this._onCompositionEnd);\n host.addEventListener('cds-aichat-prompt-focus', (event) => {\n this._focusedWithKeyboard = (event as CustomEvent).detail.keyboard;\n });\n host.addEventListener('cds-aichat-prompt-blur', () => {\n // Chromium blurs a removed ancestor's descendants before disconnecting\n // them. Wait until the DOM move finishes before treating this as a blur.\n queueMicrotask(() => {\n if (this.isConnected && !this._controller?.hasFocus()) {\n this._focusedWithKeyboard = null;\n }\n });\n });\n\n const root = host.getRootNode();\n if (root instanceof ShadowRoot || root instanceof Document) {\n adoptOnRoot(root);\n }\n return host;\n }\n\n private _onCompositionStart = (): void => {\n this._isComposing = true;\n this._controller?.setComposing(true);\n };\n\n private _onCompositionEnd = (): void => {\n this._isComposing = false;\n this._controller?.setComposing(false);\n if (this._pendingUpgrade) {\n this._pendingUpgrade = false;\n void this._requestRichUpgrade();\n }\n };\n\n /** Build the controller init from current props (rich seed by default). */\n private _makeInit(valueOverride?: string): PromptLineControllerInit {\n const value =\n valueOverride ??\n (typeof this.content === 'string'\n ? this.content\n : this.content\n ? getRawText(this.content)\n : '');\n return {\n value,\n // On an upgrade we seed losslessly from the textarea's plain text, so\n // the structured `content` prop is only used for the initial mount.\n content: valueOverride === undefined ? this.content : undefined,\n placeholder: this.placeholder,\n disabled: this.disabled,\n ariaLabel: this.ariaLabel,\n testId: this.testId,\n extensions: this.extensions,\n };\n }\n\n /** Resolve any pending `ensureEditor()` callers with the live editor. */\n private _settleRichReady(): void {\n const editor = this._controller?.getEditor();\n if (editor && this._resolveRichReady) {\n this._resolveRichReady(editor);\n this._resolveRichReady = null;\n this._rejectRichReady = null;\n }\n }\n\n /**\n * Reject any pending `ensureEditor()` callers and clear the shared promise so\n * a later call can retry.\n */\n private _failRichReady(reason: Error): void {\n if (this._rejectRichReady) {\n this._rejectRichReady(reason);\n }\n this._resolveRichReady = null;\n this._rejectRichReady = null;\n this._richReady = null;\n }\n\n /**\n * Request a textarea→rich upgrade. The upgrade may be declined or deferred:\n * returns without upgrading when already rich, when a concurrent upgrade is\n * in flight, when a teardown is pending (element scheduled for removal), when\n * a composition is in flight, or when the runtime is unavailable (SSR).\n */\n private async _requestRichUpgrade(): Promise<void> {\n if (this._mode === 'rich' || this._upgrading) {\n return;\n }\n this._upgrading = true;\n try {\n const module = getRichRuntimeIfLoaded() ?? (await loadRichRuntime());\n // After the async import, re-check all bail conditions — any of them can\n // have changed while the runtime was loading:\n // - `_pendingTeardownTimer`: element disconnected during the import; the\n // teardown is scheduled but hasn't run yet, so _editorHost and\n // _controller are still set. Mounting here would build an editor that\n // is destroyed a macrotask later, and resolve any pending ensureEditor()\n // with a dead editor. Reject instead.\n // - `_editorHost` / `_controller` null: real teardown already ran.\n // - `module` null: SSR or runtime load failed.\n if (!module || !this._editorHost || !this._controller) {\n this._failRichReady(\n new Error(\n module\n ? 'Input is not currently rendered'\n : 'Input editor runtime is unavailable'\n )\n );\n return;\n }\n if (this._pendingTeardownTimer !== null) {\n // Teardown is deferred but imminent. Reject so callers get a clear\n // error rather than a live editor that disappears one task later.\n this._failRichReady(new Error('Input is not currently rendered'));\n return;\n }\n if (this._isComposing) {\n // Defer until composition ends; `_richReady` stays pending and settles\n // when `_onCompositionEnd` re-runs the upgrade.\n this._pendingUpgrade = true;\n return;\n }\n this._swapToRich(module.createRichController());\n } catch (error) {\n // A failed runtime load or mount must reject pending `ensureEditor()`\n // callers rather than leave them hanging.\n this._failRichReady(\n error instanceof Error ? error : new Error(String(error))\n );\n } finally {\n this._upgrading = false;\n }\n }\n\n private _swapToRich(rich: PromptLineController): void {\n const previous = this._controller;\n const host = this._editorHost;\n if (!previous || !host) {\n return;\n }\n const value = previous.getValue();\n const selection = previous.getSelection();\n const hadFocus = previous.hasFocus();\n const hadKeyboardFocus = previous.getKeyboardFocus();\n\n previous.destroy();\n this._controller = rich;\n this._mode = 'rich';\n // Seeded losslessly from the textarea's text, which already reflects\n // `content`, so an in-flight identical `content` update stays a no-op.\n this._seededContent = this.content;\n this._seedPending = true;\n rich.mount(host, this._makeInit(value));\n\n rich.setTextSelection({\n from: textOffsetToDocPos(value, selection.from),\n to: textOffsetToDocPos(value, selection.to),\n });\n if (hadFocus) {\n rich.focus(hadKeyboardFocus, true);\n }\n this._settleRichReady();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-aichat-prompt-line': PromptLineElement;\n }\n}\n\nexport default PromptLineElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAsDH,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU,CAAA;AAA1C,IAAA,WAAA,GAAA;;AAKE;;;;;;;;;;;;;;;AAeG;QAEH,IAAA,CAAA,UAAU,GAAgB,EAAE;AAS5B;;;;AAIG;QAEH,IAAA,CAAA,IAAI,GAAG,KAAK;;QAIZ,IAAA,CAAA,QAAQ,GAAG,KAAK;;QAIhB,IAAA,CAAA,WAAW,GAAG,EAAE;;QAIP,IAAA,CAAA,SAAS,GAAG,SAAS;;QAI9B,IAAA,CAAA,MAAM,GAAG,EAAE;;QAIF,IAAA,CAAA,SAAS,GAAG,KAAK;QAElB,IAAA,CAAA,WAAW,GAAgC,IAAI;QAC/C,IAAA,CAAA,KAAK,GAAwB,UAAU;QACvC,IAAA,CAAA,WAAW,GAAuB,IAAI;QACtC,IAAA,CAAA,kBAAkB,GAAuB,IAAI;QAS7C,IAAA,CAAA,YAAY,GAAG,KAAK;;QAEpB,IAAA,CAAA,qBAAqB,GAAyC,IAAI;QAClE,IAAA,CAAA,oBAAoB,GAAmB,IAAI;;QAE3C,IAAA,CAAA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AQ/B,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAC7B,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAIb,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AACzB,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAIjB,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AACT,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAIR,UAAA,CAAA;AADR,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE;AACnC,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAI/B,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE;AACpC,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAIH,UAAA,CAAA;AADR,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;AACA,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAzDvB,iBAAiB,GAAA,UAAA,CAAA;AADtB,IAAA,aAAa,CAAC,CAAA,EAAG,MAAM,CAAA,YAAA,CAAc;AAChC,CAAA,EAAA,iBAAiB,CAsjBtB;AAQD,0BAAe,iBAAiB;;"}
|
|
@@ -33,7 +33,5 @@ export { TypingIndicator } from './typing-indicator.js';
|
|
|
33
33
|
export type { TypingIndicatorStorage } from './typing-indicator.js';
|
|
34
34
|
export { PlainTextPaste } from './plain-text-paste.js';
|
|
35
35
|
export { Keymap } from './keymap.js';
|
|
36
|
-
export { default as Placeholder } from '@tiptap/extension-placeholder';
|
|
37
|
-
export { UndoRedo } from '@tiptap/extensions';
|
|
38
36
|
export { HISTORY_DEFAULTS } from '../prompt-line-constants.js';
|
|
39
37
|
export type { StarterTriggerStorage } from './carbon-starter-trigger.js';
|
|
@@ -20,7 +20,5 @@ export { ValueSync } from './value-sync.js';
|
|
|
20
20
|
export { TypingIndicator } from './typing-indicator.js';
|
|
21
21
|
export { PlainTextPaste } from './plain-text-paste.js';
|
|
22
22
|
export { Keymap } from './keymap.js';
|
|
23
|
-
export { default as Placeholder } from '@tiptap/extension-placeholder';
|
|
24
|
-
export { UndoRedo } from '@tiptap/extensions';
|
|
25
23
|
export { HISTORY_DEFAULTS } from '../prompt-line-constants.js';
|
|
26
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -6,12 +6,16 @@
|
|
|
6
6
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
+
import type { SuggestionItem } from './types.js';
|
|
9
10
|
/**
|
|
10
11
|
* Shared resolver for BaseSuggestionConfig items: applies minQueryLength
|
|
11
12
|
* gating, delegates to the async function or filters the static array.
|
|
12
13
|
* Used by AutocompleteController — the canonical resolution path.
|
|
14
|
+
*
|
|
15
|
+
* When `items` is a static array, the default filter matches any item whose
|
|
16
|
+
* label contains the query (case-insensitive). Pass `items` as a function to
|
|
17
|
+
* use a different matching strategy.
|
|
13
18
|
*/
|
|
14
|
-
import type { SuggestionItem } from './types.js';
|
|
15
19
|
export declare function resolveConfigItems(config: {
|
|
16
20
|
items: SuggestionItem[] | ((query: string) => Promise<SuggestionItem[]> | SuggestionItem[]);
|
|
17
21
|
minQueryLength?: number;
|
|
@@ -13,6 +13,15 @@
|
|
|
13
13
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
14
|
* LICENSE file in the root directory of this source tree.
|
|
15
15
|
*/
|
|
16
|
+
/**
|
|
17
|
+
* Shared resolver for BaseSuggestionConfig items: applies minQueryLength
|
|
18
|
+
* gating, delegates to the async function or filters the static array.
|
|
19
|
+
* Used by AutocompleteController — the canonical resolution path.
|
|
20
|
+
*
|
|
21
|
+
* When `items` is a static array, the default filter matches any item whose
|
|
22
|
+
* label contains the query (case-insensitive). Pass `items` as a function to
|
|
23
|
+
* use a different matching strategy.
|
|
24
|
+
*/
|
|
16
25
|
async function resolveConfigItems(config, query) {
|
|
17
26
|
const minQueryLength = config.minQueryLength ?? 0;
|
|
18
27
|
if (query.length < minQueryLength) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-config-items.js","sources":["../../../../../src/components/prompt-line/src/tiptap/resolve-config-items.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 * Shared resolver for BaseSuggestionConfig items: applies minQueryLength\n * gating, delegates to the async function or filters the static array.\n * Used by AutocompleteController — the canonical resolution path.\n
|
|
1
|
+
{"version":3,"file":"resolve-config-items.js","sources":["../../../../../src/components/prompt-line/src/tiptap/resolve-config-items.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 type { SuggestionItem } from './types.js';\n\n/**\n * Shared resolver for BaseSuggestionConfig items: applies minQueryLength\n * gating, delegates to the async function or filters the static array.\n * Used by AutocompleteController — the canonical resolution path.\n *\n * When `items` is a static array, the default filter matches any item whose\n * label contains the query (case-insensitive). Pass `items` as a function to\n * use a different matching strategy.\n */\nexport async function resolveConfigItems(\n config: {\n items:\n | SuggestionItem[]\n | ((query: string) => Promise<SuggestionItem[]> | SuggestionItem[]);\n minQueryLength?: number;\n },\n query: string\n): Promise<SuggestionItem[]> {\n const minQueryLength = config.minQueryLength ?? 0;\n if (query.length < minQueryLength) {\n return [];\n }\n if (typeof config.items === 'function') {\n return await Promise.resolve(config.items(query));\n }\n if (!query) {\n return config.items;\n }\n const lower = query.toLowerCase();\n return config.items.filter((item) =>\n item.label.toLowerCase().includes(lower)\n );\n}\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAIH;;;;;;;;AAQG;AACI,eAAe,kBAAkB,CACtC,MAKC,EACD,KAAa,EAAA;AAEb,IAAA,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,CAAC;AACjD,IAAA,IAAI,KAAK,CAAC,MAAM,GAAG,cAAc,EAAE;AACjC,QAAA,OAAO,EAAE;IACX;AACA,IAAA,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,UAAU,EAAE;AACtC,QAAA,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnD;IACA,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,MAAM,CAAC,KAAK;IACrB;AACA,IAAA,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE;IACjC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,KAC9B,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CACzC;AACH;;"}
|
|
@@ -11,7 +11,7 @@ import { classMap } from 'lit/directives/class-map.js';
|
|
|
11
11
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
12
12
|
import { property, state } from 'lit/decorators.js';
|
|
13
13
|
import { iconLoader } from '@carbon/web-components/es/globals/internal/icon-loader.js';
|
|
14
|
-
import
|
|
14
|
+
import ChevronDown16 from '@carbon/icons/es/chevron--down/16.js';
|
|
15
15
|
import commonStyles from '../../../globals/scss/common.scss.js';
|
|
16
16
|
import styles from './reasoning-step.scss.js';
|
|
17
17
|
import prefix from '../../../globals/settings.js';
|
|
@@ -164,7 +164,7 @@ let CDSAIChatReasoningStep = class CDSAIChatReasoningStep extends LitElement {
|
|
|
164
164
|
@click=${this.handleButtonClick}
|
|
165
165
|
@keydown=${this.handleButtonKeydown}>
|
|
166
166
|
<span class="${baseClass}__icon" part="expando-icon" aria-hidden="true">
|
|
167
|
-
${iconLoader(
|
|
167
|
+
${iconLoader(ChevronDown16)}
|
|
168
168
|
</span>
|
|
169
169
|
<div class="${baseClass}__title" part="title">
|
|
170
170
|
<slot name="title">${this.title}</slot>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reasoning-step.js","sources":["../../../../src/components/reasoning-steps/src/reasoning-step.ts"],"sourcesContent":["/*\n * Copyright IBM Corp. 2025, 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 * @license\n */\n\nimport { LitElement, html } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { property, state } from 'lit/decorators.js';\nimport { iconLoader } from '@carbon/web-components/es/globals/internal/icon-loader.js';\nimport ChevronRight16 from '@carbon/icons/es/chevron--right/16.js';\nimport commonStyles from '../../../globals/scss/common.scss?lit';\nimport styles from './reasoning-step.scss?lit';\nimport prefix from '../../../globals/settings.js';\nimport { carbonElement } from '../../../globals/decorators';\n\nconst baseClass = `${prefix}--reasoning-step`;\nlet idCounter = 0;\n\nconst generateId = (segment: string) =>\n `${baseClass}-${segment}-${idCounter++}`;\n\n/**\n * Reasoning step component\n * @element cds-aichat-reasoning-step\n */\n@carbonElement(`${prefix}-reasoning-step`)\nclass CDSAIChatReasoningStep extends LitElement {\n static styles = [commonStyles, styles];\n\n @property({ type: String, attribute: 'title' })\n title = '';\n\n @property({ type: Boolean, attribute: 'open', reflect: true })\n open = false;\n\n @property({ type: Boolean, attribute: 'controlled', reflect: true })\n controlled = false;\n\n /**\n * @internal\n */\n @state()\n private hasBodyContent = false;\n\n /**\n * @internal\n */\n private headerId = generateId('header');\n\n /**\n * @internal\n */\n private contentId = generateId('content');\n\n connectedCallback() {\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'listitem');\n }\n\n super.connectedCallback();\n this.evaluateBodyContent();\n }\n\n firstUpdated() {\n const slot =\n this.shadowRoot?.querySelector<HTMLSlotElement>('slot:not([name])');\n const nodes = slot?.assignedNodes({ flatten: true });\n this.evaluateBodyContent(nodes);\n this.updatePanelInertState();\n }\n\n updated(changedProperties: Map<string, unknown>) {\n super.updated(changedProperties);\n\n if (\n changedProperties.has('open') ||\n changedProperties.has('hasBodyContent')\n ) {\n this.updatePanelInertState();\n }\n\n // Announce when a real open/close toggle has settled so the scroll manager can\n // recalculate geometry. Skip the initial render (no previous value).\n if (\n changedProperties.has('open') &&\n changedProperties.get('open') !== undefined\n ) {\n this.emitAnimationEndWhenSettled();\n }\n }\n\n private getTriggerElement(): HTMLButtonElement | null {\n if (!this.shadowRoot) {\n return null;\n }\n\n return this.shadowRoot.querySelector<HTMLButtonElement>(\n `.${baseClass}__trigger`\n );\n }\n\n private evaluateBodyContent(nodes?: readonly Node[]) {\n const nodesToInspect = nodes ?? Array.from(this.childNodes);\n const hasContent = nodesToInspect.some((node) => this.isBodyNode(node));\n\n if (hasContent !== this.hasBodyContent) {\n this.hasBodyContent = hasContent;\n\n if (!hasContent && this.open && !this.controlled) {\n this.open = false;\n }\n\n this.updatePanelInertState();\n }\n }\n\n private isBodyNode(node: Node) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const element = node as HTMLElement;\n const slotName = element.getAttribute('slot');\n\n return !slotName;\n }\n\n if (node.nodeType === Node.TEXT_NODE) {\n return Boolean(node.textContent?.trim());\n }\n\n return false;\n }\n\n private handleBodySlotChange(event: Event) {\n // Use currentTarget, not target: slotchange events bubble, so a nested <slot> inside slotted\n // content (e.g. the named slot inside a user_defined response wrapper) can fire its own\n // slotchange that reaches this handler with event.target pointing at that nested slot.\n // event.currentTarget is always this component's unnamed body slot.\n const slot = event.currentTarget as HTMLSlotElement;\n const nodes = slot.assignedNodes({ flatten: true });\n\n this.evaluateBodyContent(nodes);\n this.updatePanelInertState();\n }\n\n private handleToggleRequest(nextState = !this.open) {\n const detail = { open: nextState };\n const init = {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail,\n };\n const canToggle = this.dispatchEvent(\n new CustomEvent('reasoning-step-beingtoggled', init)\n );\n\n if (!canToggle) {\n return;\n }\n\n if (!this.controlled) {\n this.open = nextState;\n }\n\n this.dispatchEvent(new CustomEvent('reasoning-step-toggled', init));\n }\n\n private handleButtonClick() {\n this.handleToggleRequest(!this.open);\n }\n\n private handleButtonKeydown(event: KeyboardEvent) {\n if (!this.open) {\n return;\n }\n\n if (event.key === 'Escape' || event.key === 'Esc') {\n event.stopPropagation();\n this.handleToggleRequest(false);\n }\n }\n\n focus(options?: FocusOptions) {\n const trigger = this.getTriggerElement();\n\n if (trigger) {\n trigger.focus(options);\n return;\n }\n\n super.focus(options);\n }\n\n private renderInteractiveHeader() {\n return html`\n <button\n id=${this.headerId}\n type=\"button\"\n part=\"expando\"\n class=\"${baseClass}__trigger\"\n aria-expanded=\"${String(this.open)}\"\n aria-controls=\"${this.contentId}\"\n @click=${this.handleButtonClick}\n @keydown=${this.handleButtonKeydown}>\n <span class=\"${baseClass}__icon\" part=\"expando-icon\" aria-hidden=\"true\">\n ${iconLoader(ChevronRight16)}\n </span>\n <div class=\"${baseClass}__title\" part=\"title\">\n <slot name=\"title\">${this.title}</slot>\n </div>\n </button>\n `;\n }\n\n private renderStaticHeader() {\n return html`\n <div class=\"${baseClass}__static\" id=${this.headerId}>\n <span class=\"${baseClass}__static-icon\" aria-hidden=\"true\"\n >—</span\n >\n <div class=\"${baseClass}__title\" part=\"title\">\n <slot name=\"title\">${this.title}</slot>\n </div>\n </div>\n `;\n }\n\n /**\n * The panel animates `grid-template-rows` when the step expands/collapses. We wait for\n * any in-flight transition on the panel to finish, then emit a composed event so\n * consumers (e.g. the message list's scroll manager) can recalculate scroll geometry\n * against the settled layout.\n *\n * Using the Web Animations API (`getAnimations`) handles both cases with one path: when a\n * transition runs we resolve on its `finished` promise, and when nothing animates (reduced\n * motion, or a collapse that snaps without a transition) there are no animations so we emit\n * immediately. The rAF lets the just-changed style flush so a pending transition is\n * registered before we read it.\n */\n private emitAnimationEndWhenSettled() {\n requestAnimationFrame(() => {\n const panel = this.shadowRoot?.querySelector<HTMLElement>(\n `.${baseClass}__panel`\n );\n const emit = () =>\n this.dispatchEvent(\n new CustomEvent('reasoning-animation-end', {\n bubbles: true,\n composed: true,\n detail: { open: this.open },\n })\n );\n // Only the `grid-template-rows` transition changes block size; awaiting the\n // panel's opacity/padding transitions too can delay the emit well past the\n // height settling. If it is not animating, the height is already final.\n const animations = (panel?.getAnimations?.() ?? []).filter(\n (animation): animation is CSSTransition =>\n animation instanceof CSSTransition &&\n animation.transitionProperty === 'grid-template-rows'\n );\n if (!animations.length) {\n emit();\n return;\n }\n Promise.allSettled(\n animations.map((animation) => animation.finished)\n ).then(emit);\n });\n }\n\n private renderPanel() {\n const isHidden = !this.hasBodyContent;\n const panelClasses = classMap({\n [`${baseClass}__panel`]: true,\n [`${baseClass}__panel--hidden`]: isHidden,\n });\n\n return html`\n <div\n id=${this.contentId}\n class=${panelClasses}\n part=\"wrapper\"\n aria-hidden=\"${this.open && !isHidden ? 'false' : 'true'}\"\n role=${ifDefined(!isHidden ? 'region' : undefined)}\n aria-labelledby=${ifDefined(!isHidden ? this.headerId : undefined)}\n ?hidden=${isHidden}>\n <div\n class=\"${baseClass}__panel-body\"\n part=\"content\"\n data-visible=\"${this.open && !isHidden}\">\n <slot\n @slotchange=${this.handleBodySlotChange}\n ?hidden=${isHidden}></slot>\n </div>\n </div>\n `;\n }\n\n /**\n * Apply/remove inert on assigned elements so they are untabbable when closed.\n */\n private updatePanelInertState() {\n const slot =\n this.shadowRoot?.querySelector<HTMLSlotElement>('slot:not([name])');\n\n if (!slot) {\n return;\n }\n\n const shouldInert = !this.open || !this.hasBodyContent;\n const assignedElements = slot.assignedElements({ flatten: true });\n\n assignedElements.forEach((element) => {\n element.toggleAttribute('inert', shouldInert);\n });\n }\n\n render() {\n const classes = classMap({\n [baseClass]: true,\n [`${baseClass}--open`]: this.open && this.hasBodyContent,\n [`${baseClass}--static`]: !this.hasBodyContent,\n });\n\n return html`\n <div class=${classes}>\n ${\n this.hasBodyContent\n ? this.renderInteractiveHeader()\n : this.renderStaticHeader()\n }\n ${this.renderPanel()}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-aichat-reasoning-step': CDSAIChatReasoningStep;\n }\n}\n\nexport { CDSAIChatReasoningStep };\nexport default CDSAIChatReasoningStep;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAaH,MAAM,SAAS,GAAG,CAAA,EAAG,MAAM,kBAAkB;AAC7C,IAAI,SAAS,GAAG,CAAC;AAEjB,MAAM,UAAU,GAAG,CAAC,OAAe,KACjC,CAAA,EAAG,SAAS,IAAI,OAAO,CAAA,CAAA,EAAI,SAAS,EAAE,EAAE;AAE1C;;;AAGG;AAEH,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,UAAU,CAAA;AAA/C,IAAA,WAAA,GAAA;;QAIE,IAAA,CAAA,KAAK,GAAG,EAAE;QAGV,IAAA,CAAA,IAAI,GAAG,KAAK;QAGZ,IAAA,CAAA,UAAU,GAAG,KAAK;AAElB;;AAEG;QAEK,IAAA,CAAA,cAAc,GAAG,KAAK;AAE9B;;AAEG;AACK,QAAA,IAAA,CAAA,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;AAEvC;;AAEG;AACK,QAAA,IAAA,CAAA,SAAS,GAAG,UAAU,CAAC,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,EAAA,MAAA,CAAA;AAhB3B,sBAAsB,GAAA,UAAA,CAAA;AAD3B,IAAA,aAAa,CAAC,CAAA,EAAG,MAAM,CAAA,eAAA,CAAiB;AACnC,CAAA,EAAA,sBAAsB,CAoT3B;AASD,+BAAe,sBAAsB;;"}
|
|
1
|
+
{"version":3,"file":"reasoning-step.js","sources":["../../../../src/components/reasoning-steps/src/reasoning-step.ts"],"sourcesContent":["/*\n * Copyright IBM Corp. 2025, 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 * @license\n */\n\nimport { LitElement, html } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { property, state } from 'lit/decorators.js';\nimport { iconLoader } from '@carbon/web-components/es/globals/internal/icon-loader.js';\nimport ChevronDown16 from '@carbon/icons/es/chevron--down/16.js';\nimport commonStyles from '../../../globals/scss/common.scss?lit';\nimport styles from './reasoning-step.scss?lit';\nimport prefix from '../../../globals/settings.js';\nimport { carbonElement } from '../../../globals/decorators';\n\nconst baseClass = `${prefix}--reasoning-step`;\nlet idCounter = 0;\n\nconst generateId = (segment: string) =>\n `${baseClass}-${segment}-${idCounter++}`;\n\n/**\n * Reasoning step component\n * @element cds-aichat-reasoning-step\n */\n@carbonElement(`${prefix}-reasoning-step`)\nclass CDSAIChatReasoningStep extends LitElement {\n static styles = [commonStyles, styles];\n\n @property({ type: String, attribute: 'title' })\n title = '';\n\n @property({ type: Boolean, attribute: 'open', reflect: true })\n open = false;\n\n @property({ type: Boolean, attribute: 'controlled', reflect: true })\n controlled = false;\n\n /**\n * @internal\n */\n @state()\n private hasBodyContent = false;\n\n /**\n * @internal\n */\n private headerId = generateId('header');\n\n /**\n * @internal\n */\n private contentId = generateId('content');\n\n connectedCallback() {\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'listitem');\n }\n\n super.connectedCallback();\n this.evaluateBodyContent();\n }\n\n firstUpdated() {\n const slot =\n this.shadowRoot?.querySelector<HTMLSlotElement>('slot:not([name])');\n const nodes = slot?.assignedNodes({ flatten: true });\n this.evaluateBodyContent(nodes);\n this.updatePanelInertState();\n }\n\n updated(changedProperties: Map<string, unknown>) {\n super.updated(changedProperties);\n\n if (\n changedProperties.has('open') ||\n changedProperties.has('hasBodyContent')\n ) {\n this.updatePanelInertState();\n }\n\n // Announce when a real open/close toggle has settled so the scroll manager can\n // recalculate geometry. Skip the initial render (no previous value).\n if (\n changedProperties.has('open') &&\n changedProperties.get('open') !== undefined\n ) {\n this.emitAnimationEndWhenSettled();\n }\n }\n\n private getTriggerElement(): HTMLButtonElement | null {\n if (!this.shadowRoot) {\n return null;\n }\n\n return this.shadowRoot.querySelector<HTMLButtonElement>(\n `.${baseClass}__trigger`\n );\n }\n\n private evaluateBodyContent(nodes?: readonly Node[]) {\n const nodesToInspect = nodes ?? Array.from(this.childNodes);\n const hasContent = nodesToInspect.some((node) => this.isBodyNode(node));\n\n if (hasContent !== this.hasBodyContent) {\n this.hasBodyContent = hasContent;\n\n if (!hasContent && this.open && !this.controlled) {\n this.open = false;\n }\n\n this.updatePanelInertState();\n }\n }\n\n private isBodyNode(node: Node) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const element = node as HTMLElement;\n const slotName = element.getAttribute('slot');\n\n return !slotName;\n }\n\n if (node.nodeType === Node.TEXT_NODE) {\n return Boolean(node.textContent?.trim());\n }\n\n return false;\n }\n\n private handleBodySlotChange(event: Event) {\n // Use currentTarget, not target: slotchange events bubble, so a nested <slot> inside slotted\n // content (e.g. the named slot inside a user_defined response wrapper) can fire its own\n // slotchange that reaches this handler with event.target pointing at that nested slot.\n // event.currentTarget is always this component's unnamed body slot.\n const slot = event.currentTarget as HTMLSlotElement;\n const nodes = slot.assignedNodes({ flatten: true });\n\n this.evaluateBodyContent(nodes);\n this.updatePanelInertState();\n }\n\n private handleToggleRequest(nextState = !this.open) {\n const detail = { open: nextState };\n const init = {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail,\n };\n const canToggle = this.dispatchEvent(\n new CustomEvent('reasoning-step-beingtoggled', init)\n );\n\n if (!canToggle) {\n return;\n }\n\n if (!this.controlled) {\n this.open = nextState;\n }\n\n this.dispatchEvent(new CustomEvent('reasoning-step-toggled', init));\n }\n\n private handleButtonClick() {\n this.handleToggleRequest(!this.open);\n }\n\n private handleButtonKeydown(event: KeyboardEvent) {\n if (!this.open) {\n return;\n }\n\n if (event.key === 'Escape' || event.key === 'Esc') {\n event.stopPropagation();\n this.handleToggleRequest(false);\n }\n }\n\n focus(options?: FocusOptions) {\n const trigger = this.getTriggerElement();\n\n if (trigger) {\n trigger.focus(options);\n return;\n }\n\n super.focus(options);\n }\n\n private renderInteractiveHeader() {\n return html`\n <button\n id=${this.headerId}\n type=\"button\"\n part=\"expando\"\n class=\"${baseClass}__trigger\"\n aria-expanded=\"${String(this.open)}\"\n aria-controls=\"${this.contentId}\"\n @click=${this.handleButtonClick}\n @keydown=${this.handleButtonKeydown}>\n <span class=\"${baseClass}__icon\" part=\"expando-icon\" aria-hidden=\"true\">\n ${iconLoader(ChevronDown16)}\n </span>\n <div class=\"${baseClass}__title\" part=\"title\">\n <slot name=\"title\">${this.title}</slot>\n </div>\n </button>\n `;\n }\n\n private renderStaticHeader() {\n return html`\n <div class=\"${baseClass}__static\" id=${this.headerId}>\n <span class=\"${baseClass}__static-icon\" aria-hidden=\"true\"\n >—</span\n >\n <div class=\"${baseClass}__title\" part=\"title\">\n <slot name=\"title\">${this.title}</slot>\n </div>\n </div>\n `;\n }\n\n /**\n * The panel animates `grid-template-rows` when the step expands/collapses. We wait for\n * any in-flight transition on the panel to finish, then emit a composed event so\n * consumers (e.g. the message list's scroll manager) can recalculate scroll geometry\n * against the settled layout.\n *\n * Using the Web Animations API (`getAnimations`) handles both cases with one path: when a\n * transition runs we resolve on its `finished` promise, and when nothing animates (reduced\n * motion, or a collapse that snaps without a transition) there are no animations so we emit\n * immediately. The rAF lets the just-changed style flush so a pending transition is\n * registered before we read it.\n */\n private emitAnimationEndWhenSettled() {\n requestAnimationFrame(() => {\n const panel = this.shadowRoot?.querySelector<HTMLElement>(\n `.${baseClass}__panel`\n );\n const emit = () =>\n this.dispatchEvent(\n new CustomEvent('reasoning-animation-end', {\n bubbles: true,\n composed: true,\n detail: { open: this.open },\n })\n );\n // Only the `grid-template-rows` transition changes block size; awaiting the\n // panel's opacity/padding transitions too can delay the emit well past the\n // height settling. If it is not animating, the height is already final.\n const animations = (panel?.getAnimations?.() ?? []).filter(\n (animation): animation is CSSTransition =>\n animation instanceof CSSTransition &&\n animation.transitionProperty === 'grid-template-rows'\n );\n if (!animations.length) {\n emit();\n return;\n }\n Promise.allSettled(\n animations.map((animation) => animation.finished)\n ).then(emit);\n });\n }\n\n private renderPanel() {\n const isHidden = !this.hasBodyContent;\n const panelClasses = classMap({\n [`${baseClass}__panel`]: true,\n [`${baseClass}__panel--hidden`]: isHidden,\n });\n\n return html`\n <div\n id=${this.contentId}\n class=${panelClasses}\n part=\"wrapper\"\n aria-hidden=\"${this.open && !isHidden ? 'false' : 'true'}\"\n role=${ifDefined(!isHidden ? 'region' : undefined)}\n aria-labelledby=${ifDefined(!isHidden ? this.headerId : undefined)}\n ?hidden=${isHidden}>\n <div\n class=\"${baseClass}__panel-body\"\n part=\"content\"\n data-visible=\"${this.open && !isHidden}\">\n <slot\n @slotchange=${this.handleBodySlotChange}\n ?hidden=${isHidden}></slot>\n </div>\n </div>\n `;\n }\n\n /**\n * Apply/remove inert on assigned elements so they are untabbable when closed.\n */\n private updatePanelInertState() {\n const slot =\n this.shadowRoot?.querySelector<HTMLSlotElement>('slot:not([name])');\n\n if (!slot) {\n return;\n }\n\n const shouldInert = !this.open || !this.hasBodyContent;\n const assignedElements = slot.assignedElements({ flatten: true });\n\n assignedElements.forEach((element) => {\n element.toggleAttribute('inert', shouldInert);\n });\n }\n\n render() {\n const classes = classMap({\n [baseClass]: true,\n [`${baseClass}--open`]: this.open && this.hasBodyContent,\n [`${baseClass}--static`]: !this.hasBodyContent,\n });\n\n return html`\n <div class=${classes}>\n ${\n this.hasBodyContent\n ? this.renderInteractiveHeader()\n : this.renderStaticHeader()\n }\n ${this.renderPanel()}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-aichat-reasoning-step': CDSAIChatReasoningStep;\n }\n}\n\nexport { CDSAIChatReasoningStep };\nexport default CDSAIChatReasoningStep;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAaH,MAAM,SAAS,GAAG,CAAA,EAAG,MAAM,kBAAkB;AAC7C,IAAI,SAAS,GAAG,CAAC;AAEjB,MAAM,UAAU,GAAG,CAAC,OAAe,KACjC,CAAA,EAAG,SAAS,IAAI,OAAO,CAAA,CAAA,EAAI,SAAS,EAAE,EAAE;AAE1C;;;AAGG;AAEH,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,UAAU,CAAA;AAA/C,IAAA,WAAA,GAAA;;QAIE,IAAA,CAAA,KAAK,GAAG,EAAE;QAGV,IAAA,CAAA,IAAI,GAAG,KAAK;QAGZ,IAAA,CAAA,UAAU,GAAG,KAAK;AAElB;;AAEG;QAEK,IAAA,CAAA,cAAc,GAAG,KAAK;AAE9B;;AAEG;AACK,QAAA,IAAA,CAAA,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;AAEvC;;AAEG;AACK,QAAA,IAAA,CAAA,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;IA0R3C;IAxRE,iBAAiB,GAAA;QACf,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;AAC9B,YAAA,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC;QACvC;QAEA,KAAK,CAAC,iBAAiB,EAAE;QACzB,IAAI,CAAC,mBAAmB,EAAE;IAC5B;IAEA,YAAY,GAAA;QACV,MAAM,IAAI,GACR,IAAI,CAAC,UAAU,EAAE,aAAa,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display:block}:host([hidden]){display:none}.cds-aichat__panel--hidden{display:none}.cds-aichat--reasoning-step{inline-size:100%}.cds-aichat--reasoning-step__trigger{align-items:center;background:transparent;block-size:1.5rem;border:0;border-radius:.125rem;color:var(--cds-text-helper,#6f6f6f);cursor:pointer;display:flex;font:inherit;gap:.25rem;inline-size:100%;padding:0;padding-inline-start:.25rem;text-align:start}.cds-aichat--reasoning-step__trigger:hover{background-color:var(--cds-layer-hover-01,#e8e8e8)}.cds-aichat--reasoning-step__trigger:focus-visible{outline:2px solid var(--cds-focus,#0f62fe);outline-offset:2px}.cds-aichat--reasoning-step__icon{align-items:center;block-size:1lh;display:inline-flex;inline-size:1rem;justify-content:center;transition:transform .24s cubic-bezier(.2,0,.38,.9)}.cds-aichat--reasoning-step__icon svg{fill:currentColor;block-size:100%;inline-size:100%}:host([open]) .cds-aichat--reasoning-step__icon{transform:rotate(
|
|
10
|
+
var styles = css([":host{background-color:transparent;border:0;color:var(--cds-text-secondary,#525252);display:block}:host([hidden]){display:none}.cds-aichat__panel--hidden{display:none}.cds-aichat--reasoning-step{inline-size:100%}.cds-aichat--reasoning-step__trigger{align-items:center;background:transparent;block-size:1.5rem;border:0;border-radius:.125rem;color:var(--cds-text-helper,#6f6f6f);cursor:pointer;display:flex;font:inherit;gap:.25rem;inline-size:100%;padding:0;padding-inline-start:.25rem;text-align:start}.cds-aichat--reasoning-step__trigger:hover{background-color:var(--cds-layer-hover-01,#e8e8e8)}.cds-aichat--reasoning-step__trigger:focus-visible{outline:2px solid var(--cds-focus,#0f62fe);outline-offset:2px}.cds-aichat--reasoning-step__icon{align-items:center;block-size:1lh;display:inline-flex;inline-size:1rem;justify-content:center;transition:transform .24s cubic-bezier(.2,0,.38,.9)}.cds-aichat--reasoning-step__icon svg{fill:currentColor;block-size:100%;inline-size:100%}:host([open]) .cds-aichat--reasoning-step__icon{transform:rotate(180deg)}.cds-aichat--reasoning-step__title{color:var(--cds-text-secondary,#525252);flex:1;font-size:var(--cds-heading-01-font-size,.875rem);font-weight:var(--cds-heading-01-font-weight,600);letter-spacing:var(--cds-heading-01-letter-spacing,.16px);line-height:var(--cds-heading-01-line-height,1.42857)}.cds-aichat--reasoning-step__static{align-items:start;display:flex;gap:.25rem;padding-inline-start:.25rem}.cds-aichat--reasoning-step__static-icon{align-items:center;block-size:1lh;display:inline-flex;inline-size:1rem;justify-content:center}.cds-aichat--reasoning-step__static-icon svg{fill:currentColor;block-size:100%;inline-size:100%}.cds-aichat--reasoning-step__panel{display:grid;grid-template-rows:0fr;opacity:0;padding-block-end:0;padding-block-start:0;padding-inline:1.5rem;pointer-events:none;transition:grid-template-rows .11s cubic-bezier(0,0,.38,.9),opacity .11s cubic-bezier(0,0,.38,.9),padding-block-end .11s cubic-bezier(0,0,.38,.9)}.cds-aichat--reasoning-step__panel[hidden]{display:none}:host([open]) .cds-aichat--reasoning-step__panel{grid-template-rows:1fr;opacity:1;padding-block-end:.25rem;padding-block-start:.125rem;pointer-events:auto}.cds-aichat--reasoning-step__panel-body{min-block-size:0;overflow:hidden}"]);
|
|
11
11
|
|
|
12
12
|
export { styles as default };
|
|
13
13
|
//# sourceMappingURL=reasoning-step.scss.js.map
|
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
/**
|
|
17
17
|
* Writes runtime-dynamic CSS custom properties via a single Constructable
|
|
18
18
|
* Stylesheet. Lets us update CSS variable values from JS without touching any
|
|
19
|
-
* element's inline `style` attribute
|
|
20
|
-
* `style-src-attr 'unsafe-inline'`) would block.
|
|
19
|
+
* element's inline `style` attribute.
|
|
21
20
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* `style
|
|
21
|
+
* A strict CSP (no `style-src-attr 'unsafe-inline'`) blocks a `style`
|
|
22
|
+
* attribute set in markup or through `setAttribute`. It does not block
|
|
23
|
+
* properties set through an element's `style` object, such as
|
|
24
|
+
* `el.style.setProperty()`, so CSP alone does not require this sheet. Rule
|
|
25
|
+
* changes on the sheet pass a strict policy too.
|
|
26
|
+
* https://developer.mozilla.org/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/style-src
|
|
26
27
|
*
|
|
27
28
|
* The shared sheet must be adopted on every root (document or shadow root)
|
|
28
29
|
* where its selectors need to apply. Callers in shadow DOM should call
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-css-var-sheet.js","sources":["../../../src/components/shared/dynamic-css-var-sheet.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 * Writes runtime-dynamic CSS custom properties via a single Constructable\n * Stylesheet. Lets us update CSS variable values from JS without touching any\n * element's inline `style` attribute, which a strict CSP (no\n * `style-src-attr 'unsafe-inline'`) would block.\n *\n * Why a stylesheet, not `el.style.setProperty`: setProperty mutates the\n * element's `style` attribute and is governed by `style-src-attr`. Mutations\n * to a CSSStyleSheet that the document already trusts are governed by\n * `style-src` and pass without `'unsafe-inline'`.\n *\n * The shared sheet must be adopted on every root (document or shadow root)\n * where its selectors need to apply. Callers in shadow DOM should call\n * `adoptOnRoot(this.getRootNode())` once in `connectedCallback`. Selectors\n * targeting host elements are sufficient: CSS custom properties inherit\n * across the shadow boundary from the host into the shadow tree.\n */\n\nconst declarationsBySelector = new Map<string, Map<string, string>>();\nconst adoptedRoots = new WeakSet<Document | ShadowRoot>();\nconst fallbackStyleElements = new WeakMap<\n Document | ShadowRoot,\n HTMLStyleElement\n>();\nconst fallbackRoots = new Set<Document | ShadowRoot>();\nlet sheet: CSSStyleSheet | null = null;\n\nfunction getCssText(): string {\n return Array.from(declarationsBySelector.entries())\n .map(([selector, declarations]) => {\n const decls = Array.from(declarations.entries())\n .map(([prop, value]) => `${prop}: ${value};`)\n .join(' ');\n return `${selector} { ${decls} }`;\n })\n .join('\\n');\n}\n\nfunction ensureSheet(): CSSStyleSheet | null {\n if (sheet) {\n return sheet;\n }\n if (typeof document === 'undefined' || typeof CSSStyleSheet === 'undefined') {\n return null;\n }\n try {\n const candidate = new CSSStyleSheet();\n if (typeof (candidate as any).replaceSync !== 'function') {\n // Older browsers / jsdom may construct a sheet but not implement\n // the constructable-stylesheet write methods. Fall back to <style>.\n return null;\n }\n sheet = candidate;\n } catch {\n return null;\n }\n adoptOnRoot(document);\n return sheet;\n}\n\nfunction ensureFallbackStyleElement(\n root: Document | ShadowRoot\n): HTMLStyleElement | null {\n if (typeof document === 'undefined') {\n return null;\n }\n const existing = fallbackStyleElements.get(root);\n if (existing) {\n return existing;\n }\n const ownerDocument = root instanceof Document ? root : root.ownerDocument;\n if (!ownerDocument) {\n return null;\n }\n const styleElement = ownerDocument.createElement('style');\n const container =\n root instanceof Document ? (root.head ?? root.documentElement) : root;\n if (!container) {\n return null;\n }\n container.appendChild(styleElement);\n fallbackStyleElements.set(root, styleElement);\n return styleElement;\n}\n\nfunction rewrite(): void {\n const cssText = getCssText();\n if (sheet) {\n sheet.replaceSync(cssText);\n }\n for (const root of fallbackRoots) {\n const styleElement = fallbackStyleElements.get(root);\n if (styleElement) {\n styleElement.textContent = cssText;\n }\n }\n}\n\n/**\n * Flush a rewrite on a microtask rather than inline.\n *\n * The teardown helpers below run from component `disconnectedCallback`s, which\n * WebKit invokes while draining the custom-element reaction queue inside\n * `Element.remove()`. Mutating an adopted sheet in that window segfaults WebKit\n * in `Style::Invalidator::invalidateHostAndSlottedStyleIfNeeded`: it walks every\n * style scope adopting the sheet and dereferences a shadow-root host that isn't\n * valid mid-removal (#2201). Deferring past the removal sidesteps the window,\n * and is unobservable — nothing reads the sheet back after a rule is cleared.\n */\nlet teardownFlushScheduled = false;\nfunction rewriteAfterTeardown(): void {\n if (teardownFlushScheduled) {\n return;\n }\n teardownFlushScheduled = true;\n queueMicrotask(() => {\n teardownFlushScheduled = false;\n rewrite();\n });\n}\n\n/**\n * Adopt the shared dynamic stylesheet on a root so its rules apply within\n * that tree. Idempotent per root: subsequent calls for the same root are a\n * no-op so we don't spuriously create a fallback `<style>` element on top of\n * an already-adopted CSSStyleSheet (which trips strict CSP).\n */\nfunction adoptOnRoot(root: Document | ShadowRoot): void {\n if (adoptedRoots.has(root)) {\n return;\n }\n const s = ensureSheet();\n if (s) {\n // Some environments (older browsers, jsdom) don't implement\n // adoptedStyleSheets; fall back to a <style> element in that case.\n const current = (root as any).adoptedStyleSheets;\n if (\n Array.isArray(current) ||\n typeof current?.[Symbol.iterator] === 'function'\n ) {\n root.adoptedStyleSheets = [...current, s];\n adoptedRoots.add(root);\n return;\n }\n }\n const fallbackStyleElement = ensureFallbackStyleElement(root);\n if (fallbackStyleElement) {\n fallbackStyleElement.textContent = getCssText();\n fallbackRoots.add(root);\n adoptedRoots.add(root);\n }\n}\n\n/**\n * Merge CSS declarations into the rule for a selector. Multiple subsystems\n * can write disjoint properties for the same selector without clobbering\n * each other; existing properties are updated, new ones appended.\n *\n * The keys can be CSS custom properties (e.g. `--cds-aichat-foo`) or any\n * regular CSS property (`display`, `transform`, …).\n */\nfunction setVarsForSelector(\n selector: string,\n vars: Record<string, string>\n): void {\n if (!ensureSheet()) {\n return;\n }\n const existing = declarationsBySelector.get(selector) ?? new Map();\n let changed = false;\n for (const [prop, value] of Object.entries(vars)) {\n if (existing.get(prop) !== value) {\n existing.set(prop, value);\n changed = true;\n }\n }\n if (!changed) {\n return;\n }\n declarationsBySelector.set(selector, existing);\n rewrite();\n}\n\n/**\n * Remove the entire rule for a selector.\n */\nfunction clearSelector(selector: string): void {\n if (!declarationsBySelector.delete(selector)) {\n return;\n }\n rewriteAfterTeardown();\n}\n\n/**\n * Remove specific properties from a selector's rule, leaving any others\n * intact. If the rule ends up empty, it is dropped.\n */\nfunction clearVarsForSelector(selector: string, props: string[]): void {\n const existing = declarationsBySelector.get(selector);\n if (!existing) {\n return;\n }\n let changed = false;\n for (const prop of props) {\n if (existing.delete(prop)) {\n changed = true;\n }\n }\n if (!changed) {\n return;\n }\n if (existing.size === 0) {\n declarationsBySelector.delete(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I,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAChD,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE;AAChC,YAAA,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC;YACzB,OAAO,GAAG,IAAI;QAChB;IACF;IACA,IAAI,CAAC,OAAO,EAAE;QACZ;IACF;AACA,IAAA,sBAAsB,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC;AAC9C,IAAA,OAAO,EAAE;AACX;AAEA;;AAEG;AACH,SAAS,aAAa,CAAC,QAAgB,EAAA;IACrC,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;QAC5C;IACF;AACA,IAAA,oBAAoB,EAAE;AACxB;AAEA;;;AAGG;AACH,SAAS,oBAAoB,CAAC,QAAgB,EAAE,KAAe,EAAA;IAC7D,MAAM,QAAQ,GAAG,sBAAsB,CAAC,GAAG,CAAC,QAAQ,CAAC;IACrD,IAAI,CAAC,QAAQ,EAAE;QACb;IACF;IACA,IAAI,OAAO,GAAG,KAAK;AACnB,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;AACxB,QAAA,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACzB,OAAO,GAAG,IAAI;QAChB;IACF;IACA,IAAI,CAAC,OAAO,EAAE;QACZ;IACF;AACA,IAAA,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE;AACvB,QAAA,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC;IACzC;AACA,IAAA,oBAAoB,EAAE;AACxB;;"}
|
|
1
|
+
{"version":3,"file":"dynamic-css-var-sheet.js","sources":["../../../src/components/shared/dynamic-css-var-sheet.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 * Writes runtime-dynamic CSS custom properties via a single Constructable\n * Stylesheet. Lets us update CSS variable values from JS without touching any\n * element's inline `style` attribute.\n *\n * A strict CSP (no `style-src-attr 'unsafe-inline'`) blocks a `style`\n * attribute set in markup or through `setAttribute`. It does not block\n * properties set through an element's `style` object, such as\n * `el.style.setProperty()`, so CSP alone does not require this sheet. Rule\n * changes on the sheet pass a strict policy too.\n * https://developer.mozilla.org/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/style-src\n *\n * The shared sheet must be adopted on every root (document or shadow root)\n * where its selectors need to apply. Callers in shadow DOM should call\n * `adoptOnRoot(this.getRootNode())` once in `connectedCallback`. Selectors\n * targeting host elements are sufficient: CSS custom properties inherit\n * across the shadow boundary from the host into the shadow tree.\n */\n\nconst declarationsBySelector = new Map<string, Map<string, string>>();\nconst adoptedRoots = new WeakSet<Document | ShadowRoot>();\nconst fallbackStyleElements = new WeakMap<\n Document | ShadowRoot,\n HTMLStyleElement\n>();\nconst fallbackRoots = new Set<Document | ShadowRoot>();\nlet sheet: CSSStyleSheet | null = null;\n\nfunction getCssText(): string {\n return Array.from(declarationsBySelector.entries())\n .map(([selector, declarations]) => {\n const decls = Array.from(declarations.entries())\n .map(([prop, value]) => `${prop}: ${value};`)\n .join(' ');\n return `${selector} { ${decls} }`;\n })\n .join('\\n');\n}\n\nfunction ensureSheet(): CSSStyleSheet | null {\n if (sheet) {\n return sheet;\n }\n if (typeof document === 'undefined' || typeof CSSStyleSheet === 'undefined') {\n return null;\n }\n try {\n const candidate = new CSSStyleSheet();\n if (typeof (candidate as any).replaceSync !== 'function') {\n // Older browsers / jsdom may construct a sheet but not implement\n // the constructable-stylesheet write methods. Fall back to <style>.\n return null;\n }\n sheet = candidate;\n } catch {\n return null;\n }\n adoptOnRoot(document);\n return sheet;\n}\n\nfunction ensureFallbackStyleElement(\n root: Document | ShadowRoot\n): HTMLStyleElement | null {\n if (typeof document === 'undefined') {\n return null;\n }\n const existing = fallbackStyleElements.get(root);\n if (existing) {\n return existing;\n }\n const ownerDocument = root instanceof Document ? root : root.ownerDocument;\n if (!ownerDocument) {\n return null;\n }\n const styleElement = ownerDocument.createElement('style');\n const container =\n root instanceof Document ? (root.head ?? root.documentElement) : root;\n if (!container) {\n return null;\n }\n container.appendChild(styleElement);\n fallbackStyleElements.set(root, styleElement);\n return styleElement;\n}\n\nfunction rewrite(): void {\n const cssText = getCssText();\n if (sheet) {\n sheet.replaceSync(cssText);\n }\n for (const root of fallbackRoots) {\n const styleElement = fallbackStyleElements.get(root);\n if (styleElement) {\n styleElement.textContent = cssText;\n }\n }\n}\n\n/**\n * Flush a rewrite on a microtask rather than inline.\n *\n * The teardown helpers below run from component `disconnectedCallback`s, which\n * WebKit invokes while draining the custom-element reaction queue inside\n * `Element.remove()`. Mutating an adopted sheet in that window segfaults WebKit\n * in `Style::Invalidator::invalidateHostAndSlottedStyleIfNeeded`: it walks every\n * style scope adopting the sheet and dereferences a shadow-root host that isn't\n * valid mid-removal (#2201). Deferring past the removal sidesteps the window,\n * and is unobservable — nothing reads the sheet back after a rule is cleared.\n */\nlet teardownFlushScheduled = false;\nfunction rewriteAfterTeardown(): void {\n if (teardownFlushScheduled) {\n return;\n }\n teardownFlushScheduled = true;\n queueMicrotask(() => {\n teardownFlushScheduled = false;\n rewrite();\n });\n}\n\n/**\n * Adopt the shared dynamic stylesheet on a root so its rules apply within\n * that tree. Idempotent per root: subsequent calls for the same root are a\n * no-op so we don't spuriously create a fallback `<style>` element on top of\n * an already-adopted CSSStyleSheet (which trips strict CSP).\n */\nfunction adoptOnRoot(root: Document | ShadowRoot): void {\n if (adoptedRoots.has(root)) {\n return;\n }\n const s = ensureSheet();\n if (s) {\n // Some environments (older browsers, jsdom) don't implement\n // adoptedStyleSheets; fall back to a <style> element in that case.\n const current = (root as any).adoptedStyleSheets;\n if (\n Array.isArray(current) ||\n typeof current?.[Symbol.iterator] === 'function'\n ) {\n root.adoptedStyleSheets = [...current, s];\n adoptedRoots.add(root);\n return;\n }\n }\n const fallbackStyleElement = ensureFallbackStyleElement(root);\n if (fallbackStyleElement) {\n fallbackStyleElement.textContent = getCssText();\n fallbackRoots.add(root);\n adoptedRoots.add(root);\n }\n}\n\n/**\n * Merge CSS declarations into the rule for a selector. Multiple subsystems\n * can write disjoint properties for the same selector without clobbering\n * each other; existing properties are updated, new ones appended.\n *\n * The keys can be CSS custom properties (e.g. `--cds-aichat-foo`) or any\n * regular CSS property (`display`, `transform`, …).\n */\nfunction setVarsForSelector(\n selector: string,\n vars: Record<string, string>\n): void {\n if (!ensureSheet()) {\n return;\n }\n const existing = declarationsBySelector.get(selector) ?? new Map();\n let changed = false;\n for (const [prop, value] of Object.entries(vars)) {\n if (existing.get(prop) !== value) {\n existing.set(prop, value);\n changed = true;\n }\n }\n if (!changed) {\n return;\n }\n declarationsBySelector.set(selector, existing);\n rewrite();\n}\n\n/**\n * Remove the entire rule for a selector.\n */\nfunction clearSelector(selector: string): void {\n if (!declarationsBySelector.delete(selector)) {\n return;\n }\n rewriteAfterTeardown();\n}\n\n/**\n * Remove specific properties from a selector's rule, leaving any others\n * intact. If the rule ends up empty, it is dropped.\n */\nfunction clearVarsForSelector(selector: string, props: string[]): void {\n const existing = declarationsBySelector.get(selector);\n if (!existing) {\n return;\n }\n let changed = false;\n for (const prop of props) {\n if (existing.delete(prop)) {\n changed = true;\n }\n }\n if (!changed) {\n return;\n }\n if (existing.size === 0) {\n declarationsBySelector.delete(selector);\n }\n rewriteAfterTeardown();\n}\n\nexport { adoptOnRoot, setVarsForSelector, clearSelector, clearVarsForSelector };\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;AAEH;;;;;;;;;;;;;;;;;AAiBG;AAEH,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAA+B;AACrE,MAAM,YAAY,GAAG,IAAI,OAAO,EAAyB;AACzD,MAAM,qBAAqB,GAAG,IAAI,OAAO,EAGtC;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,EAAyB;AACtD,IAAI,KAAK,GAAy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G;AACH,SAAS,aAAa,CAAC,QAAgB,EAAA;IACrC,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;QAC5C;IACF;AACA,IAAA,oBAAoB,EAAE;AACxB;AAEA;;;AAGG;AACH,SAAS,oBAAoB,CAAC,QAAgB,EAAE,KAAe,EAAA;IAC7D,MAAM,QAAQ,GAAG,sBAAsB,CAAC,GAAG,CAAC,QAAQ,CAAC;IACrD,IAAI,CAAC,QAAQ,EAAE;QACb;IACF;IACA,IAAI,OAAO,GAAG,KAAK;AACnB,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;AACxB,QAAA,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACzB,OAAO,GAAG,IAAI;QAChB;IACF;IACA,IAAI,CAAC,OAAO,EAAE;QACZ;IACF;AACA,IAAA,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE;AACvB,QAAA,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC;IACzC;AACA,IAAA,oBAAoB,EAAE;AACxB;;"}
|
|
@@ -453,9 +453,8 @@ let CDSAIChatTable = class CDSAIChatTable extends LitElement {
|
|
|
453
453
|
// weren't enough rows to fill the page (even though the old rows weren't included in the new rows provided to the
|
|
454
454
|
// template). Using Carbon's example of hiding the rows with styling works so I'm extending that concept here even
|
|
455
455
|
// though, ideally, render controls the view and reacts to the state that would be determined here.
|
|
456
|
-
// Hide all the rows to start. Using a data attribute
|
|
457
|
-
//
|
|
458
|
-
// rule lives in table.scss.
|
|
456
|
+
// Hide all the rows to start. Using a data attribute; the matching rule
|
|
457
|
+
// lives in table.scss.
|
|
459
458
|
rows.forEach((row) => row.toggleAttribute('data-hidden', true));
|
|
460
459
|
// Now filter the rows down to what is visible according to the filter.
|
|
461
460
|
const filterVisibleRows = rows.filter((row) => this._filterVisibleRowIDs.has(row.id));
|
|
@@ -491,10 +490,9 @@ let CDSAIChatTable = class CDSAIChatTable extends LitElement {
|
|
|
491
490
|
const csvContent = stringifyCSV(tableArray);
|
|
492
491
|
// Use data URL instead of Blob to avoid CSP issues with object-src
|
|
493
492
|
const dataUrl = `data:text/csv;charset=utf-8,${encodeURIComponent(csvContent)}`;
|
|
494
|
-
// Create and trigger download using anchor element. The
|
|
495
|
-
//
|
|
496
|
-
//
|
|
497
|
-
// after click() so no flash is observed.
|
|
493
|
+
// Create and trigger download using anchor element. The link is
|
|
494
|
+
// `hidden` and removed synchronously after click() so no flash is
|
|
495
|
+
// observed.
|
|
498
496
|
const link = document.createElement('a');
|
|
499
497
|
link.setAttribute('href', dataUrl);
|
|
500
498
|
link.setAttribute('download', 'table-data.csv');
|