@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.
- package/LICENSE +21 -0
- package/README.md +190 -0
- package/dist/.storybook/theme.d.ts +6 -0
- package/dist/.storybook/theme.js +28 -0
- package/dist/package.json +111 -0
- package/dist/src/components/atoms/ActionButton/ActionButton.d.ts +47 -0
- package/dist/src/components/atoms/ActionButton/ActionButton.js +34 -0
- package/dist/src/components/atoms/ActionButton/__stories__/ActionButton.stories.d.ts +8 -0
- package/dist/src/components/atoms/ActionButton/__stories__/ActionButton.stories.js +48 -0
- package/dist/src/components/atoms/ActionButton/index.d.ts +2 -0
- package/dist/src/components/atoms/ActionButton/index.js +1 -0
- package/dist/src/components/atoms/Alert/__stories__/Alert.stories.d.ts +9 -0
- package/dist/src/components/atoms/Alert/__stories__/Alert.stories.js +56 -0
- package/dist/src/components/atoms/Alert/index.d.ts +13 -0
- package/dist/src/components/atoms/Alert/index.js +25 -0
- package/dist/src/components/atoms/ChatDate/ChatDate.d.ts +19 -0
- package/dist/src/components/atoms/ChatDate/ChatDate.js +24 -0
- package/dist/src/components/atoms/ChatDate/__stories__/ChatDate.stories.d.ts +16 -0
- package/dist/src/components/atoms/ChatDate/__stories__/ChatDate.stories.js +83 -0
- package/dist/src/components/atoms/ChatDate/i18n/en.json +8 -0
- package/dist/src/components/atoms/ChatDate/i18n/index.d.ts +13 -0
- package/dist/src/components/atoms/ChatDate/i18n/index.js +5 -0
- package/dist/src/components/atoms/ChatDate/i18n/ru.json +10 -0
- package/dist/src/components/atoms/ChatDate/index.d.ts +1 -0
- package/dist/src/components/atoms/ChatDate/index.js +1 -0
- package/dist/src/components/atoms/ContextIndicator/__stories__/ContextIndicator.stories.d.ts +17 -0
- package/dist/src/components/atoms/ContextIndicator/__stories__/ContextIndicator.stories.js +72 -0
- package/dist/src/components/atoms/ContextIndicator/index.d.ts +19 -0
- package/dist/src/components/atoms/ContextIndicator/index.js +16 -0
- package/dist/src/components/atoms/ContextIndicator/utils.d.ts +1 -0
- package/dist/src/components/atoms/ContextIndicator/utils.js +9 -0
- package/dist/src/components/atoms/ContextItem/__stories__/ContextItem.stories.d.ts +6 -0
- package/dist/src/components/atoms/ContextItem/__stories__/ContextItem.stories.js +32 -0
- package/dist/src/components/atoms/ContextItem/index.d.ts +9 -0
- package/dist/src/components/atoms/ContextItem/index.js +8 -0
- package/dist/src/components/atoms/DiffStat/__stories__/DiffStat.stories.d.ts +7 -0
- package/dist/src/components/atoms/DiffStat/__stories__/DiffStat.stories.js +45 -0
- package/dist/src/components/atoms/DiffStat/index.d.ts +8 -0
- package/dist/src/components/atoms/DiffStat/index.js +8 -0
- package/dist/src/components/atoms/Disclaimer/Disclaimer.d.ts +19 -0
- package/dist/src/components/atoms/Disclaimer/Disclaimer.js +15 -0
- package/dist/src/components/atoms/Disclaimer/__stories__/Disclaimer.stories.d.ts +8 -0
- package/dist/src/components/atoms/Disclaimer/__stories__/Disclaimer.stories.js +32 -0
- package/dist/src/components/atoms/Disclaimer/index.d.ts +1 -0
- package/dist/src/components/atoms/Disclaimer/index.js +1 -0
- package/dist/src/components/atoms/InlineCitation/index.d.ts +1 -0
- package/dist/src/components/atoms/InlineCitation/index.js +1 -0
- package/dist/src/components/atoms/Loader/Loader.d.ts +9 -0
- package/dist/src/components/atoms/Loader/Loader.js +11 -0
- package/dist/src/components/atoms/Loader/__stories__/Loader.stories.d.ts +8 -0
- package/dist/src/components/atoms/Loader/__stories__/Loader.stories.js +47 -0
- package/dist/src/components/atoms/Loader/index.d.ts +1 -0
- package/dist/src/components/atoms/Loader/index.js +1 -0
- package/dist/src/components/atoms/MarkdownRenderer/MarkdownRenderer.d.ts +10 -0
- package/dist/src/components/atoms/MarkdownRenderer/MarkdownRenderer.js +24 -0
- package/dist/src/components/atoms/MarkdownRenderer/__stories__/MarkdownRenderer.stories.d.ts +6 -0
- package/dist/src/components/atoms/MarkdownRenderer/__stories__/MarkdownRenderer.stories.js +49 -0
- package/dist/src/components/atoms/MarkdownRenderer/index.d.ts +1 -0
- package/dist/src/components/atoms/MarkdownRenderer/index.js +1 -0
- package/dist/src/components/atoms/MessageBalloon/__stories__/MessageBalloon.stories.d.ts +6 -0
- package/dist/src/components/atoms/MessageBalloon/__stories__/MessageBalloon.stories.js +32 -0
- package/dist/src/components/atoms/MessageBalloon/index.d.ts +7 -0
- package/dist/src/components/atoms/MessageBalloon/index.js +8 -0
- package/dist/src/components/atoms/Shimmer/__stories__/Shimmer.stories.d.ts +5 -0
- package/dist/src/components/atoms/Shimmer/__stories__/Shimmer.stories.js +28 -0
- package/dist/src/components/atoms/Shimmer/index.d.ts +6 -0
- package/dist/src/components/atoms/Shimmer/index.js +8 -0
- package/dist/src/components/atoms/SubmitButton/SubmitButton.d.ts +37 -0
- package/dist/src/components/atoms/SubmitButton/SubmitButton.js +33 -0
- package/dist/src/components/atoms/SubmitButton/__stories__/SubmitButton.stories.d.ts +12 -0
- package/dist/src/components/atoms/SubmitButton/__stories__/SubmitButton.stories.js +95 -0
- package/dist/src/components/atoms/SubmitButton/i18n/en.json +3 -0
- package/dist/src/components/atoms/SubmitButton/i18n/index.d.ts +13 -0
- package/dist/src/components/atoms/SubmitButton/i18n/index.js +5 -0
- package/dist/src/components/atoms/SubmitButton/i18n/ru.json +3 -0
- package/dist/src/components/atoms/SubmitButton/index.d.ts +1 -0
- package/dist/src/components/atoms/SubmitButton/index.js +1 -0
- package/dist/src/components/atoms/ToolIndicator/__stories__/ToolIndicator.stories.d.ts +9 -0
- package/dist/src/components/atoms/ToolIndicator/__stories__/ToolIndicator.stories.js +34 -0
- package/dist/src/components/atoms/ToolIndicator/index.d.ts +7 -0
- package/dist/src/components/atoms/ToolIndicator/index.js +26 -0
- package/dist/src/components/atoms/index.d.ts +14 -0
- package/dist/src/components/atoms/index.js +15 -0
- package/dist/src/components/index.d.ts +5 -0
- package/dist/src/components/index.js +6 -0
- package/dist/src/components/molecules/BaseMessage/__stories__/BaseMessage.stories.d.ts +8 -0
- package/dist/src/components/molecules/BaseMessage/__stories__/BaseMessage.stories.js +66 -0
- package/dist/src/components/molecules/BaseMessage/i18n/en.json +8 -0
- package/dist/src/components/molecules/BaseMessage/i18n/index.d.ts +13 -0
- package/dist/src/components/molecules/BaseMessage/i18n/index.js +5 -0
- package/dist/src/components/molecules/BaseMessage/i18n/ru.json +8 -0
- package/dist/src/components/molecules/BaseMessage/index.d.ts +11 -0
- package/dist/src/components/molecules/BaseMessage/index.js +48 -0
- package/dist/src/components/molecules/ButtonGroup/__stories__/ButtonGroup.stories.d.ts +6 -0
- package/dist/src/components/molecules/ButtonGroup/__stories__/ButtonGroup.stories.js +44 -0
- package/dist/src/components/molecules/ButtonGroup/index.d.ts +8 -0
- package/dist/src/components/molecules/ButtonGroup/index.js +8 -0
- package/dist/src/components/molecules/InputContext/index.d.ts +1 -0
- package/dist/src/components/molecules/InputContext/index.js +1 -0
- package/dist/src/components/molecules/PromptInputBody/PromptInputBody.d.ts +39 -0
- package/dist/src/components/molecules/PromptInputBody/PromptInputBody.js +26 -0
- package/dist/src/components/molecules/PromptInputBody/__stories__/PromptInputBody.stories.d.ts +11 -0
- package/dist/src/components/molecules/PromptInputBody/__stories__/PromptInputBody.stories.js +62 -0
- package/dist/src/components/molecules/PromptInputBody/index.d.ts +1 -0
- package/dist/src/components/molecules/PromptInputBody/index.js +1 -0
- package/dist/src/components/molecules/PromptInputFooter/PromptInputFooter.d.ts +39 -0
- package/dist/src/components/molecules/PromptInputFooter/PromptInputFooter.js +26 -0
- package/dist/src/components/molecules/PromptInputFooter/__stories__/PromptInputFooter.stories.d.ts +11 -0
- package/dist/src/components/molecules/PromptInputFooter/__stories__/PromptInputFooter.stories.js +96 -0
- package/dist/src/components/molecules/PromptInputFooter/i18n/en.json +5 -0
- package/dist/src/components/molecules/PromptInputFooter/i18n/index.d.ts +13 -0
- package/dist/src/components/molecules/PromptInputFooter/i18n/index.js +5 -0
- package/dist/src/components/molecules/PromptInputFooter/i18n/ru.json +5 -0
- package/dist/src/components/molecules/PromptInputFooter/index.d.ts +1 -0
- package/dist/src/components/molecules/PromptInputFooter/index.js +1 -0
- package/dist/src/components/molecules/PromptInputHeader/PromptInputHeader.d.ts +39 -0
- package/dist/src/components/molecules/PromptInputHeader/PromptInputHeader.js +28 -0
- package/dist/src/components/molecules/PromptInputHeader/__stories__/PromptInputHeader.stories.d.ts +13 -0
- package/dist/src/components/molecules/PromptInputHeader/__stories__/PromptInputHeader.stories.js +103 -0
- package/dist/src/components/molecules/PromptInputHeader/index.d.ts +1 -0
- package/dist/src/components/molecules/PromptInputHeader/index.js +1 -0
- package/dist/src/components/molecules/PromptInputPanel/PromptInputPanel.d.ts +20 -0
- package/dist/src/components/molecules/PromptInputPanel/PromptInputPanel.js +14 -0
- package/dist/src/components/molecules/PromptInputPanel/__stories__/PromptInputPanel.stories.d.ts +8 -0
- package/dist/src/components/molecules/PromptInputPanel/__stories__/PromptInputPanel.stories.js +38 -0
- package/dist/src/components/molecules/PromptInputPanel/index.d.ts +2 -0
- package/dist/src/components/molecules/PromptInputPanel/index.js +1 -0
- package/dist/src/components/molecules/Suggestions/Suggestions.d.ts +37 -0
- package/dist/src/components/molecules/Suggestions/Suggestions.js +27 -0
- package/dist/src/components/molecules/Suggestions/__stories__/Suggestions.stories.d.ts +19 -0
- package/dist/src/components/molecules/Suggestions/__stories__/Suggestions.stories.js +143 -0
- package/dist/src/components/molecules/Suggestions/index.d.ts +1 -0
- package/dist/src/components/molecules/Suggestions/index.js +1 -0
- package/dist/src/components/molecules/Tabs/Tabs.d.ts +15 -0
- package/dist/src/components/molecules/Tabs/Tabs.js +24 -0
- package/dist/src/components/molecules/Tabs/__stories__/Tabs.stories.d.ts +9 -0
- package/dist/src/components/molecules/Tabs/__stories__/Tabs.stories.js +103 -0
- package/dist/src/components/molecules/Tabs/i18n/en.json +3 -0
- package/dist/src/components/molecules/Tabs/i18n/index.d.ts +13 -0
- package/dist/src/components/molecules/Tabs/i18n/index.js +5 -0
- package/dist/src/components/molecules/Tabs/i18n/ru.json +3 -0
- package/dist/src/components/molecules/Tabs/index.d.ts +1 -0
- package/dist/src/components/molecules/Tabs/index.js +1 -0
- package/dist/src/components/molecules/ToolFooter/__stories__/ToolFooter.stories.d.ts +7 -0
- package/dist/src/components/molecules/ToolFooter/__stories__/ToolFooter.stories.js +58 -0
- package/dist/src/components/molecules/ToolFooter/index.d.ts +3 -0
- package/dist/src/components/molecules/ToolFooter/index.js +10 -0
- package/dist/src/components/molecules/ToolHeader/__stories__/ToolHeader.stories.d.ts +7 -0
- package/dist/src/components/molecules/ToolHeader/__stories__/ToolHeader.stories.js +55 -0
- package/dist/src/components/molecules/ToolHeader/index.d.ts +3 -0
- package/dist/src/components/molecules/ToolHeader/index.js +19 -0
- package/dist/src/components/molecules/index.d.ts +11 -0
- package/dist/src/components/molecules/index.js +12 -0
- package/dist/src/components/organisms/AssistantMessage/AssistantMessage.d.ts +14 -0
- package/dist/src/components/organisms/AssistantMessage/AssistantMessage.js +31 -0
- package/dist/src/components/organisms/AssistantMessage/__stories__/AssistantMessage.stories.d.ts +13 -0
- package/dist/src/components/organisms/AssistantMessage/__stories__/AssistantMessage.stories.js +151 -0
- package/dist/src/components/organisms/AssistantMessage/defaultMessageTypeRegistry.d.ts +3 -0
- package/dist/src/components/organisms/AssistantMessage/defaultMessageTypeRegistry.js +18 -0
- package/dist/src/components/organisms/AssistantMessage/index.d.ts +1 -0
- package/dist/src/components/organisms/AssistantMessage/index.js +1 -0
- package/dist/src/components/organisms/Header/Header.d.ts +9 -0
- package/dist/src/components/organisms/Header/Header.js +65 -0
- package/dist/src/components/organisms/Header/__stories__/Header.stories.d.ts +13 -0
- package/dist/src/components/organisms/Header/__stories__/Header.stories.js +130 -0
- package/dist/src/components/organisms/Header/i18n/en.json +7 -0
- package/dist/src/components/organisms/Header/i18n/index.d.ts +13 -0
- package/dist/src/components/organisms/Header/i18n/index.js +5 -0
- package/dist/src/components/organisms/Header/i18n/ru.json +7 -0
- package/dist/src/components/organisms/Header/index.d.ts +4 -0
- package/dist/src/components/organisms/Header/index.js +6 -0
- package/dist/src/components/organisms/Header/types.d.ts +23 -0
- package/dist/src/components/organisms/Header/types.js +7 -0
- package/dist/src/components/organisms/Header/useHeader.d.ts +21 -0
- package/dist/src/components/organisms/Header/useHeader.js +71 -0
- package/dist/src/components/organisms/MessageList/ErrorAlert.d.ts +6 -0
- package/dist/src/components/organisms/MessageList/ErrorAlert.js +15 -0
- package/dist/src/components/organisms/MessageList/MessageList.d.ts +20 -0
- package/dist/src/components/organisms/MessageList/MessageList.js +21 -0
- package/dist/src/components/organisms/MessageList/__stories__/MessageList.stories.d.ts +22 -0
- package/dist/src/components/organisms/MessageList/__stories__/MessageList.stories.js +168 -0
- package/dist/src/components/organisms/MessageList/i18n/en.json +4 -0
- package/dist/src/components/organisms/MessageList/i18n/index.d.ts +13 -0
- package/dist/src/components/organisms/MessageList/i18n/index.js +5 -0
- package/dist/src/components/organisms/MessageList/i18n/ru.json +4 -0
- package/dist/src/components/organisms/MessageList/index.d.ts +1 -0
- package/dist/src/components/organisms/MessageList/index.js +1 -0
- package/dist/src/components/organisms/PromptInput/PromptInput.d.ts +44 -0
- package/dist/src/components/organisms/PromptInput/PromptInput.js +38 -0
- package/dist/src/components/organisms/PromptInput/PromptInputFull.d.ts +26 -0
- package/dist/src/components/organisms/PromptInput/PromptInputFull.js +25 -0
- package/dist/src/components/organisms/PromptInput/PromptInputSimple.d.ts +24 -0
- package/dist/src/components/organisms/PromptInput/PromptInputSimple.js +21 -0
- package/dist/src/components/organisms/PromptInput/PromptInputWithPanels.d.ts +24 -0
- package/dist/src/components/organisms/PromptInput/PromptInputWithPanels.js +19 -0
- package/dist/src/components/organisms/PromptInput/PromptInputWithSuggestions.d.ts +22 -0
- package/dist/src/components/organisms/PromptInput/PromptInputWithSuggestions.js +16 -0
- package/dist/src/components/organisms/PromptInput/__stories__/PromptInput.stories.d.ts +18 -0
- package/dist/src/components/organisms/PromptInput/__stories__/PromptInput.stories.js +278 -0
- package/dist/src/components/organisms/PromptInput/index.d.ts +8 -0
- package/dist/src/components/organisms/PromptInput/index.js +7 -0
- package/dist/src/components/organisms/PromptInput/types.d.ts +72 -0
- package/dist/src/components/organisms/PromptInput/types.js +1 -0
- package/dist/src/components/organisms/PromptInput/useDelayedUnmount.d.ts +8 -0
- package/dist/src/components/organisms/PromptInput/useDelayedUnmount.js +26 -0
- package/dist/src/components/organisms/PromptInput/usePromptInput.d.ts +52 -0
- package/dist/src/components/organisms/PromptInput/usePromptInput.js +102 -0
- package/dist/src/components/organisms/ThinkingMessage/__stories__/ThinkingMessage.stories.d.ts +12 -0
- package/dist/src/components/organisms/ThinkingMessage/__stories__/ThinkingMessage.stories.js +107 -0
- package/dist/src/components/organisms/ThinkingMessage/i18n/en.json +4 -0
- package/dist/src/components/organisms/ThinkingMessage/i18n/index.d.ts +13 -0
- package/dist/src/components/organisms/ThinkingMessage/i18n/index.js +5 -0
- package/dist/src/components/organisms/ThinkingMessage/i18n/ru.json +4 -0
- package/dist/src/components/organisms/ThinkingMessage/index.d.ts +24 -0
- package/dist/src/components/organisms/ThinkingMessage/index.js +34 -0
- package/dist/src/components/organisms/ThinkingMessage/useThinkingMessage.d.ts +18 -0
- package/dist/src/components/organisms/ThinkingMessage/useThinkingMessage.js +23 -0
- package/dist/src/components/organisms/ToolMessage/__stories__/ToolMessage.stories.d.ts +11 -0
- package/dist/src/components/organisms/ToolMessage/__stories__/ToolMessage.stories.js +70 -0
- package/dist/src/components/organisms/ToolMessage/i18n/en.json +9 -0
- package/dist/src/components/organisms/ToolMessage/i18n/index.d.ts +13 -0
- package/dist/src/components/organisms/ToolMessage/i18n/index.js +5 -0
- package/dist/src/components/organisms/ToolMessage/i18n/ru.json +9 -0
- package/dist/src/components/organisms/ToolMessage/index.d.ts +3 -0
- package/dist/src/components/organisms/ToolMessage/index.js +12 -0
- package/dist/src/components/organisms/UserMessage/__stories__/UserMessage.stories.d.ts +7 -0
- package/dist/src/components/organisms/UserMessage/__stories__/UserMessage.stories.js +70 -0
- package/dist/src/components/organisms/UserMessage/index.d.ts +13 -0
- package/dist/src/components/organisms/UserMessage/index.js +12 -0
- package/dist/src/components/organisms/index.d.ts +7 -0
- package/dist/src/components/organisms/index.js +8 -0
- package/dist/src/components/pages/ChatContainer/ChatContainer.d.ts +10 -0
- package/dist/src/components/pages/ChatContainer/ChatContainer.js +110 -0
- package/dist/src/components/pages/ChatContainer/__stories__/ChatContainer.stories.d.ts +53 -0
- package/dist/src/components/pages/ChatContainer/__stories__/ChatContainer.stories.js +707 -0
- package/dist/src/components/pages/ChatContainer/i18n/en.json +10 -0
- package/dist/src/components/pages/ChatContainer/i18n/index.d.ts +13 -0
- package/dist/src/components/pages/ChatContainer/i18n/index.js +5 -0
- package/dist/src/components/pages/ChatContainer/i18n/ru.json +10 -0
- package/dist/src/components/pages/ChatContainer/index.d.ts +2 -0
- package/dist/src/components/pages/ChatContainer/index.js +1 -0
- package/dist/src/components/pages/ChatContainer/types.d.ts +143 -0
- package/dist/src/components/pages/ChatContainer/types.js +1 -0
- package/dist/src/components/pages/ChatContainer/useChatContainer.d.ts +20 -0
- package/dist/src/components/pages/ChatContainer/useChatContainer.js +77 -0
- package/dist/src/components/pages/index.d.ts +1 -0
- package/dist/src/components/pages/index.js +2 -0
- package/dist/src/components/templates/ChatContent/ChatContent.d.ts +29 -0
- package/dist/src/components/templates/ChatContent/ChatContent.js +19 -0
- package/dist/src/components/templates/ChatContent/__stories__/ChatContent.stories.d.ts +14 -0
- package/dist/src/components/templates/ChatContent/__stories__/ChatContent.stories.js +315 -0
- package/dist/src/components/templates/ChatContent/index.d.ts +1 -0
- package/dist/src/components/templates/ChatContent/index.js +1 -0
- package/dist/src/components/templates/EmptyContainer/EmptyContainer.d.ts +57 -0
- package/dist/src/components/templates/EmptyContainer/EmptyContainer.js +26 -0
- package/dist/src/components/templates/EmptyContainer/__stories__/EmptyContainer.stories.d.ts +20 -0
- package/dist/src/components/templates/EmptyContainer/__stories__/EmptyContainer.stories.js +250 -0
- package/dist/src/components/templates/EmptyContainer/i18n/en.json +3 -0
- package/dist/src/components/templates/EmptyContainer/i18n/index.d.ts +13 -0
- package/dist/src/components/templates/EmptyContainer/i18n/index.js +5 -0
- package/dist/src/components/templates/EmptyContainer/i18n/ru.json +3 -0
- package/dist/src/components/templates/EmptyContainer/index.d.ts +1 -0
- package/dist/src/components/templates/EmptyContainer/index.js +1 -0
- package/dist/src/components/templates/History/ChatItem.d.ts +17 -0
- package/dist/src/components/templates/History/ChatItem.js +18 -0
- package/dist/src/components/templates/History/DateHeaderItem.d.ts +12 -0
- package/dist/src/components/templates/History/DateHeaderItem.js +12 -0
- package/dist/src/components/templates/History/History.d.ts +46 -0
- package/dist/src/components/templates/History/History.js +16 -0
- package/dist/src/components/templates/History/HistoryList.d.ts +43 -0
- package/dist/src/components/templates/History/HistoryList.js +87 -0
- package/dist/src/components/templates/History/__stories__/History.stories.d.ts +17 -0
- package/dist/src/components/templates/History/__stories__/History.stories.js +281 -0
- package/dist/src/components/templates/History/i18n/en.json +7 -0
- package/dist/src/components/templates/History/i18n/index.d.ts +13 -0
- package/dist/src/components/templates/History/i18n/index.js +5 -0
- package/dist/src/components/templates/History/i18n/ru.json +7 -0
- package/dist/src/components/templates/History/index.d.ts +8 -0
- package/dist/src/components/templates/History/index.js +4 -0
- package/dist/src/components/templates/index.d.ts +3 -0
- package/dist/src/components/templates/index.js +4 -0
- package/dist/src/constants/index.d.ts +1 -0
- package/dist/src/constants/index.js +1 -0
- package/dist/src/demo/ContentWrapper/ContentWrapper.d.ts +7 -0
- package/dist/src/demo/ContentWrapper/ContentWrapper.js +7 -0
- package/dist/src/demo/ContentWrapper/index.d.ts +1 -0
- package/dist/src/demo/ContentWrapper/index.js +1 -0
- package/dist/src/demo/DocsDecorator/DocsDecorator.d.ts +6 -0
- package/dist/src/demo/DocsDecorator/DocsDecorator.js +12 -0
- package/dist/src/demo/DocsDecorator/ThemeContext.d.ts +2 -0
- package/dist/src/demo/DocsDecorator/ThemeContext.js +2 -0
- package/dist/src/demo/Showcase/Showcase.d.ts +9 -0
- package/dist/src/demo/Showcase/Showcase.js +7 -0
- package/dist/src/demo/Showcase/index.d.ts +1 -0
- package/dist/src/demo/Showcase/index.js +1 -0
- package/dist/src/demo/ShowcaseItem/ShowcaseItem.d.ts +7 -0
- package/dist/src/demo/ShowcaseItem/ShowcaseItem.js +7 -0
- package/dist/src/demo/ShowcaseItem/index.d.ts +1 -0
- package/dist/src/demo/ShowcaseItem/index.js +1 -0
- package/dist/src/demo/SwapArea/SwapArea.d.ts +2 -0
- package/dist/src/demo/SwapArea/SwapArea.js +7 -0
- package/dist/src/demo/SwapArea/index.d.ts +1 -0
- package/dist/src/demo/SwapArea/index.js +1 -0
- package/dist/src/hooks/index.d.ts +2 -0
- package/dist/src/hooks/index.js +2 -0
- package/dist/src/hooks/useDateFormatter/index.d.ts +34 -0
- package/dist/src/hooks/useDateFormatter/index.js +101 -0
- package/dist/src/hooks/useToolMessage.d.ts +11 -0
- package/dist/src/hooks/useToolMessage.js +96 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +19 -0
- package/dist/src/types/chat.d.ts +17 -0
- package/dist/src/types/chat.js +1 -0
- package/dist/src/types/common.d.ts +7 -0
- package/dist/src/types/common.js +1 -0
- package/dist/src/types/index.d.ts +4 -0
- package/dist/src/types/index.js +4 -0
- package/dist/src/types/messages.d.ts +62 -0
- package/dist/src/types/messages.js +1 -0
- package/dist/src/types/tool.d.ts +34 -0
- package/dist/src/types/tool.js +1 -0
- package/dist/src/utils/chatUtils.d.ts +23 -0
- package/dist/src/utils/chatUtils.js +43 -0
- package/dist/src/utils/cn.d.ts +11 -0
- package/dist/src/utils/cn.js +12 -0
- package/dist/src/utils/index.d.ts +4 -0
- package/dist/src/utils/index.js +5 -0
- package/dist/src/utils/messageTypeRegistry.d.ts +13 -0
- package/dist/src/utils/messageTypeRegistry.js +16 -0
- package/dist/src/utils/messageUtils.d.ts +4 -0
- package/dist/src/utils/messageUtils.js +25 -0
- package/dist/src/utils/validation.d.ts +16 -0
- package/dist/src/utils/validation.js +24 -0
- 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,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,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,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,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
|
+
};
|