@swisper.ai/web-chat-ui 0.0.2

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 (609) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +251 -0
  3. package/dist/components/canvas-shell/canvas-shell.d.ts +64 -0
  4. package/dist/components/canvas-shell/canvas-shell.d.ts.map +1 -0
  5. package/dist/components/canvas-shell/canvas-shell.stories.d.ts +26 -0
  6. package/dist/components/canvas-shell/canvas-shell.stories.d.ts.map +1 -0
  7. package/dist/components/canvas-shell/index.d.ts +2 -0
  8. package/dist/components/canvas-shell/index.d.ts.map +1 -0
  9. package/dist/components/card-item-picker/card-item-picker-context.d.ts +21 -0
  10. package/dist/components/card-item-picker/card-item-picker-context.d.ts.map +1 -0
  11. package/dist/components/card-item-picker/card-item-picker-list.d.ts +24 -0
  12. package/dist/components/card-item-picker/card-item-picker-list.d.ts.map +1 -0
  13. package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts +28 -0
  14. package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts.map +1 -0
  15. package/dist/components/card-item-picker/card-item-picker-row.d.ts +12 -0
  16. package/dist/components/card-item-picker/card-item-picker-row.d.ts.map +1 -0
  17. package/dist/components/card-item-picker/card-item-picker.stories.d.ts +19 -0
  18. package/dist/components/card-item-picker/card-item-picker.stories.d.ts.map +1 -0
  19. package/dist/components/card-item-picker/index.d.ts +9 -0
  20. package/dist/components/card-item-picker/index.d.ts.map +1 -0
  21. package/dist/components/chat-card/chat-card.d.ts +4 -0
  22. package/dist/components/chat-card/chat-card.d.ts.map +1 -0
  23. package/dist/components/chat-card/chat-card.stories.d.ts +11 -0
  24. package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -0
  25. package/dist/components/chat-card/components/chat-card-body.d.ts +22 -0
  26. package/dist/components/chat-card/components/chat-card-body.d.ts.map +1 -0
  27. package/dist/components/chat-card/components/chat-card-footer.d.ts +20 -0
  28. package/dist/components/chat-card/components/chat-card-footer.d.ts.map +1 -0
  29. package/dist/components/chat-card/components/chat-card-form.d.ts +28 -0
  30. package/dist/components/chat-card/components/chat-card-form.d.ts.map +1 -0
  31. package/dist/components/chat-card/components/chat-card-header.d.ts +36 -0
  32. package/dist/components/chat-card/components/chat-card-header.d.ts.map +1 -0
  33. package/dist/components/chat-card/components/index.d.ts +5 -0
  34. package/dist/components/chat-card/components/index.d.ts.map +1 -0
  35. package/dist/components/chat-card/context.d.ts +13 -0
  36. package/dist/components/chat-card/context.d.ts.map +1 -0
  37. package/dist/components/chat-card/contexts.d.ts +16 -0
  38. package/dist/components/chat-card/contexts.d.ts.map +1 -0
  39. package/dist/components/chat-card/hooks.d.ts +13 -0
  40. package/dist/components/chat-card/hooks.d.ts.map +1 -0
  41. package/dist/components/chat-card/index.d.ts +6 -0
  42. package/dist/components/chat-card/index.d.ts.map +1 -0
  43. package/dist/components/chat-card/types.d.ts +21 -0
  44. package/dist/components/chat-card/types.d.ts.map +1 -0
  45. package/dist/components/chat-card-container/chat-card-container.d.ts +43 -0
  46. package/dist/components/chat-card-container/chat-card-container.d.ts.map +1 -0
  47. package/dist/components/chat-card-container/chat-card-container.stories.d.ts +17 -0
  48. package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -0
  49. package/dist/components/chat-card-container/index.d.ts +3 -0
  50. package/dist/components/chat-card-container/index.d.ts.map +1 -0
  51. package/dist/components/chat-container/chat-container.d.ts +51 -0
  52. package/dist/components/chat-container/chat-container.d.ts.map +1 -0
  53. package/dist/components/chat-container/chat-container.stories.d.ts +21 -0
  54. package/dist/components/chat-container/chat-container.stories.d.ts.map +1 -0
  55. package/dist/components/chat-container/index.d.ts +3 -0
  56. package/dist/components/chat-container/index.d.ts.map +1 -0
  57. package/dist/components/chat-input/chat-input.d.ts +35 -0
  58. package/dist/components/chat-input/chat-input.d.ts.map +1 -0
  59. package/dist/components/chat-input/chat-input.stories.d.ts +14 -0
  60. package/dist/components/chat-input/chat-input.stories.d.ts.map +1 -0
  61. package/dist/components/chat-input/index.d.ts +3 -0
  62. package/dist/components/chat-input/index.d.ts.map +1 -0
  63. package/dist/components/chat-input/plugins/auto-focus-plugin.d.ts +8 -0
  64. package/dist/components/chat-input/plugins/auto-focus-plugin.d.ts.map +1 -0
  65. package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts +6 -0
  66. package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts.map +1 -0
  67. package/dist/components/chat-input/plugins/disabled-plugin.d.ts +7 -0
  68. package/dist/components/chat-input/plugins/disabled-plugin.d.ts.map +1 -0
  69. package/dist/components/chat-input/plugins/focus-plugin.d.ts +6 -0
  70. package/dist/components/chat-input/plugins/focus-plugin.d.ts.map +1 -0
  71. package/dist/components/chat-input/plugins/has-value-plugin.d.ts +6 -0
  72. package/dist/components/chat-input/plugins/has-value-plugin.d.ts.map +1 -0
  73. package/dist/components/chat-input/plugins/hooks.d.ts +2 -0
  74. package/dist/components/chat-input/plugins/hooks.d.ts.map +1 -0
  75. package/dist/components/chat-input/plugins/index.d.ts +8 -0
  76. package/dist/components/chat-input/plugins/index.d.ts.map +1 -0
  77. package/dist/components/chat-input/plugins/markdown-plain-paste-plugin.d.ts +2 -0
  78. package/dist/components/chat-input/plugins/markdown-plain-paste-plugin.d.ts.map +1 -0
  79. package/dist/components/chat-input/plugins/utils.d.ts +4 -0
  80. package/dist/components/chat-input/plugins/utils.d.ts.map +1 -0
  81. package/dist/components/chat-input/plugins/value-plugin.d.ts +6 -0
  82. package/dist/components/chat-input/plugins/value-plugin.d.ts.map +1 -0
  83. package/dist/components/chat-input/transformers.d.ts +3 -0
  84. package/dist/components/chat-input/transformers.d.ts.map +1 -0
  85. package/dist/components/chat-list/chat-list-item.d.ts +8 -0
  86. package/dist/components/chat-list/chat-list-item.d.ts.map +1 -0
  87. package/dist/components/chat-list/chat-list-items.d.ts +11 -0
  88. package/dist/components/chat-list/chat-list-items.d.ts.map +1 -0
  89. package/dist/components/chat-list/chat-list.d.ts +63 -0
  90. package/dist/components/chat-list/chat-list.d.ts.map +1 -0
  91. package/dist/components/chat-list/chat-list.stories.d.ts +13 -0
  92. package/dist/components/chat-list/chat-list.stories.d.ts.map +1 -0
  93. package/dist/components/chat-list/index.d.ts +4 -0
  94. package/dist/components/chat-list/index.d.ts.map +1 -0
  95. package/dist/components/chat-message/chat-message.d.ts +17 -0
  96. package/dist/components/chat-message/chat-message.d.ts.map +1 -0
  97. package/dist/components/chat-message/chat-message.stories.d.ts +11 -0
  98. package/dist/components/chat-message/chat-message.stories.d.ts.map +1 -0
  99. package/dist/components/chat-message/index.d.ts +2 -0
  100. package/dist/components/chat-message/index.d.ts.map +1 -0
  101. package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts +9 -0
  102. package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts.map +1 -0
  103. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts +30 -0
  104. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts.map +1 -0
  105. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts +11 -0
  106. package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts.map +1 -0
  107. package/dist/components/chat-message-attachment-card/index.d.ts +4 -0
  108. package/dist/components/chat-message-attachment-card/index.d.ts.map +1 -0
  109. package/dist/components/chat-message-attachment-card/utils.d.ts +5 -0
  110. package/dist/components/chat-message-attachment-card/utils.d.ts.map +1 -0
  111. package/dist/components/chat-message-history/chat-message-history.d.ts +48 -0
  112. package/dist/components/chat-message-history/chat-message-history.d.ts.map +1 -0
  113. package/dist/components/chat-message-history/chat-message-history.stories.d.ts +7 -0
  114. package/dist/components/chat-message-history/chat-message-history.stories.d.ts.map +1 -0
  115. package/dist/components/chat-message-history/index.d.ts +2 -0
  116. package/dist/components/chat-message-history/index.d.ts.map +1 -0
  117. package/dist/components/chat-message-response/chat-message-response.d.ts +7 -0
  118. package/dist/components/chat-message-response/chat-message-response.d.ts.map +1 -0
  119. package/dist/components/chat-message-response/chat-message-response.stories.d.ts +7 -0
  120. package/dist/components/chat-message-response/chat-message-response.stories.d.ts.map +1 -0
  121. package/dist/components/chat-message-response/index.d.ts +2 -0
  122. package/dist/components/chat-message-response/index.d.ts.map +1 -0
  123. package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts +25 -0
  124. package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts.map +1 -0
  125. package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts +7 -0
  126. package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts.map +1 -0
  127. package/dist/components/chat-message-toolbar/index.d.ts +2 -0
  128. package/dist/components/chat-message-toolbar/index.d.ts.map +1 -0
  129. package/dist/components/chat-messages/chat-messages.d.ts +24 -0
  130. package/dist/components/chat-messages/chat-messages.d.ts.map +1 -0
  131. package/dist/components/chat-messages/chat-messages.stories.d.ts +8 -0
  132. package/dist/components/chat-messages/chat-messages.stories.d.ts.map +1 -0
  133. package/dist/components/chat-messages/index.d.ts +2 -0
  134. package/dist/components/chat-messages/index.d.ts.map +1 -0
  135. package/dist/components/chat-notification-card/chat-notification-card.d.ts +114 -0
  136. package/dist/components/chat-notification-card/chat-notification-card.d.ts.map +1 -0
  137. package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts +10 -0
  138. package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts.map +1 -0
  139. package/dist/components/chat-notification-card/index.d.ts +4 -0
  140. package/dist/components/chat-notification-card/index.d.ts.map +1 -0
  141. package/dist/components/chat-notification-card/types.d.ts +2 -0
  142. package/dist/components/chat-notification-card/types.d.ts.map +1 -0
  143. package/dist/components/chat-notification-card/utils.d.ts +3 -0
  144. package/dist/components/chat-notification-card/utils.d.ts.map +1 -0
  145. package/dist/components/chat-notification-popup/chat-notification-popup.d.ts +12 -0
  146. package/dist/components/chat-notification-popup/chat-notification-popup.d.ts.map +1 -0
  147. package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts +8 -0
  148. package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts.map +1 -0
  149. package/dist/components/chat-notification-popup/index.d.ts +2 -0
  150. package/dist/components/chat-notification-popup/index.d.ts.map +1 -0
  151. package/dist/components/chat-prompt-box/chat-prompt-box-context.d.ts +17 -0
  152. package/dist/components/chat-prompt-box/chat-prompt-box-context.d.ts.map +1 -0
  153. package/dist/components/chat-prompt-box/chat-prompt-box-focus-plugin.d.ts +2 -0
  154. package/dist/components/chat-prompt-box/chat-prompt-box-focus-plugin.d.ts.map +1 -0
  155. package/dist/components/chat-prompt-box/chat-prompt-box.d.ts +27 -0
  156. package/dist/components/chat-prompt-box/chat-prompt-box.d.ts.map +1 -0
  157. package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts +9 -0
  158. package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts.map +1 -0
  159. package/dist/components/chat-prompt-box/index.d.ts +3 -0
  160. package/dist/components/chat-prompt-box/index.d.ts.map +1 -0
  161. package/dist/components/chat-reply/chat-reply.d.ts +23 -0
  162. package/dist/components/chat-reply/chat-reply.d.ts.map +1 -0
  163. package/dist/components/chat-reply/chat-reply.stories.d.ts +7 -0
  164. package/dist/components/chat-reply/chat-reply.stories.d.ts.map +1 -0
  165. package/dist/components/chat-reply/index.d.ts +2 -0
  166. package/dist/components/chat-reply/index.d.ts.map +1 -0
  167. package/dist/components/chat-suggestion/chat-suggestion.d.ts +37 -0
  168. package/dist/components/chat-suggestion/chat-suggestion.d.ts.map +1 -0
  169. package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts +9 -0
  170. package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts.map +1 -0
  171. package/dist/components/chat-suggestion/index.d.ts +2 -0
  172. package/dist/components/chat-suggestion/index.d.ts.map +1 -0
  173. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +47 -0
  174. package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -0
  175. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +10 -0
  176. package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -0
  177. package/dist/components/chat-thinking-process/index.d.ts +2 -0
  178. package/dist/components/chat-thinking-process/index.d.ts.map +1 -0
  179. package/dist/components/chat-thread/chat-thread.d.ts +78 -0
  180. package/dist/components/chat-thread/chat-thread.d.ts.map +1 -0
  181. package/dist/components/chat-thread/chat-thread.stories.d.ts +14 -0
  182. package/dist/components/chat-thread/chat-thread.stories.d.ts.map +1 -0
  183. package/dist/components/chat-thread/index.d.ts +2 -0
  184. package/dist/components/chat-thread/index.d.ts.map +1 -0
  185. package/dist/components/deprecated-empty-state.d.ts +22 -0
  186. package/dist/components/deprecated-empty-state.d.ts.map +1 -0
  187. package/dist/components/index.d.ts +27 -0
  188. package/dist/components/index.d.ts.map +1 -0
  189. package/dist/components/markdown-viewer/hooks.d.ts +9 -0
  190. package/dist/components/markdown-viewer/hooks.d.ts.map +1 -0
  191. package/dist/components/markdown-viewer/index.d.ts +3 -0
  192. package/dist/components/markdown-viewer/index.d.ts.map +1 -0
  193. package/dist/components/markdown-viewer/markdown-viewer.d.ts +10 -0
  194. package/dist/components/markdown-viewer/markdown-viewer.d.ts.map +1 -0
  195. package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts +9 -0
  196. package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts.map +1 -0
  197. package/dist/components/markdown-viewer/types.d.ts +9 -0
  198. package/dist/components/markdown-viewer/types.d.ts.map +1 -0
  199. package/dist/components/markdown-viewer/utils.d.ts +3 -0
  200. package/dist/components/markdown-viewer/utils.d.ts.map +1 -0
  201. package/dist/components/new-chat-trigger/index.d.ts +2 -0
  202. package/dist/components/new-chat-trigger/index.d.ts.map +1 -0
  203. package/dist/components/new-chat-trigger/new-chat-trigger.d.ts +8 -0
  204. package/dist/components/new-chat-trigger/new-chat-trigger.d.ts.map +1 -0
  205. package/dist/components/rich-text-area/constants/index.d.ts +3 -0
  206. package/dist/components/rich-text-area/constants/index.d.ts.map +1 -0
  207. package/dist/components/rich-text-area/hooks.d.ts +3 -0
  208. package/dist/components/rich-text-area/hooks.d.ts.map +1 -0
  209. package/dist/components/rich-text-area/html-config.d.ts +4 -0
  210. package/dist/components/rich-text-area/html-config.d.ts.map +1 -0
  211. package/dist/components/rich-text-area/index.d.ts +7 -0
  212. package/dist/components/rich-text-area/index.d.ts.map +1 -0
  213. package/dist/components/rich-text-area/nodes/div-block-node.d.ts +18 -0
  214. package/dist/components/rich-text-area/nodes/div-block-node.d.ts.map +1 -0
  215. package/dist/components/rich-text-area/nodes/image-node.d.ts +24 -0
  216. package/dist/components/rich-text-area/nodes/image-node.d.ts.map +1 -0
  217. package/dist/components/rich-text-area/plugins/blur-plugin.d.ts +6 -0
  218. package/dist/components/rich-text-area/plugins/blur-plugin.d.ts.map +1 -0
  219. package/dist/components/rich-text-area/plugins/controlled-plugin.d.ts +7 -0
  220. package/dist/components/rich-text-area/plugins/controlled-plugin.d.ts.map +1 -0
  221. package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts +7 -0
  222. package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts.map +1 -0
  223. package/dist/components/rich-text-area/plugins/disabled-plugin.d.ts +6 -0
  224. package/dist/components/rich-text-area/plugins/disabled-plugin.d.ts.map +1 -0
  225. package/dist/components/rich-text-area/plugins/file-attachment-plugin.d.ts +10 -0
  226. package/dist/components/rich-text-area/plugins/file-attachment-plugin.d.ts.map +1 -0
  227. package/dist/components/rich-text-area/plugins/focus-plugin.d.ts +6 -0
  228. package/dist/components/rich-text-area/plugins/focus-plugin.d.ts.map +1 -0
  229. package/dist/components/rich-text-area/plugins/html-paste-plugin.d.ts +19 -0
  230. package/dist/components/rich-text-area/plugins/html-paste-plugin.d.ts.map +1 -0
  231. package/dist/components/rich-text-area/plugins/image-drop-plugin.d.ts +12 -0
  232. package/dist/components/rich-text-area/plugins/image-drop-plugin.d.ts.map +1 -0
  233. package/dist/components/rich-text-area/plugins/index.d.ts +11 -0
  234. package/dist/components/rich-text-area/plugins/index.d.ts.map +1 -0
  235. package/dist/components/rich-text-area/plugins/markdown-plain-paste-plugin.d.ts +2 -0
  236. package/dist/components/rich-text-area/plugins/markdown-plain-paste-plugin.d.ts.map +1 -0
  237. package/dist/components/rich-text-area/plugins/value-plugin.d.ts +7 -0
  238. package/dist/components/rich-text-area/plugins/value-plugin.d.ts.map +1 -0
  239. package/dist/components/rich-text-area/rich-text-area.d.ts +20 -0
  240. package/dist/components/rich-text-area/rich-text-area.d.ts.map +1 -0
  241. package/dist/components/rich-text-area/rich-text-area.stories.d.ts +7 -0
  242. package/dist/components/rich-text-area/rich-text-area.stories.d.ts.map +1 -0
  243. package/dist/components/rich-text-area/styled.d.ts +3 -0
  244. package/dist/components/rich-text-area/styled.d.ts.map +1 -0
  245. package/dist/components/rich-text-area/transformers.d.ts +16 -0
  246. package/dist/components/rich-text-area/transformers.d.ts.map +1 -0
  247. package/dist/components/rich-text-area/types.d.ts +8 -0
  248. package/dist/components/rich-text-area/types.d.ts.map +1 -0
  249. package/dist/components/rich-text-area/utils/index.d.ts +6 -0
  250. package/dist/components/rich-text-area/utils/index.d.ts.map +1 -0
  251. package/dist/components/rich-text-field/components/alignment-select.d.ts +5 -0
  252. package/dist/components/rich-text-field/components/alignment-select.d.ts.map +1 -0
  253. package/dist/components/rich-text-field/components/attachment-button.d.ts +3 -0
  254. package/dist/components/rich-text-field/components/attachment-button.d.ts.map +1 -0
  255. package/dist/components/rich-text-field/components/bold-button.d.ts +3 -0
  256. package/dist/components/rich-text-field/components/bold-button.d.ts.map +1 -0
  257. package/dist/components/rich-text-field/components/clean-format-button.d.ts +3 -0
  258. package/dist/components/rich-text-field/components/clean-format-button.d.ts.map +1 -0
  259. package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts +11 -0
  260. package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts.map +1 -0
  261. package/dist/components/rich-text-field/components/image-button.d.ts +3 -0
  262. package/dist/components/rich-text-field/components/image-button.d.ts.map +1 -0
  263. package/dist/components/rich-text-field/components/index.d.ts +14 -0
  264. package/dist/components/rich-text-field/components/index.d.ts.map +1 -0
  265. package/dist/components/rich-text-field/components/italic-button.d.ts +3 -0
  266. package/dist/components/rich-text-field/components/italic-button.d.ts.map +1 -0
  267. package/dist/components/rich-text-field/components/link-button.d.ts +3 -0
  268. package/dist/components/rich-text-field/components/link-button.d.ts.map +1 -0
  269. package/dist/components/rich-text-field/components/size-select.d.ts +5 -0
  270. package/dist/components/rich-text-field/components/size-select.d.ts.map +1 -0
  271. package/dist/components/rich-text-field/components/text-color-button.d.ts +3 -0
  272. package/dist/components/rich-text-field/components/text-color-button.d.ts.map +1 -0
  273. package/dist/components/rich-text-field/components/toolbar-button.d.ts +6 -0
  274. package/dist/components/rich-text-field/components/toolbar-button.d.ts.map +1 -0
  275. package/dist/components/rich-text-field/components/toolbar-select.d.ts +5 -0
  276. package/dist/components/rich-text-field/components/toolbar-select.d.ts.map +1 -0
  277. package/dist/components/rich-text-field/components/typography-select.d.ts +5 -0
  278. package/dist/components/rich-text-field/components/typography-select.d.ts.map +1 -0
  279. package/dist/components/rich-text-field/components/underline-button.d.ts +3 -0
  280. package/dist/components/rich-text-field/components/underline-button.d.ts.map +1 -0
  281. package/dist/components/rich-text-field/constants.d.ts +57 -0
  282. package/dist/components/rich-text-field/constants.d.ts.map +1 -0
  283. package/dist/components/rich-text-field/context.d.ts +26 -0
  284. package/dist/components/rich-text-field/context.d.ts.map +1 -0
  285. package/dist/components/rich-text-field/index.d.ts +3 -0
  286. package/dist/components/rich-text-field/index.d.ts.map +1 -0
  287. package/dist/components/rich-text-field/rich-text-field.d.ts +17 -0
  288. package/dist/components/rich-text-field/rich-text-field.d.ts.map +1 -0
  289. package/dist/components/rich-text-field/rich-text-field.stories.d.ts +10 -0
  290. package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -0
  291. package/dist/components/rich-text-field/utils.d.ts +1759 -0
  292. package/dist/components/rich-text-field/utils.d.ts.map +1 -0
  293. package/dist/components/spinner/index.d.ts +2 -0
  294. package/dist/components/spinner/index.d.ts.map +1 -0
  295. package/dist/components/spinner/spinner.d.ts +9 -0
  296. package/dist/components/spinner/spinner.d.ts.map +1 -0
  297. package/dist/components/spinner/spinner.stories.d.ts +8 -0
  298. package/dist/components/spinner/spinner.stories.d.ts.map +1 -0
  299. package/dist/contexts/chat-context/chat-context.d.ts +20 -0
  300. package/dist/contexts/chat-context/chat-context.d.ts.map +1 -0
  301. package/dist/contexts/chat-context/index.d.ts +2 -0
  302. package/dist/contexts/chat-context/index.d.ts.map +1 -0
  303. package/dist/contexts/chat-context/utils.d.ts +3 -0
  304. package/dist/contexts/chat-context/utils.d.ts.map +1 -0
  305. package/dist/contexts/chat-conversation-context/chat-conversation-context.d.ts +20 -0
  306. package/dist/contexts/chat-conversation-context/chat-conversation-context.d.ts.map +1 -0
  307. package/dist/contexts/chat-conversation-context/index.d.ts +2 -0
  308. package/dist/contexts/chat-conversation-context/index.d.ts.map +1 -0
  309. package/dist/contexts/index.d.ts +3 -0
  310. package/dist/contexts/index.d.ts.map +1 -0
  311. package/dist/docs/agent.stories.d.ts +41 -0
  312. package/dist/docs/agent.stories.d.ts.map +1 -0
  313. package/dist/docs/chat-panel.d.ts +33 -0
  314. package/dist/docs/chat-panel.d.ts.map +1 -0
  315. package/dist/docs/chatbot-panel.d.ts +20 -0
  316. package/dist/docs/chatbot-panel.d.ts.map +1 -0
  317. package/dist/docs/chatbot.stories.d.ts +11 -0
  318. package/dist/docs/chatbot.stories.d.ts.map +1 -0
  319. package/dist/domain/actions/constants.d.ts +2 -0
  320. package/dist/domain/actions/constants.d.ts.map +1 -0
  321. package/dist/domain/actions/hooks/index.d.ts +3 -0
  322. package/dist/domain/actions/hooks/index.d.ts.map +1 -0
  323. package/dist/domain/actions/index.d.ts +5 -0
  324. package/dist/domain/actions/index.d.ts.map +1 -0
  325. package/dist/domain/actions/types.d.ts +7 -0
  326. package/dist/domain/actions/types.d.ts.map +1 -0
  327. package/dist/domain/actions/utils/index.d.ts +11 -0
  328. package/dist/domain/actions/utils/index.d.ts.map +1 -0
  329. package/dist/domain/index.d.ts +2 -0
  330. package/dist/domain/index.d.ts.map +1 -0
  331. package/dist/hooks/index.d.ts +7 -0
  332. package/dist/hooks/index.d.ts.map +1 -0
  333. package/dist/hooks/use-chat-prompt-placeholder.d.ts +6 -0
  334. package/dist/hooks/use-chat-prompt-placeholder.d.ts.map +1 -0
  335. package/dist/hooks/use-chat-stream-message.d.ts +42 -0
  336. package/dist/hooks/use-chat-stream-message.d.ts.map +1 -0
  337. package/dist/hooks/use-current-chat-id.d.ts +2 -0
  338. package/dist/hooks/use-current-chat-id.d.ts.map +1 -0
  339. package/dist/hooks/use-is-current-chat-new.d.ts +2 -0
  340. package/dist/hooks/use-is-current-chat-new.d.ts.map +1 -0
  341. package/dist/hooks/use-loaded-chat-ids.d.ts +9 -0
  342. package/dist/hooks/use-loaded-chat-ids.d.ts.map +1 -0
  343. package/dist/hooks/use-on-chat-changed.d.ts +9 -0
  344. package/dist/hooks/use-on-chat-changed.d.ts.map +1 -0
  345. package/dist/index.css +2 -0
  346. package/dist/index.d.ts +7 -0
  347. package/dist/index.d.ts.map +1 -0
  348. package/dist/index.es.js +4404 -0
  349. package/dist/index.es.js.map +1 -0
  350. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +95 -0
  351. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +1 -0
  352. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +24 -0
  353. package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +1 -0
  354. package/dist/layouts/chat-card-list-layout/index.d.ts +3 -0
  355. package/dist/layouts/chat-card-list-layout/index.d.ts.map +1 -0
  356. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts +84 -0
  357. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts.map +1 -0
  358. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts +45 -0
  359. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts.map +1 -0
  360. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +37 -0
  361. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +1 -0
  362. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts +81 -0
  363. package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts.map +1 -0
  364. package/dist/layouts/chat-card-three-column-layout/index.d.ts +5 -0
  365. package/dist/layouts/chat-card-three-column-layout/index.d.ts.map +1 -0
  366. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +31 -0
  367. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +1 -0
  368. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts +12 -0
  369. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts.map +1 -0
  370. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +19 -0
  371. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +1 -0
  372. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts +35 -0
  373. package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts.map +1 -0
  374. package/dist/layouts/chat-card-two-column-layout/index.d.ts +4 -0
  375. package/dist/layouts/chat-card-two-column-layout/index.d.ts.map +1 -0
  376. package/dist/layouts/index.d.ts +4 -0
  377. package/dist/layouts/index.d.ts.map +1 -0
  378. package/dist/types.d.ts +22 -0
  379. package/dist/types.d.ts.map +1 -0
  380. package/dist/utils/use-streaming-markdown.d.ts +18 -0
  381. package/dist/utils/use-streaming-markdown.d.ts.map +1 -0
  382. package/package.json +155 -0
  383. package/src/__tests__/setup.ts +5 -0
  384. package/src/components/canvas-shell/canvas-shell.json +126 -0
  385. package/src/components/canvas-shell/canvas-shell.stories.tsx +194 -0
  386. package/src/components/canvas-shell/canvas-shell.test.tsx +205 -0
  387. package/src/components/canvas-shell/canvas-shell.tsx +250 -0
  388. package/src/components/canvas-shell/index.ts +19 -0
  389. package/src/components/card-item-picker/__tests__/card-item-picker.spec.tsx +279 -0
  390. package/src/components/card-item-picker/card-item-picker-context.tsx +44 -0
  391. package/src/components/card-item-picker/card-item-picker-list.tsx +95 -0
  392. package/src/components/card-item-picker/card-item-picker-row-parts.tsx +96 -0
  393. package/src/components/card-item-picker/card-item-picker-row.tsx +109 -0
  394. package/src/components/card-item-picker/card-item-picker.json +147 -0
  395. package/src/components/card-item-picker/card-item-picker.stories.tsx +158 -0
  396. package/src/components/card-item-picker/index.ts +24 -0
  397. package/src/components/chat-card/__tests__/chat-card.spec.tsx +118 -0
  398. package/src/components/chat-card/chat-card.json +162 -0
  399. package/src/components/chat-card/chat-card.stories.tsx +349 -0
  400. package/src/components/chat-card/chat-card.tsx +106 -0
  401. package/src/components/chat-card/components/chat-card-body.tsx +115 -0
  402. package/src/components/chat-card/components/chat-card-footer.tsx +95 -0
  403. package/src/components/chat-card/components/chat-card-form.tsx +120 -0
  404. package/src/components/chat-card/components/chat-card-header.tsx +240 -0
  405. package/src/components/chat-card/components/index.ts +4 -0
  406. package/src/components/chat-card/context.tsx +34 -0
  407. package/src/components/chat-card/contexts.tsx +42 -0
  408. package/src/components/chat-card/hooks.ts +51 -0
  409. package/src/components/chat-card/index.ts +5 -0
  410. package/src/components/chat-card/types.ts +23 -0
  411. package/src/components/chat-card-container/chat-card-container.json +84 -0
  412. package/src/components/chat-card-container/chat-card-container.stories.tsx +149 -0
  413. package/src/components/chat-card-container/chat-card-container.tsx +75 -0
  414. package/src/components/chat-card-container/index.ts +2 -0
  415. package/src/components/chat-container/chat-container.json +93 -0
  416. package/src/components/chat-container/chat-container.stories.tsx +179 -0
  417. package/src/components/chat-container/chat-container.tsx +231 -0
  418. package/src/components/chat-container/index.ts +2 -0
  419. package/src/components/chat-input/chat-input.json +106 -0
  420. package/src/components/chat-input/chat-input.stories.tsx +291 -0
  421. package/src/components/chat-input/chat-input.tsx +220 -0
  422. package/src/components/chat-input/index.ts +2 -0
  423. package/src/components/chat-input/plugins/auto-focus-plugin.tsx +43 -0
  424. package/src/components/chat-input/plugins/controlled-value-plugin.tsx +47 -0
  425. package/src/components/chat-input/plugins/disabled-plugin.tsx +18 -0
  426. package/src/components/chat-input/plugins/focus-plugin.tsx +44 -0
  427. package/src/components/chat-input/plugins/has-value-plugin.tsx +51 -0
  428. package/src/components/chat-input/plugins/hooks.ts +7 -0
  429. package/src/components/chat-input/plugins/index.ts +7 -0
  430. package/src/components/chat-input/plugins/markdown-plain-paste-plugin.tsx +63 -0
  431. package/src/components/chat-input/plugins/utils.ts +48 -0
  432. package/src/components/chat-input/plugins/value-plugin.tsx +35 -0
  433. package/src/components/chat-input/transformers.ts +4 -0
  434. package/src/components/chat-list/chat-list-item.tsx +33 -0
  435. package/src/components/chat-list/chat-list-items.tsx +144 -0
  436. package/src/components/chat-list/chat-list.json +117 -0
  437. package/src/components/chat-list/chat-list.stories.tsx +332 -0
  438. package/src/components/chat-list/chat-list.tsx +278 -0
  439. package/src/components/chat-list/index.ts +18 -0
  440. package/src/components/chat-message/chat-message.json +105 -0
  441. package/src/components/chat-message/chat-message.stories.tsx +95 -0
  442. package/src/components/chat-message/chat-message.tsx +66 -0
  443. package/src/components/chat-message/index.ts +1 -0
  444. package/src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx +74 -0
  445. package/src/components/chat-message-attachment-card/chat-message-attachment-card.json +110 -0
  446. package/src/components/chat-message-attachment-card/chat-message-attachment-card.stories.tsx +131 -0
  447. package/src/components/chat-message-attachment-card/chat-message-attachment-card.tsx +142 -0
  448. package/src/components/chat-message-attachment-card/index.ts +12 -0
  449. package/src/components/chat-message-attachment-card/utils.ts +41 -0
  450. package/src/components/chat-message-history/chat-message-history.json +99 -0
  451. package/src/components/chat-message-history/chat-message-history.stories.tsx +136 -0
  452. package/src/components/chat-message-history/chat-message-history.tsx +277 -0
  453. package/src/components/chat-message-history/index.ts +13 -0
  454. package/src/components/chat-message-response/chat-message-response.json +68 -0
  455. package/src/components/chat-message-response/chat-message-response.stories.tsx +63 -0
  456. package/src/components/chat-message-response/chat-message-response.tsx +24 -0
  457. package/src/components/chat-message-response/index.ts +1 -0
  458. package/src/components/chat-message-toolbar/chat-message-toolbar.json +100 -0
  459. package/src/components/chat-message-toolbar/chat-message-toolbar.stories.tsx +62 -0
  460. package/src/components/chat-message-toolbar/chat-message-toolbar.tsx +97 -0
  461. package/src/components/chat-message-toolbar/index.ts +6 -0
  462. package/src/components/chat-messages/chat-messages.json +95 -0
  463. package/src/components/chat-messages/chat-messages.stories.tsx +284 -0
  464. package/src/components/chat-messages/chat-messages.tsx +264 -0
  465. package/src/components/chat-messages/index.ts +10 -0
  466. package/src/components/chat-notification-card/chat-notification-card.json +135 -0
  467. package/src/components/chat-notification-card/chat-notification-card.stories.tsx +290 -0
  468. package/src/components/chat-notification-card/chat-notification-card.tsx +684 -0
  469. package/src/components/chat-notification-card/index.ts +3 -0
  470. package/src/components/chat-notification-card/types.ts +1 -0
  471. package/src/components/chat-notification-card/utils.ts +34 -0
  472. package/src/components/chat-notification-popup/chat-notification-popup.json +97 -0
  473. package/src/components/chat-notification-popup/chat-notification-popup.stories.tsx +80 -0
  474. package/src/components/chat-notification-popup/chat-notification-popup.tsx +36 -0
  475. package/src/components/chat-notification-popup/index.ts +1 -0
  476. package/src/components/chat-prompt-box/chat-prompt-box-context.tsx +62 -0
  477. package/src/components/chat-prompt-box/chat-prompt-box-focus-plugin.tsx +22 -0
  478. package/src/components/chat-prompt-box/chat-prompt-box.json +106 -0
  479. package/src/components/chat-prompt-box/chat-prompt-box.stories.tsx +117 -0
  480. package/src/components/chat-prompt-box/chat-prompt-box.tsx +296 -0
  481. package/src/components/chat-prompt-box/index.ts +16 -0
  482. package/src/components/chat-reply/chat-reply.json +79 -0
  483. package/src/components/chat-reply/chat-reply.stories.tsx +72 -0
  484. package/src/components/chat-reply/chat-reply.tsx +103 -0
  485. package/src/components/chat-reply/index.ts +1 -0
  486. package/src/components/chat-suggestion/chat-suggestion.json +108 -0
  487. package/src/components/chat-suggestion/chat-suggestion.stories.tsx +147 -0
  488. package/src/components/chat-suggestion/chat-suggestion.tsx +184 -0
  489. package/src/components/chat-suggestion/index.ts +8 -0
  490. package/src/components/chat-thinking-process/chat-thinking-process.json +110 -0
  491. package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +202 -0
  492. package/src/components/chat-thinking-process/chat-thinking-process.tsx +268 -0
  493. package/src/components/chat-thinking-process/index.ts +9 -0
  494. package/src/components/chat-thread/__tests__/chat-thread.spec.tsx +385 -0
  495. package/src/components/chat-thread/chat-thread.json +120 -0
  496. package/src/components/chat-thread/chat-thread.stories.tsx +218 -0
  497. package/src/components/chat-thread/chat-thread.tsx +549 -0
  498. package/src/components/chat-thread/index.ts +18 -0
  499. package/src/components/deprecated-empty-state.ts +39 -0
  500. package/src/components/index.ts +26 -0
  501. package/src/components/markdown-viewer/hooks.ts +59 -0
  502. package/src/components/markdown-viewer/index.ts +2 -0
  503. package/src/components/markdown-viewer/markdown-viewer.json +84 -0
  504. package/src/components/markdown-viewer/markdown-viewer.stories.tsx +110 -0
  505. package/src/components/markdown-viewer/markdown-viewer.tsx +95 -0
  506. package/src/components/markdown-viewer/types.ts +10 -0
  507. package/src/components/markdown-viewer/utils.ts +5 -0
  508. package/src/components/new-chat-trigger/index.ts +1 -0
  509. package/src/components/new-chat-trigger/new-chat-trigger.tsx +29 -0
  510. package/src/components/rich-text-area/constants/index.ts +10 -0
  511. package/src/components/rich-text-area/hooks.ts +24 -0
  512. package/src/components/rich-text-area/html-config.ts +195 -0
  513. package/src/components/rich-text-area/index.ts +6 -0
  514. package/src/components/rich-text-area/nodes/div-block-node.tsx +145 -0
  515. package/src/components/rich-text-area/nodes/image-node.tsx +100 -0
  516. package/src/components/rich-text-area/plugins/blur-plugin.tsx +36 -0
  517. package/src/components/rich-text-area/plugins/controlled-plugin.tsx +23 -0
  518. package/src/components/rich-text-area/plugins/controlled-value-plugin.tsx +101 -0
  519. package/src/components/rich-text-area/plugins/disabled-plugin.tsx +17 -0
  520. package/src/components/rich-text-area/plugins/file-attachment-plugin.tsx +57 -0
  521. package/src/components/rich-text-area/plugins/focus-plugin.tsx +44 -0
  522. package/src/components/rich-text-area/plugins/html-paste-plugin.tsx +104 -0
  523. package/src/components/rich-text-area/plugins/image-drop-plugin.tsx +56 -0
  524. package/src/components/rich-text-area/plugins/index.ts +10 -0
  525. package/src/components/rich-text-area/plugins/markdown-plain-paste-plugin.tsx +63 -0
  526. package/src/components/rich-text-area/plugins/value-plugin.tsx +46 -0
  527. package/src/components/rich-text-area/rich-text-area.json +102 -0
  528. package/src/components/rich-text-area/rich-text-area.stories.tsx +140 -0
  529. package/src/components/rich-text-area/rich-text-area.tsx +156 -0
  530. package/src/components/rich-text-area/styled.tsx +20 -0
  531. package/src/components/rich-text-area/transformers.ts +175 -0
  532. package/src/components/rich-text-area/types.ts +8 -0
  533. package/src/components/rich-text-area/utils/index.ts +77 -0
  534. package/src/components/rich-text-field/components/alignment-select.tsx +103 -0
  535. package/src/components/rich-text-field/components/attachment-button.tsx +25 -0
  536. package/src/components/rich-text-field/components/bold-button.tsx +21 -0
  537. package/src/components/rich-text-field/components/clean-format-button.tsx +44 -0
  538. package/src/components/rich-text-field/components/formatting-toolbar-plugin.tsx +69 -0
  539. package/src/components/rich-text-field/components/image-button.tsx +11 -0
  540. package/src/components/rich-text-field/components/index.ts +14 -0
  541. package/src/components/rich-text-field/components/italic-button.tsx +21 -0
  542. package/src/components/rich-text-field/components/link-button.tsx +11 -0
  543. package/src/components/rich-text-field/components/size-select.tsx +27 -0
  544. package/src/components/rich-text-field/components/text-color-button.tsx +41 -0
  545. package/src/components/rich-text-field/components/toolbar-button.tsx +27 -0
  546. package/src/components/rich-text-field/components/toolbar-select.tsx +19 -0
  547. package/src/components/rich-text-field/components/typography-select.tsx +27 -0
  548. package/src/components/rich-text-field/components/underline-button.tsx +21 -0
  549. package/src/components/rich-text-field/constants.ts +33 -0
  550. package/src/components/rich-text-field/context.tsx +251 -0
  551. package/src/components/rich-text-field/index.tsx +6 -0
  552. package/src/components/rich-text-field/rich-text-field.json +118 -0
  553. package/src/components/rich-text-field/rich-text-field.stories.tsx +218 -0
  554. package/src/components/rich-text-field/rich-text-field.tsx +93 -0
  555. package/src/components/rich-text-field/utils.ts +532 -0
  556. package/src/components/spinner/index.ts +1 -0
  557. package/src/components/spinner/spinner.json +73 -0
  558. package/src/components/spinner/spinner.stories.tsx +41 -0
  559. package/src/components/spinner/spinner.tsx +32 -0
  560. package/src/contexts/chat-context/chat-context.tsx +97 -0
  561. package/src/contexts/chat-context/index.ts +1 -0
  562. package/src/contexts/chat-context/utils.ts +7 -0
  563. package/src/contexts/chat-conversation-context/chat-conversation-context.tsx +608 -0
  564. package/src/contexts/chat-conversation-context/index.ts +1 -0
  565. package/src/contexts/index.ts +2 -0
  566. package/src/docs/agent.stories.tsx +567 -0
  567. package/src/docs/chat-panel.tsx +174 -0
  568. package/src/docs/chatbot-panel.tsx +381 -0
  569. package/src/docs/chatbot.mdx +144 -0
  570. package/src/docs/chatbot.stories.tsx +63 -0
  571. package/src/domain/actions/constants.ts +1 -0
  572. package/src/domain/actions/hooks/index.ts +22 -0
  573. package/src/domain/actions/index.ts +4 -0
  574. package/src/domain/actions/types.ts +6 -0
  575. package/src/domain/actions/utils/index.ts +112 -0
  576. package/src/domain/index.ts +1 -0
  577. package/src/hooks/index.tsx +10 -0
  578. package/src/hooks/use-chat-prompt-placeholder.ts +7 -0
  579. package/src/hooks/use-chat-stream-message.ts +189 -0
  580. package/src/hooks/use-current-chat-id.ts +6 -0
  581. package/src/hooks/use-is-current-chat-new.ts +6 -0
  582. package/src/hooks/use-loaded-chat-ids.ts +32 -0
  583. package/src/hooks/use-on-chat-changed.ts +33 -0
  584. package/src/index.css +1 -0
  585. package/src/index.ts +6 -0
  586. package/src/layouts/chat-card-list-layout/__tests__/chat-card-list-layout.spec.tsx +204 -0
  587. package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +116 -0
  588. package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +190 -0
  589. package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +250 -0
  590. package/src/layouts/chat-card-list-layout/index.ts +11 -0
  591. package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.sizing.test.ts +73 -0
  592. package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.spec.tsx +282 -0
  593. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +131 -0
  594. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.ts +78 -0
  595. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +273 -0
  596. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.tsx +291 -0
  597. package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.ts +135 -0
  598. package/src/layouts/chat-card-three-column-layout/index.ts +24 -0
  599. package/src/layouts/chat-card-two-column-layout/__tests__/chat-card-two-column-layout.spec.tsx +109 -0
  600. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +97 -0
  601. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.ts +21 -0
  602. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +138 -0
  603. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +132 -0
  604. package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.ts +65 -0
  605. package/src/layouts/chat-card-two-column-layout/index.ts +17 -0
  606. package/src/layouts/index.ts +3 -0
  607. package/src/types.ts +29 -0
  608. package/src/utils/use-streaming-markdown.ts +113 -0
  609. package/tailwind.css +7 -0
@@ -0,0 +1,291 @@
1
+ import { Slot } from '@radix-ui/react-slot';
2
+ import { createContext, forwardRef, useCallback, useContext, useMemo } from 'react';
3
+ import type { ComponentProps, ForwardedRef, ReactNode } from 'react';
4
+
5
+ import { cn, useElementMeasure } from '@swisper.ai/web-core';
6
+
7
+ import { resolveLayout } from './chat-card-three-column-layout.sizing';
8
+ import {
9
+ DEFAULT_DETAILS_PLACEMENT,
10
+ chatCardThreeColumnLayoutDetailsVariants,
11
+ chatCardThreeColumnLayoutListVariants,
12
+ chatCardThreeColumnLayoutMainVariants,
13
+ chatCardThreeColumnLayoutPanelVariants,
14
+ chatCardThreeColumnLayoutVariants,
15
+ } from './chat-card-three-column-layout.variants';
16
+ import type { ChatCardThreeColumnLayoutDetailsPlacement } from './chat-card-three-column-layout.variants';
17
+
18
+ interface ChatCardThreeColumnLayoutContextValue {
19
+ isListFloating: boolean;
20
+ isDetailsFloating: boolean;
21
+ isDetailsSheet: boolean;
22
+ }
23
+
24
+ const ChatCardThreeColumnLayoutContext = createContext<ChatCardThreeColumnLayoutContextValue>(
25
+ null!,
26
+ );
27
+
28
+ function useChatCardThreeColumnLayoutContext(part: string) {
29
+ const context = useContext(ChatCardThreeColumnLayoutContext);
30
+
31
+ if (!context) {
32
+ throw new Error(
33
+ `[web-chat-ui] "${part}" must be used within a ChatCardThreeColumnLayout. ` +
34
+ 'It reads its floating state from the layout, so render ' +
35
+ 'it as a child of the ChatCardThreeColumnLayout element, not as a sibling of it.',
36
+ );
37
+ }
38
+
39
+ return context;
40
+ }
41
+
42
+ /**
43
+ * A pane's content, or a function of whether the pane is currently floating.
44
+ *
45
+ * The function form exists because a floating pane usually needs different content, not
46
+ * just different styling: the places card shows a vertical list in the column and a
47
+ * horizontal swipe strip when floating. CSS alone cannot swap the component tree.
48
+ */
49
+ export type ChatCardThreeColumnLayoutPaneChildren =
50
+ ReactNode | ((isFloating: boolean) => ReactNode);
51
+
52
+ function renderPane(children: ChatCardThreeColumnLayoutPaneChildren, isFloating: boolean) {
53
+ return typeof children === 'function' ? children(isFloating) : children;
54
+ }
55
+
56
+ export interface ChatCardThreeColumnLayoutProps extends ComponentProps<'div'> {
57
+ children: ReactNode;
58
+ /**
59
+ * Whether Details may take its own column. See `ChatCardThreeColumnLayoutDetailsPlacement`.
60
+ * It is on the root, not on Details, because the root's grid template has to change
61
+ * with it.
62
+ */
63
+ detailsPlacement?: ChatCardThreeColumnLayoutDetailsPlacement;
64
+ asChild?: boolean;
65
+ }
66
+
67
+ /** Hands one element to the measuring ref and the consumer's forwarded ref alike. */
68
+ function useMergedRef<T>(first: (node: T | null) => void, second: ForwardedRef<T>) {
69
+ return useCallback(
70
+ (node: T | null) => {
71
+ first(node);
72
+
73
+ if (typeof second === 'function') {
74
+ second(node);
75
+ } else if (second) {
76
+ second.current = node;
77
+ }
78
+ },
79
+ [first, second],
80
+ );
81
+ }
82
+
83
+ /**
84
+ * A three-pane card body: List (fixed column), Main (flexible), Details (floating or a
85
+ * right column).
86
+ *
87
+ * Which panes fit is decided by the layout's **own measured width**, not by viewport
88
+ * breakpoints. The card is sized by the chat window, and a sidebar, a split view or the
89
+ * Storybook panel all make the viewport claim room the card doesn't have (or the
90
+ * reverse). The root measures itself, resolves the panes once (`resolveLayout`), and
91
+ * publishes the result twice: as data attributes for the CSS, and through context for the render props. Both read the same numbers, so the content a
92
+ * render prop picks always matches where its pane is drawn.
93
+ *
94
+ * Height is not set here, because it belongs to the content (a map needs a fixed height, a
95
+ * table might not), so pass it in `className`.
96
+ */
97
+ export const ChatCardThreeColumnLayout = forwardRef<HTMLDivElement, ChatCardThreeColumnLayoutProps>(
98
+ function ChatCardThreeColumnLayout(
99
+ { children, className, detailsPlacement = DEFAULT_DETAILS_PLACEMENT, asChild = false, ...rest },
100
+ ref,
101
+ ) {
102
+ const { ref: measureRef, width } = useElementMeasure<HTMLDivElement>();
103
+ const mergedRef = useMergedRef(measureRef, ref);
104
+
105
+ const { size, isListFloating, isDetailsFloating, isDetailsSheet } = resolveLayout(
106
+ width,
107
+ detailsPlacement,
108
+ );
109
+
110
+ const contextValue = useMemo(
111
+ () => ({ isListFloating, isDetailsFloating, isDetailsSheet }),
112
+ [isListFloating, isDetailsFloating, isDetailsSheet],
113
+ );
114
+
115
+ const Component = asChild ? Slot : 'div';
116
+
117
+ return (
118
+ <ChatCardThreeColumnLayoutContext.Provider value={contextValue}>
119
+ <Component
120
+ ref={mergedRef}
121
+ data-testid="chat-card-three-column-layout"
122
+ data-slot="chat-card-three-column-layout"
123
+ data-details-placement={detailsPlacement}
124
+ data-size={size}
125
+ data-list-floating={isListFloating}
126
+ data-details-floating={isDetailsFloating}
127
+ className={cn(chatCardThreeColumnLayoutVariants(), className)}
128
+ {...rest}
129
+ >
130
+ {children}
131
+ </Component>
132
+ </ChatCardThreeColumnLayoutContext.Provider>
133
+ );
134
+ },
135
+ );
136
+
137
+ ChatCardThreeColumnLayout.displayName = 'ChatCardThreeColumnLayout';
138
+
139
+ export interface ChatCardThreeColumnLayoutListProps extends Omit<
140
+ ComponentProps<'aside'>,
141
+ 'children'
142
+ > {
143
+ children: ChatCardThreeColumnLayoutPaneChildren;
144
+ asChild?: boolean;
145
+ }
146
+
147
+ /**
148
+ * Column 1 when the layout has room for it beside a usable Main; otherwise a strip pinned
149
+ * to the bottom, over Main. It is the same element either way, so only the render prop's
150
+ * output changes when it switches.
151
+ *
152
+ * `data-floating` is set too, for styling the pane itself without a render prop.
153
+ */
154
+ export const ChatCardThreeColumnLayoutList = forwardRef<
155
+ HTMLDivElement,
156
+ ChatCardThreeColumnLayoutListProps
157
+ >(function ChatCardThreeColumnLayoutList({ children, className, asChild = false, ...rest }, ref) {
158
+ const { isListFloating } = useChatCardThreeColumnLayoutContext('ChatCardThreeColumnLayoutList');
159
+
160
+ const Component = asChild ? Slot : 'aside';
161
+
162
+ return (
163
+ <Component
164
+ ref={ref}
165
+ data-testid="chat-card-three-column-layout-list"
166
+ data-slot="chat-card-three-column-layout-list"
167
+ data-floating={isListFloating}
168
+ className={cn(chatCardThreeColumnLayoutListVariants(), className)}
169
+ {...rest}
170
+ >
171
+ {renderPane(children, isListFloating)}
172
+ </Component>
173
+ );
174
+ });
175
+
176
+ ChatCardThreeColumnLayoutList.displayName = 'ChatCardThreeColumnLayoutList';
177
+
178
+ export interface ChatCardThreeColumnLayoutMainProps extends ComponentProps<'main'> {
179
+ children: ReactNode;
180
+ asChild?: boolean;
181
+ }
182
+
183
+ /**
184
+ * Column 2, the flexible track. It never floats, so it takes plain children. It still
185
+ * requires the layout, because outside the grid its `[grid-area:main]` means nothing and
186
+ * the pane collapses without any error.
187
+ */
188
+ export const ChatCardThreeColumnLayoutMain = forwardRef<
189
+ HTMLDivElement,
190
+ ChatCardThreeColumnLayoutMainProps
191
+ >(function ChatCardThreeColumnLayoutMain({ children, className, asChild = false, ...rest }, ref) {
192
+ useChatCardThreeColumnLayoutContext('ChatCardThreeColumnLayoutMain');
193
+
194
+ const Component = asChild ? Slot : 'main';
195
+
196
+ return (
197
+ <Component
198
+ ref={ref}
199
+ data-testid="chat-card-three-column-layout-main"
200
+ data-slot="chat-card-three-column-layout-main"
201
+ className={cn(chatCardThreeColumnLayoutMainVariants(), className)}
202
+ {...rest}
203
+ >
204
+ {children}
205
+ </Component>
206
+ );
207
+ });
208
+
209
+ ChatCardThreeColumnLayoutMain.displayName = 'ChatCardThreeColumnLayoutMain';
210
+
211
+ export interface ChatCardThreeColumnLayoutDetailsProps extends Omit<
212
+ ComponentProps<'aside'>,
213
+ 'children'
214
+ > {
215
+ children: ChatCardThreeColumnLayoutPaneChildren;
216
+ asChild?: boolean;
217
+ }
218
+
219
+ /**
220
+ * Column 3. Mount it only while there is something to show: its presence is what adds the
221
+ * third grid track, so rendering it empty would reserve a blank column.
222
+ *
223
+ * It takes a column when the layout is wide enough and `detailsPlacement` allows it, and
224
+ * floats over Main otherwise: pinned to Main's right edge, or a bottom sheet on a narrow
225
+ * layout (`data-sheet`). `isFloating` in the render prop reflects all of that.
226
+ */
227
+ export const ChatCardThreeColumnLayoutDetails = forwardRef<
228
+ HTMLDivElement,
229
+ ChatCardThreeColumnLayoutDetailsProps
230
+ >(function ChatCardThreeColumnLayoutDetails(
231
+ { children, className, asChild = false, ...rest },
232
+ ref,
233
+ ) {
234
+ const { isDetailsFloating, isDetailsSheet } = useChatCardThreeColumnLayoutContext(
235
+ 'ChatCardThreeColumnLayoutDetails',
236
+ );
237
+
238
+ const Component = asChild ? Slot : 'aside';
239
+
240
+ return (
241
+ <Component
242
+ ref={ref}
243
+ data-testid="chat-card-three-column-layout-details"
244
+ data-slot="chat-card-three-column-layout-details"
245
+ data-floating={isDetailsFloating}
246
+ data-sheet={isDetailsSheet}
247
+ className={cn(chatCardThreeColumnLayoutDetailsVariants(), className)}
248
+ {...rest}
249
+ >
250
+ {renderPane(children, isDetailsFloating)}
251
+ </Component>
252
+ );
253
+ });
254
+
255
+ ChatCardThreeColumnLayoutDetails.displayName = 'ChatCardThreeColumnLayoutDetails';
256
+
257
+ export interface ChatCardThreeColumnLayoutPanelProps extends ComponentProps<'section'> {
258
+ children: ReactNode;
259
+ asChild?: boolean;
260
+ }
261
+
262
+ /**
263
+ * An overlay covering everything but the List column (the whole layout when List floats),
264
+ * inset 12px. Mount it only while it is open. Main and Details stay mounted under it, so
265
+ * a map keeps its viewport and the open Details item survives closing the Panel.
266
+ *
267
+ * The pane is transparent: draw the surface (background, radius, shadow) in its content,
268
+ * as for Details.
269
+ */
270
+ export const ChatCardThreeColumnLayoutPanel = forwardRef<
271
+ HTMLElement,
272
+ ChatCardThreeColumnLayoutPanelProps
273
+ >(function ChatCardThreeColumnLayoutPanel({ children, className, asChild = false, ...rest }, ref) {
274
+ const { isListFloating } = useChatCardThreeColumnLayoutContext('ChatCardThreeColumnLayoutPanel');
275
+ const Component = asChild ? Slot : 'section';
276
+
277
+ return (
278
+ <Component
279
+ ref={ref}
280
+ data-testid="chat-card-three-column-layout-panel"
281
+ data-slot="chat-card-three-column-layout-panel"
282
+ data-list-floating={isListFloating}
283
+ className={cn(chatCardThreeColumnLayoutPanelVariants(), className)}
284
+ {...rest}
285
+ >
286
+ {children}
287
+ </Component>
288
+ );
289
+ });
290
+
291
+ ChatCardThreeColumnLayoutPanel.displayName = 'ChatCardThreeColumnLayoutPanel';
@@ -0,0 +1,135 @@
1
+ import { cva } from 'class-variance-authority';
2
+
3
+ /**
4
+ * Whether Details may take its own right column.
5
+ *
6
+ * - `responsive` — a column whenever the layout is wide enough for List, Details and a
7
+ * usable Main side by side; floating over Main otherwise.
8
+ * - `floating` — always over Main, for a pane that is secondary at every size.
9
+ *
10
+ * There is no "always a column": at widths where it would not fit, Main would be squeezed
11
+ * below usefulness, which is exactly what the width check exists to prevent.
12
+ */
13
+ export type ChatCardThreeColumnLayoutDetailsPlacement = 'responsive' | 'floating';
14
+
15
+ /**
16
+ * `responsive` because it uses the room when it is there: `floating` would cover Main on
17
+ * a card with space to spare.
18
+ */
19
+ export const DEFAULT_DETAILS_PLACEMENT: ChatCardThreeColumnLayoutDetailsPlacement = 'responsive';
20
+
21
+ /*
22
+ * Every recipe below keys on data attributes the components set from the layout's measured
23
+ * width (`data-size`, `data-list-floating`, `data-details-floating` on the root;
24
+ * `data-floating`, `data-sheet` on each pane). `290px` and `358px` are `LIST_WIDTH_LG` and
25
+ * `PANE_WIDTH_XL` from `chat-card-three-column-layout.sizing.ts`, written out because
26
+ * Tailwind cannot read a constant. Change both together.
27
+ *
28
+ * The tiers are the original card's `md` / `lg` / `xl`, but none of the recipes uses viewport
29
+ * breakpoints: the card is sized by the chat window, not the viewport, so `lg:` / `xl:`
30
+ * would switch panes at the wrong widths.
31
+ *
32
+ * Using a recipe without its component means setting those attributes yourself.
33
+ *
34
+ * Class strings are written out in full because Tailwind finds classes by scanning source;
35
+ * a class assembled from a constant is never generated.
36
+ */
37
+
38
+ /**
39
+ * Root grid.
40
+ *
41
+ * The third track needs both "Details fits" (`data-details-floating=false`, from the
42
+ * width) and "Details is mounted" (`:has(> [data-slot=…-details])`). The second is CSS, not
43
+ * a prop, because consumers mount Details conditionally and a `hasDetails` prop could
44
+ * disagree with what is rendered.
45
+ */
46
+ export const chatCardThreeColumnLayoutVariants = cva([
47
+ 'relative grid gap-[8px]',
48
+ // sm + md — Main only; List floats as a strip and Details floats over Main
49
+ "grid-cols-[1fr] [grid-template-areas:'main']",
50
+ "data-[size=lg]:grid-cols-[290px_1fr] data-[size=lg]:[grid-template-areas:'list_main']",
51
+ "data-[size=xl]:grid-cols-[358px_1fr] data-[size=xl]:[grid-template-areas:'list_main']",
52
+ // xl with a mounted Details that is allowed a column
53
+ 'data-[details-floating=false]:has-[>[data-slot=chat-card-three-column-layout-details]]:grid-cols-[358px_1fr_358px]',
54
+ "data-[details-floating=false]:has-[>[data-slot=chat-card-three-column-layout-details]]:[grid-template-areas:'list_main_details']",
55
+ ]);
56
+
57
+ /**
58
+ * Column 1, or, when there is no room for it, a strip pinned to the bottom of the layout
59
+ * over Main. One element for both, so the pane never remounts when it switches; only what
60
+ * the consumer's render prop returns changes.
61
+ *
62
+ * Floating is `absolute` rather than a grid row so Main keeps the full height. In the
63
+ * column, `min-h-0` + `overflow-hidden` keep a long list inside the row. Without them the
64
+ * grid item grows to its content and the card gets taller instead of scrolling.
65
+ */
66
+ export const chatCardThreeColumnLayoutListVariants = cva([
67
+ 'min-w-0',
68
+ 'data-[floating=true]:absolute data-[floating=true]:bottom-0 data-[floating=true]:inset-x-0 data-[floating=true]:z-10',
69
+ 'data-[floating=false]:[grid-area:list] data-[floating=false]:min-h-0 data-[floating=false]:h-full data-[floating=false]:overflow-hidden',
70
+ ]);
71
+
72
+ /**
73
+ * Column 2, the flexible `1fr` track. `min-w-0` because a grid item's minimum width is its
74
+ * content by default: a map or a wide table would push the track past the card. `relative`
75
+ * so the consumer can anchor their own overlays to Main.
76
+ */
77
+ export const chatCardThreeColumnLayoutMainVariants = cva([
78
+ '[grid-area:main] relative min-w-0 min-h-0 h-full',
79
+ ]);
80
+
81
+ /**
82
+ * Column 3, or floating over Main. Floating shares Main's grid area instead of being
83
+ * `absolute`, so it is sized by the same track Main is.
84
+ *
85
+ * - pinned: the right edge of Main, at the same width the column would have, inset 12px
86
+ * - sheet: on a narrow layout, a bottom sheet at a fixed 85% height, so the pane does not
87
+ * change height as its content changes (the content scrolls instead)
88
+ *
89
+ * `z-20` keeps a floating Details above the floating List (`z-10`): an open Details is
90
+ * what the reader asked for last. `min-w-0` + `max-w-full` stop the fixed width from
91
+ * widening the `1fr` track past the card.
92
+ */
93
+ export const chatCardThreeColumnLayoutDetailsVariants = cva([
94
+ 'min-h-0 min-w-0 max-w-full',
95
+ 'data-[floating=false]:[grid-area:details] data-[floating=false]:h-full',
96
+ 'data-[floating=true]:z-20 data-[floating=true]:[grid-area:main]',
97
+ 'data-[floating=true]:data-[sheet=false]:w-[358px] data-[floating=true]:data-[sheet=false]:h-full data-[floating=true]:data-[sheet=false]:justify-self-end data-[floating=true]:data-[sheet=false]:self-stretch data-[floating=true]:data-[sheet=false]:p-[12px]',
98
+ 'data-[sheet=true]:w-full data-[sheet=true]:h-[85%] data-[sheet=true]:justify-self-start data-[sheet=true]:self-end',
99
+ ]);
100
+
101
+ /**
102
+ * An overlay over everything but the List column, inset 12px, for a view that takes over the
103
+ * card (all reviews, a filter form) while Main and Details stay mounted underneath.
104
+ *
105
+ * It spans columns in row 1 instead of being `absolute`, so it follows the grid template:
106
+ * from column 2 to the last one when List is a column, all of them when List floats. It
107
+ * never adds a track, so mounting it doesn't move Main. `z-30` keeps it above floating
108
+ * Details (`z-20`) and the List strip (`z-10`).
109
+ */
110
+ export const chatCardThreeColumnLayoutPanelVariants = cva([
111
+ 'relative z-30 min-w-0 min-h-0 h-full p-[12px] row-1',
112
+ 'data-[list-floating=false]:col-[2/-1]',
113
+ 'data-[list-floating=true]:col-span-full',
114
+ ]);
115
+
116
+ /**
117
+ * Width recipe for the `ChatCard` that wraps the layout.
118
+ *
119
+ * A grid of `1fr` tracks has no intrinsic width, so inside a shrink-to-fit message the card
120
+ * would collapse to nothing. It takes the whole chat window instead, minus the message
121
+ * gutter on both sides, up to 1432px (four 358px columns). The layout then decides which
122
+ * panes fit in whatever width that gives it. `ChatContainer` sets both variables.
123
+ *
124
+ * One cap, not a ladder of viewport steps: a step like `lg:min-w-[1074px]` held the card
125
+ * narrower than the chat window between breakpoints, and Details floated for no reason.
126
+ *
127
+ * Gated on `data-state=open`, which `ChatCard`'s `Collapsible` puts on the card element
128
+ * itself: a collapsed card is only a header, and holding it at full width would leave a
129
+ * wide empty bar in the thread. A non-collapsible card is always `open`.
130
+ */
131
+ export const chatCardThreeColumnLayoutCardVariants = cva([
132
+ 'data-[state=open]:w-(--message-list-content-width) data-[state=open]:mx-0',
133
+ // `100%` fallback, like every other read of the variable, for a card outside `ChatContainer`
134
+ 'data-[state=open]:min-w-[min(1432px,calc(var(--chat-window-width,100%)-var(--spacing-message)*2))]',
135
+ ]);
@@ -0,0 +1,24 @@
1
+ export {
2
+ ChatCardThreeColumnLayout,
3
+ ChatCardThreeColumnLayoutList,
4
+ ChatCardThreeColumnLayoutMain,
5
+ ChatCardThreeColumnLayoutDetails,
6
+ ChatCardThreeColumnLayoutPanel,
7
+ } from './chat-card-three-column-layout';
8
+ export type {
9
+ ChatCardThreeColumnLayoutProps,
10
+ ChatCardThreeColumnLayoutListProps,
11
+ ChatCardThreeColumnLayoutMainProps,
12
+ ChatCardThreeColumnLayoutDetailsProps,
13
+ ChatCardThreeColumnLayoutPanelProps,
14
+ ChatCardThreeColumnLayoutPaneChildren,
15
+ } from './chat-card-three-column-layout';
16
+ export {
17
+ chatCardThreeColumnLayoutVariants,
18
+ chatCardThreeColumnLayoutListVariants,
19
+ chatCardThreeColumnLayoutMainVariants,
20
+ chatCardThreeColumnLayoutDetailsVariants,
21
+ chatCardThreeColumnLayoutPanelVariants,
22
+ chatCardThreeColumnLayoutCardVariants,
23
+ } from './chat-card-three-column-layout.variants';
24
+ export type { ChatCardThreeColumnLayoutDetailsPlacement } from './chat-card-three-column-layout.variants';
@@ -0,0 +1,109 @@
1
+ import { cleanup, render, screen } from '@testing-library/react';
2
+ import { afterEach, describe, expect, test, vi } from 'vitest';
3
+
4
+ import {
5
+ ChatCardTwoColumnLayout,
6
+ ChatCardTwoColumnLayoutAside,
7
+ ChatCardTwoColumnLayoutMain,
8
+ } from '../chat-card-two-column-layout';
9
+ import { TWO_COLUMN_MIN_WIDTH } from '../chat-card-two-column-layout.sizing';
10
+
11
+ /**
12
+ * jsdom evaluates no container queries, so the switch itself is checked in Storybook. What
13
+ * this file locks is the structure the query depends on: the root is the named container,
14
+ * the panes sit directly in the grid it renders, and the threshold in the classes matches
15
+ * the sizing constants.
16
+ */
17
+
18
+ afterEach(() => {
19
+ cleanup();
20
+ vi.restoreAllMocks();
21
+ });
22
+
23
+ function renderLayout() {
24
+ return render(
25
+ <ChatCardTwoColumnLayout className="h-[480px]">
26
+ <ChatCardTwoColumnLayoutAside>list</ChatCardTwoColumnLayoutAside>
27
+ <ChatCardTwoColumnLayoutMain>chart</ChatCardTwoColumnLayoutMain>
28
+ </ChatCardTwoColumnLayout>,
29
+ );
30
+ }
31
+
32
+ describe('ChatCardTwoColumnLayout', () => {
33
+ test('the root is the named container and keeps the consumer className', () => {
34
+ renderLayout();
35
+
36
+ const root = screen.getByTestId('chat-card-two-column-layout');
37
+
38
+ expect(root.className).toContain('@container/chat-card-two-column-layout');
39
+ expect(root.className).toContain('h-[480px]');
40
+ });
41
+
42
+ test('Aside and Main are direct children of the grid, in order', () => {
43
+ renderLayout();
44
+
45
+ const grid = screen.getByTestId('chat-card-two-column-layout-grid');
46
+
47
+ expect(grid.parentElement).toBe(screen.getByTestId('chat-card-two-column-layout'));
48
+ expect([...grid.children].map((child) => child.getAttribute('data-slot'))).toEqual([
49
+ 'chat-card-two-column-layout-aside',
50
+ 'chat-card-two-column-layout-main',
51
+ ]);
52
+ });
53
+
54
+ test('the grid switches at the width the sizing file derives', () => {
55
+ renderLayout();
56
+
57
+ expect(TWO_COLUMN_MIN_WIDTH).toBe(744);
58
+ expect(screen.getByTestId('chat-card-two-column-layout-grid').className).toContain(
59
+ `@[${TWO_COLUMN_MIN_WIDTH}px]/chat-card-two-column-layout:grid-cols-[336px_minmax(0,1fr)]`,
60
+ );
61
+ });
62
+
63
+ test('panes render semantic elements and merge className', () => {
64
+ render(
65
+ <ChatCardTwoColumnLayout>
66
+ <ChatCardTwoColumnLayoutAside className="p-[4px]">list</ChatCardTwoColumnLayoutAside>
67
+ <ChatCardTwoColumnLayoutMain>chart</ChatCardTwoColumnLayoutMain>
68
+ </ChatCardTwoColumnLayout>,
69
+ );
70
+
71
+ const aside = screen.getByTestId('chat-card-two-column-layout-aside');
72
+
73
+ expect(aside.tagName).toBe('ASIDE');
74
+ expect(aside.className).toContain('p-[4px]');
75
+ expect(screen.getByTestId('chat-card-two-column-layout-main').tagName).toBe('MAIN');
76
+ });
77
+
78
+ test('asChild renders the consumer element', () => {
79
+ render(
80
+ <ChatCardTwoColumnLayout asChild>
81
+ <section>
82
+ <ChatCardTwoColumnLayoutAside asChild>
83
+ <nav>list</nav>
84
+ </ChatCardTwoColumnLayoutAside>
85
+ <ChatCardTwoColumnLayoutMain>chart</ChatCardTwoColumnLayoutMain>
86
+ </section>
87
+ </ChatCardTwoColumnLayout>,
88
+ );
89
+
90
+ expect(screen.getByTestId('chat-card-two-column-layout-aside').tagName).toBe('NAV');
91
+ });
92
+
93
+ test.each([
94
+ [
95
+ 'ChatCardTwoColumnLayoutAside',
96
+ <ChatCardTwoColumnLayoutAside key="a">x</ChatCardTwoColumnLayoutAside>,
97
+ ],
98
+ [
99
+ 'ChatCardTwoColumnLayoutMain',
100
+ <ChatCardTwoColumnLayoutMain key="m">x</ChatCardTwoColumnLayoutMain>,
101
+ ],
102
+ ])('%s throws outside the layout', (part, element) => {
103
+ vi.spyOn(console, 'error').mockImplementation(() => {});
104
+
105
+ expect(() => render(element)).toThrow(
106
+ `[web-chat-ui] "${part}" must be used within a ChatCardTwoColumnLayout`,
107
+ );
108
+ });
109
+ });
@@ -0,0 +1,97 @@
1
+ {
2
+ "$schema": "../../../../int-eslint-config/schemas/component.schema.json",
3
+ "component": "chat-card-two-column-layout",
4
+ "purpose": "Responsive two-pane body for a chat card: Aside (a fixed 336px column) beside Main (flexible), stacked as Aside over Main when the layout is narrower than 744px. Parts: ChatCardTwoColumnLayout, ChatCardTwoColumnLayoutAside, ChatCardTwoColumnLayoutMain, plus chatCardTwoColumnLayoutCardVariants for the wrapping ChatCard.",
5
+ "useWhen": [
6
+ "A chat card shaped like \"a list or a summary + a canvas\", e.g. rows of figures beside a chart",
7
+ "Two panes that should sit side by side when the card is wide and stack when it is narrow, with nothing floating over Main",
8
+ "Main holds content that needs a fixed height, such as a map or a chart"
9
+ ],
10
+ "avoidWhen": [
11
+ "A selected item needs its own pane, or a pane must float over Main or cover it — use web-chat-ui/chat-card-three-column-layout instead",
12
+ "The card has a single content area — put the content in web-chat-ui/ChatCardContent directly",
13
+ "Page-level layout outside a chat card — the widths and the card recipe are tuned for a card in a chat message"
14
+ ],
15
+ "uxPrinciples": [
16
+ "The card is sized by the chat window, not the viewport, so the panes switch on the layout's own width",
17
+ "Main must stay wide enough to be useful beside the Aside column; below that, stack rather than squeeze"
18
+ ],
19
+ "accessibility": {
20
+ "required": [
21
+ "Aside renders an <aside> and Main a <main>; a chat page usually already has a <main>, so use asChild to render a <section> or <div> for Main when that would create a second main landmark",
22
+ "Give a scrolling Aside an accessible name (aria-label) when its content scrolls independently"
23
+ ],
24
+ "keyboard": [
25
+ "No keyboard handling of its own; DOM and tab order is always Aside, then Main, in both the stacked and the side-by-side arrangement"
26
+ ],
27
+ "aria": [
28
+ "Sets no ARIA attributes; landmarks come from the <aside> and <main> elements (or the asChild element)"
29
+ ],
30
+ "focus": ["The layout and its panes are not focusable; focus is per interactive child"]
31
+ },
32
+ "behaviour": {
33
+ "states": ["stacked (layout narrower than 744px)", "side by side (layout 744px or wider)"],
34
+ "rules": [
35
+ "The switch is a CSS container query on the layout's own width, not a viewport breakpoint; there is no JS measuring, so it also renders correctly on the server",
36
+ "Narrower than 744px: one column, Aside in the first row at its content height and Main in the second row taking the rest of the height",
37
+ "From 744px: Aside is a 336px column at full height with overflow hidden, and Main takes the remaining width",
38
+ "The root is the query container and renders the grid inside itself, because an element cannot query its own width; className goes on the root",
39
+ "The layout sets no height: give the root one in className (e.g. h-[480px]) when Main needs it; without it a map or chart in Main has no height",
40
+ "A long Aside list in the column makes the card taller unless its content has h-full and its own scroll (e.g. ui/scroll-area)",
41
+ "Main is position: relative, so consumers can anchor their own overlays to it",
42
+ "The panes query the layout's named container, so they only switch inside a ChatCardTwoColumnLayout; a two-column layout nested in another container still queries its own root",
43
+ "The exported pane cva recipes only work inside an element carrying chatCardTwoColumnLayoutVariants(), the named query container; a className on any part is merged over its recipe and wins",
44
+ "Aside and Main throw \"[web-chat-ui] … must be used within a ChatCardTwoColumnLayout\" when rendered outside the root",
45
+ "asChild on the root and on each pane renders the consumer's element instead of div / aside / main"
46
+ ]
47
+ },
48
+ "composition": {
49
+ "allowedParents": ["web-chat-ui/ChatCardContent"],
50
+ "allowedChildren": [
51
+ "web-chat-ui/ChatCardTwoColumnLayoutAside",
52
+ "web-chat-ui/ChatCardTwoColumnLayoutMain",
53
+ "ui/scroll-area",
54
+ "web-map/map-view"
55
+ ],
56
+ "avoidCombinations": [
57
+ "Wrapping Aside or Main in another element — they must be direct children of the root to sit in the grid; use asChild for a different element instead",
58
+ "The wrapping web-chat-ui/chat-card without chatCardTwoColumnLayoutCardVariants() — a grid of 1fr tracks has no intrinsic width, so the card shrinks to nothing inside a message",
59
+ "web-chat-ui/chat-card-container on its default fixed variant — it caps the card at the reading column, so the layout never reaches two columns; use variant=\"full\""
60
+ ],
61
+ "contexts": ["chat card body", "chat thread"]
62
+ },
63
+ "content": {
64
+ "labelRules": [],
65
+ "helperTextRules": [],
66
+ "errorRules": []
67
+ },
68
+ "aiDecisionRules": [
69
+ {
70
+ "condition": "Building a card with a list or summary beside a chart or map",
71
+ "decision": "Render web-chat-ui/chat-card-container variant=\"full\" > web-chat-ui/chat-card with className={chatCardTwoColumnLayoutCardVariants()} > ChatCardBody > ChatCardContent > ChatCardTwoColumnLayout with Aside and Main",
72
+ "reason": "Without the card recipe the card collapses to zero width, and without variant=\"full\" it never gets wide enough for two columns"
73
+ },
74
+ {
75
+ "condition": "The card is always stacked although the window is wide",
76
+ "decision": "Check that the ChatCard has chatCardTwoColumnLayoutCardVariants() and that its web-chat-ui/chat-card-container uses variant=\"full\"",
77
+ "reason": "The layout switches on its own width, so it stays stacked whenever the card is not given the width"
78
+ },
79
+ {
80
+ "condition": "Main contains a map or a chart",
81
+ "decision": "Set a height on the root with className (e.g. h-[480px])",
82
+ "reason": "The layout sets no height, so the chart or map in Main renders blank"
83
+ },
84
+ {
85
+ "condition": "The Aside content is longer than the card height",
86
+ "decision": "Give the Aside content h-full and its own scroll, e.g. ui/scroll-area with className h-full",
87
+ "reason": "Otherwise the long list grows the card instead of scrolling inside the column"
88
+ }
89
+ ],
90
+ "relatedComponents": [
91
+ "web-chat-ui/chat-card-three-column-layout",
92
+ "web-chat-ui/chat-card",
93
+ "web-chat-ui/chat-card-container",
94
+ "ui/scroll-area",
95
+ "web-map/map-view"
96
+ ]
97
+ }
@@ -0,0 +1,21 @@
1
+ /*
2
+ * The recipes in `chat-card-two-column-layout.variants.ts` write these out as literal
3
+ * `336px` / `744px`, because Tailwind cannot read a constant, so change both together.
4
+ * Nothing reads them at runtime: the switch is a CSS container query. They are here so the
5
+ * threshold is derived in one place, not guessed.
6
+ */
7
+
8
+ /** Aside's fixed column width once the layout is wide enough for two columns. */
9
+ export const ASIDE_WIDTH = 336;
10
+
11
+ /**
12
+ * Narrowest Main may get beside the Aside column. The same 400px as the three-column
13
+ * layout: below it a map or a chart shows too little to be worth sitting beside anything.
14
+ */
15
+ export const MIN_MAIN_WIDTH = 400;
16
+
17
+ /** Must equal the `gap-[8px]` on the grid, or the threshold is off by that much. */
18
+ export const GAP = 8;
19
+
20
+ /** From this layout width, Aside and Main sit side by side; below it they stack. */
21
+ export const TWO_COLUMN_MIN_WIDTH = ASIDE_WIDTH + GAP + MIN_MAIN_WIDTH;