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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/README.md +9 -12
  2. package/dist/components/canvas-shell/canvas-shell.d.ts +32 -10
  3. package/dist/components/canvas-shell/canvas-shell.d.ts.map +1 -1
  4. package/dist/components/canvas-shell/canvas-shell.stories.d.ts +49 -17
  5. package/dist/components/canvas-shell/canvas-shell.stories.d.ts.map +1 -1
  6. package/dist/components/chat-card/chat-card.d.ts +1 -0
  7. package/dist/components/chat-card/chat-card.d.ts.map +1 -1
  8. package/dist/components/chat-card/chat-card.stories.d.ts +47 -1
  9. package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -1
  10. package/dist/components/chat-card/components/chat-card-body.d.ts +8 -0
  11. package/dist/components/chat-card/components/chat-card-body.d.ts.map +1 -1
  12. package/dist/components/chat-card/components/chat-card-footer.d.ts +8 -0
  13. package/dist/components/chat-card/components/chat-card-footer.d.ts.map +1 -1
  14. package/dist/components/chat-card/components/chat-card-form.d.ts +15 -2
  15. package/dist/components/chat-card/components/chat-card-form.d.ts.map +1 -1
  16. package/dist/components/chat-card/components/chat-card-header.d.ts +23 -2
  17. package/dist/components/chat-card/components/chat-card-header.d.ts.map +1 -1
  18. package/dist/components/chat-card/contexts.d.ts +2 -0
  19. package/dist/components/chat-card/contexts.d.ts.map +1 -1
  20. package/dist/components/chat-card/hooks.d.ts +1 -0
  21. package/dist/components/chat-card/hooks.d.ts.map +1 -1
  22. package/dist/components/chat-card/types.d.ts +3 -0
  23. package/dist/components/chat-card/types.d.ts.map +1 -1
  24. package/dist/components/chat-card-container/chat-card-container.d.ts +4 -0
  25. package/dist/components/chat-card-container/chat-card-container.d.ts.map +1 -1
  26. package/dist/components/chat-card-container/chat-card-container.stories.d.ts +12 -1
  27. package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -1
  28. package/dist/components/chat-container/chat-container.d.ts.map +1 -1
  29. package/dist/components/chat-container/chat-container.stories.d.ts +36 -11
  30. package/dist/components/chat-container/chat-container.stories.d.ts.map +1 -1
  31. package/dist/components/chat-input/chat-input.d.ts +30 -2
  32. package/dist/components/chat-input/chat-input.d.ts.map +1 -1
  33. package/dist/components/chat-input/chat-input.stories.d.ts +63 -3
  34. package/dist/components/chat-input/chat-input.stories.d.ts.map +1 -1
  35. package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts +4 -1
  36. package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts.map +1 -1
  37. package/dist/components/chat-input/plugins/value-plugin.d.ts +4 -1
  38. package/dist/components/chat-input/plugins/value-plugin.d.ts.map +1 -1
  39. package/dist/components/chat-list/chat-list-item.d.ts +6 -0
  40. package/dist/components/chat-list/chat-list-item.d.ts.map +1 -1
  41. package/dist/components/chat-list/chat-list-items.d.ts +12 -1
  42. package/dist/components/chat-list/chat-list-items.d.ts.map +1 -1
  43. package/dist/components/chat-list/chat-list.d.ts +36 -2
  44. package/dist/components/chat-list/chat-list.d.ts.map +1 -1
  45. package/dist/components/chat-list/chat-list.stories.d.ts +67 -9
  46. package/dist/components/chat-list/chat-list.stories.d.ts.map +1 -1
  47. package/dist/components/chat-message/chat-message.d.ts +12 -1
  48. package/dist/components/chat-message/chat-message.d.ts.map +1 -1
  49. package/dist/components/chat-message/chat-message.stories.d.ts +31 -0
  50. package/dist/components/chat-message/chat-message.stories.d.ts.map +1 -1
  51. package/dist/components/chat-message/index.d.ts +1 -1
  52. package/dist/components/chat-message/index.d.ts.map +1 -1
  53. package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts +3 -0
  54. package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts.map +1 -1
  55. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts +25 -5
  56. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts.map +1 -1
  57. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts +32 -1
  58. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts.map +1 -1
  59. package/dist/components/chat-message-attachment-card/index.d.ts +2 -2
  60. package/dist/components/chat-message-attachment-card/index.d.ts.map +1 -1
  61. package/dist/components/chat-message-attachment-card/utils.d.ts +1 -0
  62. package/dist/components/chat-message-attachment-card/utils.d.ts.map +1 -1
  63. package/dist/components/chat-message-response/chat-message-response.stories.d.ts +13 -0
  64. package/dist/components/chat-message-response/chat-message-response.stories.d.ts.map +1 -1
  65. package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts +22 -5
  66. package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts.map +1 -1
  67. package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts +42 -0
  68. package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts.map +1 -1
  69. package/dist/components/chat-message-toolbar/index.d.ts +1 -1
  70. package/dist/components/chat-message-toolbar/index.d.ts.map +1 -1
  71. package/dist/components/chat-messages/chat-messages.d.ts +34 -2
  72. package/dist/components/chat-messages/chat-messages.d.ts.map +1 -1
  73. package/dist/components/chat-messages/chat-messages.stories.d.ts +33 -2
  74. package/dist/components/chat-messages/chat-messages.stories.d.ts.map +1 -1
  75. package/dist/components/chat-notification-card/chat-notification-card.d.ts +56 -4
  76. package/dist/components/chat-notification-card/chat-notification-card.d.ts.map +1 -1
  77. package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts +50 -1
  78. package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts.map +1 -1
  79. package/dist/components/chat-notification-popup/chat-notification-popup.d.ts +6 -0
  80. package/dist/components/chat-notification-popup/chat-notification-popup.d.ts.map +1 -1
  81. package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts +43 -1
  82. package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts.map +1 -1
  83. package/dist/components/chat-prompt-box/chat-prompt-box.d.ts +37 -17
  84. package/dist/components/chat-prompt-box/chat-prompt-box.d.ts.map +1 -1
  85. package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts +53 -1
  86. package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts.map +1 -1
  87. package/dist/components/chat-reply/chat-reply.d.ts +11 -0
  88. package/dist/components/chat-reply/chat-reply.d.ts.map +1 -1
  89. package/dist/components/chat-reply/chat-reply.stories.d.ts +23 -0
  90. package/dist/components/chat-reply/chat-reply.stories.d.ts.map +1 -1
  91. package/dist/components/chat-reply/index.d.ts +1 -1
  92. package/dist/components/chat-reply/index.d.ts.map +1 -1
  93. package/dist/components/chat-suggestion/chat-suggestion.d.ts +36 -10
  94. package/dist/components/chat-suggestion/chat-suggestion.d.ts.map +1 -1
  95. package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts +66 -2
  96. package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts.map +1 -1
  97. package/dist/components/chat-suggestion/index.d.ts +2 -1
  98. package/dist/components/chat-suggestion/index.d.ts.map +1 -1
  99. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +26 -1
  100. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -1
  101. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +25 -1
  102. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -1
  103. package/dist/components/chat-thread/chat-thread.d.ts +17 -2
  104. package/dist/components/chat-thread/chat-thread.d.ts.map +1 -1
  105. package/dist/components/chat-thread/chat-thread.stories.d.ts +75 -10
  106. package/dist/components/chat-thread/chat-thread.stories.d.ts.map +1 -1
  107. package/dist/components/index.d.ts +1 -3
  108. package/dist/components/index.d.ts.map +1 -1
  109. package/dist/components/markdown-viewer/markdown-viewer.d.ts +8 -1
  110. package/dist/components/markdown-viewer/markdown-viewer.d.ts.map +1 -1
  111. package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts +18 -1
  112. package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts.map +1 -1
  113. package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts +4 -1
  114. package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts.map +1 -1
  115. package/dist/components/rich-text-area/plugins/value-plugin.d.ts +4 -1
  116. package/dist/components/rich-text-area/plugins/value-plugin.d.ts.map +1 -1
  117. package/dist/components/rich-text-area/rich-text-area.d.ts +17 -0
  118. package/dist/components/rich-text-area/rich-text-area.d.ts.map +1 -1
  119. package/dist/components/rich-text-area/rich-text-area.stories.d.ts +52 -0
  120. package/dist/components/rich-text-area/rich-text-area.stories.d.ts.map +1 -1
  121. package/dist/components/rich-text-area/styled.d.ts +6 -2
  122. package/dist/components/rich-text-area/styled.d.ts.map +1 -1
  123. package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts +9 -2
  124. package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts.map +1 -1
  125. package/dist/components/rich-text-field/components/index.d.ts +5 -5
  126. package/dist/components/rich-text-field/components/index.d.ts.map +1 -1
  127. package/dist/components/rich-text-field/components/text-color-button.d.ts +12 -1
  128. package/dist/components/rich-text-field/components/text-color-button.d.ts.map +1 -1
  129. package/dist/components/rich-text-field/rich-text-field.d.ts +22 -0
  130. package/dist/components/rich-text-field/rich-text-field.d.ts.map +1 -1
  131. package/dist/components/rich-text-field/rich-text-field.stories.d.ts +28 -1
  132. package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -1
  133. package/dist/components/topmenu/index.d.ts +2 -0
  134. package/dist/components/topmenu/index.d.ts.map +1 -0
  135. package/dist/components/topmenu/topmenu.d.ts +22 -0
  136. package/dist/components/topmenu/topmenu.d.ts.map +1 -0
  137. package/dist/components/topmenu/topmenu.stories.d.ts +31 -0
  138. package/dist/components/topmenu/topmenu.stories.d.ts.map +1 -0
  139. package/dist/docs/agent.stories.d.ts.map +1 -1
  140. package/dist/docs/chat-panel.d.ts +7 -5
  141. package/dist/docs/chat-panel.d.ts.map +1 -1
  142. package/dist/docs/chatbot-panel.d.ts.map +1 -1
  143. package/dist/docs/chatbot.stories.d.ts.map +1 -1
  144. package/dist/index.css +1 -1
  145. package/dist/index.es.js +1801 -1806
  146. package/dist/index.es.js.map +1 -1
  147. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +9 -7
  148. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +1 -1
  149. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +37 -9
  150. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +1 -1
  151. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +41 -16
  152. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +1 -1
  153. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +6 -0
  154. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +1 -1
  155. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +22 -1
  156. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +1 -1
  157. package/package.json +16 -10
  158. package/src/__storybook__/parent-block.tsx +21 -0
  159. package/src/components/canvas-shell/__stories__/canvas-panel.tsx +25 -0
  160. package/src/components/canvas-shell/__stories__/document-list.tsx +29 -0
  161. package/src/components/canvas-shell/__stories__/fixtures.ts +222 -0
  162. package/src/components/canvas-shell/__stories__/holdings-table.tsx +56 -0
  163. package/src/components/canvas-shell/__stories__/types.ts +47 -0
  164. package/src/components/canvas-shell/{canvas-shell.test.tsx → __tests__/canvas-shell.spec.tsx} +1 -1
  165. package/src/components/canvas-shell/canvas-shell.json +24 -0
  166. package/src/components/canvas-shell/canvas-shell.stories.tsx +581 -122
  167. package/src/components/canvas-shell/canvas-shell.tsx +44 -17
  168. package/src/components/chat-card/__stories__/fixtures.ts +119 -0
  169. package/src/components/chat-card/__stories__/types.ts +44 -0
  170. package/src/components/chat-card/chat-card.json +67 -3
  171. package/src/components/chat-card/chat-card.stories.tsx +872 -148
  172. package/src/components/chat-card/chat-card.tsx +2 -0
  173. package/src/components/chat-card/components/chat-card-body.tsx +12 -0
  174. package/src/components/chat-card/components/chat-card-footer.tsx +11 -0
  175. package/src/components/chat-card/components/chat-card-form.tsx +21 -2
  176. package/src/components/chat-card/components/chat-card-header.tsx +39 -2
  177. package/src/components/chat-card/contexts.tsx +2 -0
  178. package/src/components/chat-card/hooks.ts +1 -0
  179. package/src/components/chat-card/types.ts +3 -0
  180. package/src/components/chat-card-container/__stories__/fixtures.ts +54 -0
  181. package/src/components/chat-card-container/__stories__/resizable-chat-window.tsx +19 -0
  182. package/src/components/chat-card-container/__stories__/result-card.tsx +31 -0
  183. package/src/components/chat-card-container/__stories__/types.ts +16 -0
  184. package/src/components/chat-card-container/chat-card-container.json +7 -0
  185. package/src/components/chat-card-container/chat-card-container.stories.tsx +209 -56
  186. package/src/components/chat-card-container/chat-card-container.tsx +5 -0
  187. package/src/components/chat-container/__stories__/chat-composer.tsx +67 -0
  188. package/src/components/chat-container/__stories__/fixtures.ts +27 -0
  189. package/src/components/chat-container/__stories__/measure.ts +22 -0
  190. package/src/components/chat-container/__stories__/types.ts +7 -0
  191. package/src/components/chat-container/__stories__/variable-readout.tsx +64 -0
  192. package/src/components/chat-container/chat-container.json +9 -1
  193. package/src/components/chat-container/chat-container.stories.tsx +538 -106
  194. package/src/components/chat-container/chat-container.tsx +3 -0
  195. package/src/components/chat-input/__stories__/fixtures.ts +31 -0
  196. package/src/components/chat-input/__tests__/chat-input.spec.tsx +100 -0
  197. package/src/components/chat-input/chat-input.json +11 -2
  198. package/src/components/chat-input/chat-input.stories.tsx +660 -197
  199. package/src/components/chat-input/chat-input.tsx +39 -5
  200. package/src/components/chat-input/plugins/controlled-value-plugin.tsx +16 -3
  201. package/src/components/chat-input/plugins/value-plugin.tsx +19 -4
  202. package/src/components/chat-list/__stories__/chat-row.tsx +41 -0
  203. package/src/components/chat-list/__stories__/fixtures.ts +94 -0
  204. package/src/components/chat-list/__stories__/types.ts +13 -0
  205. package/src/components/chat-list/chat-list-item.tsx +6 -0
  206. package/src/components/chat-list/chat-list-items.tsx +16 -0
  207. package/src/components/chat-list/chat-list.json +24 -2
  208. package/src/components/chat-list/chat-list.stories.tsx +631 -215
  209. package/src/components/chat-list/chat-list.tsx +51 -4
  210. package/src/components/chat-message/__stories__/fixtures.ts +53 -0
  211. package/src/components/chat-message/__stories__/sent-attachment.tsx +22 -0
  212. package/src/components/chat-message/__stories__/tool-steps.tsx +37 -0
  213. package/src/components/chat-message/chat-message.json +10 -1
  214. package/src/components/chat-message/chat-message.stories.tsx +282 -20
  215. package/src/components/chat-message/chat-message.tsx +16 -1
  216. package/src/components/chat-message/index.ts +8 -1
  217. package/src/components/chat-message-attachment-card/__stories__/fixtures.ts +30 -0
  218. package/src/components/chat-message-attachment-card/__stories__/types.ts +14 -0
  219. package/src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx +4 -0
  220. package/src/components/chat-message-attachment-card/chat-message-attachment-card.json +20 -0
  221. package/src/components/chat-message-attachment-card/chat-message-attachment-card.stories.tsx +266 -51
  222. package/src/components/chat-message-attachment-card/chat-message-attachment-card.tsx +37 -4
  223. package/src/components/chat-message-attachment-card/index.ts +6 -0
  224. package/src/components/chat-message-attachment-card/utils.ts +1 -0
  225. package/src/components/chat-message-response/__stories__/fixtures.ts +50 -0
  226. package/src/components/chat-message-response/chat-message-response.json +5 -0
  227. package/src/components/chat-message-response/chat-message-response.stories.tsx +135 -26
  228. package/src/components/chat-message-toolbar/chat-message-toolbar.json +21 -3
  229. package/src/components/chat-message-toolbar/chat-message-toolbar.stories.tsx +377 -6
  230. package/src/components/chat-message-toolbar/chat-message-toolbar.tsx +47 -12
  231. package/src/components/chat-message-toolbar/index.ts +4 -0
  232. package/src/components/chat-messages/__stories__/conversation-frame.tsx +25 -0
  233. package/src/components/chat-messages/__stories__/conversation-group.tsx +22 -0
  234. package/src/components/chat-messages/__stories__/fixtures.ts +70 -0
  235. package/src/components/chat-messages/__stories__/types.ts +5 -0
  236. package/src/components/chat-messages/chat-messages.json +30 -12
  237. package/src/components/chat-messages/chat-messages.stories.tsx +439 -212
  238. package/src/components/chat-messages/chat-messages.tsx +46 -3
  239. package/src/components/chat-notification-card/__stories__/fixtures.ts +38 -0
  240. package/src/components/chat-notification-card/__stories__/types.ts +13 -0
  241. package/src/components/chat-notification-card/chat-notification-card.json +52 -2
  242. package/src/components/chat-notification-card/chat-notification-card.stories.tsx +542 -62
  243. package/src/components/chat-notification-card/chat-notification-card.tsx +97 -6
  244. package/src/components/chat-notification-popup/__stories__/fixtures.ts +36 -0
  245. package/src/components/chat-notification-popup/__stories__/notification-item.tsx +93 -0
  246. package/src/components/chat-notification-popup/__stories__/types.ts +14 -0
  247. package/src/components/chat-notification-popup/chat-notification-popup.json +14 -1
  248. package/src/components/chat-notification-popup/chat-notification-popup.stories.tsx +467 -17
  249. package/src/components/chat-notification-popup/chat-notification-popup.tsx +18 -3
  250. package/src/components/chat-prompt-box/__stories__/fixtures.ts +16 -0
  251. package/src/components/chat-prompt-box/__stories__/types.ts +8 -0
  252. package/src/components/chat-prompt-box/chat-prompt-box.json +25 -2
  253. package/src/components/chat-prompt-box/chat-prompt-box.stories.tsx +535 -43
  254. package/src/components/chat-prompt-box/chat-prompt-box.tsx +73 -19
  255. package/src/components/chat-reply/chat-reply.json +10 -0
  256. package/src/components/chat-reply/chat-reply.stories.tsx +264 -21
  257. package/src/components/chat-reply/chat-reply.tsx +15 -0
  258. package/src/components/chat-reply/index.ts +10 -1
  259. package/src/components/chat-suggestion/__stories__/fixtures.ts +16 -0
  260. package/src/components/chat-suggestion/__tests__/chat-suggestion.spec.tsx +185 -0
  261. package/src/components/chat-suggestion/chat-suggestion.json +62 -20
  262. package/src/components/chat-suggestion/chat-suggestion.stories.tsx +542 -58
  263. package/src/components/chat-suggestion/chat-suggestion.tsx +154 -65
  264. package/src/components/chat-suggestion/index.ts +9 -0
  265. package/src/components/chat-thinking-process/__stories__/fixtures.ts +56 -0
  266. package/src/components/chat-thinking-process/chat-thinking-process.json +28 -3
  267. package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +354 -78
  268. package/src/components/chat-thinking-process/chat-thinking-process.tsx +55 -4
  269. package/src/components/chat-thread/__stories__/fixtures.ts +171 -0
  270. package/src/components/chat-thread/__stories__/scroll-position.ts +9 -0
  271. package/src/components/chat-thread/__stories__/snippets.ts +129 -0
  272. package/src/components/chat-thread/__stories__/thread-frame.tsx +22 -0
  273. package/src/components/chat-thread/__stories__/thread-turns.tsx +35 -0
  274. package/src/components/chat-thread/__stories__/types.ts +12 -0
  275. package/src/components/chat-thread/__stories__/use-turn-stream.ts +78 -0
  276. package/src/components/chat-thread/chat-thread.json +23 -3
  277. package/src/components/chat-thread/chat-thread.stories.tsx +804 -142
  278. package/src/components/chat-thread/chat-thread.tsx +64 -16
  279. package/src/components/index.ts +1 -3
  280. package/src/components/markdown-viewer/__stories__/fixtures.ts +67 -0
  281. package/src/components/markdown-viewer/markdown-viewer.json +7 -1
  282. package/src/components/markdown-viewer/markdown-viewer.stories.tsx +219 -50
  283. package/src/components/markdown-viewer/markdown-viewer.tsx +9 -0
  284. package/src/components/rich-text-area/__stories__/fixtures.ts +30 -0
  285. package/src/components/rich-text-area/__tests__/rich-text-area.spec.tsx +114 -0
  286. package/src/components/rich-text-area/plugins/controlled-value-plugin.tsx +20 -3
  287. package/src/components/rich-text-area/plugins/value-plugin.tsx +16 -3
  288. package/src/components/rich-text-area/rich-text-area.json +7 -4
  289. package/src/components/rich-text-area/rich-text-area.stories.tsx +597 -41
  290. package/src/components/rich-text-area/rich-text-area.tsx +27 -4
  291. package/src/components/rich-text-area/styled.tsx +11 -5
  292. package/src/components/rich-text-field/__stories__/fixtures.ts +29 -0
  293. package/src/components/rich-text-field/components/formatting-toolbar-plugin.tsx +10 -1
  294. package/src/components/rich-text-field/components/index.ts +8 -5
  295. package/src/components/rich-text-field/components/text-color-button.tsx +16 -2
  296. package/src/components/rich-text-field/rich-text-field.json +3 -1
  297. package/src/components/rich-text-field/rich-text-field.stories.tsx +452 -61
  298. package/src/components/rich-text-field/rich-text-field.tsx +23 -0
  299. package/src/components/topmenu/index.ts +1 -0
  300. package/src/components/topmenu/topmenu.json +107 -0
  301. package/src/components/topmenu/topmenu.stories.tsx +334 -0
  302. package/src/components/topmenu/topmenu.tsx +71 -0
  303. package/src/docs/agent.stories.tsx +16 -16
  304. package/src/docs/chat-panel.tsx +37 -32
  305. package/src/docs/chatbot-panel.tsx +11 -2
  306. package/src/docs/chatbot.mdx +17 -12
  307. package/src/docs/chatbot.stories.tsx +7 -8
  308. package/src/layouts/chat-card-list-layout/__stories__/fixtures.ts +112 -0
  309. package/src/layouts/chat-card-list-layout/__stories__/result-card.tsx +36 -0
  310. package/src/layouts/chat-card-list-layout/__stories__/types.ts +31 -0
  311. package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +14 -1
  312. package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +316 -84
  313. package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +11 -7
  314. package/src/layouts/chat-card-three-column-layout/__stories__/fixtures.ts +117 -0
  315. package/src/layouts/chat-card-three-column-layout/__stories__/resizable-chat-window.tsx +18 -0
  316. package/src/layouts/chat-card-three-column-layout/__stories__/stay-details.tsx +85 -0
  317. package/src/layouts/chat-card-three-column-layout/__stories__/stay-list.tsx +50 -0
  318. package/src/layouts/chat-card-three-column-layout/__stories__/stay-map.tsx +44 -0
  319. package/src/layouts/chat-card-three-column-layout/__stories__/stay-rooms.tsx +61 -0
  320. package/src/layouts/chat-card-three-column-layout/__stories__/types.ts +35 -0
  321. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +16 -0
  322. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +603 -182
  323. package/src/layouts/chat-card-two-column-layout/__stories__/connection-itinerary.tsx +51 -0
  324. package/src/layouts/chat-card-two-column-layout/__stories__/fixtures.ts +83 -0
  325. package/src/layouts/chat-card-two-column-layout/__stories__/route-map.tsx +24 -0
  326. package/src/layouts/chat-card-two-column-layout/__stories__/types.ts +15 -0
  327. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +13 -1
  328. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +368 -67
  329. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +11 -2
  330. package/dist/components/card-item-picker/card-item-picker-context.d.ts +0 -21
  331. package/dist/components/card-item-picker/card-item-picker-context.d.ts.map +0 -1
  332. package/dist/components/card-item-picker/card-item-picker-list.d.ts +0 -24
  333. package/dist/components/card-item-picker/card-item-picker-list.d.ts.map +0 -1
  334. package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts +0 -28
  335. package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts.map +0 -1
  336. package/dist/components/card-item-picker/card-item-picker-row.d.ts +0 -12
  337. package/dist/components/card-item-picker/card-item-picker-row.d.ts.map +0 -1
  338. package/dist/components/card-item-picker/card-item-picker.stories.d.ts +0 -19
  339. package/dist/components/card-item-picker/card-item-picker.stories.d.ts.map +0 -1
  340. package/dist/components/card-item-picker/index.d.ts +0 -9
  341. package/dist/components/card-item-picker/index.d.ts.map +0 -1
  342. package/dist/components/chat-message-history/chat-message-history.d.ts +0 -48
  343. package/dist/components/chat-message-history/chat-message-history.d.ts.map +0 -1
  344. package/dist/components/chat-message-history/chat-message-history.stories.d.ts +0 -7
  345. package/dist/components/chat-message-history/chat-message-history.stories.d.ts.map +0 -1
  346. package/dist/components/chat-message-history/index.d.ts +0 -2
  347. package/dist/components/chat-message-history/index.d.ts.map +0 -1
  348. package/dist/components/spinner/index.d.ts +0 -2
  349. package/dist/components/spinner/index.d.ts.map +0 -1
  350. package/dist/components/spinner/spinner.d.ts +0 -9
  351. package/dist/components/spinner/spinner.d.ts.map +0 -1
  352. package/dist/components/spinner/spinner.stories.d.ts +0 -8
  353. package/dist/components/spinner/spinner.stories.d.ts.map +0 -1
  354. package/src/components/card-item-picker/__tests__/card-item-picker.spec.tsx +0 -279
  355. package/src/components/card-item-picker/card-item-picker-context.tsx +0 -44
  356. package/src/components/card-item-picker/card-item-picker-list.tsx +0 -95
  357. package/src/components/card-item-picker/card-item-picker-row-parts.tsx +0 -96
  358. package/src/components/card-item-picker/card-item-picker-row.tsx +0 -109
  359. package/src/components/card-item-picker/card-item-picker.json +0 -147
  360. package/src/components/card-item-picker/card-item-picker.stories.tsx +0 -158
  361. package/src/components/card-item-picker/index.ts +0 -24
  362. package/src/components/chat-message-history/chat-message-history.json +0 -99
  363. package/src/components/chat-message-history/chat-message-history.stories.tsx +0 -136
  364. package/src/components/chat-message-history/chat-message-history.tsx +0 -277
  365. package/src/components/chat-message-history/index.ts +0 -13
  366. package/src/components/spinner/index.ts +0 -1
  367. package/src/components/spinner/spinner.json +0 -73
  368. package/src/components/spinner/spinner.stories.tsx +0 -41
  369. package/src/components/spinner/spinner.tsx +0 -32
@@ -1,31 +1,38 @@
1
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
1
2
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { useState } from 'react';
3
+ import { $getRoot, COMMAND_PRIORITY_LOW, KEY_ESCAPE_COMMAND } from 'lexical';
4
+ import { useEffect, useState } from 'react';
5
+ import type { FormEvent, KeyboardEvent } from 'react';
6
+ import { expect, fn } from 'storybook/test';
3
7
 
4
8
  import { EnterIcon } from '@swisper.ai/icons';
5
- import { IconButton } from '@swisper.ai/ui';
6
- import { cn } from '@swisper.ai/web-core';
7
-
9
+ import { Button, IconButton, Typography } from '@swisper.ai/ui';
10
+
11
+ import { ParentBlock } from '../../__storybook__/parent-block';
12
+ import {
13
+ CanvasShell,
14
+ CanvasShellContent,
15
+ CanvasShellFooter,
16
+ CanvasShellHeader,
17
+ CanvasShellTitle,
18
+ } from '../canvas-shell';
19
+ import { ChatContainer, ChatContainerPrompt } from '../chat-container';
20
+
21
+ import { CALENDAR_SIGNAL, MARKDOWN_DRAFT, SIGNAL_REPLIES } from './__stories__/fixtures';
8
22
  import { ChatInput, ChatInputTextarea, useChatInputContext } from './chat-input';
9
23
 
10
- function ChatInputStateDebug() {
11
- const { isFocused, hasValue } = useChatInputContext();
12
-
13
- return (
14
- <div>
15
- <p className="text-sm text-text-secondary">
16
- State: focused={String(isFocused)}, empty={String(!hasValue)}
17
- </p>
18
- </div>
19
- );
20
- }
24
+ // ChatInput ships unstyled. This is the look a consumer gives it: a bordered field that takes its
25
+ // focus colour from the `data-focused` attribute the root sets.
26
+ const fieldClassName =
27
+ 'max-h-30 min-h-40 w-full overflow-y-auto rounded-md border border-form-fields-border bg-paper-elevation-1 px-12 py-6 transition-colors hover:border-form-fields-border-hover data-[focused=true]:border-primary-main data-[focused=true]:bg-paper-elevation-2';
21
28
 
22
29
  const meta: Meta<typeof ChatInput> = {
23
- title: 'Chatbot/ChatInput',
30
+ title: 'Chat/ChatInput',
24
31
  component: ChatInput,
25
32
  tags: ['autodocs'],
26
33
  decorators: [
27
34
  (Story) => (
28
- <div className="max-w-[420px]">
35
+ <div className="max-w-105">
29
36
  <Story />
30
37
  </div>
31
38
  ),
@@ -34,7 +41,7 @@ const meta: Meta<typeof ChatInput> = {
34
41
  initialConfig: {
35
42
  control: false,
36
43
  description:
37
- 'Lexical composer config (namespace, nodes, theme, `onError`). Override only to add nodes or retheme the editor.',
44
+ 'Lexical composer config (namespace, nodes, theme, `onError`), read once on mount. Override only to add nodes or retheme the editor.',
38
45
  table: { defaultValue: { summary: 'DEFAULT_CONFIG' } },
39
46
  },
40
47
  children: {
@@ -45,247 +52,703 @@ const meta: Meta<typeof ChatInput> = {
45
52
  className: {
46
53
  control: 'text',
47
54
  description:
48
- 'Extra classes on the wrapper; style focus and empty states with `data-[focused=true]` and `data-[empty=true]`.',
55
+ 'Classes on the wrapper, which ships unstyled; style focus and empty states with `data-[focused=true]` and `data-[empty=true]`.',
49
56
  },
50
57
  },
51
58
  args: {
52
- className: 'min-h-[80px]',
59
+ className: fieldClassName,
53
60
  },
54
61
  };
55
62
 
56
63
  export default meta;
57
64
  type Story = StoryObj<typeof ChatInput>;
58
65
 
66
+ /** The reply field under a notification: the unstyled editor with the border and focus colour its consumer gives it. */
59
67
  export const Default: Story = {
60
- render: () => (
61
- <div className="flex flex-col gap-2">
62
- <ChatInput className="min-h-[80px]">
63
- <ChatInputTextarea placeholder="Input your message..." />
64
- <ChatInputStateDebug />
65
- </ChatInput>
66
- </div>
68
+ render: (args) => (
69
+ <ChatInput {...args}>
70
+ <ChatInputTextarea autoFocus={false} placeholder="Tell Swisper what to do instead" />
71
+ </ChatInput>
67
72
  ),
68
73
  };
69
74
 
75
+ function ComposerStateReadout() {
76
+ const { isFocused, hasValue } = useChatInputContext();
77
+
78
+ return (
79
+ <Typography variant="caption-md" className="text-text-tertiary">
80
+ {isFocused ? 'Focused' : 'Not focused'} · {hasValue ? 'Has a draft' : 'Empty'}
81
+ </Typography>
82
+ );
83
+ }
84
+
85
+ /** The editor takes focus on mount, which is the default; the line below reads the state from `useChatInputContext`. */
70
86
  export const AutoFocus: Story = {
87
+ parameters: { controls: { disable: true } },
71
88
  render: () => (
72
- <div className="flex flex-col gap-2">
73
- <ChatInput className="min-h-[80px]">
74
- <ChatInputTextarea autoFocus placeholder="Focused on mount..." />
75
- <ChatInputStateDebug />
89
+ <ChatInput className={fieldClassName}>
90
+ <ChatInputTextarea autoFocus placeholder="How can I help?" />
91
+ <ComposerStateReadout />
92
+ </ChatInput>
93
+ ),
94
+ };
95
+
96
+ interface ReplyDraftProps {
97
+ suggestions: string[];
98
+ onChange: (value: string) => void;
99
+ }
100
+
101
+ function ReplyDraft({ suggestions, onChange }: ReplyDraftProps) {
102
+ const [value, setValue] = useState('');
103
+
104
+ function handleChange(nextValue: string) {
105
+ setValue(nextValue);
106
+ onChange(nextValue);
107
+ }
108
+
109
+ return (
110
+ <div className="flex flex-col gap-8">
111
+ <ChatInput className={fieldClassName}>
112
+ <ChatInputTextarea
113
+ autoFocus={false}
114
+ value={value}
115
+ placeholder="Tell Swisper what to do instead"
116
+ onChange={handleChange}
117
+ />
76
118
  </ChatInput>
77
- <p className="text-sm text-text-secondary">
78
- The editor receives focus when the story loads (focused=true in state debug).
79
- </p>
119
+
120
+ <div className="flex flex-wrap gap-8">
121
+ {suggestions.map((suggestion) => (
122
+ <Button key={suggestion} size="sm" onClick={() => setValue(suggestion)}>
123
+ {suggestion}
124
+ </Button>
125
+ ))}
126
+ <Button size="sm" variant="tertiary" onClick={() => setValue('')}>
127
+ Clear draft
128
+ </Button>
129
+ </div>
80
130
  </div>
131
+ );
132
+ }
133
+
134
+ type ReplyDraftStory = StoryObj<typeof ReplyDraft>;
135
+
136
+ /** A controlled draft: picking a reply replaces the content, including one long enough to wrap, and clearing sets it to an empty string. */
137
+ export const Controlled: ReplyDraftStory = {
138
+ parameters: { controls: { disable: true } },
139
+ args: { suggestions: SIGNAL_REPLIES.slice(1), onChange: fn() },
140
+ render: (args) => <ReplyDraft {...args} />,
141
+ };
142
+
143
+ /** A reply that is being sent: the draft stays visible but dimmed, and can't be edited or selected. */
144
+ export const Disabled: Story = {
145
+ parameters: { controls: { disable: true } },
146
+ render: () => (
147
+ <ChatInput className={fieldClassName}>
148
+ <ChatInputTextarea
149
+ value={SIGNAL_REPLIES[0]}
150
+ isDisabled
151
+ placeholder="Tell Swisper what to do instead"
152
+ />
153
+ </ChatInput>
81
154
  ),
82
155
  };
83
156
 
84
- export const Controlled: Story = {
85
- render: function ControlledStory() {
86
- const [value, setValue] = useState('');
157
+ /** A reply Swisper is already acting on: it can't be edited, but stays readable and selectable. */
158
+ export const ReadOnly: Story = {
159
+ parameters: { controls: { disable: true } },
160
+ render: () => (
161
+ <ChatInput className={fieldClassName}>
162
+ <ChatInputTextarea
163
+ value={SIGNAL_REPLIES[0]}
164
+ isReadOnly
165
+ placeholder="Tell Swisper what to do instead"
166
+ />
167
+ </ChatInput>
168
+ ),
169
+ };
170
+
171
+ /** The value is Markdown both ways: headings, lists, code and quotes load into the editor and come back in `onChange`, shown below it. */
172
+ export const ControlledMarkdown: Story = {
173
+ parameters: { controls: { disable: true } },
174
+ render: function ControlledMarkdownStory() {
175
+ const [value, setValue] = useState(MARKDOWN_DRAFT);
87
176
 
88
177
  return (
89
- <div className="flex flex-col gap-2">
90
- <ChatInput className="min-h-[80px]">
178
+ <div className="flex flex-col gap-8">
179
+ <ChatInput className="w-full rounded-md border border-form-fields-border bg-paper-elevation-1 px-12 py-6 data-[focused=true]:border-primary-main">
91
180
  <ChatInputTextarea
181
+ autoFocus={false}
92
182
  value={value}
183
+ placeholder="Write a follow-up"
93
184
  onChange={setValue}
94
- placeholder="Input your message..."
95
185
  />
96
- <ChatInputStateDebug />
97
186
  </ChatInput>
98
187
 
99
- <div>
100
- <button
101
- type="button"
102
- onClick={() =>
103
- setValue(
104
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
105
- )
106
- }
107
- >
108
- Set long value
109
- </button>
110
- <button type="button" onClick={() => setValue('')}>
111
- Clear
112
- </button>
113
- <p className="text-sm text-text-secondary">
114
- Value: {value.length > 0 ? value : '(empty)'}
115
- </p>
188
+ <div className="flex gap-8">
189
+ <Button size="sm" onClick={() => setValue(MARKDOWN_DRAFT)}>
190
+ Load the draft
191
+ </Button>
192
+ <Button size="sm" variant="tertiary" onClick={() => setValue('')}>
193
+ Clear draft
194
+ </Button>
116
195
  </div>
196
+
197
+ <Typography variant="caption-md" fontFamily="mono" asChild>
198
+ <pre
199
+ aria-label="Markdown value"
200
+ className="rounded-sm bg-paper-elevation-1 p-12 whitespace-pre-wrap text-text-secondary"
201
+ >
202
+ {value || 'No draft'}
203
+ </pre>
204
+ </Typography>
117
205
  </div>
118
206
  );
119
207
  },
120
208
  };
121
209
 
122
- const presetMessage =
123
- 'Hello! This message is preset. You can focus and select it, but editing depends on the story state.';
210
+ interface QuickReplyProps {
211
+ placeholder: string;
212
+ onSend: (message: string) => void;
213
+ }
124
214
 
125
- export const Disabled: Story = {
126
- render: function DisabledStory() {
127
- const [value] = useState(presetMessage);
215
+ function QuickReply({ placeholder, onSend }: QuickReplyProps) {
216
+ const [value, setValue] = useState('');
217
+ const [lastSent, setLastSent] = useState<string | null>(null);
128
218
 
129
- return (
130
- <div className="flex flex-col gap-2">
131
- <ChatInput className="min-h-[80px]">
132
- <ChatInputTextarea value={value} isDisabled placeholder="Disabled chat input" />
133
- <ChatInputStateDebug />
134
- </ChatInput>
135
- <p className="text-sm text-text-secondary">Disabled: not editable and not tab-focusable.</p>
136
- </div>
137
- );
138
- },
139
- };
219
+ function handleKeyDown(event: KeyboardEvent<HTMLDivElement>) {
220
+ // Shift+Enter falls through to the editor, which adds a line.
221
+ if (event.key !== 'Enter' || event.shiftKey) {
222
+ return;
223
+ }
140
224
 
141
- export const ReadOnly: Story = {
142
- render: function ReadOnlyStory() {
143
- const [value] = useState(presetMessage);
225
+ // Without this the editor inserts a paragraph as well.
226
+ event.preventDefault();
144
227
 
145
- return (
146
- <div className="flex flex-col gap-2">
147
- <ChatInput className="min-h-[80px]">
148
- <ChatInputTextarea value={value} isReadOnly placeholder="Read-only chat input" />
149
- <ChatInputStateDebug />
150
- </ChatInput>
151
- <p className="text-sm text-text-secondary">
152
- Read-only: not editable, but focusable and selectable.
153
- </p>
154
- </div>
155
- );
156
- },
228
+ const message = value.trim();
229
+
230
+ if (!message) {
231
+ return;
232
+ }
233
+
234
+ onSend(message);
235
+ setLastSent(message);
236
+ setValue('');
237
+ }
238
+
239
+ return (
240
+ <div className="flex flex-col gap-8">
241
+ <ChatInput className={fieldClassName}>
242
+ <ChatInputTextarea
243
+ autoFocus={false}
244
+ value={value}
245
+ placeholder={placeholder}
246
+ onChange={setValue}
247
+ onKeyDown={handleKeyDown}
248
+ />
249
+ </ChatInput>
250
+ <Typography variant="caption-md" className="text-text-tertiary">
251
+ Enter sends, Shift+Enter adds a line.
252
+ </Typography>
253
+ {lastSent !== null && (
254
+ <Typography variant="caption-md" className="text-text-secondary">
255
+ Sent: {lastSent}
256
+ </Typography>
257
+ )}
258
+ </div>
259
+ );
260
+ }
261
+
262
+ type QuickReplyStory = StoryObj<typeof QuickReply>;
263
+
264
+ /** Send on Enter is the consumer's `onKeyDown`: it prevents the default, sends the trimmed draft and clears the value. */
265
+ export const SubmitOnEnter: QuickReplyStory = {
266
+ parameters: { controls: { disable: true } },
267
+ args: { placeholder: 'Tell Swisper what to do instead', onSend: fn() },
268
+ render: (args) => <QuickReply {...args} />,
157
269
  };
158
270
 
159
- const LOREM_MARKDOWN = `# Lorem ipsum dolor
271
+ interface SignalReplyInputProps {
272
+ placeholder: string;
273
+ onAction: (action: string) => void;
274
+ }
160
275
 
161
- **Bold lorem** and *italic dolor* sit amet, consectetur adipiscing elit.
276
+ function SignalReplyInput({ placeholder, onAction }: SignalReplyInputProps) {
277
+ const [value, setValue] = useState('');
162
278
 
163
- ## Consectetur adipiscing
279
+ function handleSubmit() {
280
+ const trimmed = value.trim();
164
281
 
165
- - First bullet with lorem ipsum
166
- - Second item with **emphasis**
167
- - Third item with *italic notes*
282
+ if (!trimmed) {
283
+ return;
284
+ }
168
285
 
169
- \`\`\`
170
- const example = "fenced code block";
171
- console.log(example);
172
- \`\`\`
286
+ onAction(trimmed);
287
+ setValue('');
288
+ }
173
289
 
174
- > Blockquote: Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
290
+ function handleFormSubmit(event: FormEvent<HTMLFormElement>) {
291
+ event.preventDefault();
292
+ handleSubmit();
293
+ }
175
294
 
176
- Plain paragraph ending the sample.`;
295
+ function handleKeyDown(event: KeyboardEvent<HTMLDivElement>) {
296
+ if (event.key === 'Enter' && !event.shiftKey) {
297
+ event.preventDefault();
298
+ handleSubmit();
299
+ }
300
+ }
177
301
 
178
- export const ControlledMarkdown: Story = {
179
- render: function ControlledMarkdownStory() {
180
- const [value, setValue] = useState(LOREM_MARKDOWN);
302
+ return (
303
+ <form className="flex w-full items-end gap-8" onSubmit={handleFormSubmit}>
304
+ <ChatInput className={fieldClassName}>
305
+ <ChatInputTextarea
306
+ autoFocus={false}
307
+ value={value}
308
+ placeholder={placeholder}
309
+ onChange={setValue}
310
+ onKeyDown={handleKeyDown}
311
+ />
312
+ </ChatInput>
313
+ <IconButton type="submit" size="md" variant="primary" aria-label="Send reply">
314
+ <EnterIcon />
315
+ </IconButton>
316
+ </form>
317
+ );
318
+ }
181
319
 
182
- return (
183
- <div className="flex flex-col gap-4">
184
- <ChatInput className="min-h-[80px]">
185
- <ChatInputTextarea
186
- value={value}
187
- onChange={setValue}
188
- placeholder="Input your message..."
189
- />
190
- <ChatInputStateDebug />
191
- </ChatInput>
320
+ type SignalReplyInputStory = StoryObj<typeof SignalReplyInput>;
192
321
 
193
- <div className="flex gap-2">
194
- <button type="button" onClick={() => setValue(LOREM_MARKDOWN)}>
195
- Load sample
196
- </button>
197
- <button type="button" onClick={() => setValue('')}>
198
- Clear
199
- </button>
200
- </div>
322
+ /** A small composer built from the editor and a send button beside it: the custom reply under a notification's suggested actions. */
323
+ export const SimplePromptBox: SignalReplyInputStory = {
324
+ parameters: { controls: { disable: true } },
325
+ args: { placeholder: 'Tell Swisper what to do instead', onAction: fn() },
326
+ render: (args) => <SignalReplyInput {...args} />,
327
+ };
201
328
 
202
- <pre
203
- className="rounded-lg p-3 text-xs whitespace-pre-wrap"
204
- style={{ background: '#1a1a2e', color: '#e0e0e0' }}
205
- >
206
- {value || '(empty)'}
207
- </pre>
208
- </div>
209
- );
329
+ /** Typing fills the editor and flips the root's empty and focused attributes; an empty draft shows the placeholder. */
330
+ export const DefaultTypeAndFocus: Story = {
331
+ ...Default,
332
+ tags: ['e2e', '!autodocs'],
333
+ play: async ({ canvas, canvasElement, userEvent, step }) => {
334
+ const editor = canvas.getByRole('textbox', { name: 'Chat input' });
335
+ const root = canvasElement.querySelector('[data-slot="chat-input"]');
336
+
337
+ await step('Starts empty, unfocused, with the placeholder', async () => {
338
+ await expect(root).toHaveAttribute('data-empty', 'true');
339
+ await expect(root).toHaveAttribute('data-focused', 'false');
340
+ await expect(root).toHaveAttribute('aria-invalid', 'false');
341
+ await expect(editor).toHaveAttribute('aria-placeholder', 'Tell Swisper what to do instead');
342
+ await expect(canvas.getByText('Tell Swisper what to do instead')).toBeVisible();
343
+ });
344
+
345
+ await step('Every element a consumer styles carries its slot name', async () => {
346
+ await expect(editor).toHaveAttribute('data-slot', 'chat-input-editable');
347
+ await expect(editor.parentElement).toHaveAttribute('data-slot', 'chat-input-textarea');
348
+ await expect(canvas.getByText('Tell Swisper what to do instead')).toHaveAttribute(
349
+ 'data-slot',
350
+ 'chat-input-placeholder',
351
+ );
352
+ });
353
+
354
+ await step('Clicking focuses the editor', async () => {
355
+ await userEvent.click(editor);
356
+ await expect(root).toHaveAttribute('data-focused', 'true');
357
+ });
358
+
359
+ await step('Typing hides the placeholder', async () => {
360
+ await userEvent.keyboard('Move it to Friday');
361
+ await expect(editor).toHaveTextContent('Move it to Friday');
362
+ await expect(root).toHaveAttribute('data-empty', 'false');
363
+ await expect(canvas.queryByText('Tell Swisper what to do instead')).toBeNull();
364
+ });
365
+
366
+ await step('Leaving the editor clears the focused state', async () => {
367
+ await userEvent.tab();
368
+ await expect(root).toHaveAttribute('data-focused', 'false');
369
+ });
210
370
  },
211
371
  };
212
372
 
213
- export const SubmitOnEnter: Story = {
214
- render: function SubmitOnEnterStory() {
215
- const [value, setValue] = useState('');
216
- const [lastSubmitted, setLastSubmitted] = useState<string | null>(null);
373
+ /** The editor is focused as soon as the story mounts, and the context reports it. */
374
+ export const AutoFocusOnMount: Story = {
375
+ ...AutoFocus,
376
+ tags: ['e2e', '!autodocs'],
377
+ play: async ({ canvas }) => {
378
+ await expect(canvas.getByRole('textbox', { name: 'Chat input' })).toHaveFocus();
379
+ await expect(await canvas.findByText('Focused · Empty')).toBeVisible();
380
+ },
381
+ };
217
382
 
218
- return (
219
- <div className="flex flex-col gap-2">
220
- <ChatInput className="min-h-[80px]">
221
- <ChatInputTextarea
222
- value={value}
223
- onChange={setValue}
224
- placeholder="Press Enter to submit, Shift+Enter for newline"
225
- onKeyDown={(event) => {
226
- if (event.key !== 'Enter' || event.shiftKey || !value.trim()) {
227
- return;
228
- }
229
-
230
- event.preventDefault();
231
- setLastSubmitted(value);
232
- setValue('');
233
- }}
234
- />
235
- <ChatInputStateDebug />
236
- </ChatInput>
383
+ /** Setting `value` replaces the content, and an empty string clears it and brings the placeholder back. */
384
+ export const ControlledFillAndClear: ReplyDraftStory = {
385
+ ...Controlled,
386
+ tags: ['e2e', '!autodocs'],
387
+ args: { suggestions: SIGNAL_REPLIES.slice(1), onChange: fn() },
388
+ play: async ({ args, canvas, canvasElement, userEvent, step }) => {
389
+ const editor = canvas.getByRole('textbox', { name: 'Chat input' });
390
+ const root = canvasElement.querySelector('[data-slot="chat-input"]');
391
+
392
+ await step('Picking a reply fills the editor', async () => {
393
+ await userEvent.click(canvas.getByRole('button', { name: 'Decline the design review' }));
394
+ await expect(editor).toHaveTextContent('Decline the design review');
395
+ await expect(root).toHaveAttribute('data-empty', 'false');
396
+ await expect(args.onChange).toHaveBeenLastCalledWith('Decline the design review');
397
+ });
398
+
399
+ await step('Picking another replaces it', async () => {
400
+ await userEvent.click(canvas.getByRole('button', { name: /^Ask Marc/ }));
401
+ await expect(editor).toHaveTextContent(SIGNAL_REPLIES[2]);
402
+ await expect(editor).not.toHaveTextContent('Decline the design review');
403
+ });
404
+
405
+ await step('Clearing empties it and brings the placeholder back', async () => {
406
+ await userEvent.click(canvas.getByRole('button', { name: 'Clear draft' }));
407
+ await expect(editor).toHaveTextContent('');
408
+ await expect(root).toHaveAttribute('data-empty', 'true');
409
+ await expect(canvas.getByText('Tell Swisper what to do instead')).toBeVisible();
410
+ });
411
+ },
412
+ };
237
413
 
238
- <p className="text-sm text-text-secondary">
239
- Enter submits and clears. Shift+Enter inserts a newline.
240
- </p>
241
- <p className="text-sm text-text-secondary">Last submitted: {lastSubmitted ?? '(none)'}</p>
242
- </div>
243
- );
414
+ /** A disabled editor is not editable, is marked disabled, and typing at it changes nothing. */
415
+ export const DisabledBlocksEditing: Story = {
416
+ ...Disabled,
417
+ tags: ['e2e', '!autodocs'],
418
+ play: async ({ canvas, canvasElement, userEvent }) => {
419
+ const editor = canvas.getByRole('textbox', { name: 'Chat input' });
420
+ const textarea = canvasElement.querySelector('[data-slot="chat-input-textarea"]');
421
+
422
+ await expect(editor).toHaveTextContent(SIGNAL_REPLIES[0]);
423
+ await expect(editor).toHaveAttribute('contenteditable', 'false');
424
+ await expect(textarea).toHaveAttribute('data-disabled', 'true');
425
+ await expect(textarea).toHaveAttribute('aria-disabled', 'true');
426
+ await expect(textarea).toHaveAttribute('data-readonly', 'false');
427
+
428
+ // Disabled also skips autoFocus, which is on by default here.
429
+ await expect(editor).not.toHaveFocus();
430
+ await userEvent.click(editor);
431
+ await userEvent.keyboard(' today');
432
+ await expect(editor).toHaveTextContent(SIGNAL_REPLIES[0]);
244
433
  },
245
434
  };
246
435
 
247
- export const SimplePromptBox: Story = {
248
- render: function SimplePromptBoxStory() {
249
- const [value, setValue] = useState('');
436
+ /** A read-only editor is not editable and is marked read-only, not disabled. */
437
+ export const ReadOnlyBlocksEditing: Story = {
438
+ ...ReadOnly,
439
+ tags: ['e2e', '!autodocs'],
440
+ play: async ({ canvas, canvasElement, userEvent }) => {
441
+ const editor = canvas.getByRole('textbox', { name: 'Chat input' });
442
+ const textarea = canvasElement.querySelector('[data-slot="chat-input-textarea"]');
443
+
444
+ await expect(editor).toHaveAttribute('contenteditable', 'false');
445
+ await expect(editor).toHaveAttribute('aria-readonly', 'true');
446
+ await expect(textarea).toHaveAttribute('data-readonly', 'true');
447
+ await expect(textarea).toHaveAttribute('aria-readonly', 'true');
448
+ await expect(textarea).toHaveAttribute('data-disabled', 'false');
449
+
450
+ await expect(editor).not.toHaveFocus();
451
+ await userEvent.click(editor);
452
+ await userEvent.keyboard(' today');
453
+ await expect(editor).toHaveTextContent(SIGNAL_REPLIES[0]);
454
+ },
455
+ };
250
456
 
251
- function handlePostMessage() {
252
- setValue('');
253
- }
457
+ /** Loads a Markdown draft as formatted blocks and reports edits back as Markdown. */
458
+ export const ControlledMarkdownRoundTrip: Story = {
459
+ ...ControlledMarkdown,
460
+ tags: ['e2e', '!autodocs'],
461
+ play: async ({ canvas, userEvent, step }) => {
462
+ const editor = canvas.getByRole('textbox', { name: 'Chat input' });
463
+ const markdown = canvas.getByLabelText('Markdown value');
464
+
465
+ await step('Renders the Markdown as blocks, not as source', async () => {
466
+ await expect(editor.querySelector('h1')).toHaveTextContent('Board meeting follow-up');
467
+ await expect(editor.querySelectorAll('li')).toHaveLength(3);
468
+ await expect(editor.querySelector('blockquote')).toHaveTextContent(/12 November/);
469
+ await expect(editor).not.toHaveTextContent('# Board');
470
+ });
471
+
472
+ await step('Clearing and typing reports plain Markdown', async () => {
473
+ await userEvent.click(canvas.getByRole('button', { name: 'Clear draft' }));
474
+ await expect(markdown).toHaveTextContent('No draft');
475
+ await userEvent.click(editor);
476
+ await userEvent.keyboard('Thanks, all good');
477
+ await expect(markdown).toHaveTextContent('Thanks, all good');
478
+ });
479
+
480
+ await step('Loading the draft again restores the blocks', async () => {
481
+ await userEvent.click(canvas.getByRole('button', { name: 'Load the draft' }));
482
+ await expect(editor.querySelector('h2')).toHaveTextContent('Next steps');
483
+ await expect(markdown).toHaveTextContent('## Next steps');
484
+ });
485
+ },
486
+ };
254
487
 
255
- return (
256
- <div className="flex w-full items-end gap-4 p-4">
257
- <ChatInput
258
- className={cn(
259
- 'max-h-[120px] min-h-[36px]',
260
- 'w-full overflow-y-auto rounded-[20px]',
261
- 'border border-solid border-transparent bg-paper-elevation-1 px-2.5 py-1.5 transition-[border-color] duration-150 outline-none',
262
- 'data-[focused=true]:border-primary-main data-[focused=true]:bg-paper-elevation-2',
263
- )}
264
- >
265
- <ChatInputTextarea
266
- placeholder="Input your message..."
267
- className="text-white"
268
- value={value}
269
- onChange={setValue}
270
- onKeyDown={(event) => {
271
- if (event.key === 'Enter' && !event.shiftKey) {
272
- event.preventDefault();
273
- handlePostMessage();
274
- }
275
- }}
276
- />
277
- </ChatInput>
488
+ /** Enter sends the trimmed draft and clears the editor; Shift+Enter and an empty draft send nothing. */
489
+ export const SubmitOnEnterSends: QuickReplyStory = {
490
+ ...SubmitOnEnter,
491
+ tags: ['e2e', '!autodocs'],
492
+ args: { placeholder: 'Tell Swisper what to do instead', onSend: fn() },
493
+ play: async ({ args, canvas, userEvent, step }) => {
494
+ const editor = canvas.getByRole('textbox', { name: 'Chat input' });
495
+
496
+ await step('Enter on an empty draft sends nothing', async () => {
497
+ await userEvent.click(editor);
498
+ await userEvent.keyboard('{Enter}');
499
+ await expect(args.onSend).not.toHaveBeenCalled();
500
+ await expect(editor).toHaveTextContent('');
501
+ });
502
+
503
+ await step('Shift+Enter adds a line and does not send', async () => {
504
+ await userEvent.keyboard('Move the design review');
505
+ await userEvent.keyboard('{Shift>}{Enter}{/Shift}');
506
+ await userEvent.keyboard('to Friday');
507
+ await expect(args.onSend).not.toHaveBeenCalled();
508
+ await expect(editor).toHaveTextContent(/Move the design review\s*to Friday/);
509
+ });
510
+
511
+ await step('Enter sends once and clears the editor', async () => {
512
+ await userEvent.keyboard('{Enter}');
513
+ await expect(args.onSend).toHaveBeenCalledTimes(1);
514
+ await expect(args.onSend).toHaveBeenCalledWith(
515
+ expect.stringMatching(/^Move the design review/),
516
+ );
517
+ await expect(editor).toHaveTextContent('');
518
+ await expect(await canvas.findByText(/^Sent: Move the design review/)).toBeVisible();
519
+ });
520
+ },
521
+ };
522
+
523
+ /** The send button submits the draft the same way Enter does, and does nothing while the draft is empty. */
524
+ export const SimplePromptBoxSendWithButton: SignalReplyInputStory = {
525
+ ...SimplePromptBox,
526
+ tags: ['e2e', '!autodocs'],
527
+ args: { placeholder: 'Tell Swisper what to do instead', onAction: fn() },
528
+ play: async ({ args, canvas, userEvent, step }) => {
529
+ const editor = canvas.getByRole('textbox', { name: 'Chat input' });
530
+ const send = canvas.getByRole('button', { name: 'Send reply' });
531
+
532
+ await step('An empty draft is not sent', async () => {
533
+ await userEvent.click(send);
534
+ await expect(args.onAction).not.toHaveBeenCalled();
535
+ });
536
+
537
+ await step('The button sends the draft and clears the editor', async () => {
538
+ await userEvent.click(editor);
539
+ await userEvent.keyboard(' Decline the design review ');
540
+ await userEvent.click(send);
541
+ await expect(args.onAction).toHaveBeenCalledTimes(1);
542
+ await expect(args.onAction).toHaveBeenCalledWith('Decline the design review');
543
+ await expect(editor).toHaveTextContent('');
544
+ });
545
+
546
+ await step('Enter sends the next one', async () => {
547
+ await userEvent.click(editor);
548
+ await userEvent.keyboard('Move it to Friday{Enter}');
549
+ await expect(args.onAction).toHaveBeenLastCalledWith('Move it to Friday');
550
+ await expect(args.onAction).toHaveBeenCalledTimes(2);
551
+ await expect(editor).toHaveTextContent('');
552
+ });
553
+ },
554
+ };
278
555
 
279
- <IconButton
280
- size="md"
281
- variant="primary"
282
- color="primary"
283
- aria-label="Send message"
284
- onClick={handlePostMessage}
556
+ /** The editor in each place it's allowed: a canvas footer, the chat container's prompt slot, a chat composer and a panel footer. */
557
+ export const Examples: Story = {
558
+ parameters: { controls: { disable: true } },
559
+ render: () => (
560
+ <div className="flex flex-col gap-24">
561
+ <ParentBlock parent="web-chat-ui/CanvasShellFooter">
562
+ <div className="h-70 rounded-md border border-component-divider">
563
+ <CanvasShell>
564
+ <CanvasShellHeader>
565
+ <CanvasShellTitle>Board meeting follow-up</CanvasShellTitle>
566
+ </CanvasShellHeader>
567
+ <CanvasShellContent>
568
+ <Typography variant="body-small-high" className="text-text-secondary">
569
+ Thanks for joining on short notice. The revised budget follows by Friday, and the
570
+ next session is on 12 November at 14:00.
571
+ </Typography>
572
+ </CanvasShellContent>
573
+ <CanvasShellFooter className="flex-col items-stretch">
574
+ <ChatInput className={fieldClassName}>
575
+ <ChatInputTextarea autoFocus={false} placeholder="Ask for a change to this draft" />
576
+ </ChatInput>
577
+ </CanvasShellFooter>
578
+ </CanvasShell>
579
+ </div>
580
+ </ParentBlock>
581
+
582
+ <ParentBlock parent="web-chat-ui/ChatContainerPrompt">
583
+ <div className="h-50 rounded-md border border-component-divider">
584
+ <ChatContainer>
585
+ <Typography
586
+ variant="body-small-high"
587
+ className="m-message min-h-0 flex-1 text-text-secondary"
588
+ >
589
+ Your Thursday has one conflict: the board meeting and the design review both start at
590
+ 14:00.
591
+ </Typography>
592
+ <ChatContainerPrompt className="m-message">
593
+ <ChatInput className={fieldClassName}>
594
+ <ChatInputTextarea autoFocus={false} placeholder="How can I help?" />
595
+ </ChatInput>
596
+ </ChatContainerPrompt>
597
+ </ChatContainer>
598
+ </div>
599
+ </ParentBlock>
600
+
601
+ <ParentBlock parent="chat composer">
602
+ <div role="group" aria-label="Chat composer">
603
+ <SignalReplyInput placeholder="How can I help?" onAction={fn()} />
604
+ </div>
605
+ </ParentBlock>
606
+
607
+ <ParentBlock parent="panel footer">
608
+ <aside
609
+ aria-label="Notifications"
610
+ className="flex flex-col rounded-md border border-component-divider bg-paper-elevation-0"
285
611
  >
286
- <EnterIcon />
287
- </IconButton>
288
- </div>
612
+ <div className="flex flex-col gap-4 p-16">
613
+ <Typography variant="body-small-high" fontWeight="medium">
614
+ {CALENDAR_SIGNAL.title}
615
+ </Typography>
616
+ <Typography variant="body-small-high" className="text-text-secondary">
617
+ {CALENDAR_SIGNAL.body}
618
+ </Typography>
619
+ </div>
620
+ <footer className="border-t border-component-divider p-16">
621
+ <ChatInput className={fieldClassName}>
622
+ <ChatInputTextarea autoFocus={false} placeholder="Tell Swisper what to do instead" />
623
+ </ChatInput>
624
+ </footer>
625
+ </aside>
626
+ </ParentBlock>
627
+ </div>
628
+ ),
629
+ };
630
+
631
+ // A custom Lexical plugin: anything rendered inside ChatInputTextarea can reach the editor.
632
+ function ClearOnEscapePlugin() {
633
+ const [editor] = useLexicalComposerContext();
634
+
635
+ useEffect(() => {
636
+ return editor.registerCommand(
637
+ KEY_ESCAPE_COMMAND,
638
+ () => {
639
+ editor.update(() => {
640
+ $getRoot().clear();
641
+ });
642
+
643
+ return true;
644
+ },
645
+ COMMAND_PRIORITY_LOW,
289
646
  );
647
+ }, [editor]);
648
+
649
+ return null;
650
+ }
651
+
652
+ interface ChatInputPlaygroundProps {
653
+ className: string;
654
+ placeholder: string;
655
+ value: string;
656
+ autoFocus: boolean;
657
+ isDisabled: boolean;
658
+ isReadOnly: boolean;
659
+ hasStateReadout: boolean;
660
+ hasClearOnEscape: boolean;
661
+ onChange: (value: string) => void;
662
+ onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
663
+ }
664
+
665
+ function ChatInputPlayground({
666
+ className,
667
+ placeholder,
668
+ value,
669
+ autoFocus,
670
+ isDisabled,
671
+ isReadOnly,
672
+ hasStateReadout,
673
+ hasClearOnEscape,
674
+ onChange,
675
+ onKeyDown,
676
+ }: ChatInputPlaygroundProps) {
677
+ return (
678
+ <ChatInput className={className}>
679
+ <ChatInputTextarea
680
+ value={value}
681
+ placeholder={placeholder}
682
+ autoFocus={autoFocus}
683
+ isDisabled={isDisabled}
684
+ isReadOnly={isReadOnly}
685
+ onChange={onChange}
686
+ onKeyDown={onKeyDown}
687
+ >
688
+ {hasClearOnEscape && <ClearOnEscapePlugin />}
689
+ </ChatInputTextarea>
690
+ {hasStateReadout && <ComposerStateReadout />}
691
+ </ChatInput>
692
+ );
693
+ }
694
+
695
+ /** The editor with a state readout and a custom plugin, and every textarea prop on the Controls panel. */
696
+ export const Playground: StoryObj<typeof ChatInputPlayground> = {
697
+ tags: ['!autodocs'],
698
+ args: {
699
+ className: fieldClassName,
700
+ placeholder: 'Tell Swisper what to do instead',
701
+ value: SIGNAL_REPLIES[2],
702
+ autoFocus: false,
703
+ isDisabled: false,
704
+ isReadOnly: false,
705
+ hasStateReadout: true,
706
+ hasClearOnEscape: true,
707
+ onChange: fn(),
708
+ onKeyDown: fn(),
709
+ },
710
+ argTypes: {
711
+ className: {
712
+ control: 'text',
713
+ description:
714
+ '`className` on `ChatInput`, which ships unstyled: the border, background and focus colour of the field.',
715
+ },
716
+ placeholder: {
717
+ control: 'text',
718
+ description: '`placeholder` on `ChatInputTextarea`; also its `aria-placeholder`.',
719
+ },
720
+ value: {
721
+ control: 'text',
722
+ description:
723
+ '`value` on `ChatInputTextarea`, as Markdown. Changing it replaces what is in the editor.',
724
+ },
725
+ autoFocus: {
726
+ control: 'boolean',
727
+ description:
728
+ '`autoFocus` on `ChatInputTextarea`. Read on mount, so remount the story to see it.',
729
+ table: { defaultValue: { summary: 'true' } },
730
+ },
731
+ isDisabled: {
732
+ control: 'boolean',
733
+ description: 'Blocks editing and selection and dims the textarea.',
734
+ table: { defaultValue: { summary: 'false' } },
735
+ },
736
+ isReadOnly: {
737
+ control: 'boolean',
738
+ description: 'Blocks editing but keeps the text selectable.',
739
+ table: { defaultValue: { summary: 'false' } },
740
+ },
741
+ hasStateReadout: {
742
+ control: 'boolean',
743
+ description: 'Renders a sibling that reads `useChatInputContext`.',
744
+ },
745
+ hasClearOnEscape: {
746
+ control: 'boolean',
747
+ description:
748
+ 'Renders a custom Lexical plugin inside `ChatInputTextarea`: Escape clears the draft.',
749
+ },
750
+ onChange: { description: 'Called with the content as Markdown on every edit.' },
751
+ onKeyDown: { description: 'Key handler on the editable element.' },
290
752
  },
753
+ render: (args) => <ChatInputPlayground {...args} />,
291
754
  };