@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,19 +1,37 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { useState } from 'react';
2
+ import { useId, useState } from 'react';
3
+ import type { ReactNode } from 'react';
4
+ import { expect, fn, waitFor, within } from 'storybook/test';
3
5
 
4
- import { Button } from '@swisper.ai/ui';
6
+ import { HomeIcon } from '@swisper.ai/icons';
7
+ import { Typography } from '@swisper.ai/ui';
5
8
 
9
+ import { ParentBlock } from '../../__storybook__/parent-block';
6
10
  import {
7
11
  ChatCard,
12
+ ChatCardActions,
8
13
  ChatCardBody,
14
+ ChatCardCollapsibleButton,
9
15
  ChatCardContent,
16
+ ChatCardFooter,
17
+ ChatCardFooterNotes,
10
18
  ChatCardHeader,
11
19
  ChatCardHeaderContent,
20
+ ChatCardIcon,
21
+ ChatCardSubTitle,
12
22
  ChatCardTitle,
13
23
  } from '../../components/chat-card';
14
24
  import { ChatCardContainer } from '../../components/chat-card-container';
15
25
  import { ChatContainer } from '../../components/chat-container';
26
+ import { ChatMessage, ChatMessageContent } from '../../components/chat-message';
16
27
 
28
+ import { FEATURED_STAY, ROOM_RATES, STAYS } from './__stories__/fixtures';
29
+ import { ResizableChatWindow } from './__stories__/resizable-chat-window';
30
+ import { StayDetails } from './__stories__/stay-details';
31
+ import { StayList } from './__stories__/stay-list';
32
+ import { StayMap } from './__stories__/stay-map';
33
+ import { StayRooms } from './__stories__/stay-rooms';
34
+ import type { Stay } from './__stories__/types';
17
35
  import {
18
36
  ChatCardThreeColumnLayout,
19
37
  ChatCardThreeColumnLayoutDetails,
@@ -21,143 +39,22 @@ import {
21
39
  ChatCardThreeColumnLayoutMain,
22
40
  ChatCardThreeColumnLayoutPanel,
23
41
  } from './chat-card-three-column-layout';
24
- import type { ChatCardThreeColumnLayoutDetailsPlacement } from './chat-card-three-column-layout.variants';
42
+ import type { ChatCardThreeColumnLayoutProps } from './chat-card-three-column-layout';
25
43
  import { chatCardThreeColumnLayoutCardVariants } from './chat-card-three-column-layout.variants';
26
-
27
- const PLACES = [
28
- 'Café Sprüngli',
29
- 'Kronenhalle',
30
- 'Zeughauskeller',
31
- 'Hiltl',
32
- 'Haus Hiltl',
33
- 'Rheinfelder',
34
- ];
35
-
36
- function Placeholder({ label, className = '' }: { label: string; className?: string }) {
37
- return (
38
- <div
39
- className={`flex h-full w-full items-center justify-center rounded-[8px] border border-dashed border-card-border-base text-sm ${className}`}
40
- >
41
- {label}
42
- </div>
43
- );
44
- }
45
-
46
- function List({ isFloating, onOpen }: { isFloating: boolean; onOpen: (place: string) => void }) {
47
- if (isFloating) {
48
- return (
49
- <ul className="flex gap-[8px] overflow-x-auto p-[12px]">
50
- {PLACES.map((place) => (
51
- <li key={place} className="shrink-0">
52
- <Button size="sm" variant="secondary" onClick={() => onOpen(place)}>
53
- {place}
54
- </Button>
55
- </li>
56
- ))}
57
- </ul>
58
- );
59
- }
60
-
61
- return (
62
- <ul className="flex h-full flex-col gap-[8px] overflow-y-auto">
63
- {PLACES.map((place) => (
64
- <li key={place}>
65
- <Button size="sm" variant="tertiary" onClick={() => onOpen(place)}>
66
- {place}
67
- </Button>
68
- </li>
69
- ))}
70
- </ul>
71
- );
72
- }
73
-
74
- function PlacesExample({
75
- detailsPlacement,
76
- initialDetails = null,
77
- initialPanel = null,
78
- }: {
79
- detailsPlacement?: ChatCardThreeColumnLayoutDetailsPlacement;
80
- initialDetails?: string | null;
81
- initialPanel?: string | null;
82
- }) {
83
- const [details, setDetails] = useState<string | null>(initialDetails);
84
- const [panel, setPanel] = useState<string | null>(initialPanel);
85
-
86
- return (
87
- <ChatContainer className="h-auto py-16">
88
- {/* `full`: the card's minimum widths go past the default reading column */}
89
- <ChatCardContainer variant="full">
90
- <ChatCard className={chatCardThreeColumnLayoutCardVariants()}>
91
- <ChatCardHeader>
92
- <ChatCardHeaderContent>
93
- <ChatCardTitle>Restaurants in Zurich</ChatCardTitle>
94
- </ChatCardHeaderContent>
95
- </ChatCardHeader>
96
- <ChatCardBody>
97
- <ChatCardContent>
98
- <ChatCardThreeColumnLayout
99
- detailsPlacement={detailsPlacement}
100
- className="h-[480px] md:h-[600px]"
101
- >
102
- <ChatCardThreeColumnLayoutList>
103
- {(isFloating) => <List isFloating={isFloating} onOpen={setDetails} />}
104
- </ChatCardThreeColumnLayoutList>
105
-
106
- <ChatCardThreeColumnLayoutMain>
107
- <Placeholder label="Map" className="bg-card-background-lvl-2" />
108
- </ChatCardThreeColumnLayoutMain>
109
-
110
- {details && (
111
- <ChatCardThreeColumnLayoutDetails>
112
- {(isFloating) => (
113
- <div className="flex h-full flex-col gap-[8px] rounded-[8px] bg-card-background-base p-[12px] shadow-md">
114
- <div className="flex items-center justify-between">
115
- <strong>{details}</strong>
116
- <Button size="sm" variant="tertiary" onClick={() => setDetails(null)}>
117
- Close
118
- </Button>
119
- </div>
120
- <span className="text-sm">
121
- {isFloating ? 'Floating over the map' : 'In its own column'}
122
- </span>
123
- <Button size="sm" variant="secondary" onClick={() => setPanel(details)}>
124
- All reviews
125
- </Button>
126
- </div>
127
- )}
128
- </ChatCardThreeColumnLayoutDetails>
129
- )}
130
-
131
- {panel && (
132
- <ChatCardThreeColumnLayoutPanel>
133
- <div className="flex h-full flex-col gap-[8px] overflow-y-auto rounded-[8px] bg-card-background-base p-[12px] shadow-md">
134
- <div className="flex items-center justify-between">
135
- <strong>Reviews of {panel}</strong>
136
- <Button size="sm" variant="tertiary" onClick={() => setPanel(null)}>
137
- Close
138
- </Button>
139
- </div>
140
- <span className="text-sm">
141
- Covers everything but the List column. The map and Details are still mounted
142
- underneath.
143
- </span>
144
- </div>
145
- </ChatCardThreeColumnLayoutPanel>
146
- )}
147
- </ChatCardThreeColumnLayout>
148
- </ChatCardContent>
149
- </ChatCardBody>
150
- </ChatCard>
151
- </ChatCardContainer>
152
- </ChatContainer>
153
- );
154
- }
44
+ import type { ChatCardThreeColumnLayoutDetailsPlacement } from './chat-card-three-column-layout.variants';
155
45
 
156
46
  const meta: Meta<typeof ChatCardThreeColumnLayout> = {
157
- title: 'Chatbot/ChatCardThreeColumnLayout',
47
+ title: 'Chat/ChatCardThreeColumnLayout',
158
48
  component: ChatCardThreeColumnLayout,
159
49
  tags: ['autodocs'],
160
50
  parameters: { layout: 'fullscreen' },
51
+ decorators: [
52
+ (Story) => (
53
+ <div className="py-16">
54
+ <Story />
55
+ </div>
56
+ ),
57
+ ],
161
58
  argTypes: {
162
59
  detailsPlacement: {
163
60
  control: 'inline-radio',
@@ -174,7 +71,7 @@ const meta: Meta<typeof ChatCardThreeColumnLayout> = {
174
71
  className: {
175
72
  control: 'text',
176
73
  description:
177
- 'Classes for the root. Set the height here (e.g. `h-[480px]`); the layout sets none.',
74
+ 'Classes for the root. Set the height here (e.g. `h-120 md:h-150`); the layout sets none.',
178
75
  },
179
76
  asChild: {
180
77
  control: false,
@@ -184,6 +81,7 @@ const meta: Meta<typeof ChatCardThreeColumnLayout> = {
184
81
  },
185
82
  args: {
186
83
  detailsPlacement: 'responsive',
84
+ className: 'h-120 md:h-150',
187
85
  asChild: false,
188
86
  },
189
87
  };
@@ -191,83 +89,606 @@ const meta: Meta<typeof ChatCardThreeColumnLayout> = {
191
89
  export default meta;
192
90
  type Story = StoryObj<typeof ChatCardThreeColumnLayout>;
193
91
 
92
+ interface StayCardProps {
93
+ title: string;
94
+ subTitle: string;
95
+ isDefaultOpen?: boolean;
96
+ /** The card's `ChatCardBody`. */
97
+ children: ReactNode;
98
+ }
99
+
194
100
  /**
195
- * The places card. Below 698px the list becomes a swipe strip over the map, and its render
196
- * prop swaps the content; from 698px it is a 290px column, and from 1132px a 358px one.
197
- * Click a place to open Details: it floats over the map until 1132px, then takes a 358px
198
- * third column. All thresholds are the layout's own width, not the viewport's.
101
+ * The card around the layout. Both settings matter: `variant="full"` lets the card grow past the
102
+ * reading column, and the card recipe gives a grid of `1fr` tracks a width to fill.
103
+ */
104
+ function StayCard({ title, subTitle, isDefaultOpen = true, children }: StayCardProps) {
105
+ const titleId = useId();
106
+
107
+ return (
108
+ <ChatCardContainer variant="full">
109
+ <ChatCard
110
+ aria-labelledby={titleId}
111
+ defaultOpen={isDefaultOpen}
112
+ className={chatCardThreeColumnLayoutCardVariants()}
113
+ >
114
+ <ChatCardHeader>
115
+ <ChatCardIcon>
116
+ <HomeIcon />
117
+ </ChatCardIcon>
118
+ <ChatCardHeaderContent>
119
+ <ChatCardTitle id={titleId}>{title}</ChatCardTitle>
120
+ <ChatCardSubTitle>{subTitle}</ChatCardSubTitle>
121
+ </ChatCardHeaderContent>
122
+ <ChatCardActions>
123
+ <ChatCardCollapsibleButton aria-label="Collapse or expand the places to stay" />
124
+ </ChatCardActions>
125
+ </ChatCardHeader>
126
+ {children}
127
+ </ChatCard>
128
+ </ChatCardContainer>
129
+ );
130
+ }
131
+
132
+ interface StaySearchCardProps extends Omit<ChatCardThreeColumnLayoutProps, 'children'> {
133
+ /** The property whose Details are open on mount; `null` opens at the list. */
134
+ initialStayId?: string | null;
135
+ /** Whether the rooms Panel is open on mount. It needs an open property. */
136
+ isRoomsInitiallyOpen?: boolean;
137
+ /** Whether the card starts expanded. */
138
+ isDefaultOpen?: boolean;
139
+ }
140
+
141
+ /**
142
+ * An accommodation search: the places as a list, their prices on a map, and the open place in
143
+ * Details. "Check other rooms" opens the rooms in the Panel, over the map and Details.
144
+ */
145
+ function StaySearchCard({
146
+ initialStayId = null,
147
+ isRoomsInitiallyOpen = false,
148
+ isDefaultOpen,
149
+ ...layoutProps
150
+ }: StaySearchCardProps) {
151
+ const [stayId, setStayId] = useState<string | null>(initialStayId);
152
+ const [isRoomsOpen, setIsRoomsOpen] = useState(isRoomsInitiallyOpen);
153
+ const stay = STAYS.find((candidate) => candidate.id === stayId) ?? null;
154
+
155
+ return (
156
+ <StayCard
157
+ title="Places to stay in Zurich"
158
+ subTitle="12–15 Nov · 2 adults"
159
+ isDefaultOpen={isDefaultOpen}
160
+ >
161
+ <ChatCardBody>
162
+ <ChatCardContent>
163
+ <ChatCardThreeColumnLayout {...layoutProps}>
164
+ <ChatCardThreeColumnLayoutList aria-label="Places to stay">
165
+ {(isFloating) => (
166
+ <StayList
167
+ stays={STAYS}
168
+ isFloating={isFloating}
169
+ selectedId={stayId}
170
+ onOpen={setStayId}
171
+ />
172
+ )}
173
+ </ChatCardThreeColumnLayoutList>
174
+
175
+ {/* `asChild`: the chat page already has a `<main>` landmark. */}
176
+ <ChatCardThreeColumnLayoutMain asChild>
177
+ <section aria-label="Map of available properties">
178
+ <StayMap stays={STAYS} selectedId={stayId} onOpen={setStayId} />
179
+ </section>
180
+ </ChatCardThreeColumnLayoutMain>
181
+
182
+ {/* Mounted only with a place open: an empty Details would reserve a blank column. */}
183
+ {stay && (
184
+ <ChatCardThreeColumnLayoutDetails aria-label={`Details for ${stay.name}`}>
185
+ {(isFloating) => (
186
+ <StayDetails
187
+ stay={stay}
188
+ isFloating={isFloating}
189
+ onClose={() => setStayId(null)}
190
+ onCheckRooms={() => setIsRoomsOpen(true)}
191
+ />
192
+ )}
193
+ </ChatCardThreeColumnLayoutDetails>
194
+ )}
195
+
196
+ {stay && isRoomsOpen && (
197
+ <ChatCardThreeColumnLayoutPanel aria-label={`Rooms at ${stay.name}`}>
198
+ <StayRooms stay={stay} rates={ROOM_RATES} onBack={() => setIsRoomsOpen(false)} />
199
+ </ChatCardThreeColumnLayoutPanel>
200
+ )}
201
+ </ChatCardThreeColumnLayout>
202
+ </ChatCardContent>
203
+ </ChatCardBody>
204
+ </StayCard>
205
+ );
206
+ }
207
+
208
+ /**
209
+ * An accommodation search. Below 698px of layout width the list is a swipe strip over the map,
210
+ * and its render prop swaps the content; from 698px it is a 290px column, and from 1132px a
211
+ * 358px one. Open a place for its Details: they float over the map until 1132px, then take a
212
+ * 358px third column. Every threshold is the layout's own width, not the viewport's.
199
213
  */
200
214
  export const Default: Story = {
201
- render: () => <PlacesExample />,
215
+ render: (args) => (
216
+ <ChatContainer className="h-auto">
217
+ <StaySearchCard {...args} />
218
+ </ChatContainer>
219
+ ),
202
220
  };
203
221
 
204
- /** Details always floats over Main, even on a wide screen. */
222
+ /** Details always floats over Main, even in a wide chat window. */
205
223
  export const DetailsFloating: Story = {
206
- render: () => <PlacesExample detailsPlacement="floating" initialDetails="Kronenhalle" />,
224
+ args: { detailsPlacement: 'floating' },
225
+ render: (args) => (
226
+ <ChatContainer className="h-auto">
227
+ <StaySearchCard {...args} initialStayId={FEATURED_STAY.id} />
228
+ </ChatContainer>
229
+ ),
207
230
  };
208
231
 
209
232
  /**
210
- * Panel covers everything but the List column, and the whole layout when List floats
211
- * (below 698px). Main and Details stay mounted under it: close it and the open place is
212
- * still there. Open it again from Details with "All reviews".
233
+ * Panel covers everything but the List column, and the whole layout when List floats (below
234
+ * 698px). Main and Details stay mounted under it: go back and the open place is still there.
235
+ * Open it again from Details with "Check other rooms".
213
236
  */
214
237
  export const Panel: Story = {
215
- render: () => <PlacesExample initialDetails="Kronenhalle" initialPanel="Kronenhalle" />,
238
+ render: (args) => (
239
+ <ChatContainer className="h-auto">
240
+ <StaySearchCard {...args} initialStayId={FEATURED_STAY.id} isRoomsInitiallyOpen />
241
+ </ChatContainer>
242
+ ),
216
243
  };
217
244
 
218
245
  /** Drag the right edge across 698px: the Panel grows over the List once it floats. */
219
246
  export const PanelResizable: Story = {
220
- render: () => (
221
- <div
222
- className="border border-dashed border-card-border-base"
223
- style={{
224
- resize: 'horizontal',
225
- overflow: 'auto',
226
- width: 900,
227
- minWidth: 360,
228
- maxWidth: '100%',
229
- }}
230
- >
231
- <PlacesExample initialDetails="Hiltl" initialPanel="Hiltl" />
232
- </div>
247
+ render: (args) => (
248
+ <ResizableChatWindow>
249
+ <ChatContainer className="h-auto">
250
+ <StaySearchCard {...args} initialStayId="seefeld-garden" isRoomsInitiallyOpen />
251
+ </ChatContainer>
252
+ </ResizableChatWindow>
233
253
  ),
234
254
  };
235
255
 
236
256
  /**
237
- * Collapse the card from its header: the minimum widths are gated on `data-state=open`, so
238
- * the collapsed card shrinks back to its header.
257
+ * A card that starts collapsed. The card's minimum width is gated on `data-state=open`, so the
258
+ * collapsed card is only as wide as the reading column; expand it from the header and it takes
259
+ * the chat window's width.
239
260
  */
240
261
  export const CollapsedCard: Story = {
241
- render: () => <PlacesExample initialDetails="Hiltl" />,
262
+ render: (args) => (
263
+ <ChatContainer className="h-auto">
264
+ <StaySearchCard {...args} initialStayId="seefeld-garden" isDefaultOpen={false} />
265
+ </ChatContainer>
266
+ ),
242
267
  };
243
268
 
244
269
  /**
245
- * Drag the dashed wrapper's right edge. The panes switch on the layout's own width: List
246
- * becomes a 290px column at 698px, and at 1132px List widens to 358px and Details takes
247
- * its 358px column, with the render-prop text changing at
248
- * the same moment. No window resize needed, which is the point: the viewport never changes
249
- * here.
270
+ * Drag the dashed window's right edge. The panes switch on the layout's own width: List becomes
271
+ * a 290px column at 698px, and at 1132px List widens to 358px and Details takes its 358px
272
+ * column, with the render-prop content changing at the same moment. No browser resize needed,
273
+ * which is the point: the viewport never changes here.
250
274
  */
251
275
  export const ResizableContainer: Story = {
276
+ render: (args) => (
277
+ <ResizableChatWindow>
278
+ <ChatContainer className="h-auto">
279
+ <StaySearchCard {...args} initialStayId={FEATURED_STAY.id} />
280
+ </ChatContainer>
281
+ </ResizableChatWindow>
282
+ ),
283
+ };
284
+
285
+ /** Opens a place from the list and from the map, then closes Details, which unmounts the pane. */
286
+ export const DefaultOpenAndCloseDetails: Story = {
287
+ ...Default,
288
+ tags: ['e2e', '!autodocs'],
289
+ play: async ({ canvas, userEvent, step }) => {
290
+ const list = within(canvas.getByRole('complementary', { name: 'Places to stay' }));
291
+ const map = within(canvas.getByRole('region', { name: 'Map of available properties' }));
292
+
293
+ await step('Starts at the list, with no Details pane', async () => {
294
+ await expect(canvas.queryByRole('complementary', { name: /details for/i })).toBeNull();
295
+ await expect(map.getByText('1 of these has no map location')).toBeVisible();
296
+ });
297
+
298
+ await step('A row opens its place in Details', async () => {
299
+ await userEvent.click(list.getByRole('button', { name: /seefeld garden hotel/i }));
300
+ const details = within(
301
+ await canvas.findByRole('complementary', { name: 'Details for Seefeld Garden Hotel' }),
302
+ );
303
+ await expect(details.getByText('CHF 825 total · 3 nights')).toBeVisible();
304
+ await expect(list.getByRole('button', { name: /seefeld garden hotel/i })).toHaveAttribute(
305
+ 'aria-pressed',
306
+ 'true',
307
+ );
308
+ });
309
+
310
+ await step('A pin swaps the place in the same pane', async () => {
311
+ await userEvent.click(map.getByRole('button', { name: /wiedikon loft house/i }));
312
+ await expect(
313
+ canvas.getByRole('complementary', { name: 'Details for Wiedikon Loft House' }),
314
+ ).toBeVisible();
315
+ await expect(canvas.getAllByRole('complementary', { name: /details for/i })).toHaveLength(1);
316
+ });
317
+
318
+ await step('Closing unmounts Details', async () => {
319
+ await userEvent.click(canvas.getByRole('button', { name: 'Close details' }));
320
+ await expect(canvas.queryByRole('complementary', { name: /details for/i })).toBeNull();
321
+ });
322
+ },
323
+ };
324
+
325
+ /** Closes the rooms Panel and checks that the map and the open place were mounted under it all along. */
326
+ export const PanelBackKeepsDetails: Story = {
327
+ ...Panel,
328
+ tags: ['e2e', '!autodocs'],
329
+ play: async ({ canvas, userEvent, step }) => {
330
+ const map = canvas.getByRole('region', { name: 'Map of available properties' });
331
+
332
+ await step('The Panel covers the map while Details stays mounted', async () => {
333
+ const panel = canvas.getByRole('region', { name: 'Rooms at Hotel Limmatblick' });
334
+ await expect(within(panel).getByText('Junior suite')).toBeVisible();
335
+ await expect(
336
+ canvas.getByRole('complementary', { name: 'Details for Hotel Limmatblick' }),
337
+ ).toBeInTheDocument();
338
+
339
+ const panelBox = panel.getBoundingClientRect();
340
+ const mapBox = map.getBoundingClientRect();
341
+ await expect(Math.round(panelBox.left)).toBeLessThanOrEqual(Math.round(mapBox.left));
342
+ await expect(Math.round(panelBox.right)).toBeGreaterThanOrEqual(Math.round(mapBox.right));
343
+ await expect(Math.round(panelBox.height)).toBe(Math.round(mapBox.height));
344
+ });
345
+
346
+ await step('Going back leaves the same map and the same open place', async () => {
347
+ await userEvent.click(canvas.getByRole('button', { name: 'Back to the property' }));
348
+ await expect(canvas.queryByRole('region', { name: /rooms at/i })).toBeNull();
349
+ await expect(canvas.getByRole('region', { name: 'Map of available properties' })).toBe(map);
350
+ await expect(
351
+ canvas.getByRole('complementary', { name: 'Details for Hotel Limmatblick' }),
352
+ ).toBeVisible();
353
+ });
354
+
355
+ await step('Details opens the Panel again', async () => {
356
+ await userEvent.click(canvas.getByRole('button', { name: 'Check other rooms' }));
357
+ await expect(
358
+ canvas.getByRole('region', { name: 'Rooms at Hotel Limmatblick' }),
359
+ ).toBeVisible();
360
+ });
361
+ },
362
+ };
363
+
364
+ /** Resizes the chat window through the tiers and checks where each pane is drawn and what its render prop shows. */
365
+ export const ResizableContainerSwitchesPanes: Story = {
366
+ ...ResizableContainer,
367
+ tags: ['e2e', '!autodocs'],
368
+ play: async ({ canvas, step }) => {
369
+ const chatWindow = canvas.getByRole('group', { name: 'Resizable chat window' });
370
+ const list = canvas.getByRole('complementary', { name: 'Places to stay' });
371
+ const map = canvas.getByRole('region', { name: 'Map of available properties' });
372
+ const details = canvas.getByRole('complementary', { name: 'Details for Hotel Limmatblick' });
373
+
374
+ const box = (element: HTMLElement) => {
375
+ const rect = element.getBoundingClientRect();
376
+ return {
377
+ left: Math.round(rect.left),
378
+ right: Math.round(rect.right),
379
+ top: Math.round(rect.top),
380
+ bottom: Math.round(rect.bottom),
381
+ width: Math.round(rect.width),
382
+ height: Math.round(rect.height),
383
+ };
384
+ };
385
+ const rowTops = () =>
386
+ within(list)
387
+ .getAllByRole('button')
388
+ .slice(0, 2)
389
+ .map((row) => box(row).top);
390
+
391
+ // The window is capped at 100% of the page, which in a test run is narrower than the tiers.
392
+ chatWindow.style.maxWidth = 'none';
393
+
394
+ await step('lg: List is a 290px column and Details floats at Main’s right edge', async () => {
395
+ chatWindow.style.width = '1000px';
396
+ await waitFor(() => expect(list).toHaveAttribute('data-floating', 'false'));
397
+ await waitFor(() => expect(box(list).width).toBe(290));
398
+ await expect(box(list).right).toBeLessThanOrEqual(box(map).left);
399
+ await expect(details).toHaveAttribute('data-floating', 'true');
400
+ await expect(details).toHaveAttribute('data-sheet', 'false');
401
+ await expect(box(details).width).toBe(358);
402
+ await expect(box(details).right).toBe(box(map).right);
403
+ // The column's render prop draws the rows one under the other.
404
+ const [first, second] = rowTops();
405
+ await expect(second).toBeGreaterThan(first ?? 0);
406
+ });
407
+
408
+ await step('xl: List widens to 358px and Details takes its own column', async () => {
409
+ chatWindow.style.width = '1400px';
410
+ await waitFor(() => expect(details).toHaveAttribute('data-floating', 'false'));
411
+ await waitFor(() => expect(box(list).width).toBe(358));
412
+ await expect(box(details).width).toBe(358);
413
+ await expect(box(details).left).toBeGreaterThanOrEqual(box(map).right);
414
+ });
415
+
416
+ await step('sm: List is a strip over Main and Details a bottom sheet', async () => {
417
+ chatWindow.style.width = '600px';
418
+ await waitFor(() => expect(list).toHaveAttribute('data-floating', 'true'));
419
+ await expect(details).toHaveAttribute('data-sheet', 'true');
420
+ await waitFor(() => expect(box(list).bottom).toBe(box(map).bottom));
421
+ await expect(box(list).width).toBe(box(map).width);
422
+ await expect(box(details).width).toBe(box(map).width);
423
+ await expect(box(details).bottom).toBe(box(map).bottom);
424
+ await expect(box(details).height).toBe(Math.round(box(map).height * 0.85));
425
+ // The strip's render prop draws the rows side by side.
426
+ const [first, second] = rowTops();
427
+ await expect(second).toBe(first);
428
+ });
429
+ },
430
+ };
431
+
432
+ /** Expands the collapsed card from its header and checks it only then claims the chat window's width. */
433
+ export const CollapsedCardExpands: Story = {
434
+ ...CollapsedCard,
435
+ tags: ['e2e', '!autodocs'],
436
+ play: async ({ canvas, userEvent, step }) => {
437
+ const card = canvas.getByRole('region', { name: 'Places to stay in Zurich' });
438
+ const collapsedMinWidth = getComputedStyle(card).minWidth;
439
+
440
+ await step('Starts as a header, with no layout and no minimum width', async () => {
441
+ await expect(card).toHaveAttribute('data-state', 'closed');
442
+ await expect(
443
+ canvas.queryByRole('region', { name: 'Map of available properties' }),
444
+ ).toBeNull();
445
+ await expect(Number.parseFloat(collapsedMinWidth) || 0).toBe(0);
446
+ });
447
+
448
+ await step('Expanding mounts the layout and holds the card at the window’s width', async () => {
449
+ await userEvent.click(canvas.getByText('Places to stay in Zurich'));
450
+ await expect(card).toHaveAttribute('data-state', 'open');
451
+ await expect(
452
+ await canvas.findByRole('region', { name: 'Map of available properties' }),
453
+ ).toBeVisible();
454
+ await expect(
455
+ canvas.getByRole('complementary', { name: 'Details for Seefeld Garden Hotel' }),
456
+ ).toBeVisible();
457
+ await expect(Number.parseFloat(getComputedStyle(card).minWidth)).toBeGreaterThan(0);
458
+ });
459
+ },
460
+ };
461
+
462
+ /** The layout in each place it's allowed: a card's content, a card body with a note and a footer around it, and a chat thread. */
463
+ export const Examples: Story = {
464
+ parameters: { controls: { disable: true } },
252
465
  render: () => (
253
- <div
254
- className="border border-dashed border-card-border-base"
255
- style={{
256
- resize: 'horizontal',
257
- overflow: 'auto',
258
- width: 900,
259
- minWidth: 360,
260
- maxWidth: '100%',
261
- }}
262
- >
263
- <PlacesExample initialDetails="Kronenhalle" />
466
+ <div className="flex flex-col gap-24">
467
+ <ParentBlock parent="web-chat-ui/ChatCardContent">
468
+ <ChatContainer className="h-auto">
469
+ <StayCard title={FEATURED_STAY.name} subTitle="Hotel · Zurich">
470
+ <ChatCardBody>
471
+ <ChatCardContent>
472
+ <ChatCardThreeColumnLayout className="h-100">
473
+ <ChatCardThreeColumnLayoutList aria-label="Places to stay">
474
+ {(isFloating) => (
475
+ <StayList
476
+ stays={[FEATURED_STAY]}
477
+ isFloating={isFloating}
478
+ selectedId={FEATURED_STAY.id}
479
+ onOpen={fn()}
480
+ />
481
+ )}
482
+ </ChatCardThreeColumnLayoutList>
483
+ <ChatCardThreeColumnLayoutMain asChild>
484
+ <section aria-label="Map of the property">
485
+ <StayMap
486
+ stays={[FEATURED_STAY]}
487
+ selectedId={FEATURED_STAY.id}
488
+ onOpen={fn()}
489
+ />
490
+ </section>
491
+ </ChatCardThreeColumnLayoutMain>
492
+ {/* A card about one property: Details is its content, so it is always mounted. */}
493
+ <ChatCardThreeColumnLayoutDetails
494
+ aria-label={`Details for ${FEATURED_STAY.name}`}
495
+ >
496
+ {(isFloating) => <StayDetails stay={FEATURED_STAY} isFloating={isFloating} />}
497
+ </ChatCardThreeColumnLayoutDetails>
498
+ </ChatCardThreeColumnLayout>
499
+ </ChatCardContent>
500
+ </ChatCardBody>
501
+ </StayCard>
502
+ </ChatContainer>
503
+ </ParentBlock>
504
+
505
+ <ParentBlock parent="chat card body">
506
+ <ChatContainer className="h-auto">
507
+ <StayCard title="Places to stay in Zurich" subTitle="12–15 Nov · 2 adults">
508
+ <ChatCardBody>
509
+ <ChatCardContent className="flex flex-col gap-8">
510
+ <Typography variant="caption-md" className="text-text-tertiary">
511
+ Prices as they were on this search. Restore it to check them again.
512
+ </Typography>
513
+ <ChatCardThreeColumnLayout className="h-100">
514
+ <ChatCardThreeColumnLayoutList aria-label="Places to stay">
515
+ {(isFloating) => (
516
+ <StayList
517
+ stays={STAYS}
518
+ isFloating={isFloating}
519
+ selectedId={FEATURED_STAY.id}
520
+ onOpen={fn()}
521
+ />
522
+ )}
523
+ </ChatCardThreeColumnLayoutList>
524
+ <ChatCardThreeColumnLayoutMain asChild>
525
+ <section aria-label="Map of available properties">
526
+ <StayMap stays={STAYS} selectedId={FEATURED_STAY.id} onOpen={fn()} />
527
+ </section>
528
+ </ChatCardThreeColumnLayoutMain>
529
+ </ChatCardThreeColumnLayout>
530
+ </ChatCardContent>
531
+ <ChatCardFooter>
532
+ <ChatCardFooterNotes>
533
+ <Typography variant="body-small-high" fontWeight="semibold">
534
+ {FEATURED_STAY.name}
535
+ </Typography>
536
+ <Typography variant="caption-md" className="text-text-secondary">
537
+ 1 × Double room · {FEATURED_STAY.total} total
538
+ </Typography>
539
+ </ChatCardFooterNotes>
540
+ </ChatCardFooter>
541
+ </ChatCardBody>
542
+ </StayCard>
543
+ </ChatContainer>
544
+ </ParentBlock>
545
+
546
+ <ParentBlock parent="chat thread">
547
+ <ChatContainer className="h-auto gap-16">
548
+ <ChatMessage isQuestion className="px-message">
549
+ <ChatMessageContent>
550
+ Find me a place to stay in Zurich from 12 to 15 November, for two adults.
551
+ </ChatMessageContent>
552
+ </ChatMessage>
553
+ <ChatMessage className="px-message">
554
+ <ChatMessageContent>
555
+ Here are five places with a room free on those dates. Open one for its rates.
556
+ </ChatMessageContent>
557
+ </ChatMessage>
558
+ <StaySearchCard className="h-100" />
559
+ </ChatContainer>
560
+ </ParentBlock>
264
561
  </div>
265
562
  ),
266
563
  };
267
564
 
268
- export const Playground: Story = {
269
- args: { detailsPlacement: 'responsive' },
270
- render: (args) => (
271
- <PlacesExample detailsPlacement={args.detailsPlacement} initialDetails="Zeughauskeller" />
272
- ),
565
+ interface ChatCardThreeColumnLayoutPlaygroundProps {
566
+ detailsPlacement: ChatCardThreeColumnLayoutDetailsPlacement;
567
+ className: string;
568
+ chatWindowWidth: number;
569
+ stayCount: number;
570
+ hasDetails: boolean;
571
+ hasPanel: boolean;
572
+ onOpenStay: (stayId: string) => void;
573
+ onCloseDetails: () => void;
574
+ onCheckRooms: () => void;
575
+ onCloseRooms: () => void;
576
+ }
577
+
578
+ function ChatCardThreeColumnLayoutPlayground({
579
+ detailsPlacement,
580
+ className,
581
+ chatWindowWidth,
582
+ stayCount,
583
+ hasDetails,
584
+ hasPanel,
585
+ onOpenStay,
586
+ onCloseDetails,
587
+ onCheckRooms,
588
+ onCloseRooms,
589
+ }: ChatCardThreeColumnLayoutPlaygroundProps) {
590
+ const stays: Stay[] = STAYS.slice(0, stayCount);
591
+
592
+ return (
593
+ // The layout switches on its own width, so the window's width is the control that drives it.
594
+ <div style={{ width: chatWindowWidth }}>
595
+ <ChatContainer className="h-auto">
596
+ <StayCard
597
+ title="Places to stay in Zurich"
598
+ subTitle={`12–15 Nov · 2 adults · ${stays.length} places`}
599
+ >
600
+ <ChatCardBody>
601
+ <ChatCardContent>
602
+ <ChatCardThreeColumnLayout detailsPlacement={detailsPlacement} className={className}>
603
+ <ChatCardThreeColumnLayoutList aria-label="Places to stay">
604
+ {(isFloating) => (
605
+ <StayList
606
+ stays={stays}
607
+ isFloating={isFloating}
608
+ selectedId={hasDetails ? FEATURED_STAY.id : null}
609
+ onOpen={onOpenStay}
610
+ />
611
+ )}
612
+ </ChatCardThreeColumnLayoutList>
613
+
614
+ <ChatCardThreeColumnLayoutMain asChild>
615
+ <section aria-label="Map of available properties">
616
+ <StayMap
617
+ stays={stays}
618
+ selectedId={hasDetails ? FEATURED_STAY.id : null}
619
+ onOpen={onOpenStay}
620
+ />
621
+ </section>
622
+ </ChatCardThreeColumnLayoutMain>
623
+
624
+ {hasDetails && (
625
+ <ChatCardThreeColumnLayoutDetails
626
+ aria-label={`Details for ${FEATURED_STAY.name}`}
627
+ >
628
+ {(isFloating) => (
629
+ <StayDetails
630
+ stay={FEATURED_STAY}
631
+ isFloating={isFloating}
632
+ onClose={onCloseDetails}
633
+ onCheckRooms={onCheckRooms}
634
+ />
635
+ )}
636
+ </ChatCardThreeColumnLayoutDetails>
637
+ )}
638
+
639
+ {hasPanel && (
640
+ <ChatCardThreeColumnLayoutPanel aria-label={`Rooms at ${FEATURED_STAY.name}`}>
641
+ <StayRooms stay={FEATURED_STAY} rates={ROOM_RATES} onBack={onCloseRooms} />
642
+ </ChatCardThreeColumnLayoutPanel>
643
+ )}
644
+ </ChatCardThreeColumnLayout>
645
+ </ChatCardContent>
646
+ </ChatCardBody>
647
+ </StayCard>
648
+ </ChatContainer>
649
+ </div>
650
+ );
651
+ }
652
+
653
+ /** All four panes at once, with the root's props, the chat window's width and each optional pane on the Controls panel. */
654
+ export const Playground: StoryObj<typeof ChatCardThreeColumnLayoutPlayground> = {
655
+ tags: ['!autodocs'],
656
+ args: {
657
+ detailsPlacement: 'responsive',
658
+ className: 'h-150',
659
+ chatWindowWidth: 1280,
660
+ stayCount: STAYS.length,
661
+ hasDetails: true,
662
+ hasPanel: true,
663
+ onOpenStay: fn(),
664
+ onCloseDetails: fn(),
665
+ onCheckRooms: fn(),
666
+ onCloseRooms: fn(),
667
+ },
668
+ argTypes: {
669
+ chatWindowWidth: {
670
+ control: { type: 'range', min: 360, max: 1600, step: 20 },
671
+ description:
672
+ 'Width of the chat window around the card, in px. The layout is this minus the message gutters and the card padding, and switches at 640px, 698px and 1132px of its own width.',
673
+ },
674
+ stayCount: {
675
+ control: { type: 'number', min: 1, max: STAYS.length },
676
+ description: 'Number of places in the List and on the map.',
677
+ },
678
+ hasDetails: {
679
+ control: 'boolean',
680
+ description:
681
+ 'Mounts `ChatCardThreeColumnLayoutDetails`. Only a mounted Details adds the third column.',
682
+ },
683
+ hasPanel: {
684
+ control: 'boolean',
685
+ description:
686
+ 'Mounts `ChatCardThreeColumnLayoutPanel` over Main and Details, which stay mounted under it.',
687
+ },
688
+ onOpenStay: { description: 'Called with the place’s id when a row or a pin is clicked.' },
689
+ onCloseDetails: { description: 'Called by the close control in Details.' },
690
+ onCheckRooms: { description: 'Called by "Check other rooms" in Details.' },
691
+ onCloseRooms: { description: 'Called by "Back to the property" in the Panel.' },
692
+ },
693
+ render: (args) => <ChatCardThreeColumnLayoutPlayground {...args} />,
273
694
  };