@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,109 +0,0 @@
1
- import * as RovingFocusGroup from '@radix-ui/react-roving-focus';
2
- import type { ComponentPropsWithoutRef, KeyboardEvent } from 'react';
3
- import { forwardRef, useId, useMemo, useState } from 'react';
4
-
5
- import { cn } from '@swisper.ai/ui';
6
-
7
- import {
8
- CardItemPickerRowContext,
9
- type CardItemPickerRowContextValue,
10
- type CardItemPickerValue,
11
- useCardItemPickerListContext,
12
- } from './card-item-picker-context';
13
-
14
- export interface CardItemPickerRowProps extends Omit<
15
- ComponentPropsWithoutRef<'li'>,
16
- 'role' | 'tabIndex' | 'aria-selected' | 'aria-labelledby' | 'aria-describedby'
17
- > {
18
- value: CardItemPickerValue;
19
- }
20
-
21
- /**
22
- * One card of a {@link CardItemPickerList}: a listbox option. Its accessible name
23
- * comes from {@link CardItemPickerRowTitle} and its description from
24
- * {@link CardItemPickerRowDescription}, when rendered.
25
- */
26
- export const CardItemPickerRow = forwardRef<HTMLLIElement, CardItemPickerRowProps>(
27
- function CardItemPickerRow(
28
- { value, className, children, onClick, onKeyDown, onMouseEnter, onMouseLeave, ...props },
29
- forwardedRef,
30
- ) {
31
- const list = useCardItemPickerListContext();
32
- const id = useId();
33
- const [hasTitle, setHasTitle] = useState(false);
34
- const [hasDescription, setHasDescription] = useState(false);
35
-
36
- const isSelected = list.value === value;
37
- const isHovered = list.hoveredValue === value;
38
-
39
- const itemContext = useMemo<CardItemPickerRowContextValue>(
40
- () => ({
41
- isSelected,
42
- titleId: `${id}-title`,
43
- descriptionId: `${id}-description`,
44
- registerTitle: () => {
45
- setHasTitle(true);
46
- return () => setHasTitle(false);
47
- },
48
- registerDescription: () => {
49
- setHasDescription(true);
50
- return () => setHasDescription(false);
51
- },
52
- }),
53
- [id, isSelected],
54
- );
55
-
56
- function handleKeyDown(event: KeyboardEvent<HTMLLIElement>) {
57
- onKeyDown?.(event);
58
- if (event.defaultPrevented) return;
59
- if (event.key === 'Enter' || event.key === ' ') {
60
- event.preventDefault();
61
- list.select(value);
62
- }
63
- }
64
-
65
- return (
66
- <CardItemPickerRowContext.Provider value={itemContext}>
67
- <RovingFocusGroup.Item asChild tabStopId={String(value)}>
68
- <li
69
- {...props}
70
- ref={forwardedRef}
71
- role="option"
72
- aria-selected={isSelected}
73
- aria-labelledby={hasTitle ? itemContext.titleId : undefined}
74
- aria-describedby={hasDescription ? itemContext.descriptionId : undefined}
75
- data-selected={isSelected}
76
- data-hovered={isHovered}
77
- className={cn(
78
- 'relative flex flex-row items-start gap-4',
79
- 'w-full cursor-pointer rounded-(--st-border-radius-md) p-8',
80
- 'transition-colors duration-150',
81
- 'hover:bg-layout-accent-low-background-hover-base',
82
- 'data-[selected=true]:bg-layout-accent-low-background-pressed-base',
83
- // Not while focus-visible: these rules come later in the CSS and would hide the focus ring.
84
- 'data-[selected=true]:not-focus-visible:ring-1 data-[selected=true]:not-focus-visible:ring-inset',
85
- 'data-[selected=true]:not-focus-visible:ring-brand-secondary-700',
86
- 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-secondary-focus-visible',
87
- className,
88
- )}
89
- onClick={(event) => {
90
- onClick?.(event);
91
- if (!event.defaultPrevented) list.select(value);
92
- }}
93
- onKeyDown={handleKeyDown}
94
- onMouseEnter={(event) => {
95
- onMouseEnter?.(event);
96
- list.hover(value);
97
- }}
98
- onMouseLeave={(event) => {
99
- onMouseLeave?.(event);
100
- list.hover(null);
101
- }}
102
- >
103
- {children}
104
- </li>
105
- </RovingFocusGroup.Item>
106
- </CardItemPickerRowContext.Provider>
107
- );
108
- },
109
- );
@@ -1,147 +0,0 @@
1
- {
2
- "$schema": "../../../../int-eslint-config/schemas/component.schema.json",
3
- "component": "card-item-picker",
4
- "purpose": "Single-select list of cards on the ARIA listbox pattern, for the collection pane of a chat card (e.g. places on a map): picking a row opens its details, and hover can be mirrored with an outside source such as map pins. Parts: CardItemPickerList, CardItemPickerRow, CardItemPickerRowMedia, CardItemPickerRowContent, CardItemPickerRowTitle, CardItemPickerRowDescription, CardItemPickerRowCheckbox.",
5
- "useWhen": [
6
- "The collection pane of a chat card where picking one item opens its details (places, documents, contacts)",
7
- "A list that must stay in sync with another view's hover and selection, such as pins on a map",
8
- "Choosing one item from a short visual collection, stacked vertically or as a horizontal strip"
9
- ],
10
- "avoidWhen": [
11
- "Rows need their own buttons or links — a listbox option can't hold controls; use ui/list and put actions in the rows",
12
- "Several items can be selected at once — use ui/checkbox-field rows or ui/list with checkboxes",
13
- "A form field choosing from options — use ui/select-field or ui/radio-group",
14
- "Navigation between pages — use links or ui/tabs"
15
- ],
16
- "uxPrinciples": [
17
- "A row is a single target: the whole card picks the item, and its actions live in the details view.",
18
- "Selection and hover are one shared state across the list and the map, so the user always sees which item is which."
19
- ],
20
- "accessibility": {
21
- "required": [
22
- "Name the list with aria-label or aria-labelledby on CardItemPickerList; an unnamed listbox is announced as just 'listbox'",
23
- "Give every row a CardItemPickerRowTitle: it becomes the option's accessible name (aria-labelledby); without it the whole row text is read as the name",
24
- "No links, buttons or other controls inside a row: they are unreachable by keyboard and confuse screen readers. Put actions in the details pane",
25
- "Images in CardItemPickerRowMedia are decorative (the media is aria-hidden): pass alt=''"
26
- ],
27
- "keyboard": [
28
- "Tab focuses the list, which moves into the last focused row, else the selected one, else the first; Shift+Tab leaves the list in one step",
29
- "ArrowDown / ArrowUp (vertical) or ArrowRight / ArrowLeft (horizontal) move to the next / previous row and stop at the ends",
30
- "Home or PageUp moves to the first row; End or PageDown to the last",
31
- "Enter or Space picks the focused row (onValueChange)"
32
- ],
33
- "aria": [
34
- "CardItemPickerList is role=listbox with aria-orientation from orientation",
35
- "Each CardItemPickerRow is role=option with aria-selected; aria-labelledby points at its title and aria-describedby at CardItemPickerRowDescription when rendered",
36
- "CardItemPickerRowMedia and CardItemPickerRowCheckbox are aria-hidden; the selection is announced through aria-selected"
37
- ],
38
- "focus": [
39
- "Roving focus (@radix-ui/react-roving-focus): the list is one tab stop and at most one row has tabIndex=0",
40
- "The focus ring (2px inset) replaces the selected row's 1px ring while that row has keyboard focus",
41
- "Arrow keys follow DOM order, so rows shown in another visual order (flex-row-reverse) feel backwards",
42
- "Arrow moves land a tick after the keydown (Radix defers them with setTimeout), so tests must flush timers"
43
- ]
44
- },
45
- "behaviour": {
46
- "states": [
47
- "default",
48
- "hover",
49
- "hovered from outside (data-hovered)",
50
- "selected",
51
- "focus-visible"
52
- ],
53
- "rules": [
54
- "Controlled: value is the selected row's value (null for none), and onValueChange fires with the row's value on click, Enter or Space",
55
- "It does not toggle: picking the selected row fires onValueChange with the same value again. To deselect on a second pick, return null for it in the handler",
56
- "Row values are unique strings or numbers; they identify rows for selection, hover and focus, so duplicates break all three",
57
- "orientation='vertical' stacks rows in a column and moves with ↑/↓; 'horizontal' lays them in a row and moves with ←/→. A horizontal list needs a width on each row (rows are full width by default)",
58
- "hoveredValue is for an outside hover source (a map pin under the pointer) and sets data-hovered=true on that row; onHoverChange reports the row the pointer enters and null when it leaves",
59
- "Rows carry data-selected and data-hovered, so style them with data-[selected=true]: and data-[hovered=true]:",
60
- "A row's own onClick and onKeyDown run first; calling event.preventDefault() in them cancels the pick",
61
- "CardItemPickerRowTitle takes a plain string, clamps it to one line and puts the full text in its title attribute",
62
- "CardItemPickerRowCheckbox only mirrors the selection: it is out of the tab order, lets clicks through to the row and sits absolutely in the row's top-right corner",
63
- "CardItemPickerRowMedia is a 64px square for a thumbnail",
64
- "The list adds no scrolling: add overflow and sizing through className, or wrap it in a ui/scroll-area",
65
- "className on any part is merged with tailwind-merge, so it wins over the defaults",
66
- "CardItemPickerRow, its parts and the context hooks (useCardItemPickerListContext, useCardItemPickerRowContext) throw outside their parent"
67
- ]
68
- },
69
- "composition": {
70
- "allowedParents": [
71
- "web-chat-ui/chat-card",
72
- "web-chat-ui/ChatCardThreeColumnLayoutList",
73
- "ui/scroll-area"
74
- ],
75
- "allowedChildren": [
76
- "web-chat-ui/CardItemPickerRow",
77
- "web-chat-ui/CardItemPickerRowMedia",
78
- "web-chat-ui/CardItemPickerRowContent",
79
- "web-chat-ui/CardItemPickerRowTitle",
80
- "web-chat-ui/CardItemPickerRowDescription",
81
- "web-chat-ui/CardItemPickerRowCheckbox",
82
- "thumbnail image (alt='')",
83
- "text title",
84
- "description text"
85
- ],
86
- "avoidCombinations": [
87
- "ui/button, ui/link or any control inside a row — move the action to the details pane",
88
- "CardItemPickerRowCheckbox without right padding on CardItemPickerRowContent — the checkbox overlaps the title; add pr-[36px]",
89
- "Two rows with the same value — they highlight and select together"
90
- ],
91
- "contexts": ["collection pane of a chat card", "floating strip over a map"]
92
- },
93
- "content": {
94
- "labelRules": [
95
- "CardItemPickerRowTitle: the item's name as a plain string; it is cut to one line, so lead with the distinguishing word"
96
- ],
97
- "helperTextRules": [
98
- "CardItemPickerRowDescription: one short line of secondary details (address, summary); it is announced as the option's description"
99
- ],
100
- "errorRules": []
101
- },
102
- "aiDecisionRules": [
103
- {
104
- "condition": "Inside web-chat-ui/ChatCardThreeColumnLayoutList",
105
- "decision": "Render it vertical in the column, and orientation='horizontal' in the floating strip (isFloating) with fixed-width, shrink-0 rows and overflow-x-auto on the list",
106
- "reason": "The floating strip is a horizontal row over the map; rows need their own width there"
107
- },
108
- {
109
- "condition": "Picking the selected row again should clear the selection",
110
- "decision": "Toggle in onValueChange: setSelected(current => current === next ? null : next)",
111
- "reason": "The list never deselects on its own"
112
- },
113
- {
114
- "condition": "Hover must be mirrored with a map or another view",
115
- "decision": "Keep the hovered id in shared state: pass it as hoveredValue and update it from onHoverChange and from the other view",
116
- "reason": "hoveredValue drives data-hovered on the row, and onHoverChange reports pointer enter and leave"
117
- },
118
- {
119
- "condition": "Arrow keys appear to do nothing",
120
- "decision": "Match orientation to the layout: vertical for a column (↑/↓), horizontal for a row (←/→)",
121
- "reason": "Each orientation only listens to its own pair of arrow keys"
122
- },
123
- {
124
- "condition": "A row needs an action (open in maps, call, delete)",
125
- "decision": "Show the action in the details pane opened by the selection, not in the row",
126
- "reason": "A listbox option can't contain interactive controls"
127
- }
128
- ],
129
- "relatedComponents": [
130
- "web-chat-ui/chat-card-three-column-layout",
131
- "web-chat-ui/chat-card",
132
- "ui/list",
133
- "ui/scroll-area",
134
- "web-map/map-view"
135
- ],
136
- "tokenReferences": {
137
- "source": "packages/design-system/src/tailwind.css",
138
- "categories": [
139
- "bg-layout-accent-low-background-hover-base (hover)",
140
- "bg-layout-accent-low-background-pressed-base (selected)",
141
- "ring-brand-secondary-700 (selected ring)",
142
- "ring-secondary-focus-visible (focus ring)",
143
- "--st-border-radius-md (row radius)"
144
- ],
145
- "rule": "Restyle rows through className and the data-[selected=true]: / data-[hovered=true]: variants with theme utilities; never hardcode colours."
146
- }
147
- }
@@ -1,158 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { useState } from 'react';
3
-
4
- import { Typography } from '@swisper.ai/ui';
5
-
6
- import {
7
- CardItemPickerList,
8
- CardItemPickerRow,
9
- CardItemPickerRowCheckbox,
10
- CardItemPickerRowContent,
11
- CardItemPickerRowDescription,
12
- CardItemPickerRowMedia,
13
- CardItemPickerRowTitle,
14
- type CardItemPickerOrientation,
15
- } from '.';
16
-
17
- interface City {
18
- id: string;
19
- name: string;
20
- canton: string;
21
- summary: string;
22
- }
23
-
24
- const CITIES: City[] = [
25
- { id: 'zrh', name: 'Zurich', canton: 'ZH', summary: 'Largest city · Lake Zurich' },
26
- { id: 'gva', name: 'Geneva', canton: 'GE', summary: 'Lake Geneva · Jet d’Eau' },
27
- { id: 'bsl', name: 'Basel', canton: 'BS', summary: 'On the Rhine · Art Basel' },
28
- { id: 'brn', name: 'Bern', canton: 'BE', summary: 'Federal city · Old Town' },
29
- ];
30
-
31
- interface DemoProps {
32
- orientation?: CardItemPickerOrientation;
33
- withMedia?: boolean;
34
- withCheckbox?: boolean;
35
- initialValue?: string | null;
36
- }
37
-
38
- /** A controlled list, so selecting, hovering and keyboard focus can be tried out. */
39
- function Demo({
40
- orientation,
41
- withMedia = false,
42
- withCheckbox = false,
43
- initialValue = null,
44
- }: DemoProps) {
45
- const [value, setValue] = useState<string | null>(initialValue);
46
- const [hovered, setHovered] = useState<string | null>(null);
47
-
48
- return (
49
- <div className="flex flex-col gap-[16px] max-w-[480px]">
50
- <CardItemPickerList
51
- aria-label="Cities"
52
- orientation={orientation}
53
- value={value}
54
- hoveredValue={hovered}
55
- onValueChange={(next) => setValue((current) => (current === next ? null : next))}
56
- onHoverChange={setHovered}
57
- className={orientation === 'horizontal' ? 'overflow-x-auto' : undefined}
58
- >
59
- {CITIES.map((city) => (
60
- <CardItemPickerRow
61
- key={city.id}
62
- value={city.id}
63
- className={orientation === 'horizontal' ? 'w-[240px] shrink-0' : undefined}
64
- >
65
- {withMedia && (
66
- <CardItemPickerRowMedia className="flex items-center justify-center">
67
- <Typography variant="body" fontWeight="semibold">
68
- {city.canton}
69
- </Typography>
70
- </CardItemPickerRowMedia>
71
- )}
72
-
73
- <CardItemPickerRowContent className={withCheckbox ? 'pr-[36px]' : undefined}>
74
- <CardItemPickerRowTitle>{city.name}</CardItemPickerRowTitle>
75
- <CardItemPickerRowDescription>
76
- <Typography variant="caption" className="text-text-secondary">
77
- {city.summary}
78
- </Typography>
79
- </CardItemPickerRowDescription>
80
- </CardItemPickerRowContent>
81
-
82
- {withCheckbox && <CardItemPickerRowCheckbox />}
83
- </CardItemPickerRow>
84
- ))}
85
- </CardItemPickerList>
86
-
87
- <Typography variant="caption" className="text-text-secondary">
88
- Selected: {value ?? 'none'} · Hovered: {hovered ?? 'none'}
89
- </Typography>
90
- </div>
91
- );
92
- }
93
-
94
- const meta: Meta<typeof Demo> = {
95
- title: 'Chatbot/Card Item Picker',
96
- component: Demo,
97
- parameters: {
98
- layout: 'padded',
99
- docs: {
100
- description: {
101
- component:
102
- 'A single-select list of cards on the ARIA listbox pattern. Tab reaches the list once; ↑/↓ (←/→ when horizontal), Home and End move between cards; Enter or Space picks one.',
103
- },
104
- },
105
- },
106
- tags: ['autodocs'],
107
- argTypes: {
108
- orientation: {
109
- control: 'inline-radio',
110
- options: ['vertical', 'horizontal'],
111
- description:
112
- 'Stacks the cards in a column (`vertical`) or a scrolling row (`horizontal`); also sets which arrow keys move focus.',
113
- table: { defaultValue: { summary: 'vertical' } },
114
- },
115
- withMedia: {
116
- control: 'boolean',
117
- description:
118
- 'Renders a `CardItemPickerRowMedia` block (the canton code) at the start of each card.',
119
- table: { defaultValue: { summary: 'false' } },
120
- },
121
- withCheckbox: {
122
- control: 'boolean',
123
- description:
124
- 'Adds a `CardItemPickerRowCheckbox` in each card’s top-right corner that mirrors the selection.',
125
- table: { defaultValue: { summary: 'false' } },
126
- },
127
- initialValue: {
128
- control: 'select',
129
- options: [null, ...CITIES.map((city) => city.id)],
130
- description: 'Value of the card selected on first render, or `null` for no selection.',
131
- table: { defaultValue: { summary: 'null' } },
132
- },
133
- },
134
- args: {
135
- orientation: 'vertical',
136
- withMedia: false,
137
- withCheckbox: false,
138
- initialValue: null,
139
- },
140
- };
141
-
142
- export default meta;
143
- type Story = StoryObj<typeof Demo>;
144
-
145
- export const Default: Story = {};
146
-
147
- export const WithMedia: Story = {
148
- args: { withMedia: true },
149
- };
150
-
151
- /** A checkbox in each card's top-right corner mirrors the selection. */
152
- export const WithCheckbox: Story = {
153
- args: { withMedia: true, withCheckbox: true, initialValue: 'gva' },
154
- };
155
-
156
- export const Horizontal: Story = {
157
- args: { orientation: 'horizontal', withMedia: true },
158
- };
@@ -1,24 +0,0 @@
1
- export { CardItemPickerList } from './card-item-picker-list';
2
- export { CardItemPickerRow } from './card-item-picker-row';
3
- export {
4
- CardItemPickerRowCheckbox,
5
- CardItemPickerRowContent,
6
- CardItemPickerRowDescription,
7
- CardItemPickerRowMedia,
8
- CardItemPickerRowTitle,
9
- } from './card-item-picker-row-parts';
10
- export {
11
- useCardItemPickerListContext,
12
- useCardItemPickerRowContext,
13
- } from './card-item-picker-context';
14
-
15
- export type { CardItemPickerListProps } from './card-item-picker-list';
16
- export type { CardItemPickerRowProps } from './card-item-picker-row';
17
- export type {
18
- CardItemPickerRowMediaProps,
19
- CardItemPickerRowContentProps,
20
- CardItemPickerRowTitleProps,
21
- CardItemPickerRowDescriptionProps,
22
- CardItemPickerRowCheckboxProps,
23
- } from './card-item-picker-row-parts';
24
- export type { CardItemPickerValue, CardItemPickerOrientation } from './card-item-picker-context';
@@ -1,99 +0,0 @@
1
- {
2
- "$schema": "../../../../int-eslint-config/schemas/component.schema.json",
3
- "component": "chat-message-history",
4
- "purpose": "A scroll container for a chat conversation that sticks to the bottom: it opens at the latest message, follows new content while the reader is at the end, and shows a scroll-to-latest button (ChatMessageHistoryScrollButton) once they scroll up.",
5
- "useWhen": [
6
- "Maintaining an existing screen already built on ChatMessageHistory and ChatMessageHistoryList",
7
- "A simple log-style message list that should always stick to the newest message at the bottom, without anchoring questions at the top"
8
- ],
9
- "avoidWhen": [
10
- "Building a new question-and-answer chat or agent transcript — use web-chat-ui/chat-thread, which anchors new questions and supports a follow mode",
11
- "Inside a web-chat-ui/chat-thread or another scroller — the composition rules allow one scroller per conversation",
12
- "Scrolling generic page content — use ui/scroll-area"
13
- ],
14
- "uxPrinciples": [
15
- "The newest message is where the reader is: open at the end and stay there while content arrives",
16
- "Never pull the reader back while they read history; offer a scroll-to-latest button instead"
17
- ],
18
- "accessibility": {
19
- "required": [
20
- "Wrap each message in an <li> inside ChatMessageHistoryList, which renders a <ul>",
21
- "Pass tooltip to ChatMessageHistoryScrollButton: it is the button's aria-label as well as its tooltip",
22
- "Render inside a ui/TooltipProvider: the scroll button always renders a ui/tooltip"
23
- ],
24
- "keyboard": [
25
- "The viewport sets no tabIndex, so arrow and page keys scroll it only while focus is on an element inside it",
26
- "The scroll-to-latest button has tabIndex=-1, so it is pointer-only; keyboard users reach the end by scrolling"
27
- ],
28
- "aria": [
29
- "ChatMessageHistoryList is a role=log list labelled \"Message list\" with aria-atomic=false, so assistive technology announces appended messages",
30
- "The root carries aria-label=\"Chat message history\" but no role",
31
- "The scroll button wrapper is aria-hidden while the view is at the bottom",
32
- "The built-in labels are fixed English strings"
33
- ],
34
- "focus": ["No focus management; the scroll button is not a tab stop"]
35
- },
36
- "behaviour": {
37
- "states": ["at bottom", "scrolled up (scroll button visible)", "loading", "error", "empty"],
38
- "rules": [
39
- "On mount the view jumps to the bottom instantly; when content grows while the reader is at the bottom it stays pinned to the bottom",
40
- "Once the reader scrolls up, new content no longer moves the view and ChatMessageHistoryScrollButton fades in; clicking it scrolls to the last message",
41
- "totalMessages only decides emptiness: 0 marks the history empty (data-empty); it does not drive scrolling",
42
- "isLoading and hasError are reflected as data attributes and shared through context with ChatMessageHistoryEmptyState and ChatMessageHistoryErrorState",
43
- "ChatMessageHistoryEmptyState renders only while isLoading or hasError is true, and ChatMessageHistoryErrorState renders whenever there is no error or while loading; their conditions don't match their names, so check them before relying on either",
44
- "The scrollbar is a custom overlay that appears on hover of the scroll area",
45
- "useChatMessageHistoryContext exposes isCurrentScrollBottom, isLoading, isEmpty, hasError and scrollToLastMessage to custom parts inside the history"
46
- ]
47
- },
48
- "composition": {
49
- "allowedParents": ["web-chat-ui/CanvasShellContent"],
50
- "allowedChildren": [
51
- "web-chat-ui/ChatMessageHistoryList",
52
- "web-chat-ui/ChatMessageHistoryScrollButton",
53
- "web-chat-ui/ChatMessageHistoryEmptyState",
54
- "web-chat-ui/ChatMessageHistoryErrorState"
55
- ],
56
- "avoidCombinations": [
57
- "Nesting it in web-chat-ui/chat-thread or web-chat-ui/chat-messages — two scrollers fight over the scroll position",
58
- "Mixing its parts with ChatMessages or ChatThread parts — each reads its own context"
59
- ],
60
- "contexts": ["assistant side panel", "full-page chat"]
61
- },
62
- "content": {
63
- "labelRules": [
64
- "Scroll button tooltip: short and about the destination, e.g. \"Scroll to latest message\""
65
- ],
66
- "helperTextRules": [],
67
- "errorRules": [
68
- "ChatMessageHistoryErrorState shows its children, or else the error's message, or \"An error occurred\"; pass a message that says what failed and what to do"
69
- ]
70
- },
71
- "aiDecisionRules": [
72
- {
73
- "condition": "Starting a new chat or agent UI",
74
- "decision": "Use web-chat-ui/chat-thread with ChatThreadProvider instead of ChatMessageHistory",
75
- "reason": "The Chatbot overview builds the conversation on ChatThread, which owns scrolling, anchors new questions and offers a follow mode"
76
- },
77
- {
78
- "condition": "Keeping ChatMessageHistory in an existing screen",
79
- "decision": "Give it a height (className=\"h-full\" in a sized parent), put messages in ChatMessageHistoryList as <li> items and add a ChatMessageHistoryScrollButton with a tooltip",
80
- "reason": "It only scrolls with a bounded height, and the button's tooltip is also its accessible name"
81
- },
82
- {
83
- "condition": "The history needs a loading, empty or error view",
84
- "decision": "Render it yourself from isLoading, hasError and totalMessages, or use web-chat-ui/ChatThreadErrorState in a ChatThread",
85
- "reason": "ChatMessageHistoryEmptyState and ChatMessageHistoryErrorState show under conditions that don't match their names"
86
- }
87
- ],
88
- "relatedComponents": [
89
- "web-chat-ui/chat-thread",
90
- "web-chat-ui/chat-messages",
91
- "web-chat-ui/chat-message",
92
- "ui/scroll-area"
93
- ],
94
- "tokenReferences": {
95
- "source": "packages/design-system/src/tailwind.css",
96
- "categories": ["scrollbar-* (track, thumb, width)", "bg-paper-elevation-2 (scroll button)"],
97
- "rule": "The scrollbar takes its colours and sizes from the scrollbar tokens; don't restyle it per screen."
98
- }
99
- }
@@ -1,136 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { useState } from 'react';
3
-
4
- import { TooltipProvider } from '@swisper.ai/ui';
5
-
6
- import { ChatMessage, ChatMessageContent } from '../chat-message/chat-message';
7
-
8
- import {
9
- ChatMessageHistory,
10
- ChatMessageHistoryList,
11
- ChatMessageHistoryScrollButton,
12
- } from './chat-message-history';
13
-
14
- const initialMessages = [
15
- { isQuestion: true, text: 'What are my recent transactions?' },
16
- { isQuestion: false, text: 'Here is the history of your recent transactions.' },
17
- { isQuestion: true, text: 'Can you show the largest one?' },
18
- {
19
- isQuestion: false,
20
- text: 'Your largest transaction this month was $1,240.50 at Acme Corp on May 12.',
21
- },
22
- { isQuestion: true, text: 'How does that compare to last month?' },
23
- {
24
- isQuestion: false,
25
- text: 'Last month your largest transaction was $980.20, so spending is up about 27% on your top purchase.',
26
- },
27
- { isQuestion: true, text: 'Break down my spending by category this month.' },
28
- {
29
- isQuestion: false,
30
- text: 'Sure. Groceries: $412.30, Dining: $286.15, Transport: $154.00, Subscriptions: $89.99, Other: $298.06.',
31
- },
32
- { isQuestion: true, text: 'Which subscriptions am I paying for?' },
33
- {
34
- isQuestion: false,
35
- text: 'You have four active subscriptions: StreamPlus ($14.99), Cloud Storage ($2.99), Fitness App ($29.99), and News Daily ($41.02).',
36
- },
37
- { isQuestion: true, text: 'Can I set a budget alert for dining?' },
38
- {
39
- isQuestion: false,
40
- text: 'Yes. I can notify you when dining spending reaches a limit you choose. What monthly cap would you like?',
41
- },
42
- { isQuestion: true, text: 'Set it to $300.' },
43
- {
44
- isQuestion: false,
45
- text: 'Done. You will get an alert when dining spending hits $300 this month. You are currently at $286.15.',
46
- },
47
- { isQuestion: true, text: 'Show pending transactions too.' },
48
- {
49
- isQuestion: false,
50
- text: 'You have two pending charges: $45.00 at City Parking (May 23) and $12.50 at Metro Coffee (May 24).',
51
- },
52
- { isQuestion: true, text: 'Thanks!' },
53
- { isQuestion: false, text: 'You are welcome. Let me know if you need anything else.' },
54
- ];
55
-
56
- const meta: Meta<typeof ChatMessageHistory> = {
57
- title: 'Chatbot/ChatMessageHistory',
58
- component: ChatMessageHistory,
59
- parameters: { layout: 'padded' },
60
- tags: ['autodocs'],
61
- decorators: [
62
- (Story) => (
63
- <TooltipProvider>
64
- <Story />
65
- </TooltipProvider>
66
- ),
67
- (Story) => (
68
- <div className="relative h-[480px] w-[700px] bg-paper-1">
69
- <Story />
70
- </div>
71
- ),
72
- ],
73
- argTypes: {
74
- totalMessages: {
75
- control: { type: 'number', min: 0 },
76
- description: 'Number of messages in the thread; `0` marks the history as empty.',
77
- },
78
- isLoading: {
79
- control: 'boolean',
80
- description: 'Messages are loading; exposed to the empty and error state parts.',
81
- table: { defaultValue: { summary: 'false' } },
82
- },
83
- hasError: {
84
- control: 'boolean',
85
- description: 'Loading the messages failed; exposed to the empty and error state parts.',
86
- table: { defaultValue: { summary: 'false' } },
87
- },
88
- children: {
89
- control: false,
90
- description:
91
- 'The scrollable content: a `ChatMessageHistoryList` of messages and a `ChatMessageHistoryScrollButton`.',
92
- },
93
- className: {
94
- control: 'text',
95
- description: 'Extra classes merged onto the root, e.g. `h-full`.',
96
- },
97
- },
98
- args: {
99
- totalMessages: initialMessages.length,
100
- isLoading: false,
101
- hasError: false,
102
- className: 'h-full',
103
- },
104
- };
105
-
106
- export default meta;
107
- type Story = StoryObj<typeof ChatMessageHistory>;
108
-
109
- export const Default: Story = {
110
- render: () => {
111
- const [messages, setMessages] = useState(initialMessages);
112
-
113
- function handleAddMessage() {
114
- setMessages([...messages, { isQuestion: true, text: 'What are my recent transactions?' }]);
115
- }
116
-
117
- return (
118
- <>
119
- <ChatMessageHistory totalMessages={messages.length} className="h-full">
120
- <ChatMessageHistoryList>
121
- {messages.map((message, index) => (
122
- <li key={index}>
123
- <ChatMessage isQuestion={message.isQuestion}>
124
- <ChatMessageContent>{message.text}</ChatMessageContent>
125
- </ChatMessage>
126
- </li>
127
- ))}
128
- </ChatMessageHistoryList>
129
- <ChatMessageHistoryScrollButton tooltip="Scroll to latest message" />
130
- </ChatMessageHistory>
131
-
132
- <button onClick={handleAddMessage}>add message</button>
133
- </>
134
- );
135
- },
136
- };