@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
@@ -36,6 +36,7 @@ export interface ChatListContextValue {
36
36
 
37
37
  const ChatListContext = createContext<ChatListContextValue | null>(null);
38
38
 
39
+ /** The list state `ChatList` shares with its parts. Throws when called outside a `ChatList`. */
39
40
  export function useChatListContext() {
40
41
  const context = useContext(ChatListContext);
41
42
 
@@ -47,19 +48,33 @@ export function useChatListContext() {
47
48
  }
48
49
 
49
50
  export interface ChatListProps {
51
+ /** The list parts: `ChatListItems`, `ChatListSkeleton`, `ChatListLoadMore`, `ChatListEmptyState` and `ChatListError`. */
50
52
  children: ReactNode;
51
53
  className?: string;
54
+ /** Number of rows already loaded; `ChatListItems` renders this many. */
52
55
  loadedCount: number;
56
+ /** Total rows on the server, when known; used to work out `hasMore`. */
53
57
  totalCount?: number;
58
+ /** Whether another page can be loaded. Defaults to `loadedCount < totalCount`, and to false without `totalCount`. */
54
59
  hasMore?: boolean;
60
+ /** The first page is loading: with no rows loaded, `ChatListSkeleton` shows in place of the rows. */
55
61
  isLoading?: boolean;
62
+ /** The next page is loading: stops `onLoadMore` from firing again until it is false. */
56
63
  isLoadingMore?: boolean;
64
+ /** Loading failed: with no rows loaded, `ChatListError` shows. */
57
65
  hasError?: boolean;
66
+ /** Called when the last rendered row reaches the end of the loaded rows while `hasMore` is true. */
58
67
  onLoadMore?: () => void;
68
+ /** Returns a stable key for the row at an index, e.g. the chat id. */
59
69
  getItemKey: (index: number) => string | number;
70
+ /** Accessible name of the navigation landmark. Defaults to "Chat list". */
60
71
  'aria-label'?: string;
61
72
  }
62
73
 
74
+ /**
75
+ * Root of the conversation list: a `role="navigation"` landmark that holds the fetch state and
76
+ * shares it with its parts. Give it a bounded height; `ChatListItems` scrolls inside it.
77
+ */
63
78
  export function ChatList({
64
79
  children,
65
80
  className,
@@ -152,6 +167,8 @@ export interface ChatListSkeletonProps {
152
167
  /** Number of default rows, used only when `children` is not passed. Rows past the list's height are clipped. */
153
168
  rows?: number;
154
169
  className?: string;
170
+ /** Classes for each default row; merged after its defaults. Not used when `children` is passed. */
171
+ rowClassName?: string;
155
172
  }
156
173
 
157
174
  // Title and preview widths alternate per row, so the placeholder reads as a list of chats.
@@ -163,7 +180,12 @@ const PREVIEW_WIDTHS = ['w-full', 'w-4/5'] as const;
163
180
  * loaded, in the space `ChatListItems` will fill. It is a `role="status"` region named
164
181
  * "Loading chats"; its rows are `Skeleton`s from `@swisper.ai/ui`, which are `aria-hidden`.
165
182
  */
166
- export function ChatListSkeleton({ children, rows = 16, className }: ChatListSkeletonProps) {
183
+ export function ChatListSkeleton({
184
+ children,
185
+ rows = 16,
186
+ className,
187
+ rowClassName,
188
+ }: ChatListSkeletonProps) {
167
189
  const { isLoading, loadedCount, skeletonContainer } = useChatListContext();
168
190
 
169
191
  if (!(isLoading && loadedCount === 0) || !skeletonContainer) {
@@ -184,7 +206,7 @@ export function ChatListSkeleton({ children, rows = 16, className }: ChatListSke
184
206
  <div
185
207
  key={index}
186
208
  data-slot="chat-list-skeleton-row"
187
- className="flex shrink-0 flex-col gap-4 px-12 py-8"
209
+ className={cn('flex shrink-0 flex-col gap-4 px-12 py-8', rowClassName)}
188
210
  >
189
211
  <div className="flex h-20 items-center">
190
212
  <Skeleton className={cn('h-12', TITLE_WIDTHS[index % 2])} />
@@ -204,6 +226,10 @@ export interface ChatListEmptyStateProps {
204
226
  className?: string;
205
227
  }
206
228
 
229
+ /**
230
+ * What the list says when it has no chats. Renders only when nothing is loaded, nothing is loading
231
+ * and there is no error, as a `role="status"` region named "No chats".
232
+ */
207
233
  export function ChatListEmptyState({ children, className }: ChatListEmptyStateProps) {
208
234
  const { isEmpty } = useChatListContext();
209
235
 
@@ -226,12 +252,25 @@ export function ChatListEmptyState({ children, className }: ChatListEmptyStatePr
226
252
  }
227
253
 
228
254
  export interface ChatListErrorProps {
255
+ /** Your own error content. Leave it out to get the `error` message, or "An error occurred". */
229
256
  children?: ReactNode;
257
+ /** The failure to show when `children` is not passed: an `Error`'s message, or the string itself. */
230
258
  error?: Error | string;
231
259
  className?: string;
260
+ /** Classes for the default message; merged after its defaults. Not used when `children` is passed. */
261
+ messageClassName?: string;
232
262
  }
233
263
 
234
- export function ChatListError({ children, error, className }: ChatListErrorProps) {
264
+ /**
265
+ * What the list says when the first page fails. Renders only while `hasError` is true and no chats
266
+ * are loaded, as a `role="alert"` region named "Error loading chats".
267
+ */
268
+ export function ChatListError({
269
+ children,
270
+ error,
271
+ className,
272
+ messageClassName,
273
+ }: ChatListErrorProps) {
235
274
  const { hasError, loadedCount } = useChatListContext();
236
275
 
237
276
  if (!(hasError && loadedCount === 0)) {
@@ -248,7 +287,10 @@ export function ChatListError({ children, error, className }: ChatListErrorProps
248
287
  className={cn('flex flex-1 items-center justify-center', className)}
249
288
  >
250
289
  {children || (
251
- <div className="text-text-error-main">
290
+ <div
291
+ data-slot="chat-list-error-message"
292
+ className={cn('text-text-error-main', messageClassName)}
293
+ >
252
294
  {error instanceof Error ? error.message : error || 'An error occurred'}
253
295
  </div>
254
296
  )}
@@ -257,9 +299,14 @@ export function ChatListError({ children, error, className }: ChatListErrorProps
257
299
  }
258
300
 
259
301
  export interface ChatListLoadMoreProps {
302
+ /** Content of the load-more row, e.g. "Loading more…" or a few skeleton rows. */
260
303
  children?: ReactNode;
261
304
  }
262
305
 
306
+ /**
307
+ * Registers its children as the content of the row `ChatListItems` appends while `hasMore` is true.
308
+ * It renders nothing where it is placed.
309
+ */
263
310
  export function ChatListLoadMore({ children }: ChatListLoadMoreProps) {
264
311
  const { loadMoreContentRef, bumpLoadMore } = useChatListContext();
265
312
 
@@ -0,0 +1,53 @@
1
+ import type { Markdown } from '../../../types';
2
+
3
+ export const QUESTION = 'What were my biggest expenses this month?';
4
+
5
+ /** The longest kind of question people send: context, a constraint and two asks in one message. */
6
+ export const LONG_QUESTION =
7
+ "I'm trying to work out why May cost so much more than April. Can you go through every card and account transaction for both months, leave out rent and the SBB travelcard because those are the same every month, group what's left by category, and tell me which categories went up by more than CHF 50? If dining is one of them, list the five most expensive restaurant visits with their dates as well.";
8
+
9
+ export const ANSWER: Markdown = [
10
+ 'Your three biggest expenses in May:',
11
+ '',
12
+ '1. **Rent** – CHF 2,150.00 on 1 May',
13
+ '2. **Migros** – CHF 412.30 across 9 purchases',
14
+ '3. **SBB GA travelcard** – CHF 340.00 on 3 May',
15
+ ].join('\n');
16
+
17
+ export const ANSWER_TIME = '09:41';
18
+
19
+ /** Tool steps the assistant ran before answering, listed in the thinking process. */
20
+ export const TOOL_STEPS = ['Searching transactions for May', 'Sorting by amount'];
21
+
22
+ export const FOLLOW_UP_QUESTION = 'Break down my spending by category.';
23
+
24
+ export const FOLLOW_UP_ANSWER: Markdown = [
25
+ 'Here is where your money went in May, excluding rent:',
26
+ '',
27
+ '- **Groceries** – CHF 412.30',
28
+ '- **Dining** – CHF 286.15',
29
+ '- **Transport** – CHF 154.00',
30
+ '- **Subscriptions** – CHF 89.90',
31
+ '',
32
+ 'Dining is 18% above your three-month average. Everything else is in line with usual.',
33
+ ].join('\n');
34
+
35
+ export const ATTACHMENT_QUESTION = 'Does this statement match what you have for May?';
36
+
37
+ export const ATTACHMENT_NAME = 'Account_statement_May_2026.pdf';
38
+
39
+ /** One turn of an agent run: tool calls and the text between them, in the order they happened. */
40
+ export const AGENT_PROMPT = 'Find the subscriptions I no longer use and draft the cancellations.';
41
+
42
+ export const AGENT_SEARCH_STEPS = [
43
+ 'Searching recurring payments',
44
+ 'Matching merchants to subscriptions',
45
+ ];
46
+
47
+ export const AGENT_FINDINGS: Markdown =
48
+ "You have four active subscriptions, CHF 89.90 a month in total. You haven't opened **Tamedia digital** in 60 days.";
49
+
50
+ export const AGENT_DRAFT_STEPS = ['Reading the Tamedia cancellation terms', 'Drafting the letter'];
51
+
52
+ export const AGENT_RESULT: Markdown =
53
+ 'The cancellation letter for Tamedia digital is ready to review. Cancelling it saves CHF 624.60 a year.';
@@ -0,0 +1,22 @@
1
+ import {
2
+ ChatMessageAttachmentCard,
3
+ ChatMessageAttachmentCardContent,
4
+ ChatMessageAttachmentCardIcon,
5
+ ChatMessageAttachmentCardTitle,
6
+ } from '../../chat-message-attachment-card';
7
+
8
+ export interface SentAttachmentProps {
9
+ name: string;
10
+ }
11
+
12
+ /** A file the user sent with a question: not interactive, so it has no remove action. */
13
+ export function SentAttachment({ name }: SentAttachmentProps) {
14
+ return (
15
+ <ChatMessageAttachmentCard isInteractive={false} className="max-w-60">
16
+ <ChatMessageAttachmentCardIcon icon="pdf" />
17
+ <ChatMessageAttachmentCardContent>
18
+ <ChatMessageAttachmentCardTitle>{name}</ChatMessageAttachmentCardTitle>
19
+ </ChatMessageAttachmentCardContent>
20
+ </ChatMessageAttachmentCard>
21
+ );
22
+ }
@@ -0,0 +1,37 @@
1
+ import { BrainIcon } from '@swisper.ai/icons';
2
+
3
+ import {
4
+ ChatThinkingProcess,
5
+ ChatThinkingProcessContent,
6
+ ChatThinkingProcessContentItem,
7
+ ChatThinkingProcessTrigger,
8
+ ChatThinkingProcessTriggerArrow,
9
+ ChatThinkingProcessTriggerIcon,
10
+ ChatThinkingProcessTriggerLabel,
11
+ } from '../../chat-thinking-process';
12
+
13
+ export interface ToolStepsProps {
14
+ steps: readonly string[];
15
+ }
16
+
17
+ /** The collapsed list of tool steps that opens an assistant answer. */
18
+ export function ToolSteps({ steps }: ToolStepsProps) {
19
+ return (
20
+ <ChatThinkingProcess>
21
+ <ChatThinkingProcessTrigger>
22
+ <ChatThinkingProcessTriggerIcon>
23
+ <BrainIcon />
24
+ </ChatThinkingProcessTriggerIcon>
25
+ <ChatThinkingProcessTriggerLabel>
26
+ {`Used ${steps.length} ${steps.length === 1 ? 'tool' : 'tools'}`}
27
+ </ChatThinkingProcessTriggerLabel>
28
+ <ChatThinkingProcessTriggerArrow />
29
+ </ChatThinkingProcessTrigger>
30
+ <ChatThinkingProcessContent>
31
+ {steps.map((step) => (
32
+ <ChatThinkingProcessContentItem key={step}>{step}</ChatThinkingProcessContentItem>
33
+ ))}
34
+ </ChatThinkingProcessContent>
35
+ </ChatThinkingProcess>
36
+ );
37
+ }
@@ -2,6 +2,14 @@
2
2
  "$schema": "../../../../int-eslint-config/schemas/component.schema.json",
3
3
  "component": "chat-message",
4
4
  "purpose": "One message in a chat conversation: the user's question as an end-aligned bubble, or the assistant's answer at full width, with its parts ChatMessageContent (the message body) and ChatMessageActions (a hover-revealed row under it).",
5
+ "anatomy": [
6
+ "import { ChatMessage, ChatMessageContent, ChatMessageActions } from '@swisper.ai/web-chat-ui';",
7
+ "",
8
+ "<ChatMessage>",
9
+ " <ChatMessageContent />",
10
+ " <ChatMessageActions />",
11
+ "</ChatMessage>"
12
+ ],
5
13
  "useWhen": [
6
14
  "Rendering a user question or an assistant answer inside a chat thread",
7
15
  "Stacking an answer's parts in order: ChatThinkingProcess, one or more ChatMessageContent blocks, then ChatMessageActions with a ChatMessageToolbar",
@@ -42,7 +50,8 @@
42
50
  "ChatMessageContent sizes to its content (w-fit) and keeps a minimum width on small screens",
43
51
  "ChatMessageActions is fully visible below the md breakpoint and fades in on hover of its ChatMessage from md up",
44
52
  "ChatMessageContent takes plain text, a web-chat-ui/markdown-viewer or a web-chat-ui/chat-card-container; ChatMessageActions takes a web-chat-ui/chat-message-toolbar or other controls",
45
- "The parts read the question state from the parent ChatMessage through a group selector, so ChatMessageContent and ChatMessageActions only work inside a ChatMessage"
53
+ "The parts read the question state from the parent ChatMessage through a group selector, so ChatMessageContent and ChatMessageActions only work inside a ChatMessage",
54
+ "Each part takes a className, merged last so it replaces the part's own classes, and sets a data-slot: chat-message, chat-message-content, chat-message-actions"
46
55
  ]
47
56
  },
48
57
  "composition": {
@@ -1,15 +1,50 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { expect, fn } from 'storybook/test';
2
3
 
3
- import { ChatMessage, ChatMessageContent, ChatMessageActions } from './chat-message';
4
+ import { CopyIcon, ThumbsDownIcon, ThumbsUpIcon } from '@swisper.ai/icons';
5
+ import { withTooltip } from '@swisper.ai/ui';
6
+
7
+ import { ParentBlock } from '../../__storybook__/parent-block';
8
+ import {
9
+ ChatMessageToolbar,
10
+ ChatMessageToolbarActionButton,
11
+ ChatMessageToolbarActions,
12
+ ChatMessageToolbarTimestamp,
13
+ } from '../chat-message-toolbar';
14
+ import { ChatThreadAnswer, ChatThreadQuestion } from '../chat-thread';
15
+ import { MarkdownViewer } from '../markdown-viewer';
16
+
17
+ import {
18
+ AGENT_DRAFT_STEPS,
19
+ AGENT_FINDINGS,
20
+ AGENT_PROMPT,
21
+ AGENT_RESULT,
22
+ AGENT_SEARCH_STEPS,
23
+ ANSWER,
24
+ ANSWER_TIME,
25
+ ATTACHMENT_NAME,
26
+ ATTACHMENT_QUESTION,
27
+ FOLLOW_UP_ANSWER,
28
+ FOLLOW_UP_QUESTION,
29
+ LONG_QUESTION,
30
+ QUESTION,
31
+ TOOL_STEPS,
32
+ } from './__stories__/fixtures';
33
+ import { SentAttachment } from './__stories__/sent-attachment';
34
+ import { ToolSteps } from './__stories__/tool-steps';
35
+ import { ChatMessage, ChatMessageActions, ChatMessageContent } from './chat-message';
4
36
 
5
37
  const meta: Meta<typeof ChatMessage> = {
6
- title: 'Chatbot/ChatMessage',
38
+ title: 'Chat/ChatMessage',
7
39
  component: ChatMessage,
40
+ subcomponents: { ChatMessageContent, ChatMessageActions },
8
41
  parameters: { layout: 'padded' },
9
42
  tags: ['autodocs'],
10
43
  decorators: [
44
+ // The toolbar's action buttons are wrapped in a Tooltip, which needs a TooltipProvider above them
45
+ withTooltip,
11
46
  (Story) => (
12
- <div className="w-[700px]">
47
+ <div className="w-full max-w-175">
13
48
  <Story />
14
49
  </div>
15
50
  ),
@@ -33,63 +68,290 @@ const meta: Meta<typeof ChatMessage> = {
33
68
  },
34
69
  args: {
35
70
  isQuestion: false,
36
- children: <ChatMessageContent>What are my recent transactions?</ChatMessageContent>,
71
+ children: <ChatMessageContent>{QUESTION}</ChatMessageContent>,
37
72
  },
38
73
  };
39
74
 
40
75
  export default meta;
41
76
  type Story = StoryObj<typeof ChatMessage>;
42
77
 
78
+ /** The user's question: right-aligned, with its content in a filled bubble. */
79
+ export const Default: Story = {
80
+ args: { isQuestion: true },
81
+ };
82
+
83
+ /** A question shows the user's text exactly as sent, in a bubble at the end of the row. */
43
84
  export const Question: Story = {
85
+ parameters: { controls: { disable: true } },
44
86
  render: () => (
45
87
  <ChatMessage isQuestion>
46
- <ChatMessageContent>Hello, how can I help you today?</ChatMessageContent>
88
+ <ChatMessageContent>{FOLLOW_UP_QUESTION}</ChatMessageContent>
47
89
  </ChatMessage>
48
90
  ),
49
91
  };
50
92
 
93
+ /** The assistant's answer: start-aligned with no bubble, its Markdown rendered by a `MarkdownViewer`. */
51
94
  export const Answer: Story = {
95
+ parameters: { controls: { disable: true } },
52
96
  render: () => (
53
97
  <ChatMessage>
54
- <ChatMessageContent>Hello, how can I help you today?</ChatMessageContent>
98
+ <ChatMessageContent>
99
+ <MarkdownViewer markdown={ANSWER} />
100
+ </ChatMessageContent>
55
101
  </ChatMessage>
56
102
  ),
57
103
  };
58
104
 
59
- export const WithActions: Story = {
60
- render: () => (
105
+ interface AssistantAnswerProps {
106
+ answer: string;
107
+ /** When the answer finished, as the toolbar shows it */
108
+ time: string;
109
+ onCopy: () => void;
110
+ }
111
+
112
+ function AssistantAnswer({ answer, time, onCopy }: AssistantAnswerProps) {
113
+ return (
61
114
  <ChatMessage>
62
- <ChatMessageContent>Hello, how can I help you today?</ChatMessageContent>
115
+ <ChatMessageContent>
116
+ <MarkdownViewer markdown={answer} />
117
+ </ChatMessageContent>
63
118
  <ChatMessageActions>
64
- <button type="button">Copy</button>
119
+ <ChatMessageToolbar>
120
+ <ChatMessageToolbarTimestamp>{time}</ChatMessageToolbarTimestamp>
121
+ <ChatMessageToolbarActions>
122
+ <ChatMessageToolbarActionButton tooltip="Copy" aria-label="Copy" onClick={onCopy}>
123
+ <CopyIcon />
124
+ </ChatMessageToolbarActionButton>
125
+ <ChatMessageToolbarActionButton tooltip="Good response" aria-label="Good response">
126
+ <ThumbsUpIcon />
127
+ </ChatMessageToolbarActionButton>
128
+ <ChatMessageToolbarActionButton tooltip="Bad response" aria-label="Bad response">
129
+ <ThumbsDownIcon />
130
+ </ChatMessageToolbarActionButton>
131
+ </ChatMessageToolbarActions>
132
+ </ChatMessageToolbar>
65
133
  </ChatMessageActions>
66
134
  </ChatMessage>
67
- ),
135
+ );
136
+ }
137
+
138
+ /** A finished answer with its toolbar in `ChatMessageActions`; from `md` up, hover the message to show it. */
139
+ export const WithActions: Story = {
140
+ parameters: { controls: { disable: true } },
141
+ render: () => <AssistantAnswer answer={ANSWER} time={ANSWER_TIME} onCopy={fn()} />,
142
+ };
143
+
144
+ /** The actions stay reachable by keyboard while hover has not revealed them. */
145
+ export const WithActionsKeyboard: StoryObj<typeof AssistantAnswer> = {
146
+ tags: ['e2e', '!autodocs'],
147
+ parameters: { controls: { disable: true } },
148
+ args: { answer: ANSWER, time: ANSWER_TIME, onCopy: fn() },
149
+ render: (args) => <AssistantAnswer {...args} />,
150
+ play: async ({ args, canvas, userEvent, step }) => {
151
+ const copy = canvas.getByRole('button', { name: 'Copy' });
152
+
153
+ await step('Names every action in the row', async () => {
154
+ await expect(canvas.getByRole('button', { name: 'Good response' })).toBeInTheDocument();
155
+ await expect(canvas.getByRole('button', { name: 'Bad response' })).toBeInTheDocument();
156
+ });
157
+
158
+ await step('Reaches Copy with Tab and runs it with Enter', async () => {
159
+ await userEvent.tab();
160
+ await expect(copy).toHaveFocus();
161
+ await userEvent.keyboard('{Enter}');
162
+ await expect(args.onCopy).toHaveBeenCalledOnce();
163
+ });
164
+ },
68
165
  };
69
166
 
167
+ /** One turn of a conversation: the question bubble, then the answer under it. */
70
168
  export const History: Story = {
169
+ parameters: { controls: { disable: true } },
71
170
  render: () => (
72
- <div className="flex flex-col gap-8">
171
+ <div className="flex flex-col gap-16">
73
172
  <ChatMessage isQuestion>
74
- <ChatMessageContent>What are my recent transactions?</ChatMessageContent>
173
+ <ChatMessageContent>{QUESTION}</ChatMessageContent>
75
174
  </ChatMessage>
76
175
  <ChatMessage>
77
- <ChatMessageContent>Here is the history of your transactions</ChatMessageContent>
176
+ <ChatMessageContent>
177
+ <MarkdownViewer markdown={ANSWER} />
178
+ </ChatMessageContent>
78
179
  </ChatMessage>
79
180
  </div>
80
181
  ),
81
182
  };
82
183
 
184
+ /** A long question wraps inside its bubble and keeps to the width of the thread. */
83
185
  export const LongMessage: Story = {
186
+ parameters: { controls: { disable: true } },
84
187
  render: () => (
85
188
  <ChatMessage isQuestion>
189
+ <ChatMessageContent>{LONG_QUESTION}</ChatMessageContent>
190
+ </ChatMessage>
191
+ ),
192
+ };
193
+
194
+ /** The message in each parent it's allowed in, then in a chat thread, an agent transcript and a side panel. */
195
+ export const Examples: Story = {
196
+ parameters: { controls: { disable: true } },
197
+ render: () => (
198
+ <div className="flex flex-col gap-24">
199
+ <ParentBlock parent="web-chat-ui/ChatThreadQuestion">
200
+ <ChatThreadQuestion messageId="turn-1-question">
201
+ <ChatMessage isQuestion>
202
+ <ChatMessageContent>{QUESTION}</ChatMessageContent>
203
+ </ChatMessage>
204
+ </ChatThreadQuestion>
205
+ </ParentBlock>
206
+
207
+ <ParentBlock parent="web-chat-ui/ChatThreadAnswer">
208
+ <ChatThreadAnswer messageId="turn-1-answer">
209
+ <ChatMessage>
210
+ <ToolSteps steps={TOOL_STEPS} />
211
+ <ChatMessageContent>
212
+ <MarkdownViewer markdown={ANSWER} />
213
+ </ChatMessageContent>
214
+ </ChatMessage>
215
+ </ChatThreadAnswer>
216
+ </ParentBlock>
217
+
218
+ <ParentBlock parent="web-chat-ui/ChatMessageListGroup">
219
+ <div className="flex flex-col gap-16">
220
+ <ChatMessage isQuestion>
221
+ <ChatMessageContent>{FOLLOW_UP_QUESTION}</ChatMessageContent>
222
+ </ChatMessage>
223
+ <ChatMessage>
224
+ <ChatMessageContent>
225
+ <MarkdownViewer markdown={FOLLOW_UP_ANSWER} />
226
+ </ChatMessageContent>
227
+ </ChatMessage>
228
+ </div>
229
+ </ParentBlock>
230
+
231
+ <ParentBlock parent="chat thread">
232
+ <section aria-label="Chat thread" className="flex flex-col gap-16">
233
+ <ChatMessage isQuestion>
234
+ <SentAttachment name={ATTACHMENT_NAME} />
235
+ <ChatMessageContent>{ATTACHMENT_QUESTION}</ChatMessageContent>
236
+ </ChatMessage>
237
+ <AssistantAnswer
238
+ answer="Yes. Every line on the statement matches a transaction in your account, and the closing balance of **CHF 8,214.55** is the same."
239
+ time="09:47"
240
+ onCopy={fn()}
241
+ />
242
+ </section>
243
+ </ParentBlock>
244
+
245
+ <ParentBlock parent="agent transcript">
246
+ <section aria-label="Agent transcript" className="flex flex-col gap-16">
247
+ <ChatMessage isQuestion>
248
+ <ChatMessageContent>{AGENT_PROMPT}</ChatMessageContent>
249
+ </ChatMessage>
250
+ <ChatMessage className="gap-12">
251
+ <ToolSteps steps={AGENT_SEARCH_STEPS} />
252
+ <ChatMessageContent>
253
+ <MarkdownViewer markdown={AGENT_FINDINGS} />
254
+ </ChatMessageContent>
255
+ <ToolSteps steps={AGENT_DRAFT_STEPS} />
256
+ <ChatMessageContent>
257
+ <MarkdownViewer markdown={AGENT_RESULT} />
258
+ </ChatMessageContent>
259
+ </ChatMessage>
260
+ </section>
261
+ </ParentBlock>
262
+
263
+ <ParentBlock parent="assistant side panel">
264
+ <aside
265
+ aria-label="Swisper assistant"
266
+ className="flex max-w-90 flex-col gap-16 rounded-10 border border-divider-border-base p-16"
267
+ >
268
+ <ChatMessage isQuestion>
269
+ <ChatMessageContent>Compare with last month</ChatMessageContent>
270
+ </ChatMessage>
271
+ <ChatMessage>
272
+ <ChatMessageContent>
273
+ <MarkdownViewer markdown="You spent **CHF 3,442.35** in May, CHF 181.20 more than in April." />
274
+ </ChatMessageContent>
275
+ </ChatMessage>
276
+ </aside>
277
+ </ParentBlock>
278
+ </div>
279
+ ),
280
+ };
281
+
282
+ interface ChatMessagePlaygroundProps {
283
+ isQuestion: boolean;
284
+ className: string;
285
+ text: string;
286
+ hasThinkingProcess: boolean;
287
+ hasAttachment: boolean;
288
+ hasActions: boolean;
289
+ time: string;
290
+ onCopy: () => void;
291
+ }
292
+
293
+ function ChatMessagePlayground({
294
+ isQuestion,
295
+ className,
296
+ text,
297
+ hasThinkingProcess,
298
+ hasAttachment,
299
+ hasActions,
300
+ time,
301
+ onCopy,
302
+ }: ChatMessagePlaygroundProps) {
303
+ return (
304
+ <ChatMessage isQuestion={isQuestion} className={className}>
305
+ {hasThinkingProcess && <ToolSteps steps={TOOL_STEPS} />}
306
+ {hasAttachment && <SentAttachment name={ATTACHMENT_NAME} />}
86
307
  <ChatMessageContent>
87
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
88
- labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
89
- laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
90
- voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
91
- cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
308
+ <MarkdownViewer markdown={text} />
92
309
  </ChatMessageContent>
310
+ {hasActions && (
311
+ <ChatMessageActions>
312
+ <ChatMessageToolbar reverse={isQuestion}>
313
+ <ChatMessageToolbarTimestamp>{time}</ChatMessageToolbarTimestamp>
314
+ <ChatMessageToolbarActions>
315
+ <ChatMessageToolbarActionButton tooltip="Copy" aria-label="Copy" onClick={onCopy}>
316
+ <CopyIcon />
317
+ </ChatMessageToolbarActionButton>
318
+ </ChatMessageToolbarActions>
319
+ </ChatMessageToolbar>
320
+ </ChatMessageActions>
321
+ )}
93
322
  </ChatMessage>
94
- ),
323
+ );
324
+ }
325
+
326
+ /** Every part of a message at once, with each part and prop on the Controls panel. */
327
+ export const Playground: StoryObj<typeof ChatMessagePlayground> = {
328
+ tags: ['!autodocs'],
329
+ args: {
330
+ isQuestion: false,
331
+ className: '',
332
+ text: ANSWER,
333
+ hasThinkingProcess: true,
334
+ hasAttachment: true,
335
+ hasActions: true,
336
+ time: ANSWER_TIME,
337
+ onCopy: fn(),
338
+ },
339
+ argTypes: {
340
+ text: { control: 'text', description: 'Markdown inside `ChatMessageContent`.' },
341
+ hasThinkingProcess: {
342
+ control: 'boolean',
343
+ description: 'Renders a `ChatThinkingProcess` with the tool steps above the content.',
344
+ },
345
+ hasAttachment: {
346
+ control: 'boolean',
347
+ description: 'Renders a `ChatMessageAttachmentCard` above the content.',
348
+ },
349
+ hasActions: {
350
+ control: 'boolean',
351
+ description: 'Renders `ChatMessageActions` with a `ChatMessageToolbar` under the content.',
352
+ },
353
+ time: { control: 'text', description: 'Text of the toolbar timestamp.' },
354
+ onCopy: { control: false, description: 'Called when the Copy action is pressed.' },
355
+ },
356
+ render: (args) => <ChatMessagePlayground {...args} />,
95
357
  };