@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,103 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { At, Envelope, Gear } from '@gravity-ui/icons';
|
|
3
|
+
import { Icon } from '@gravity-ui/uikit';
|
|
4
|
+
import { Tabs } from '..';
|
|
5
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
6
|
+
import { Showcase } from '../../../../demo/Showcase';
|
|
7
|
+
import { ShowcaseItem } from '../../../../demo/ShowcaseItem';
|
|
8
|
+
import MDXDocs from './Docs.mdx';
|
|
9
|
+
export default {
|
|
10
|
+
title: 'molecules/Tabs',
|
|
11
|
+
component: Tabs,
|
|
12
|
+
parameters: {
|
|
13
|
+
docs: {
|
|
14
|
+
page: MDXDocs,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
argTypes: {
|
|
18
|
+
items: {
|
|
19
|
+
control: 'object',
|
|
20
|
+
description: 'Array of tab items',
|
|
21
|
+
},
|
|
22
|
+
activeId: {
|
|
23
|
+
control: 'text',
|
|
24
|
+
description: 'ID of the currently active tab',
|
|
25
|
+
},
|
|
26
|
+
allowDelete: {
|
|
27
|
+
control: 'boolean',
|
|
28
|
+
description: 'Whether to show delete buttons',
|
|
29
|
+
},
|
|
30
|
+
className: {
|
|
31
|
+
control: 'text',
|
|
32
|
+
description: 'Additional CSS class',
|
|
33
|
+
},
|
|
34
|
+
styles: {
|
|
35
|
+
control: 'object',
|
|
36
|
+
description: 'Additional CSS properties',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const defaultDecorators = [
|
|
41
|
+
(Story) => (_jsx(ContentWrapper, { children: _jsx(Showcase, { children: _jsx(Story, {}) }) })),
|
|
42
|
+
];
|
|
43
|
+
const basicItems = [
|
|
44
|
+
{ id: '1', title: 'Chat name 1' },
|
|
45
|
+
{ id: '2', title: 'Chat name 2' },
|
|
46
|
+
{ id: '3', title: 'Chat name 3' },
|
|
47
|
+
{ id: '4', title: 'Chat name 4' },
|
|
48
|
+
];
|
|
49
|
+
const itemsWithIcons = [
|
|
50
|
+
{ id: '1', title: 'Chat name 1', icon: _jsx(Icon, { data: At, size: 16 }) },
|
|
51
|
+
{ id: '2', title: 'Chat name 2', icon: _jsx(Icon, { data: Envelope, size: 16 }) },
|
|
52
|
+
{ id: '3', title: 'Chat name 3', icon: _jsx(Icon, { data: Gear, size: 16 }) },
|
|
53
|
+
];
|
|
54
|
+
export const Playground = (args) => (_jsx(ContentWrapper, { children: _jsx(Tabs, Object.assign({}, args)) }));
|
|
55
|
+
Playground.args = {
|
|
56
|
+
items: basicItems,
|
|
57
|
+
activeId: '1',
|
|
58
|
+
allowDelete: true,
|
|
59
|
+
};
|
|
60
|
+
export const Basic = {
|
|
61
|
+
render: (args) => (_jsx(ShowcaseItem, { title: "Basic Tabs", children: _jsx(Tabs, Object.assign({}, args)) })),
|
|
62
|
+
decorators: defaultDecorators,
|
|
63
|
+
};
|
|
64
|
+
Basic.args = {
|
|
65
|
+
items: basicItems,
|
|
66
|
+
activeId: '1',
|
|
67
|
+
allowDelete: true,
|
|
68
|
+
};
|
|
69
|
+
export const WithIcons = {
|
|
70
|
+
render: (args) => (_jsx(ShowcaseItem, { title: "Tabs with Icons", children: _jsx(Tabs, Object.assign({}, args)) })),
|
|
71
|
+
decorators: defaultDecorators,
|
|
72
|
+
};
|
|
73
|
+
WithIcons.args = {
|
|
74
|
+
items: itemsWithIcons,
|
|
75
|
+
activeId: '1',
|
|
76
|
+
allowDelete: true,
|
|
77
|
+
};
|
|
78
|
+
export const WithStyle = {
|
|
79
|
+
render: (args) => (_jsx(ShowcaseItem, { title: "Tabs with Style", children: _jsx(Tabs, Object.assign({}, args)) })),
|
|
80
|
+
decorators: defaultDecorators,
|
|
81
|
+
};
|
|
82
|
+
WithStyle.args = {
|
|
83
|
+
items: basicItems,
|
|
84
|
+
activeId: '1',
|
|
85
|
+
allowDelete: true,
|
|
86
|
+
style: {
|
|
87
|
+
'--g-color-base-info-light': '#ff9100',
|
|
88
|
+
'--g-color-base-info-light-hover': '#aa9100',
|
|
89
|
+
'--g-color-text-info-heavy': '#ffffff',
|
|
90
|
+
'--g-color-base-simple-hover': '#aa9100',
|
|
91
|
+
'--g-color-text-complementary': '#ff9100',
|
|
92
|
+
'--g-color-line-generic': '#ff9100',
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
export const MaxWidth = {
|
|
96
|
+
render: (args) => (_jsx(ShowcaseItem, { title: "Max width (200px)", children: _jsxs("div", { style: { maxWidth: '200px', border: '1px solid lightgray' }, children: [_jsx("h1", { style: { paddingInline: '10px' }, children: "Lorem ipsum" }), _jsx(Tabs, Object.assign({}, args)), _jsx("p", { style: { paddingInline: '10px' }, children: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Optio consectetur commodi natus dolor repellendus sit, similique aliquam, quia ad hic quam porro nobis a? Cumque ratione est nostrum exercitationem velit." })] }) })),
|
|
97
|
+
decorators: defaultDecorators,
|
|
98
|
+
};
|
|
99
|
+
MaxWidth.args = {
|
|
100
|
+
items: basicItems,
|
|
101
|
+
activeId: '1',
|
|
102
|
+
allowDelete: true,
|
|
103
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const i18n: ((key: "close-tooltip", params?: import("@gravity-ui/i18n").Params) => string) & {
|
|
2
|
+
Translation: import("react").ComponentType<{
|
|
3
|
+
children: (props: {
|
|
4
|
+
t: (key: "close-tooltip", params?: import("@gravity-ui/i18n").Params) => string;
|
|
5
|
+
}) => React.ReactNode;
|
|
6
|
+
}>;
|
|
7
|
+
useTranslation: () => {
|
|
8
|
+
t: (key: "close-tooltip", params?: import("@gravity-ui/i18n").Params) => string;
|
|
9
|
+
};
|
|
10
|
+
keysetData: {
|
|
11
|
+
"g-aikit-Tabs": Record<"close-tooltip", import("@gravity-ui/i18n").KeyData>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tabs, type TabsProps } from './Tabs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tabs } from './Tabs';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { ToolFooterProps } from 'src/types';
|
|
3
|
+
declare const _default: Meta;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Playground: StoryFn<ToolFooterProps>;
|
|
6
|
+
export declare const ConfirmationState: StoryObj<ToolFooterProps>;
|
|
7
|
+
export declare const WaitingState: StoryObj<ToolFooterProps>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ToolFooter } from '..';
|
|
3
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
4
|
+
import { Showcase } from '../../../../demo/Showcase';
|
|
5
|
+
import { ShowcaseItem } from '../../../../demo/ShowcaseItem';
|
|
6
|
+
import MDXDocs from './Docs.mdx';
|
|
7
|
+
export default {
|
|
8
|
+
title: 'molecules/ToolFooter',
|
|
9
|
+
component: ToolFooter,
|
|
10
|
+
parameters: {
|
|
11
|
+
docs: {
|
|
12
|
+
page: MDXDocs,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
argTypes: {
|
|
16
|
+
content: {
|
|
17
|
+
control: 'text',
|
|
18
|
+
description: 'Status message to display',
|
|
19
|
+
},
|
|
20
|
+
showLoader: {
|
|
21
|
+
control: 'boolean',
|
|
22
|
+
description: 'Whether to show loading indicator',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const defaultDecorators = [
|
|
27
|
+
(Story) => (_jsx(Showcase, { children: _jsx(Story, {}) })),
|
|
28
|
+
];
|
|
29
|
+
const rejectAction = {
|
|
30
|
+
label: 'Reject',
|
|
31
|
+
onClick: () => alert('Rejected'),
|
|
32
|
+
view: 'outlined',
|
|
33
|
+
};
|
|
34
|
+
const acceptAction = {
|
|
35
|
+
label: 'Accept',
|
|
36
|
+
onClick: () => alert('Accepted'),
|
|
37
|
+
view: 'action',
|
|
38
|
+
};
|
|
39
|
+
const cancelAction = {
|
|
40
|
+
label: 'Cancel',
|
|
41
|
+
onClick: () => alert('Cancelled'),
|
|
42
|
+
view: 'outlined',
|
|
43
|
+
};
|
|
44
|
+
const defaultActions = [rejectAction, acceptAction];
|
|
45
|
+
export const Playground = (args) => (_jsx(ContentWrapper, { width: "430px", children: _jsx(ToolFooter, Object.assign({}, args)) }));
|
|
46
|
+
Playground.args = {
|
|
47
|
+
content: 'Awaiting confirmation',
|
|
48
|
+
actions: defaultActions,
|
|
49
|
+
showLoader: true,
|
|
50
|
+
};
|
|
51
|
+
export const ConfirmationState = {
|
|
52
|
+
render: (args) => (_jsx(ShowcaseItem, { title: "Confirmation State", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolFooter, Object.assign({}, args, { content: "Awaiting confirmation", actions: defaultActions })) }) })),
|
|
53
|
+
decorators: defaultDecorators,
|
|
54
|
+
};
|
|
55
|
+
export const WaitingState = {
|
|
56
|
+
render: (args) => (_jsx(ShowcaseItem, { title: "Waiting State", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolFooter, Object.assign({}, args, { content: "Awaiting form submission", actions: [cancelAction] })) }) })),
|
|
57
|
+
decorators: defaultDecorators,
|
|
58
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Text } from '@gravity-ui/uikit';
|
|
3
|
+
import { block } from '../../../utils/cn';
|
|
4
|
+
import { Loader, Shimmer } from '../../atoms';
|
|
5
|
+
import { ButtonGroup } from '../ButtonGroup';
|
|
6
|
+
import './ToolFooter.scss';
|
|
7
|
+
const b = block('tool-footer');
|
|
8
|
+
export function ToolFooter({ actions, content, showLoader = true, className, qa }) {
|
|
9
|
+
return (_jsxs("div", { className: b('', className), "data-qa": qa, children: [_jsxs("div", { className: b('left'), children: [showLoader && _jsx(Loader, { view: "loading", size: "xs" }), content && (_jsx(Shimmer, { children: _jsx(Text, { children: content }) }))] }), _jsx(ButtonGroup, { children: actions.map((action, index) => (_jsx(Button, { view: action.view, onClick: action.onClick, size: "s", children: action.label }, index))) })] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import type { ToolHeaderProps } from '../../../../types/tool';
|
|
3
|
+
declare const _default: Meta;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Playground: StoryFn<ToolHeaderProps>;
|
|
6
|
+
export declare const Loading: StoryObj<ToolHeaderProps>;
|
|
7
|
+
export declare const Success: StoryObj<ToolHeaderProps>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDown, Copy, Pencil } from '@gravity-ui/icons';
|
|
3
|
+
import { Icon, Text } from '@gravity-ui/uikit';
|
|
4
|
+
import { ToolHeader } from '..';
|
|
5
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
6
|
+
import { Showcase } from '../../../../demo/Showcase';
|
|
7
|
+
import MDXDocs from './Docs.mdx';
|
|
8
|
+
export default {
|
|
9
|
+
title: 'molecules/ToolHeader',
|
|
10
|
+
component: ToolHeader,
|
|
11
|
+
parameters: {
|
|
12
|
+
docs: {
|
|
13
|
+
page: MDXDocs,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
argTypes: {
|
|
17
|
+
toolName: {
|
|
18
|
+
control: 'text',
|
|
19
|
+
description: 'Name of the tool',
|
|
20
|
+
},
|
|
21
|
+
status: {
|
|
22
|
+
control: 'select',
|
|
23
|
+
options: ['success', 'error', 'loading'],
|
|
24
|
+
description: 'Status indicator',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const defaultDecorators = [
|
|
29
|
+
(Story) => (_jsx(Showcase, { children: _jsx(Story, {}) })),
|
|
30
|
+
];
|
|
31
|
+
const copyAction = {
|
|
32
|
+
label: 'Copy',
|
|
33
|
+
onClick: () => alert('Copied'),
|
|
34
|
+
icon: _jsx(Icon, { data: Copy, size: 16 }),
|
|
35
|
+
};
|
|
36
|
+
const collapseAction = {
|
|
37
|
+
label: 'Collapse',
|
|
38
|
+
onClick: () => alert('Collapsed'),
|
|
39
|
+
icon: _jsx(Icon, { data: ChevronDown, size: 16 }),
|
|
40
|
+
};
|
|
41
|
+
export const Playground = (args) => (_jsx(ContentWrapper, { width: "430px", children: _jsx(ToolHeader, Object.assign({}, args)) }));
|
|
42
|
+
Playground.args = {
|
|
43
|
+
toolIcon: _jsx(Icon, { data: Pencil, size: 16 }),
|
|
44
|
+
toolName: 'Writing',
|
|
45
|
+
content: (_jsx(Text, { color: "secondary", variant: "body-1", children: "expectScreenshotFixture.ts" })),
|
|
46
|
+
status: 'success',
|
|
47
|
+
};
|
|
48
|
+
export const Loading = {
|
|
49
|
+
render: (args) => (_jsx(ContentWrapper, { width: "430px", children: _jsx(ToolHeader, Object.assign({}, args, { toolIcon: _jsx(Icon, { data: Pencil, size: 16 }), toolName: "Writing", content: _jsx(Text, { color: "secondary", variant: "body-1", children: "expectScreenshotFixture.ts" }), status: "loading" })) })),
|
|
50
|
+
decorators: defaultDecorators,
|
|
51
|
+
};
|
|
52
|
+
export const Success = {
|
|
53
|
+
render: (args) => (_jsx(ContentWrapper, { width: "430px", children: _jsx(ToolHeader, Object.assign({}, args, { toolIcon: _jsx(Icon, { data: Pencil, size: 16 }), toolName: "Writing", content: _jsx(Text, { color: "secondary", variant: "body-1", children: "expectScreenshotFixture.ts" }), actions: [collapseAction, copyAction], status: "success" })) })),
|
|
54
|
+
decorators: defaultDecorators,
|
|
55
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from '@gravity-ui/uikit';
|
|
3
|
+
import { block } from '../../../utils/cn';
|
|
4
|
+
import { ActionButton, ToolIndicator } from '../../atoms';
|
|
5
|
+
import { ButtonGroup } from '../ButtonGroup';
|
|
6
|
+
import './ToolHeader.scss';
|
|
7
|
+
const b = block('tool-header');
|
|
8
|
+
function getIndicatorStatus(status) {
|
|
9
|
+
if (status === 'success' || status === 'error' || status === 'loading') {
|
|
10
|
+
return status;
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
export function ToolHeader(props) {
|
|
15
|
+
const { toolIcon, toolName, content, actions, status, className, qa } = props;
|
|
16
|
+
const hasActions = actions && actions.length > 0;
|
|
17
|
+
const indicatorStatus = getIndicatorStatus(status);
|
|
18
|
+
return (_jsxs("div", { className: b('', className), "data-qa": qa, children: [_jsxs("div", { className: b('left'), children: [toolIcon, _jsx(Text, { children: toolName }), content] }), _jsxs("div", { className: b('right'), children: [hasActions && (_jsx(ButtonGroup, { children: actions.map((action, index) => (_jsx(ActionButton, Object.assign({ tooltipTitle: action.label, view: "flat-secondary", size: "s" }, action, { children: action.icon }), index))) })), indicatorStatus && _jsx(ToolIndicator, { status: indicatorStatus })] })] }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './BaseMessage';
|
|
2
|
+
export * from './ButtonGroup';
|
|
3
|
+
export * from './InputContext';
|
|
4
|
+
export * from './PromptInputBody';
|
|
5
|
+
export * from './PromptInputFooter';
|
|
6
|
+
export * from './PromptInputHeader';
|
|
7
|
+
export * from './PromptInputPanel';
|
|
8
|
+
export * from './Suggestions';
|
|
9
|
+
export * from './Tabs';
|
|
10
|
+
export * from './ToolFooter';
|
|
11
|
+
export * from './ToolHeader';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Export all molecules
|
|
2
|
+
export * from './BaseMessage';
|
|
3
|
+
export * from './ButtonGroup';
|
|
4
|
+
export * from './InputContext';
|
|
5
|
+
export * from './PromptInputBody';
|
|
6
|
+
export * from './PromptInputFooter';
|
|
7
|
+
export * from './PromptInputHeader';
|
|
8
|
+
export * from './PromptInputPanel';
|
|
9
|
+
export * from './Suggestions';
|
|
10
|
+
export * from './Tabs';
|
|
11
|
+
export * from './ToolFooter';
|
|
12
|
+
export * from './ToolHeader';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { OptionsType } from '@diplodoc/transform/lib/typings';
|
|
2
|
+
import type { BaseMessageProps, TAssistantMessage, TMessageContent, TMessageMetadata } from '../../../types/messages';
|
|
3
|
+
import { type MessageRendererRegistry } from '../../../utils/messageTypeRegistry';
|
|
4
|
+
import './AssistantMessage.scss';
|
|
5
|
+
type BaseMessagePick = Pick<BaseMessageProps, 'actions' | 'timestamp' | 'showActionsOnHover' | 'showTimestamp'>;
|
|
6
|
+
type AssistantMessagePick<TContent extends TMessageContent> = Pick<TAssistantMessage<TContent, TMessageMetadata>, 'id' | 'content'>;
|
|
7
|
+
export type AssistantMessageProps<TContent extends TMessageContent = never> = BaseMessagePick & AssistantMessagePick<TContent> & {
|
|
8
|
+
messageRendererRegistry?: MessageRendererRegistry;
|
|
9
|
+
transformOptions?: OptionsType;
|
|
10
|
+
className?: string;
|
|
11
|
+
qa?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function AssistantMessage<TContent extends TMessageContent = never>({ content, actions, timestamp, id, messageRendererRegistry, transformOptions, showActionsOnHover, showTimestamp, className, qa, }: AssistantMessageProps<TContent>): import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { block } from '../../../utils/cn';
|
|
4
|
+
import { getMessageRenderer, mergeMessageRendererRegistries, } from '../../../utils/messageTypeRegistry';
|
|
5
|
+
import { normalizeContent } from '../../../utils/messageUtils';
|
|
6
|
+
import { BaseMessage } from '../../molecules/BaseMessage';
|
|
7
|
+
import { createDefaultMessageRegistry } from './defaultMessageTypeRegistry';
|
|
8
|
+
import './AssistantMessage.scss';
|
|
9
|
+
const b = block('assistant-message');
|
|
10
|
+
export function AssistantMessage({ content, actions, timestamp, id, messageRendererRegistry, transformOptions, showActionsOnHover, showTimestamp, className, qa, }) {
|
|
11
|
+
const registry = useMemo(() => {
|
|
12
|
+
const defaultRegistry = createDefaultMessageRegistry(transformOptions);
|
|
13
|
+
if (messageRendererRegistry) {
|
|
14
|
+
return mergeMessageRendererRegistries(defaultRegistry, messageRendererRegistry);
|
|
15
|
+
}
|
|
16
|
+
return defaultRegistry;
|
|
17
|
+
}, [messageRendererRegistry, transformOptions]);
|
|
18
|
+
const parts = normalizeContent(content);
|
|
19
|
+
if (parts.length === 0) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const renderPart = (part, partIndex) => {
|
|
23
|
+
const PartComponent = getMessageRenderer(registry, part.type);
|
|
24
|
+
if (!PartComponent) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const key = part.id || `${id || 'message'}-part-${partIndex}`;
|
|
28
|
+
return _jsx(PartComponent, { part: part }, key);
|
|
29
|
+
};
|
|
30
|
+
return (_jsx(BaseMessage, { role: "assistant", actions: actions, showActionsOnHover: showActionsOnHover, showTimestamp: showTimestamp, timestamp: timestamp, className: b(null, className), qa: qa, children: _jsx("div", { className: b('content'), children: parts.map((part, index) => renderPart(part, index)) }) }));
|
|
31
|
+
}
|
package/dist/src/components/organisms/AssistantMessage/__stories__/AssistantMessage.stories.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { type AssistantMessageProps } from '..';
|
|
3
|
+
import type { TMessageContent } from '../../../../types/messages';
|
|
4
|
+
declare const _default: Meta;
|
|
5
|
+
export default _default;
|
|
6
|
+
export declare const Playground: StoryFn<AssistantMessageProps>;
|
|
7
|
+
export declare const WithToolCall: StoryObj<AssistantMessageProps>;
|
|
8
|
+
interface CustomMessageData {
|
|
9
|
+
title: string;
|
|
10
|
+
description: string;
|
|
11
|
+
}
|
|
12
|
+
type CustomMessageContent = TMessageContent<'custom', CustomMessageData>;
|
|
13
|
+
export declare const WithCustomRenderer: StoryObj<AssistantMessageProps<CustomMessageContent>>;
|
package/dist/src/components/organisms/AssistantMessage/__stories__/AssistantMessage.stories.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
import { Pencil } from '@gravity-ui/icons';
|
|
4
|
+
import { Icon, Text } from '@gravity-ui/uikit';
|
|
5
|
+
import { AssistantMessage } from '..';
|
|
6
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
7
|
+
import { Showcase } from '../../../../demo/Showcase';
|
|
8
|
+
import { ShowcaseItem } from '../../../../demo/ShowcaseItem';
|
|
9
|
+
import { createMessageRendererRegistry, registerMessageRenderer, } from '../../../../utils/messageTypeRegistry';
|
|
10
|
+
import MDXDocs from './Docs.mdx';
|
|
11
|
+
export default {
|
|
12
|
+
title: 'organisms/AssistantMessage',
|
|
13
|
+
component: AssistantMessage,
|
|
14
|
+
parameters: {
|
|
15
|
+
docs: {
|
|
16
|
+
page: MDXDocs,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
argTypes: {
|
|
20
|
+
content: {
|
|
21
|
+
control: 'object',
|
|
22
|
+
description: 'Message content',
|
|
23
|
+
},
|
|
24
|
+
actions: {
|
|
25
|
+
control: 'object',
|
|
26
|
+
description: 'Message actions',
|
|
27
|
+
},
|
|
28
|
+
timestamp: {
|
|
29
|
+
control: 'text',
|
|
30
|
+
description: 'Message timestamp',
|
|
31
|
+
},
|
|
32
|
+
id: {
|
|
33
|
+
control: 'text',
|
|
34
|
+
description: 'Message ID',
|
|
35
|
+
},
|
|
36
|
+
messageRendererRegistry: {
|
|
37
|
+
control: false,
|
|
38
|
+
description: 'Custom message renderer registry',
|
|
39
|
+
},
|
|
40
|
+
showActionsOnHover: {
|
|
41
|
+
control: 'boolean',
|
|
42
|
+
description: 'Show action buttons on hover',
|
|
43
|
+
},
|
|
44
|
+
showTimestamp: {
|
|
45
|
+
control: 'boolean',
|
|
46
|
+
description: 'Show timestamp in actions area',
|
|
47
|
+
},
|
|
48
|
+
className: {
|
|
49
|
+
control: 'text',
|
|
50
|
+
description: 'Additional CSS class',
|
|
51
|
+
},
|
|
52
|
+
qa: {
|
|
53
|
+
control: 'text',
|
|
54
|
+
description: 'QA/test identifier',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
const simpleMessage = {
|
|
59
|
+
id: '1',
|
|
60
|
+
role: 'assistant',
|
|
61
|
+
content: 'Hello! How can I help you today?',
|
|
62
|
+
};
|
|
63
|
+
const multiPartMessage = {
|
|
64
|
+
id: '4',
|
|
65
|
+
role: 'assistant',
|
|
66
|
+
content: [
|
|
67
|
+
{
|
|
68
|
+
type: 'text',
|
|
69
|
+
data: {
|
|
70
|
+
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.",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: 'tool',
|
|
75
|
+
data: {
|
|
76
|
+
toolName: 'Reading',
|
|
77
|
+
headerContent: (_jsx(Text, { color: "secondary", variant: "body-1", children: "Warning.css" })),
|
|
78
|
+
status: 'success',
|
|
79
|
+
toolIcon: _jsx(Icon, { data: Pencil }),
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'text',
|
|
84
|
+
data: {
|
|
85
|
+
text: 'I’m organizing which files to read first. I’ll start with the essentials like package.json, README.md, tsconfig.json, jest.config.js, and eslint.config.mjs.',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
};
|
|
90
|
+
const actions = [
|
|
91
|
+
// eslint-disable-next-line no-console
|
|
92
|
+
{ type: 'copy', onClick: () => console.log('Copy clicked') },
|
|
93
|
+
// eslint-disable-next-line no-console
|
|
94
|
+
{ type: 'like', onClick: () => console.log('Like clicked') },
|
|
95
|
+
// eslint-disable-next-line no-console
|
|
96
|
+
{ type: 'unlike', onClick: () => console.log('Unlike clicked') },
|
|
97
|
+
];
|
|
98
|
+
export const Playground = (args) => (_jsx(ContentWrapper, { width: "480px", children: _jsx(AssistantMessage, Object.assign({}, args)) }));
|
|
99
|
+
Playground.args = {
|
|
100
|
+
content: simpleMessage.content,
|
|
101
|
+
actions,
|
|
102
|
+
timestamp: simpleMessage.timestamp,
|
|
103
|
+
id: simpleMessage.id,
|
|
104
|
+
};
|
|
105
|
+
export const WithToolCall = {
|
|
106
|
+
render: (args) => (_jsx(ShowcaseItem, { title: "With Tool Call", children: _jsx(ContentWrapper, { width: "480px", children: _jsx(AssistantMessage, Object.assign({}, args, { content: multiPartMessage.content, actions: actions, timestamp: multiPartMessage.timestamp, id: multiPartMessage.id })) }) })),
|
|
107
|
+
decorators: [
|
|
108
|
+
(StoryComponent) => (_jsx(Showcase, { children: _jsx(StoryComponent, {}) })),
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
const CustomMessageView = ({ part, }) => {
|
|
112
|
+
const { title, description } = part.data;
|
|
113
|
+
return (_jsxs("div", { style: {
|
|
114
|
+
padding: '16px',
|
|
115
|
+
border: '1px solid var(--g-color-line-generic)',
|
|
116
|
+
borderRadius: '8px',
|
|
117
|
+
backgroundColor: 'var(--g-color-base-float)',
|
|
118
|
+
}, children: [_jsx("div", { style: { fontWeight: 'bold', marginBottom: '8px' }, children: title }), _jsx("div", { style: { color: 'var(--g-color-text-secondary)' }, children: description })] }));
|
|
119
|
+
};
|
|
120
|
+
export const WithCustomRenderer = {
|
|
121
|
+
render: (args) => {
|
|
122
|
+
const customRegistry = createMessageRendererRegistry();
|
|
123
|
+
registerMessageRenderer(customRegistry, 'custom', {
|
|
124
|
+
component: CustomMessageView,
|
|
125
|
+
});
|
|
126
|
+
const customMessage = {
|
|
127
|
+
id: '5',
|
|
128
|
+
role: 'assistant',
|
|
129
|
+
timestamp: '2024-01-01T00:00:04Z',
|
|
130
|
+
content: [
|
|
131
|
+
{
|
|
132
|
+
type: 'text',
|
|
133
|
+
data: {
|
|
134
|
+
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.",
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'custom',
|
|
139
|
+
data: {
|
|
140
|
+
title: 'Custom Message',
|
|
141
|
+
description: 'This is a custom message part rendered with a custom renderer.',
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
};
|
|
146
|
+
return (_jsx(ShowcaseItem, { title: "With Custom Renderer", children: _jsx(ContentWrapper, { width: "480px", children: _jsx(AssistantMessage, Object.assign({}, args, { content: customMessage.content, actions: actions, timestamp: customMessage.timestamp, id: customMessage.id, messageRendererRegistry: customRegistry })) }) }));
|
|
147
|
+
},
|
|
148
|
+
decorators: [
|
|
149
|
+
(StoryComponent) => (_jsx(Showcase, { children: _jsx(StoryComponent, {}) })),
|
|
150
|
+
],
|
|
151
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createMessageRendererRegistry, registerMessageRenderer, } from '../../../utils/messageTypeRegistry';
|
|
3
|
+
import { MarkdownRenderer } from '../../atoms/MarkdownRenderer';
|
|
4
|
+
import { ThinkingMessage } from '../ThinkingMessage';
|
|
5
|
+
import { ToolMessage } from '../ToolMessage';
|
|
6
|
+
export function createDefaultMessageRegistry(transformOptions) {
|
|
7
|
+
const registry = createMessageRendererRegistry();
|
|
8
|
+
registerMessageRenderer(registry, 'text', {
|
|
9
|
+
component: ({ part }) => (_jsx(MarkdownRenderer, { content: part.data.text, transformOptions: transformOptions })),
|
|
10
|
+
});
|
|
11
|
+
registerMessageRenderer(registry, 'tool', {
|
|
12
|
+
component: ({ part }) => _jsx(ToolMessage, Object.assign({}, part.data)),
|
|
13
|
+
});
|
|
14
|
+
registerMessageRenderer(registry, 'thinking', {
|
|
15
|
+
component: ({ part }) => _jsx(ThinkingMessage, { data: part.data }),
|
|
16
|
+
});
|
|
17
|
+
return registry;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AssistantMessage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AssistantMessage';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type HeaderProps } from './types';
|
|
2
|
+
import './Header.scss';
|
|
3
|
+
/**
|
|
4
|
+
* Header component for displaying chat header with navigation and actions
|
|
5
|
+
*
|
|
6
|
+
* @param props - Component props
|
|
7
|
+
* @returns Header component
|
|
8
|
+
*/
|
|
9
|
+
export declare function Header(props: HeaderProps): import("react/jsx-runtime").JSX.Element;
|