@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
@@ -7,7 +7,7 @@ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
7
7
  import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
8
8
  import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
9
9
  import { HeadingNode, QuoteNode } from '@lexical/rich-text';
10
- import { createContext, forwardRef, useContext, useMemo, useState } from 'react';
10
+ import { createContext, forwardRef, useContext, useMemo, useRef, useState } from 'react';
11
11
  import type { CSSProperties, ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from 'react';
12
12
 
13
13
  import { Typography } from '@swisper.ai/ui';
@@ -37,6 +37,10 @@ interface ChatInputContextValue {
37
37
 
38
38
  const ChatInputContext = createContext<ChatInputContextValue>(null!);
39
39
 
40
+ /**
41
+ * The editor state `ChatInput` tracks (`isFocused`, `hasValue`, `hasError`) and its setters.
42
+ * Throws when called outside a `ChatInput`.
43
+ */
40
44
  export function useChatInputContext() {
41
45
  const context = useContext(ChatInputContext);
42
46
 
@@ -65,9 +69,14 @@ export const DEFAULT_CONFIG: ChatInputConfig = {
65
69
  };
66
70
 
67
71
  export interface ChatInputProps extends ComponentPropsWithoutRef<'div'> {
72
+ /** Lexical composer config, read once on mount. Override only to add nodes or retheme. */
68
73
  initialConfig?: ChatInputConfig;
69
74
  }
70
75
 
76
+ /**
77
+ * Root of the composer: holds the Lexical editor and puts its state on the wrapper as
78
+ * `data-focused`, `data-empty` and `data-error`. Ships unstyled.
79
+ */
71
80
  export const ChatInput = forwardRef<HTMLDivElement, ChatInputProps>(function ChatInput(
72
81
  { className, children, initialConfig = DEFAULT_CONFIG, ...rest },
73
82
  ref,
@@ -93,6 +102,7 @@ export const ChatInput = forwardRef<HTMLDivElement, ChatInputProps>(function Cha
93
102
  <LexicalComposer initialConfig={initialConfig}>
94
103
  <div
95
104
  ref={ref}
105
+ data-slot="chat-input"
96
106
  data-testid="chat-input"
97
107
  data-focused={isFocused}
98
108
  data-empty={!hasValue}
@@ -110,7 +120,7 @@ export const ChatInput = forwardRef<HTMLDivElement, ChatInputProps>(function Cha
110
120
 
111
121
  ChatInput.displayName = 'ChatInput';
112
122
 
113
- export type ChatInputPlaceholderProps = ComponentPropsWithoutRef<'span'>;
123
+ export interface ChatInputPlaceholderProps extends ComponentPropsWithoutRef<'span'> {}
114
124
 
115
125
  export const ChatInputPlaceholder = forwardRef<HTMLSpanElement, ChatInputPlaceholderProps>(
116
126
  function ChatInputPlaceholder({ className, children, ...rest }, ref) {
@@ -124,9 +134,11 @@ export const ChatInputPlaceholder = forwardRef<HTMLSpanElement, ChatInputPlaceho
124
134
  'text-text-tertiary',
125
135
  className,
126
136
  )}
137
+ asChild
127
138
  {...rest}
128
139
  >
129
- {children}
140
+ {/* Typography stamps its own data-slot unless it renders as its child. */}
141
+ <p data-slot="chat-input-placeholder">{children}</p>
130
142
  </Typography>
131
143
  );
132
144
  },
@@ -135,19 +147,37 @@ export const ChatInputPlaceholder = forwardRef<HTMLSpanElement, ChatInputPlaceho
135
147
  ChatInputPlaceholder.displayName = 'ChatInputPlaceholder';
136
148
 
137
149
  export interface ChatInputTextareaProps {
150
+ /** Classes for the editable element (`data-slot="chat-input-editable"`), not its wrapper. */
138
151
  className?: string;
152
+ /** Inline styles for the wrapper around the editable element. */
139
153
  style?: CSSProperties | undefined;
154
+ /** Classes for the placeholder (`data-slot="chat-input-placeholder"`). */
140
155
  placeholderClassName?: string;
156
+ /** Shown while the editor is empty; also the editable's `aria-placeholder`. */
141
157
  placeholder?: string;
158
+ /** Custom Lexical plugins; rendered inside the composer, after the built-in ones. */
142
159
  children?: ReactNode;
160
+ /**
161
+ * Content as Markdown. When it differs from the editor's, it replaces the content; a late
162
+ * render of a value `onChange` already emitted is ignored.
163
+ */
143
164
  value?: string;
165
+ /** Focuses the editor on mount, caret at the end. Skipped when disabled or read-only. */
144
166
  autoFocus?: boolean;
167
+ /** Blocks editing and selection and dims the wrapper (`data-disabled`). */
145
168
  isDisabled?: boolean;
169
+ /** Blocks editing but keeps the text selectable (`data-readonly`). */
146
170
  isReadOnly?: boolean;
171
+ /** Called with the content as Markdown on every edit. */
147
172
  onChange?: (value: string) => void;
173
+ /** Key handler on the editable element; implement send-on-Enter here. */
148
174
  onKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;
149
175
  }
150
176
 
177
+ /**
178
+ * The editable area of a `ChatInput`. Its value is a Markdown string; paste inserts plain
179
+ * text. Must be rendered inside a `ChatInput`.
180
+ */
151
181
  export const ChatInputTextarea = forwardRef<HTMLDivElement, ChatInputTextareaProps>(
152
182
  function ChatInputTextarea(
153
183
  {
@@ -168,11 +198,14 @@ export const ChatInputTextarea = forwardRef<HTMLDivElement, ChatInputTextareaPro
168
198
  ) {
169
199
  const { setHasValue, setIsFocused } = useChatInputContext();
170
200
  const isReadOnlyState = isReadOnly && !isDisabled;
201
+ const emittedValuesRef = useRef<string[]>([]);
171
202
 
172
203
  return (
173
204
  <div
205
+ data-slot="chat-input-textarea"
174
206
  data-testid="chat-input-textarea"
175
207
  data-disabled={isDisabled}
208
+ data-readonly={isReadOnlyState}
176
209
  aria-disabled={isDisabled}
177
210
  aria-readonly={isReadOnlyState}
178
211
  className={cn(
@@ -188,6 +221,7 @@ export const ChatInputTextarea = forwardRef<HTMLDivElement, ChatInputTextareaPro
188
221
  contentEditable={
189
222
  <ContentEditable
190
223
  ref={ref}
224
+ data-slot="chat-input-editable"
191
225
  className={cn('min-h-[26px]!', 'overflow-y-auto text-wrap outline-none', className)}
192
226
  aria-label="Chat input"
193
227
  aria-placeholder={placeholder}
@@ -204,8 +238,8 @@ export const ChatInputTextarea = forwardRef<HTMLDivElement, ChatInputTextareaPro
204
238
 
205
239
  <HistoryPlugin />
206
240
  <DisabledPlugin isDisabled={isDisabled} isReadOnly={isReadOnly} />
207
- <ControlledValuePlugin value={value} />
208
- <ValuePlugin onChange={onChange} />
241
+ <ControlledValuePlugin value={value} emittedValuesRef={emittedValuesRef} />
242
+ <ValuePlugin onChange={onChange} emittedValuesRef={emittedValuesRef} />
209
243
  <MarkdownPlainPastePlugin />
210
244
  <HasValuePlugin onHasValueChange={setHasValue} />
211
245
  <FocusPlugin onFocusChange={setIsFocused} />
@@ -1,6 +1,6 @@
1
1
  import { $convertFromMarkdownString, $convertToMarkdownString } from '@lexical/markdown';
2
2
  import { $addUpdateTag, SKIP_DOM_SELECTION_TAG } from 'lexical';
3
- import { useEffect, useRef } from 'react';
3
+ import { type MutableRefObject, useEffect, useRef } from 'react';
4
4
 
5
5
  import { EXPORT_TRANSFORMERS, IMPORT_TRANSFORMERS } from '../transformers';
6
6
 
@@ -9,9 +9,11 @@ import { $setSelectionToEnd } from './utils';
9
9
 
10
10
  interface ControlledValuePluginProps {
11
11
  value?: string;
12
+ /** The values `ValuePlugin` gave to `onChange` that the parent has not rendered back yet. */
13
+ emittedValuesRef?: MutableRefObject<string[]>;
12
14
  }
13
15
 
14
- export function ControlledValuePlugin({ value }: ControlledValuePluginProps) {
16
+ export function ControlledValuePlugin({ value, emittedValuesRef }: ControlledValuePluginProps) {
15
17
  const editor = useChatInputEditor();
16
18
  const previousValueRef = useRef<string | undefined>();
17
19
 
@@ -26,6 +28,17 @@ export function ControlledValuePlugin({ value }: ControlledValuePluginProps) {
26
28
 
27
29
  previousValueRef.current = value;
28
30
 
31
+ // The parent renders back each value `onChange` gave it, and that render can land after later
32
+ // keystrokes. Such a value is an echo of an older edit, not a change to apply: applying it
33
+ // would drop what was typed since.
34
+ if (emittedValuesRef && value !== undefined) {
35
+ const echoIndex = emittedValuesRef.current.lastIndexOf(value);
36
+ emittedValuesRef.current.splice(0, echoIndex === -1 ? Infinity : echoIndex + 1);
37
+ if (echoIndex !== -1) {
38
+ return;
39
+ }
40
+ }
41
+
29
42
  let currentValue = '';
30
43
  editor.getEditorState().read(() => {
31
44
  currentValue = $convertToMarkdownString(EXPORT_TRANSFORMERS);
@@ -41,7 +54,7 @@ export function ControlledValuePlugin({ value }: ControlledValuePluginProps) {
41
54
  { discrete: true },
42
55
  );
43
56
  }
44
- }, [editor, value]);
57
+ }, [editor, value, emittedValuesRef]);
45
58
 
46
59
  return null;
47
60
  }
@@ -1,15 +1,20 @@
1
1
  import { $convertToMarkdownString } from '@lexical/markdown';
2
2
  import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
3
3
  import type { EditorState, LexicalEditor } from 'lexical';
4
- import { useCallback } from 'react';
4
+ import { type MutableRefObject, useCallback } from 'react';
5
5
 
6
6
  import { EXPORT_TRANSFORMERS } from '../transformers';
7
7
 
8
+ /** How many emitted values to remember; a parent that never echoes them back must not grow the list. */
9
+ const MAX_EMITTED_VALUES = 50;
10
+
8
11
  interface ValuePluginProps {
9
12
  onChange?: (value: string) => void;
13
+ /** Receives every value given to `onChange`, so `ControlledValuePlugin` can tell an echo of one. */
14
+ emittedValuesRef?: MutableRefObject<string[]>;
10
15
  }
11
16
 
12
- export function ValuePlugin({ onChange }: ValuePluginProps) {
17
+ export function ValuePlugin({ onChange, emittedValuesRef }: ValuePluginProps) {
13
18
  const handleChange = useCallback(
14
19
  (editorState: EditorState, _editor: LexicalEditor, tags: Set<string>) => {
15
20
  if (tags.has('focus')) {
@@ -22,13 +27,23 @@ export function ValuePlugin({ onChange }: ValuePluginProps) {
22
27
 
23
28
  try {
24
29
  editorState.read(() => {
25
- onChange($convertToMarkdownString(EXPORT_TRANSFORMERS));
30
+ const value = $convertToMarkdownString(EXPORT_TRANSFORMERS);
31
+
32
+ if (emittedValuesRef) {
33
+ emittedValuesRef.current.push(value);
34
+ emittedValuesRef.current.splice(
35
+ 0,
36
+ emittedValuesRef.current.length - MAX_EMITTED_VALUES,
37
+ );
38
+ }
39
+
40
+ onChange(value);
26
41
  });
27
42
  } catch (error) {
28
43
  console.error('ValuePlugin error:', error);
29
44
  }
30
45
  },
31
- [onChange],
46
+ [onChange, emittedValuesRef],
32
47
  );
33
48
 
34
49
  return <OnChangePlugin onChange={handleChange} />;
@@ -0,0 +1,41 @@
1
+ import { Typography } from '@swisper.ai/ui';
2
+
3
+ import { ChatListItem } from '../chat-list-item';
4
+
5
+ import type { Chat } from './types';
6
+
7
+ export interface ChatRowProps {
8
+ chat: Chat;
9
+ isSelected: boolean;
10
+ onOpen: (chatId: string) => void;
11
+ }
12
+
13
+ /** One row of the list: a link to the chat with its title, when it was last updated, and a preview. */
14
+ export function ChatRow({ chat, isSelected, onOpen }: ChatRowProps) {
15
+ return (
16
+ <ChatListItem isSelected={isSelected} asChild>
17
+ <a
18
+ href={`/chat/${chat.chatId}`}
19
+ aria-current={isSelected ? 'page' : undefined}
20
+ className="flex min-w-0 flex-col gap-4 rounded-sm px-12 py-8 hover:bg-secondary-states-hover focus-visible:ring-2 focus-visible:ring-primary-focus-visible focus-visible:ring-inset data-[selected=true]:bg-menuitem-background-active-level1"
21
+ onClick={(event) => {
22
+ // A story has no router: the consumer keeps the open chat in state instead.
23
+ event.preventDefault();
24
+ onOpen(chat.chatId);
25
+ }}
26
+ >
27
+ <span className="flex items-baseline gap-8">
28
+ <Typography variant="body-small-high" className="min-w-0 flex-1 truncate" asChild>
29
+ <span>{chat.title}</span>
30
+ </Typography>
31
+ <Typography variant="caption-md" className="shrink-0 text-text-secondary" asChild>
32
+ <span>{chat.updatedAt}</span>
33
+ </Typography>
34
+ </span>
35
+ <Typography variant="caption-md" className="truncate text-text-secondary" asChild>
36
+ <span>{chat.preview}</span>
37
+ </Typography>
38
+ </a>
39
+ </ChatListItem>
40
+ );
41
+ }
@@ -0,0 +1,94 @@
1
+ import type { Chat, ChatPage } from './types';
2
+
3
+ /** Page size of the sidebar's chats request. */
4
+ export const CHAT_PAGE_SIZE = 12;
5
+
6
+ const CHAT_TOPICS: Pick<Chat, 'title' | 'preview'>[] = [
7
+ { title: 'Train to Zurich on Friday', preview: 'The 07:32 from Bern gets you there by 08:28.' },
8
+ { title: 'Reply to the landlord', preview: 'Here is a shorter version of the second paragraph.' },
9
+ {
10
+ title:
11
+ 'Summary of the quarterly board deck, with the open questions for finance and the follow-ups for the product leads',
12
+ preview: 'Revenue is up 8% on the previous quarter; three questions are still open.',
13
+ },
14
+ { title: 'Dinner ideas for six', preview: 'A lemon risotto works if two guests are vegetarian.' },
15
+ { title: 'Lisbon trip in May', preview: 'I found four direct flights that leave after 17:00.' },
16
+ {
17
+ title: 'Unread email from this morning',
18
+ preview: 'You have 14 unread emails; 3 need a reply.',
19
+ },
20
+ {
21
+ title: 'Birthday present for Nora',
22
+ preview: 'A ceramics course is CHF 180 for four evenings.',
23
+ },
24
+ {
25
+ title: 'Notes from the kickoff call',
26
+ preview: 'Actions: send the timeline, book the workshop.',
27
+ },
28
+ { title: 'Translate the offer to French', preview: 'Voici la traduction de la première page.' },
29
+ { title: 'Health insurance comparison', preview: 'The second model saves about CHF 40 a month.' },
30
+ {
31
+ title: 'Weekend hike near Lucerne',
32
+ preview: 'The Rigi panorama trail takes about three hours.',
33
+ },
34
+ {
35
+ title: 'Agenda for the team offsite',
36
+ preview: 'Day one opens with the roadmap review at 09:00.',
37
+ },
38
+ {
39
+ title: 'Explain a rent reduction request',
40
+ preview: 'You can ask once the reference rate drops.',
41
+ },
42
+ { title: 'Packing list for a ski week', preview: 'Added sunscreen, a spare pair of gloves and…' },
43
+ {
44
+ title: 'Rewrite my LinkedIn summary',
45
+ preview: 'This version leads with the migration project.',
46
+ },
47
+ {
48
+ title: 'Tax deductions for commuting',
49
+ preview: 'Public transport passes are deductible in full.',
50
+ },
51
+ { title: 'Book a table for Thursday', preview: 'The 19:30 slot for four is still free.' },
52
+ { title: 'Compare two phone plans', preview: 'The cheaper plan has no roaming outside Europe.' },
53
+ {
54
+ title: 'Parent-teacher meeting questions',
55
+ preview: 'Start with how the reading group is going.',
56
+ },
57
+ { title: 'Fix the spreadsheet formula', preview: 'The range in column D stops one row short.' },
58
+ ];
59
+
60
+ // The first five chats were updated today and show a time; older ones show day and month.
61
+ const TODAY_TIMES = ['16:42', '14:05', '11:30', '09:12', '08:47'];
62
+ const TODAY = new Date(2026, 9, 3);
63
+
64
+ function formatUpdatedAt(index: number) {
65
+ if (index < TODAY_TIMES.length) {
66
+ return TODAY_TIMES[index];
67
+ }
68
+
69
+ const date = new Date(TODAY);
70
+ date.setDate(TODAY.getDate() - (index - TODAY_TIMES.length + 1));
71
+
72
+ return `${String(date.getDate()).padStart(2, '0')}/${String(date.getMonth() + 1).padStart(2, '0')}`;
73
+ }
74
+
75
+ /** Every chat on the server, newest first: the topics repeat, the ids and dates do not. */
76
+ export const CHATS: Chat[] = Array.from({ length: CHAT_TOPICS.length * 4 }, (_, index) => ({
77
+ ...CHAT_TOPICS[index % CHAT_TOPICS.length],
78
+ chatId: `chat_${String(index + 1).padStart(3, '0')}`,
79
+ updatedAt: formatUpdatedAt(index),
80
+ }));
81
+
82
+ /** What the chats endpoint returns for one page. */
83
+ export function getChatPage(offset: number, limit: number): ChatPage {
84
+ return { chats: CHATS.slice(offset, offset + limit), count: CHATS.length };
85
+ }
86
+
87
+ export const FIRST_CHAT_PAGE: ChatPage = getChatPage(0, CHAT_PAGE_SIZE);
88
+
89
+ /** A page small enough to leave room under it, so the load-more row is in view. */
90
+ export const SHORT_CHAT_PAGE: ChatPage = getChatPage(0, 6);
91
+
92
+ export const ALL_CHATS_PAGE: ChatPage = getChatPage(0, CHATS.length);
93
+
94
+ export const NO_CHATS_PAGE: ChatPage = { chats: [], count: 0 };
@@ -0,0 +1,13 @@
1
+ /** One conversation as the sidebar lists it. `updatedAt` is already formatted the way the row shows it. */
2
+ export interface Chat {
3
+ chatId: string;
4
+ title: string;
5
+ preview: string;
6
+ updatedAt: string;
7
+ }
8
+
9
+ /** One page of the chats endpoint: its rows and the number of chats on the server. */
10
+ export interface ChatPage {
11
+ chats: Chat[];
12
+ count: number;
13
+ }
@@ -5,10 +5,16 @@ import { cn } from '@swisper.ai/web-core';
5
5
 
6
6
  export interface ChatListItemProps extends ComponentPropsWithoutRef<'div'> {
7
7
  children?: ReactNode;
8
+ /** Merges the item's props onto its only child, e.g. a link or a button, without adding a `div`. */
8
9
  asChild?: boolean;
10
+ /** Marks the open conversation: sets `data-selected` and `aria-selected`. */
9
11
  isSelected?: boolean;
10
12
  }
11
13
 
14
+ /**
15
+ * One row's content, returned from the `ChatListItems` render function. It has no role, tab stop or
16
+ * look of its own: render it `asChild` over a link or button and style that from `data-selected`.
17
+ */
12
18
  export const ChatListItem = forwardRef<HTMLDivElement, ChatListItemProps>(function ChatListItem(
13
19
  { children, className, asChild = false, isSelected = false, ...rest },
14
20
  ref,
@@ -9,18 +9,30 @@ import { useChatListContext } from './chat-list';
9
9
  const LOAD_MORE_KEY = 'chat-list-load-more';
10
10
 
11
11
  export interface ChatListItemsProps {
12
+ /** Render function called with each loaded row's index; return a `ChatListItem`. */
12
13
  children: (index: number) => ReactNode;
13
14
  className?: string;
15
+ /** Classes for the `ul` that holds the rows; merged after its defaults. */
14
16
  listClassName?: string;
17
+ /** Classes for every `li`, the load-more row included; merged after its defaults. */
18
+ rowClassName?: string;
19
+ /** First guess of a row's height in pixels; rows are measured after they render. */
15
20
  estimateSize?: number;
21
+ /** Rows rendered beyond the visible ones, above and below. */
16
22
  overscan?: number;
23
+ /** Space between rows, in pixels. */
17
24
  gap?: number;
18
25
  }
19
26
 
27
+ /**
28
+ * The scrolling, virtualised rows of a `ChatList`. While `hasMore` is true it appends one row with
29
+ * the `ChatListLoadMore` content and calls `onLoadMore` when that row comes into range.
30
+ */
20
31
  export const ChatListItems = memo(function ChatListItems({
21
32
  children,
22
33
  className,
23
34
  listClassName,
35
+ rowClassName,
24
36
  estimateSize = 54,
25
37
  overscan = 6,
26
38
  gap = 4,
@@ -104,6 +116,7 @@ export const ChatListItems = memo(function ChatListItems({
104
116
  className={cn('min-h-0 flex-1', 'overflow-auto', className)}
105
117
  >
106
118
  <ul
119
+ data-slot="chat-list-items-list"
107
120
  role="list"
108
121
  aria-label="Chats"
109
122
  className={cn(
@@ -121,11 +134,14 @@ export const ChatListItems = memo(function ChatListItems({
121
134
  return (
122
135
  <li
123
136
  key={virtualItem.key}
137
+ data-slot="chat-list-items-row"
124
138
  data-index={virtualItem.index}
139
+ data-load-more={isLoaderRow}
125
140
  ref={virtualizer.measureElement}
126
141
  role={isLoaderRow ? 'status' : 'listitem'}
127
142
  aria-live={isLoaderRow ? 'polite' : undefined}
128
143
  aria-busy={isLoaderRow ? isLoadingMore : undefined}
144
+ className={rowClassName}
129
145
  style={{
130
146
  position: 'absolute',
131
147
  top: 0,
@@ -2,6 +2,27 @@
2
2
  "$schema": "../../../../int-eslint-config/schemas/component.schema.json",
3
3
  "component": "chat-list",
4
4
  "purpose": "Virtualised, paginated list of the user's conversations for a navigation sidebar, with infinite loading and built-in slots for the first-page skeleton, the load-more row, the empty state and the error state.",
5
+ "anatomy": [
6
+ "import {",
7
+ " ChatList,",
8
+ " ChatListItems,",
9
+ " ChatListItem,",
10
+ " ChatListSkeleton,",
11
+ " ChatListLoadMore,",
12
+ " ChatListEmptyState,",
13
+ " ChatListError,",
14
+ "} from '@swisper.ai/web-chat-ui';",
15
+ "",
16
+ "<ChatList>",
17
+ " <ChatListItems>",
18
+ " <ChatListItem />",
19
+ " </ChatListItems>",
20
+ " <ChatListSkeleton />",
21
+ " <ChatListLoadMore />",
22
+ " <ChatListEmptyState />",
23
+ " <ChatListError />",
24
+ "</ChatList>"
25
+ ],
5
26
  "useWhen": [
6
27
  "A sidebar or drawer lists past conversations to switch between",
7
28
  "The list is long or paginated and loads more pages as the user scrolls",
@@ -47,14 +68,15 @@
47
68
  "getItemKey returns a stable key per index (the chat id), so rows keep their identity as pages load",
48
69
  "hasMore defaults to loadedCount < totalCount, and to false when totalCount is unknown; pass hasMore when the server only says whether another page exists",
49
70
  "While hasMore is true, ChatListItems appends one extra row at the end holding the ChatListLoadMore content",
50
- "onLoadMore fires when the last rendered row reaches the end of the loaded rows, hasMore is true and isLoadingMore is false; set isLoadingMore as soon as the request starts so it isn't called twice",
71
+ "onLoadMore fires when the last rendered row reaches the end of the loaded rows, hasMore is true and isLoadingMore is false; set isLoadingMore as soon as the request starts, and make the handler ignore a call while a request is in flight, because it can fire again before isLoadingMore reaches the list",
51
72
  "isLoading with no loaded rows shows ChatListSkeleton in place of the rows; ChatListSkeleton draws into a container that ChatListItems provides, so both must be rendered",
52
73
  "ChatListSkeleton renders rows default Skeleton rows (title and preview) unless you pass your own children; rows past the list's height are clipped",
53
74
  "ChatListEmptyState shows only when nothing is loaded, nothing is loading and there is no error",
54
75
  "ChatListError shows only when hasError is true and no rows are loaded; a failed later page leaves the loaded rows on screen without an error",
55
76
  "ChatListError renders children, or else the error's message, or \"An error occurred\"",
56
77
  "ChatListLoadMore renders nothing in place; it registers its children as the content of the load-more row",
57
- "Rows are measured after render, so items may vary in height; estimateSize is only the first guess, and gap is the space between rows"
78
+ "Rows are measured after render, so items may vary in height; estimateSize is only the first guess, and gap is the space between rows",
79
+ "Inner elements take their own class props, merged after the defaults: listClassName (the ul) and rowClassName (every li; the load-more row has data-load-more=true) on ChatListItems, rowClassName on ChatListSkeleton's default rows, messageClassName on ChatListError's default message"
58
80
  ]
59
81
  },
60
82
  "composition": {