@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,29 +1,50 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { useState } from 'react';
3
- import { fn } from 'storybook/test';
2
+ import { useId, useState } from 'react';
3
+ import { expect, fn } from 'storybook/test';
4
4
 
5
- import { cn } from '@swisper.ai/web-core';
5
+ import { SignatureIcon } from '@swisper.ai/icons';
6
+ import { Button, Divider, Typography } from '@swisper.ai/ui';
6
7
 
7
- import { RichTextField } from './rich-text-field';
8
+ import { ParentBlock } from '../../__storybook__/parent-block';
9
+
10
+ import {
11
+ EMAIL_ATTACHMENT_TYPES,
12
+ EVENT_DESCRIPTION_HTML,
13
+ HANDOVER_NOTE_MARKDOWN,
14
+ INCOMING_MESSAGE,
15
+ REPLY_DRAFT_MARKDOWN,
16
+ } from './__stories__/fixtures';
17
+ import {
18
+ AlignmentSelect,
19
+ AttachmentButton,
20
+ BoldButton,
21
+ CleanFormatButton,
22
+ ImageButton,
23
+ ItalicButton,
24
+ LinkButton,
25
+ SizeSelect,
26
+ TextColorButton,
27
+ ToolbarButton,
28
+ TypographySelect,
29
+ UnderlineButton,
30
+ } from './components';
31
+ import { RichTextField, type RichTextFieldProps } from './rich-text-field';
8
32
 
9
33
  const meta: Meta<typeof RichTextField> = {
10
- title: 'Chatbot/RichTextField',
34
+ title: 'Chat/RichTextField',
11
35
  component: RichTextField,
12
36
  parameters: {
13
37
  layout: 'padded',
14
38
  },
15
39
  decorators: [
16
40
  (Story) => (
17
- <div data-testid="rich-text-field-story" className="relative w-[688px] min-h-[72px]">
41
+ <div className="relative w-full max-w-172">
18
42
  <Story />
19
43
  </div>
20
44
  ),
21
45
  ],
22
46
  args: {
23
- className: cn(
24
- 'rich-text-area w-full h-full',
25
- 'text-text-primary font-noto-sans font-normal text-base leading-[160%]',
26
- ),
47
+ className: 'font-noto-sans text-base leading-relaxed text-text-primary',
27
48
  toolbarPlacement: 'top',
28
49
  source: 'markdown',
29
50
  placeholder: 'Write a reply',
@@ -135,84 +156,454 @@ const meta: Meta<typeof RichTextField> = {
135
156
  export default meta;
136
157
  type Story = StoryObj<typeof RichTextField>;
137
158
 
138
- const presetMarkdown = `**Bold text** and *italic text*
139
-
140
- <div style="text-align: right">I beeen</div>
159
+ /** The reply body as a form holds it: every edit is written back to the value, shown underneath as it is stored. */
160
+ function ReplyBodyField({ value: initialValue, onChange, ...rest }: RichTextFieldProps) {
161
+ const [value, setValue] = useState(initialValue);
141
162
 
142
- A list of items:
143
- - First item
144
- - Second item
145
- - Third item`;
163
+ const handleChange = (nextValue: string) => {
164
+ setValue(nextValue);
165
+ onChange?.(nextValue);
166
+ };
146
167
 
147
- export const Default: Story = {
148
- args: {
149
- value: presetMarkdown,
150
- placeholder: 'Type something...',
151
- },
152
- render: (args) => {
153
- const [value, setValue] = useState(args.value);
168
+ return (
169
+ <div className="flex flex-col gap-16">
170
+ <RichTextField {...rest} value={value} onChange={handleChange} />
154
171
 
155
- return (
156
- <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
157
- <RichTextField {...args} value={value} onChange={setValue} />
158
-
159
- <pre
160
- style={{
161
- padding: 12,
162
- borderRadius: 8,
163
- background: '#1a1a2e',
164
- color: '#e0e0e0',
165
- fontSize: 12,
166
- whiteSpace: 'pre-wrap',
167
- }}
168
- >
172
+ <div className="flex flex-col gap-4">
173
+ <Typography variant="caption-md" className="text-text-tertiary">
174
+ Stored value
175
+ </Typography>
176
+ <pre className="rounded-sm bg-paper-elevation-1 p-12 font-mono text-xs whitespace-pre-wrap text-text-secondary">
169
177
  {value}
170
178
  </pre>
171
179
  </div>
172
- );
180
+ </div>
181
+ );
182
+ }
183
+
184
+ /** An email reply with the full toolbar above the text, and the Markdown it is stored as underneath. */
185
+ export const Default: Story = {
186
+ args: {
187
+ value: REPLY_DRAFT_MARKDOWN,
173
188
  },
189
+ render: (args) => <ReplyBodyField {...args} />,
174
190
  };
175
191
 
192
+ /** A new reply: the placeholder says what to write and sits below the toolbar. */
176
193
  export const Empty: Story = {
177
194
  args: {
178
- placeholder: 'Start typing here...',
195
+ placeholder: 'Write a reply',
179
196
  },
180
197
  };
181
198
 
199
+ /** The reply while it is being sent: the text is dimmed and can't be edited. */
182
200
  export const Disabled: Story = {
183
201
  args: {
184
- value: presetMarkdown,
202
+ value: REPLY_DRAFT_MARKDOWN,
185
203
  isDisabled: true,
186
- placeholder: 'Disabled editor',
187
204
  },
188
205
  };
189
206
 
207
+ /** The toolbar under the text, for a reply written below the message it answers. */
190
208
  export const ToolbarBottom: Story = {
191
209
  args: {
192
- value: presetMarkdown,
193
- placeholder: 'Type something...',
210
+ value: REPLY_DRAFT_MARKDOWN,
194
211
  toolbarPlacement: 'bottom',
195
212
  },
196
- render: (args) => {
197
- const [value, setValue] = useState(args.value);
213
+ render: (args) => <ReplyBodyField {...args} />,
214
+ };
215
+
216
+ /** A calendar event description with only the controls its HTML keeps: no typeface, size, link, attachment or image. */
217
+ export const CustomToolbar: Story = {
218
+ args: {
219
+ source: 'html',
220
+ value: EVENT_DESCRIPTION_HTML,
221
+ placeholder: 'Add a description',
222
+ toolbarChildren: () => (
223
+ <>
224
+ <BoldButton />
225
+ <ItalicButton />
226
+ <UnderlineButton />
227
+ <TextColorButton />
228
+
229
+ <Divider orientation="vertical" />
230
+
231
+ <AlignmentSelect />
232
+
233
+ <Divider orientation="vertical" />
234
+
235
+ <CleanFormatButton />
236
+ </>
237
+ ),
238
+ },
239
+ };
240
+
241
+ /** The email body with its attachments: the field hands over the picked files, and the form lists them. */
242
+ function EmailBodyField({ onFileAttach, ...rest }: RichTextFieldProps) {
243
+ const [attachments, setAttachments] = useState<string[]>([]);
244
+
245
+ const handleFileAttach = (files: File[]) => {
246
+ setAttachments((current) => [...current, ...files.map((file) => file.name)]);
247
+ onFileAttach?.(files);
248
+ };
249
+
250
+ return (
251
+ <div className="flex flex-col gap-8">
252
+ <RichTextField {...rest} onFileAttach={handleFileAttach} />
253
+
254
+ {attachments.length > 0 && (
255
+ <ul aria-label="Attachments" className="flex flex-col gap-4">
256
+ {attachments.map((name, index) => (
257
+ <Typography key={`${name}-${index}`} variant="caption-md" asChild>
258
+ <li>{name}</li>
259
+ </Typography>
260
+ ))}
261
+ </ul>
262
+ )}
263
+ </div>
264
+ );
265
+ }
266
+
267
+ /** An email body that takes several documents: the attachment button is enabled and the picker is limited to document types. */
268
+ export const WithAttachments: Story = {
269
+ args: {
270
+ source: 'html',
271
+ toolbarPlacement: 'bottom',
272
+ placeholder: 'Write your email',
273
+ enableAttachments: true,
274
+ isMultipleAttachments: true,
275
+ acceptedFiles: EMAIL_ATTACHMENT_TYPES,
276
+ onFileAttach: fn(),
277
+ },
278
+ render: (args) => <EmailBodyField {...args} />,
279
+ };
280
+
281
+ /** Typing fills the reply and reports it as Markdown; the bold shortcut formats the next words and lights the bold button. */
282
+ export const EmptyTypeAndFormat: Story = {
283
+ ...Empty,
284
+ tags: ['e2e', '!autodocs'],
285
+ args: { placeholder: 'Write a reply', onChange: fn() },
286
+ play: async ({ args, canvas, canvasElement, userEvent, step }) => {
287
+ // TODO(echo-ds): the field has no label prop, so the editable element has no accessible name.
288
+ const editor = canvas.getByRole('textbox');
289
+ const root = canvasElement.querySelector('[data-slot="rich-text-field"]');
290
+ const boldButton = canvas.getByRole('button', { name: 'Format Bold' });
291
+
292
+ await step('Starts empty with the placeholder and the toolbar on top', async () => {
293
+ await expect(root).toHaveAttribute('data-toolbar-placement', 'top');
294
+ await expect(editor).toHaveAttribute('aria-placeholder', 'Write a reply');
295
+ await expect(canvas.getByText('Write a reply')).toBeVisible();
296
+ await expect(canvasElement.querySelector('[data-slot="rich-text-field-toolbar"]')).toBe(
297
+ boldButton.parentElement,
298
+ );
299
+ });
300
+
301
+ await step('The default toolbar disables link, image and attachment', async () => {
302
+ await expect(canvas.getByRole('button', { name: 'Add Link' })).toBeDisabled();
303
+ await expect(canvas.getByRole('button', { name: 'Add Image' })).toBeDisabled();
304
+ await expect(canvas.getByRole('button', { name: 'Add Attachment' })).toBeDisabled();
305
+ await expect(canvas.getByRole('button', { name: 'Reset Formatting' })).toBeEnabled();
306
+ });
307
+
308
+ await step('Typing replaces the placeholder and reports the text', async () => {
309
+ await userEvent.click(editor);
310
+ await userEvent.keyboard('Tuesday works');
311
+ await expect(editor).toHaveTextContent('Tuesday works');
312
+ await expect(canvas.queryByText('Write a reply')).toBeNull();
313
+ await expect(args.onChange).toHaveBeenLastCalledWith('Tuesday works');
314
+ });
315
+
316
+ await step('The bold button formats what is typed next', async () => {
317
+ await expect(boldButton).not.toHaveAttribute('data-active');
318
+ await userEvent.click(boldButton);
319
+ await expect(boldButton).toHaveAttribute('data-active');
320
+ await userEvent.click(editor);
321
+ await userEvent.keyboard(' for us');
322
+ await expect(editor).toHaveTextContent('Tuesday works for us');
323
+ await expect(args.onChange).toHaveBeenLastCalledWith(expect.stringContaining('**'));
324
+ });
325
+ },
326
+ };
327
+
328
+ /** A disabled field marks itself disabled and its text can't be edited or reached with Tab. */
329
+ export const DisabledIsReadOnly: Story = {
330
+ ...Disabled,
331
+ tags: ['e2e', '!autodocs'],
332
+ args: { value: REPLY_DRAFT_MARKDOWN, isDisabled: true, onChange: fn() },
333
+ play: async ({ canvas, canvasElement }) => {
334
+ const editor = canvas.getByRole('textbox');
335
+ const root = canvasElement.querySelector('[data-slot="rich-text-field"]');
336
+
337
+ await expect(root).toHaveAttribute('data-disabled', 'true');
338
+ await expect(root).toHaveAttribute('aria-disabled', 'true');
339
+ await expect(editor).toHaveAttribute('contenteditable', 'false');
340
+ await expect(editor).toHaveAttribute('aria-readonly', 'true');
341
+ await expect(editor).toHaveTextContent('Tuesday at 14:00 works for us');
342
+ },
343
+ };
344
+
345
+ /** The toolbar placement is on the root, and the toolbar follows the text in the bottom layout. */
346
+ export const ToolbarBottomPlacement: Story = {
347
+ ...ToolbarBottom,
348
+ tags: ['e2e', '!autodocs'],
349
+ args: { value: REPLY_DRAFT_MARKDOWN, toolbarPlacement: 'bottom' },
350
+ play: async ({ canvas, canvasElement }) => {
351
+ const editor = canvas.getByRole('textbox');
352
+ const root = canvasElement.querySelector('[data-slot="rich-text-field"]');
353
+ const toolbar = canvasElement.querySelector('[data-slot="rich-text-field-toolbar"]');
354
+
355
+ await expect(root).toHaveAttribute('data-toolbar-placement', 'bottom');
356
+ await expect(toolbar).toBeVisible();
357
+ await expect(toolbar?.getBoundingClientRect().top).toBeGreaterThan(
358
+ editor.getBoundingClientRect().top,
359
+ );
360
+ await expect(toolbar?.getBoundingClientRect().bottom).toBe(
361
+ root?.getBoundingClientRect().bottom,
362
+ );
363
+ await expect(canvas.getByText(/Tuesday at 14:00/, { selector: 'pre' })).toBeVisible();
364
+ },
365
+ };
366
+
367
+ /** A custom toolbar renders only the controls it was given. */
368
+ export const CustomToolbarControls: Story = {
369
+ ...CustomToolbar,
370
+ tags: ['e2e', '!autodocs'],
371
+ play: async ({ canvas, canvasElement }) => {
372
+ await expect(canvas.getByRole('textbox')).toHaveTextContent('Agenda for the quarterly');
373
+
374
+ for (const name of [
375
+ 'Format Bold',
376
+ 'Format Italics',
377
+ 'Format Underline',
378
+ 'Text Color',
379
+ 'Reset Formatting',
380
+ ]) {
381
+ await expect(canvas.getByRole('button', { name })).toBeEnabled();
382
+ }
383
+
384
+ for (const name of ['Add Link', 'Add Attachment', 'Add Image']) {
385
+ await expect(canvas.queryByRole('button', { name })).toBeNull();
386
+ }
387
+
388
+ // Only the alignment select is left: the typeface and size selects were not passed.
389
+ await expect(canvas.getAllByRole('combobox')).toHaveLength(1);
390
+ await expect(
391
+ canvasElement.querySelector('[data-slot="rich-text-field-text-color"]'),
392
+ ).toContainElement(canvas.getByRole('button', { name: 'Text Color' }));
393
+ },
394
+ };
395
+
396
+ /** Picking documents hands every file to `onFileAttach`, and the picker is limited to the accepted types. */
397
+ export const WithAttachmentsPickFiles: Story = {
398
+ ...WithAttachments,
399
+ tags: ['e2e', '!autodocs'],
400
+ args: {
401
+ source: 'html',
402
+ toolbarPlacement: 'bottom',
403
+ placeholder: 'Write your email',
404
+ enableAttachments: true,
405
+ isMultipleAttachments: true,
406
+ acceptedFiles: EMAIL_ATTACHMENT_TYPES,
407
+ onFileAttach: fn(),
408
+ },
409
+ play: async ({ args, canvas, canvasElement, userEvent, step }) => {
410
+ // The file input is hidden from assistive technology on purpose; the attachment button is its
411
+ // accessible control, and a test can't drive the browser's file dialog through it.
412
+ const picker = canvasElement.querySelector<HTMLInputElement>('input[type="file"]');
413
+ const offer = new File(['offer'], 'offer-2026-014.pdf', { type: 'application/pdf' });
414
+ const priceList = new File(['prices'], 'price-list.xlsx', {
415
+ type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
416
+ });
417
+
418
+ await step('The attachment button is enabled and the picker takes documents', async () => {
419
+ await expect(canvas.getByRole('button', { name: 'Add Attachment' })).toBeEnabled();
420
+ await expect(picker).toHaveAttribute('accept', EMAIL_ATTACHMENT_TYPES.join(','));
421
+ await expect(picker).toHaveAttribute('multiple');
422
+ });
423
+
424
+ await step('Picked files reach the form', async () => {
425
+ await userEvent.upload(picker!, [offer, priceList]);
426
+ await expect(args.onFileAttach).toHaveBeenCalledWith([offer, priceList]);
427
+
428
+ const attachments = canvas.getByRole('list', { name: 'Attachments' });
429
+ await expect(attachments).toHaveTextContent('offer-2026-014.pdf');
430
+ await expect(attachments).toHaveTextContent('price-list.xlsx');
431
+ });
432
+ },
433
+ };
434
+
435
+ const formattingOnlyToolbar: RichTextFieldProps['toolbarChildren'] = () => (
436
+ <>
437
+ <BoldButton />
438
+ <ItalicButton />
439
+ <UnderlineButton />
440
+ <TextColorButton />
441
+
442
+ <Divider orientation="vertical" />
443
+
444
+ <AlignmentSelect />
445
+
446
+ <Divider orientation="vertical" />
447
+
448
+ <CleanFormatButton />
449
+ </>
450
+ );
451
+
452
+ /** The field in each place it's used: a reply composer, a form section and a dialog body. */
453
+ export const Examples: Story = {
454
+ parameters: { controls: { disable: true } },
455
+ render: function ExamplesStory(args) {
456
+ const descriptionLabelId = useId();
457
+ const noteTitleId = useId();
198
458
 
199
459
  return (
200
- <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
201
- <RichTextField {...args} value={value} onChange={setValue} />
202
-
203
- <pre
204
- style={{
205
- padding: 12,
206
- borderRadius: 8,
207
- background: '#1a1a2e',
208
- color: '#e0e0e0',
209
- fontSize: 12,
210
- whiteSpace: 'pre-wrap',
211
- }}
212
- >
213
- {value}
214
- </pre>
460
+ <div className="flex flex-col gap-24">
461
+ <ParentBlock parent="reply composer">
462
+ <section aria-label="Reply to Lena Brunner" className="flex flex-col gap-12">
463
+ <div className="flex flex-col gap-4 rounded-sm border border-divider-border-base p-12">
464
+ <Typography variant="caption-md" className="text-text-tertiary">
465
+ {INCOMING_MESSAGE.sender} · {INCOMING_MESSAGE.receivedAt}
466
+ </Typography>
467
+ <Typography variant="body-small-high">{INCOMING_MESSAGE.text}</Typography>
468
+ </div>
469
+ <RichTextField
470
+ className={args.className}
471
+ source="html"
472
+ toolbarPlacement="bottom"
473
+ placeholder="Write a reply"
474
+ enableAttachments
475
+ isMultipleAttachments
476
+ acceptedFiles={EMAIL_ATTACHMENT_TYPES}
477
+ onFileAttach={fn()}
478
+ onChange={fn()}
479
+ />
480
+ <div className="flex justify-end">
481
+ <Button variant="primary">Send reply</Button>
482
+ </div>
483
+ </section>
484
+ </ParentBlock>
485
+
486
+ <ParentBlock parent="form section">
487
+ <section
488
+ aria-labelledby={descriptionLabelId}
489
+ className="flex flex-col gap-8 rounded-sm border border-divider-border-base p-16"
490
+ >
491
+ <Typography id={descriptionLabelId} variant="body-small-high" fontWeight="medium">
492
+ Description
493
+ </Typography>
494
+ <RichTextField
495
+ className={args.className}
496
+ name="description"
497
+ source="html"
498
+ value={EVENT_DESCRIPTION_HTML}
499
+ placeholder="Add a description"
500
+ toolbarChildren={formattingOnlyToolbar}
501
+ onChange={fn()}
502
+ />
503
+ </section>
504
+ </ParentBlock>
505
+
506
+ <ParentBlock parent="dialog body">
507
+ <section
508
+ aria-labelledby={noteTitleId}
509
+ className="flex max-w-120 flex-col gap-16 rounded-15 border border-divider-border-base bg-paper-elevation-0 p-24"
510
+ >
511
+ <Typography id={noteTitleId} variant="body-small-high" fontWeight="medium">
512
+ Add a handover note
513
+ </Typography>
514
+ <RichTextField
515
+ className={args.className}
516
+ value={HANDOVER_NOTE_MARKDOWN}
517
+ placeholder="Write a note for the next shift"
518
+ toolbarChildren={formattingOnlyToolbar}
519
+ onChange={fn()}
520
+ />
521
+ <div className="flex justify-end gap-8">
522
+ <Button variant="tertiary">Cancel</Button>
523
+ <Button variant="primary">Save note</Button>
524
+ </div>
525
+ </section>
526
+ </ParentBlock>
215
527
  </div>
216
528
  );
217
529
  },
218
530
  };
531
+
532
+ type PlaygroundToolbar = 'Default' | 'Formatting only' | 'Every control';
533
+
534
+ const PLAYGROUND_TOOLBARS: Record<PlaygroundToolbar, RichTextFieldProps['toolbarChildren']> = {
535
+ Default: undefined,
536
+ 'Formatting only': formattingOnlyToolbar,
537
+ 'Every control': ({ hasAttachments }) => (
538
+ <>
539
+ <TypographySelect />
540
+ <SizeSelect />
541
+
542
+ <Divider orientation="vertical" />
543
+
544
+ <BoldButton />
545
+ <ItalicButton />
546
+ <UnderlineButton />
547
+ <TextColorButton />
548
+
549
+ <Divider orientation="vertical" />
550
+
551
+ <LinkButton isDisabled />
552
+ <AttachmentButton isDisabled={!hasAttachments} />
553
+ <ImageButton isDisabled />
554
+
555
+ <Divider orientation="vertical" />
556
+
557
+ <AlignmentSelect />
558
+
559
+ <Divider orientation="vertical" />
560
+
561
+ <CleanFormatButton />
562
+ <ToolbarButton aria-label="Insert signature">
563
+ <SignatureIcon />
564
+ </ToolbarButton>
565
+ </>
566
+ ),
567
+ };
568
+
569
+ interface RichTextFieldPlaygroundProps extends Omit<RichTextFieldProps, 'toolbarChildren'> {
570
+ toolbar: PlaygroundToolbar;
571
+ }
572
+
573
+ function RichTextFieldPlayground({ toolbar, ...rest }: RichTextFieldPlaygroundProps) {
574
+ return <RichTextField {...rest} toolbarChildren={PLAYGROUND_TOOLBARS[toolbar]} />;
575
+ }
576
+
577
+ /** Every toolbar control at once, including a custom `ToolbarButton`, with each prop of the field on the Controls panel. */
578
+ export const Playground: StoryObj<typeof RichTextFieldPlayground> = {
579
+ tags: ['!autodocs'],
580
+ args: {
581
+ toolbar: 'Every control',
582
+ value: REPLY_DRAFT_MARKDOWN,
583
+ source: 'markdown',
584
+ placeholder: 'Write a reply',
585
+ toolbarPlacement: 'top',
586
+ isDisabled: false,
587
+ enableAttachments: true,
588
+ isMultipleAttachments: true,
589
+ acceptedFiles: EMAIL_ATTACHMENT_TYPES,
590
+ name: 'body',
591
+ containerClassName: '',
592
+ placeholderClassName: '',
593
+ toolbarClassName: '',
594
+ onChange: fn(),
595
+ onBlur: fn(),
596
+ onKeyDown: fn(),
597
+ onFocusChange: fn(),
598
+ onFileAttach: fn(),
599
+ },
600
+ argTypes: {
601
+ toolbar: {
602
+ control: 'select',
603
+ options: ['Default', 'Formatting only', 'Every control'],
604
+ description:
605
+ 'What `toolbarChildren` renders: nothing passed (the default set), the formatting buttons only, or every exported control plus a custom `ToolbarButton`.',
606
+ },
607
+ },
608
+ render: (args) => <RichTextFieldPlayground {...args} />,
609
+ };
@@ -8,19 +8,41 @@ import { FileAttachmentPlugin } from '../rich-text-area/plugins/file-attachment-
8
8
  import { FormattingToolbarPlugin } from './components/formatting-toolbar-plugin';
9
9
  import { RichTextFieldContextProvider } from './context';
10
10
 
11
+ /** Where the formatting toolbar sits inside the field: above or below the text. */
11
12
  export type RichTextFieldToolbarPlacement = 'top' | 'bottom';
12
13
 
13
14
  export interface RichTextFieldProps extends Omit<RichTextAreaProps, 'children'> {
15
+ /** Accepted for type compatibility with `RichTextArea` but not rendered; use `toolbarChildren`. */
14
16
  children?: ReactNode;
17
+ /**
18
+ * Puts the toolbar above or below the text. The text padding and the placeholder offset follow
19
+ * it, and the root carries it as `data-toolbar-placement`.
20
+ * @default 'top'
21
+ */
15
22
  toolbarPlacement?: RichTextFieldToolbarPlacement;
23
+ /** Classes for the toolbar (`data-slot="rich-text-field-toolbar"`), merged last. */
16
24
  toolbarClassName?: string;
25
+ /**
26
+ * Replaces the default toolbar controls. Receives `{ hasAttachments }` (the `enableAttachments`
27
+ * value) and returns the toolbar content, built from the exported buttons and selects.
28
+ */
17
29
  toolbarChildren?: ({ hasAttachments }: { hasAttachments: boolean }) => ReactNode;
30
+ /** Lets the file picker select several files; `onFileAttach` gets only the first otherwise. */
18
31
  isMultipleAttachments?: boolean;
32
+ /** Enables the attachment button of the default toolbar; it is shown disabled otherwise. */
19
33
  enableAttachments?: boolean;
34
+ /** File types the picker accepts, as extensions or MIME types (`['.pdf', 'image/*']`). */
20
35
  acceptedFiles?: string[];
36
+ /** Called with the picked files after the attachment button opens the file picker. */
21
37
  onFileAttach?: (files: File[]) => void;
22
38
  }
23
39
 
40
+ /**
41
+ * A fixed-height rich-text editor with a formatting toolbar above or below the text, built on
42
+ * `RichTextArea`. `className` styles the editable text, `containerClassName` the root
43
+ * (`data-slot="rich-text-field"`), `placeholderClassName` the placeholder and `toolbarClassName`
44
+ * the toolbar; each is merged last.
45
+ */
24
46
  export const RichTextField = forwardRef<HTMLInputElement, RichTextFieldProps>(
25
47
  (
26
48
  {
@@ -45,6 +67,7 @@ export const RichTextField = forwardRef<HTMLInputElement, RichTextFieldProps>(
45
67
  <RichTextArea
46
68
  ref={ref}
47
69
  data-testid="rich-text-field"
70
+ data-slot="rich-text-field"
48
71
  data-toolbar-placement={toolbarPlacement}
49
72
  placeholderClassName={cn(
50
73
  'left-(--rich-text-field-editor-padding)',
@@ -0,0 +1 @@
1
+ export { TopMenu, TopMenuActions, type TopMenuActionsProps, type TopMenuProps } from './topmenu';