@carbon/ai-chat-components 0.7.1 → 0.8.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 (280) hide show
  1. package/README.md +4 -1
  2. package/custom-elements.json +1705 -467
  3. package/es/components/card/src/card-footer.d.ts +1 -0
  4. package/es/components/card/src/card-footer.js +3 -2
  5. package/es/components/card/src/card-footer.js.map +1 -1
  6. package/es/components/card/src/card-footer.scss.js +1 -1
  7. package/es/components/card/src/card-steps.d.ts +1 -0
  8. package/es/components/card/src/card-steps.js +2 -1
  9. package/es/components/card/src/card-steps.js.map +1 -1
  10. package/es/components/card/src/card.d.ts +1 -0
  11. package/es/components/card/src/card.js +3 -1
  12. package/es/components/card/src/card.js.map +1 -1
  13. package/es/components/card/src/card.scss.js +1 -1
  14. package/es/components/chain-of-thought/src/chain-of-thought-step.d.ts +4 -0
  15. package/es/components/chain-of-thought/src/chain-of-thought-step.js +5 -1
  16. package/es/components/chain-of-thought/src/chain-of-thought-step.js.map +1 -1
  17. package/es/components/chain-of-thought/src/chain-of-thought-toggle.d.ts +4 -0
  18. package/es/components/chain-of-thought/src/chain-of-thought-toggle.js +5 -1
  19. package/es/components/chain-of-thought/src/chain-of-thought-toggle.js.map +1 -1
  20. package/es/components/chain-of-thought/src/chain-of-thought.d.ts +4 -0
  21. package/es/components/chain-of-thought/src/chain-of-thought.js +5 -1
  22. package/es/components/chain-of-thought/src/chain-of-thought.js.map +1 -1
  23. package/es/components/chain-of-thought/src/tool-call-data.d.ts +4 -0
  24. package/es/components/chain-of-thought/src/tool-call-data.js +5 -1
  25. package/es/components/chain-of-thought/src/tool-call-data.js.map +1 -1
  26. package/es/components/chat-button/src/chat-button.js +4 -3
  27. package/es/components/chat-button/src/chat-button.js.map +1 -1
  28. package/es/components/chat-shell/index.d.ts +10 -0
  29. package/es/{node_modules/@carbon/utilities/es/documentLang/documentLang.js → components/chat-shell/index.js} +3 -2
  30. package/es/components/chat-shell/index.js.map +1 -0
  31. package/es/components/chat-shell/src/cds-aichat-panel.d.ts +66 -0
  32. package/es/components/chat-shell/src/cds-aichat-panel.js +433 -0
  33. package/es/components/chat-shell/src/cds-aichat-panel.js.map +1 -0
  34. package/es/components/chat-shell/src/cds-aichat-panel.scss.js +13 -0
  35. package/es/components/chat-shell/src/cds-aichat-panel.scss.js.map +1 -0
  36. package/es/components/chat-shell/src/cds-aichat-shell.d.ts +73 -0
  37. package/es/components/chat-shell/src/cds-aichat-shell.js +554 -0
  38. package/es/components/chat-shell/src/cds-aichat-shell.js.map +1 -0
  39. package/es/components/chat-shell/src/cds-aichat-shell.scss.js +13 -0
  40. package/es/components/chat-shell/src/cds-aichat-shell.scss.js.map +1 -0
  41. package/es/components/chat-shell/src/panel-manager.d.ts +29 -0
  42. package/es/components/chat-shell/src/panel-manager.js +144 -0
  43. package/es/components/chat-shell/src/panel-manager.js.map +1 -0
  44. package/es/components/chat-shell/src/workspace-manager.d.ts +118 -0
  45. package/es/components/chat-shell/src/workspace-manager.js +465 -0
  46. package/es/components/chat-shell/src/workspace-manager.js.map +1 -0
  47. package/es/components/code-snippet/src/code-snippet-card.js +2 -1
  48. package/es/components/code-snippet/src/code-snippet-card.js.map +1 -1
  49. package/es/components/code-snippet/src/code-snippet.d.ts +1 -0
  50. package/es/components/code-snippet/src/code-snippet.js +3 -1
  51. package/es/components/code-snippet/src/code-snippet.js.map +1 -1
  52. package/es/components/code-snippet/src/code-snippet.scss.js +1 -1
  53. package/es/components/feedback/src/feedback-buttons.d.ts +4 -0
  54. package/es/components/feedback/src/feedback-buttons.js +6 -1
  55. package/es/components/feedback/src/feedback-buttons.js.map +1 -1
  56. package/es/components/feedback/src/feedback.d.ts +1 -0
  57. package/es/components/feedback/src/feedback.js +3 -1
  58. package/es/components/feedback/src/feedback.js.map +1 -1
  59. package/es/components/feedback/src/feedback.scss.js +1 -1
  60. package/es/components/markdown/src/markdown-token-tree.js +1 -1
  61. package/es/components/markdown/src/markdown.d.ts +4 -0
  62. package/es/components/markdown/src/markdown.js +6 -1
  63. package/es/components/markdown/src/markdown.js.map +1 -1
  64. package/es/components/markdown/src/plugins/markdownItAttrs/patterns/code.js +1 -1
  65. package/es/components/markdown/src/plugins/markdownItAttrs/patterns/inline.js +1 -1
  66. package/es/components/markdown/src/plugins/markdownItAttrs/patterns/lists.js +1 -1
  67. package/es/components/markdown/src/plugins/markdownItAttrs/patterns/tables.js +1 -1
  68. package/es/components/processing/src/processing.d.ts +4 -0
  69. package/es/components/processing/src/processing.js +6 -1
  70. package/es/components/processing/src/processing.js.map +1 -1
  71. package/es/components/reasoning-steps/src/reasoning-step.d.ts +4 -0
  72. package/es/components/reasoning-steps/src/reasoning-step.js +5 -1
  73. package/es/components/reasoning-steps/src/reasoning-step.js.map +1 -1
  74. package/es/components/reasoning-steps/src/reasoning-steps-toggle.d.ts +4 -0
  75. package/es/components/reasoning-steps/src/reasoning-steps-toggle.js +6 -1
  76. package/es/components/reasoning-steps/src/reasoning-steps-toggle.js.map +1 -1
  77. package/es/components/reasoning-steps/src/reasoning-steps.d.ts +4 -0
  78. package/es/components/reasoning-steps/src/reasoning-steps.js +5 -1
  79. package/es/components/reasoning-steps/src/reasoning-steps.js.map +1 -1
  80. package/es/components/table/src/table.d.ts +1 -0
  81. package/es/components/table/src/table.js +5 -3
  82. package/es/components/table/src/table.js.map +1 -1
  83. package/es/components/table/src/table.template.js +2 -2
  84. package/es/components/table/src/table.template.js.map +1 -1
  85. package/es/components/toolbar/src/toolbar.js +3 -4
  86. package/es/components/toolbar/src/toolbar.js.map +1 -1
  87. package/es/components/toolbar/src/toolbar.scss.js +1 -1
  88. package/es/components/workspace-shell/src/workspace-shell-body.js +2 -1
  89. package/es/components/workspace-shell/src/workspace-shell-body.js.map +1 -1
  90. package/es/components/workspace-shell/src/workspace-shell-footer.js +2 -2
  91. package/es/components/workspace-shell/src/workspace-shell-footer.js.map +1 -1
  92. package/es/components/workspace-shell/src/workspace-shell-footer.scss.js +1 -1
  93. package/es/components/workspace-shell/src/workspace-shell-header.js +2 -2
  94. package/es/components/workspace-shell/src/workspace-shell-header.js.map +1 -1
  95. package/es/components/workspace-shell/src/workspace-shell.js +2 -1
  96. package/es/components/workspace-shell/src/workspace-shell.js.map +1 -1
  97. package/es/components/workspace-shell/src/workspace-shell.scss.js +1 -1
  98. package/es/react/__tests__/jest.setup.js +83 -0
  99. package/es/react/__tests__/jest.setup.js.map +1 -0
  100. package/es/react/chat-shell.d.ts +12 -0
  101. package/es/react/chat-shell.js +28 -0
  102. package/es/react/chat-shell.js.map +1 -0
  103. package/es/react/panel.d.ts +4 -0
  104. package/{es-custom/react/inline-notification.js → es/react/panel.js} +12 -6
  105. package/es/react/panel.js.map +1 -0
  106. package/es/react/toolbar.d.ts +14 -2
  107. package/es/react/toolbar.js +59 -9
  108. package/es/react/toolbar.js.map +1 -1
  109. package/es/react/utils/iconTransform.d.ts +37 -0
  110. package/es/react/utils/iconTransform.js +176 -0
  111. package/es/react/utils/iconTransform.js.map +1 -0
  112. package/es-custom/components/card/src/card-footer.d.ts +1 -0
  113. package/es-custom/components/card/src/card-footer.js +3 -2
  114. package/es-custom/components/card/src/card-footer.js.map +1 -1
  115. package/es-custom/components/card/src/card-footer.scss.js +1 -1
  116. package/es-custom/components/card/src/card-steps.d.ts +1 -0
  117. package/es-custom/components/card/src/card-steps.js +2 -1
  118. package/es-custom/components/card/src/card-steps.js.map +1 -1
  119. package/es-custom/components/card/src/card.d.ts +1 -0
  120. package/es-custom/components/card/src/card.js +3 -1
  121. package/es-custom/components/card/src/card.js.map +1 -1
  122. package/es-custom/components/card/src/card.scss.js +1 -1
  123. package/es-custom/components/chain-of-thought/src/chain-of-thought-step.d.ts +4 -0
  124. package/es-custom/components/chain-of-thought/src/chain-of-thought-step.js +5 -1
  125. package/es-custom/components/chain-of-thought/src/chain-of-thought-step.js.map +1 -1
  126. package/es-custom/components/chain-of-thought/src/chain-of-thought-toggle.d.ts +4 -0
  127. package/es-custom/components/chain-of-thought/src/chain-of-thought-toggle.js +5 -1
  128. package/es-custom/components/chain-of-thought/src/chain-of-thought-toggle.js.map +1 -1
  129. package/es-custom/components/chain-of-thought/src/chain-of-thought.d.ts +4 -0
  130. package/es-custom/components/chain-of-thought/src/chain-of-thought.js +5 -1
  131. package/es-custom/components/chain-of-thought/src/chain-of-thought.js.map +1 -1
  132. package/es-custom/components/chain-of-thought/src/tool-call-data.d.ts +4 -0
  133. package/es-custom/components/chain-of-thought/src/tool-call-data.js +5 -1
  134. package/es-custom/components/chain-of-thought/src/tool-call-data.js.map +1 -1
  135. package/es-custom/components/chat-button/src/chat-button.js +4 -3
  136. package/es-custom/components/chat-button/src/chat-button.js.map +1 -1
  137. package/es-custom/components/chat-shell/index.d.ts +10 -0
  138. package/es-custom/{node_modules/@carbon/utilities/es/documentLang/documentLang.js → components/chat-shell/index.js} +3 -2
  139. package/es-custom/components/chat-shell/index.js.map +1 -0
  140. package/es-custom/components/chat-shell/src/cds-aichat-panel.d.ts +66 -0
  141. package/es-custom/components/chat-shell/src/cds-aichat-panel.js +433 -0
  142. package/es-custom/components/chat-shell/src/cds-aichat-panel.js.map +1 -0
  143. package/es-custom/components/chat-shell/src/cds-aichat-panel.scss.js +13 -0
  144. package/es-custom/components/chat-shell/src/cds-aichat-panel.scss.js.map +1 -0
  145. package/es-custom/components/chat-shell/src/cds-aichat-shell.d.ts +73 -0
  146. package/es-custom/components/chat-shell/src/cds-aichat-shell.js +554 -0
  147. package/es-custom/components/chat-shell/src/cds-aichat-shell.js.map +1 -0
  148. package/es-custom/components/chat-shell/src/cds-aichat-shell.scss.js +13 -0
  149. package/es-custom/components/chat-shell/src/cds-aichat-shell.scss.js.map +1 -0
  150. package/es-custom/components/chat-shell/src/panel-manager.d.ts +29 -0
  151. package/es-custom/components/chat-shell/src/panel-manager.js +144 -0
  152. package/es-custom/components/chat-shell/src/panel-manager.js.map +1 -0
  153. package/es-custom/components/chat-shell/src/workspace-manager.d.ts +118 -0
  154. package/es-custom/components/chat-shell/src/workspace-manager.js +465 -0
  155. package/es-custom/components/chat-shell/src/workspace-manager.js.map +1 -0
  156. package/es-custom/components/code-snippet/src/code-snippet-card.js +2 -1
  157. package/es-custom/components/code-snippet/src/code-snippet-card.js.map +1 -1
  158. package/es-custom/components/code-snippet/src/code-snippet.d.ts +1 -0
  159. package/es-custom/components/code-snippet/src/code-snippet.js +3 -1
  160. package/es-custom/components/code-snippet/src/code-snippet.js.map +1 -1
  161. package/es-custom/components/code-snippet/src/code-snippet.scss.js +1 -1
  162. package/es-custom/components/feedback/src/feedback-buttons.d.ts +4 -0
  163. package/es-custom/components/feedback/src/feedback-buttons.js +6 -1
  164. package/es-custom/components/feedback/src/feedback-buttons.js.map +1 -1
  165. package/es-custom/components/feedback/src/feedback.d.ts +1 -0
  166. package/es-custom/components/feedback/src/feedback.js +3 -1
  167. package/es-custom/components/feedback/src/feedback.js.map +1 -1
  168. package/es-custom/components/feedback/src/feedback.scss.js +1 -1
  169. package/es-custom/components/markdown/src/markdown-token-tree.js +1 -1
  170. package/es-custom/components/markdown/src/markdown.d.ts +4 -0
  171. package/es-custom/components/markdown/src/markdown.js +6 -1
  172. package/es-custom/components/markdown/src/markdown.js.map +1 -1
  173. package/es-custom/components/markdown/src/plugins/markdownItAttrs/patterns/code.js +1 -1
  174. package/es-custom/components/markdown/src/plugins/markdownItAttrs/patterns/inline.js +1 -1
  175. package/es-custom/components/markdown/src/plugins/markdownItAttrs/patterns/lists.js +1 -1
  176. package/es-custom/components/markdown/src/plugins/markdownItAttrs/patterns/tables.js +1 -1
  177. package/es-custom/components/processing/src/processing.d.ts +4 -0
  178. package/es-custom/components/processing/src/processing.js +6 -1
  179. package/es-custom/components/processing/src/processing.js.map +1 -1
  180. package/es-custom/components/reasoning-steps/src/reasoning-step.d.ts +4 -0
  181. package/es-custom/components/reasoning-steps/src/reasoning-step.js +5 -1
  182. package/es-custom/components/reasoning-steps/src/reasoning-step.js.map +1 -1
  183. package/es-custom/components/reasoning-steps/src/reasoning-steps-toggle.d.ts +4 -0
  184. package/es-custom/components/reasoning-steps/src/reasoning-steps-toggle.js +6 -1
  185. package/es-custom/components/reasoning-steps/src/reasoning-steps-toggle.js.map +1 -1
  186. package/es-custom/components/reasoning-steps/src/reasoning-steps.d.ts +4 -0
  187. package/es-custom/components/reasoning-steps/src/reasoning-steps.js +5 -1
  188. package/es-custom/components/reasoning-steps/src/reasoning-steps.js.map +1 -1
  189. package/es-custom/components/table/src/table.d.ts +1 -0
  190. package/es-custom/components/table/src/table.js +5 -3
  191. package/es-custom/components/table/src/table.js.map +1 -1
  192. package/es-custom/components/table/src/table.template.js +2 -2
  193. package/es-custom/components/table/src/table.template.js.map +1 -1
  194. package/es-custom/components/toolbar/src/toolbar.js +3 -4
  195. package/es-custom/components/toolbar/src/toolbar.js.map +1 -1
  196. package/es-custom/components/toolbar/src/toolbar.scss.js +1 -1
  197. package/es-custom/components/workspace-shell/src/workspace-shell-body.js +2 -1
  198. package/es-custom/components/workspace-shell/src/workspace-shell-body.js.map +1 -1
  199. package/es-custom/components/workspace-shell/src/workspace-shell-footer.js +2 -2
  200. package/es-custom/components/workspace-shell/src/workspace-shell-footer.js.map +1 -1
  201. package/es-custom/components/workspace-shell/src/workspace-shell-footer.scss.js +1 -1
  202. package/es-custom/components/workspace-shell/src/workspace-shell-header.js +2 -2
  203. package/es-custom/components/workspace-shell/src/workspace-shell-header.js.map +1 -1
  204. package/es-custom/components/workspace-shell/src/workspace-shell.js +2 -1
  205. package/es-custom/components/workspace-shell/src/workspace-shell.js.map +1 -1
  206. package/es-custom/components/workspace-shell/src/workspace-shell.scss.js +1 -1
  207. package/es-custom/react/__tests__/jest.setup.js +83 -0
  208. package/es-custom/react/__tests__/jest.setup.js.map +1 -0
  209. package/es-custom/react/chat-shell.d.ts +12 -0
  210. package/es-custom/react/chat-shell.js +28 -0
  211. package/es-custom/react/chat-shell.js.map +1 -0
  212. package/es-custom/react/panel.d.ts +4 -0
  213. package/es-custom/react/{ai-label.js → panel.js} +12 -6
  214. package/es-custom/react/panel.js.map +1 -0
  215. package/es-custom/react/toolbar.d.ts +14 -2
  216. package/es-custom/react/toolbar.js +59 -9
  217. package/es-custom/react/toolbar.js.map +1 -1
  218. package/es-custom/react/utils/iconTransform.d.ts +37 -0
  219. package/es-custom/react/utils/iconTransform.js +176 -0
  220. package/es-custom/react/utils/iconTransform.js.map +1 -0
  221. package/package.json +21 -6
  222. package/telemetry.yml +125 -2
  223. package/es/node_modules/@carbon/utilities/es/documentLang/documentLang.js.map +0 -1
  224. package/es/node_modules/@carbon/utilities/es/overflowHandler/overflowHandler.js +0 -11
  225. package/es/node_modules/@carbon/utilities/es/overflowHandler/overflowHandler.js.map +0 -1
  226. package/es/react/ai-label.d.ts +0 -4
  227. package/es/react/ai-label.js +0 -28
  228. package/es/react/ai-label.js.map +0 -1
  229. package/es/react/button.d.ts +0 -6
  230. package/es/react/button.js +0 -29
  231. package/es/react/button.js.map +0 -1
  232. package/es/react/content-switcher.d.ts +0 -7
  233. package/es/react/content-switcher.js +0 -37
  234. package/es/react/content-switcher.js.map +0 -1
  235. package/es/react/icon-button.d.ts +0 -4
  236. package/es/react/icon-button.js +0 -28
  237. package/es/react/icon-button.js.map +0 -1
  238. package/es/react/icon.d.ts +0 -4
  239. package/es/react/icon.js +0 -28
  240. package/es/react/icon.js.map +0 -1
  241. package/es/react/inline-notification.d.ts +0 -4
  242. package/es/react/inline-notification.js +0 -28
  243. package/es/react/inline-notification.js.map +0 -1
  244. package/es/react/overflow-menu.d.ts +0 -9
  245. package/es/react/overflow-menu.js +0 -40
  246. package/es/react/overflow-menu.js.map +0 -1
  247. package/es/react/tag.d.ts +0 -4
  248. package/es/react/tag.js +0 -28
  249. package/es/react/tag.js.map +0 -1
  250. package/es/react/tile.d.ts +0 -7
  251. package/es/react/tile.js +0 -34
  252. package/es/react/tile.js.map +0 -1
  253. package/es-custom/node_modules/@carbon/utilities/es/documentLang/documentLang.js.map +0 -1
  254. package/es-custom/node_modules/@carbon/utilities/es/overflowHandler/overflowHandler.js +0 -11
  255. package/es-custom/node_modules/@carbon/utilities/es/overflowHandler/overflowHandler.js.map +0 -1
  256. package/es-custom/react/ai-label.d.ts +0 -4
  257. package/es-custom/react/ai-label.js.map +0 -1
  258. package/es-custom/react/button.d.ts +0 -6
  259. package/es-custom/react/button.js +0 -29
  260. package/es-custom/react/button.js.map +0 -1
  261. package/es-custom/react/content-switcher.d.ts +0 -7
  262. package/es-custom/react/content-switcher.js +0 -37
  263. package/es-custom/react/content-switcher.js.map +0 -1
  264. package/es-custom/react/icon-button.d.ts +0 -4
  265. package/es-custom/react/icon-button.js +0 -28
  266. package/es-custom/react/icon-button.js.map +0 -1
  267. package/es-custom/react/icon.d.ts +0 -4
  268. package/es-custom/react/icon.js +0 -28
  269. package/es-custom/react/icon.js.map +0 -1
  270. package/es-custom/react/inline-notification.d.ts +0 -4
  271. package/es-custom/react/inline-notification.js.map +0 -1
  272. package/es-custom/react/overflow-menu.d.ts +0 -9
  273. package/es-custom/react/overflow-menu.js +0 -40
  274. package/es-custom/react/overflow-menu.js.map +0 -1
  275. package/es-custom/react/tag.d.ts +0 -4
  276. package/es-custom/react/tag.js +0 -28
  277. package/es-custom/react/tag.js.map +0 -1
  278. package/es-custom/react/tile.d.ts +0 -7
  279. package/es-custom/react/tile.js +0 -34
  280. package/es-custom/react/tile.js.map +0 -1
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ /**
9
+ * @license
10
+ *
11
+ * Copyright IBM Corp. 2025
12
+ *
13
+ * This source code is licensed under the Apache-2.0 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+ class PanelManager {
17
+ constructor(panelsSlot, shellRoot) {
18
+ this.panelsSlot = panelsSlot;
19
+ this.shellRoot = shellRoot;
20
+ this.panelObservers = new Map();
21
+ this.slotElements = [];
22
+ this.onSlotChange = () => {
23
+ this.observeAssignedPanels();
24
+ this.updateState();
25
+ };
26
+ this.onPanelMutation = () => {
27
+ this.updateState();
28
+ };
29
+ }
30
+ connect() {
31
+ this.syncSlotElements();
32
+ this.panelsSlot.addEventListener("slotchange", this.onSlotChange);
33
+ this.observeAssignedPanels();
34
+ this.updateState();
35
+ }
36
+ disconnect() {
37
+ this.panelsSlot.removeEventListener("slotchange", this.onSlotChange);
38
+ this.stopObservingPanels();
39
+ }
40
+ refresh() {
41
+ this.observeAssignedPanels();
42
+ this.updateState();
43
+ }
44
+ observeAssignedPanels() {
45
+ const panels = this.getAssignedPanelElements();
46
+ const current = new Set(panels);
47
+ for (const [panel, observer] of this.panelObservers) {
48
+ if (!current.has(panel)) {
49
+ observer.disconnect();
50
+ this.panelObservers.delete(panel);
51
+ }
52
+ }
53
+ for (const panel of panels) {
54
+ if (!this.panelObservers.has(panel)) {
55
+ const observer = new MutationObserver(this.onPanelMutation);
56
+ observer.observe(panel, { attributes: true });
57
+ this.panelObservers.set(panel, observer);
58
+ }
59
+ }
60
+ }
61
+ stopObservingPanels() {
62
+ for (const observer of this.panelObservers.values()) {
63
+ observer.disconnect();
64
+ }
65
+ this.panelObservers.clear();
66
+ }
67
+ updateState() {
68
+ this.syncSlotElements();
69
+ const panels = this.getPanelStates();
70
+ const active = this.pickActivePanel(panels);
71
+ const hasActive = Boolean(active);
72
+ const headerInert = hasActive && !active?.showChatHeader;
73
+ this.slotElements.forEach((slot) => {
74
+ const slotName = slot.dataset.panelSlot;
75
+ if (slotName === "header" || slotName === "header-after") {
76
+ this.setInert(slot, headerInert);
77
+ }
78
+ else {
79
+ this.setInert(slot, hasActive);
80
+ }
81
+ });
82
+ panels.forEach((panel) => {
83
+ const shouldInert = hasActive && panel.element !== active?.element && panel.open;
84
+ this.setInert(panel.element, shouldInert);
85
+ });
86
+ const isAnyPanelAnimating = panels.some((panelState) => this.isPanelAnimating(panelState.element));
87
+ this.shellRoot.classList.toggle("shell--panels-animating", isAnyPanelAnimating);
88
+ }
89
+ getAssignedPanelElements() {
90
+ const internalPanels = Array.from(this.shellRoot.querySelectorAll("cds-aichat-panel[data-internal-panel]"));
91
+ const panelsElement = this.panelsSlot
92
+ .assignedElements({ flatten: true })
93
+ .find((element) => element instanceof HTMLElement);
94
+ const slottedPanels = panelsElement
95
+ ? Array.from(panelsElement.querySelectorAll("cds-aichat-panel"))
96
+ : [];
97
+ const panels = [...internalPanels, ...slottedPanels];
98
+ return Array.from(new Set(panels));
99
+ }
100
+ getPanelStates() {
101
+ const panels = this.getAssignedPanelElements();
102
+ return panels.map((element, index) => ({
103
+ element,
104
+ open: element.hasAttribute("open"),
105
+ priority: Number(element.getAttribute("priority") ?? 0),
106
+ showChatHeader: element.hasAttribute("show-chat-header"),
107
+ index,
108
+ }));
109
+ }
110
+ pickActivePanel(panels) {
111
+ if (panels?.length) {
112
+ const sortedPanels = panels
113
+ .filter((panel) => panel.open)
114
+ .sort((a, b) => {
115
+ if (a.priority !== b.priority) {
116
+ return b.priority - a.priority;
117
+ }
118
+ return b.index - a.index;
119
+ });
120
+ return sortedPanels[0];
121
+ }
122
+ return;
123
+ }
124
+ setInert(target, value) {
125
+ if (!target) {
126
+ return;
127
+ }
128
+ if (value) {
129
+ target.inert = true;
130
+ }
131
+ else {
132
+ target.inert = false;
133
+ }
134
+ }
135
+ isPanelAnimating(panelElement) {
136
+ return panelElement.classList.contains("panel-container--animating");
137
+ }
138
+ syncSlotElements() {
139
+ this.slotElements = Array.from(this.shellRoot.querySelectorAll("[data-panel-slot]"));
140
+ }
141
+ }
142
+
143
+ export { PanelManager };
144
+ //# sourceMappingURL=panel-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-manager.js","sources":["../../../../src/components/chat-shell/src/panel-manager.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;;;;;AAOG;MAUU,YAAY,CAAA;IAIvB,WAAA,CACmB,UAA2B,EAC3B,SAAsB,EA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,cAAc,EAAE,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC;YACxD,KAAK;AACN,SAAA,CAAC,CAAC;IACL;AAEQ,IAAA,eAAe,CAAC,MAAoB,EAAA;AAC1C,QAAA,IAAI,MAAM,EAAE,MAAM,EAAE;YAClB,MAAM,YAAY,GAAG;iBAClB,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI;AAC5B,iBAAA,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAI;gBACb,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,EAAE;AAC7B,oBAAA,OAAO,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ;gBAChC;AACA,gBAAA,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;AAC1B,YAAA,CAAC,CAAC;AAEJ,YAAA,OAAO,YAAY,CAAC,CAAC,CAAC;QACxB;QACA;IACF;IAEQ,QAAQ,CAAC,MAA+B,EAAE,KAAc,EAAA;QAC9D,IAAI,CAAC,MAAM,EAAE;YACX;QACF;QACA,IAAI,KAAK,EAAE;AACT,YAAA,MAAM,CAAC,KAAK,GAAG,IAAI;QACrB;aAAO;AACL,YAAA,MAAM,CAAC,KAAK,GAAG,KAAK;QACtB;IACF;AAEQ,IAAA,gBAAgB,CAAC,YAAyB,EAAA;QAChD,OAAO,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IACtE;IAEQ,gBAAgB,GAAA;AACtB,QAAA,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,IAAI,CAC5B,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAc,mBAAmB,CAAC,CAClE;IACH;AACD;;;;"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @license
3
+ *
4
+ * Copyright IBM Corp. 2025
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ interface WorkspaceConfig {
10
+ showWorkspace: boolean;
11
+ showHistory: boolean;
12
+ workspaceLocation: "start" | "end";
13
+ roundedCorners: boolean;
14
+ }
15
+ interface WorkspaceState {
16
+ inPanel: boolean;
17
+ contentVisible: boolean;
18
+ containerVisible: boolean;
19
+ isExpanding: boolean;
20
+ isContracting: boolean;
21
+ }
22
+ /**
23
+ * Manages workspace layout, responsive behavior, and transitions for cds-aichat-shell.
24
+ * Handles switching between inline and panel modes based on available width,
25
+ * and orchestrates smooth transitions when workspace visibility changes.
26
+ */
27
+ export declare class WorkspaceManager {
28
+ private readonly shellRoot;
29
+ private readonly hostElement;
30
+ private config;
31
+ private state;
32
+ private hostResizeObserver?;
33
+ private windowResizeHandler?;
34
+ private expansionCheckInterval?;
35
+ private expansionLastInlineSize?;
36
+ private closingCheckInterval?;
37
+ private closingLastInlineSize?;
38
+ private throttledHandleHostResize;
39
+ private cssPropertyObserver?;
40
+ private lastKnownCssValues;
41
+ constructor(shellRoot: HTMLElement, hostElement: HTMLElement, config: WorkspaceConfig);
42
+ /**
43
+ * Initialize workspace management and start observing resize events.
44
+ * Should be called after the shell component is fully rendered.
45
+ */
46
+ connect(): void;
47
+ /**
48
+ * Clean up observers and timers.
49
+ * Should be called when the shell component is disconnected.
50
+ */
51
+ disconnect(): void;
52
+ /**
53
+ * Refresh workspace state and re-evaluate layout.
54
+ * Useful after external changes that might affect layout.
55
+ */
56
+ refresh(): void;
57
+ /**
58
+ * Update workspace configuration.
59
+ * Handles transitions when workspace visibility or related settings change.
60
+ */
61
+ updateConfig(newConfig: Partial<WorkspaceConfig>): void;
62
+ /**
63
+ * Get current workspace state.
64
+ * Returns a readonly copy to prevent external mutations.
65
+ */
66
+ getState(): Readonly<WorkspaceState>;
67
+ /**
68
+ * Check if workspace should be rendered inline (side-by-side with messages).
69
+ */
70
+ shouldRenderInline(): boolean;
71
+ /**
72
+ * Check if workspace should be rendered as a panel (overlay).
73
+ */
74
+ shouldRenderPanel(): boolean;
75
+ private observeHostWidth;
76
+ private setupWindowResizeListener;
77
+ private createHostResizeObserver;
78
+ private reconnectHostResizeObserver;
79
+ private performInitialHostMeasurement;
80
+ private handleHostResize;
81
+ private updateWorkspaceInPanelState;
82
+ private handleShowWorkspaceEnabled;
83
+ private handleShowWorkspaceDisabled;
84
+ private startExpansionPolling;
85
+ private startClosingPolling;
86
+ private finishWorkspaceExpansion;
87
+ private finishWorkspaceClosing;
88
+ private trackExpectedExpansion;
89
+ private clearExpansionTimers;
90
+ private clearClosingTimer;
91
+ private setWorkspaceInPanel;
92
+ private setWorkspaceContentVisible;
93
+ private setShowWorkspaceContainer;
94
+ private setState;
95
+ private updateShellClasses;
96
+ private requestHostUpdate;
97
+ private getRequiredMinWidth;
98
+ private isWideEnough;
99
+ private canHostGrow;
100
+ private finalizeImmediateDisplay;
101
+ private setupExpansionTracking;
102
+ private getInlineSizeFromEntry;
103
+ private getCssLengthFromProperty;
104
+ /**
105
+ * Observe CSS custom properties that affect workspace layout.
106
+ * When these properties change, recalculate workspace positioning.
107
+ */
108
+ private observeCssProperties;
109
+ /**
110
+ * Update the cached CSS property values.
111
+ */
112
+ private updateLastKnownCssValues;
113
+ /**
114
+ * Check if any relevant CSS properties have changed and trigger recalculation.
115
+ */
116
+ private checkCssPropertyChanges;
117
+ }
118
+ export {};