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

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 (355) 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 +27 -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-list/chat-list-item.d.ts +6 -0
  36. package/dist/components/chat-list/chat-list-item.d.ts.map +1 -1
  37. package/dist/components/chat-list/chat-list-items.d.ts +12 -1
  38. package/dist/components/chat-list/chat-list-items.d.ts.map +1 -1
  39. package/dist/components/chat-list/chat-list.d.ts +36 -2
  40. package/dist/components/chat-list/chat-list.d.ts.map +1 -1
  41. package/dist/components/chat-list/chat-list.stories.d.ts +67 -9
  42. package/dist/components/chat-list/chat-list.stories.d.ts.map +1 -1
  43. package/dist/components/chat-message/chat-message.d.ts +12 -1
  44. package/dist/components/chat-message/chat-message.d.ts.map +1 -1
  45. package/dist/components/chat-message/chat-message.stories.d.ts +31 -0
  46. package/dist/components/chat-message/chat-message.stories.d.ts.map +1 -1
  47. package/dist/components/chat-message/index.d.ts +1 -1
  48. package/dist/components/chat-message/index.d.ts.map +1 -1
  49. package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts +3 -0
  50. package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts.map +1 -1
  51. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts +25 -5
  52. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts.map +1 -1
  53. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts +32 -1
  54. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts.map +1 -1
  55. package/dist/components/chat-message-attachment-card/index.d.ts +2 -2
  56. package/dist/components/chat-message-attachment-card/index.d.ts.map +1 -1
  57. package/dist/components/chat-message-attachment-card/utils.d.ts +1 -0
  58. package/dist/components/chat-message-attachment-card/utils.d.ts.map +1 -1
  59. package/dist/components/chat-message-response/chat-message-response.stories.d.ts +13 -0
  60. package/dist/components/chat-message-response/chat-message-response.stories.d.ts.map +1 -1
  61. package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts +22 -5
  62. package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts.map +1 -1
  63. package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts +42 -0
  64. package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts.map +1 -1
  65. package/dist/components/chat-message-toolbar/index.d.ts +1 -1
  66. package/dist/components/chat-message-toolbar/index.d.ts.map +1 -1
  67. package/dist/components/chat-messages/chat-messages.d.ts +34 -2
  68. package/dist/components/chat-messages/chat-messages.d.ts.map +1 -1
  69. package/dist/components/chat-messages/chat-messages.stories.d.ts +33 -2
  70. package/dist/components/chat-messages/chat-messages.stories.d.ts.map +1 -1
  71. package/dist/components/chat-notification-card/chat-notification-card.d.ts +56 -4
  72. package/dist/components/chat-notification-card/chat-notification-card.d.ts.map +1 -1
  73. package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts +50 -1
  74. package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts.map +1 -1
  75. package/dist/components/chat-notification-popup/chat-notification-popup.d.ts +6 -0
  76. package/dist/components/chat-notification-popup/chat-notification-popup.d.ts.map +1 -1
  77. package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts +43 -1
  78. package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts.map +1 -1
  79. package/dist/components/chat-prompt-box/chat-prompt-box.d.ts +37 -17
  80. package/dist/components/chat-prompt-box/chat-prompt-box.d.ts.map +1 -1
  81. package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts +53 -1
  82. package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts.map +1 -1
  83. package/dist/components/chat-reply/chat-reply.d.ts +11 -0
  84. package/dist/components/chat-reply/chat-reply.d.ts.map +1 -1
  85. package/dist/components/chat-reply/chat-reply.stories.d.ts +23 -0
  86. package/dist/components/chat-reply/chat-reply.stories.d.ts.map +1 -1
  87. package/dist/components/chat-reply/index.d.ts +1 -1
  88. package/dist/components/chat-reply/index.d.ts.map +1 -1
  89. package/dist/components/chat-suggestion/chat-suggestion.d.ts +36 -10
  90. package/dist/components/chat-suggestion/chat-suggestion.d.ts.map +1 -1
  91. package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts +66 -2
  92. package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts.map +1 -1
  93. package/dist/components/chat-suggestion/index.d.ts +2 -1
  94. package/dist/components/chat-suggestion/index.d.ts.map +1 -1
  95. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +26 -1
  96. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -1
  97. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +25 -1
  98. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -1
  99. package/dist/components/chat-thread/chat-thread.d.ts +17 -2
  100. package/dist/components/chat-thread/chat-thread.d.ts.map +1 -1
  101. package/dist/components/chat-thread/chat-thread.stories.d.ts +75 -10
  102. package/dist/components/chat-thread/chat-thread.stories.d.ts.map +1 -1
  103. package/dist/components/index.d.ts +1 -3
  104. package/dist/components/index.d.ts.map +1 -1
  105. package/dist/components/markdown-viewer/markdown-viewer.d.ts +8 -1
  106. package/dist/components/markdown-viewer/markdown-viewer.d.ts.map +1 -1
  107. package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts +18 -1
  108. package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts.map +1 -1
  109. package/dist/components/rich-text-area/rich-text-area.d.ts +17 -0
  110. package/dist/components/rich-text-area/rich-text-area.d.ts.map +1 -1
  111. package/dist/components/rich-text-area/rich-text-area.stories.d.ts +52 -0
  112. package/dist/components/rich-text-area/rich-text-area.stories.d.ts.map +1 -1
  113. package/dist/components/rich-text-area/styled.d.ts +6 -2
  114. package/dist/components/rich-text-area/styled.d.ts.map +1 -1
  115. package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts +9 -2
  116. package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts.map +1 -1
  117. package/dist/components/rich-text-field/components/index.d.ts +5 -5
  118. package/dist/components/rich-text-field/components/index.d.ts.map +1 -1
  119. package/dist/components/rich-text-field/components/text-color-button.d.ts +12 -1
  120. package/dist/components/rich-text-field/components/text-color-button.d.ts.map +1 -1
  121. package/dist/components/rich-text-field/rich-text-field.d.ts +22 -0
  122. package/dist/components/rich-text-field/rich-text-field.d.ts.map +1 -1
  123. package/dist/components/rich-text-field/rich-text-field.stories.d.ts +28 -1
  124. package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -1
  125. package/dist/components/topmenu/index.d.ts +2 -0
  126. package/dist/components/topmenu/index.d.ts.map +1 -0
  127. package/dist/components/topmenu/topmenu.d.ts +22 -0
  128. package/dist/components/topmenu/topmenu.d.ts.map +1 -0
  129. package/dist/components/topmenu/topmenu.stories.d.ts +31 -0
  130. package/dist/components/topmenu/topmenu.stories.d.ts.map +1 -0
  131. package/dist/docs/agent.stories.d.ts.map +1 -1
  132. package/dist/docs/chat-panel.d.ts +7 -5
  133. package/dist/docs/chat-panel.d.ts.map +1 -1
  134. package/dist/docs/chatbot-panel.d.ts.map +1 -1
  135. package/dist/docs/chatbot.stories.d.ts.map +1 -1
  136. package/dist/index.css +1 -1
  137. package/dist/index.es.js +1227 -1260
  138. package/dist/index.es.js.map +1 -1
  139. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +9 -7
  140. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +1 -1
  141. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +37 -9
  142. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +1 -1
  143. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +41 -16
  144. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +1 -1
  145. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +6 -0
  146. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +1 -1
  147. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +22 -1
  148. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +1 -1
  149. package/package.json +15 -9
  150. package/src/__storybook__/parent-block.tsx +21 -0
  151. package/src/components/canvas-shell/__stories__/canvas-panel.tsx +25 -0
  152. package/src/components/canvas-shell/__stories__/document-list.tsx +29 -0
  153. package/src/components/canvas-shell/__stories__/fixtures.ts +222 -0
  154. package/src/components/canvas-shell/__stories__/holdings-table.tsx +56 -0
  155. package/src/components/canvas-shell/__stories__/types.ts +47 -0
  156. package/src/components/canvas-shell/{canvas-shell.test.tsx → __tests__/canvas-shell.spec.tsx} +1 -1
  157. package/src/components/canvas-shell/canvas-shell.json +24 -0
  158. package/src/components/canvas-shell/canvas-shell.stories.tsx +581 -122
  159. package/src/components/canvas-shell/canvas-shell.tsx +44 -17
  160. package/src/components/chat-card/__stories__/fixtures.ts +119 -0
  161. package/src/components/chat-card/__stories__/types.ts +44 -0
  162. package/src/components/chat-card/chat-card.json +67 -3
  163. package/src/components/chat-card/chat-card.stories.tsx +872 -148
  164. package/src/components/chat-card/chat-card.tsx +2 -0
  165. package/src/components/chat-card/components/chat-card-body.tsx +12 -0
  166. package/src/components/chat-card/components/chat-card-footer.tsx +11 -0
  167. package/src/components/chat-card/components/chat-card-form.tsx +21 -2
  168. package/src/components/chat-card/components/chat-card-header.tsx +39 -2
  169. package/src/components/chat-card/contexts.tsx +2 -0
  170. package/src/components/chat-card/hooks.ts +1 -0
  171. package/src/components/chat-card/types.ts +3 -0
  172. package/src/components/chat-card-container/__stories__/fixtures.ts +54 -0
  173. package/src/components/chat-card-container/__stories__/resizable-chat-window.tsx +19 -0
  174. package/src/components/chat-card-container/__stories__/result-card.tsx +31 -0
  175. package/src/components/chat-card-container/__stories__/types.ts +16 -0
  176. package/src/components/chat-card-container/chat-card-container.json +7 -0
  177. package/src/components/chat-card-container/chat-card-container.stories.tsx +209 -56
  178. package/src/components/chat-card-container/chat-card-container.tsx +5 -0
  179. package/src/components/chat-container/__stories__/chat-composer.tsx +67 -0
  180. package/src/components/chat-container/__stories__/fixtures.ts +27 -0
  181. package/src/components/chat-container/__stories__/measure.ts +22 -0
  182. package/src/components/chat-container/__stories__/types.ts +7 -0
  183. package/src/components/chat-container/__stories__/variable-readout.tsx +64 -0
  184. package/src/components/chat-container/chat-container.json +9 -1
  185. package/src/components/chat-container/chat-container.stories.tsx +538 -106
  186. package/src/components/chat-container/chat-container.tsx +3 -0
  187. package/src/components/chat-input/__stories__/fixtures.ts +31 -0
  188. package/src/components/chat-input/chat-input.json +10 -2
  189. package/src/components/chat-input/chat-input.stories.tsx +660 -197
  190. package/src/components/chat-input/chat-input.tsx +32 -2
  191. package/src/components/chat-list/__stories__/chat-row.tsx +41 -0
  192. package/src/components/chat-list/__stories__/fixtures.ts +94 -0
  193. package/src/components/chat-list/__stories__/types.ts +13 -0
  194. package/src/components/chat-list/chat-list-item.tsx +6 -0
  195. package/src/components/chat-list/chat-list-items.tsx +16 -0
  196. package/src/components/chat-list/chat-list.json +24 -2
  197. package/src/components/chat-list/chat-list.stories.tsx +631 -215
  198. package/src/components/chat-list/chat-list.tsx +51 -4
  199. package/src/components/chat-message/__stories__/fixtures.ts +53 -0
  200. package/src/components/chat-message/__stories__/sent-attachment.tsx +22 -0
  201. package/src/components/chat-message/__stories__/tool-steps.tsx +37 -0
  202. package/src/components/chat-message/chat-message.json +10 -1
  203. package/src/components/chat-message/chat-message.stories.tsx +282 -20
  204. package/src/components/chat-message/chat-message.tsx +16 -1
  205. package/src/components/chat-message/index.ts +8 -1
  206. package/src/components/chat-message-attachment-card/__stories__/fixtures.ts +30 -0
  207. package/src/components/chat-message-attachment-card/__stories__/types.ts +14 -0
  208. package/src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx +4 -0
  209. package/src/components/chat-message-attachment-card/chat-message-attachment-card.json +20 -0
  210. package/src/components/chat-message-attachment-card/chat-message-attachment-card.stories.tsx +266 -51
  211. package/src/components/chat-message-attachment-card/chat-message-attachment-card.tsx +37 -4
  212. package/src/components/chat-message-attachment-card/index.ts +6 -0
  213. package/src/components/chat-message-attachment-card/utils.ts +1 -0
  214. package/src/components/chat-message-response/__stories__/fixtures.ts +50 -0
  215. package/src/components/chat-message-response/chat-message-response.json +5 -0
  216. package/src/components/chat-message-response/chat-message-response.stories.tsx +135 -26
  217. package/src/components/chat-message-toolbar/chat-message-toolbar.json +21 -3
  218. package/src/components/chat-message-toolbar/chat-message-toolbar.stories.tsx +377 -6
  219. package/src/components/chat-message-toolbar/chat-message-toolbar.tsx +47 -12
  220. package/src/components/chat-message-toolbar/index.ts +4 -0
  221. package/src/components/chat-messages/__stories__/conversation-frame.tsx +25 -0
  222. package/src/components/chat-messages/__stories__/conversation-group.tsx +22 -0
  223. package/src/components/chat-messages/__stories__/fixtures.ts +70 -0
  224. package/src/components/chat-messages/__stories__/types.ts +5 -0
  225. package/src/components/chat-messages/chat-messages.json +30 -12
  226. package/src/components/chat-messages/chat-messages.stories.tsx +439 -212
  227. package/src/components/chat-messages/chat-messages.tsx +46 -3
  228. package/src/components/chat-notification-card/__stories__/fixtures.ts +38 -0
  229. package/src/components/chat-notification-card/__stories__/types.ts +13 -0
  230. package/src/components/chat-notification-card/chat-notification-card.json +52 -2
  231. package/src/components/chat-notification-card/chat-notification-card.stories.tsx +542 -62
  232. package/src/components/chat-notification-card/chat-notification-card.tsx +97 -6
  233. package/src/components/chat-notification-popup/__stories__/fixtures.ts +36 -0
  234. package/src/components/chat-notification-popup/__stories__/notification-item.tsx +93 -0
  235. package/src/components/chat-notification-popup/__stories__/types.ts +14 -0
  236. package/src/components/chat-notification-popup/chat-notification-popup.json +14 -1
  237. package/src/components/chat-notification-popup/chat-notification-popup.stories.tsx +467 -17
  238. package/src/components/chat-notification-popup/chat-notification-popup.tsx +18 -3
  239. package/src/components/chat-prompt-box/__stories__/fixtures.ts +16 -0
  240. package/src/components/chat-prompt-box/__stories__/types.ts +8 -0
  241. package/src/components/chat-prompt-box/chat-prompt-box.json +25 -2
  242. package/src/components/chat-prompt-box/chat-prompt-box.stories.tsx +535 -43
  243. package/src/components/chat-prompt-box/chat-prompt-box.tsx +73 -19
  244. package/src/components/chat-reply/chat-reply.json +10 -0
  245. package/src/components/chat-reply/chat-reply.stories.tsx +264 -21
  246. package/src/components/chat-reply/chat-reply.tsx +15 -0
  247. package/src/components/chat-reply/index.ts +10 -1
  248. package/src/components/chat-suggestion/__stories__/fixtures.ts +16 -0
  249. package/src/components/chat-suggestion/__tests__/chat-suggestion.spec.tsx +185 -0
  250. package/src/components/chat-suggestion/chat-suggestion.json +62 -20
  251. package/src/components/chat-suggestion/chat-suggestion.stories.tsx +542 -58
  252. package/src/components/chat-suggestion/chat-suggestion.tsx +154 -65
  253. package/src/components/chat-suggestion/index.ts +9 -0
  254. package/src/components/chat-thinking-process/__stories__/fixtures.ts +56 -0
  255. package/src/components/chat-thinking-process/chat-thinking-process.json +28 -3
  256. package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +354 -78
  257. package/src/components/chat-thinking-process/chat-thinking-process.tsx +55 -4
  258. package/src/components/chat-thread/__stories__/fixtures.ts +171 -0
  259. package/src/components/chat-thread/__stories__/scroll-position.ts +9 -0
  260. package/src/components/chat-thread/__stories__/snippets.ts +129 -0
  261. package/src/components/chat-thread/__stories__/thread-frame.tsx +22 -0
  262. package/src/components/chat-thread/__stories__/thread-turns.tsx +35 -0
  263. package/src/components/chat-thread/__stories__/types.ts +12 -0
  264. package/src/components/chat-thread/__stories__/use-turn-stream.ts +78 -0
  265. package/src/components/chat-thread/chat-thread.json +23 -3
  266. package/src/components/chat-thread/chat-thread.stories.tsx +804 -142
  267. package/src/components/chat-thread/chat-thread.tsx +64 -16
  268. package/src/components/index.ts +1 -3
  269. package/src/components/markdown-viewer/__stories__/fixtures.ts +67 -0
  270. package/src/components/markdown-viewer/markdown-viewer.json +7 -1
  271. package/src/components/markdown-viewer/markdown-viewer.stories.tsx +219 -50
  272. package/src/components/markdown-viewer/markdown-viewer.tsx +9 -0
  273. package/src/components/rich-text-area/__stories__/fixtures.ts +30 -0
  274. package/src/components/rich-text-area/rich-text-area.json +6 -4
  275. package/src/components/rich-text-area/rich-text-area.stories.tsx +597 -41
  276. package/src/components/rich-text-area/rich-text-area.tsx +22 -1
  277. package/src/components/rich-text-area/styled.tsx +11 -5
  278. package/src/components/rich-text-field/__stories__/fixtures.ts +29 -0
  279. package/src/components/rich-text-field/components/formatting-toolbar-plugin.tsx +10 -1
  280. package/src/components/rich-text-field/components/index.ts +8 -5
  281. package/src/components/rich-text-field/components/text-color-button.tsx +16 -2
  282. package/src/components/rich-text-field/rich-text-field.json +3 -1
  283. package/src/components/rich-text-field/rich-text-field.stories.tsx +452 -61
  284. package/src/components/rich-text-field/rich-text-field.tsx +23 -0
  285. package/src/components/topmenu/index.ts +1 -0
  286. package/src/components/topmenu/topmenu.json +107 -0
  287. package/src/components/topmenu/topmenu.stories.tsx +334 -0
  288. package/src/components/topmenu/topmenu.tsx +71 -0
  289. package/src/docs/agent.stories.tsx +16 -16
  290. package/src/docs/chat-panel.tsx +37 -32
  291. package/src/docs/chatbot-panel.tsx +11 -2
  292. package/src/docs/chatbot.mdx +17 -12
  293. package/src/docs/chatbot.stories.tsx +7 -8
  294. package/src/layouts/chat-card-list-layout/__stories__/fixtures.ts +112 -0
  295. package/src/layouts/chat-card-list-layout/__stories__/result-card.tsx +36 -0
  296. package/src/layouts/chat-card-list-layout/__stories__/types.ts +31 -0
  297. package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +14 -1
  298. package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +316 -84
  299. package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +11 -7
  300. package/src/layouts/chat-card-three-column-layout/__stories__/fixtures.ts +117 -0
  301. package/src/layouts/chat-card-three-column-layout/__stories__/resizable-chat-window.tsx +18 -0
  302. package/src/layouts/chat-card-three-column-layout/__stories__/stay-details.tsx +85 -0
  303. package/src/layouts/chat-card-three-column-layout/__stories__/stay-list.tsx +50 -0
  304. package/src/layouts/chat-card-three-column-layout/__stories__/stay-map.tsx +44 -0
  305. package/src/layouts/chat-card-three-column-layout/__stories__/stay-rooms.tsx +61 -0
  306. package/src/layouts/chat-card-three-column-layout/__stories__/types.ts +35 -0
  307. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +16 -0
  308. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +603 -182
  309. package/src/layouts/chat-card-two-column-layout/__stories__/connection-itinerary.tsx +51 -0
  310. package/src/layouts/chat-card-two-column-layout/__stories__/fixtures.ts +83 -0
  311. package/src/layouts/chat-card-two-column-layout/__stories__/route-map.tsx +24 -0
  312. package/src/layouts/chat-card-two-column-layout/__stories__/types.ts +15 -0
  313. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +13 -1
  314. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +368 -67
  315. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +11 -2
  316. package/dist/components/card-item-picker/card-item-picker-context.d.ts +0 -21
  317. package/dist/components/card-item-picker/card-item-picker-context.d.ts.map +0 -1
  318. package/dist/components/card-item-picker/card-item-picker-list.d.ts +0 -24
  319. package/dist/components/card-item-picker/card-item-picker-list.d.ts.map +0 -1
  320. package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts +0 -28
  321. package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts.map +0 -1
  322. package/dist/components/card-item-picker/card-item-picker-row.d.ts +0 -12
  323. package/dist/components/card-item-picker/card-item-picker-row.d.ts.map +0 -1
  324. package/dist/components/card-item-picker/card-item-picker.stories.d.ts +0 -19
  325. package/dist/components/card-item-picker/card-item-picker.stories.d.ts.map +0 -1
  326. package/dist/components/card-item-picker/index.d.ts +0 -9
  327. package/dist/components/card-item-picker/index.d.ts.map +0 -1
  328. package/dist/components/chat-message-history/chat-message-history.d.ts +0 -48
  329. package/dist/components/chat-message-history/chat-message-history.d.ts.map +0 -1
  330. package/dist/components/chat-message-history/chat-message-history.stories.d.ts +0 -7
  331. package/dist/components/chat-message-history/chat-message-history.stories.d.ts.map +0 -1
  332. package/dist/components/chat-message-history/index.d.ts +0 -2
  333. package/dist/components/chat-message-history/index.d.ts.map +0 -1
  334. package/dist/components/spinner/index.d.ts +0 -2
  335. package/dist/components/spinner/index.d.ts.map +0 -1
  336. package/dist/components/spinner/spinner.d.ts +0 -9
  337. package/dist/components/spinner/spinner.d.ts.map +0 -1
  338. package/dist/components/spinner/spinner.stories.d.ts +0 -8
  339. package/dist/components/spinner/spinner.stories.d.ts.map +0 -1
  340. package/src/components/card-item-picker/__tests__/card-item-picker.spec.tsx +0 -279
  341. package/src/components/card-item-picker/card-item-picker-context.tsx +0 -44
  342. package/src/components/card-item-picker/card-item-picker-list.tsx +0 -95
  343. package/src/components/card-item-picker/card-item-picker-row-parts.tsx +0 -96
  344. package/src/components/card-item-picker/card-item-picker-row.tsx +0 -109
  345. package/src/components/card-item-picker/card-item-picker.json +0 -147
  346. package/src/components/card-item-picker/card-item-picker.stories.tsx +0 -158
  347. package/src/components/card-item-picker/index.ts +0 -24
  348. package/src/components/chat-message-history/chat-message-history.json +0 -99
  349. package/src/components/chat-message-history/chat-message-history.stories.tsx +0 -136
  350. package/src/components/chat-message-history/chat-message-history.tsx +0 -277
  351. package/src/components/chat-message-history/index.ts +0 -13
  352. package/src/components/spinner/index.ts +0 -1
  353. package/src/components/spinner/spinner.json +0 -73
  354. package/src/components/spinner/spinner.stories.tsx +0 -41
  355. package/src/components/spinner/spinner.tsx +0 -32
@@ -1,46 +1,22 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { expect } from 'storybook/test';
2
3
 
4
+ import { ParentBlock } from '../../__storybook__/parent-block';
3
5
  import {
4
- ChatCard,
5
- ChatCardBody,
6
- ChatCardContent,
7
- ChatCardHeader,
8
- ChatCardHeaderContent,
9
- ChatCardTitle,
10
- } from '../chat-card';
6
+ ChatCardListLayout,
7
+ ChatCardListLayoutItems,
8
+ ChatCardListLayoutShowMore,
9
+ } from '../../layouts/chat-card-list-layout';
11
10
  import { ChatContainer } from '../chat-container';
11
+ import { ChatMessage, ChatMessageContent } from '../chat-message';
12
12
 
13
+ import { NEWS_ARTICLES, TRAIN_CONNECTIONS, WEATHER_SUMMARY } from './__stories__/fixtures';
14
+ import { ResizableChatWindow } from './__stories__/resizable-chat-window';
15
+ import { ResultCard } from './__stories__/result-card';
13
16
  import { ChatCardContainer } from './chat-card-container';
14
17
 
15
- /**
16
- * The `md` breakpoint is 820px in this design system, so the resize handle has to be
17
- * dragged across that width for the variants to separate.
18
- */
19
- function ResizableChatWindow({ children }: { children: React.ReactNode }) {
20
- return (
21
- <div className="resize-x overflow-auto min-w-[320px] max-w-full w-[900px] border border-dashed border-steel-700 p-0">
22
- <ChatContainer className="h-auto py-16">{children}</ChatContainer>
23
- </div>
24
- );
25
- }
26
-
27
- function DemoCard({ title, children }: { title: string; children: React.ReactNode }) {
28
- return (
29
- <ChatCard fullWidth>
30
- <ChatCardHeader>
31
- <ChatCardHeaderContent>
32
- <ChatCardTitle>{title}</ChatCardTitle>
33
- </ChatCardHeaderContent>
34
- </ChatCardHeader>
35
- <ChatCardBody>
36
- <ChatCardContent>{children}</ChatCardContent>
37
- </ChatCardBody>
38
- </ChatCard>
39
- );
40
- }
41
-
42
18
  const meta: Meta<typeof ChatCardContainer> = {
43
- title: 'Chatbot/ChatCardContainer',
19
+ title: 'Chat/ChatCardContainer',
44
20
  component: ChatCardContainer,
45
21
  tags: ['autodocs'],
46
22
  parameters: { layout: 'padded' },
@@ -60,11 +36,11 @@ const meta: Meta<typeof ChatCardContainer> = {
60
36
  },
61
37
  children: {
62
38
  control: false,
63
- description: 'The card to size, usually a `ChatCard`.',
39
+ description: 'The card to size: a `ChatCard`, or a `ChatCardListLayout` of cards.',
64
40
  },
65
41
  className: {
66
42
  control: 'text',
67
- description: 'Extra classes merged onto the wrapper.',
43
+ description: 'Extra classes merged last onto the wrapper.',
68
44
  },
69
45
  },
70
46
  args: {
@@ -76,35 +52,96 @@ const meta: Meta<typeof ChatCardContainer> = {
76
52
  export default meta;
77
53
  type Story = StoryObj<typeof ChatCardContainer>;
78
54
 
55
+ /** A train connection as one card of a result list. */
56
+ function ConnectionCards() {
57
+ return (
58
+ <ChatCardListLayout visibleCount={2} className="flex flex-col gap-8">
59
+ <ChatCardListLayoutItems>
60
+ {TRAIN_CONNECTIONS.map((connection) => (
61
+ <ResultCard key={connection.train} title={`${connection.train}, ${connection.route}`}>
62
+ {connection.departure} to {connection.arrival}, {connection.duration}, from{' '}
63
+ {connection.price}.
64
+ </ResultCard>
65
+ ))}
66
+ </ChatCardListLayoutItems>
67
+ <ChatCardListLayoutShowMore>Show more</ChatCardListLayoutShowMore>
68
+ </ChatCardListLayout>
69
+ );
70
+ }
71
+
72
+ /**
73
+ * One card in the default `fixed` variant: it fills a narrow chat window and stops growing at
74
+ * the reading column in a wide one.
75
+ */
76
+ export const Default: Story = {
77
+ render: (args) => (
78
+ <ResizableChatWindow>
79
+ <ChatCardContainer {...args}>
80
+ <ResultCard title="Weather in Zurich">{WEATHER_SUMMARY}</ResultCard>
81
+ </ChatCardContainer>
82
+ </ResizableChatWindow>
83
+ ),
84
+ };
85
+
79
86
  /**
80
87
  * Drag the right edge past 820px: `fixed` stops growing at the reading column
81
88
  * (736 − 16 = 720px), `fluid` hugs its content, `full` keeps tracking the window.
82
89
  */
83
90
  export const Variants: Story = {
91
+ parameters: { controls: { disable: true } },
84
92
  render: () => (
85
93
  <ResizableChatWindow>
86
94
  <div className="flex flex-col gap-16">
87
95
  <ChatCardContainer variant="fixed">
88
- <DemoCard title="fixed">
89
- Clamped to the reading column above md, so it lines up with message text.
90
- </DemoCard>
96
+ <ResultCard title="Email draft">
97
+ To mara.keller@company.com. Subject: Agenda for the offsite on 14 November.
98
+ </ResultCard>
91
99
  </ChatCardContainer>
92
100
 
93
101
  <ChatCardContainer variant="fluid">
94
- <DemoCard title="fluid">Shrinks to content.</DemoCard>
102
+ <ResultCard title="Table">Zurich HB to Bern, 56 min.</ResultCard>
95
103
  </ChatCardContainer>
96
104
 
97
105
  <ChatCardContainer variant="fluid">
98
- <DemoCard title="fluid">
99
- Shrinks to content.
100
- <div className="w-[800px] h-[80px] bg-red-500" />
101
- </DemoCard>
106
+ <ResultCard title="Table">
107
+ <table className="w-200 text-left">
108
+ <thead>
109
+ <tr>
110
+ <th className="p-8">Train</th>
111
+ <th className="p-8">Route</th>
112
+ <th className="p-8">Departure</th>
113
+ <th className="p-8">Arrival</th>
114
+ <th className="p-8">Platform</th>
115
+ <th className="p-8">Price</th>
116
+ </tr>
117
+ </thead>
118
+ <tbody>
119
+ {TRAIN_CONNECTIONS.map((connection) => (
120
+ <tr key={connection.train}>
121
+ <td className="p-8">{connection.train}</td>
122
+ <td className="p-8">{connection.route}</td>
123
+ <td className="p-8">{connection.departure}</td>
124
+ <td className="p-8">{connection.arrival}</td>
125
+ <td className="p-8">{connection.platform ?? 'Not announced'}</td>
126
+ <td className="p-8">{connection.price}</td>
127
+ </tr>
128
+ ))}
129
+ </tbody>
130
+ </table>
131
+ </ResultCard>
102
132
  </ChatCardContainer>
103
133
 
104
134
  <ChatCardContainer variant="full">
105
- <DemoCard title="full">
106
- Always the full chat window width, less one --spacing-message gutter.
107
- </DemoCard>
135
+ <ResultCard title="Top stories">
136
+ <ul className="grid grid-cols-3 gap-16">
137
+ {NEWS_ARTICLES.map((article) => (
138
+ <li key={article.id} className="flex flex-col gap-4">
139
+ <span className="text-text-tertiary">{article.source}</span>
140
+ <span>{article.headline}</span>
141
+ </li>
142
+ ))}
143
+ </ul>
144
+ </ResultCard>
108
145
  </ChatCardContainer>
109
146
  </div>
110
147
  </ResizableChatWindow>
@@ -113,9 +150,11 @@ export const Variants: Story = {
113
150
 
114
151
  /**
115
152
  * The inlined card must sit at the same visual inset as the text around it — one
116
- * `--spacing-message` gutter, not two. Compare the card's left edge to the paragraphs.
153
+ * `--spacing-message` gutter, not two. Drag the window below 820px and compare the card's left
154
+ * edge to the paragraphs; above that, `fixed` also centres the card in the reading column.
117
155
  */
118
156
  export const Inline: Story = {
157
+ parameters: { controls: { disable: true } },
119
158
  render: () => (
120
159
  <ResizableChatWindow>
121
160
  <div className="flex flex-col gap-8">
@@ -124,7 +163,7 @@ export const Inline: Story = {
124
163
  </p>
125
164
 
126
165
  <ChatCardContainer variant="fixed" inline>
127
- <DemoCard title="Weather">Partly cloudy, 18°C, light wind from the north-west.</DemoCard>
166
+ <ResultCard title="Weather in Zurich">{WEATHER_SUMMARY}</ResultCard>
128
167
  </ChatCardContainer>
129
168
 
130
169
  <p className="px-message text-text-secondary">
@@ -135,15 +174,129 @@ export const Inline: Story = {
135
174
  ),
136
175
  };
137
176
 
177
+ /** Checks that an inline `full` card starts at the same left edge as the message text around it. */
178
+ export const InlineAlignsWithText: Story = {
179
+ tags: ['e2e', '!autodocs'],
180
+ parameters: { controls: { disable: true } },
181
+ render: () => (
182
+ <ResizableChatWindow>
183
+ <div className="flex flex-col gap-8">
184
+ <p className="px-message text-text-secondary">These are the connections I found.</p>
185
+
186
+ <ChatCardContainer variant="full" inline>
187
+ <ResultCard title="Trains to Geneva">3 connections tomorrow morning.</ResultCard>
188
+ </ChatCardContainer>
189
+ </div>
190
+ </ResizableChatWindow>
191
+ ),
192
+ play: async ({ canvas, step }) => {
193
+ const paragraph = canvas.getByText('These are the connections I found.');
194
+ // TODO(echo-ds): the wrapper is a plain div with no role or name, so it is found by its slot.
195
+ const container = canvas
196
+ .getByText('Trains to Geneva')
197
+ .closest<HTMLElement>('[data-slot="chat-card-container"]');
198
+
199
+ await step('Publishes its props as data attributes', async () => {
200
+ await expect(container).toHaveAttribute('data-variant', 'full');
201
+ await expect(container).toHaveAttribute('data-inline', 'true');
202
+ });
203
+
204
+ await step('Insets the card by one message gutter, like the text', async () => {
205
+ const card = container?.firstElementChild;
206
+ const textLeft =
207
+ paragraph.getBoundingClientRect().left +
208
+ parseFloat(getComputedStyle(paragraph).paddingLeft);
209
+
210
+ await expect(card?.getBoundingClientRect().left).toBeCloseTo(textLeft, 0);
211
+ });
212
+ },
213
+ };
214
+
215
+ /** The container in each parent it's allowed in, then in a chat message list and a message body. */
216
+ export const Examples: Story = {
217
+ parameters: { controls: { disable: true } },
218
+ render: () => (
219
+ <div className="flex flex-col gap-24">
220
+ <ParentBlock parent="web-chat-ui/chat-container">
221
+ <ChatContainer className="h-auto">
222
+ <ChatCardContainer>
223
+ <ResultCard title="Weather in Zurich">{WEATHER_SUMMARY}</ResultCard>
224
+ </ChatCardContainer>
225
+ </ChatContainer>
226
+ </ParentBlock>
227
+
228
+ <ParentBlock parent="web-chat-ui/ChatMessageContent">
229
+ <ChatContainer className="h-auto">
230
+ <ChatMessage>
231
+ <ChatMessageContent className="flex w-full flex-col gap-8">
232
+ <p className="px-message text-text-secondary">
233
+ I drafted the invitation. Review it before I send it.
234
+ </p>
235
+ <ChatCardContainer inline>
236
+ <ResultCard title="Email draft">
237
+ To mara.keller@company.com. Subject: Agenda for the offsite on 14 November.
238
+ </ResultCard>
239
+ </ChatCardContainer>
240
+ </ChatMessageContent>
241
+ </ChatMessage>
242
+ </ChatContainer>
243
+ </ParentBlock>
244
+
245
+ <ParentBlock parent="chat message list">
246
+ <ChatContainer className="h-auto">
247
+ <section aria-label="Chat message list" className="flex flex-col gap-16">
248
+ <ChatMessage isQuestion className="px-message">
249
+ <ChatMessageContent>Find me a train to Geneva tomorrow morning</ChatMessageContent>
250
+ </ChatMessage>
251
+ <ChatCardContainer>
252
+ <ConnectionCards />
253
+ </ChatCardContainer>
254
+ </section>
255
+ </ChatContainer>
256
+ </ParentBlock>
257
+
258
+ <ParentBlock parent="chat message body">
259
+ <ChatContainer className="h-auto">
260
+ <div aria-label="Chat message body" role="group" className="flex flex-col gap-8">
261
+ <p className="px-message text-text-secondary">
262
+ Here is the forecast you asked about for the rest of the week.
263
+ </p>
264
+ <ChatCardContainer inline>
265
+ <ResultCard title="Weather in Zurich">{WEATHER_SUMMARY}</ResultCard>
266
+ </ChatCardContainer>
267
+ <p className="px-message text-text-secondary">
268
+ Let me know if you want the hourly breakdown instead.
269
+ </p>
270
+ </div>
271
+ </ChatContainer>
272
+ </ParentBlock>
273
+ </div>
274
+ ),
275
+ };
276
+
277
+ /** Both props and both kinds of content on the Controls panel; drag the right edge to resize the chat window. */
138
278
  export const Playground: Story = {
139
- args: { variant: 'fixed', inline: false },
279
+ tags: ['!autodocs'],
280
+ args: {
281
+ variant: 'fixed',
282
+ inline: false,
283
+ className: '',
284
+ children: 'Card list',
285
+ },
286
+ argTypes: {
287
+ children: {
288
+ control: 'select',
289
+ options: ['Card', 'Card list'],
290
+ mapping: {
291
+ Card: <ResultCard title="Weather in Zurich">{WEATHER_SUMMARY}</ResultCard>,
292
+ 'Card list': <ConnectionCards />,
293
+ },
294
+ description: 'What the container sizes: one `ChatCard`, or a `ChatCardListLayout` of cards.',
295
+ },
296
+ },
140
297
  render: (args) => (
141
298
  <ResizableChatWindow>
142
- <ChatCardContainer {...args}>
143
- <DemoCard title={`variant="${args.variant}" inline={${String(args.inline)}}`}>
144
- Resize the dashed wrapper to see how this variant responds.
145
- </DemoCard>
146
- </ChatCardContainer>
299
+ <ChatCardContainer {...args} />
147
300
  </ResizableChatWindow>
148
301
  ),
149
302
  };
@@ -2,8 +2,10 @@ import type { ComponentProps, ReactNode } from 'react';
2
2
 
3
3
  import { cn } from '@swisper.ai/web-core';
4
4
 
5
+ /** @deprecated Use `FlexibleContainerVariant` from `@swisper.ai/cards-ui`. */
5
6
  export type ChatCardContainerVariant = 'fixed' | 'fluid' | 'full';
6
7
 
8
+ /** @deprecated Use `FlexibleContainerProps` from `@swisper.ai/cards-ui`. */
7
9
  export interface ChatCardContainerProps extends ComponentProps<'div'> {
8
10
  children: ReactNode;
9
11
  /**
@@ -43,6 +45,8 @@ export interface ChatCardContainerProps extends ComponentProps<'div'> {
43
45
  * Both variables are read with a `100%` fallback, so a card rendered outside a
44
46
  * `ChatContainer` (a portal, a test, a Storybook story) degrades to its parent's width
45
47
  * instead of collapsing to zero.
48
+ *
49
+ * @deprecated Use `FlexibleContainer` from `@swisper.ai/cards-ui`.
46
50
  */
47
51
  export function ChatCardContainer({
48
52
  children,
@@ -53,6 +57,7 @@ export function ChatCardContainer({
53
57
  }: ChatCardContainerProps) {
54
58
  return (
55
59
  <div
60
+ data-slot="chat-card-container"
56
61
  data-testid="chat-card-container"
57
62
  data-variant={variant}
58
63
  data-inline={inline}
@@ -0,0 +1,67 @@
1
+ import { useState, type KeyboardEvent } from 'react';
2
+
3
+ import { EnterIcon } from '@swisper.ai/icons';
4
+ import { IconButton } from '@swisper.ai/ui';
5
+
6
+ import {
7
+ ChatPromptBox,
8
+ ChatPromptBoxActionsRight,
9
+ ChatPromptBoxContent,
10
+ ChatPromptBoxInput,
11
+ } from '../../chat-prompt-box';
12
+
13
+ export interface ChatComposerProps {
14
+ placeholder?: string;
15
+ onSend?: (message: string) => void;
16
+ }
17
+
18
+ /**
19
+ * The composer a chat page puts in `ChatContainerPrompt`: a prompt box that grows with its text,
20
+ * sends on Enter or the send button and then empties.
21
+ */
22
+ export function ChatComposer({ placeholder = 'How can I help?', onSend }: ChatComposerProps) {
23
+ const [message, setMessage] = useState('');
24
+ const canSend = message.trim().length > 0;
25
+
26
+ const send = () => {
27
+ if (!canSend) {
28
+ return;
29
+ }
30
+
31
+ onSend?.(message.trim());
32
+ setMessage('');
33
+ };
34
+
35
+ // Enter sends, Shift+Enter keeps the editor's new line.
36
+ const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
37
+ if (event.key === 'Enter' && !event.shiftKey) {
38
+ event.preventDefault();
39
+ send();
40
+ }
41
+ };
42
+
43
+ return (
44
+ <ChatPromptBox>
45
+ <ChatPromptBoxContent>
46
+ <ChatPromptBoxInput
47
+ value={message}
48
+ placeholder={placeholder}
49
+ autoFocus={false}
50
+ onChange={setMessage}
51
+ onKeyDown={handleKeyDown}
52
+ />
53
+ <ChatPromptBoxActionsRight aria-label="Message actions">
54
+ <IconButton
55
+ size="md"
56
+ variant="primary"
57
+ aria-label="Send message"
58
+ isDisabled={!canSend}
59
+ onClick={send}
60
+ >
61
+ <EnterIcon />
62
+ </IconButton>
63
+ </ChatPromptBoxActionsRight>
64
+ </ChatPromptBoxContent>
65
+ </ChatPromptBox>
66
+ );
67
+ }
@@ -0,0 +1,27 @@
1
+ import type { InboxEmail } from './types';
2
+
3
+ /** The five custom properties a `ChatContainer` publishes, in the order the docs list them. */
4
+ export const PUBLISHED_VARIABLES = [
5
+ '--chat-window-width',
6
+ '--chat-window-height',
7
+ '--message-list-content-width',
8
+ '--type-window-height',
9
+ '--welcome-screen-box-height',
10
+ ] as const;
11
+
12
+ // The inbox beside the chat. The last subject is long enough to truncate in a narrow pane.
13
+ export const INBOX_EMAILS: InboxEmail[] = [
14
+ {
15
+ id: 'mail_01',
16
+ sender: 'Facilities team',
17
+ subject: 'Office move on Friday',
18
+ receivedAt: '09:12',
19
+ },
20
+ { id: 'mail_02', sender: 'Noa Keller', subject: 'Desk allocation', receivedAt: '08:40' },
21
+ {
22
+ id: 'mail_03',
23
+ sender: 'Building services',
24
+ subject: 'Access badges for the fourth floor need to be collected before Thursday afternoon',
25
+ receivedAt: 'Mon',
26
+ },
27
+ ];
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Resolves a CSS length the way a descendant of `container` would, in pixels.
3
+ *
4
+ * `getPropertyValue` returns a custom property unresolved (`min(736px, 900px)`), so this sizes a
5
+ * throwaway child with the value and measures it.
6
+ *
7
+ * Call it outside `waitFor`: the probe is a DOM mutation, and `waitFor` reruns on every mutation.
8
+ */
9
+ export function resolveLength(container: HTMLElement, value: string): number {
10
+ const probe = document.createElement('div');
11
+
12
+ probe.style.position = 'absolute';
13
+ probe.style.visibility = 'hidden';
14
+ probe.style.width = value;
15
+ container.appendChild(probe);
16
+
17
+ const { width } = probe.getBoundingClientRect();
18
+
19
+ probe.remove();
20
+
21
+ return Math.round(width);
22
+ }
@@ -0,0 +1,7 @@
1
+ /** One row of the inbox beside the chat in a split pane. */
2
+ export interface InboxEmail {
3
+ id: string;
4
+ sender: string;
5
+ subject: string;
6
+ receivedAt: string;
7
+ }
@@ -0,0 +1,64 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+
3
+ import { Typography } from '@swisper.ai/ui';
4
+
5
+ import { PUBLISHED_VARIABLES } from './fixtures';
6
+
7
+ /**
8
+ * Reads the variables off an element inside the container. Custom properties inherit, so this
9
+ * shows what a real descendant resolves them to.
10
+ *
11
+ * It polls on each animation frame: a custom property has no change event, and this exists only
12
+ * to make the contract visible in Storybook.
13
+ */
14
+ export function VariableReadout() {
15
+ const ref = useRef<HTMLDListElement>(null);
16
+ const [values, setValues] = useState<Record<string, string>>({});
17
+
18
+ useEffect(() => {
19
+ let frame = requestAnimationFrame(function read() {
20
+ const element = ref.current;
21
+
22
+ if (element) {
23
+ const styles = getComputedStyle(element);
24
+ const next: Record<string, string> = {};
25
+
26
+ for (const name of PUBLISHED_VARIABLES) {
27
+ next[name] = styles.getPropertyValue(name).trim() || '—';
28
+ }
29
+
30
+ setValues((current) =>
31
+ PUBLISHED_VARIABLES.every((name) => current[name] === next[name]) ? current : next,
32
+ );
33
+ }
34
+
35
+ frame = requestAnimationFrame(read);
36
+ });
37
+
38
+ return () => cancelAnimationFrame(frame);
39
+ }, []);
40
+
41
+ return (
42
+ <dl
43
+ ref={ref}
44
+ aria-label="Published variables"
45
+ className="m-message grid shrink-0 grid-cols-[auto_1fr] gap-x-16 gap-y-1"
46
+ >
47
+ {PUBLISHED_VARIABLES.map((name) => (
48
+ <div key={name} className="contents">
49
+ <Typography
50
+ variant="caption-md"
51
+ fontFamily="mono"
52
+ className="text-text-secondary"
53
+ asChild
54
+ >
55
+ <dt>{name}</dt>
56
+ </Typography>
57
+ <Typography variant="caption-md" fontFamily="mono" className="m-0" asChild>
58
+ <dd>{values[name] ?? '—'}</dd>
59
+ </Typography>
60
+ </div>
61
+ ))}
62
+ </dl>
63
+ );
64
+ }
@@ -2,6 +2,14 @@
2
2
  "$schema": "../../../../int-eslint-config/schemas/component.schema.json",
3
3
  "component": "chat-container",
4
4
  "purpose": "Root of a chat surface that measures its own box and publishes the chat window width, height, reading-column width and the composer and welcome-box heights as CSS custom properties, so descendants size themselves against the chat window without prop drilling.",
5
+ "anatomy": [
6
+ "import { ChatContainer, ChatContainerWelcome, ChatContainerPrompt } from '@swisper.ai/web-chat-ui';",
7
+ "",
8
+ "<ChatContainer>",
9
+ " <ChatContainerWelcome />",
10
+ " <ChatContainerPrompt />",
11
+ "</ChatContainer>"
12
+ ],
5
13
  "useWhen": [
6
14
  "Wrapping a full chat surface whose cards and layouts size against the chat window (web-chat-ui/chat-card-container, the chat-card layouts)",
7
15
  "The message list has to reserve room for a composer that grows as the user types, or for a welcome box shown on an empty chat",
@@ -10,7 +18,7 @@
10
18
  "avoidWhen": [
11
19
  "A side-panel assistant with a header, scrolling conversation and footer — use web-chat-ui/canvas-shell with web-chat-ui/chat-thread instead",
12
20
  "You only need a scrolling list of messages — use web-chat-ui/chat-thread; ChatContainer does not scroll",
13
- "A generic page or card layout outside chat — use plain layout or ui/surface"
21
+ "A generic page or card layout outside chat — use plain layout or ui/card"
14
22
  ],
15
23
  "uxPrinciples": [
16
24
  "Keep the reading column a comfortable line length (the chat-area token, 736px) and let it shrink with narrow windows rather than overflow.",