@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,76 +1,39 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import type { ReactNode } from 'react';
3
+ import { expect } from 'storybook/test';
2
4
 
5
+ import { Button, Chip, ScrollArea, Typography } from '@swisper.ai/ui';
6
+
7
+ import { ParentBlock } from '../../__storybook__/parent-block';
3
8
  import {
4
9
  ChatCard,
10
+ ChatCardActions,
5
11
  ChatCardBody,
12
+ ChatCardCollapsibleButton,
6
13
  ChatCardContent,
14
+ ChatCardFooter,
7
15
  ChatCardHeader,
8
16
  ChatCardHeaderContent,
9
17
  ChatCardTitle,
10
18
  } from '../../components/chat-card';
11
19
  import { ChatCardContainer } from '../../components/chat-card-container';
12
20
  import { ChatContainer } from '../../components/chat-container';
21
+ import { ChatMessage, ChatMessageContent } from '../../components/chat-message';
13
22
 
23
+ import { ConnectionItinerary } from './__stories__/connection-itinerary';
24
+ import { ZURICH_TO_LUGANO, ZURICH_TO_PARADISO_DOOR_TO_DOOR } from './__stories__/fixtures';
25
+ import { RouteMap } from './__stories__/route-map';
26
+ import type { ItineraryStep } from './__stories__/types';
14
27
  import {
15
28
  ChatCardTwoColumnLayout,
16
29
  ChatCardTwoColumnLayoutAside,
17
30
  ChatCardTwoColumnLayoutMain,
18
31
  } from './chat-card-two-column-layout';
32
+ import type { ChatCardTwoColumnLayoutProps } from './chat-card-two-column-layout';
19
33
  import { chatCardTwoColumnLayoutCardVariants } from './chat-card-two-column-layout.variants';
20
34
 
21
- const ROWS = ['Revenue', 'Gross margin', 'Operating costs', 'EBITDA', 'Net income', 'Cash flow'];
22
-
23
- function Placeholder({ label, className = '' }: { label: string; className?: string }) {
24
- return (
25
- <div
26
- className={`flex h-full w-full items-center justify-center rounded-[8px] border border-dashed border-card-border-base text-sm ${className}`}
27
- >
28
- {label}
29
- </div>
30
- );
31
- }
32
-
33
- function Example() {
34
- return (
35
- <ChatContainer className="h-auto py-16">
36
- {/* `full`: the card's minimum width goes past the default reading column */}
37
- <ChatCardContainer variant="full">
38
- <ChatCard className={chatCardTwoColumnLayoutCardVariants()}>
39
- <ChatCardHeader>
40
- <ChatCardHeaderContent>
41
- <ChatCardTitle>Quarterly figures</ChatCardTitle>
42
- </ChatCardHeaderContent>
43
- </ChatCardHeader>
44
- <ChatCardBody>
45
- <ChatCardContent>
46
- <ChatCardTwoColumnLayout className="h-[480px]">
47
- <ChatCardTwoColumnLayoutAside>
48
- <ul className="flex h-full flex-col gap-[8px] overflow-y-auto">
49
- {ROWS.map((row) => (
50
- <li
51
- key={row}
52
- className="rounded-[8px] border border-card-border-base p-[8px] text-sm"
53
- >
54
- {row}
55
- </li>
56
- ))}
57
- </ul>
58
- </ChatCardTwoColumnLayoutAside>
59
-
60
- <ChatCardTwoColumnLayoutMain>
61
- <Placeholder label="Chart" className="bg-card-background-lvl-2" />
62
- </ChatCardTwoColumnLayoutMain>
63
- </ChatCardTwoColumnLayout>
64
- </ChatCardContent>
65
- </ChatCardBody>
66
- </ChatCard>
67
- </ChatCardContainer>
68
- </ChatContainer>
69
- );
70
- }
71
-
72
35
  const meta: Meta<typeof ChatCardTwoColumnLayout> = {
73
- title: 'Chatbot/ChatCardTwoColumnLayout',
36
+ title: 'Chat/ChatCardTwoColumnLayout',
74
37
  component: ChatCardTwoColumnLayout,
75
38
  tags: ['autodocs'],
76
39
  parameters: { layout: 'fullscreen' },
@@ -82,7 +45,12 @@ const meta: Meta<typeof ChatCardTwoColumnLayout> = {
82
45
  className: {
83
46
  control: 'text',
84
47
  description:
85
- 'Classes for the root. Set the height here (e.g. `h-[480px]`); the layout sets none.',
48
+ 'Classes for the root, merged last. Set the height here (e.g. `h-120`); the layout sets none, and without one a map or chart in Main has no height.',
49
+ },
50
+ gridClassName: {
51
+ control: 'text',
52
+ description:
53
+ 'Classes for the grid the root renders around the panes, merged after its defaults, e.g. `gap-8` for a tighter gutter.',
86
54
  },
87
55
  asChild: {
88
56
  control: false,
@@ -91,6 +59,7 @@ const meta: Meta<typeof ChatCardTwoColumnLayout> = {
91
59
  },
92
60
  },
93
61
  args: {
62
+ className: 'h-120',
94
63
  asChild: false,
95
64
  },
96
65
  };
@@ -98,20 +67,79 @@ const meta: Meta<typeof ChatCardTwoColumnLayout> = {
98
67
  export default meta;
99
68
  type Story = StoryObj<typeof ChatCardTwoColumnLayout>;
100
69
 
70
+ interface ConnectionLayoutProps extends Omit<ChatCardTwoColumnLayoutProps, 'children'> {
71
+ /** The itinerary rows in the Aside column. */
72
+ steps?: ItineraryStep[];
73
+ }
74
+
75
+ /** The travel card's body: the itinerary in Aside, scrolling on its own, beside the route map in Main. */
76
+ function ConnectionLayout({ steps = ZURICH_TO_LUGANO, ...rest }: ConnectionLayoutProps) {
77
+ return (
78
+ <ChatCardTwoColumnLayout {...rest}>
79
+ <ChatCardTwoColumnLayoutAside aria-label="Itinerary">
80
+ <ScrollArea className="h-full">
81
+ <ConnectionItinerary steps={steps} />
82
+ </ScrollArea>
83
+ </ChatCardTwoColumnLayoutAside>
84
+
85
+ {/* A chat page already has a `<main>`, so Main renders a named section here. */}
86
+ <ChatCardTwoColumnLayoutMain asChild>
87
+ <section aria-label="Route map">
88
+ <RouteMap label="Map of the route from Zürich to Lugano" />
89
+ </section>
90
+ </ChatCardTwoColumnLayoutMain>
91
+ </ChatCardTwoColumnLayout>
92
+ );
93
+ }
94
+
95
+ /** The connection as a chat card. The card recipe gives it the width the two columns need. */
96
+ function ConnectionCard(props: ConnectionLayoutProps) {
97
+ return (
98
+ <ChatCard className={chatCardTwoColumnLayoutCardVariants()}>
99
+ <ChatCardHeader>
100
+ <ChatCardHeaderContent>
101
+ <ChatCardTitle>Zürich to Lugano</ChatCardTitle>
102
+ </ChatCardHeaderContent>
103
+ </ChatCardHeader>
104
+ <ChatCardBody>
105
+ <ChatCardContent>
106
+ <ConnectionLayout {...props} />
107
+ </ChatCardContent>
108
+ </ChatCardBody>
109
+ </ChatCard>
110
+ );
111
+ }
112
+
113
+ /** The chat surface around the card. `full` lets the card grow past the reading column. */
114
+ function ChatWindow({ children }: { children: ReactNode }) {
115
+ return (
116
+ <ChatContainer className="h-auto py-16">
117
+ <ChatCardContainer variant="full">{children}</ChatCardContainer>
118
+ </ChatContainer>
119
+ );
120
+ }
121
+
101
122
  /**
102
123
  * From 744px of layout width, Aside is a 336px column beside Main; below it, Aside stacks
103
124
  * above Main and Main takes the rest of the height. The threshold is the layout's own width,
104
125
  * not the viewport's.
105
126
  */
106
127
  export const Default: Story = {
107
- render: () => <Example />,
128
+ render: (args) => (
129
+ <ChatWindow>
130
+ <ConnectionCard {...args} />
131
+ </ChatWindow>
132
+ ),
108
133
  };
109
134
 
110
135
  /** A narrow card: Aside stacks above Main although the viewport is wide. */
111
136
  export const Stacked: Story = {
137
+ parameters: { controls: { disable: true } },
112
138
  render: () => (
113
- <div style={{ width: 500 }}>
114
- <Example />
139
+ <div className="w-125">
140
+ <ChatWindow>
141
+ <ConnectionCard className="h-150" />
142
+ </ChatWindow>
115
143
  </div>
116
144
  ),
117
145
  };
@@ -121,18 +149,291 @@ export const Stacked: Story = {
121
149
  * changing, which is the point.
122
150
  */
123
151
  export const ResizableContainer: Story = {
152
+ parameters: { controls: { disable: true } },
124
153
  render: () => (
125
- <div
126
- className="border border-dashed border-card-border-base"
127
- style={{
128
- resize: 'horizontal',
129
- overflow: 'auto',
130
- width: 900,
131
- minWidth: 360,
132
- maxWidth: '100%',
133
- }}
134
- >
135
- <Example />
154
+ <div className="w-225 max-w-full min-w-90 resize-x overflow-auto border border-dashed border-card-border-base">
155
+ <ChatWindow>
156
+ <ConnectionCard className="h-150" />
157
+ </ChatWindow>
158
+ </div>
159
+ ),
160
+ };
161
+
162
+ // TODO(echo-ds): the root is a plain div with no role or name, so it is found by its slot.
163
+ function getLayoutRoot(pane: HTMLElement) {
164
+ return pane.closest<HTMLElement>('[data-slot="chat-card-two-column-layout"]');
165
+ }
166
+
167
+ /** Checks that a 1000px card puts Aside in a 336px column beside Main, both at the root's height. */
168
+ export const SideBySideColumns: Story = {
169
+ tags: ['e2e', '!autodocs'],
170
+ render: (args) => (
171
+ <div className="w-250">
172
+ <ChatWindow>
173
+ <ConnectionCard {...args} />
174
+ </ChatWindow>
136
175
  </div>
137
176
  ),
177
+ play: async ({ canvas, step }) => {
178
+ const aside = canvas.getByRole('complementary', { name: 'Itinerary' });
179
+ const main = canvas.getByRole('region', { name: 'Route map' });
180
+ const asideBox = aside.getBoundingClientRect();
181
+ const mainBox = main.getBoundingClientRect();
182
+
183
+ await step('Aside is the fixed column, Main the flexible one', async () => {
184
+ await expect(asideBox.width).toBeCloseTo(336, 0);
185
+ await expect(mainBox.top).toBeCloseTo(asideBox.top, 0);
186
+ await expect(mainBox.left - asideBox.right).toBeCloseTo(16, 0);
187
+ await expect(mainBox.width).toBeGreaterThanOrEqual(400);
188
+ });
189
+
190
+ await step('The height on the root reaches both panes', async () => {
191
+ await expect(getLayoutRoot(aside)?.getBoundingClientRect().height).toBeCloseTo(480, 0);
192
+ await expect(asideBox.height).toBeCloseTo(480, 0);
193
+ await expect(mainBox.height).toBeCloseTo(480, 0);
194
+ });
195
+
196
+ await step('Aside comes before Main in the DOM', async () => {
197
+ await expect(
198
+ aside.compareDocumentPosition(main) & Node.DOCUMENT_POSITION_FOLLOWING,
199
+ ).toBeTruthy();
200
+ });
201
+ },
202
+ };
203
+
204
+ /** Checks that a 500px card stacks Aside over Main at one width, and Main takes the height Aside leaves. */
205
+ export const StackedRows: Story = {
206
+ ...Stacked,
207
+ tags: ['e2e', '!autodocs'],
208
+ play: async ({ canvas, step }) => {
209
+ const aside = canvas.getByRole('complementary', { name: 'Itinerary' });
210
+ const main = canvas.getByRole('region', { name: 'Route map' });
211
+ const rootBox = getLayoutRoot(aside)?.getBoundingClientRect();
212
+ const asideBox = aside.getBoundingClientRect();
213
+ const mainBox = main.getBoundingClientRect();
214
+
215
+ await step('Aside sits above Main in one column', async () => {
216
+ await expect(mainBox.top).toBeGreaterThanOrEqual(asideBox.bottom);
217
+ await expect(mainBox.left).toBeCloseTo(asideBox.left, 0);
218
+ await expect(mainBox.width).toBeCloseTo(asideBox.width, 0);
219
+ });
220
+
221
+ await step('Aside keeps its content height and Main takes the rest', async () => {
222
+ await expect(rootBox?.height).toBeCloseTo(600, 0);
223
+ await expect(asideBox.height).toBeLessThan(600);
224
+ await expect(mainBox.bottom).toBeCloseTo(rootBox?.bottom ?? 0, 0);
225
+ await expect(mainBox.height).toBeGreaterThan(0);
226
+ });
227
+ },
228
+ };
229
+
230
+ /** Checks that an itinerary longer than the card scrolls inside the Aside column instead of growing the card. */
231
+ export const LongAsideScrolls: Story = {
232
+ tags: ['e2e', '!autodocs'],
233
+ args: { className: 'h-60' },
234
+ render: (args) => (
235
+ <div className="w-250">
236
+ <ChatWindow>
237
+ <ConnectionCard {...args} steps={ZURICH_TO_PARADISO_DOOR_TO_DOOR} />
238
+ </ChatWindow>
239
+ </div>
240
+ ),
241
+ play: async ({ canvas }) => {
242
+ const aside = canvas.getByRole('complementary', { name: 'Itinerary' });
243
+ // TODO(echo-ds): the scroll viewport has no role or name, so it is found by its slot.
244
+ const viewport = aside.querySelector<HTMLElement>('[data-slot="scroll-area-viewport"]');
245
+
246
+ await expect(getLayoutRoot(aside)?.getBoundingClientRect().height).toBeCloseTo(240, 0);
247
+ await expect(aside.getBoundingClientRect().height).toBeCloseTo(240, 0);
248
+ await expect(viewport?.scrollHeight).toBeGreaterThan(viewport?.clientHeight ?? 0);
249
+ await expect(canvas.getByText(/6900 Paradiso/)).toBeInTheDocument();
250
+ },
251
+ };
252
+
253
+ /** Checks that `gridClassName` reaches the grid: `gap-8` halves the gutter between the columns. */
254
+ export const GridClassNameGutter: Story = {
255
+ ...SideBySideColumns,
256
+ tags: ['e2e', '!autodocs'],
257
+ args: { gridClassName: 'gap-8' },
258
+ play: async ({ canvas }) => {
259
+ const aside = canvas.getByRole('complementary', { name: 'Itinerary' });
260
+ const main = canvas.getByRole('region', { name: 'Route map' });
261
+
262
+ await expect(
263
+ main.getBoundingClientRect().left - aside.getBoundingClientRect().right,
264
+ ).toBeCloseTo(8, 0);
265
+ await expect(aside.getBoundingClientRect().width).toBeCloseTo(336, 0);
266
+ },
267
+ };
268
+
269
+ /** The layout in each place it's allowed: straight in a card's content, in a card body with a footer under it, and in a chat thread. */
270
+ export const Examples: Story = {
271
+ parameters: { controls: { disable: true } },
272
+ render: () => (
273
+ <div className="flex flex-col gap-24 p-16">
274
+ <ParentBlock parent="web-chat-ui/ChatCardContent">
275
+ <ChatCard className={chatCardTwoColumnLayoutCardVariants()}>
276
+ <ChatCardHeader>
277
+ <ChatCardHeaderContent>
278
+ <ChatCardTitle>Zürich to Lugano</ChatCardTitle>
279
+ </ChatCardHeaderContent>
280
+ </ChatCardHeader>
281
+ <ChatCardBody>
282
+ <ChatCardContent>
283
+ <ConnectionLayout className="h-90" />
284
+ </ChatCardContent>
285
+ </ChatCardBody>
286
+ </ChatCard>
287
+ </ParentBlock>
288
+
289
+ <ParentBlock parent="chat card body">
290
+ <ChatCard className={chatCardTwoColumnLayoutCardVariants()}>
291
+ <ChatCardHeader>
292
+ <ChatCardHeaderContent>
293
+ <ChatCardTitle>Zürich to Lugano</ChatCardTitle>
294
+ </ChatCardHeaderContent>
295
+ <ChatCardActions className="flex items-center gap-4">
296
+ <Chip variant="outlined" size="2xs" color="success">
297
+ On time
298
+ </Chip>
299
+ <ChatCardCollapsibleButton />
300
+ </ChatCardActions>
301
+ </ChatCardHeader>
302
+ <ChatCardBody>
303
+ <ChatCardContent hasHeaderPadding={false}>
304
+ <ConnectionLayout className="h-90" />
305
+ </ChatCardContent>
306
+ <ChatCardFooter className="flex-wrap justify-between gap-12">
307
+ <Chip variant="outlined" size="2xs" color="info">
308
+ From CHF 34.00
309
+ </Chip>
310
+ <Button variant="primary">Select connection</Button>
311
+ </ChatCardFooter>
312
+ </ChatCardBody>
313
+ </ChatCard>
314
+ </ParentBlock>
315
+
316
+ <ParentBlock parent="chat thread">
317
+ <ChatContainer aria-label="Chat" className="h-auto gap-16 py-16">
318
+ <ChatMessage isQuestion className="px-message">
319
+ <ChatMessageContent>
320
+ <Typography>When is the next train from Zürich to Lugano?</Typography>
321
+ </ChatMessageContent>
322
+ </ChatMessage>
323
+ <ChatMessage className="px-message">
324
+ <ChatMessageContent>
325
+ <Typography>
326
+ The next connection leaves Höschgasse at 12:10 and reaches Lugano at 14:28, with one
327
+ change at Zürich HB.
328
+ </Typography>
329
+ </ChatMessageContent>
330
+ </ChatMessage>
331
+ <ChatCardContainer variant="full">
332
+ <ConnectionCard className="h-90" />
333
+ </ChatCardContainer>
334
+ </ChatContainer>
335
+ </ParentBlock>
336
+ </div>
337
+ ),
338
+ };
339
+
340
+ interface ChatCardTwoColumnLayoutPlaygroundProps extends Omit<
341
+ ChatCardTwoColumnLayoutProps,
342
+ 'children'
343
+ > {
344
+ width: number;
345
+ title: string;
346
+ stepCount: number;
347
+ hasScrollArea: boolean;
348
+ asideClassName: string;
349
+ mainClassName: string;
350
+ }
351
+
352
+ function ChatCardTwoColumnLayoutPlayground({
353
+ width,
354
+ title,
355
+ stepCount,
356
+ hasScrollArea,
357
+ asideClassName,
358
+ mainClassName,
359
+ ...rest
360
+ }: ChatCardTwoColumnLayoutPlaygroundProps) {
361
+ const itinerary = (
362
+ <ConnectionItinerary steps={ZURICH_TO_PARADISO_DOOR_TO_DOOR.slice(0, stepCount)} />
363
+ );
364
+
365
+ return (
366
+ // The width is a control, so it can only be an inline style.
367
+ <div style={{ width }} className="max-w-full">
368
+ <ChatWindow>
369
+ <ChatCard className={chatCardTwoColumnLayoutCardVariants()}>
370
+ <ChatCardHeader>
371
+ <ChatCardHeaderContent>
372
+ <ChatCardTitle>{title}</ChatCardTitle>
373
+ </ChatCardHeaderContent>
374
+ </ChatCardHeader>
375
+ <ChatCardBody>
376
+ <ChatCardContent>
377
+ <ChatCardTwoColumnLayout {...rest}>
378
+ <ChatCardTwoColumnLayoutAside aria-label="Itinerary" className={asideClassName}>
379
+ {hasScrollArea ? (
380
+ <ScrollArea className="h-full">{itinerary}</ScrollArea>
381
+ ) : (
382
+ itinerary
383
+ )}
384
+ </ChatCardTwoColumnLayoutAside>
385
+
386
+ <ChatCardTwoColumnLayoutMain asChild className={mainClassName}>
387
+ <section aria-label="Route map">
388
+ <RouteMap label="Map of the route from Zürich to Paradiso" />
389
+ </section>
390
+ </ChatCardTwoColumnLayoutMain>
391
+ </ChatCardTwoColumnLayout>
392
+ </ChatCardContent>
393
+ </ChatCardBody>
394
+ </ChatCard>
395
+ </ChatWindow>
396
+ </div>
397
+ );
398
+ }
399
+
400
+ /** Both panes with the door-to-door itinerary, and the card width, the classes of every part and the Aside scroll on the Controls panel. */
401
+ export const Playground: StoryObj<typeof ChatCardTwoColumnLayoutPlayground> = {
402
+ tags: ['!autodocs'],
403
+ args: {
404
+ width: 1000,
405
+ title: 'Zürich, Feldeggstrasse to Paradiso',
406
+ stepCount: ZURICH_TO_PARADISO_DOOR_TO_DOOR.length,
407
+ hasScrollArea: true,
408
+ className: 'h-120',
409
+ gridClassName: '',
410
+ asideClassName: '',
411
+ mainClassName: '',
412
+ },
413
+ argTypes: {
414
+ width: {
415
+ control: { type: 'range', min: 360, max: 1200, step: 8 },
416
+ description:
417
+ 'Width of the chat window in pixels. The columns switch when the layout inside the card reaches 744px.',
418
+ },
419
+ title: { control: 'text', description: 'Text of the wrapping card’s `ChatCardTitle`.' },
420
+ stepCount: {
421
+ control: { type: 'number', min: 1, max: ZURICH_TO_PARADISO_DOOR_TO_DOOR.length },
422
+ description: 'Number of itinerary steps in `ChatCardTwoColumnLayoutAside`.',
423
+ },
424
+ hasScrollArea: {
425
+ control: 'boolean',
426
+ description:
427
+ 'Wraps the Aside content in a `ScrollArea` with `h-full`. Without it a long itinerary is cut off at the column’s height.',
428
+ },
429
+ asideClassName: {
430
+ control: 'text',
431
+ description: '`className` of `ChatCardTwoColumnLayoutAside`, merged over its recipe.',
432
+ },
433
+ mainClassName: {
434
+ control: 'text',
435
+ description: '`className` of `ChatCardTwoColumnLayoutMain`, merged over its recipe.',
436
+ },
437
+ },
438
+ render: (args) => <ChatCardTwoColumnLayoutPlayground {...args} />,
138
439
  };
@@ -30,6 +30,11 @@ function useChatCardTwoColumnLayoutContext(part: string) {
30
30
 
31
31
  export interface ChatCardTwoColumnLayoutProps extends ComponentProps<'div'> {
32
32
  children: ReactNode;
33
+ /**
34
+ * Classes for the grid the root renders around its children, merged after its defaults, e.g.
35
+ * `gap-8` for a tighter gutter. Keep the column and row templates: the panes rely on them.
36
+ */
37
+ gridClassName?: string;
33
38
  asChild?: boolean;
34
39
  }
35
40
 
@@ -44,9 +49,13 @@ export interface ChatCardTwoColumnLayoutProps extends ComponentProps<'div'> {
44
49
  * The root is the query container and renders the grid inside itself: an element cannot
45
50
  * query its own width. `className` goes on the root, so a height set there reaches the grid.
46
51
  * Height is not set here, because it belongs to the content, so pass it in `className`.
52
+ * `gridClassName` reaches the grid itself.
47
53
  */
48
54
  export const ChatCardTwoColumnLayout = forwardRef<HTMLDivElement, ChatCardTwoColumnLayoutProps>(
49
- function ChatCardTwoColumnLayout({ children, className, asChild = false, ...rest }, ref) {
55
+ function ChatCardTwoColumnLayout(
56
+ { children, className, gridClassName, asChild = false, ...rest },
57
+ ref,
58
+ ) {
50
59
  const Component = asChild ? Slot : 'div';
51
60
 
52
61
  return (
@@ -61,7 +70,7 @@ export const ChatCardTwoColumnLayout = forwardRef<HTMLDivElement, ChatCardTwoCol
61
70
  <div
62
71
  data-testid="chat-card-two-column-layout-grid"
63
72
  data-slot="chat-card-two-column-layout-grid"
64
- className={chatCardTwoColumnLayoutGridVariants()}
73
+ className={cn(chatCardTwoColumnLayoutGridVariants(), gridClassName)}
65
74
  >
66
75
  {children}
67
76
  </div>
@@ -1,21 +0,0 @@
1
- export type CardItemPickerValue = string | number;
2
- export type CardItemPickerOrientation = 'vertical' | 'horizontal';
3
- export interface CardItemPickerListContextValue {
4
- value: CardItemPickerValue | null;
5
- hoveredValue: CardItemPickerValue | null;
6
- orientation: CardItemPickerOrientation;
7
- select: (value: CardItemPickerValue) => void;
8
- hover: (value: CardItemPickerValue | null) => void;
9
- }
10
- export declare const CardItemPickerListContext: import('react').Context<CardItemPickerListContextValue | null>;
11
- export declare function useCardItemPickerListContext(): CardItemPickerListContextValue;
12
- export interface CardItemPickerRowContextValue {
13
- isSelected: boolean;
14
- titleId: string;
15
- descriptionId: string;
16
- registerTitle: () => () => void;
17
- registerDescription: () => () => void;
18
- }
19
- export declare const CardItemPickerRowContext: import('react').Context<CardItemPickerRowContextValue | null>;
20
- export declare function useCardItemPickerRowContext(): CardItemPickerRowContextValue;
21
- //# sourceMappingURL=card-item-picker-context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"card-item-picker-context.d.ts","sourceRoot":"","sources":["../../../src/components/card-item-picker/card-item-picker-context.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAAC;AAClD,MAAM,MAAM,yBAAyB,GAAG,UAAU,GAAG,YAAY,CAAC;AAElE,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACzC,WAAW,EAAE,yBAAyB,CAAC;IACvC,MAAM,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC7C,KAAK,EAAE,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,KAAK,IAAI,CAAC;CACpD;AAED,eAAO,MAAM,yBAAyB,gEAA6D,CAAC;AAEpG,wBAAgB,4BAA4B,mCAQ3C;AAED,MAAM,WAAW,6BAA6B;IAC5C,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,MAAM,IAAI,CAAC;IAChC,mBAAmB,EAAE,MAAM,MAAM,IAAI,CAAC;CACvC;AAED,eAAO,MAAM,wBAAwB,+DAA4D,CAAC;AAElG,wBAAgB,2BAA2B,kCAQ1C"}
@@ -1,24 +0,0 @@
1
- import { ComponentPropsWithoutRef } from 'react';
2
- import { CardItemPickerOrientation, CardItemPickerValue } from './card-item-picker-context';
3
- export interface CardItemPickerListProps<V extends CardItemPickerValue = CardItemPickerValue> extends Omit<ComponentPropsWithoutRef<'ul'>, 'role' | 'onKeyDown' | 'aria-orientation'> {
4
- /** The selected card, or `null` when nothing is selected. */
5
- value: V | null;
6
- /** The card under the pointer, mirrored as `data-hovered` (e.g. when a map pin is hovered). */
7
- hoveredValue?: V | null;
8
- /** A card was picked by click, Enter or Space. Toggling is up to the caller. */
9
- onValueChange: (value: V) => void;
10
- /** The pointer entered a card (`value`) or left it (`null`). */
11
- onHoverChange?: (value: V | null) => void;
12
- orientation?: CardItemPickerOrientation;
13
- }
14
- /**
15
- * A single-select list of cards, built on the ARIA listbox pattern: the list is
16
- * one tab stop that moves focus into the last focused card, else the selected
17
- * one, else the first. Arrow keys (plus Home/End, PageUp/PageDown) move between
18
- * cards and Enter/Space picks one. Name it with `aria-label` or `aria-labelledby`.
19
- *
20
- * Cards are listbox options, so they must not contain their own links or
21
- * buttons — put those in a details view instead.
22
- */
23
- export declare function CardItemPickerList<V extends CardItemPickerValue>({ value, hoveredValue, onValueChange, onHoverChange, orientation, className, children, ...props }: CardItemPickerListProps<V>): import('react').JSX.Element;
24
- //# sourceMappingURL=card-item-picker-list.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"card-item-picker-list.d.ts","sourceRoot":"","sources":["../../../src/components/card-item-picker/card-item-picker-list.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAKtD,OAAO,EAGL,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACzB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,uBAAuB,CACtC,CAAC,SAAS,mBAAmB,GAAG,mBAAmB,CACnD,SAAQ,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,kBAAkB,CAAC;IACvF,6DAA6D;IAC7D,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAChB,+FAA+F;IAC/F,YAAY,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IACxB,gFAAgF;IAChF,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAClC,gEAAgE;IAChE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,yBAAyB,CAAC;CACzC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,mBAAmB,EAAE,EAChE,KAAK,EACL,YAAmB,EACnB,aAAa,EACb,aAAa,EACb,WAAwB,EACxB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,uBAAuB,CAAC,CAAC,CAAC,+BAiD5B"}
@@ -1,28 +0,0 @@
1
- import { ComponentPropsWithoutRef } from 'react';
2
- export type CardItemPickerRowMediaProps = ComponentPropsWithoutRef<'div'>;
3
- /** Leading visual of a card (a thumbnail); hidden from assistive tech. */
4
- export declare function CardItemPickerRowMedia({ className, ...props }: CardItemPickerRowMediaProps): import('react').JSX.Element;
5
- export type CardItemPickerRowContentProps = ComponentPropsWithoutRef<'div'>;
6
- /** The text column of a card, beside its media. */
7
- export declare function CardItemPickerRowContent({ className, ...props }: CardItemPickerRowContentProps): import('react').JSX.Element;
8
- export interface CardItemPickerRowTitleProps {
9
- children: string;
10
- className?: string;
11
- }
12
- /** The card's name — becomes the option's accessible name. */
13
- export declare function CardItemPickerRowTitle({ children, className }: CardItemPickerRowTitleProps): import('react').JSX.Element;
14
- export type CardItemPickerRowDescriptionProps = ComponentPropsWithoutRef<'div'>;
15
- /** Secondary details of a card — announced as the option's description. */
16
- export declare function CardItemPickerRowDescription({ className, ...props }: CardItemPickerRowDescriptionProps): import('react').JSX.Element;
17
- export interface CardItemPickerRowCheckboxProps {
18
- className?: string;
19
- }
20
- /**
21
- * A checkbox in the card's top-right corner that mirrors its selection. It only
22
- * shows the selection: the option already announces it through `aria-selected`,
23
- * and a listbox option can't hold a control of its own, so the checkbox is out of
24
- * the tab order, hidden from assistive tech, and clicks pass through to the card.
25
- * Leave room for it on the right of the card's content.
26
- */
27
- export declare function CardItemPickerRowCheckbox({ className }: CardItemPickerRowCheckboxProps): import('react').JSX.Element;
28
- //# sourceMappingURL=card-item-picker-row-parts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"card-item-picker-row-parts.d.ts","sourceRoot":"","sources":["../../../src/components/card-item-picker/card-item-picker-row-parts.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAOtD,MAAM,MAAM,2BAA2B,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;AAE1E,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,2BAA2B,+BAa1F;AAED,MAAM,MAAM,6BAA6B,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;AAE5E,mDAAmD;AACnD,wBAAgB,wBAAwB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,6BAA6B,+BAI9F;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,8DAA8D;AAC9D,wBAAgB,sBAAsB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,2BAA2B,+BAgB1F;AAED,MAAM,MAAM,iCAAiC,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;AAEhF,2EAA2E;AAC3E,wBAAgB,4BAA4B,CAAC,EAC3C,SAAS,EACT,GAAG,KAAK,EACT,EAAE,iCAAiC,+BAMnC;AAED,MAAM,WAAW,8BAA8B;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,EAAE,SAAS,EAAE,EAAE,8BAA8B,+BAYtF"}
@@ -1,12 +0,0 @@
1
- import { ComponentPropsWithoutRef } from 'react';
2
- import { CardItemPickerValue } from './card-item-picker-context';
3
- export interface CardItemPickerRowProps extends Omit<ComponentPropsWithoutRef<'li'>, 'role' | 'tabIndex' | 'aria-selected' | 'aria-labelledby' | 'aria-describedby'> {
4
- value: CardItemPickerValue;
5
- }
6
- /**
7
- * One card of a {@link CardItemPickerList}: a listbox option. Its accessible name
8
- * comes from {@link CardItemPickerRowTitle} and its description from
9
- * {@link CardItemPickerRowDescription}, when rendered.
10
- */
11
- export declare const CardItemPickerRow: import('react').ForwardRefExoticComponent<CardItemPickerRowProps & import('react').RefAttributes<HTMLLIElement>>;
12
- //# sourceMappingURL=card-item-picker-row.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"card-item-picker-row.d.ts","sourceRoot":"","sources":["../../../src/components/card-item-picker/card-item-picker-row.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAiB,MAAM,OAAO,CAAC;AAKrE,OAAO,EAGL,KAAK,mBAAmB,EAEzB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAClD,wBAAwB,CAAC,IAAI,CAAC,EAC9B,MAAM,GAAG,UAAU,GAAG,eAAe,GAAG,iBAAiB,GAAG,kBAAkB,CAC/E;IACC,KAAK,EAAE,mBAAmB,CAAC;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,kHAmF7B,CAAC"}
@@ -1,19 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react-vite';
2
- import { CardItemPickerOrientation } from '.';
3
- interface DemoProps {
4
- orientation?: CardItemPickerOrientation;
5
- withMedia?: boolean;
6
- withCheckbox?: boolean;
7
- initialValue?: string | null;
8
- }
9
- /** A controlled list, so selecting, hovering and keyboard focus can be tried out. */
10
- declare function Demo({ orientation, withMedia, withCheckbox, initialValue, }: DemoProps): import('react').JSX.Element;
11
- declare const meta: Meta<typeof Demo>;
12
- export default meta;
13
- type Story = StoryObj<typeof Demo>;
14
- export declare const Default: Story;
15
- export declare const WithMedia: Story;
16
- /** A checkbox in each card's top-right corner mirrors the selection. */
17
- export declare const WithCheckbox: Story;
18
- export declare const Horizontal: Story;
19
- //# sourceMappingURL=card-item-picker.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"card-item-picker.stories.d.ts","sourceRoot":"","sources":["../../../src/components/card-item-picker/card-item-picker.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAK5D,OAAO,EAQL,KAAK,yBAAyB,EAC/B,MAAM,GAAG,CAAC;AAgBX,UAAU,SAAS;IACjB,WAAW,CAAC,EAAE,yBAAyB,CAAC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,qFAAqF;AACrF,iBAAS,IAAI,CAAC,EACZ,WAAW,EACX,SAAiB,EACjB,YAAoB,EACpB,YAAmB,GACpB,EAAE,SAAS,+BAgDX;AAED,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,IAAI,CA8C3B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC;AAEjC,eAAO,MAAM,SAAS,EAAE,KAEvB,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,YAAY,EAAE,KAE1B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAExB,CAAC"}