@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,65 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { ChevronsCollapseUpRight, ChevronsExpandUpRight, ClockArrowRotateLeft, Plus, Sparkles, Xmark, } from '@gravity-ui/icons';
4
+ import { Button, Icon, Text } from '@gravity-ui/uikit';
5
+ import { block } from '../../../utils/cn';
6
+ import { ActionButton } from '../../atoms';
7
+ import { ButtonGroup } from '../../molecules';
8
+ import { i18n } from './i18n';
9
+ import { HeaderAction } from './types';
10
+ import { useHeader } from './useHeader';
11
+ import './Header.scss';
12
+ const b = block('header');
13
+ // Icons for base actions
14
+ const ACTION_ICONS = {
15
+ [HeaderAction.NewChat]: Plus,
16
+ [HeaderAction.History]: ClockArrowRotateLeft,
17
+ [HeaderAction.Folding]: ChevronsCollapseUpRight, // Default icon, will be switched based on state
18
+ [HeaderAction.Close]: Xmark,
19
+ };
20
+ // Icons for folding states
21
+ const FOLDING_ICONS = {
22
+ collapsed: ChevronsExpandUpRight,
23
+ opened: ChevronsCollapseUpRight,
24
+ };
25
+ /**
26
+ * Header component for displaying chat header with navigation and actions
27
+ *
28
+ * @param props - Component props
29
+ * @returns Header component
30
+ */
31
+ export function Header(props) {
32
+ const { title, preview, icon, baseActions, additionalActions, titlePosition, className, historyButtonRef, } = useHeader(props);
33
+ // Render base action
34
+ const renderBaseAction = (action) => {
35
+ let IconComponent = ACTION_ICONS[action.id];
36
+ // Handle folding icon based on state
37
+ if (action.id === HeaderAction.Folding && action.foldingState) {
38
+ IconComponent = FOLDING_ICONS[action.foldingState];
39
+ }
40
+ if (!IconComponent) {
41
+ return null;
42
+ }
43
+ // Get tooltip text
44
+ let tooltipKey = `action-tooltip-${action.id}`;
45
+ if (action.id === HeaderAction.Folding && action.foldingState) {
46
+ tooltipKey = `action-tooltip-folding-${action.foldingState}`;
47
+ }
48
+ // Determine ref for history button
49
+ const buttonRef = action.id === HeaderAction.History ? historyButtonRef : undefined;
50
+ return (_jsx(ActionButton, { ref: buttonRef, tooltipTitle: i18n(tooltipKey), size: "m", view: "flat", onClick: action.onClick, className: b('action-button'), qa: `header-action-${action.id}`, children: _jsx(Icon, { data: IconComponent, size: 16 }) }, action.id));
51
+ };
52
+ // Render additional action
53
+ const renderAdditionalAction = (action, index) => {
54
+ if (action.content && React.isValidElement(action.content)) {
55
+ return (_jsx(React.Fragment, { children: action.content }, action.id || `additional-${index}`));
56
+ }
57
+ if (action.buttonProps) {
58
+ return _jsx(Button, Object.assign({}, action.buttonProps), action.id);
59
+ }
60
+ return null;
61
+ };
62
+ // Determine class for title positioning
63
+ const titlePositionClass = b('title-container', { position: titlePosition });
64
+ return (_jsxs("div", { className: b('', className), children: [icon ? _jsx("div", { className: b('icon'), children: icon }) : _jsx(Icon, { data: Sparkles, size: 16 }), _jsxs("div", { className: titlePositionClass, children: [title && (_jsx(Text, { as: "div", variant: "subheader-2", className: b('title'), children: title })), preview && _jsx("div", { className: b('preview'), children: preview })] }), _jsxs(ButtonGroup, { children: [additionalActions.map((action, index) => renderAdditionalAction(action, index)), baseActions.map((action) => renderBaseAction(action))] })] }));
65
+ }
@@ -0,0 +1,13 @@
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-webpack5';
2
+ import { type HeaderProps } from '../index';
3
+ declare const _default: Meta;
4
+ export default _default;
5
+ export declare const Playground: StoryFn<HeaderProps>;
6
+ export declare const WithTitle: StoryFn<HeaderProps>;
7
+ export declare const WithIcon: StoryFn<HeaderProps>;
8
+ export declare const WithPreview: StoryFn<HeaderProps>;
9
+ export declare const TitlePositions: StoryObj<HeaderProps>;
10
+ export declare const BaseActions: StoryObj<HeaderProps>;
11
+ export declare const AdditionalActions: StoryFn<HeaderProps>;
12
+ export declare const FullExample: StoryFn<HeaderProps>;
13
+ export declare const FoldingInteractive: StoryFn<HeaderProps>;
@@ -0,0 +1,130 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Gear } from '@gravity-ui/icons';
4
+ import { Button, Icon } from '@gravity-ui/uikit';
5
+ import { ContentWrapper } from '../../../../demo/ContentWrapper';
6
+ import { Showcase } from '../../../../demo/Showcase';
7
+ import { ShowcaseItem } from '../../../../demo/ShowcaseItem';
8
+ import { Header, HeaderAction } from '../index';
9
+ import MDXDocs from './Docs.mdx';
10
+ export default {
11
+ title: 'organisms/Header',
12
+ component: Header,
13
+ parameters: {
14
+ docs: {
15
+ page: MDXDocs,
16
+ },
17
+ },
18
+ argTypes: {
19
+ titlePosition: {
20
+ control: 'radio',
21
+ options: ['left', 'center'],
22
+ description: 'Title position',
23
+ },
24
+ },
25
+ };
26
+ const defaultDecorators = [
27
+ (Story) => (_jsx(Showcase, { children: _jsx(Story, {}) })),
28
+ ];
29
+ // Mock handlers for actions
30
+ const mockHandlers = {
31
+ handleNewChat: () => {
32
+ // eslint-disable-next-line no-console
33
+ console.log('New chat clicked');
34
+ },
35
+ handleHistoryToggle: () => {
36
+ // eslint-disable-next-line no-console
37
+ console.log('History toggle clicked');
38
+ },
39
+ handleFolding: (value) => {
40
+ // eslint-disable-next-line no-console
41
+ console.log('Folding clicked:', value);
42
+ },
43
+ handleClose: () => {
44
+ // eslint-disable-next-line no-console
45
+ console.log('Close clicked');
46
+ },
47
+ };
48
+ export const Playground = (args) => {
49
+ return (_jsx(ContentWrapper, { width: "480px", children: _jsx(Header, Object.assign({}, args)) }));
50
+ };
51
+ Playground.args = Object.assign({ title: 'Chat Header', baseActions: [
52
+ HeaderAction.NewChat,
53
+ HeaderAction.History,
54
+ HeaderAction.Folding,
55
+ HeaderAction.Close,
56
+ ], foldingState: 'opened' }, mockHandlers);
57
+ export const WithTitle = (args) => {
58
+ return (_jsx(ContentWrapper, { width: "480px", children: _jsx(Header, Object.assign({ title: "Chat Header", baseActions: [HeaderAction.NewChat, HeaderAction.History, HeaderAction.Close] }, mockHandlers, args)) }));
59
+ };
60
+ export const WithIcon = (args) => {
61
+ return (_jsx(ContentWrapper, { width: "480px", children: _jsx(Header, Object.assign({ icon: _jsx("div", { style: { width: 24, height: 24, background: '#ccc', borderRadius: 4 } }), title: "Chat Header", baseActions: [HeaderAction.NewChat, HeaderAction.History, HeaderAction.Close] }, mockHandlers, args)) }));
62
+ };
63
+ export const WithPreview = (args) => {
64
+ return (_jsx(ContentWrapper, { width: "480px", children: _jsx(Header, Object.assign({ title: "Chat Header", preview: _jsx("div", { children: "Preview" }), baseActions: [HeaderAction.NewChat, HeaderAction.History, HeaderAction.Close] }, mockHandlers, args)) }));
65
+ };
66
+ export const TitlePositions = {
67
+ render: (args) => {
68
+ return (_jsxs(_Fragment, { children: [_jsx(ShowcaseItem, { title: "Left", children: _jsx(ContentWrapper, { width: "480px", children: _jsx(Header, Object.assign({ title: "Left Title", titlePosition: "left", baseActions: [HeaderAction.NewChat, HeaderAction.Close] }, mockHandlers, args)) }) }), _jsx(ShowcaseItem, { title: "Center", children: _jsx(ContentWrapper, { width: "480px", children: _jsx(Header, Object.assign({ title: "Center Title", titlePosition: "center", baseActions: [HeaderAction.NewChat, HeaderAction.Close] }, mockHandlers, args)) }) })] }));
69
+ },
70
+ decorators: defaultDecorators,
71
+ };
72
+ export const BaseActions = {
73
+ render: (args) => {
74
+ return (_jsxs(_Fragment, { children: [_jsx(ShowcaseItem, { title: "All actions", children: _jsx(ContentWrapper, { width: "480px", children: _jsx(Header, Object.assign({ title: "All Actions", baseActions: [
75
+ HeaderAction.NewChat,
76
+ HeaderAction.History,
77
+ HeaderAction.Folding,
78
+ HeaderAction.Close,
79
+ ], foldingState: "opened" }, mockHandlers)) }) }), _jsx(ShowcaseItem, { title: "Folding opened", children: _jsx(ContentWrapper, { width: "480px", children: _jsx(Header, Object.assign({ title: "With Folding (opened)", baseActions: [
80
+ HeaderAction.NewChat,
81
+ HeaderAction.History,
82
+ HeaderAction.Folding,
83
+ ], foldingState: "opened" }, mockHandlers)) }) }), _jsx(ShowcaseItem, { title: "Folding collapsed", children: _jsx(ContentWrapper, { width: "480px", children: _jsx(Header, Object.assign({ title: "With Folding (collapsed)", baseActions: [
84
+ HeaderAction.NewChat,
85
+ HeaderAction.History,
86
+ HeaderAction.Folding,
87
+ ], foldingState: "collapsed" }, mockHandlers, args)) }) })] }));
88
+ },
89
+ decorators: defaultDecorators,
90
+ };
91
+ export const AdditionalActions = (args) => {
92
+ return (_jsx(ContentWrapper, { width: "480px", children: _jsx(Header, Object.assign({ title: "With Additional Actions", baseActions: [HeaderAction.NewChat, HeaderAction.History, HeaderAction.Close], additionalActions: [
93
+ {
94
+ children: 'Action 1',
95
+ onClick: () => {
96
+ // eslint-disable-next-line no-console
97
+ console.log('Additional action 1');
98
+ },
99
+ },
100
+ _jsx(Button, { size: "m", view: "flat", children: _jsx(Icon, { data: Gear, size: 16 }) }, "settings"),
101
+ ] }, mockHandlers, args)) }));
102
+ };
103
+ export const FullExample = (args) => {
104
+ return (_jsx(ContentWrapper, { width: "480px", children: _jsx(Header, Object.assign({ icon: _jsx("div", { style: { width: 24, height: 24, background: '#ccc', borderRadius: 4 } }), title: "Chat Header", preview: _jsx("div", { children: "Preview" }), baseActions: [HeaderAction.NewChat, HeaderAction.History, HeaderAction.Close], additionalActions: [
105
+ {
106
+ children: 'Settings',
107
+ view: 'outlined',
108
+ size: 'm',
109
+ onClick: () => {
110
+ // eslint-disable-next-line no-console
111
+ console.log('Settings clicked');
112
+ },
113
+ },
114
+ _jsx(Button, { size: "m", view: "flat", children: _jsx(Icon, { data: Gear, size: 16 }) }, "settings"),
115
+ ], titlePosition: "center" }, mockHandlers, args)) }));
116
+ };
117
+ // Interactive story to demonstrate folding state toggle
118
+ export const FoldingInteractive = (args) => {
119
+ const [foldingState, setFoldingState] = useState('opened');
120
+ return (_jsx(ContentWrapper, { width: "480px", children: _jsx(Header, Object.assign({ title: "Interactive Folding", baseActions: [
121
+ HeaderAction.NewChat,
122
+ HeaderAction.History,
123
+ HeaderAction.Folding,
124
+ HeaderAction.Close,
125
+ ], foldingState: foldingState, handleFolding: (value) => {
126
+ setFoldingState(value);
127
+ // eslint-disable-next-line no-console
128
+ console.log('Folding state changed to:', value);
129
+ }, handleNewChat: mockHandlers.handleNewChat, handleHistoryToggle: mockHandlers.handleHistoryToggle, handleClose: mockHandlers.handleClose }, args)) }));
130
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "action-tooltip-newChat": "New chat",
3
+ "action-tooltip-history": "History",
4
+ "action-tooltip-folding-collapsed": "Expand",
5
+ "action-tooltip-folding-opened": "Collapse",
6
+ "action-tooltip-close": "Close"
7
+ }
@@ -0,0 +1,13 @@
1
+ export declare const i18n: ((key: "action-tooltip-newChat" | "action-tooltip-history" | "action-tooltip-folding-collapsed" | "action-tooltip-folding-opened" | "action-tooltip-close", params?: import("@gravity-ui/i18n").Params) => string) & {
2
+ Translation: import("react").ComponentType<{
3
+ children: (props: {
4
+ t: (key: "action-tooltip-newChat" | "action-tooltip-history" | "action-tooltip-folding-collapsed" | "action-tooltip-folding-opened" | "action-tooltip-close", params?: import("@gravity-ui/i18n").Params) => string;
5
+ }) => React.ReactNode;
6
+ }>;
7
+ useTranslation: () => {
8
+ t: (key: "action-tooltip-newChat" | "action-tooltip-history" | "action-tooltip-folding-collapsed" | "action-tooltip-folding-opened" | "action-tooltip-close", params?: import("@gravity-ui/i18n").Params) => string;
9
+ };
10
+ keysetData: {
11
+ "g-aikit-Header": Record<"action-tooltip-newChat" | "action-tooltip-history" | "action-tooltip-folding-collapsed" | "action-tooltip-folding-opened" | "action-tooltip-close", import("@gravity-ui/i18n").KeyData>;
12
+ };
13
+ };
@@ -0,0 +1,5 @@
1
+ import { addComponentKeysets } from '@gravity-ui/uikit/i18n';
2
+ import { NAMESPACE } from '../../../../utils/cn';
3
+ import en from './en.json';
4
+ import ru from './ru.json';
5
+ export const i18n = addComponentKeysets({ en, ru }, `${NAMESPACE}Header`);
@@ -0,0 +1,7 @@
1
+ {
2
+ "action-tooltip-newChat": "Новый чат",
3
+ "action-tooltip-history": "История",
4
+ "action-tooltip-folding-collapsed": "Развернуть",
5
+ "action-tooltip-folding-opened": "Свернуть",
6
+ "action-tooltip-close": "Закрыть"
7
+ }
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export { Header } from './Header';
3
+ export { useHeader } from './useHeader';
4
+ export type { ActionItem } from './useHeader';
@@ -0,0 +1,6 @@
1
+ // Types
2
+ export * from './types';
3
+ // Components
4
+ export { Header } from './Header';
5
+ // Hooks
6
+ export { useHeader } from './useHeader';
@@ -0,0 +1,23 @@
1
+ import type { ButtonProps } from '@gravity-ui/uikit';
2
+ export declare enum HeaderAction {
3
+ NewChat = "newChat",
4
+ History = "history",
5
+ Folding = "folding",
6
+ Close = "close"
7
+ }
8
+ export type AdditionalActionsConfig = ButtonProps | React.ReactNode;
9
+ export type HeaderProps = {
10
+ icon?: React.ReactNode;
11
+ title?: string;
12
+ preview?: React.ReactNode;
13
+ baseActions?: HeaderAction[];
14
+ handleNewChat?: () => void;
15
+ handleHistoryToggle?: () => void;
16
+ handleFolding?: (value: 'collapsed' | 'opened') => void;
17
+ handleClose?: () => void;
18
+ additionalActions?: AdditionalActionsConfig[];
19
+ historyButtonRef?: React.RefObject<HTMLElement>;
20
+ foldingState?: 'collapsed' | 'opened';
21
+ titlePosition?: 'left' | 'center';
22
+ className?: string;
23
+ };
@@ -0,0 +1,7 @@
1
+ export var HeaderAction;
2
+ (function (HeaderAction) {
3
+ HeaderAction["NewChat"] = "newChat";
4
+ HeaderAction["History"] = "history";
5
+ HeaderAction["Folding"] = "folding";
6
+ HeaderAction["Close"] = "close";
7
+ })(HeaderAction || (HeaderAction = {}));
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import type { ButtonProps } from '@gravity-ui/uikit';
3
+ import { type HeaderProps } from './types';
4
+ export type ActionItem = {
5
+ id: string;
6
+ type: 'base' | 'additional';
7
+ content: React.ReactNode;
8
+ onClick?: () => void;
9
+ buttonProps?: ButtonProps;
10
+ foldingState?: 'collapsed' | 'opened';
11
+ };
12
+ export declare function useHeader(props: HeaderProps): {
13
+ title: string | undefined;
14
+ preview: React.ReactNode | undefined;
15
+ icon: React.ReactNode | undefined;
16
+ baseActions: ActionItem[];
17
+ additionalActions: ActionItem[];
18
+ titlePosition: 'left' | 'center';
19
+ className?: string;
20
+ historyButtonRef?: React.RefObject<HTMLElement>;
21
+ };
@@ -0,0 +1,71 @@
1
+ import React, { useMemo } from 'react';
2
+ import { HeaderAction } from './types';
3
+ export function useHeader(props) {
4
+ const { icon, title, preview, baseActions = [], handleNewChat, handleHistoryToggle, handleClose, handleFolding, foldingState = 'opened', additionalActions = [], titlePosition = 'left', className, historyButtonRef, } = props;
5
+ // Build base actions
6
+ const baseActionsList = useMemo(() => {
7
+ const actions = [];
8
+ baseActions.forEach((action) => {
9
+ if (action === HeaderAction.Folding) {
10
+ if (handleFolding) {
11
+ actions.push({
12
+ id: action,
13
+ type: 'base',
14
+ content: null, // Will be rendered in component
15
+ onClick: () => {
16
+ const newState = foldingState === 'opened' ? 'collapsed' : 'opened';
17
+ handleFolding(newState);
18
+ },
19
+ foldingState,
20
+ });
21
+ }
22
+ return;
23
+ }
24
+ const actionMap = {
25
+ [HeaderAction.NewChat]: handleNewChat,
26
+ [HeaderAction.History]: handleHistoryToggle,
27
+ [HeaderAction.Close]: handleClose,
28
+ };
29
+ const handler = actionMap[action];
30
+ if (handler) {
31
+ actions.push({
32
+ id: action,
33
+ type: 'base',
34
+ content: null, // Will be rendered in component
35
+ onClick: handler,
36
+ });
37
+ }
38
+ });
39
+ return actions;
40
+ }, [baseActions, handleNewChat, handleHistoryToggle, handleClose, handleFolding, foldingState]);
41
+ // Build additional actions
42
+ const additionalActionsList = useMemo(() => {
43
+ return additionalActions.map((action, index) => {
44
+ if (React.isValidElement(action)) {
45
+ return {
46
+ id: `additional-${index}`,
47
+ type: 'additional',
48
+ content: action,
49
+ };
50
+ }
51
+ // If it's ButtonProps, create a button
52
+ const buttonProps = action;
53
+ return {
54
+ id: buttonProps.qa || `additional-${index}`,
55
+ type: 'additional',
56
+ content: null, // Will be rendered in component
57
+ buttonProps,
58
+ };
59
+ });
60
+ }, [additionalActions]);
61
+ return {
62
+ title,
63
+ preview,
64
+ icon,
65
+ baseActions: baseActionsList,
66
+ additionalActions: additionalActionsList,
67
+ titlePosition,
68
+ className,
69
+ historyButtonRef,
70
+ };
71
+ }
@@ -0,0 +1,6 @@
1
+ import { AlertProps } from '../../atoms/Alert';
2
+ export type ErrorAlertProps = {
3
+ onRetry?: () => void;
4
+ errorMessage?: AlertProps;
5
+ };
6
+ export declare function ErrorAlert({ onRetry, errorMessage }: ErrorAlertProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ArrowRotateLeft } from '@gravity-ui/icons';
3
+ import { Icon } from '@gravity-ui/uikit';
4
+ import { block } from '../../../utils/cn';
5
+ import { Alert } from '../../atoms/Alert';
6
+ import { i18n } from './i18n';
7
+ const b = block('message-list');
8
+ export function ErrorAlert({ onRetry, errorMessage }) {
9
+ return (_jsx(Alert, Object.assign({ text: i18n('default-error-text'), variant: "warning", button: onRetry
10
+ ? {
11
+ content: (_jsxs("div", { className: b('retry-button'), children: [_jsx(Icon, { data: ArrowRotateLeft, size: 14 }), i18n('retry-button')] })),
12
+ onClick: onRetry,
13
+ }
14
+ : undefined }, errorMessage)));
15
+ }
@@ -0,0 +1,20 @@
1
+ import type { OptionsType } from '@diplodoc/transform/lib/typings';
2
+ import { ChatStatus } from '../../../types';
3
+ import type { TChatMessage, TMessageContent, TMessageMetadata } from '../../../types/messages';
4
+ import { type MessageRendererRegistry } from '../../../utils/messageTypeRegistry';
5
+ import { AlertProps } from '../../atoms/Alert';
6
+ import './MessageList.scss';
7
+ export type MessageListProps<TContent extends TMessageContent = never> = {
8
+ messages: TChatMessage<TContent, TMessageMetadata>[];
9
+ status?: ChatStatus;
10
+ errorMessage?: AlertProps;
11
+ onRetry?: () => void;
12
+ messageRendererRegistry?: MessageRendererRegistry;
13
+ transformOptions?: OptionsType;
14
+ showActionsOnHover?: boolean;
15
+ showTimestamp?: boolean;
16
+ showAvatar?: boolean;
17
+ className?: string;
18
+ qa?: string;
19
+ };
20
+ export declare function MessageList<TContent extends TMessageContent = never>({ messages, messageRendererRegistry, transformOptions, showActionsOnHover, showTimestamp, showAvatar, className, qa, status, errorMessage, onRetry, }: MessageListProps<TContent>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { isAssistantMessage, isUserMessage } from '../../../utils';
3
+ import { block } from '../../../utils/cn';
4
+ import { Loader } from '../../atoms/Loader';
5
+ import { AssistantMessage } from '../AssistantMessage';
6
+ import { UserMessage } from '../UserMessage';
7
+ import { ErrorAlert } from './ErrorAlert';
8
+ import './MessageList.scss';
9
+ const b = block('message-list');
10
+ export function MessageList({ messages, messageRendererRegistry, transformOptions, showActionsOnHover, showTimestamp, showAvatar, className, qa, status, errorMessage, onRetry, }) {
11
+ const renderMessage = (message, index) => {
12
+ if (isUserMessage(message)) {
13
+ return (_jsx(UserMessage, { content: message.content, actions: message.actions, timestamp: message.timestamp, format: message.format, avatarUrl: message.avatarUrl, transformOptions: transformOptions, showActionsOnHover: showActionsOnHover, showTimestamp: showTimestamp, showAvatar: showAvatar }, message.id || `message-${index}`));
14
+ }
15
+ if (isAssistantMessage(message)) {
16
+ return (_jsx(AssistantMessage, { content: message.content, actions: message.actions, timestamp: message.timestamp, id: message.id, messageRendererRegistry: messageRendererRegistry, transformOptions: transformOptions, showActionsOnHover: showActionsOnHover, showTimestamp: showTimestamp }, message.id || `message-${index}`));
17
+ }
18
+ return null;
19
+ };
20
+ return (_jsxs("div", { className: b(null, className), "data-qa": qa, children: [_jsx("div", { className: b('messages', className), "data-qa": qa, children: messages.map(renderMessage) }), status === 'submitted' && _jsx(Loader, {}), status === 'error' && _jsx(ErrorAlert, { onRetry: onRetry, errorMessage: errorMessage })] }));
21
+ }
@@ -0,0 +1,22 @@
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-webpack5';
2
+ import { type MessageListProps } from '..';
3
+ import type { TMessageContent } from '../../../../types/messages';
4
+ declare const _default: Meta;
5
+ export default _default;
6
+ export declare const Playground: StoryFn<MessageListProps>;
7
+ export declare const WithSubmittedStatus: StoryObj<MessageListProps>;
8
+ export declare const WithErrorMessage: StoryObj<MessageListProps>;
9
+ export declare const WithToolMessage: StoryObj<MessageListProps>;
10
+ interface ChartMessageData {
11
+ chartData: {
12
+ labels: string[];
13
+ datasets: Array<{
14
+ label: string;
15
+ data: number[];
16
+ color?: string;
17
+ }>;
18
+ };
19
+ chartType: 'line' | 'bar' | 'pie';
20
+ }
21
+ type ChartMessageContent = TMessageContent<'chart', ChartMessageData>;
22
+ export declare const WithCustomMessageType: StoryObj<MessageListProps<ChartMessageContent>>;
@@ -0,0 +1,168 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pencil } from '@gravity-ui/icons';
3
+ import { Icon, Text } from '@gravity-ui/uikit';
4
+ import { MessageList } from '..';
5
+ import { ContentWrapper } from '../../../../demo/ContentWrapper';
6
+ import { Showcase } from '../../../../demo/Showcase';
7
+ import { ShowcaseItem } from '../../../../demo/ShowcaseItem';
8
+ import { createMessageRendererRegistry, registerMessageRenderer, } from '../../../../utils/messageTypeRegistry';
9
+ import MDXDocs from './Docs.mdx';
10
+ export default {
11
+ title: 'organisms/MessageList',
12
+ component: MessageList,
13
+ parameters: {
14
+ docs: {
15
+ page: MDXDocs,
16
+ },
17
+ },
18
+ argTypes: {
19
+ messages: {
20
+ control: 'object',
21
+ description: 'Array of messages to render',
22
+ },
23
+ messageRendererRegistry: {
24
+ control: false,
25
+ description: 'Custom message renderer registry',
26
+ },
27
+ showActionsOnHover: {
28
+ control: 'boolean',
29
+ description: 'Show action buttons on hover for all messages',
30
+ },
31
+ showTimestamp: {
32
+ control: 'boolean',
33
+ description: 'Show timestamp for all messages',
34
+ },
35
+ showAvatar: {
36
+ control: 'boolean',
37
+ description: 'Show avatar for user messages',
38
+ },
39
+ className: {
40
+ control: 'text',
41
+ description: 'Additional CSS class',
42
+ },
43
+ qa: {
44
+ control: 'text',
45
+ description: 'QA/test identifier',
46
+ },
47
+ },
48
+ };
49
+ const defaultDecorators = [
50
+ (StoryComponent) => (_jsx(Showcase, { children: _jsx(StoryComponent, {}) })),
51
+ ];
52
+ const userMessage = {
53
+ id: '1',
54
+ role: 'user',
55
+ timestamp: '2024-01-01T00:00:00Z',
56
+ content: 'Hello, how are you?',
57
+ };
58
+ const assistantMessage = {
59
+ id: '2',
60
+ role: 'assistant',
61
+ timestamp: '2024-01-01T00:00:01Z',
62
+ content: 'Hi! I am doing well, thank you for asking.',
63
+ };
64
+ export const Playground = (args) => (_jsx(ContentWrapper, { width: "480px", children: _jsx(MessageList, Object.assign({}, args)) }));
65
+ Playground.args = {
66
+ messages: [userMessage, assistantMessage],
67
+ };
68
+ export const WithSubmittedStatus = {
69
+ render: (args) => (_jsx(ShowcaseItem, { title: "With Submitted Status", children: _jsx(ContentWrapper, { width: "480px", children: _jsx(MessageList, Object.assign({}, args, { messages: [userMessage], status: "submitted" })) }) })),
70
+ };
71
+ export const WithErrorMessage = {
72
+ render: (args) => (_jsx(ShowcaseItem, { title: "With Error Message", children: _jsx(ContentWrapper, { width: "480px", children: _jsx(MessageList, Object.assign({}, args, { messages: [userMessage], status: "error",
73
+ // eslint-disable-next-line no-console
74
+ onRetry: () => console.log('retry') })) }) })),
75
+ };
76
+ const toolIcon = _jsx(Icon, { data: Pencil });
77
+ const toolHeaderContent = (_jsx(Text, { color: "secondary", variant: "body-1", children: "expectScreenshotFixture.ts" }));
78
+ export const WithToolMessage = {
79
+ render: (args) => (_jsx(ShowcaseItem, { title: "With Tool Message", children: _jsx(ContentWrapper, { width: "480px", children: _jsx(MessageList, Object.assign({}, args, { messages: [
80
+ {
81
+ role: 'user',
82
+ content: 'Analyze the project and suggest a better solution to implement a feature-name',
83
+ },
84
+ {
85
+ role: 'assistant',
86
+ content: [
87
+ {
88
+ type: 'text',
89
+ data: {
90
+ text: "I'll scan the SCSS structure: global styles and mixins, theme files, and a couple of component styles. I'll also search for the custom Sass function usage and theming patterns.",
91
+ },
92
+ },
93
+ {
94
+ type: 'tool',
95
+ data: {
96
+ toolName: 'Reading',
97
+ status: 'success',
98
+ toolIcon,
99
+ expandable: true,
100
+ headerContent: toolHeaderContent,
101
+ },
102
+ },
103
+ {
104
+ type: 'text',
105
+ data: {
106
+ text: "Absolutely! Here are some suggestions for improving the SCSS structure: \n\n- Consider organizing global styles and mixins into separate directories for better modularity. \n- Group theme files and component styles to simplify maintenance. \n- Use consistent naming patterns for custom Sass functions and variables. \n- Leverage nesting carefully to avoid deeply nested selectors and improve readability. \n- Document theming patterns to ease onboarding for new contributors.\n\nLet me know if you'd like examples or more details on any point!",
107
+ },
108
+ },
109
+ ],
110
+ },
111
+ ] })) }) })),
112
+ decorators: defaultDecorators,
113
+ };
114
+ const ChartMessageView = ({ part }) => {
115
+ const { chartData, chartType } = part.data;
116
+ return (_jsxs("div", { style: {
117
+ padding: '16px',
118
+ border: '1px solid var(--g-color-line-generic)',
119
+ borderRadius: '8px',
120
+ backgroundColor: 'var(--g-color-base-float)',
121
+ }, children: [_jsxs("div", { style: { marginBottom: '8px', fontWeight: 'bold' }, children: ["Chart: ", chartType] }), _jsxs("div", { style: { fontSize: '12px', color: 'var(--g-color-text-secondary)' }, children: ["Labels: ", chartData.labels.join(', ')] }), _jsxs("div", { style: { fontSize: '12px', color: 'var(--g-color-text-secondary)' }, children: ["Datasets: ", chartData.datasets.length] })] }));
122
+ };
123
+ export const WithCustomMessageType = {
124
+ render: (args) => {
125
+ const customRegistry = createMessageRendererRegistry();
126
+ registerMessageRenderer(customRegistry, 'chart', {
127
+ component: ChartMessageView,
128
+ });
129
+ return (_jsx(ShowcaseItem, { title: "With Custom Message Type", children: _jsx(ContentWrapper, { width: "480px", children: _jsx(MessageList, Object.assign({}, args, { messages: [
130
+ {
131
+ id: 'user-1',
132
+ role: 'user',
133
+ timestamp: '2024-01-01T00:00:00Z',
134
+ content: 'Hi! Can you show me the sales statistics for the first months of the year?',
135
+ },
136
+ {
137
+ id: 'assistant-1',
138
+ role: 'assistant',
139
+ timestamp: '2024-01-01T00:00:02Z',
140
+ content: [
141
+ {
142
+ type: 'text',
143
+ data: {
144
+ text: 'Sure! Here is a bar chart showing sales statistics by month. As you can see, February had the highest sales.',
145
+ },
146
+ },
147
+ {
148
+ type: 'chart',
149
+ data: {
150
+ chartData: {
151
+ labels: ['January', 'February', 'March', 'April'],
152
+ datasets: [
153
+ {
154
+ label: 'Sales',
155
+ data: [12, 19, 3, 5],
156
+ color: '#0077ff',
157
+ },
158
+ ],
159
+ },
160
+ chartType: 'bar',
161
+ },
162
+ },
163
+ ],
164
+ },
165
+ ], messageRendererRegistry: customRegistry })) }) }));
166
+ },
167
+ decorators: defaultDecorators,
168
+ };