@carbon/ai-chat-components 1.11.0 → 1.12.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.
Files changed (148) hide show
  1. package/custom-elements.json +2414 -2161
  2. package/es/components/card/src/card-footer.scss.js +1 -1
  3. package/es/components/card/src/card-steps.scss.js +1 -1
  4. package/es/components/card/src/card.scss.js +1 -1
  5. package/es/components/chat-button/src/chat-button.scss.js +1 -1
  6. package/es/components/chat-history/src/history-panel-item-input.js +0 -1
  7. package/es/components/chat-history/src/history-panel-item-input.js.map +1 -1
  8. package/es/components/code-snippet/src/codemirror/language-controller.js +1 -1
  9. package/es/components/code-snippet/src/codemirror/language-controller.js.map +1 -1
  10. package/es/components/file-uploads/src/file-upload-item.d.ts +14 -1
  11. package/es/components/file-uploads/src/file-upload-item.js +78 -2
  12. package/es/components/file-uploads/src/file-upload-item.js.map +1 -1
  13. package/es/components/file-uploads/src/file-uploads.d.ts +29 -4
  14. package/es/components/file-uploads/src/file-uploads.js +69 -16
  15. package/es/components/file-uploads/src/file-uploads.js.map +1 -1
  16. package/es/components/launcher/src/launcher.scss.js +1 -1
  17. package/es/components/prompt-line/index.d.ts +3 -2
  18. package/es/components/prompt-line/index.js +2 -1
  19. package/es/components/prompt-line/index.js.map +1 -1
  20. package/es/components/prompt-line/src/__tests__/wait-for-rich.d.ts +20 -0
  21. package/es/components/prompt-line/src/autocomplete-controller-element.d.ts +68 -0
  22. package/es/components/prompt-line/src/autocomplete-controller-element.js +221 -0
  23. package/es/components/prompt-line/src/autocomplete-controller-element.js.map +1 -0
  24. package/es/components/prompt-line/src/autocomplete-controller.d.ts +10 -69
  25. package/es/components/prompt-line/src/autocomplete-controller.js +44 -251
  26. package/es/components/prompt-line/src/autocomplete-controller.js.map +1 -1
  27. package/es/components/prompt-line/src/prompt-line-rich-runtime.js +3 -0
  28. package/es/components/prompt-line/src/prompt-line-rich-runtime.js.map +1 -1
  29. package/es/components/prompt-line/src/prompt-line-shell.scss.js +1 -1
  30. package/es/components/prompt-line/src/prompt-line-textarea-runtime.js +0 -5
  31. package/es/components/prompt-line/src/prompt-line-textarea-runtime.js.map +1 -1
  32. package/es/components/prompt-line/src/prompt-line.js +1 -1
  33. package/es/components/prompt-line/src/prompt-line.js.map +1 -1
  34. package/es/components/prompt-line/src/tiptap/build-extensions.js +1 -1
  35. package/es/components/prompt-line/src/tiptap/build-extensions.js.map +1 -1
  36. package/es/components/prompt-line/src/tiptap/carbon-autocomplete.d.ts +5 -6
  37. package/es/components/prompt-line/src/tiptap/carbon-autocomplete.js +4 -28
  38. package/es/components/prompt-line/src/tiptap/carbon-autocomplete.js.map +1 -1
  39. package/es/components/prompt-line/src/tiptap/carbon-mention.js +13 -47
  40. package/es/components/prompt-line/src/tiptap/carbon-mention.js.map +1 -1
  41. package/es/components/prompt-line/src/tiptap/carbon-starter-trigger.js +3 -4
  42. package/es/components/prompt-line/src/tiptap/carbon-starter-trigger.js.map +1 -1
  43. package/es/components/prompt-line/src/tiptap/keymap.d.ts +1 -1
  44. package/es/components/prompt-line/src/tiptap/keymap.js +3 -4
  45. package/es/components/prompt-line/src/tiptap/keymap.js.map +1 -1
  46. package/es/components/prompt-line/src/tiptap/render-token-chip.js +0 -1
  47. package/es/components/prompt-line/src/tiptap/render-token-chip.js.map +1 -1
  48. package/es/components/prompt-line/src/tiptap/resolve-config-items.d.ts +18 -0
  49. package/es/components/prompt-line/src/tiptap/resolve-config-items.js +32 -0
  50. package/es/components/prompt-line/src/tiptap/resolve-config-items.js.map +1 -0
  51. package/es/components/prompt-line/src/tiptap/strip-presentation-fields.d.ts +18 -0
  52. package/es/components/prompt-line/src/tiptap/strip-presentation-fields.js +22 -0
  53. package/es/components/prompt-line/src/tiptap/strip-presentation-fields.js.map +1 -0
  54. package/es/components/prompt-line/src/tiptap/types.d.ts +11 -3
  55. package/es/components/toolbar/src/toolbar.d.ts +8 -0
  56. package/es/components/toolbar/src/toolbar.js +65 -19
  57. package/es/components/toolbar/src/toolbar.js.map +1 -1
  58. package/es/components/video-player/src/providers/vimeo-provider.js +1 -1
  59. package/es/components/video-player/src/providers/vimeo-provider.js.map +1 -1
  60. package/es/globals/decorators/carbon-element.js +2 -3
  61. package/es/globals/decorators/carbon-element.js.map +1 -1
  62. package/es/globals/utils/aria-announcer-manager.d.ts +56 -0
  63. package/es/globals/utils/aria-announcer-manager.js +46 -1
  64. package/es/globals/utils/aria-announcer-manager.js.map +1 -1
  65. package/es/globals/utils/focus-utils.js +1 -3
  66. package/es/globals/utils/focus-utils.js.map +1 -1
  67. package/es/globals/utils/iconTransform.d.ts +16 -2
  68. package/es/globals/utils/iconTransform.js +22 -1
  69. package/es/globals/utils/iconTransform.js.map +1 -1
  70. package/es/react/hooks/useChatAutocomplete.js.map +1 -1
  71. package/es/react/markdown.js +0 -1
  72. package/es/react/markdown.js.map +1 -1
  73. package/es/typings/overflow-menu.d.ts +4 -0
  74. package/es-custom/components/card/src/card-footer.scss.js +1 -1
  75. package/es-custom/components/card/src/card-steps.scss.js +1 -1
  76. package/es-custom/components/card/src/card.scss.js +1 -1
  77. package/es-custom/components/chat-button/src/chat-button.scss.js +1 -1
  78. package/es-custom/components/chat-history/src/history-panel-item-input.js +0 -1
  79. package/es-custom/components/chat-history/src/history-panel-item-input.js.map +1 -1
  80. package/es-custom/components/code-snippet/src/codemirror/language-controller.js +1 -1
  81. package/es-custom/components/code-snippet/src/codemirror/language-controller.js.map +1 -1
  82. package/es-custom/components/file-uploads/src/file-upload-item.d.ts +14 -1
  83. package/es-custom/components/file-uploads/src/file-upload-item.js +78 -2
  84. package/es-custom/components/file-uploads/src/file-upload-item.js.map +1 -1
  85. package/es-custom/components/file-uploads/src/file-uploads.d.ts +29 -4
  86. package/es-custom/components/file-uploads/src/file-uploads.js +69 -16
  87. package/es-custom/components/file-uploads/src/file-uploads.js.map +1 -1
  88. package/es-custom/components/launcher/src/launcher.scss.js +1 -1
  89. package/es-custom/components/prompt-line/index.d.ts +3 -2
  90. package/es-custom/components/prompt-line/index.js +2 -1
  91. package/es-custom/components/prompt-line/index.js.map +1 -1
  92. package/es-custom/components/prompt-line/src/__tests__/wait-for-rich.d.ts +20 -0
  93. package/es-custom/components/prompt-line/src/autocomplete-controller-element.d.ts +68 -0
  94. package/es-custom/components/prompt-line/src/autocomplete-controller-element.js +221 -0
  95. package/es-custom/components/prompt-line/src/autocomplete-controller-element.js.map +1 -0
  96. package/es-custom/components/prompt-line/src/autocomplete-controller.d.ts +10 -69
  97. package/es-custom/components/prompt-line/src/autocomplete-controller.js +44 -251
  98. package/es-custom/components/prompt-line/src/autocomplete-controller.js.map +1 -1
  99. package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.js +3 -0
  100. package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.js.map +1 -1
  101. package/es-custom/components/prompt-line/src/prompt-line-shell.scss.js +1 -1
  102. package/es-custom/components/prompt-line/src/prompt-line-textarea-runtime.js +0 -5
  103. package/es-custom/components/prompt-line/src/prompt-line-textarea-runtime.js.map +1 -1
  104. package/es-custom/components/prompt-line/src/prompt-line.js +1 -1
  105. package/es-custom/components/prompt-line/src/prompt-line.js.map +1 -1
  106. package/es-custom/components/prompt-line/src/tiptap/build-extensions.js +1 -1
  107. package/es-custom/components/prompt-line/src/tiptap/build-extensions.js.map +1 -1
  108. package/es-custom/components/prompt-line/src/tiptap/carbon-autocomplete.d.ts +5 -6
  109. package/es-custom/components/prompt-line/src/tiptap/carbon-autocomplete.js +4 -28
  110. package/es-custom/components/prompt-line/src/tiptap/carbon-autocomplete.js.map +1 -1
  111. package/es-custom/components/prompt-line/src/tiptap/carbon-mention.js +13 -47
  112. package/es-custom/components/prompt-line/src/tiptap/carbon-mention.js.map +1 -1
  113. package/es-custom/components/prompt-line/src/tiptap/carbon-starter-trigger.js +3 -4
  114. package/es-custom/components/prompt-line/src/tiptap/carbon-starter-trigger.js.map +1 -1
  115. package/es-custom/components/prompt-line/src/tiptap/keymap.d.ts +1 -1
  116. package/es-custom/components/prompt-line/src/tiptap/keymap.js +3 -4
  117. package/es-custom/components/prompt-line/src/tiptap/keymap.js.map +1 -1
  118. package/es-custom/components/prompt-line/src/tiptap/render-token-chip.js +0 -1
  119. package/es-custom/components/prompt-line/src/tiptap/render-token-chip.js.map +1 -1
  120. package/es-custom/components/prompt-line/src/tiptap/resolve-config-items.d.ts +18 -0
  121. package/es-custom/components/prompt-line/src/tiptap/resolve-config-items.js +32 -0
  122. package/es-custom/components/prompt-line/src/tiptap/resolve-config-items.js.map +1 -0
  123. package/es-custom/components/prompt-line/src/tiptap/strip-presentation-fields.d.ts +18 -0
  124. package/es-custom/components/prompt-line/src/tiptap/strip-presentation-fields.js +22 -0
  125. package/es-custom/components/prompt-line/src/tiptap/strip-presentation-fields.js.map +1 -0
  126. package/es-custom/components/prompt-line/src/tiptap/types.d.ts +11 -3
  127. package/es-custom/components/toolbar/src/toolbar.d.ts +8 -0
  128. package/es-custom/components/toolbar/src/toolbar.js +65 -19
  129. package/es-custom/components/toolbar/src/toolbar.js.map +1 -1
  130. package/es-custom/components/video-player/src/providers/vimeo-provider.js +1 -1
  131. package/es-custom/components/video-player/src/providers/vimeo-provider.js.map +1 -1
  132. package/es-custom/globals/decorators/carbon-element.js +2 -3
  133. package/es-custom/globals/decorators/carbon-element.js.map +1 -1
  134. package/es-custom/globals/utils/aria-announcer-manager.d.ts +56 -0
  135. package/es-custom/globals/utils/aria-announcer-manager.js +46 -1
  136. package/es-custom/globals/utils/aria-announcer-manager.js.map +1 -1
  137. package/es-custom/globals/utils/focus-utils.js +1 -3
  138. package/es-custom/globals/utils/focus-utils.js.map +1 -1
  139. package/es-custom/globals/utils/iconTransform.d.ts +16 -2
  140. package/es-custom/globals/utils/iconTransform.js +22 -1
  141. package/es-custom/globals/utils/iconTransform.js.map +1 -1
  142. package/es-custom/react/hooks/useChatAutocomplete.js.map +1 -1
  143. package/es-custom/react/markdown.js +0 -1
  144. package/es-custom/react/markdown.js.map +1 -1
  145. package/es-custom/typings/overflow-menu.d.ts +4 -0
  146. package/package.json +6 -6
  147. package/scss/_custom-properties.scss +0 -17
  148. package/scss/_tokens-component.scss +1 -2
@@ -1 +1 @@
1
- {"version":3,"file":"useChatAutocomplete.js","sources":["../../../src/react/hooks/useChatAutocomplete.tsx"],"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 * React hook for the chat-input autocomplete overlay. Thin wrapper around\n * the framework-agnostic `AutocompleteController` co-located in\n * [../../components/prompt-line/src/autocomplete-controller.ts] (which also exports\n * the `<cds-custom-aichat-autocomplete-controller>` element). The controller owns\n * trigger handling, async resolution, and selection routing; this hook\n * adapts those callbacks into React state and returns a JSX node to slot\n * into `<PromptLineShell>`.\n */\n\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport type { JSX, ReactNode, RefObject } from 'react';\n\nimport Autocomplete from '../autocomplete.js';\nimport type PromptLineElement from '../../components/prompt-line/src/prompt-line.js';\nimport {\n AutocompleteController,\n itemsToGroups,\n type AutocompleteControllerState,\n} from '../../components/prompt-line/src/autocomplete-controller.js';\nimport type {\n AutocompleteConfig,\n StartersConfig,\n SuggestionItem,\n TriggerChangeEventDetail,\n TriggerSuggestionConfig,\n} from '../../components/prompt-line/src/tiptap/types.js';\n\nexport interface UseChatAutocompleteOptions {\n mention?: TriggerSuggestionConfig;\n command?: TriggerSuggestionConfig;\n autocomplete?: AutocompleteConfig;\n starters?: StartersConfig;\n /** Ref to the slotted `<cds-custom-aichat-prompt-line>`. */\n promptLineRef: RefObject<PromptLineElement | null>;\n /** When true, starter selection inserts the text but does not auto-send. */\n isSendDisabled?: boolean;\n /** Fired after a starter is selected and inserted (used to trigger send). */\n onStarterSelected?: (text: string) => void;\n /**\n * Fired when an autocomplete suggestion item is selected.\n * Called after the controller has already inserted the item.\n */\n onSelectItem?: (item: SuggestionItem) => void;\n /**\n * Fired when the send button inside an autocomplete suggestion item is clicked.\n */\n onSendItem?: (text: string) => void;\n /** Whether the autocomplete is attached to the input (affects corner rounding). */\n attached?: boolean;\n /** Maximum height for the autocomplete popover */\n maxHeight?: string;\n}\n\nexport interface UseChatAutocompleteResult {\n /** Attach to `<PromptLine onTriggerChange={...} />`. */\n onTriggerChange: (\n event: CustomEvent<TriggerChangeEventDetail | null>\n ) => void;\n /**\n * JSX to render with `slot=\"autocomplete-content\"` inside `<PromptLineShell>`.\n * `null` while no trigger is active.\n */\n autocompleteContent: ReactNode;\n}\n\nexport function useChatAutocomplete(\n options: UseChatAutocompleteOptions\n): UseChatAutocompleteResult {\n const {\n mention,\n command,\n autocomplete,\n starters,\n promptLineRef,\n isSendDisabled,\n onStarterSelected,\n onSelectItem,\n onSendItem,\n attached = true,\n maxHeight,\n } = options;\n\n const [state, setState] = React.useState<AutocompleteControllerState>({\n trigger: null,\n items: [],\n });\n\n // Keep the controller stable for the hook's lifetime — set in a layout\n // effect so it's wired before any event handler can fire.\n const controllerRef = React.useRef<AutocompleteController | null>(null);\n // Latest config / callback values; the controller stores its own copies\n // but reading them out of refs avoids re-instantiation churn.\n const onStarterRef = React.useRef(onStarterSelected);\n onStarterRef.current = onStarterSelected;\n const onSelectItemRef = React.useRef(onSelectItem);\n onSelectItemRef.current = onSelectItem;\n const onSendItemRef = React.useRef(onSendItem);\n onSendItemRef.current = onSendItem;\n\n if (!controllerRef.current) {\n controllerRef.current = new AutocompleteController({\n mention,\n command,\n autocomplete,\n starters,\n isSendDisabled,\n onStarterSelected: (text) => onStarterRef.current?.(text),\n onChange: setState,\n });\n }\n\n // Push prop changes into the controller without recreating it.\n React.useEffect(() => {\n controllerRef.current?.setConfigs({\n mention,\n command,\n autocomplete,\n starters,\n isSendDisabled,\n });\n }, [mention, command, autocomplete, starters, isSendDisabled]);\n\n // Keep the controller pointed at the live prompt-line element.\n React.useEffect(() => {\n controllerRef.current?.setPromptLine(promptLineRef.current);\n });\n\n React.useEffect(() => {\n return () => {\n controllerRef.current?.destroy();\n controllerRef.current = null;\n };\n }, []);\n\n const onTriggerChange = React.useCallback(\n (event: CustomEvent<TriggerChangeEventDetail | null>) => {\n // Pin the controller to the current prompt-line ref before handing\n // off the detail — the React caller's ref is authoritative.\n controllerRef.current?.setPromptLine(promptLineRef.current);\n controllerRef.current?.handleTriggerChange(event.detail ?? null);\n },\n [promptLineRef]\n );\n\n const handleSelect = React.useCallback((item: SuggestionItem) => {\n controllerRef.current?.select(item);\n onSelectItemRef.current?.(item);\n }, []);\n\n const isSendDisabledRef = React.useRef(isSendDisabled);\n isSendDisabledRef.current = isSendDisabled;\n\n const handleSend = React.useCallback((text: string) => {\n if (!text || isSendDisabledRef.current) {\n return;\n }\n controllerRef.current?.dismiss(true);\n onSendItemRef.current?.(text);\n }, []);\n\n const dismiss = React.useCallback(() => {\n controllerRef.current?.dismiss();\n }, []);\n\n // Register / unregister the rendered list element with the controller so\n // arrow / Enter / Escape on the editor DOM get forwarded to it.\n // Also set the max-height CSS variable if provided.\n const setListElement = React.useCallback(\n (el: HTMLElement | null) => {\n controllerRef.current?.setListElement(el);\n // Pass the editor DOM as anchorElement so outside-click detection on the\n // autocomplete element doesn't dismiss the list when the user clicks the\n // editor (the editor is not inside the autocomplete element).\n if (el && 'anchorElement' in el) {\n (el as HTMLElement & { anchorElement: Element | null }).anchorElement =\n promptLineRef.current?.getEditor?.()?.view.dom ?? null;\n }\n if (el && maxHeight) {\n el.style.setProperty('--cds-aichat-autocomplete-max-height', maxHeight);\n }\n },\n [maxHeight, promptLineRef]\n );\n\n // Prevent mousedown on the autocomplete container from stealing focus from\n // the editor.\n const handleContainerMousedown = React.useCallback(\n (e: Event | React.MouseEvent) => {\n e.preventDefault();\n },\n []\n );\n\n const autocompleteContent = React.useMemo<ReactNode>(() => {\n if (!state.trigger || state.items.length === 0) {\n return null;\n }\n const { items: flatItems, groups } = itemsToGroups(state.items);\n if (state.renderCustomList) {\n const result = state.renderCustomList({\n items: state.items,\n query: state.trigger.query,\n onDismiss: dismiss,\n onSelect: handleSelect,\n onSend: handleSend,\n });\n if (result == null) {\n return null;\n }\n if (result instanceof HTMLElement) {\n return (\n <CustomElementHost\n slot=\"autocomplete-content\"\n element={result}\n onMount={setListElement}\n onMousedown={handleContainerMousedown}\n />\n );\n }\n return (\n <CustomReactNodePortal\n slot=\"autocomplete-content\"\n node={result as ReactNode}\n onMount={setListElement}\n onMousedown={handleContainerMousedown}\n />\n );\n }\n return (\n <Autocomplete\n ref={setListElement}\n slot=\"autocomplete-content\"\n items={flatItems}\n groups={groups}\n attached={attached}\n disableDirectSend={state.disableDirectSend}\n onDismiss={dismiss}\n onSelect={(e: CustomEvent<{ item: SuggestionItem }>) =>\n handleSelect(e.detail.item)\n }\n onSend={(e: CustomEvent<{ text: string }>) =>\n handleSend(e.detail?.text)\n }\n />\n );\n }, [\n state,\n handleSelect,\n handleSend,\n dismiss,\n setListElement,\n attached,\n handleContainerMousedown,\n ]);\n\n return { onTriggerChange, autocompleteContent };\n}\n\ninterface CustomElementHostProps {\n slot: string;\n element: HTMLElement;\n /** Notify the parent which element is the key-forwarding target. */\n onMount?: (el: HTMLElement | null) => void;\n onMousedown?: (e: React.MouseEvent) => void;\n}\n\n/** Mounts a host-provided HTMLElement into the React tree at `slot`. */\nfunction CustomElementHost({\n slot,\n element,\n onMount,\n onMousedown,\n}: CustomElementHostProps): JSX.Element {\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n React.useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return undefined;\n }\n container.appendChild(element);\n onMount?.(element);\n return () => {\n onMount?.(null);\n if (element.parentNode === container) {\n container.removeChild(element);\n }\n };\n }, [element, onMount]);\n return (\n <div\n ref={containerRef}\n role=\"presentation\"\n slot={slot}\n onMouseDown={onMousedown}\n />\n );\n}\n\ninterface CustomReactNodePortalProps {\n slot: string;\n node: ReactNode;\n onMount?: (el: HTMLElement | null) => void;\n onMousedown?: (e: MouseEvent) => void;\n}\n\nlet autocompletePortalCounter = 0;\n\n/**\n * Projects a consumer-supplied React node into the page's light DOM via a\n * two-level slot/host pair so external `<style>` tags reach it. The rendered\n * `<div>` is a slot-projected anchor in the shell's `autocomplete-content`\n * slot; a sibling `<div slot=\"…\">` is appended to the chatWrapper (the host\n * of the surrounding shadow root) and receives the React node via\n * `createPortal`. Without this hop the node would mount inside the chat's\n * shadow root, hidden from page CSS.\n */\nfunction CustomReactNodePortal({\n slot,\n node,\n onMount,\n onMousedown,\n}: CustomReactNodePortalProps): JSX.Element {\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n const [hostElement, setHostElement] = React.useState<HTMLElement | null>(\n null\n );\n\n React.useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return undefined;\n }\n const rootNode = container.getRootNode();\n const chatWrapper =\n rootNode instanceof ShadowRoot ? (rootNode.host as HTMLElement) : null;\n if (!chatWrapper) {\n return undefined;\n }\n\n const slotName = `cds-custom-aichat-autocomplete-${++autocompletePortalCounter}`;\n const slotEl = document.createElement('slot');\n slotEl.setAttribute('name', slotName);\n container.appendChild(slotEl);\n\n const hostEl = document.createElement('div');\n hostEl.setAttribute('slot', slotName);\n if (onMousedown) {\n hostEl.addEventListener('mousedown', onMousedown);\n }\n chatWrapper.appendChild(hostEl);\n\n setHostElement(hostEl);\n return () => {\n onMount?.(null);\n if (onMousedown) {\n hostEl.removeEventListener('mousedown', onMousedown);\n }\n slotEl.remove();\n hostEl.remove();\n setHostElement(null);\n };\n // Empty deps: the slot/host pair is owned by this mount cycle and should\n // not churn as `node` updates — React's portal reconciliation handles\n // those updates in place.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // After the portal content is committed into hostElement, hand the first\n // child element to the controller. This is typically a custom element (e.g.\n // <cds-custom-aichat-autocomplete>) whose properties (anchorElement, keydown\n // forwarding) only work on the element itself — not on the plain <div>\n // wrapper that createPortal renders into. Custom elements are defined\n // synchronously at module load, so by the time useEffect fires (post-paint)\n // the element is fully upgraded and its properties are available.\n React.useEffect(() => {\n if (!hostElement) {\n return;\n }\n const child = hostElement.firstElementChild as HTMLElement | null;\n onMount?.(child ?? hostElement);\n }, [hostElement, onMount]);\n\n return (\n <div slot={slot} ref={containerRef}>\n {hostElement ? ReactDOM.createPortal(node, hostElement) : null}\n </div>\n );\n}\n"],"names":["_jsx","Autocomplete"],"mappings":";;;;;;;;;;;;;AA4EM,SAAU,mBAAmB,CACjC,OAAmC,EAAA;IAEnC,MAAM,EACJ,OAAO,EACP,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,QAAQ,GAAG,IAAI,EACf,SAAS,GACV,GAAG,OAAO;IAEX,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAA8B;AACpE,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,KAAK,EAAE,EAAE;AACV,KAAA,CAAC;;;IAIF,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAgC,IAAI,CAAC;;;IAGvE,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC;AACpD,IAAA,YAAY,CAAC,OAAO,GAAG,iBAAiB;IACxC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;AAClD,IAAA,eAAe,CAAC,OAAO,GAAG,YAAY;IACtC,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;AAC9C,IAAA,aAAa,CAAC,OAAO,GAAG,UAAU;AAElC,IAAA,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC1B,QAAA,aAAa,CAAC,OAAO,GAAG,IAAI,sBAAsB,CAAC;YACjD,OAAO;YACP,OAAO;YACP,YAAY;YACZ,QAAQ;YACR,cAAc;AACd,YAAA,iBAAiB,EAAE,CAAC,IAAI,KAAK,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;AACzD,YAAA,QAAQ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CAAC,MAAK;QACnB,IAAI,CAAC,WAAW,EAAE;YAChB;QACF;AACA,QAAA,MAAM,KAAK,GAAG,WAAW,CAAC,iBAAuC;AACjE,QAAA,OAAO,GAAG,KAAK,IAAI,WAAW,CAAC;AACjC,IAAA,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAE1B,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAK,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAA,QAAA,EAC/B,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,IAAI,EAAA,CAC1D;AAEV;;"}
1
+ {"version":3,"file":"useChatAutocomplete.js","sources":["../../../src/react/hooks/useChatAutocomplete.tsx"],"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 * React hook for the chat-input autocomplete overlay. Thin wrapper around\n * the framework-agnostic `AutocompleteController` in\n * [../../components/prompt-line/src/autocomplete-controller.ts]. That module\n * holds no Lit and registers no custom element, so reaching the controller\n * costs this hook neither. It still loads `<cds-custom-aichat-autocomplete>` — it\n * renders that list itself — but never\n * `<cds-custom-aichat-autocomplete-controller>`, the other surface on the same\n * class. The controller owns\n * trigger handling, async resolution, and selection routing; this hook\n * adapts those callbacks into React state and returns a JSX node to slot\n * into `<PromptLineShell>`.\n */\n\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport type { JSX, ReactNode, RefObject } from 'react';\n\nimport Autocomplete from '../autocomplete.js';\nimport type PromptLineElement from '../../components/prompt-line/src/prompt-line.js';\nimport {\n AutocompleteController,\n itemsToGroups,\n type AutocompleteControllerState,\n} from '../../components/prompt-line/src/autocomplete-controller.js';\nimport type {\n AutocompleteConfig,\n StartersConfig,\n SuggestionItem,\n TriggerChangeEventDetail,\n TriggerSuggestionConfig,\n} from '../../components/prompt-line/src/tiptap/types.js';\n\nexport interface UseChatAutocompleteOptions {\n mention?: TriggerSuggestionConfig;\n command?: TriggerSuggestionConfig;\n autocomplete?: AutocompleteConfig;\n starters?: StartersConfig;\n /** Ref to the slotted `<cds-custom-aichat-prompt-line>`. */\n promptLineRef: RefObject<PromptLineElement | null>;\n /** When true, starter selection inserts the text but does not auto-send. */\n isSendDisabled?: boolean;\n /** Fired after a starter is selected and inserted (used to trigger send). */\n onStarterSelected?: (text: string) => void;\n /**\n * Fired when an autocomplete suggestion item is selected.\n * Called after the controller has already inserted the item.\n */\n onSelectItem?: (item: SuggestionItem) => void;\n /**\n * Fired when the send button inside an autocomplete suggestion item is clicked.\n */\n onSendItem?: (text: string) => void;\n /** Whether the autocomplete is attached to the input (affects corner rounding). */\n attached?: boolean;\n /** Maximum height for the autocomplete popover */\n maxHeight?: string;\n}\n\nexport interface UseChatAutocompleteResult {\n /** Attach to `<PromptLine onTriggerChange={...} />`. */\n onTriggerChange: (\n event: CustomEvent<TriggerChangeEventDetail | null>\n ) => void;\n /**\n * JSX to render with `slot=\"autocomplete-content\"` inside `<PromptLineShell>`.\n * `null` while no trigger is active.\n */\n autocompleteContent: ReactNode;\n}\n\nexport function useChatAutocomplete(\n options: UseChatAutocompleteOptions\n): UseChatAutocompleteResult {\n const {\n mention,\n command,\n autocomplete,\n starters,\n promptLineRef,\n isSendDisabled,\n onStarterSelected,\n onSelectItem,\n onSendItem,\n attached = true,\n maxHeight,\n } = options;\n\n const [state, setState] = React.useState<AutocompleteControllerState>({\n trigger: null,\n items: [],\n });\n\n // Keep the controller stable for the hook's lifetime — set in a layout\n // effect so it's wired before any event handler can fire.\n const controllerRef = React.useRef<AutocompleteController | null>(null);\n // Latest config / callback values; the controller stores its own copies\n // but reading them out of refs avoids re-instantiation churn.\n const onStarterRef = React.useRef(onStarterSelected);\n onStarterRef.current = onStarterSelected;\n const onSelectItemRef = React.useRef(onSelectItem);\n onSelectItemRef.current = onSelectItem;\n const onSendItemRef = React.useRef(onSendItem);\n onSendItemRef.current = onSendItem;\n\n if (!controllerRef.current) {\n controllerRef.current = new AutocompleteController({\n mention,\n command,\n autocomplete,\n starters,\n isSendDisabled,\n onStarterSelected: (text) => onStarterRef.current?.(text),\n onChange: setState,\n });\n }\n\n // Push prop changes into the controller without recreating it.\n React.useEffect(() => {\n controllerRef.current?.setConfigs({\n mention,\n command,\n autocomplete,\n starters,\n isSendDisabled,\n });\n }, [mention, command, autocomplete, starters, isSendDisabled]);\n\n // Keep the controller pointed at the live prompt-line element.\n React.useEffect(() => {\n controllerRef.current?.setPromptLine(promptLineRef.current);\n });\n\n React.useEffect(() => {\n return () => {\n controllerRef.current?.destroy();\n controllerRef.current = null;\n };\n }, []);\n\n const onTriggerChange = React.useCallback(\n (event: CustomEvent<TriggerChangeEventDetail | null>) => {\n // Pin the controller to the current prompt-line ref before handing\n // off the detail — the React caller's ref is authoritative.\n controllerRef.current?.setPromptLine(promptLineRef.current);\n controllerRef.current?.handleTriggerChange(event.detail ?? null);\n },\n [promptLineRef]\n );\n\n const handleSelect = React.useCallback((item: SuggestionItem) => {\n controllerRef.current?.select(item);\n onSelectItemRef.current?.(item);\n }, []);\n\n const isSendDisabledRef = React.useRef(isSendDisabled);\n isSendDisabledRef.current = isSendDisabled;\n\n const handleSend = React.useCallback((text: string) => {\n if (!text || isSendDisabledRef.current) {\n return;\n }\n controllerRef.current?.dismiss(true);\n onSendItemRef.current?.(text);\n }, []);\n\n const dismiss = React.useCallback(() => {\n controllerRef.current?.dismiss();\n }, []);\n\n // Register / unregister the rendered list element with the controller so\n // arrow / Enter / Escape on the editor DOM get forwarded to it.\n // Also set the max-height CSS variable if provided.\n const setListElement = React.useCallback(\n (el: HTMLElement | null) => {\n controllerRef.current?.setListElement(el);\n // Pass the editor DOM as anchorElement so outside-click detection on the\n // autocomplete element doesn't dismiss the list when the user clicks the\n // editor (the editor is not inside the autocomplete element).\n if (el && 'anchorElement' in el) {\n (el as HTMLElement & { anchorElement: Element | null }).anchorElement =\n promptLineRef.current?.getEditor?.()?.view.dom ?? null;\n }\n if (el && maxHeight) {\n el.style.setProperty('--cds-aichat-autocomplete-max-height', maxHeight);\n }\n },\n [maxHeight, promptLineRef]\n );\n\n // Prevent mousedown on the autocomplete container from stealing focus from\n // the editor.\n const handleContainerMousedown = React.useCallback(\n (e: Event | React.MouseEvent) => {\n e.preventDefault();\n },\n []\n );\n\n const autocompleteContent = React.useMemo<ReactNode>(() => {\n if (!state.trigger || state.items.length === 0) {\n return null;\n }\n const { items: flatItems, groups } = itemsToGroups(state.items);\n if (state.renderCustomList) {\n const result = state.renderCustomList({\n items: state.items,\n query: state.trigger.query,\n onDismiss: dismiss,\n onSelect: handleSelect,\n onSend: handleSend,\n });\n if (result == null) {\n return null;\n }\n if (result instanceof HTMLElement) {\n return (\n <CustomElementHost\n slot=\"autocomplete-content\"\n element={result}\n onMount={setListElement}\n onMousedown={handleContainerMousedown}\n />\n );\n }\n return (\n <CustomReactNodePortal\n slot=\"autocomplete-content\"\n node={result as ReactNode}\n onMount={setListElement}\n onMousedown={handleContainerMousedown}\n />\n );\n }\n return (\n <Autocomplete\n ref={setListElement}\n slot=\"autocomplete-content\"\n items={flatItems}\n groups={groups}\n attached={attached}\n disableDirectSend={state.disableDirectSend}\n onDismiss={dismiss}\n onSelect={(e: CustomEvent<{ item: SuggestionItem }>) =>\n handleSelect(e.detail.item)\n }\n onSend={(e: CustomEvent<{ text: string }>) =>\n handleSend(e.detail?.text)\n }\n />\n );\n }, [\n state,\n handleSelect,\n handleSend,\n dismiss,\n setListElement,\n attached,\n handleContainerMousedown,\n ]);\n\n return { onTriggerChange, autocompleteContent };\n}\n\ninterface CustomElementHostProps {\n slot: string;\n element: HTMLElement;\n /** Notify the parent which element is the key-forwarding target. */\n onMount?: (el: HTMLElement | null) => void;\n onMousedown?: (e: React.MouseEvent) => void;\n}\n\n/** Mounts a host-provided HTMLElement into the React tree at `slot`. */\nfunction CustomElementHost({\n slot,\n element,\n onMount,\n onMousedown,\n}: CustomElementHostProps): JSX.Element {\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n React.useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return undefined;\n }\n container.appendChild(element);\n onMount?.(element);\n return () => {\n onMount?.(null);\n if (element.parentNode === container) {\n container.removeChild(element);\n }\n };\n }, [element, onMount]);\n return (\n <div\n ref={containerRef}\n role=\"presentation\"\n slot={slot}\n onMouseDown={onMousedown}\n />\n );\n}\n\ninterface CustomReactNodePortalProps {\n slot: string;\n node: ReactNode;\n onMount?: (el: HTMLElement | null) => void;\n onMousedown?: (e: MouseEvent) => void;\n}\n\nlet autocompletePortalCounter = 0;\n\n/**\n * Projects a consumer-supplied React node into the page's light DOM via a\n * two-level slot/host pair so external `<style>` tags reach it. The rendered\n * `<div>` is a slot-projected anchor in the shell's `autocomplete-content`\n * slot; a sibling `<div slot=\"…\">` is appended to the chatWrapper (the host\n * of the surrounding shadow root) and receives the React node via\n * `createPortal`. Without this hop the node would mount inside the chat's\n * shadow root, hidden from page CSS.\n */\nfunction CustomReactNodePortal({\n slot,\n node,\n onMount,\n onMousedown,\n}: CustomReactNodePortalProps): JSX.Element {\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n const [hostElement, setHostElement] = React.useState<HTMLElement | null>(\n null\n );\n\n React.useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return undefined;\n }\n const rootNode = container.getRootNode();\n const chatWrapper =\n rootNode instanceof ShadowRoot ? (rootNode.host as HTMLElement) : null;\n if (!chatWrapper) {\n return undefined;\n }\n\n const slotName = `cds-custom-aichat-autocomplete-${++autocompletePortalCounter}`;\n const slotEl = document.createElement('slot');\n slotEl.setAttribute('name', slotName);\n container.appendChild(slotEl);\n\n const hostEl = document.createElement('div');\n hostEl.setAttribute('slot', slotName);\n if (onMousedown) {\n hostEl.addEventListener('mousedown', onMousedown);\n }\n chatWrapper.appendChild(hostEl);\n\n setHostElement(hostEl);\n return () => {\n onMount?.(null);\n if (onMousedown) {\n hostEl.removeEventListener('mousedown', onMousedown);\n }\n slotEl.remove();\n hostEl.remove();\n setHostElement(null);\n };\n // Empty deps: the slot/host pair is owned by this mount cycle and should\n // not churn as `node` updates — React's portal reconciliation handles\n // those updates in place.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // After the portal content is committed into hostElement, hand the first\n // child element to the controller. This is typically a custom element (e.g.\n // <cds-custom-aichat-autocomplete>) whose properties (anchorElement, keydown\n // forwarding) only work on the element itself — not on the plain <div>\n // wrapper that createPortal renders into. Custom elements are defined\n // synchronously at module load, so by the time useEffect fires (post-paint)\n // the element is fully upgraded and its properties are available.\n React.useEffect(() => {\n if (!hostElement) {\n return;\n }\n const child = hostElement.firstElementChild as HTMLElement | null;\n onMount?.(child ?? hostElement);\n }, [hostElement, onMount]);\n\n return (\n <div slot={slot} ref={containerRef}>\n {hostElement ? ReactDOM.createPortal(node, hostElement) : null}\n </div>\n );\n}\n"],"names":["_jsx","Autocomplete"],"mappings":";;;;;;;;;;;;;AAgFM,SAAU,mBAAmB,CACjC,OAAmC,EAAA;IAEnC,MAAM,EACJ,OAAO,EACP,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,QAAQ,GAAG,IAAI,EACf,SAAS,GACV,GAAG,OAAO;IAEX,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAA8B;AACpE,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,KAAK,EAAE,EAAE;AACV,KAAA,CAAC;;;IAIF,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAgC,IAAI,CAAC;;;IAGvE,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC;AACpD,IAAA,YAAY,CAAC,OAAO,GAAG,iBAAiB;IACxC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;AAClD,IAAA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WAAW,CAAC,WAAW,CAAC,MAAM,CAAC;QAE/B,cAAc,CAAC,MAAM,CAAC;AACtB,QAAA,OAAO,MAAK;AACV,YAAA,OAAO,GAAG,IAAI,CAAC;YACf,IAAI,WAAW,EAAE;AACf,gBAAA,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,CAAC;YACtD;YACA,MAAM,CAAC,MAAM,EAAE;YACf,MAAM,CAAC,MAAM,EAAE;YACf,cAAc,CAAC,IAAI,CAAC;AACtB,QAAA,CAAC;;;;;IAKH,CAAC,EAAE,EAAE,CAAC;;;;;;;;AASN,IAAA,KAAK,CAAC,SAAS,CAAC,MAAK;QACnB,IAAI,CAAC,WAAW,EAAE;YAChB;QACF;AACA,QAAA,MAAM,KAAK,GAAG,WAAW,CAAC,iBAAuC;AACjE,QAAA,OAAO,GAAG,KAAK,IAAI,WAAW,CAAC;AACjC,IAAA,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAE1B,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAK,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAA,QAAA,EAC/B,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,IAAI,EAAA,CAC1D;AAEV;;"}
@@ -127,7 +127,6 @@ const Markdown = forwardRef(function Markdown({ customRenderers, ...rest }, forw
127
127
  // flickering out as later content arrives). Reading `isConnected` a
128
128
  // microtask later lets Lit's adoption land first, so we only drop
129
129
  // genuinely-removed hosts.
130
- // eslint-disable-next-line react-hooks/exhaustive-deps
131
130
  useEffect(() => {
132
131
  let cancelled = false;
133
132
  queueMicrotask(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.js","sources":["../../src/react/markdown.tsx"],"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 { createComponent } from '@lit/react';\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ComponentPropsWithoutRef,\n type ReactNode,\n} from 'react';\nimport { createPortal, flushSync } from 'react-dom';\n\n// Export the actual class for the component that will *directly* be wrapped with React.\nimport CDSAIChatMarkdown from '../components/markdown/src/markdown.js';\nimport type {\n MarkdownCustomRenderers,\n MarkdownRendererCodeBlockArgs,\n MarkdownRendererTableArgs,\n} from '../components/markdown/src/markdown-renderer-types.js';\nimport { withWebComponentBridge } from './utils/withWebComponentBridge';\n\nconst LitMarkdown = createComponent({\n tagName: 'cds-custom-aichat-markdown',\n elementClass: CDSAIChatMarkdown,\n react: React,\n});\n\nconst ForwardedBaseMarkdown = React.forwardRef<\n CDSAIChatMarkdown,\n React.ComponentProps<typeof LitMarkdown> & { markdown?: string }\n>(({ children, markdown, ...rest }, forwardedRef) => {\n const isTextChildren =\n typeof children === 'string' || typeof children === 'number';\n return React.createElement(\n LitMarkdown,\n {\n ...rest,\n ref: forwardedRef,\n markdown: markdown ?? (isTextChildren ? String(children) : undefined),\n },\n // Text children become the `markdown` prop; element children pass through\n // as light-DOM slot children (used by the React wrapper to mount plugin\n // slot forwarders inside the underlying `<cds-custom-aichat-markdown>`).\n isTextChildren ? null : children\n );\n});\n\nForwardedBaseMarkdown.displayName = 'BaseMarkdown';\n\n/**\n * Thin `@lit/react` bridge around `<cds-custom-aichat-markdown>`. Handles text vs.\n * element children and the web-component prop bridge, but performs no\n * React-specific `customRenderers` portaling — that is layered on by the\n * `Markdown` wrapper below.\n */\nconst BaseMarkdown = withWebComponentBridge(ForwardedBaseMarkdown);\n\n/**\n * React-flavored variant of {@link MarkdownCustomRenderers}. The element\n * replacements (`table`, `codeBlock`) may additionally return a `ReactNode`\n * (portaled into a light-DOM slot host) on top of the framework-neutral\n * `HTMLElement | null`. The attribute transforms (`link`, `image`) and the\n * `checklist` behavior hook return plain data, so they keep the base\n * signatures unchanged.\n */\nexport interface MarkdownReactCustomRenderers {\n /**\n * Override the default `cds-custom-aichat-table` rendering. Return a `ReactNode`\n * (rendered via portal into a light-DOM slot host) or an `HTMLElement`\n * (adopted into the slot host as-is); return `null` to fall back to the\n * default Carbon table renderer.\n */\n table?: (args: MarkdownRendererTableArgs) => ReactNode | HTMLElement | null;\n /**\n * Override the default `cds-custom-aichat-code-snippet` rendering. Return a\n * `ReactNode` (rendered via portal into a light-DOM slot host) or an\n * `HTMLElement` (adopted into the slot host as-is); return `null` to fall\n * back to the default Carbon code snippet renderer.\n */\n codeBlock?: (\n args: MarkdownRendererCodeBlockArgs\n ) => ReactNode | HTMLElement | null;\n /** Transform how links render. See {@link MarkdownCustomRenderers.link}. */\n link?: MarkdownCustomRenderers['link'];\n /** Transform how images render. See {@link MarkdownCustomRenderers.image}. */\n image?: MarkdownCustomRenderers['image'];\n /** Make task-list checkboxes actionable. See {@link MarkdownCustomRenderers.checklist}. */\n checklist?: MarkdownCustomRenderers['checklist'];\n}\n\ntype BaseMarkdownProps = Omit<\n ComponentPropsWithoutRef<typeof BaseMarkdown>,\n 'customRenderers'\n>;\n\n/**\n * Props for the React `<Markdown>` wrapper around `<cds-custom-aichat-markdown>`.\n */\nexport interface MarkdownProps extends BaseMarkdownProps {\n /**\n * Per-element render overrides. Each callback returns either a `ReactNode`\n * (rendered via portal into a light-DOM slot host) or an `HTMLElement`\n * (adopted into the slot host as-is). Return `null` to fall back to the\n * default Carbon rendering. Pass a stable reference (e.g. `useMemo`) — a\n * new object identity each render forces a full re-reconcile.\n */\n customRenderers?: MarkdownReactCustomRenderers;\n}\n\ntype PortalEntry = {\n slotName: string;\n host: HTMLDivElement;\n node: ReactNode;\n};\n\nfunction isElement(value: unknown): value is HTMLElement {\n return (\n typeof Element !== 'undefined' &&\n value instanceof Element &&\n 'tagName' in value\n );\n}\n\nconst Markdown = forwardRef<CDSAIChatMarkdown, MarkdownProps>(function Markdown(\n { customRenderers, ...rest },\n forwardedRef\n) {\n const hostsRef = useRef<Map<string, HTMLDivElement>>(new Map());\n const [portalEntries, setPortalEntries] = useState<PortalEntry[]>([]);\n\n const markdownRef = useRef<CDSAIChatMarkdown | null>(null);\n const setMarkdownRef = useCallback(\n (node: CDSAIChatMarkdown | null) => {\n markdownRef.current = node;\n if (typeof forwardedRef === 'function') {\n forwardedRef(node);\n } else if (forwardedRef && 'current' in forwardedRef) {\n (\n forwardedRef as React.MutableRefObject<CDSAIChatMarkdown | null>\n ).current = node;\n }\n },\n [forwardedRef]\n );\n\n const setPortalForSlot = useCallback(\n (slotName: string, host: HTMLDivElement, node: ReactNode) => {\n setPortalEntries((prev) => {\n const idx = prev.findIndex((e) => e.slotName === slotName);\n if (idx >= 0 && prev[idx].node === node && prev[idx].host === host) {\n return prev;\n }\n if (idx >= 0) {\n const next = prev.slice();\n next[idx] = { slotName, host, node };\n return next;\n }\n return [...prev, { slotName, host, node }];\n });\n },\n []\n );\n\n const bridgedRenderers = useMemo<MarkdownCustomRenderers | undefined>(() => {\n if (!customRenderers) {\n return undefined;\n }\n const bridge = <Args extends { slotName: string }>(\n callback: (args: Args) => ReactNode | HTMLElement | null\n ) => {\n return (args: Args): HTMLElement | null => {\n const rendered = callback(args);\n if (rendered == null) {\n return null;\n }\n if (isElement(rendered)) {\n return rendered;\n }\n // Mint or reuse a stable host for this slot, then flush a portal\n // update synchronously so the host is populated before the Lit\n // element adopts it (no empty-host flash).\n let host = hostsRef.current.get(args.slotName);\n if (!host) {\n host = document.createElement('div');\n hostsRef.current.set(args.slotName, host);\n }\n flushSync(() => {\n setPortalForSlot(args.slotName, host as HTMLDivElement, rendered);\n });\n return host;\n };\n };\n\n const out: MarkdownCustomRenderers = {};\n if (customRenderers.table) {\n out.table = bridge(customRenderers.table);\n }\n if (customRenderers.codeBlock) {\n out.codeBlock = bridge(customRenderers.codeBlock);\n }\n // Attribute transforms / behavior hook return plain data (not DOM), so\n // they skip the portal bridge and pass straight through.\n if (customRenderers.link) {\n out.link = customRenderers.link;\n }\n if (customRenderers.image) {\n out.image = customRenderers.image;\n }\n if (customRenderers.checklist) {\n out.checklist = customRenderers.checklist;\n }\n return out;\n }, [customRenderers, setPortalForSlot]);\n\n // After every commit, prune portals whose host Lit has removed (its slot\n // dropped out of the descriptor batch, leaving the host detached). The\n // connectivity check is deferred to a microtask on purpose: `bridge` mints a\n // host, `flushSync`s the portal into it while it is still detached, and only\n // *returns* it to Lit — which appends it synchronously afterwards. That\n // `flushSync` runs this effect once while the host is not yet adopted, so a\n // synchronous `isConnected` check would prune the entry we just added and\n // leave the slot permanently empty (e.g. a streaming table custom renderer\n // flickering out as later content arrives). Reading `isConnected` a\n // microtask later lets Lit's adoption land first, so we only drop\n // genuinely-removed hosts.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useEffect(() => {\n let cancelled = false;\n queueMicrotask(() => {\n if (cancelled) {\n return;\n }\n let pruned = false;\n const aliveHosts = new Map<string, HTMLDivElement>();\n for (const [slotName, host] of hostsRef.current) {\n if (host.isConnected) {\n aliveHosts.set(slotName, host);\n } else {\n pruned = true;\n }\n }\n if (pruned) {\n hostsRef.current = aliveHosts;\n }\n setPortalEntries((prev) => {\n const filtered = prev.filter((e) => e.host.isConnected);\n return filtered.length === prev.length ? prev : filtered;\n });\n });\n return () => {\n cancelled = true;\n };\n });\n\n return (\n <>\n <BaseMarkdown\n {...rest}\n ref={setMarkdownRef as React.Ref<HTMLElement>}\n customRenderers={bridgedRenderers as never}\n />\n {portalEntries.map((entry) => (\n <React.Fragment key={entry.slotName}>\n {createPortal(entry.node, entry.host)}\n </React.Fragment>\n ))}\n </>\n );\n});\n\nMarkdown.displayName = 'Markdown';\n\nexport default Markdown;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;AA+BA,MAAM,WAAW,GAAG,eAAe,CAAC;AAClC,IAAA,OAAO,EAAE,qBAAqB;AAC9B,IAAA,YAAY,EAAE,iBAAiB;AAC/B,IAAA,KAAK,EAAE,KAAK;AACb,CAAA,CAAC;AAEF,MAAM,qBAA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UAAU;;"}
1
+ {"version":3,"file":"markdown.js","sources":["../../src/react/markdown.tsx"],"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 { createComponent } from '@lit/react';\nimport React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ComponentPropsWithoutRef,\n type ReactNode,\n} from 'react';\nimport { createPortal, flushSync } from 'react-dom';\n\n// Export the actual class for the component that will *directly* be wrapped with React.\nimport CDSAIChatMarkdown from '../components/markdown/src/markdown.js';\nimport type {\n MarkdownCustomRenderers,\n MarkdownRendererCodeBlockArgs,\n MarkdownRendererTableArgs,\n} from '../components/markdown/src/markdown-renderer-types.js';\nimport { withWebComponentBridge } from './utils/withWebComponentBridge';\n\nconst LitMarkdown = createComponent({\n tagName: 'cds-custom-aichat-markdown',\n elementClass: CDSAIChatMarkdown,\n react: React,\n});\n\nconst ForwardedBaseMarkdown = React.forwardRef<\n CDSAIChatMarkdown,\n React.ComponentProps<typeof LitMarkdown> & { markdown?: string }\n>(({ children, markdown, ...rest }, forwardedRef) => {\n const isTextChildren =\n typeof children === 'string' || typeof children === 'number';\n return React.createElement(\n LitMarkdown,\n {\n ...rest,\n ref: forwardedRef,\n markdown: markdown ?? (isTextChildren ? String(children) : undefined),\n },\n // Text children become the `markdown` prop; element children pass through\n // as light-DOM slot children (used by the React wrapper to mount plugin\n // slot forwarders inside the underlying `<cds-custom-aichat-markdown>`).\n isTextChildren ? null : children\n );\n});\n\nForwardedBaseMarkdown.displayName = 'BaseMarkdown';\n\n/**\n * Thin `@lit/react` bridge around `<cds-custom-aichat-markdown>`. Handles text vs.\n * element children and the web-component prop bridge, but performs no\n * React-specific `customRenderers` portaling — that is layered on by the\n * `Markdown` wrapper below.\n */\nconst BaseMarkdown = withWebComponentBridge(ForwardedBaseMarkdown);\n\n/**\n * React-flavored variant of {@link MarkdownCustomRenderers}. The element\n * replacements (`table`, `codeBlock`) may additionally return a `ReactNode`\n * (portaled into a light-DOM slot host) on top of the framework-neutral\n * `HTMLElement | null`. The attribute transforms (`link`, `image`) and the\n * `checklist` behavior hook return plain data, so they keep the base\n * signatures unchanged.\n */\nexport interface MarkdownReactCustomRenderers {\n /**\n * Override the default `cds-custom-aichat-table` rendering. Return a `ReactNode`\n * (rendered via portal into a light-DOM slot host) or an `HTMLElement`\n * (adopted into the slot host as-is); return `null` to fall back to the\n * default Carbon table renderer.\n */\n table?: (args: MarkdownRendererTableArgs) => ReactNode | HTMLElement | null;\n /**\n * Override the default `cds-custom-aichat-code-snippet` rendering. Return a\n * `ReactNode` (rendered via portal into a light-DOM slot host) or an\n * `HTMLElement` (adopted into the slot host as-is); return `null` to fall\n * back to the default Carbon code snippet renderer.\n */\n codeBlock?: (\n args: MarkdownRendererCodeBlockArgs\n ) => ReactNode | HTMLElement | null;\n /** Transform how links render. See {@link MarkdownCustomRenderers.link}. */\n link?: MarkdownCustomRenderers['link'];\n /** Transform how images render. See {@link MarkdownCustomRenderers.image}. */\n image?: MarkdownCustomRenderers['image'];\n /** Make task-list checkboxes actionable. See {@link MarkdownCustomRenderers.checklist}. */\n checklist?: MarkdownCustomRenderers['checklist'];\n}\n\ntype BaseMarkdownProps = Omit<\n ComponentPropsWithoutRef<typeof BaseMarkdown>,\n 'customRenderers'\n>;\n\n/**\n * Props for the React `<Markdown>` wrapper around `<cds-custom-aichat-markdown>`.\n */\nexport interface MarkdownProps extends BaseMarkdownProps {\n /**\n * Per-element render overrides. Each callback returns either a `ReactNode`\n * (rendered via portal into a light-DOM slot host) or an `HTMLElement`\n * (adopted into the slot host as-is). Return `null` to fall back to the\n * default Carbon rendering. Pass a stable reference (e.g. `useMemo`) — a\n * new object identity each render forces a full re-reconcile.\n */\n customRenderers?: MarkdownReactCustomRenderers;\n}\n\ntype PortalEntry = {\n slotName: string;\n host: HTMLDivElement;\n node: ReactNode;\n};\n\nfunction isElement(value: unknown): value is HTMLElement {\n return (\n typeof Element !== 'undefined' &&\n value instanceof Element &&\n 'tagName' in value\n );\n}\n\nconst Markdown = forwardRef<CDSAIChatMarkdown, MarkdownProps>(function Markdown(\n { customRenderers, ...rest },\n forwardedRef\n) {\n const hostsRef = useRef<Map<string, HTMLDivElement>>(new Map());\n const [portalEntries, setPortalEntries] = useState<PortalEntry[]>([]);\n\n const markdownRef = useRef<CDSAIChatMarkdown | null>(null);\n const setMarkdownRef = useCallback(\n (node: CDSAIChatMarkdown | null) => {\n markdownRef.current = node;\n if (typeof forwardedRef === 'function') {\n forwardedRef(node);\n } else if (forwardedRef && 'current' in forwardedRef) {\n (\n forwardedRef as React.MutableRefObject<CDSAIChatMarkdown | null>\n ).current = node;\n }\n },\n [forwardedRef]\n );\n\n const setPortalForSlot = useCallback(\n (slotName: string, host: HTMLDivElement, node: ReactNode) => {\n setPortalEntries((prev) => {\n const idx = prev.findIndex((e) => e.slotName === slotName);\n if (idx >= 0 && prev[idx].node === node && prev[idx].host === host) {\n return prev;\n }\n if (idx >= 0) {\n const next = prev.slice();\n next[idx] = { slotName, host, node };\n return next;\n }\n return [...prev, { slotName, host, node }];\n });\n },\n []\n );\n\n const bridgedRenderers = useMemo<MarkdownCustomRenderers | undefined>(() => {\n if (!customRenderers) {\n return undefined;\n }\n const bridge = <Args extends { slotName: string }>(\n callback: (args: Args) => ReactNode | HTMLElement | null\n ) => {\n return (args: Args): HTMLElement | null => {\n const rendered = callback(args);\n if (rendered == null) {\n return null;\n }\n if (isElement(rendered)) {\n return rendered;\n }\n // Mint or reuse a stable host for this slot, then flush a portal\n // update synchronously so the host is populated before the Lit\n // element adopts it (no empty-host flash).\n let host = hostsRef.current.get(args.slotName);\n if (!host) {\n host = document.createElement('div');\n hostsRef.current.set(args.slotName, host);\n }\n flushSync(() => {\n setPortalForSlot(args.slotName, host as HTMLDivElement, rendered);\n });\n return host;\n };\n };\n\n const out: MarkdownCustomRenderers = {};\n if (customRenderers.table) {\n out.table = bridge(customRenderers.table);\n }\n if (customRenderers.codeBlock) {\n out.codeBlock = bridge(customRenderers.codeBlock);\n }\n // Attribute transforms / behavior hook return plain data (not DOM), so\n // they skip the portal bridge and pass straight through.\n if (customRenderers.link) {\n out.link = customRenderers.link;\n }\n if (customRenderers.image) {\n out.image = customRenderers.image;\n }\n if (customRenderers.checklist) {\n out.checklist = customRenderers.checklist;\n }\n return out;\n }, [customRenderers, setPortalForSlot]);\n\n // After every commit, prune portals whose host Lit has removed (its slot\n // dropped out of the descriptor batch, leaving the host detached). The\n // connectivity check is deferred to a microtask on purpose: `bridge` mints a\n // host, `flushSync`s the portal into it while it is still detached, and only\n // *returns* it to Lit — which appends it synchronously afterwards. That\n // `flushSync` runs this effect once while the host is not yet adopted, so a\n // synchronous `isConnected` check would prune the entry we just added and\n // leave the slot permanently empty (e.g. a streaming table custom renderer\n // flickering out as later content arrives). Reading `isConnected` a\n // microtask later lets Lit's adoption land first, so we only drop\n // genuinely-removed hosts.\n\n useEffect(() => {\n let cancelled = false;\n queueMicrotask(() => {\n if (cancelled) {\n return;\n }\n let pruned = false;\n const aliveHosts = new Map<string, HTMLDivElement>();\n for (const [slotName, host] of hostsRef.current) {\n if (host.isConnected) {\n aliveHosts.set(slotName, host);\n } else {\n pruned = true;\n }\n }\n if (pruned) {\n hostsRef.current = aliveHosts;\n }\n setPortalEntries((prev) => {\n const filtered = prev.filter((e) => e.host.isConnected);\n return filtered.length === prev.length ? prev : filtered;\n });\n });\n return () => {\n cancelled = true;\n };\n });\n\n return (\n <>\n <BaseMarkdown\n {...rest}\n ref={setMarkdownRef as React.Ref<HTMLElement>}\n customRenderers={bridgedRenderers as never}\n />\n {portalEntries.map((entry) => (\n <React.Fragment key={entry.slotName}>\n {createPortal(entry.node, entry.host)}\n </React.Fragment>\n ))}\n </>\n );\n});\n\nMarkdown.displayName = 'Markdown';\n\nexport default Markdown;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;AA+BA,MAAM,WAAW,G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C,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,EAAA,EADlB,KAAK,CAAC,QAAQ,CAElB,CAClB,CAAC,CAAA,EAAA,CACD;AAEP,CAAC;AAED,QAAQ,CAAC,WAAW,GAAG,UAAU;;"}
@@ -27,4 +27,8 @@ export interface BaseOverflowMenuItem extends Partial<Pick<CDSOverflowMenuItem,
27
27
  * Optional data-testid string for e2e testing.
28
28
  */
29
29
  testId?: string;
30
+ /**
31
+ * Optional ID
32
+ */
33
+ id?: string;
30
34
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/ai-chat-components",
3
3
  "description": "AI Chat Components",
4
- "version": "1.11.0",
4
+ "version": "1.12.0-rc.0",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -102,10 +102,10 @@
102
102
  "tslib": "^2.6.3"
103
103
  },
104
104
  "devDependencies": {
105
- "@babel/core": "^7.26.0",
106
- "@babel/preset-env": "^7.26.0",
107
- "@babel/preset-react": "^7.25.9",
108
- "@babel/preset-typescript": "^7.26.0",
105
+ "@babel/core": "^8.0.0",
106
+ "@babel/preset-env": "^8.0.0",
107
+ "@babel/preset-react": "^8.0.0",
108
+ "@babel/preset-typescript": "^8.0.0",
109
109
  "@carbon/grid": "^11.20.0",
110
110
  "@carbon/icons-react": "^11.53.0",
111
111
  "@carbon/layout": "^11.19.0",
@@ -158,5 +158,5 @@
158
158
  "vite": "^8.0.16",
159
159
  "web-dev-server-plugin-lit-css": "^4.0.0"
160
160
  },
161
- "gitHead": "27001f31bd5bc3d286e672818c4214156366f603"
161
+ "gitHead": "d30211e57c329add14c03c71e52cd4e23ec9651a"
162
162
  }
@@ -40,23 +40,6 @@
40
40
  'card-border-radius',
41
41
  component.$card-border-radius
42
42
  );
43
- @include utilities.declaration('border-radius', component.$border-radius);
44
- @include utilities.declaration(
45
- 'border-radius-start-start',
46
- component.$border-radius-start-start
47
- );
48
- @include utilities.declaration(
49
- 'border-radius-start-end',
50
- component.$border-radius-start-end
51
- );
52
- @include utilities.declaration(
53
- 'border-radius-end-start',
54
- component.$border-radius-end-start
55
- );
56
- @include utilities.declaration(
57
- 'border-radius-end-end',
58
- component.$border-radius-end-end
59
- );
60
43
  }
61
44
 
62
45
  // ============================================================================
@@ -16,12 +16,11 @@
16
16
  // These tokens can be customized by developers to adjust component appearance
17
17
 
18
18
  // Border radius tokens
19
- $border-radius: 0 !default;
19
+ $border-radius: layout.$spacing-03 !default;
20
20
  $card-border-radius: layout.$spacing-03 !default;
21
21
 
22
22
  // Rounded modifier radius tokens
23
23
  // These are used by the data-rounded modifier system to apply contextual rounding
24
- $border-radius: layout.$spacing-03 !default;
25
24
  $border-radius-start-start: layout.$spacing-03 !default;
26
25
  $border-radius-start-end: layout.$spacing-03 !default;
27
26
  $border-radius-end-start: layout.$spacing-03 !default;