@swisper.ai/web-chat-ui 0.0.2 → 0.0.5

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 (369) hide show
  1. package/README.md +9 -12
  2. package/dist/components/canvas-shell/canvas-shell.d.ts +32 -10
  3. package/dist/components/canvas-shell/canvas-shell.d.ts.map +1 -1
  4. package/dist/components/canvas-shell/canvas-shell.stories.d.ts +49 -17
  5. package/dist/components/canvas-shell/canvas-shell.stories.d.ts.map +1 -1
  6. package/dist/components/chat-card/chat-card.d.ts +1 -0
  7. package/dist/components/chat-card/chat-card.d.ts.map +1 -1
  8. package/dist/components/chat-card/chat-card.stories.d.ts +47 -1
  9. package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -1
  10. package/dist/components/chat-card/components/chat-card-body.d.ts +8 -0
  11. package/dist/components/chat-card/components/chat-card-body.d.ts.map +1 -1
  12. package/dist/components/chat-card/components/chat-card-footer.d.ts +8 -0
  13. package/dist/components/chat-card/components/chat-card-footer.d.ts.map +1 -1
  14. package/dist/components/chat-card/components/chat-card-form.d.ts +15 -2
  15. package/dist/components/chat-card/components/chat-card-form.d.ts.map +1 -1
  16. package/dist/components/chat-card/components/chat-card-header.d.ts +23 -2
  17. package/dist/components/chat-card/components/chat-card-header.d.ts.map +1 -1
  18. package/dist/components/chat-card/contexts.d.ts +2 -0
  19. package/dist/components/chat-card/contexts.d.ts.map +1 -1
  20. package/dist/components/chat-card/hooks.d.ts +1 -0
  21. package/dist/components/chat-card/hooks.d.ts.map +1 -1
  22. package/dist/components/chat-card/types.d.ts +3 -0
  23. package/dist/components/chat-card/types.d.ts.map +1 -1
  24. package/dist/components/chat-card-container/chat-card-container.d.ts +4 -0
  25. package/dist/components/chat-card-container/chat-card-container.d.ts.map +1 -1
  26. package/dist/components/chat-card-container/chat-card-container.stories.d.ts +12 -1
  27. package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -1
  28. package/dist/components/chat-container/chat-container.d.ts.map +1 -1
  29. package/dist/components/chat-container/chat-container.stories.d.ts +36 -11
  30. package/dist/components/chat-container/chat-container.stories.d.ts.map +1 -1
  31. package/dist/components/chat-input/chat-input.d.ts +30 -2
  32. package/dist/components/chat-input/chat-input.d.ts.map +1 -1
  33. package/dist/components/chat-input/chat-input.stories.d.ts +63 -3
  34. package/dist/components/chat-input/chat-input.stories.d.ts.map +1 -1
  35. package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts +4 -1
  36. package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts.map +1 -1
  37. package/dist/components/chat-input/plugins/value-plugin.d.ts +4 -1
  38. package/dist/components/chat-input/plugins/value-plugin.d.ts.map +1 -1
  39. package/dist/components/chat-list/chat-list-item.d.ts +6 -0
  40. package/dist/components/chat-list/chat-list-item.d.ts.map +1 -1
  41. package/dist/components/chat-list/chat-list-items.d.ts +12 -1
  42. package/dist/components/chat-list/chat-list-items.d.ts.map +1 -1
  43. package/dist/components/chat-list/chat-list.d.ts +36 -2
  44. package/dist/components/chat-list/chat-list.d.ts.map +1 -1
  45. package/dist/components/chat-list/chat-list.stories.d.ts +67 -9
  46. package/dist/components/chat-list/chat-list.stories.d.ts.map +1 -1
  47. package/dist/components/chat-message/chat-message.d.ts +12 -1
  48. package/dist/components/chat-message/chat-message.d.ts.map +1 -1
  49. package/dist/components/chat-message/chat-message.stories.d.ts +31 -0
  50. package/dist/components/chat-message/chat-message.stories.d.ts.map +1 -1
  51. package/dist/components/chat-message/index.d.ts +1 -1
  52. package/dist/components/chat-message/index.d.ts.map +1 -1
  53. package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts +3 -0
  54. package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts.map +1 -1
  55. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts +25 -5
  56. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts.map +1 -1
  57. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts +32 -1
  58. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts.map +1 -1
  59. package/dist/components/chat-message-attachment-card/index.d.ts +2 -2
  60. package/dist/components/chat-message-attachment-card/index.d.ts.map +1 -1
  61. package/dist/components/chat-message-attachment-card/utils.d.ts +1 -0
  62. package/dist/components/chat-message-attachment-card/utils.d.ts.map +1 -1
  63. package/dist/components/chat-message-response/chat-message-response.stories.d.ts +13 -0
  64. package/dist/components/chat-message-response/chat-message-response.stories.d.ts.map +1 -1
  65. package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts +22 -5
  66. package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts.map +1 -1
  67. package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts +42 -0
  68. package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts.map +1 -1
  69. package/dist/components/chat-message-toolbar/index.d.ts +1 -1
  70. package/dist/components/chat-message-toolbar/index.d.ts.map +1 -1
  71. package/dist/components/chat-messages/chat-messages.d.ts +34 -2
  72. package/dist/components/chat-messages/chat-messages.d.ts.map +1 -1
  73. package/dist/components/chat-messages/chat-messages.stories.d.ts +33 -2
  74. package/dist/components/chat-messages/chat-messages.stories.d.ts.map +1 -1
  75. package/dist/components/chat-notification-card/chat-notification-card.d.ts +56 -4
  76. package/dist/components/chat-notification-card/chat-notification-card.d.ts.map +1 -1
  77. package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts +50 -1
  78. package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts.map +1 -1
  79. package/dist/components/chat-notification-popup/chat-notification-popup.d.ts +6 -0
  80. package/dist/components/chat-notification-popup/chat-notification-popup.d.ts.map +1 -1
  81. package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts +43 -1
  82. package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts.map +1 -1
  83. package/dist/components/chat-prompt-box/chat-prompt-box.d.ts +37 -17
  84. package/dist/components/chat-prompt-box/chat-prompt-box.d.ts.map +1 -1
  85. package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts +53 -1
  86. package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts.map +1 -1
  87. package/dist/components/chat-reply/chat-reply.d.ts +11 -0
  88. package/dist/components/chat-reply/chat-reply.d.ts.map +1 -1
  89. package/dist/components/chat-reply/chat-reply.stories.d.ts +23 -0
  90. package/dist/components/chat-reply/chat-reply.stories.d.ts.map +1 -1
  91. package/dist/components/chat-reply/index.d.ts +1 -1
  92. package/dist/components/chat-reply/index.d.ts.map +1 -1
  93. package/dist/components/chat-suggestion/chat-suggestion.d.ts +36 -10
  94. package/dist/components/chat-suggestion/chat-suggestion.d.ts.map +1 -1
  95. package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts +66 -2
  96. package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts.map +1 -1
  97. package/dist/components/chat-suggestion/index.d.ts +2 -1
  98. package/dist/components/chat-suggestion/index.d.ts.map +1 -1
  99. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +26 -1
  100. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -1
  101. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +25 -1
  102. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -1
  103. package/dist/components/chat-thread/chat-thread.d.ts +17 -2
  104. package/dist/components/chat-thread/chat-thread.d.ts.map +1 -1
  105. package/dist/components/chat-thread/chat-thread.stories.d.ts +75 -10
  106. package/dist/components/chat-thread/chat-thread.stories.d.ts.map +1 -1
  107. package/dist/components/index.d.ts +1 -3
  108. package/dist/components/index.d.ts.map +1 -1
  109. package/dist/components/markdown-viewer/markdown-viewer.d.ts +8 -1
  110. package/dist/components/markdown-viewer/markdown-viewer.d.ts.map +1 -1
  111. package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts +18 -1
  112. package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts.map +1 -1
  113. package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts +4 -1
  114. package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts.map +1 -1
  115. package/dist/components/rich-text-area/plugins/value-plugin.d.ts +4 -1
  116. package/dist/components/rich-text-area/plugins/value-plugin.d.ts.map +1 -1
  117. package/dist/components/rich-text-area/rich-text-area.d.ts +17 -0
  118. package/dist/components/rich-text-area/rich-text-area.d.ts.map +1 -1
  119. package/dist/components/rich-text-area/rich-text-area.stories.d.ts +52 -0
  120. package/dist/components/rich-text-area/rich-text-area.stories.d.ts.map +1 -1
  121. package/dist/components/rich-text-area/styled.d.ts +6 -2
  122. package/dist/components/rich-text-area/styled.d.ts.map +1 -1
  123. package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts +9 -2
  124. package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts.map +1 -1
  125. package/dist/components/rich-text-field/components/index.d.ts +5 -5
  126. package/dist/components/rich-text-field/components/index.d.ts.map +1 -1
  127. package/dist/components/rich-text-field/components/text-color-button.d.ts +12 -1
  128. package/dist/components/rich-text-field/components/text-color-button.d.ts.map +1 -1
  129. package/dist/components/rich-text-field/rich-text-field.d.ts +22 -0
  130. package/dist/components/rich-text-field/rich-text-field.d.ts.map +1 -1
  131. package/dist/components/rich-text-field/rich-text-field.stories.d.ts +28 -1
  132. package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -1
  133. package/dist/components/topmenu/index.d.ts +2 -0
  134. package/dist/components/topmenu/index.d.ts.map +1 -0
  135. package/dist/components/topmenu/topmenu.d.ts +22 -0
  136. package/dist/components/topmenu/topmenu.d.ts.map +1 -0
  137. package/dist/components/topmenu/topmenu.stories.d.ts +31 -0
  138. package/dist/components/topmenu/topmenu.stories.d.ts.map +1 -0
  139. package/dist/docs/agent.stories.d.ts.map +1 -1
  140. package/dist/docs/chat-panel.d.ts +7 -5
  141. package/dist/docs/chat-panel.d.ts.map +1 -1
  142. package/dist/docs/chatbot-panel.d.ts.map +1 -1
  143. package/dist/docs/chatbot.stories.d.ts.map +1 -1
  144. package/dist/index.css +1 -1
  145. package/dist/index.es.js +1801 -1806
  146. package/dist/index.es.js.map +1 -1
  147. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +9 -7
  148. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +1 -1
  149. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +37 -9
  150. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +1 -1
  151. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +41 -16
  152. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +1 -1
  153. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +6 -0
  154. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +1 -1
  155. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +22 -1
  156. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +1 -1
  157. package/package.json +16 -10
  158. package/src/__storybook__/parent-block.tsx +21 -0
  159. package/src/components/canvas-shell/__stories__/canvas-panel.tsx +25 -0
  160. package/src/components/canvas-shell/__stories__/document-list.tsx +29 -0
  161. package/src/components/canvas-shell/__stories__/fixtures.ts +222 -0
  162. package/src/components/canvas-shell/__stories__/holdings-table.tsx +56 -0
  163. package/src/components/canvas-shell/__stories__/types.ts +47 -0
  164. package/src/components/canvas-shell/{canvas-shell.test.tsx → __tests__/canvas-shell.spec.tsx} +1 -1
  165. package/src/components/canvas-shell/canvas-shell.json +24 -0
  166. package/src/components/canvas-shell/canvas-shell.stories.tsx +581 -122
  167. package/src/components/canvas-shell/canvas-shell.tsx +44 -17
  168. package/src/components/chat-card/__stories__/fixtures.ts +119 -0
  169. package/src/components/chat-card/__stories__/types.ts +44 -0
  170. package/src/components/chat-card/chat-card.json +67 -3
  171. package/src/components/chat-card/chat-card.stories.tsx +872 -148
  172. package/src/components/chat-card/chat-card.tsx +2 -0
  173. package/src/components/chat-card/components/chat-card-body.tsx +12 -0
  174. package/src/components/chat-card/components/chat-card-footer.tsx +11 -0
  175. package/src/components/chat-card/components/chat-card-form.tsx +21 -2
  176. package/src/components/chat-card/components/chat-card-header.tsx +39 -2
  177. package/src/components/chat-card/contexts.tsx +2 -0
  178. package/src/components/chat-card/hooks.ts +1 -0
  179. package/src/components/chat-card/types.ts +3 -0
  180. package/src/components/chat-card-container/__stories__/fixtures.ts +54 -0
  181. package/src/components/chat-card-container/__stories__/resizable-chat-window.tsx +19 -0
  182. package/src/components/chat-card-container/__stories__/result-card.tsx +31 -0
  183. package/src/components/chat-card-container/__stories__/types.ts +16 -0
  184. package/src/components/chat-card-container/chat-card-container.json +7 -0
  185. package/src/components/chat-card-container/chat-card-container.stories.tsx +209 -56
  186. package/src/components/chat-card-container/chat-card-container.tsx +5 -0
  187. package/src/components/chat-container/__stories__/chat-composer.tsx +67 -0
  188. package/src/components/chat-container/__stories__/fixtures.ts +27 -0
  189. package/src/components/chat-container/__stories__/measure.ts +22 -0
  190. package/src/components/chat-container/__stories__/types.ts +7 -0
  191. package/src/components/chat-container/__stories__/variable-readout.tsx +64 -0
  192. package/src/components/chat-container/chat-container.json +9 -1
  193. package/src/components/chat-container/chat-container.stories.tsx +538 -106
  194. package/src/components/chat-container/chat-container.tsx +3 -0
  195. package/src/components/chat-input/__stories__/fixtures.ts +31 -0
  196. package/src/components/chat-input/__tests__/chat-input.spec.tsx +100 -0
  197. package/src/components/chat-input/chat-input.json +11 -2
  198. package/src/components/chat-input/chat-input.stories.tsx +660 -197
  199. package/src/components/chat-input/chat-input.tsx +39 -5
  200. package/src/components/chat-input/plugins/controlled-value-plugin.tsx +16 -3
  201. package/src/components/chat-input/plugins/value-plugin.tsx +19 -4
  202. package/src/components/chat-list/__stories__/chat-row.tsx +41 -0
  203. package/src/components/chat-list/__stories__/fixtures.ts +94 -0
  204. package/src/components/chat-list/__stories__/types.ts +13 -0
  205. package/src/components/chat-list/chat-list-item.tsx +6 -0
  206. package/src/components/chat-list/chat-list-items.tsx +16 -0
  207. package/src/components/chat-list/chat-list.json +24 -2
  208. package/src/components/chat-list/chat-list.stories.tsx +631 -215
  209. package/src/components/chat-list/chat-list.tsx +51 -4
  210. package/src/components/chat-message/__stories__/fixtures.ts +53 -0
  211. package/src/components/chat-message/__stories__/sent-attachment.tsx +22 -0
  212. package/src/components/chat-message/__stories__/tool-steps.tsx +37 -0
  213. package/src/components/chat-message/chat-message.json +10 -1
  214. package/src/components/chat-message/chat-message.stories.tsx +282 -20
  215. package/src/components/chat-message/chat-message.tsx +16 -1
  216. package/src/components/chat-message/index.ts +8 -1
  217. package/src/components/chat-message-attachment-card/__stories__/fixtures.ts +30 -0
  218. package/src/components/chat-message-attachment-card/__stories__/types.ts +14 -0
  219. package/src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx +4 -0
  220. package/src/components/chat-message-attachment-card/chat-message-attachment-card.json +20 -0
  221. package/src/components/chat-message-attachment-card/chat-message-attachment-card.stories.tsx +266 -51
  222. package/src/components/chat-message-attachment-card/chat-message-attachment-card.tsx +37 -4
  223. package/src/components/chat-message-attachment-card/index.ts +6 -0
  224. package/src/components/chat-message-attachment-card/utils.ts +1 -0
  225. package/src/components/chat-message-response/__stories__/fixtures.ts +50 -0
  226. package/src/components/chat-message-response/chat-message-response.json +5 -0
  227. package/src/components/chat-message-response/chat-message-response.stories.tsx +135 -26
  228. package/src/components/chat-message-toolbar/chat-message-toolbar.json +21 -3
  229. package/src/components/chat-message-toolbar/chat-message-toolbar.stories.tsx +377 -6
  230. package/src/components/chat-message-toolbar/chat-message-toolbar.tsx +47 -12
  231. package/src/components/chat-message-toolbar/index.ts +4 -0
  232. package/src/components/chat-messages/__stories__/conversation-frame.tsx +25 -0
  233. package/src/components/chat-messages/__stories__/conversation-group.tsx +22 -0
  234. package/src/components/chat-messages/__stories__/fixtures.ts +70 -0
  235. package/src/components/chat-messages/__stories__/types.ts +5 -0
  236. package/src/components/chat-messages/chat-messages.json +30 -12
  237. package/src/components/chat-messages/chat-messages.stories.tsx +439 -212
  238. package/src/components/chat-messages/chat-messages.tsx +46 -3
  239. package/src/components/chat-notification-card/__stories__/fixtures.ts +38 -0
  240. package/src/components/chat-notification-card/__stories__/types.ts +13 -0
  241. package/src/components/chat-notification-card/chat-notification-card.json +52 -2
  242. package/src/components/chat-notification-card/chat-notification-card.stories.tsx +542 -62
  243. package/src/components/chat-notification-card/chat-notification-card.tsx +97 -6
  244. package/src/components/chat-notification-popup/__stories__/fixtures.ts +36 -0
  245. package/src/components/chat-notification-popup/__stories__/notification-item.tsx +93 -0
  246. package/src/components/chat-notification-popup/__stories__/types.ts +14 -0
  247. package/src/components/chat-notification-popup/chat-notification-popup.json +14 -1
  248. package/src/components/chat-notification-popup/chat-notification-popup.stories.tsx +467 -17
  249. package/src/components/chat-notification-popup/chat-notification-popup.tsx +18 -3
  250. package/src/components/chat-prompt-box/__stories__/fixtures.ts +16 -0
  251. package/src/components/chat-prompt-box/__stories__/types.ts +8 -0
  252. package/src/components/chat-prompt-box/chat-prompt-box.json +25 -2
  253. package/src/components/chat-prompt-box/chat-prompt-box.stories.tsx +535 -43
  254. package/src/components/chat-prompt-box/chat-prompt-box.tsx +73 -19
  255. package/src/components/chat-reply/chat-reply.json +10 -0
  256. package/src/components/chat-reply/chat-reply.stories.tsx +264 -21
  257. package/src/components/chat-reply/chat-reply.tsx +15 -0
  258. package/src/components/chat-reply/index.ts +10 -1
  259. package/src/components/chat-suggestion/__stories__/fixtures.ts +16 -0
  260. package/src/components/chat-suggestion/__tests__/chat-suggestion.spec.tsx +185 -0
  261. package/src/components/chat-suggestion/chat-suggestion.json +62 -20
  262. package/src/components/chat-suggestion/chat-suggestion.stories.tsx +542 -58
  263. package/src/components/chat-suggestion/chat-suggestion.tsx +154 -65
  264. package/src/components/chat-suggestion/index.ts +9 -0
  265. package/src/components/chat-thinking-process/__stories__/fixtures.ts +56 -0
  266. package/src/components/chat-thinking-process/chat-thinking-process.json +28 -3
  267. package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +354 -78
  268. package/src/components/chat-thinking-process/chat-thinking-process.tsx +55 -4
  269. package/src/components/chat-thread/__stories__/fixtures.ts +171 -0
  270. package/src/components/chat-thread/__stories__/scroll-position.ts +9 -0
  271. package/src/components/chat-thread/__stories__/snippets.ts +129 -0
  272. package/src/components/chat-thread/__stories__/thread-frame.tsx +22 -0
  273. package/src/components/chat-thread/__stories__/thread-turns.tsx +35 -0
  274. package/src/components/chat-thread/__stories__/types.ts +12 -0
  275. package/src/components/chat-thread/__stories__/use-turn-stream.ts +78 -0
  276. package/src/components/chat-thread/chat-thread.json +23 -3
  277. package/src/components/chat-thread/chat-thread.stories.tsx +804 -142
  278. package/src/components/chat-thread/chat-thread.tsx +64 -16
  279. package/src/components/index.ts +1 -3
  280. package/src/components/markdown-viewer/__stories__/fixtures.ts +67 -0
  281. package/src/components/markdown-viewer/markdown-viewer.json +7 -1
  282. package/src/components/markdown-viewer/markdown-viewer.stories.tsx +219 -50
  283. package/src/components/markdown-viewer/markdown-viewer.tsx +9 -0
  284. package/src/components/rich-text-area/__stories__/fixtures.ts +30 -0
  285. package/src/components/rich-text-area/__tests__/rich-text-area.spec.tsx +114 -0
  286. package/src/components/rich-text-area/plugins/controlled-value-plugin.tsx +20 -3
  287. package/src/components/rich-text-area/plugins/value-plugin.tsx +16 -3
  288. package/src/components/rich-text-area/rich-text-area.json +7 -4
  289. package/src/components/rich-text-area/rich-text-area.stories.tsx +597 -41
  290. package/src/components/rich-text-area/rich-text-area.tsx +27 -4
  291. package/src/components/rich-text-area/styled.tsx +11 -5
  292. package/src/components/rich-text-field/__stories__/fixtures.ts +29 -0
  293. package/src/components/rich-text-field/components/formatting-toolbar-plugin.tsx +10 -1
  294. package/src/components/rich-text-field/components/index.ts +8 -5
  295. package/src/components/rich-text-field/components/text-color-button.tsx +16 -2
  296. package/src/components/rich-text-field/rich-text-field.json +3 -1
  297. package/src/components/rich-text-field/rich-text-field.stories.tsx +452 -61
  298. package/src/components/rich-text-field/rich-text-field.tsx +23 -0
  299. package/src/components/topmenu/index.ts +1 -0
  300. package/src/components/topmenu/topmenu.json +107 -0
  301. package/src/components/topmenu/topmenu.stories.tsx +334 -0
  302. package/src/components/topmenu/topmenu.tsx +71 -0
  303. package/src/docs/agent.stories.tsx +16 -16
  304. package/src/docs/chat-panel.tsx +37 -32
  305. package/src/docs/chatbot-panel.tsx +11 -2
  306. package/src/docs/chatbot.mdx +17 -12
  307. package/src/docs/chatbot.stories.tsx +7 -8
  308. package/src/layouts/chat-card-list-layout/__stories__/fixtures.ts +112 -0
  309. package/src/layouts/chat-card-list-layout/__stories__/result-card.tsx +36 -0
  310. package/src/layouts/chat-card-list-layout/__stories__/types.ts +31 -0
  311. package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +14 -1
  312. package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +316 -84
  313. package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +11 -7
  314. package/src/layouts/chat-card-three-column-layout/__stories__/fixtures.ts +117 -0
  315. package/src/layouts/chat-card-three-column-layout/__stories__/resizable-chat-window.tsx +18 -0
  316. package/src/layouts/chat-card-three-column-layout/__stories__/stay-details.tsx +85 -0
  317. package/src/layouts/chat-card-three-column-layout/__stories__/stay-list.tsx +50 -0
  318. package/src/layouts/chat-card-three-column-layout/__stories__/stay-map.tsx +44 -0
  319. package/src/layouts/chat-card-three-column-layout/__stories__/stay-rooms.tsx +61 -0
  320. package/src/layouts/chat-card-three-column-layout/__stories__/types.ts +35 -0
  321. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +16 -0
  322. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +603 -182
  323. package/src/layouts/chat-card-two-column-layout/__stories__/connection-itinerary.tsx +51 -0
  324. package/src/layouts/chat-card-two-column-layout/__stories__/fixtures.ts +83 -0
  325. package/src/layouts/chat-card-two-column-layout/__stories__/route-map.tsx +24 -0
  326. package/src/layouts/chat-card-two-column-layout/__stories__/types.ts +15 -0
  327. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +13 -1
  328. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +368 -67
  329. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +11 -2
  330. package/dist/components/card-item-picker/card-item-picker-context.d.ts +0 -21
  331. package/dist/components/card-item-picker/card-item-picker-context.d.ts.map +0 -1
  332. package/dist/components/card-item-picker/card-item-picker-list.d.ts +0 -24
  333. package/dist/components/card-item-picker/card-item-picker-list.d.ts.map +0 -1
  334. package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts +0 -28
  335. package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts.map +0 -1
  336. package/dist/components/card-item-picker/card-item-picker-row.d.ts +0 -12
  337. package/dist/components/card-item-picker/card-item-picker-row.d.ts.map +0 -1
  338. package/dist/components/card-item-picker/card-item-picker.stories.d.ts +0 -19
  339. package/dist/components/card-item-picker/card-item-picker.stories.d.ts.map +0 -1
  340. package/dist/components/card-item-picker/index.d.ts +0 -9
  341. package/dist/components/card-item-picker/index.d.ts.map +0 -1
  342. package/dist/components/chat-message-history/chat-message-history.d.ts +0 -48
  343. package/dist/components/chat-message-history/chat-message-history.d.ts.map +0 -1
  344. package/dist/components/chat-message-history/chat-message-history.stories.d.ts +0 -7
  345. package/dist/components/chat-message-history/chat-message-history.stories.d.ts.map +0 -1
  346. package/dist/components/chat-message-history/index.d.ts +0 -2
  347. package/dist/components/chat-message-history/index.d.ts.map +0 -1
  348. package/dist/components/spinner/index.d.ts +0 -2
  349. package/dist/components/spinner/index.d.ts.map +0 -1
  350. package/dist/components/spinner/spinner.d.ts +0 -9
  351. package/dist/components/spinner/spinner.d.ts.map +0 -1
  352. package/dist/components/spinner/spinner.stories.d.ts +0 -8
  353. package/dist/components/spinner/spinner.stories.d.ts.map +0 -1
  354. package/src/components/card-item-picker/__tests__/card-item-picker.spec.tsx +0 -279
  355. package/src/components/card-item-picker/card-item-picker-context.tsx +0 -44
  356. package/src/components/card-item-picker/card-item-picker-list.tsx +0 -95
  357. package/src/components/card-item-picker/card-item-picker-row-parts.tsx +0 -96
  358. package/src/components/card-item-picker/card-item-picker-row.tsx +0 -109
  359. package/src/components/card-item-picker/card-item-picker.json +0 -147
  360. package/src/components/card-item-picker/card-item-picker.stories.tsx +0 -158
  361. package/src/components/card-item-picker/index.ts +0 -24
  362. package/src/components/chat-message-history/chat-message-history.json +0 -99
  363. package/src/components/chat-message-history/chat-message-history.stories.tsx +0 -136
  364. package/src/components/chat-message-history/chat-message-history.tsx +0 -277
  365. package/src/components/chat-message-history/index.ts +0 -13
  366. package/src/components/spinner/index.ts +0 -1
  367. package/src/components/spinner/spinner.json +0 -73
  368. package/src/components/spinner/spinner.stories.tsx +0 -41
  369. package/src/components/spinner/spinner.tsx +0 -32
@@ -1,70 +1,36 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { useEffect, useRef, useState } from 'react';
2
+ import { useState } from 'react';
3
+ import { expect, fn, waitFor } from 'storybook/test';
3
4
 
4
- import { ChatCardContainer } from '../chat-card-container';
5
+ import { Button, Typography } from '@swisper.ai/ui';
5
6
 
6
- import { ChatContainer, ChatContainerPrompt, ChatContainerWelcome } from './chat-container';
7
+ import { ParentBlock } from '../../__storybook__/parent-block';
8
+ import {
9
+ ChatCard,
10
+ ChatCardBody,
11
+ ChatCardContent,
12
+ ChatCardHeader,
13
+ ChatCardHeaderContent,
14
+ ChatCardTitle,
15
+ } from '../chat-card';
16
+ import { ChatCardContainer, type ChatCardContainerVariant } from '../chat-card-container';
17
+ import { ChatInput, ChatInputTextarea } from '../chat-input';
7
18
 
8
- const PUBLISHED_VARIABLES = [
9
- '--chat-window-width',
10
- '--chat-window-height',
11
- '--message-list-content-width',
12
- '--type-window-height',
13
- '--welcome-screen-box-height',
14
- ] as const;
15
-
16
- /**
17
- * Reads the variables off an element *inside* the container — custom properties
18
- * inherit, so this shows exactly what a real descendant resolves them to.
19
- *
20
- * Polls on rAF rather than subscribing: there is no change event for a custom
21
- * property, and this only exists to make the contract visible in Storybook.
22
- */
23
- function VariableReadout() {
24
- const ref = useRef<HTMLDListElement>(null);
25
- const [values, setValues] = useState<Record<string, string>>({});
26
-
27
- useEffect(() => {
28
- let frame = requestAnimationFrame(function read() {
29
- const element = ref.current;
30
-
31
- if (element) {
32
- const styles = getComputedStyle(element);
33
- const next: Record<string, string> = {};
34
-
35
- for (const name of PUBLISHED_VARIABLES) {
36
- next[name] = styles.getPropertyValue(name).trim() || '—';
37
- }
38
-
39
- setValues((current) =>
40
- PUBLISHED_VARIABLES.every((name) => current[name] === next[name]) ? current : next,
41
- );
42
- }
43
-
44
- frame = requestAnimationFrame(read);
45
- });
46
-
47
- return () => cancelAnimationFrame(frame);
48
- }, []);
49
-
50
- return (
51
- <dl
52
- ref={ref}
53
- className="m-message grid grid-cols-[auto_1fr] gap-x-16 gap-y-1 font-mono text-[12px]"
54
- >
55
- {PUBLISHED_VARIABLES.map((name) => (
56
- <div key={name} className="contents">
57
- <dt className="text-text-secondary">{name}</dt>
58
- <dd className="m-0">{values[name] ?? '—'}</dd>
59
- </div>
60
- ))}
61
- </dl>
62
- );
63
- }
19
+ import { ChatComposer } from './__stories__/chat-composer';
20
+ import { INBOX_EMAILS } from './__stories__/fixtures';
21
+ import { resolveLength } from './__stories__/measure';
22
+ import { VariableReadout } from './__stories__/variable-readout';
23
+ import {
24
+ ChatContainer,
25
+ ChatContainerPrompt,
26
+ ChatContainerWelcome,
27
+ type ChatContainerProps,
28
+ } from './chat-container';
64
29
 
65
30
  const meta: Meta<typeof ChatContainer> = {
66
- title: 'Chatbot/ChatContainer',
31
+ title: 'Chat/ChatContainer',
67
32
  component: ChatContainer,
33
+ subcomponents: { ChatContainerWelcome, ChatContainerPrompt },
68
34
  tags: ['autodocs'],
69
35
  parameters: { layout: 'padded' },
70
36
  argTypes: {
@@ -103,77 +69,543 @@ const meta: Meta<typeof ChatContainer> = {
103
69
  export default meta;
104
70
  type Story = StoryObj<typeof ChatContainer>;
105
71
 
72
+ // The reading column: message text reads the width the container publishes, like the cards do.
73
+ const readingColumnClassName =
74
+ 'mx-auto flex w-full max-w-(--message-list-content-width) flex-col gap-16 px-8';
75
+
76
+ const questionClassName = 'max-w-4/5 self-end rounded-sm bg-paper-elevation-1 px-12 py-8';
77
+
78
+ // The composer sits in the reading column too, so it lines up with the messages above it.
79
+ const promptClassName = 'mx-auto w-full max-w-(--message-list-content-width) px-8 pb-16';
80
+
106
81
  /**
107
- * Drag the dashed wrapper's right edge. `--chat-window-width` tracks the measured box,
108
- * and `--message-list-content-width` is clamped by `min()` — it stops at 736px when
109
- * the window is wider, and follows the window when it is narrower.
82
+ * A chat window with its message list, a result card and the composer. Drag the dashed
83
+ * wrapper's right edge: `--chat-window-width` tracks the measured box, and
84
+ * `--message-list-content-width` stops at 736px in a wide window and follows a narrow one.
110
85
  */
111
86
  export const Default: Story = {
112
- render: () => (
113
- <div className="resize-x overflow-auto w-[900px] min-w-[320px] max-w-full border border-dashed border-steel-700">
114
- <ChatContainer className="h-[420px]">
87
+ args: { className: 'h-105', 'aria-label': 'Chat' },
88
+ render: (args) => (
89
+ <div className="w-225 max-w-full min-w-80 resize-x overflow-auto border border-dashed border-component-divider">
90
+ <ChatContainer {...args}>
115
91
  <VariableReadout />
116
92
 
117
- <div className="flex-1 min-h-0 overflow-auto">
118
- <ChatCardContainer variant="fixed">
119
- <div className="rounded-[12px] bg-steel-900 p-16">
120
- A <code>fixed</code> card, sized against the variables above.
121
- </div>
93
+ <div role="log" aria-label="Messages" className="min-h-0 flex-1 overflow-y-auto py-16">
94
+ <div className={readingColumnClassName}>
95
+ <Typography className={questionClassName}>
96
+ When is the office move, and what do I need to do before it?
97
+ </Typography>
98
+ <Typography className="text-text-secondary">
99
+ The move is on Friday 16 October. Pack your desk by Thursday afternoon; the movers
100
+ arrive at 08:00.
101
+ </Typography>
102
+ </div>
103
+
104
+ <ChatCardContainer variant="fixed" className="mt-16">
105
+ <ChatCard fullWidth>
106
+ <ChatCardHeader>
107
+ <ChatCardHeaderContent>
108
+ <ChatCardTitle>Reminder</ChatCardTitle>
109
+ </ChatCardHeaderContent>
110
+ </ChatCardHeader>
111
+ <ChatCardBody>
112
+ <ChatCardContent>Pack up my desk · Thursday 15 October, 15:00</ChatCardContent>
113
+ </ChatCardBody>
114
+ </ChatCard>
122
115
  </ChatCardContainer>
123
116
  </div>
117
+
118
+ <ChatContainerPrompt className={promptClassName}>
119
+ <ChatComposer />
120
+ </ChatContainerPrompt>
124
121
  </ChatContainer>
125
122
  </div>
126
123
  ),
127
124
  };
128
125
 
129
- /**
130
- * Proves the slot round-trip: a slot measures itself and the height lands on the
131
- * *container*, where siblings can read it.
132
- *
133
- * Drag the textarea taller and watch `--type-window-height` follow. Toggle the welcome
134
- * box off and `--welcome-screen-box-height` returns to `unset` rather than leaving a
135
- * stale height behind for the message list to reserve space for.
136
- */
137
- export const MeasuredSlots: Story = {
138
- render: function MeasuredSlotsStory() {
139
- const [hasWelcome, setHasWelcome] = useState(true);
126
+ /** Sets the dashed wrapper to a width the viewport can't cap, so the test runs the same at any size. */
127
+ function resizeChatWindow(region: HTMLElement, width: number) {
128
+ const wrapper = region.parentElement;
140
129
 
141
- return (
142
- <div className="w-[900px] max-w-full border border-dashed border-steel-700">
143
- <ChatContainer className="h-[520px]">
144
- <VariableReadout />
130
+ if (wrapper) {
131
+ wrapper.style.maxWidth = 'none';
132
+ wrapper.style.width = `${width}px`;
133
+ }
134
+ }
145
135
 
146
- <button
147
- type="button"
148
- className="m-message w-fit rounded-[8px] bg-steel-900 px-16 py-8 text-left"
149
- onClick={() => setHasWelcome((current) => !current)}
150
- >
151
- {hasWelcome ? 'Unmount' : 'Mount'} welcome box
152
- </button>
136
+ /** The window variables follow the measured box, and the reading column is clamped to the window. */
137
+ export const DefaultTracksWindow: Story = {
138
+ ...Default,
139
+ tags: ['e2e', '!autodocs'],
140
+ play: async ({ canvas, step }) => {
141
+ const region = canvas.getByRole('region', { name: 'Chat' });
142
+ const chatArea = resolveLength(region, 'var(--spacing-chat-area)');
143
+
144
+ await step('Carries its slot name', async () => {
145
+ await expect(region).toHaveAttribute('data-slot', 'chat-container');
146
+ });
153
147
 
154
- {hasWelcome ? (
155
- <ChatContainerWelcome className="m-message rounded-[12px] bg-steel-900 p-16">
156
- Welcome box — its height is published as --welcome-screen-box-height.
148
+ await step('A wide window publishes its size and stops the column at the token', async () => {
149
+ resizeChatWindow(region, 900);
150
+ await waitFor(() =>
151
+ expect(region.style.getPropertyValue('--chat-window-width')).toBe(
152
+ `${region.offsetWidth}px`,
153
+ ),
154
+ );
155
+ await expect(region.offsetWidth).toBeGreaterThan(chatArea);
156
+ await expect(region.style.getPropertyValue('--chat-window-height')).toBe(
157
+ `${region.offsetHeight}px`,
158
+ );
159
+ await expect(resolveLength(region, 'var(--message-list-content-width)')).toBe(chatArea);
160
+ });
161
+
162
+ await step('A window narrower than the column pulls the column in with it', async () => {
163
+ resizeChatWindow(region, 400);
164
+ await waitFor(() =>
165
+ expect(region.style.getPropertyValue('--chat-window-width')).toBe(
166
+ `${region.offsetWidth}px`,
167
+ ),
168
+ );
169
+ await expect(region.offsetWidth).toBeLessThan(chatArea);
170
+ await expect(resolveLength(region, 'var(--message-list-content-width)')).toBe(
171
+ region.offsetWidth,
172
+ );
173
+ });
174
+ },
175
+ };
176
+
177
+ /** `contentWidth` sets the reading column, and the window width still caps it. */
178
+ export const DefaultContentWidth: Story = {
179
+ ...Default,
180
+ tags: ['e2e', '!autodocs'],
181
+ args: { ...Default.args, contentWidth: '30rem' },
182
+ play: async ({ canvas, step }) => {
183
+ const region = canvas.getByRole('region', { name: 'Chat' });
184
+ const contentWidth = resolveLength(region, '30rem');
185
+
186
+ // `resolveLength` adds a probe to the DOM, which would re-trigger `waitFor`; wait on the
187
+ // published width first, then resolve the column once.
188
+ await step('A wide window gives the column its own width', async () => {
189
+ resizeChatWindow(region, 900);
190
+ await waitFor(() =>
191
+ expect(region.style.getPropertyValue('--chat-window-width')).toBe(
192
+ `${region.offsetWidth}px`,
193
+ ),
194
+ );
195
+ await expect(region.offsetWidth).toBeGreaterThan(contentWidth);
196
+ await expect(resolveLength(region, 'var(--message-list-content-width)')).toBe(contentWidth);
197
+ });
198
+
199
+ await step('A narrower window caps it', async () => {
200
+ resizeChatWindow(region, 400);
201
+ await waitFor(() =>
202
+ expect(region.style.getPropertyValue('--chat-window-width')).toBe(
203
+ `${region.offsetWidth}px`,
204
+ ),
205
+ );
206
+ await expect(region.offsetWidth).toBeLessThan(contentWidth);
207
+ await expect(resolveLength(region, 'var(--message-list-content-width)')).toBe(
208
+ region.offsetWidth,
209
+ );
210
+ });
211
+ },
212
+ };
213
+
214
+ interface NewChatProps {
215
+ greeting: string;
216
+ onSend: (message: string) => void;
217
+ }
218
+
219
+ function NewChat({ greeting, onSend }: NewChatProps) {
220
+ const [questions, setQuestions] = useState<string[]>([]);
221
+ // The welcome box only exists on an empty chat: the first message unmounts it.
222
+ const isEmpty = questions.length === 0;
223
+
224
+ const handleSend = (message: string) => {
225
+ setQuestions((current) => [...current, message]);
226
+ onSend(message);
227
+ };
228
+
229
+ return (
230
+ <div className="flex w-225 max-w-full flex-col gap-8">
231
+ <Button
232
+ variant="tertiary"
233
+ size="sm"
234
+ className="self-start"
235
+ isDisabled={isEmpty}
236
+ onClick={() => setQuestions([])}
237
+ >
238
+ New chat
239
+ </Button>
240
+
241
+ <div className="border border-dashed border-component-divider">
242
+ <ChatContainer aria-label="Chat" className="h-130">
243
+ <VariableReadout />
244
+
245
+ {isEmpty ? (
246
+ <ChatContainerWelcome className="px-message py-16">
247
+ <Typography variant="title-small" className="text-text-secondary">
248
+ {greeting}
249
+ </Typography>
157
250
  </ChatContainerWelcome>
158
251
  ) : null}
159
252
 
160
- {/* Sizes itself from a sibling slot's variable, which is the whole point. */}
253
+ {/* A sibling of the composer, sized from the height the prompt slot publishes. */}
161
254
  <div
162
- className="m-message rounded-[12px] border border-steel-700 p-8 text-[12px] text-text-secondary"
163
- style={{ minHeight: 'var(--type-window-height)' }}
255
+ role="log"
256
+ aria-label="Messages"
257
+ className="min-h-0 flex-1 overflow-y-auto pt-16 pb-(--type-window-height)"
164
258
  >
165
- This box mirrors the composer height via min-height: var(--type-window-height).
259
+ <div className={readingColumnClassName}>
260
+ {questions.map((question, index) => (
261
+ // Messages are only ever appended, so the position keeps the key stable.
262
+ <Typography key={`${index}-${question}`} className={questionClassName}>
263
+ {question}
264
+ </Typography>
265
+ ))}
266
+ </div>
166
267
  </div>
167
268
 
168
- <ChatContainerPrompt className="mt-auto m-message">
169
- <textarea
170
- className="w-full resize-y rounded-[12px] bg-steel-900 p-16"
171
- defaultValue="Drag my bottom edge to grow the composer."
172
- rows={2}
173
- />
269
+ {/* Floats over the list, so the list has to reserve its height. */}
270
+ <ChatContainerPrompt className={`absolute inset-x-0 bottom-0 ${promptClassName}`}>
271
+ <ChatComposer onSend={handleSend} />
174
272
  </ChatContainerPrompt>
175
273
  </ChatContainer>
176
274
  </div>
275
+ </div>
276
+ );
277
+ }
278
+
279
+ type NewChatStory = StoryObj<typeof NewChat>;
280
+
281
+ /**
282
+ * The slot round-trip on a new chat: the welcome box and the composer measure themselves and
283
+ * their heights land on the container, where the message list reads them. Type a few lines and
284
+ * `--type-window-height` follows the composer; send the message and the welcome box unmounts,
285
+ * returning `--welcome-screen-box-height` to `unset`.
286
+ */
287
+ export const MeasuredSlots: NewChatStory = {
288
+ args: {
289
+ greeting: 'Good morning, Mara. What should we get done today?',
290
+ onSend: fn(),
291
+ },
292
+ argTypes: {
293
+ greeting: { control: 'text', description: 'Text of the box in `ChatContainerWelcome`.' },
294
+ onSend: { description: 'Called with each message the composer sends.' },
295
+ },
296
+ parameters: { controls: { include: ['greeting', 'onSend'] } },
297
+ render: (args) => <NewChat {...args} />,
298
+ };
299
+
300
+ /** Grows the composer and sends the first message, checking both slot heights on the container. */
301
+ export const MeasuredSlotsRoundTrip: NewChatStory = {
302
+ ...MeasuredSlots,
303
+ tags: ['e2e', '!autodocs'],
304
+ args: { ...MeasuredSlots.args, onSend: fn() },
305
+ play: async ({ args, canvas, canvasElement, userEvent, step }) => {
306
+ const region = canvas.getByRole('region', { name: 'Chat' });
307
+ const textbox = canvas.getByRole('textbox', { name: 'Chat input' });
308
+ // The slots are layout wrappers with no role to query by; `data-slot` is their documented name.
309
+ const prompt = canvasElement.querySelector<HTMLElement>('[data-slot="chat-container-prompt"]');
310
+ const promptHeight = () => `${prompt?.offsetHeight ?? 0}px`;
311
+ const slotVariable = (name: string) => region.style.getPropertyValue(name);
312
+
313
+ await step('Both slots report their height to the container', async () => {
314
+ const welcome = canvasElement.querySelector<HTMLElement>(
315
+ '[data-slot="chat-container-welcome"]',
316
+ );
317
+
318
+ await expect(prompt).toBeInTheDocument();
319
+ await expect(welcome).toBeInTheDocument();
320
+ await waitFor(() => expect(slotVariable('--type-window-height')).toBe(promptHeight()));
321
+ await expect(slotVariable('--welcome-screen-box-height')).toBe(
322
+ `${welcome?.offsetHeight ?? 0}px`,
323
+ );
324
+ });
325
+
326
+ const oneLineHeight = prompt?.offsetHeight ?? 0;
327
+
328
+ await step('The composer height follows the text', async () => {
329
+ await userEvent.click(textbox);
330
+ await userEvent.keyboard('Move my 3pm to Friday');
331
+ await userEvent.keyboard('{Shift>}{Enter}{/Shift}and tell the facilities team');
332
+ await userEvent.keyboard('{Shift>}{Enter}{/Shift}before the movers arrive');
333
+ await waitFor(() => expect(prompt?.offsetHeight).toBeGreaterThan(oneLineHeight));
334
+ await waitFor(() => expect(slotVariable('--type-window-height')).toBe(promptHeight()));
335
+ });
336
+
337
+ await step('The message list reserves the composer height', async () => {
338
+ const list = canvas.getByRole('log', { name: 'Messages' });
339
+
340
+ await waitFor(() => expect(getComputedStyle(list).paddingBottom).toBe(promptHeight()));
341
+ });
342
+
343
+ await step(
344
+ 'Sending the first message unmounts the welcome box and clears its height',
345
+ async () => {
346
+ await userEvent.keyboard('{Enter}');
347
+ await expect(args.onSend).toHaveBeenCalledTimes(1);
348
+ await waitFor(() =>
349
+ expect(canvasElement.querySelector('[data-slot="chat-container-welcome"]')).toBeNull(),
350
+ );
351
+ await waitFor(() => expect(slotVariable('--welcome-screen-box-height')).toBe('unset'));
352
+ await waitFor(() => expect(prompt?.offsetHeight).toBe(oneLineHeight));
353
+ await waitFor(() => expect(slotVariable('--type-window-height')).toBe(promptHeight()));
354
+ },
177
355
  );
356
+
357
+ await step('A new chat mounts the welcome box and its height again', async () => {
358
+ await userEvent.click(canvas.getByRole('button', { name: 'New chat' }));
359
+ await expect(canvas.getByText(args.greeting)).toBeVisible();
360
+ await waitFor(() => expect(slotVariable('--welcome-screen-box-height')).toMatch(/^\d+px$/));
361
+ });
362
+ },
363
+ };
364
+
365
+ /** The container in each place it goes: a chat page, the chat side of a split pane and a full-screen chat. */
366
+ export const Examples: Story = {
367
+ parameters: { controls: { disable: true } },
368
+ render: () => (
369
+ <div className="flex flex-col gap-24">
370
+ <ParentBlock parent="chat page">
371
+ <div
372
+ role="group"
373
+ aria-label="Chat page"
374
+ className="flex h-80 flex-col rounded-sm border border-component-divider"
375
+ >
376
+ <header className="shrink-0 border-b border-component-divider px-16 py-8">
377
+ <Typography variant="body-small-high" fontWeight="medium">
378
+ Office move
379
+ </Typography>
380
+ </header>
381
+ <div className="min-h-0 flex-1">
382
+ <ChatContainer aria-label="Office move chat">
383
+ <div
384
+ role="log"
385
+ aria-label="Office move messages"
386
+ className="min-h-0 flex-1 overflow-y-auto py-16"
387
+ >
388
+ <div className={readingColumnClassName}>
389
+ <Typography className={questionClassName}>Move my 3pm to Friday</Typography>
390
+ <Typography className="text-text-secondary">
391
+ Your 3pm with the facilities team is now on Friday at 10:00. Everyone has been
392
+ notified.
393
+ </Typography>
394
+ </div>
395
+ </div>
396
+ <ChatContainerPrompt className={promptClassName}>
397
+ <ChatComposer />
398
+ </ChatContainerPrompt>
399
+ </ChatContainer>
400
+ </div>
401
+ </div>
402
+ </ParentBlock>
403
+
404
+ <ParentBlock parent="split pane">
405
+ <div
406
+ role="group"
407
+ aria-label="Productivity dashboard"
408
+ className="flex h-80 gap-16 rounded-sm border border-component-divider p-16"
409
+ >
410
+ <aside
411
+ aria-label="Inbox"
412
+ className="flex w-60 shrink-0 flex-col gap-8 rounded-sm border border-component-divider p-12"
413
+ >
414
+ <Typography
415
+ variant="body-small-high"
416
+ fontWeight="semibold"
417
+ className="text-text-secondary"
418
+ >
419
+ Productivity dashboard
420
+ </Typography>
421
+ <ul className="flex flex-col gap-8">
422
+ {INBOX_EMAILS.map((email) => (
423
+ <li key={email.id} className="flex min-w-0 flex-col">
424
+ <span className="flex items-baseline justify-between gap-8">
425
+ <Typography variant="caption-md" className="truncate">
426
+ {email.sender}
427
+ </Typography>
428
+ <Typography variant="caption-md" className="shrink-0 text-text-tertiary">
429
+ {email.receivedAt}
430
+ </Typography>
431
+ </span>
432
+ <Typography variant="caption-md" className="truncate text-text-secondary">
433
+ {email.subject}
434
+ </Typography>
435
+ </li>
436
+ ))}
437
+ </ul>
438
+ </aside>
439
+
440
+ {/* The pane is narrower than the reading column, so the column follows the pane. */}
441
+ <div className="min-w-0 flex-1 overflow-hidden">
442
+ <ChatContainer aria-label="Chat about the selected email">
443
+ <div
444
+ role="log"
445
+ aria-label="Email chat messages"
446
+ className="min-h-0 flex-1 overflow-y-auto pb-16"
447
+ >
448
+ <div className={readingColumnClassName}>
449
+ <Typography className="text-text-secondary">
450
+ The facilities team confirms the office move for Friday 16 October and asks you
451
+ to pack your desk by Thursday afternoon.
452
+ </Typography>
453
+ </div>
454
+ </div>
455
+ <ChatContainerPrompt className={promptClassName}>
456
+ <ChatComposer placeholder="Reply or ask about this email" />
457
+ </ChatContainerPrompt>
458
+ </ChatContainer>
459
+ </div>
460
+ </div>
461
+ </ParentBlock>
462
+
463
+ <ParentBlock parent="full-screen chat">
464
+ <div className="h-80 rounded-sm border border-component-divider">
465
+ {/* With asChild the page's own landmark is the container, so nothing wraps the chat. */}
466
+ <ChatContainer asChild>
467
+ <main aria-label="New chat">
468
+ <ChatContainerWelcome className="flex flex-1 items-center justify-center px-message">
469
+ <Typography variant="title-small" className="text-text-secondary">
470
+ Good morning, Mara. What should we get done today?
471
+ </Typography>
472
+ </ChatContainerWelcome>
473
+ <ChatContainerPrompt className={promptClassName}>
474
+ <ChatComposer />
475
+ </ChatContainerPrompt>
476
+ </main>
477
+ </ChatContainer>
478
+ </div>
479
+ </ParentBlock>
480
+ </div>
481
+ ),
482
+ };
483
+
484
+ // ChatInput ships unstyled; this is the bordered field a consumer makes of it.
485
+ const chatInputClassName =
486
+ 'max-h-30 min-h-40 w-full overflow-y-auto rounded-md border border-form-fields-border bg-paper-elevation-1 px-12 py-6 data-[focused=true]:border-primary-main';
487
+
488
+ interface ChatContainerPlaygroundProps extends Omit<ChatContainerProps, 'children'> {
489
+ hasWelcome: boolean;
490
+ greeting: string;
491
+ hasCard: boolean;
492
+ variant: ChatCardContainerVariant;
493
+ hasPrompt: boolean;
494
+ composer: 'ChatPromptBox' | 'ChatInput';
495
+ onSend: (message: string) => void;
496
+ }
497
+
498
+ function ChatContainerPlayground({
499
+ asChild,
500
+ hasWelcome,
501
+ greeting,
502
+ hasCard,
503
+ variant,
504
+ hasPrompt,
505
+ composer,
506
+ onSend,
507
+ ...rest
508
+ }: ChatContainerPlaygroundProps) {
509
+ const content = (
510
+ <>
511
+ <VariableReadout />
512
+
513
+ {hasWelcome && (
514
+ <ChatContainerWelcome className="px-message pb-16">
515
+ <Typography variant="title-small" className="text-text-secondary">
516
+ {greeting}
517
+ </Typography>
518
+ </ChatContainerWelcome>
519
+ )}
520
+
521
+ <div role="log" aria-label="Messages" className="min-h-0 flex-1 overflow-y-auto pb-16">
522
+ <div className={readingColumnClassName}>
523
+ <Typography className={questionClassName}>
524
+ When is the office move, and what do I need to do before it?
525
+ </Typography>
526
+ <Typography className="text-text-secondary">
527
+ The move is on Friday 16 October. Pack your desk by Thursday afternoon; the movers
528
+ arrive at 08:00.
529
+ </Typography>
530
+ </div>
531
+
532
+ {hasCard && (
533
+ <ChatCardContainer variant={variant} className="mt-16">
534
+ <ChatCard fullWidth>
535
+ <ChatCardHeader>
536
+ <ChatCardHeaderContent>
537
+ <ChatCardTitle>Reminder</ChatCardTitle>
538
+ </ChatCardHeaderContent>
539
+ </ChatCardHeader>
540
+ <ChatCardBody>
541
+ <ChatCardContent>Pack up my desk · Thursday 15 October, 15:00</ChatCardContent>
542
+ </ChatCardBody>
543
+ </ChatCard>
544
+ </ChatCardContainer>
545
+ )}
546
+ </div>
547
+
548
+ {hasPrompt && (
549
+ <ChatContainerPrompt className={promptClassName}>
550
+ {composer === 'ChatPromptBox' ? (
551
+ <ChatComposer onSend={onSend} />
552
+ ) : (
553
+ <ChatInput className={chatInputClassName}>
554
+ <ChatInputTextarea autoFocus={false} placeholder="How can I help?" />
555
+ </ChatInput>
556
+ )}
557
+ </ChatContainerPrompt>
558
+ )}
559
+ </>
560
+ );
561
+
562
+ return (
563
+ <div className="w-225 max-w-full min-w-80 resize-x overflow-auto border border-dashed border-component-divider">
564
+ <ChatContainer asChild={asChild} {...rest}>
565
+ {asChild ? <main>{content}</main> : content}
566
+ </ChatContainer>
567
+ </div>
568
+ );
569
+ }
570
+
571
+ /** Every slot and child at once in a resizable window, with each prop and part on the Controls panel. */
572
+ export const Playground: StoryObj<typeof ChatContainerPlayground> = {
573
+ tags: ['!autodocs'],
574
+ args: {
575
+ contentWidth: 'var(--spacing-chat-area)',
576
+ className: 'h-140',
577
+ asChild: false,
578
+ hasWelcome: true,
579
+ greeting: 'Good morning, Mara. What should we get done today?',
580
+ hasCard: true,
581
+ variant: 'fixed',
582
+ hasPrompt: true,
583
+ composer: 'ChatPromptBox',
584
+ onSend: fn(),
585
+ },
586
+ argTypes: {
587
+ asChild: {
588
+ control: 'boolean',
589
+ description: 'Renders a `<main>` as the container root instead of the `<section>`.',
590
+ },
591
+ hasWelcome: { control: 'boolean', description: 'Renders `ChatContainerWelcome`.' },
592
+ greeting: { control: 'text', description: 'Text of the box in `ChatContainerWelcome`.' },
593
+ hasCard: {
594
+ control: 'boolean',
595
+ description: 'Renders a card in a `ChatCardContainer` in the message list.',
596
+ },
597
+ variant: {
598
+ control: 'radio',
599
+ options: ['fixed', 'fluid', 'full'],
600
+ description: '`variant` of `ChatCardContainer`: how the card sizes against the window.',
601
+ },
602
+ hasPrompt: { control: 'boolean', description: 'Renders `ChatContainerPrompt`.' },
603
+ composer: {
604
+ control: 'radio',
605
+ options: ['ChatPromptBox', 'ChatInput'],
606
+ description: 'What `ChatContainerPrompt` holds: the styled prompt box or the bare input.',
607
+ },
608
+ onSend: { description: 'Called with each message the prompt box sends.' },
178
609
  },
610
+ render: (args) => <ChatContainerPlayground {...args} />,
179
611
  };