@gravity-ui/aikit 0.0.1

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 (334) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -0
  3. package/dist/.storybook/theme.d.ts +6 -0
  4. package/dist/.storybook/theme.js +28 -0
  5. package/dist/package.json +111 -0
  6. package/dist/src/components/atoms/ActionButton/ActionButton.d.ts +47 -0
  7. package/dist/src/components/atoms/ActionButton/ActionButton.js +34 -0
  8. package/dist/src/components/atoms/ActionButton/__stories__/ActionButton.stories.d.ts +8 -0
  9. package/dist/src/components/atoms/ActionButton/__stories__/ActionButton.stories.js +48 -0
  10. package/dist/src/components/atoms/ActionButton/index.d.ts +2 -0
  11. package/dist/src/components/atoms/ActionButton/index.js +1 -0
  12. package/dist/src/components/atoms/Alert/__stories__/Alert.stories.d.ts +9 -0
  13. package/dist/src/components/atoms/Alert/__stories__/Alert.stories.js +56 -0
  14. package/dist/src/components/atoms/Alert/index.d.ts +13 -0
  15. package/dist/src/components/atoms/Alert/index.js +25 -0
  16. package/dist/src/components/atoms/ChatDate/ChatDate.d.ts +19 -0
  17. package/dist/src/components/atoms/ChatDate/ChatDate.js +24 -0
  18. package/dist/src/components/atoms/ChatDate/__stories__/ChatDate.stories.d.ts +16 -0
  19. package/dist/src/components/atoms/ChatDate/__stories__/ChatDate.stories.js +83 -0
  20. package/dist/src/components/atoms/ChatDate/i18n/en.json +8 -0
  21. package/dist/src/components/atoms/ChatDate/i18n/index.d.ts +13 -0
  22. package/dist/src/components/atoms/ChatDate/i18n/index.js +5 -0
  23. package/dist/src/components/atoms/ChatDate/i18n/ru.json +10 -0
  24. package/dist/src/components/atoms/ChatDate/index.d.ts +1 -0
  25. package/dist/src/components/atoms/ChatDate/index.js +1 -0
  26. package/dist/src/components/atoms/ContextIndicator/__stories__/ContextIndicator.stories.d.ts +17 -0
  27. package/dist/src/components/atoms/ContextIndicator/__stories__/ContextIndicator.stories.js +72 -0
  28. package/dist/src/components/atoms/ContextIndicator/index.d.ts +19 -0
  29. package/dist/src/components/atoms/ContextIndicator/index.js +16 -0
  30. package/dist/src/components/atoms/ContextIndicator/utils.d.ts +1 -0
  31. package/dist/src/components/atoms/ContextIndicator/utils.js +9 -0
  32. package/dist/src/components/atoms/ContextItem/__stories__/ContextItem.stories.d.ts +6 -0
  33. package/dist/src/components/atoms/ContextItem/__stories__/ContextItem.stories.js +32 -0
  34. package/dist/src/components/atoms/ContextItem/index.d.ts +9 -0
  35. package/dist/src/components/atoms/ContextItem/index.js +8 -0
  36. package/dist/src/components/atoms/DiffStat/__stories__/DiffStat.stories.d.ts +7 -0
  37. package/dist/src/components/atoms/DiffStat/__stories__/DiffStat.stories.js +45 -0
  38. package/dist/src/components/atoms/DiffStat/index.d.ts +8 -0
  39. package/dist/src/components/atoms/DiffStat/index.js +8 -0
  40. package/dist/src/components/atoms/Disclaimer/Disclaimer.d.ts +19 -0
  41. package/dist/src/components/atoms/Disclaimer/Disclaimer.js +15 -0
  42. package/dist/src/components/atoms/Disclaimer/__stories__/Disclaimer.stories.d.ts +8 -0
  43. package/dist/src/components/atoms/Disclaimer/__stories__/Disclaimer.stories.js +32 -0
  44. package/dist/src/components/atoms/Disclaimer/index.d.ts +1 -0
  45. package/dist/src/components/atoms/Disclaimer/index.js +1 -0
  46. package/dist/src/components/atoms/InlineCitation/index.d.ts +1 -0
  47. package/dist/src/components/atoms/InlineCitation/index.js +1 -0
  48. package/dist/src/components/atoms/Loader/Loader.d.ts +9 -0
  49. package/dist/src/components/atoms/Loader/Loader.js +11 -0
  50. package/dist/src/components/atoms/Loader/__stories__/Loader.stories.d.ts +8 -0
  51. package/dist/src/components/atoms/Loader/__stories__/Loader.stories.js +47 -0
  52. package/dist/src/components/atoms/Loader/index.d.ts +1 -0
  53. package/dist/src/components/atoms/Loader/index.js +1 -0
  54. package/dist/src/components/atoms/MarkdownRenderer/MarkdownRenderer.d.ts +10 -0
  55. package/dist/src/components/atoms/MarkdownRenderer/MarkdownRenderer.js +24 -0
  56. package/dist/src/components/atoms/MarkdownRenderer/__stories__/MarkdownRenderer.stories.d.ts +6 -0
  57. package/dist/src/components/atoms/MarkdownRenderer/__stories__/MarkdownRenderer.stories.js +49 -0
  58. package/dist/src/components/atoms/MarkdownRenderer/index.d.ts +1 -0
  59. package/dist/src/components/atoms/MarkdownRenderer/index.js +1 -0
  60. package/dist/src/components/atoms/MessageBalloon/__stories__/MessageBalloon.stories.d.ts +6 -0
  61. package/dist/src/components/atoms/MessageBalloon/__stories__/MessageBalloon.stories.js +32 -0
  62. package/dist/src/components/atoms/MessageBalloon/index.d.ts +7 -0
  63. package/dist/src/components/atoms/MessageBalloon/index.js +8 -0
  64. package/dist/src/components/atoms/Shimmer/__stories__/Shimmer.stories.d.ts +5 -0
  65. package/dist/src/components/atoms/Shimmer/__stories__/Shimmer.stories.js +28 -0
  66. package/dist/src/components/atoms/Shimmer/index.d.ts +6 -0
  67. package/dist/src/components/atoms/Shimmer/index.js +8 -0
  68. package/dist/src/components/atoms/SubmitButton/SubmitButton.d.ts +37 -0
  69. package/dist/src/components/atoms/SubmitButton/SubmitButton.js +33 -0
  70. package/dist/src/components/atoms/SubmitButton/__stories__/SubmitButton.stories.d.ts +12 -0
  71. package/dist/src/components/atoms/SubmitButton/__stories__/SubmitButton.stories.js +95 -0
  72. package/dist/src/components/atoms/SubmitButton/i18n/en.json +3 -0
  73. package/dist/src/components/atoms/SubmitButton/i18n/index.d.ts +13 -0
  74. package/dist/src/components/atoms/SubmitButton/i18n/index.js +5 -0
  75. package/dist/src/components/atoms/SubmitButton/i18n/ru.json +3 -0
  76. package/dist/src/components/atoms/SubmitButton/index.d.ts +1 -0
  77. package/dist/src/components/atoms/SubmitButton/index.js +1 -0
  78. package/dist/src/components/atoms/ToolIndicator/__stories__/ToolIndicator.stories.d.ts +9 -0
  79. package/dist/src/components/atoms/ToolIndicator/__stories__/ToolIndicator.stories.js +34 -0
  80. package/dist/src/components/atoms/ToolIndicator/index.d.ts +7 -0
  81. package/dist/src/components/atoms/ToolIndicator/index.js +26 -0
  82. package/dist/src/components/atoms/index.d.ts +14 -0
  83. package/dist/src/components/atoms/index.js +15 -0
  84. package/dist/src/components/index.d.ts +5 -0
  85. package/dist/src/components/index.js +6 -0
  86. package/dist/src/components/molecules/BaseMessage/__stories__/BaseMessage.stories.d.ts +8 -0
  87. package/dist/src/components/molecules/BaseMessage/__stories__/BaseMessage.stories.js +66 -0
  88. package/dist/src/components/molecules/BaseMessage/i18n/en.json +8 -0
  89. package/dist/src/components/molecules/BaseMessage/i18n/index.d.ts +13 -0
  90. package/dist/src/components/molecules/BaseMessage/i18n/index.js +5 -0
  91. package/dist/src/components/molecules/BaseMessage/i18n/ru.json +8 -0
  92. package/dist/src/components/molecules/BaseMessage/index.d.ts +11 -0
  93. package/dist/src/components/molecules/BaseMessage/index.js +48 -0
  94. package/dist/src/components/molecules/ButtonGroup/__stories__/ButtonGroup.stories.d.ts +6 -0
  95. package/dist/src/components/molecules/ButtonGroup/__stories__/ButtonGroup.stories.js +44 -0
  96. package/dist/src/components/molecules/ButtonGroup/index.d.ts +8 -0
  97. package/dist/src/components/molecules/ButtonGroup/index.js +8 -0
  98. package/dist/src/components/molecules/InputContext/index.d.ts +1 -0
  99. package/dist/src/components/molecules/InputContext/index.js +1 -0
  100. package/dist/src/components/molecules/PromptInputBody/PromptInputBody.d.ts +39 -0
  101. package/dist/src/components/molecules/PromptInputBody/PromptInputBody.js +26 -0
  102. package/dist/src/components/molecules/PromptInputBody/__stories__/PromptInputBody.stories.d.ts +11 -0
  103. package/dist/src/components/molecules/PromptInputBody/__stories__/PromptInputBody.stories.js +62 -0
  104. package/dist/src/components/molecules/PromptInputBody/index.d.ts +1 -0
  105. package/dist/src/components/molecules/PromptInputBody/index.js +1 -0
  106. package/dist/src/components/molecules/PromptInputFooter/PromptInputFooter.d.ts +39 -0
  107. package/dist/src/components/molecules/PromptInputFooter/PromptInputFooter.js +26 -0
  108. package/dist/src/components/molecules/PromptInputFooter/__stories__/PromptInputFooter.stories.d.ts +11 -0
  109. package/dist/src/components/molecules/PromptInputFooter/__stories__/PromptInputFooter.stories.js +96 -0
  110. package/dist/src/components/molecules/PromptInputFooter/i18n/en.json +5 -0
  111. package/dist/src/components/molecules/PromptInputFooter/i18n/index.d.ts +13 -0
  112. package/dist/src/components/molecules/PromptInputFooter/i18n/index.js +5 -0
  113. package/dist/src/components/molecules/PromptInputFooter/i18n/ru.json +5 -0
  114. package/dist/src/components/molecules/PromptInputFooter/index.d.ts +1 -0
  115. package/dist/src/components/molecules/PromptInputFooter/index.js +1 -0
  116. package/dist/src/components/molecules/PromptInputHeader/PromptInputHeader.d.ts +39 -0
  117. package/dist/src/components/molecules/PromptInputHeader/PromptInputHeader.js +28 -0
  118. package/dist/src/components/molecules/PromptInputHeader/__stories__/PromptInputHeader.stories.d.ts +13 -0
  119. package/dist/src/components/molecules/PromptInputHeader/__stories__/PromptInputHeader.stories.js +103 -0
  120. package/dist/src/components/molecules/PromptInputHeader/index.d.ts +1 -0
  121. package/dist/src/components/molecules/PromptInputHeader/index.js +1 -0
  122. package/dist/src/components/molecules/PromptInputPanel/PromptInputPanel.d.ts +20 -0
  123. package/dist/src/components/molecules/PromptInputPanel/PromptInputPanel.js +14 -0
  124. package/dist/src/components/molecules/PromptInputPanel/__stories__/PromptInputPanel.stories.d.ts +8 -0
  125. package/dist/src/components/molecules/PromptInputPanel/__stories__/PromptInputPanel.stories.js +38 -0
  126. package/dist/src/components/molecules/PromptInputPanel/index.d.ts +2 -0
  127. package/dist/src/components/molecules/PromptInputPanel/index.js +1 -0
  128. package/dist/src/components/molecules/Suggestions/Suggestions.d.ts +37 -0
  129. package/dist/src/components/molecules/Suggestions/Suggestions.js +27 -0
  130. package/dist/src/components/molecules/Suggestions/__stories__/Suggestions.stories.d.ts +19 -0
  131. package/dist/src/components/molecules/Suggestions/__stories__/Suggestions.stories.js +143 -0
  132. package/dist/src/components/molecules/Suggestions/index.d.ts +1 -0
  133. package/dist/src/components/molecules/Suggestions/index.js +1 -0
  134. package/dist/src/components/molecules/Tabs/Tabs.d.ts +15 -0
  135. package/dist/src/components/molecules/Tabs/Tabs.js +24 -0
  136. package/dist/src/components/molecules/Tabs/__stories__/Tabs.stories.d.ts +9 -0
  137. package/dist/src/components/molecules/Tabs/__stories__/Tabs.stories.js +103 -0
  138. package/dist/src/components/molecules/Tabs/i18n/en.json +3 -0
  139. package/dist/src/components/molecules/Tabs/i18n/index.d.ts +13 -0
  140. package/dist/src/components/molecules/Tabs/i18n/index.js +5 -0
  141. package/dist/src/components/molecules/Tabs/i18n/ru.json +3 -0
  142. package/dist/src/components/molecules/Tabs/index.d.ts +1 -0
  143. package/dist/src/components/molecules/Tabs/index.js +1 -0
  144. package/dist/src/components/molecules/ToolFooter/__stories__/ToolFooter.stories.d.ts +7 -0
  145. package/dist/src/components/molecules/ToolFooter/__stories__/ToolFooter.stories.js +58 -0
  146. package/dist/src/components/molecules/ToolFooter/index.d.ts +3 -0
  147. package/dist/src/components/molecules/ToolFooter/index.js +10 -0
  148. package/dist/src/components/molecules/ToolHeader/__stories__/ToolHeader.stories.d.ts +7 -0
  149. package/dist/src/components/molecules/ToolHeader/__stories__/ToolHeader.stories.js +55 -0
  150. package/dist/src/components/molecules/ToolHeader/index.d.ts +3 -0
  151. package/dist/src/components/molecules/ToolHeader/index.js +19 -0
  152. package/dist/src/components/molecules/index.d.ts +11 -0
  153. package/dist/src/components/molecules/index.js +12 -0
  154. package/dist/src/components/organisms/AssistantMessage/AssistantMessage.d.ts +14 -0
  155. package/dist/src/components/organisms/AssistantMessage/AssistantMessage.js +31 -0
  156. package/dist/src/components/organisms/AssistantMessage/__stories__/AssistantMessage.stories.d.ts +13 -0
  157. package/dist/src/components/organisms/AssistantMessage/__stories__/AssistantMessage.stories.js +151 -0
  158. package/dist/src/components/organisms/AssistantMessage/defaultMessageTypeRegistry.d.ts +3 -0
  159. package/dist/src/components/organisms/AssistantMessage/defaultMessageTypeRegistry.js +18 -0
  160. package/dist/src/components/organisms/AssistantMessage/index.d.ts +1 -0
  161. package/dist/src/components/organisms/AssistantMessage/index.js +1 -0
  162. package/dist/src/components/organisms/Header/Header.d.ts +9 -0
  163. package/dist/src/components/organisms/Header/Header.js +65 -0
  164. package/dist/src/components/organisms/Header/__stories__/Header.stories.d.ts +13 -0
  165. package/dist/src/components/organisms/Header/__stories__/Header.stories.js +130 -0
  166. package/dist/src/components/organisms/Header/i18n/en.json +7 -0
  167. package/dist/src/components/organisms/Header/i18n/index.d.ts +13 -0
  168. package/dist/src/components/organisms/Header/i18n/index.js +5 -0
  169. package/dist/src/components/organisms/Header/i18n/ru.json +7 -0
  170. package/dist/src/components/organisms/Header/index.d.ts +4 -0
  171. package/dist/src/components/organisms/Header/index.js +6 -0
  172. package/dist/src/components/organisms/Header/types.d.ts +23 -0
  173. package/dist/src/components/organisms/Header/types.js +7 -0
  174. package/dist/src/components/organisms/Header/useHeader.d.ts +21 -0
  175. package/dist/src/components/organisms/Header/useHeader.js +71 -0
  176. package/dist/src/components/organisms/MessageList/ErrorAlert.d.ts +6 -0
  177. package/dist/src/components/organisms/MessageList/ErrorAlert.js +15 -0
  178. package/dist/src/components/organisms/MessageList/MessageList.d.ts +20 -0
  179. package/dist/src/components/organisms/MessageList/MessageList.js +21 -0
  180. package/dist/src/components/organisms/MessageList/__stories__/MessageList.stories.d.ts +22 -0
  181. package/dist/src/components/organisms/MessageList/__stories__/MessageList.stories.js +168 -0
  182. package/dist/src/components/organisms/MessageList/i18n/en.json +4 -0
  183. package/dist/src/components/organisms/MessageList/i18n/index.d.ts +13 -0
  184. package/dist/src/components/organisms/MessageList/i18n/index.js +5 -0
  185. package/dist/src/components/organisms/MessageList/i18n/ru.json +4 -0
  186. package/dist/src/components/organisms/MessageList/index.d.ts +1 -0
  187. package/dist/src/components/organisms/MessageList/index.js +1 -0
  188. package/dist/src/components/organisms/PromptInput/PromptInput.d.ts +44 -0
  189. package/dist/src/components/organisms/PromptInput/PromptInput.js +38 -0
  190. package/dist/src/components/organisms/PromptInput/PromptInputFull.d.ts +26 -0
  191. package/dist/src/components/organisms/PromptInput/PromptInputFull.js +25 -0
  192. package/dist/src/components/organisms/PromptInput/PromptInputSimple.d.ts +24 -0
  193. package/dist/src/components/organisms/PromptInput/PromptInputSimple.js +21 -0
  194. package/dist/src/components/organisms/PromptInput/PromptInputWithPanels.d.ts +24 -0
  195. package/dist/src/components/organisms/PromptInput/PromptInputWithPanels.js +19 -0
  196. package/dist/src/components/organisms/PromptInput/PromptInputWithSuggestions.d.ts +22 -0
  197. package/dist/src/components/organisms/PromptInput/PromptInputWithSuggestions.js +16 -0
  198. package/dist/src/components/organisms/PromptInput/__stories__/PromptInput.stories.d.ts +18 -0
  199. package/dist/src/components/organisms/PromptInput/__stories__/PromptInput.stories.js +278 -0
  200. package/dist/src/components/organisms/PromptInput/index.d.ts +8 -0
  201. package/dist/src/components/organisms/PromptInput/index.js +7 -0
  202. package/dist/src/components/organisms/PromptInput/types.d.ts +72 -0
  203. package/dist/src/components/organisms/PromptInput/types.js +1 -0
  204. package/dist/src/components/organisms/PromptInput/useDelayedUnmount.d.ts +8 -0
  205. package/dist/src/components/organisms/PromptInput/useDelayedUnmount.js +26 -0
  206. package/dist/src/components/organisms/PromptInput/usePromptInput.d.ts +52 -0
  207. package/dist/src/components/organisms/PromptInput/usePromptInput.js +102 -0
  208. package/dist/src/components/organisms/ThinkingMessage/__stories__/ThinkingMessage.stories.d.ts +12 -0
  209. package/dist/src/components/organisms/ThinkingMessage/__stories__/ThinkingMessage.stories.js +107 -0
  210. package/dist/src/components/organisms/ThinkingMessage/i18n/en.json +4 -0
  211. package/dist/src/components/organisms/ThinkingMessage/i18n/index.d.ts +13 -0
  212. package/dist/src/components/organisms/ThinkingMessage/i18n/index.js +5 -0
  213. package/dist/src/components/organisms/ThinkingMessage/i18n/ru.json +4 -0
  214. package/dist/src/components/organisms/ThinkingMessage/index.d.ts +24 -0
  215. package/dist/src/components/organisms/ThinkingMessage/index.js +34 -0
  216. package/dist/src/components/organisms/ThinkingMessage/useThinkingMessage.d.ts +18 -0
  217. package/dist/src/components/organisms/ThinkingMessage/useThinkingMessage.js +23 -0
  218. package/dist/src/components/organisms/ToolMessage/__stories__/ToolMessage.stories.d.ts +11 -0
  219. package/dist/src/components/organisms/ToolMessage/__stories__/ToolMessage.stories.js +70 -0
  220. package/dist/src/components/organisms/ToolMessage/i18n/en.json +9 -0
  221. package/dist/src/components/organisms/ToolMessage/i18n/index.d.ts +13 -0
  222. package/dist/src/components/organisms/ToolMessage/i18n/index.js +5 -0
  223. package/dist/src/components/organisms/ToolMessage/i18n/ru.json +9 -0
  224. package/dist/src/components/organisms/ToolMessage/index.d.ts +3 -0
  225. package/dist/src/components/organisms/ToolMessage/index.js +12 -0
  226. package/dist/src/components/organisms/UserMessage/__stories__/UserMessage.stories.d.ts +7 -0
  227. package/dist/src/components/organisms/UserMessage/__stories__/UserMessage.stories.js +70 -0
  228. package/dist/src/components/organisms/UserMessage/index.d.ts +13 -0
  229. package/dist/src/components/organisms/UserMessage/index.js +12 -0
  230. package/dist/src/components/organisms/index.d.ts +7 -0
  231. package/dist/src/components/organisms/index.js +8 -0
  232. package/dist/src/components/pages/ChatContainer/ChatContainer.d.ts +10 -0
  233. package/dist/src/components/pages/ChatContainer/ChatContainer.js +110 -0
  234. package/dist/src/components/pages/ChatContainer/__stories__/ChatContainer.stories.d.ts +53 -0
  235. package/dist/src/components/pages/ChatContainer/__stories__/ChatContainer.stories.js +707 -0
  236. package/dist/src/components/pages/ChatContainer/i18n/en.json +10 -0
  237. package/dist/src/components/pages/ChatContainer/i18n/index.d.ts +13 -0
  238. package/dist/src/components/pages/ChatContainer/i18n/index.js +5 -0
  239. package/dist/src/components/pages/ChatContainer/i18n/ru.json +10 -0
  240. package/dist/src/components/pages/ChatContainer/index.d.ts +2 -0
  241. package/dist/src/components/pages/ChatContainer/index.js +1 -0
  242. package/dist/src/components/pages/ChatContainer/types.d.ts +143 -0
  243. package/dist/src/components/pages/ChatContainer/types.js +1 -0
  244. package/dist/src/components/pages/ChatContainer/useChatContainer.d.ts +20 -0
  245. package/dist/src/components/pages/ChatContainer/useChatContainer.js +77 -0
  246. package/dist/src/components/pages/index.d.ts +1 -0
  247. package/dist/src/components/pages/index.js +2 -0
  248. package/dist/src/components/templates/ChatContent/ChatContent.d.ts +29 -0
  249. package/dist/src/components/templates/ChatContent/ChatContent.js +19 -0
  250. package/dist/src/components/templates/ChatContent/__stories__/ChatContent.stories.d.ts +14 -0
  251. package/dist/src/components/templates/ChatContent/__stories__/ChatContent.stories.js +315 -0
  252. package/dist/src/components/templates/ChatContent/index.d.ts +1 -0
  253. package/dist/src/components/templates/ChatContent/index.js +1 -0
  254. package/dist/src/components/templates/EmptyContainer/EmptyContainer.d.ts +57 -0
  255. package/dist/src/components/templates/EmptyContainer/EmptyContainer.js +26 -0
  256. package/dist/src/components/templates/EmptyContainer/__stories__/EmptyContainer.stories.d.ts +20 -0
  257. package/dist/src/components/templates/EmptyContainer/__stories__/EmptyContainer.stories.js +250 -0
  258. package/dist/src/components/templates/EmptyContainer/i18n/en.json +3 -0
  259. package/dist/src/components/templates/EmptyContainer/i18n/index.d.ts +13 -0
  260. package/dist/src/components/templates/EmptyContainer/i18n/index.js +5 -0
  261. package/dist/src/components/templates/EmptyContainer/i18n/ru.json +3 -0
  262. package/dist/src/components/templates/EmptyContainer/index.d.ts +1 -0
  263. package/dist/src/components/templates/EmptyContainer/index.js +1 -0
  264. package/dist/src/components/templates/History/ChatItem.d.ts +17 -0
  265. package/dist/src/components/templates/History/ChatItem.js +18 -0
  266. package/dist/src/components/templates/History/DateHeaderItem.d.ts +12 -0
  267. package/dist/src/components/templates/History/DateHeaderItem.js +12 -0
  268. package/dist/src/components/templates/History/History.d.ts +46 -0
  269. package/dist/src/components/templates/History/History.js +16 -0
  270. package/dist/src/components/templates/History/HistoryList.d.ts +43 -0
  271. package/dist/src/components/templates/History/HistoryList.js +87 -0
  272. package/dist/src/components/templates/History/__stories__/History.stories.d.ts +17 -0
  273. package/dist/src/components/templates/History/__stories__/History.stories.js +281 -0
  274. package/dist/src/components/templates/History/i18n/en.json +7 -0
  275. package/dist/src/components/templates/History/i18n/index.d.ts +13 -0
  276. package/dist/src/components/templates/History/i18n/index.js +5 -0
  277. package/dist/src/components/templates/History/i18n/ru.json +7 -0
  278. package/dist/src/components/templates/History/index.d.ts +8 -0
  279. package/dist/src/components/templates/History/index.js +4 -0
  280. package/dist/src/components/templates/index.d.ts +3 -0
  281. package/dist/src/components/templates/index.js +4 -0
  282. package/dist/src/constants/index.d.ts +1 -0
  283. package/dist/src/constants/index.js +1 -0
  284. package/dist/src/demo/ContentWrapper/ContentWrapper.d.ts +7 -0
  285. package/dist/src/demo/ContentWrapper/ContentWrapper.js +7 -0
  286. package/dist/src/demo/ContentWrapper/index.d.ts +1 -0
  287. package/dist/src/demo/ContentWrapper/index.js +1 -0
  288. package/dist/src/demo/DocsDecorator/DocsDecorator.d.ts +6 -0
  289. package/dist/src/demo/DocsDecorator/DocsDecorator.js +12 -0
  290. package/dist/src/demo/DocsDecorator/ThemeContext.d.ts +2 -0
  291. package/dist/src/demo/DocsDecorator/ThemeContext.js +2 -0
  292. package/dist/src/demo/Showcase/Showcase.d.ts +9 -0
  293. package/dist/src/demo/Showcase/Showcase.js +7 -0
  294. package/dist/src/demo/Showcase/index.d.ts +1 -0
  295. package/dist/src/demo/Showcase/index.js +1 -0
  296. package/dist/src/demo/ShowcaseItem/ShowcaseItem.d.ts +7 -0
  297. package/dist/src/demo/ShowcaseItem/ShowcaseItem.js +7 -0
  298. package/dist/src/demo/ShowcaseItem/index.d.ts +1 -0
  299. package/dist/src/demo/ShowcaseItem/index.js +1 -0
  300. package/dist/src/demo/SwapArea/SwapArea.d.ts +2 -0
  301. package/dist/src/demo/SwapArea/SwapArea.js +7 -0
  302. package/dist/src/demo/SwapArea/index.d.ts +1 -0
  303. package/dist/src/demo/SwapArea/index.js +1 -0
  304. package/dist/src/hooks/index.d.ts +2 -0
  305. package/dist/src/hooks/index.js +2 -0
  306. package/dist/src/hooks/useDateFormatter/index.d.ts +34 -0
  307. package/dist/src/hooks/useDateFormatter/index.js +101 -0
  308. package/dist/src/hooks/useToolMessage.d.ts +11 -0
  309. package/dist/src/hooks/useToolMessage.js +96 -0
  310. package/dist/src/index.d.ts +11 -0
  311. package/dist/src/index.js +19 -0
  312. package/dist/src/types/chat.d.ts +17 -0
  313. package/dist/src/types/chat.js +1 -0
  314. package/dist/src/types/common.d.ts +7 -0
  315. package/dist/src/types/common.js +1 -0
  316. package/dist/src/types/index.d.ts +4 -0
  317. package/dist/src/types/index.js +4 -0
  318. package/dist/src/types/messages.d.ts +62 -0
  319. package/dist/src/types/messages.js +1 -0
  320. package/dist/src/types/tool.d.ts +34 -0
  321. package/dist/src/types/tool.js +1 -0
  322. package/dist/src/utils/chatUtils.d.ts +23 -0
  323. package/dist/src/utils/chatUtils.js +43 -0
  324. package/dist/src/utils/cn.d.ts +11 -0
  325. package/dist/src/utils/cn.js +12 -0
  326. package/dist/src/utils/index.d.ts +4 -0
  327. package/dist/src/utils/index.js +5 -0
  328. package/dist/src/utils/messageTypeRegistry.d.ts +13 -0
  329. package/dist/src/utils/messageTypeRegistry.js +16 -0
  330. package/dist/src/utils/messageUtils.d.ts +4 -0
  331. package/dist/src/utils/messageUtils.js +25 -0
  332. package/dist/src/utils/validation.d.ts +16 -0
  333. package/dist/src/utils/validation.js +24 -0
  334. package/package.json +111 -0
@@ -0,0 +1,707 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /* eslint-disable no-console */
3
+ import { useState } from 'react';
4
+ import { Sparkles } from '@gravity-ui/icons';
5
+ import { Icon } from '@gravity-ui/uikit';
6
+ import { ChatContainer } from '..';
7
+ import { ContentWrapper } from '../../../../demo/ContentWrapper';
8
+ import MDXDocs from './Docs.mdx';
9
+ export default {
10
+ title: 'pages/ChatContainer',
11
+ component: ChatContainer,
12
+ parameters: {
13
+ docs: {
14
+ page: MDXDocs,
15
+ },
16
+ },
17
+ };
18
+ const defaultDecorators = [
19
+ (Story) => (_jsx(ContentWrapper, { height: "800px", width: "600px", children: _jsx(Story, {}) })),
20
+ ];
21
+ // Mock data
22
+ const mockSuggestions = [
23
+ {
24
+ id: '1',
25
+ content: 'Explain quantum computing in simple terms',
26
+ label: 'Quantum Computing',
27
+ },
28
+ {
29
+ id: '2',
30
+ content: 'Write a poem about nature',
31
+ label: 'Creative Writing',
32
+ },
33
+ {
34
+ id: '3',
35
+ content: 'Help me debug my JavaScript code',
36
+ label: 'Debug Code',
37
+ },
38
+ {
39
+ id: '4',
40
+ content: 'Summarize recent AI developments',
41
+ label: 'AI News',
42
+ },
43
+ ];
44
+ const mockChats = [
45
+ {
46
+ id: '1',
47
+ name: 'Quantum Computing Discussion',
48
+ createTime: new Date(Date.now() - 1000 * 60 * 60).toISOString(),
49
+ lastMessage: 'Thanks for explaining quantum entanglement!',
50
+ },
51
+ {
52
+ id: '2',
53
+ name: 'Poetry Writing Session',
54
+ createTime: new Date(Date.now() - 1000 * 60 * 60 * 24).toISOString(),
55
+ lastMessage: 'That was a beautiful poem about autumn.',
56
+ },
57
+ {
58
+ id: '3',
59
+ name: 'Code Debugging Help',
60
+ createTime: new Date(Date.now() - 1000 * 60 * 60 * 24 * 2).toISOString(),
61
+ lastMessage: 'The bug was in the async function.',
62
+ },
63
+ {
64
+ id: '4',
65
+ name: 'AI News Summary',
66
+ createTime: new Date(Date.now() - 1000 * 60 * 60 * 24 * 3).toISOString(),
67
+ lastMessage: 'Thanks for the comprehensive summary!',
68
+ },
69
+ ];
70
+ /**
71
+ * Mock messages for different chats
72
+ * Each chat has its own conversation history
73
+ * Keys correspond to chat IDs from mockChats
74
+ */
75
+ const mockChatMessages = {
76
+ '1': [
77
+ {
78
+ id: '1-1',
79
+ role: 'user',
80
+ content: 'What is quantum computing?',
81
+ timestamp: new Date(Date.now() - 1000 * 60 * 60).toISOString(),
82
+ },
83
+ {
84
+ id: '1-2',
85
+ role: 'assistant',
86
+ content: 'Quantum computing is a revolutionary approach to computation that leverages the principles of quantum mechanics. Unlike classical computers that use bits (0 or 1), quantum computers use quantum bits or "qubits" that can exist in multiple states simultaneously through a phenomenon called superposition.\n\nKey concepts include:\n1. **Superposition**: Qubits can be in multiple states at once\n2. **Entanglement**: Qubits can be correlated in ways that classical bits cannot\n3. **Quantum Interference**: Used to amplify correct answers and cancel out wrong ones',
87
+ timestamp: new Date(Date.now() - 1000 * 60 * 59).toISOString(),
88
+ },
89
+ {
90
+ id: '1-3',
91
+ role: 'user',
92
+ content: 'Can you explain quantum entanglement in simple terms?',
93
+ timestamp: new Date(Date.now() - 1000 * 60 * 58).toISOString(),
94
+ },
95
+ {
96
+ id: '1-4',
97
+ role: 'assistant',
98
+ content: 'Quantum entanglement is like having two magic coins that are mysteriously connected. When you flip one coin and it lands on heads, the other coin - no matter how far away - will instantly land on tails (or vice versa).\n\nIn quantum physics terms:\n- Two particles become "entangled" and share a quantum state\n- Measuring one particle instantly affects the other\n- This happens regardless of the distance between them\n- Einstein called it "spooky action at a distance"\n\nThis phenomenon is fundamental to quantum computing and quantum communication technologies.',
99
+ timestamp: new Date(Date.now() - 1000 * 60 * 57).toISOString(),
100
+ },
101
+ ],
102
+ '2': [
103
+ {
104
+ id: '2-1',
105
+ role: 'user',
106
+ content: 'Write a poem about autumn leaves',
107
+ timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24).toISOString(),
108
+ },
109
+ {
110
+ id: '2-2',
111
+ role: 'assistant',
112
+ content: "Golden whispers fall from trees,\nDancing softly on the breeze,\nCrimsons, ambers, russet bright,\nPainting pathways with their light.\n\nNature's canvas, rich and warm,\nBefore the coming winter storm,\nEach leaf a story, each one told,\nOf seasons passing, growing old.",
113
+ timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24 + 60000).toISOString(),
114
+ },
115
+ {
116
+ id: '2-3',
117
+ role: 'user',
118
+ content: 'That was beautiful! Can you write one about winter snow?',
119
+ timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24 + 120000).toISOString(),
120
+ },
121
+ {
122
+ id: '2-4',
123
+ role: 'assistant',
124
+ content: "Snowflakes drift from silent skies,\nBlankets white before our eyes,\nCrystal diamonds, soft and pure,\nWinter's gentle signature.\n\nFrosted windows, frozen streams,\nLandscapes wrapped in silver dreams,\nQuiet peace in cold embrace,\nNature sleeps in gentle grace.",
125
+ timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24 + 180000).toISOString(),
126
+ },
127
+ ],
128
+ '3': [
129
+ {
130
+ id: '3-1',
131
+ role: 'user',
132
+ content: "I have a bug in my async function. It's not waiting for the promise to resolve.",
133
+ timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24 * 2).toISOString(),
134
+ },
135
+ {
136
+ id: '3-2',
137
+ role: 'assistant',
138
+ content: "Let's debug this step by step. The most common issues with async/await are:\n\n1. **Missing await keyword**: Make sure you're using `await` before the promise\n2. **Function not marked as async**: The function must be declared with `async` keyword\n3. **Promise not being returned**: Ensure the function returns a promise\n\nCan you share your code? Here's a common pattern:\n\n```javascript\nasync function fetchData() {\n const result = await fetch('/api/data');\n const data = await result.json();\n return data;\n}\n```",
139
+ timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24 * 2 + 60000).toISOString(),
140
+ },
141
+ {
142
+ id: '3-3',
143
+ role: 'user',
144
+ content: 'Oh! I forgot to mark the parent function as async. That was the issue. Thanks!',
145
+ timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24 * 2 + 120000).toISOString(),
146
+ },
147
+ {
148
+ id: '3-4',
149
+ role: 'assistant',
150
+ content: "Great! That's a very common mistake. Remember: to use `await`, the containing function must be `async`. Also, if you're using `await` in a callback (like in `.map()` or `.forEach()`), make sure to make the callback function async too. Happy coding!",
151
+ timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24 * 2 + 180000).toISOString(),
152
+ },
153
+ ],
154
+ '4': [
155
+ {
156
+ id: '4-1',
157
+ role: 'user',
158
+ content: 'What are the latest developments in AI?',
159
+ timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24 * 3).toISOString(),
160
+ },
161
+ {
162
+ id: '4-2',
163
+ role: 'assistant',
164
+ content: 'Recent AI developments include:\n\n**Large Language Models**\n- More efficient training methods\n- Better reasoning capabilities\n- Multimodal models (text, image, audio)\n\n**Computer Vision**\n- Improved object detection and segmentation\n- Real-time video analysis\n- 3D reconstruction from 2D images\n\n**AI Safety**\n- Constitutional AI and alignment research\n- Better interpretability tools\n- Red-teaming and safety testing\n\n**Edge AI**\n- Running models on mobile devices\n- Reduced latency for real-time applications\n- Privacy-preserving local inference',
165
+ timestamp: new Date(Date.now() - 1000 * 60 * 60 * 24 * 3 + 60000).toISOString(),
166
+ },
167
+ ],
168
+ };
169
+ // Default messages for first chat
170
+ const mockMessages = mockChatMessages['1'];
171
+ /**
172
+ * Create message actions with handlers
173
+ * @param messageId - Message identifier
174
+ * @param role - Message role (user or assistant)
175
+ * @returns Array of message actions
176
+ */
177
+ const createMessageActions = (messageId, role) => {
178
+ const actions = [
179
+ {
180
+ type: 'copy',
181
+ onClick: () => console.log(`Copy message ${messageId}`),
182
+ },
183
+ ];
184
+ if (role === 'user') {
185
+ actions.push({
186
+ type: 'edit',
187
+ onClick: () => console.log(`Edit message ${messageId}`),
188
+ });
189
+ }
190
+ if (role === 'assistant') {
191
+ actions.push({
192
+ type: 'like',
193
+ onClick: () => console.log(`Like message ${messageId}`),
194
+ }, {
195
+ type: 'unlike',
196
+ onClick: () => console.log(`Unlike message ${messageId}`),
197
+ });
198
+ }
199
+ return actions;
200
+ };
201
+ /**
202
+ * Add actions to messages
203
+ * @param messages - Array of messages
204
+ * @returns Array of messages with actions added
205
+ */
206
+ const addActionsToMessages = (messages) => {
207
+ return messages.map((msg) => (Object.assign(Object.assign({}, msg), { actions: createMessageActions(msg.id || 'unknown', msg.role) })));
208
+ };
209
+ /**
210
+ * Playground story for interactive testing
211
+ */
212
+ export const Playground = {
213
+ args: {
214
+ messages: [],
215
+ chats: mockChats,
216
+ showHistory: true,
217
+ showNewChat: true,
218
+ showClose: false,
219
+ welcomeConfig: {
220
+ title: 'Welcome to AI Chat',
221
+ description: 'Start a conversation by typing a message or selecting a suggestion.',
222
+ suggestionTitle: 'Try asking:',
223
+ suggestions: mockSuggestions,
224
+ },
225
+ showActionsOnHover: true,
226
+ },
227
+ render: (args) => {
228
+ const initialChat = mockChats[0];
229
+ const [messages, setMessages] = useState(addActionsToMessages(mockChatMessages[initialChat.id] || []));
230
+ const [status, setStatus] = useState('ready');
231
+ const [activeChat, setActiveChat] = useState(initialChat);
232
+ const handleSendMessage = async (data) => {
233
+ const userMessage = {
234
+ id: Date.now().toString(),
235
+ role: 'user',
236
+ content: data.content,
237
+ timestamp: new Date().toISOString(),
238
+ actions: createMessageActions(Date.now().toString(), 'user'),
239
+ };
240
+ setMessages((prev) => [...prev, userMessage]);
241
+ // Simulate streaming
242
+ setStatus('streaming');
243
+ await new Promise((resolve) => setTimeout(resolve, 500));
244
+ const assistantMessageId = (Date.now() + 1).toString();
245
+ const assistantMessage = {
246
+ id: assistantMessageId,
247
+ role: 'assistant',
248
+ content: `This is a mock response to: "${data.content}". In a real application, this would be a streamed response from an AI model.`,
249
+ timestamp: new Date().toISOString(),
250
+ actions: createMessageActions(assistantMessageId, 'assistant'),
251
+ };
252
+ setMessages((prev) => [...prev, assistantMessage]);
253
+ setStatus('ready');
254
+ };
255
+ const handleSelectChat = (chat) => {
256
+ setActiveChat(chat);
257
+ // Load messages for selected chat
258
+ const chatMessages = mockChatMessages[chat.id] || [];
259
+ setMessages(addActionsToMessages(chatMessages));
260
+ };
261
+ const handleCreateChat = () => {
262
+ setActiveChat(null);
263
+ setMessages([]);
264
+ };
265
+ return (_jsx(ChatContainer, Object.assign({}, args, { messages: messages, activeChat: activeChat, onSendMessage: handleSendMessage, onSelectChat: handleSelectChat, onCreateChat: handleCreateChat, status: status })));
266
+ },
267
+ decorators: defaultDecorators,
268
+ };
269
+ /**
270
+ * Empty state with welcome screen
271
+ */
272
+ export const EmptyState = {
273
+ args: {
274
+ messages: [],
275
+ welcomeConfig: {
276
+ image: _jsx(Icon, { data: Sparkles, size: 48 }),
277
+ title: 'Welcome to AI Chat',
278
+ description: 'Start a conversation by typing a message or selecting a suggestion.',
279
+ suggestionTitle: 'Try asking:',
280
+ suggestions: mockSuggestions,
281
+ },
282
+ },
283
+ render: (args) => {
284
+ const [messages, setMessages] = useState([]);
285
+ const handleSendMessage = async (data) => {
286
+ const userMessage = {
287
+ id: Date.now().toString(),
288
+ role: 'user',
289
+ content: data.content,
290
+ };
291
+ setMessages((prev) => [...prev, userMessage]);
292
+ };
293
+ return _jsx(ChatContainer, Object.assign({}, args, { messages: messages, onSendMessage: handleSendMessage }));
294
+ },
295
+ decorators: defaultDecorators,
296
+ };
297
+ /**
298
+ * State with messages
299
+ */
300
+ export const WithMessages = {
301
+ args: {
302
+ messages: mockMessages,
303
+ chats: mockChats,
304
+ activeChat: mockChats[0],
305
+ showActionsOnHover: true,
306
+ },
307
+ render: (args) => {
308
+ const [messages, setMessages] = useState(addActionsToMessages(args.messages || []));
309
+ const handleSendMessage = async (data) => {
310
+ const userMessageId = Date.now().toString();
311
+ const userMessage = {
312
+ id: userMessageId,
313
+ role: 'user',
314
+ content: data.content,
315
+ actions: createMessageActions(userMessageId, 'user'),
316
+ };
317
+ setMessages((prev) => [...prev, userMessage]);
318
+ };
319
+ return _jsx(ChatContainer, Object.assign({}, args, { messages: messages, onSendMessage: handleSendMessage }));
320
+ },
321
+ decorators: defaultDecorators,
322
+ };
323
+ /**
324
+ * With streaming
325
+ */
326
+ export const WithStreaming = {
327
+ args: {
328
+ messages: mockMessages,
329
+ showActionsOnHover: true,
330
+ },
331
+ render: (args) => {
332
+ const [messages, setMessages] = useState(addActionsToMessages(args.messages || []));
333
+ const [status, setStatus] = useState('ready');
334
+ const handleSendMessage = async (data) => {
335
+ const userMessageId = Date.now().toString();
336
+ const userMessage = {
337
+ id: userMessageId,
338
+ role: 'user',
339
+ content: data.content,
340
+ actions: createMessageActions(userMessageId, 'user'),
341
+ };
342
+ setMessages((prev) => [...prev, userMessage]);
343
+ // Simulate streaming
344
+ setStatus('streaming');
345
+ const assistantMessageId = (Date.now() + 1).toString();
346
+ const fullResponse = 'This is a simulated streaming response. In a real application, this text would appear word by word as it streams from the AI model. Streaming provides a better user experience for long responses.';
347
+ // Add empty message
348
+ setMessages((prev) => [
349
+ ...prev,
350
+ {
351
+ id: assistantMessageId,
352
+ role: 'assistant',
353
+ content: '',
354
+ actions: createMessageActions(assistantMessageId, 'assistant'),
355
+ },
356
+ ]);
357
+ // Simulate word-by-word streaming
358
+ const words = fullResponse.split(' ');
359
+ for (let i = 0; i < words.length; i++) {
360
+ await new Promise((resolve) => setTimeout(resolve, 100));
361
+ const currentText = words.slice(0, i + 1).join(' ');
362
+ setMessages((prev) => prev.map((msg) => msg.id === assistantMessageId ? Object.assign(Object.assign({}, msg), { content: currentText }) : msg));
363
+ }
364
+ setStatus('ready');
365
+ };
366
+ const handleCancel = async () => {
367
+ setStatus('ready');
368
+ };
369
+ return (_jsx(ChatContainer, Object.assign({}, args, { messages: messages, onSendMessage: handleSendMessage, onCancel: handleCancel, status: status })));
370
+ },
371
+ decorators: defaultDecorators,
372
+ };
373
+ /**
374
+ * With history
375
+ */
376
+ export const WithHistory = {
377
+ args: {
378
+ messages: mockMessages,
379
+ chats: mockChats,
380
+ activeChat: mockChats[0],
381
+ showHistory: true,
382
+ showActionsOnHover: true,
383
+ },
384
+ render: (args) => {
385
+ const [messages, setMessages] = useState(addActionsToMessages(args.messages || []));
386
+ const [chats, setChats] = useState(args.chats || []);
387
+ const [activeChat, setActiveChat] = useState(args.activeChat || null);
388
+ const handleSendMessage = async (data) => {
389
+ const userMessageId = Date.now().toString();
390
+ const userMessage = {
391
+ id: userMessageId,
392
+ role: 'user',
393
+ content: data.content,
394
+ actions: createMessageActions(userMessageId, 'user'),
395
+ };
396
+ setMessages((prev) => [...prev, userMessage]);
397
+ };
398
+ const handleSelectChat = (chat) => {
399
+ setActiveChat(chat);
400
+ // Load messages for selected chat
401
+ const chatMessages = mockChatMessages[chat.id] || [];
402
+ setMessages(addActionsToMessages(chatMessages));
403
+ };
404
+ const handleCreateChat = () => {
405
+ const newChat = {
406
+ id: Date.now().toString(),
407
+ name: 'New Chat',
408
+ createTime: new Date().toISOString(),
409
+ };
410
+ setChats((prev) => [newChat, ...prev]);
411
+ setActiveChat(newChat);
412
+ setMessages([]);
413
+ };
414
+ const handleDeleteChat = (chat) => {
415
+ setChats((prev) => prev.filter((c) => c.id !== chat.id));
416
+ if ((activeChat === null || activeChat === void 0 ? void 0 : activeChat.id) === chat.id) {
417
+ setActiveChat(null);
418
+ setMessages([]);
419
+ }
420
+ };
421
+ return (_jsx(ChatContainer, Object.assign({}, args, { messages: messages, chats: chats, activeChat: activeChat, onSendMessage: handleSendMessage, onSelectChat: handleSelectChat, onCreateChat: handleCreateChat, onDeleteChat: handleDeleteChat })));
422
+ },
423
+ decorators: defaultDecorators,
424
+ };
425
+ /**
426
+ * With custom i18n configuration
427
+ */
428
+ export const WithI18nConfig = {
429
+ args: {
430
+ messages: [],
431
+ i18nConfig: {
432
+ header: {
433
+ defaultTitle: 'My Custom AI Assistant',
434
+ },
435
+ emptyState: {
436
+ title: 'Hello!',
437
+ description: 'How can I help you today?',
438
+ suggestionsTitle: 'Quick actions:',
439
+ },
440
+ promptInput: {
441
+ placeholder: 'Ask me anything...',
442
+ },
443
+ disclaimer: {
444
+ text: 'Custom disclaimer text here.',
445
+ },
446
+ },
447
+ welcomeConfig: {
448
+ suggestions: mockSuggestions.slice(0, 2),
449
+ },
450
+ },
451
+ render: (args) => {
452
+ const [messages, setMessages] = useState([]);
453
+ const handleSendMessage = async (data) => {
454
+ const userMessage = {
455
+ id: Date.now().toString(),
456
+ role: 'user',
457
+ content: data.content,
458
+ };
459
+ setMessages((prev) => [...prev, userMessage]);
460
+ };
461
+ return _jsx(ChatContainer, Object.assign({}, args, { messages: messages, onSendMessage: handleSendMessage }));
462
+ },
463
+ decorators: defaultDecorators,
464
+ };
465
+ /**
466
+ * With component props override
467
+ */
468
+ export const WithComponentPropsOverride = {
469
+ args: {
470
+ messages: mockMessages,
471
+ headerProps: {
472
+ titlePosition: 'center',
473
+ },
474
+ promptInputProps: {
475
+ view: 'full',
476
+ maxLength: 2000,
477
+ },
478
+ historyProps: {
479
+ groupBy: 'none',
480
+ },
481
+ },
482
+ render: (args) => {
483
+ const [messages, setMessages] = useState(args.messages || []);
484
+ const handleSendMessage = async (data) => {
485
+ const userMessage = {
486
+ id: Date.now().toString(),
487
+ role: 'user',
488
+ content: data.content,
489
+ };
490
+ setMessages((prev) => [...prev, userMessage]);
491
+ };
492
+ return _jsx(ChatContainer, Object.assign({}, args, { messages: messages, onSendMessage: handleSendMessage }));
493
+ },
494
+ decorators: defaultDecorators,
495
+ };
496
+ /**
497
+ * With context items
498
+ */
499
+ export const WithContextItems = {
500
+ args: {
501
+ messages: mockMessages,
502
+ promptInputProps: {
503
+ view: 'full',
504
+ },
505
+ },
506
+ render: (args) => {
507
+ const [messages, setMessages] = useState(args.messages || []);
508
+ const [contextItems, setContextItems] = useState([
509
+ { id: '1', content: 'ChatContainer.tsx', onRemove: () => { } },
510
+ { id: '2', content: 'types.ts', onRemove: () => { } },
511
+ { id: '3', content: 'README.md', onRemove: () => { } },
512
+ ]);
513
+ const handleSendMessage = async (data) => {
514
+ const userMessage = {
515
+ id: Date.now().toString(),
516
+ role: 'user',
517
+ content: data.content,
518
+ };
519
+ setMessages((prev) => [...prev, userMessage]);
520
+ };
521
+ const handleRemoveContext = (id) => {
522
+ setContextItems((prev) => prev.filter((item) => item.id !== id));
523
+ };
524
+ return (_jsx(ChatContainer, Object.assign({}, args, { messages: messages, onSendMessage: handleSendMessage, contextItems: contextItems.map((item) => (Object.assign(Object.assign({}, item), { onRemove: () => handleRemoveContext(item.id) }))) })));
525
+ },
526
+ decorators: defaultDecorators,
527
+ };
528
+ /**
529
+ * With context items and indicator
530
+ */
531
+ export const WithContextItemsAndIndicator = {
532
+ args: {
533
+ messages: mockMessages,
534
+ promptInputProps: {
535
+ view: 'full',
536
+ headerProps: {
537
+ showContextIndicator: true,
538
+ contextIndicatorProps: {
539
+ type: 'percent',
540
+ usedContext: 75,
541
+ },
542
+ },
543
+ },
544
+ },
545
+ render: (args) => {
546
+ const [messages, setMessages] = useState(args.messages || []);
547
+ const [contextItems, setContextItems] = useState([
548
+ { id: '1', content: 'file.tsx', onRemove: () => { } },
549
+ { id: '2', content: 'component.tsx', onRemove: () => { } },
550
+ ]);
551
+ const handleSendMessage = async (data) => {
552
+ const userMessage = {
553
+ id: Date.now().toString(),
554
+ role: 'user',
555
+ content: data.content,
556
+ };
557
+ setMessages((prev) => [...prev, userMessage]);
558
+ };
559
+ const handleRemoveContext = (id) => {
560
+ setContextItems((prev) => prev.filter((item) => item.id !== id));
561
+ };
562
+ return (_jsx(ChatContainer, Object.assign({}, args, { messages: messages, onSendMessage: handleSendMessage, contextItems: contextItems.map((item) => (Object.assign(Object.assign({}, item), { onRemove: () => handleRemoveContext(item.id) }))) })));
563
+ },
564
+ decorators: defaultDecorators,
565
+ };
566
+ /**
567
+ * With loading state
568
+ */
569
+ export const LoadingState = {
570
+ args: {
571
+ messages: addActionsToMessages(mockMessages),
572
+ status: 'submitted',
573
+ showActionsOnHover: true,
574
+ },
575
+ render: (args) => {
576
+ return _jsx(ChatContainer, Object.assign({}, args, { onSendMessage: async () => { } }));
577
+ },
578
+ decorators: defaultDecorators,
579
+ };
580
+ /**
581
+ * With error
582
+ */
583
+ export const ErrorState = {
584
+ args: {
585
+ messages: addActionsToMessages(mockMessages),
586
+ status: 'error',
587
+ error: new Error('Failed to send message. Please try again.'),
588
+ showActionsOnHover: true,
589
+ },
590
+ render: (args) => {
591
+ const [messages, setMessages] = useState(args.messages || []);
592
+ const handleSendMessage = async (data) => {
593
+ const userMessageId = Date.now().toString();
594
+ const userMessage = {
595
+ id: userMessageId,
596
+ role: 'user',
597
+ content: data.content,
598
+ actions: createMessageActions(userMessageId, 'user'),
599
+ };
600
+ setMessages((prev) => [...prev, userMessage]);
601
+ };
602
+ return _jsx(ChatContainer, Object.assign({}, args, { messages: messages, onSendMessage: handleSendMessage }));
603
+ },
604
+ decorators: defaultDecorators,
605
+ };
606
+ /**
607
+ * Full example with realistic streaming via fetch API
608
+ */
609
+ export const FullStreamingExample = {
610
+ args: {
611
+ messages: [],
612
+ chats: mockChats,
613
+ activeChat: mockChats[0],
614
+ showHistory: true,
615
+ showNewChat: true,
616
+ welcomeConfig: {
617
+ image: _jsx(Icon, { data: Sparkles, size: 48 }),
618
+ title: 'AI Streaming Chat',
619
+ description: 'Experience real-time streaming responses',
620
+ suggestionTitle: 'Try these prompts:',
621
+ suggestions: mockSuggestions,
622
+ },
623
+ showActionsOnHover: true,
624
+ },
625
+ render: (args) => {
626
+ const initialChat = mockChats[0];
627
+ const [messages, setMessages] = useState(addActionsToMessages(mockChatMessages[initialChat.id] || []));
628
+ const [activeChat, setActiveChat] = useState(initialChat);
629
+ const [status, setStatus] = useState('ready');
630
+ const [controller, setController] = useState(null);
631
+ const handleSendMessage = async (data) => {
632
+ // Add user message
633
+ const userMessageId = Date.now().toString();
634
+ const userMessage = {
635
+ id: userMessageId,
636
+ role: 'user',
637
+ content: data.content,
638
+ timestamp: new Date().toISOString(),
639
+ actions: createMessageActions(userMessageId, 'user'),
640
+ };
641
+ setMessages((prev) => [...prev, userMessage]);
642
+ // Start streaming
643
+ setStatus('streaming');
644
+ const abortController = new AbortController();
645
+ setController(abortController);
646
+ try {
647
+ // In real app, this would be a fetch to API
648
+ // const response = await fetch('/api/chat/stream', {
649
+ // method: 'POST',
650
+ // headers: {'Content-Type': 'application/json'},
651
+ // body: JSON.stringify({message: data.content}),
652
+ // signal: abortController.signal,
653
+ // });
654
+ // Simulate streaming for demo
655
+ const assistantMessageId = (Date.now() + 1).toString();
656
+ const fullResponse = `This is a detailed response to your question: "${data.content}"\n\nIn a production environment, this text would be streamed from an AI model in real-time. The streaming provides several benefits:\n\n1. **Better User Experience**: Users see the response as it's being generated\n2. **Lower Perceived Latency**: The wait feels shorter when content appears incrementally\n3. **Ability to Cancel**: Users can stop generation if they have enough information\n4. **Resource Efficiency**: Responses can be processed as they arrive\n\nThe implementation would use Server-Sent Events (SSE) or streaming fetch API to receive chunks of text from the backend, updating the message content in real-time.`;
657
+ // Create empty assistant message
658
+ setMessages((prev) => [
659
+ ...prev,
660
+ {
661
+ id: assistantMessageId,
662
+ role: 'assistant',
663
+ content: '',
664
+ timestamp: new Date().toISOString(),
665
+ actions: createMessageActions(assistantMessageId, 'assistant'),
666
+ },
667
+ ]);
668
+ // Simulate word-by-word streaming
669
+ const words = fullResponse.split(' ');
670
+ for (let i = 0; i < words.length; i++) {
671
+ if (abortController.signal.aborted) {
672
+ break;
673
+ }
674
+ await new Promise((resolve) => setTimeout(resolve, 50));
675
+ const currentText = words.slice(0, i + 1).join(' ');
676
+ setMessages((prev) => prev.map((msg) => msg.id === assistantMessageId ? Object.assign(Object.assign({}, msg), { content: currentText }) : msg));
677
+ }
678
+ }
679
+ catch (error) {
680
+ if (error.name !== 'AbortError') {
681
+ // In real app, error handling would be here
682
+ // console.error('Streaming error:', error);
683
+ }
684
+ }
685
+ finally {
686
+ setStatus('ready');
687
+ setController(null);
688
+ }
689
+ };
690
+ const handleCancel = async () => {
691
+ controller === null || controller === void 0 ? void 0 : controller.abort();
692
+ setStatus('ready');
693
+ };
694
+ const handleSelectChat = (chat) => {
695
+ setActiveChat(chat);
696
+ // Load messages for selected chat
697
+ const chatMessages = mockChatMessages[chat.id] || [];
698
+ setMessages(addActionsToMessages(chatMessages));
699
+ };
700
+ const handleCreateChat = () => {
701
+ setActiveChat(null);
702
+ setMessages([]);
703
+ };
704
+ return (_jsx(ChatContainer, Object.assign({}, args, { messages: messages, activeChat: activeChat, onSendMessage: handleSendMessage, onCancel: handleCancel, onSelectChat: handleSelectChat, onCreateChat: handleCreateChat, status: status })));
705
+ },
706
+ decorators: defaultDecorators,
707
+ };