@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,72 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PromptInputHeaderProps } from '../../molecules/PromptInputHeader';
|
|
3
|
+
import { SuggestionsItem, SuggestionsProps } from '../../molecules/Suggestions';
|
|
4
|
+
/**
|
|
5
|
+
* Props for a panel (top or bottom)
|
|
6
|
+
*/
|
|
7
|
+
export type PromptInputPanelConfig = {
|
|
8
|
+
/** Is panel open */
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
/** Panel content */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Props for the header section of PromptInput
|
|
15
|
+
*/
|
|
16
|
+
export type PromptInputHeaderConfig = {
|
|
17
|
+
/** Custom content for header area */
|
|
18
|
+
topContent?: ReactNode;
|
|
19
|
+
/** Array of context items to display on the left */
|
|
20
|
+
contextItems?: PromptInputHeaderProps['contextItems'];
|
|
21
|
+
/** Show context indicator in header */
|
|
22
|
+
showContextIndicator?: boolean;
|
|
23
|
+
/** Props for context indicator */
|
|
24
|
+
contextIndicatorProps?: PromptInputHeaderProps['contextIndicatorProps'];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Props for the body/textarea section of PromptInput
|
|
28
|
+
*/
|
|
29
|
+
export type PromptInputBodyConfig = {
|
|
30
|
+
/** Placeholder text for textarea */
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
/** Minimum number of textarea rows */
|
|
33
|
+
minRows?: number;
|
|
34
|
+
/** Maximum number of textarea rows */
|
|
35
|
+
maxRows?: number;
|
|
36
|
+
/** Auto focus textarea on mount */
|
|
37
|
+
autoFocus?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Props for the footer section of PromptInput
|
|
41
|
+
*/
|
|
42
|
+
export type PromptInputFooterConfig = {
|
|
43
|
+
/** Custom content for footer area (SubmitButton will still be shown) */
|
|
44
|
+
bottomContent?: ReactNode;
|
|
45
|
+
/** Show settings icon in footer */
|
|
46
|
+
showSettings?: boolean;
|
|
47
|
+
/** Settings icon click handler */
|
|
48
|
+
onSettingsClick?: () => void;
|
|
49
|
+
/** Show attachment icon in footer */
|
|
50
|
+
showAttachment?: boolean;
|
|
51
|
+
/** Attachment icon click handler */
|
|
52
|
+
onAttachmentClick?: () => void;
|
|
53
|
+
/** Show microphone icon in footer */
|
|
54
|
+
showMicrophone?: boolean;
|
|
55
|
+
/** Microphone icon click handler */
|
|
56
|
+
onMicrophoneClick?: () => void;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Props for the suggestions section of PromptInput
|
|
60
|
+
*/
|
|
61
|
+
export type PromptInputSuggestionsConfig = {
|
|
62
|
+
/** Submit suggestions array */
|
|
63
|
+
suggestions?: SuggestionsItem[];
|
|
64
|
+
/** Show submit suggestions */
|
|
65
|
+
showSuggestions?: boolean;
|
|
66
|
+
/** Layout orientation for suggestions: 'grid' for horizontal, 'list' for vertical */
|
|
67
|
+
suggestionsLayout?: SuggestionsProps['layout'];
|
|
68
|
+
/** Text alignment inside suggestion buttons */
|
|
69
|
+
suggestionsTextAlign?: SuggestionsProps['textAlign'];
|
|
70
|
+
/** Callback when suggestion is clicked */
|
|
71
|
+
onSuggestionClick?: (content: string, id?: string) => void;
|
|
72
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for delaying component unmount during animation
|
|
3
|
+
*
|
|
4
|
+
* @param isOpen - Open/close flag
|
|
5
|
+
* @param delayTime - Delay time in milliseconds (default 300ms)
|
|
6
|
+
* @returns shouldRender - Whether the element should be rendered
|
|
7
|
+
*/
|
|
8
|
+
export declare function useDelayedUnmount(isOpen: boolean, delayTime?: number): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for delaying component unmount during animation
|
|
4
|
+
*
|
|
5
|
+
* @param isOpen - Open/close flag
|
|
6
|
+
* @param delayTime - Delay time in milliseconds (default 300ms)
|
|
7
|
+
* @returns shouldRender - Whether the element should be rendered
|
|
8
|
+
*/
|
|
9
|
+
export function useDelayedUnmount(isOpen, delayTime = 300) {
|
|
10
|
+
const [shouldRender, setShouldRender] = useState(isOpen);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (isOpen) {
|
|
13
|
+
// If opening, show immediately
|
|
14
|
+
setShouldRender(true);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
// If closing, wait for animation to complete
|
|
18
|
+
const timeoutId = setTimeout(() => {
|
|
19
|
+
setShouldRender(false);
|
|
20
|
+
}, delayTime);
|
|
21
|
+
return () => clearTimeout(timeoutId);
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}, [isOpen, delayTime]);
|
|
25
|
+
return shouldRender;
|
|
26
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ChatStatus, TSubmitData } from '../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook props for managing PromptInput state
|
|
4
|
+
*/
|
|
5
|
+
export type UsePromptInputProps = {
|
|
6
|
+
/** Callback when message is sent */
|
|
7
|
+
onSend: (data: TSubmitData) => Promise<void>;
|
|
8
|
+
/** Callback when sending is cancelled */
|
|
9
|
+
onCancel?: () => Promise<void>;
|
|
10
|
+
/** Initial value */
|
|
11
|
+
initialValue?: string;
|
|
12
|
+
/** Maximum length of input */
|
|
13
|
+
maxLength?: number;
|
|
14
|
+
/** Disabled state */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** Chat status to determine input behavior */
|
|
17
|
+
status?: ChatStatus;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Hook return type for PromptInput state management
|
|
21
|
+
*/
|
|
22
|
+
export type UsePromptInputReturn = {
|
|
23
|
+
/** Current input value */
|
|
24
|
+
value: string;
|
|
25
|
+
/** Set the input value */
|
|
26
|
+
setValue: (value: string) => void;
|
|
27
|
+
/** Is currently sending */
|
|
28
|
+
isSending: boolean;
|
|
29
|
+
/** Can submit the form */
|
|
30
|
+
canSubmit: boolean;
|
|
31
|
+
/** Submit button state */
|
|
32
|
+
submitButtonState: 'enabled' | 'disabled' | 'loading' | 'cancelable';
|
|
33
|
+
/** Is input disabled (when loading) */
|
|
34
|
+
isInputDisabled: boolean;
|
|
35
|
+
/** Handle input change */
|
|
36
|
+
handleChange: (value: string) => void;
|
|
37
|
+
/** Handle key down */
|
|
38
|
+
handleKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
39
|
+
/** Handle submit */
|
|
40
|
+
handleSubmit: () => Promise<void>;
|
|
41
|
+
/** Attachments */
|
|
42
|
+
attachments: File[];
|
|
43
|
+
/** Set attachments */
|
|
44
|
+
setAttachments: (files: File[]) => void;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Custom hook for managing PromptInput state and behavior
|
|
48
|
+
*
|
|
49
|
+
* @param props - Hook props
|
|
50
|
+
* @returns Hook return value with state and handlers
|
|
51
|
+
*/
|
|
52
|
+
export declare function usePromptInput(props: UsePromptInputProps): UsePromptInputReturn;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook for managing PromptInput state and behavior
|
|
4
|
+
*
|
|
5
|
+
* @param props - Hook props
|
|
6
|
+
* @returns Hook return value with state and handlers
|
|
7
|
+
*/
|
|
8
|
+
export function usePromptInput(props) {
|
|
9
|
+
const { onSend, onCancel, initialValue = '', maxLength, disabled = false, status = 'ready', } = props;
|
|
10
|
+
const [value, setValue] = useState(initialValue);
|
|
11
|
+
const [isSending, setIsSending] = useState(false);
|
|
12
|
+
const [attachments, setAttachments] = useState([]);
|
|
13
|
+
const trimmedValue = value.trim();
|
|
14
|
+
const canSubmit = !disabled && !isSending && trimmedValue.length > 0;
|
|
15
|
+
// Map ChatStatus to submit button state
|
|
16
|
+
// ChatStatus.ready → submitButtonState.enabled
|
|
17
|
+
// ChatStatus.error → submitButtonState.enabled
|
|
18
|
+
// ChatStatus.streaming → submitButtonState.cancelable
|
|
19
|
+
// ChatStatus.submitted → submitButtonState.loading
|
|
20
|
+
let submitButtonState = 'disabled';
|
|
21
|
+
if (disabled || !trimmedValue) {
|
|
22
|
+
submitButtonState = 'disabled';
|
|
23
|
+
}
|
|
24
|
+
else if (isSending) {
|
|
25
|
+
submitButtonState = 'loading';
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
switch (status) {
|
|
29
|
+
case 'ready':
|
|
30
|
+
case 'error':
|
|
31
|
+
submitButtonState = 'enabled';
|
|
32
|
+
break;
|
|
33
|
+
case 'streaming':
|
|
34
|
+
submitButtonState = onCancel ? 'cancelable' : 'enabled';
|
|
35
|
+
break;
|
|
36
|
+
case 'submitted':
|
|
37
|
+
submitButtonState = 'loading';
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
submitButtonState = 'enabled';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Input is disabled when loading
|
|
44
|
+
const isInputDisabled = submitButtonState === 'loading';
|
|
45
|
+
const handleChange = useCallback((newValue) => {
|
|
46
|
+
if (maxLength && newValue.length > maxLength) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
setValue(newValue);
|
|
50
|
+
}, [maxLength]);
|
|
51
|
+
const handleSubmit = useCallback(async () => {
|
|
52
|
+
if (submitButtonState === 'cancelable' && onCancel) {
|
|
53
|
+
await onCancel();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!canSubmit) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
setIsSending(true);
|
|
60
|
+
try {
|
|
61
|
+
const submitData = Object.assign({ content: trimmedValue }, (attachments.length > 0 && { attachments }));
|
|
62
|
+
await onSend(submitData);
|
|
63
|
+
setValue('');
|
|
64
|
+
setAttachments([]);
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
setIsSending(false);
|
|
68
|
+
}
|
|
69
|
+
}, [submitButtonState, canSubmit, trimmedValue, attachments, onSend, onCancel]);
|
|
70
|
+
const handleKeyDown = useCallback((event) => {
|
|
71
|
+
const isEnter = event.code === 'Enter' || event.code === 'NumpadEnter';
|
|
72
|
+
// Insert new line on Ctrl/Cmd + Enter
|
|
73
|
+
if (isEnter && (event.ctrlKey || event.metaKey)) {
|
|
74
|
+
setValue((prev) => prev + '\n');
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// Prevent submission if can't submit
|
|
79
|
+
if (isEnter && !event.shiftKey && !canSubmit) {
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// Submit on Enter (without Shift)
|
|
84
|
+
if (isEnter && !event.shiftKey && canSubmit) {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
handleSubmit();
|
|
87
|
+
}
|
|
88
|
+
}, [canSubmit, handleSubmit]);
|
|
89
|
+
return {
|
|
90
|
+
value,
|
|
91
|
+
setValue,
|
|
92
|
+
isSending,
|
|
93
|
+
canSubmit,
|
|
94
|
+
submitButtonState,
|
|
95
|
+
isInputDisabled,
|
|
96
|
+
handleChange,
|
|
97
|
+
handleKeyDown,
|
|
98
|
+
handleSubmit,
|
|
99
|
+
attachments,
|
|
100
|
+
setAttachments,
|
|
101
|
+
};
|
|
102
|
+
}
|
package/dist/src/components/organisms/ThinkingMessage/__stories__/ThinkingMessage.stories.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { type ThinkingMessageProps } from '..';
|
|
3
|
+
declare const _default: Meta;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Playground: StoryFn<ThinkingMessageProps>;
|
|
6
|
+
export declare const ThinkingState: StoryObj<ThinkingMessageProps>;
|
|
7
|
+
export declare const ThoughtState: StoryObj<ThinkingMessageProps>;
|
|
8
|
+
export declare const SingleContent: StoryObj<ThinkingMessageProps>;
|
|
9
|
+
export declare const Collapsed: StoryObj<ThinkingMessageProps>;
|
|
10
|
+
export declare const WithoutLoader: StoryObj<ThinkingMessageProps>;
|
|
11
|
+
export declare const WithCopyAction: StoryObj<ThinkingMessageProps>;
|
|
12
|
+
export declare const WithCustomStyle: StoryObj<ThinkingMessageProps>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ThinkingMessage } 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: 'organisms/ThinkingMessage',
|
|
9
|
+
component: ThinkingMessage,
|
|
10
|
+
parameters: {
|
|
11
|
+
docs: {
|
|
12
|
+
page: MDXDocs,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
argTypes: {
|
|
16
|
+
data: {
|
|
17
|
+
control: 'object',
|
|
18
|
+
description: 'Thinking message data',
|
|
19
|
+
},
|
|
20
|
+
defaultExpanded: {
|
|
21
|
+
control: 'boolean',
|
|
22
|
+
description: 'Initial expanded state',
|
|
23
|
+
},
|
|
24
|
+
showStatusIndicator: {
|
|
25
|
+
control: 'boolean',
|
|
26
|
+
description: 'Show loader when status is "thinking"',
|
|
27
|
+
},
|
|
28
|
+
className: {
|
|
29
|
+
control: 'text',
|
|
30
|
+
description: 'Class name',
|
|
31
|
+
},
|
|
32
|
+
qa: {
|
|
33
|
+
control: 'text',
|
|
34
|
+
description: 'QA attribute',
|
|
35
|
+
},
|
|
36
|
+
style: {
|
|
37
|
+
control: 'object',
|
|
38
|
+
description: 'Style',
|
|
39
|
+
},
|
|
40
|
+
onCopyClick: {
|
|
41
|
+
action: 'copy clicked',
|
|
42
|
+
description: 'Copy button click handler',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
const defaultDecorators = [
|
|
47
|
+
(Story) => (_jsx(Showcase, { children: _jsx(Story, {}) })),
|
|
48
|
+
];
|
|
49
|
+
const thinkingData = {
|
|
50
|
+
data: {
|
|
51
|
+
content: [
|
|
52
|
+
'Lore ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
|
53
|
+
'Lore ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
|
54
|
+
],
|
|
55
|
+
status: 'thinking',
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
const thoughtData = {
|
|
59
|
+
data: {
|
|
60
|
+
content: [
|
|
61
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
|
62
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
|
63
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
|
64
|
+
],
|
|
65
|
+
status: 'thought',
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
export const Playground = (args) => (_jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, args)) }));
|
|
69
|
+
Playground.args = Object.assign(Object.assign({}, thinkingData), { defaultExpanded: true, showStatusIndicator: true });
|
|
70
|
+
export const ThinkingState = {
|
|
71
|
+
render: () => (_jsx(ShowcaseItem, { title: "Thinking State (with loader)", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, thinkingData, { defaultExpanded: true, showStatusIndicator: true })) }) })),
|
|
72
|
+
decorators: defaultDecorators,
|
|
73
|
+
};
|
|
74
|
+
export const ThoughtState = {
|
|
75
|
+
render: () => (_jsx(ShowcaseItem, { title: "Thought State (completed)", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, thoughtData, { defaultExpanded: true, showStatusIndicator: true })) }) })),
|
|
76
|
+
decorators: defaultDecorators,
|
|
77
|
+
};
|
|
78
|
+
export const SingleContent = {
|
|
79
|
+
render: () => (_jsx(ShowcaseItem, { title: "Single Content String", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, { data: {
|
|
80
|
+
content: 'Processing your request and analyzing possible solutions.',
|
|
81
|
+
status: 'thinking',
|
|
82
|
+
}, defaultExpanded: true }) }) })),
|
|
83
|
+
decorators: defaultDecorators,
|
|
84
|
+
};
|
|
85
|
+
export const Collapsed = {
|
|
86
|
+
render: () => (_jsx(ShowcaseItem, { title: "Collapsed Initially", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, thoughtData, { defaultExpanded: false })) }) })),
|
|
87
|
+
decorators: defaultDecorators,
|
|
88
|
+
};
|
|
89
|
+
export const WithoutLoader = {
|
|
90
|
+
render: () => (_jsx(ShowcaseItem, { title: "Without Loader (showStatusIndicator=false)", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, thinkingData, { defaultExpanded: true, showStatusIndicator: false })) }) })),
|
|
91
|
+
decorators: defaultDecorators,
|
|
92
|
+
};
|
|
93
|
+
export const WithCopyAction = {
|
|
94
|
+
render: () => (_jsx(ShowcaseItem, { title: "With Copy Action", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, thoughtData, { defaultExpanded: true, onCopyClick: () => alert('Content copied to clipboard!') })) }) })),
|
|
95
|
+
decorators: defaultDecorators,
|
|
96
|
+
};
|
|
97
|
+
export const WithCustomStyle = {
|
|
98
|
+
render: (args) => (_jsx(ShowcaseItem, { title: "With Custom Style", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, args)) }) })),
|
|
99
|
+
decorators: defaultDecorators,
|
|
100
|
+
};
|
|
101
|
+
WithCustomStyle.args = Object.assign(Object.assign({}, thoughtData), { defaultExpanded: true, style: {
|
|
102
|
+
'--g-color-text-complementary': '#00aa00',
|
|
103
|
+
'--g-color-line-generic': '#ff6b35',
|
|
104
|
+
'--g-text-body-1-font-size': '16px',
|
|
105
|
+
'--g-text-body-font-weight': '500',
|
|
106
|
+
'--g-text-body-1-line-height': '18px',
|
|
107
|
+
}, onCopyClick: undefined });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const i18n: ((key: "title-thinking" | "title-thought", params?: import("@gravity-ui/i18n").Params) => string) & {
|
|
2
|
+
Translation: import("react").ComponentType<{
|
|
3
|
+
children: (props: {
|
|
4
|
+
t: (key: "title-thinking" | "title-thought", params?: import("@gravity-ui/i18n").Params) => string;
|
|
5
|
+
}) => React.ReactNode;
|
|
6
|
+
}>;
|
|
7
|
+
useTranslation: () => {
|
|
8
|
+
t: (key: "title-thinking" | "title-thought", params?: import("@gravity-ui/i18n").Params) => string;
|
|
9
|
+
};
|
|
10
|
+
keysetData: {
|
|
11
|
+
"g-aikit-ThinkingMessage": Record<"title-thinking" | "title-thought", import("@gravity-ui/i18n").KeyData>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DOMProps, QAProps } from '@gravity-ui/uikit';
|
|
2
|
+
import { ThinkingMessageData } from './useThinkingMessage';
|
|
3
|
+
import './ThinkingMessage.scss';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the ThinkingMessage component.
|
|
6
|
+
* Combines DOM props, QA props, and thinking message data.
|
|
7
|
+
*/
|
|
8
|
+
export type ThinkingMessageProps = DOMProps & QAProps & ThinkingMessageData & {
|
|
9
|
+
/** Whether the thinking content should be expanded by default */
|
|
10
|
+
defaultExpanded?: boolean;
|
|
11
|
+
/** Whether to show the status indicator (loader) */
|
|
12
|
+
showStatusIndicator?: boolean;
|
|
13
|
+
/** Callback fired when the copy button is clicked */
|
|
14
|
+
onCopyClick?: () => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* ThinkingMessage component displays AI model's internal reasoning process.
|
|
18
|
+
* Shows a collapsible block with thinking content and a copy button.
|
|
19
|
+
* Displays a loader when the thinking process is still in progress.
|
|
20
|
+
*
|
|
21
|
+
* @param props - Component props
|
|
22
|
+
* @returns Rendered thinking message component
|
|
23
|
+
*/
|
|
24
|
+
export declare const ThinkingMessage: (props: ThinkingMessageProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { ChevronDown, ChevronUp, Copy } from '@gravity-ui/icons';
|
|
15
|
+
import { Button, Icon, Text } from '@gravity-ui/uikit';
|
|
16
|
+
import { block } from '../../../utils/cn';
|
|
17
|
+
import { ActionButton } from '../../atoms';
|
|
18
|
+
import { Loader } from '../../atoms/Loader';
|
|
19
|
+
import { useThinkingMessage } from './useThinkingMessage';
|
|
20
|
+
import './ThinkingMessage.scss';
|
|
21
|
+
const b = block('thinking-message');
|
|
22
|
+
/**
|
|
23
|
+
* ThinkingMessage component displays AI model's internal reasoning process.
|
|
24
|
+
* Shows a collapsible block with thinking content and a copy button.
|
|
25
|
+
* Displays a loader when the thinking process is still in progress.
|
|
26
|
+
*
|
|
27
|
+
* @param props - Component props
|
|
28
|
+
* @returns Rendered thinking message component
|
|
29
|
+
*/
|
|
30
|
+
export const ThinkingMessage = (props) => {
|
|
31
|
+
const { className, qa, style, onCopyClick } = props, data = __rest(props, ["className", "qa", "style", "onCopyClick"]);
|
|
32
|
+
const { isExpanded, toggleExpanded, buttonTitle, content, showLoader } = useThinkingMessage(Object.assign({}, data));
|
|
33
|
+
return (_jsxs("div", { className: b(null, className), "data-qa": qa, style: style, children: [_jsxs("div", { className: b('buttons'), children: [_jsxs(Button, { size: "s", onClick: toggleExpanded, children: [buttonTitle, _jsx(Icon, { data: isExpanded ? ChevronUp : ChevronDown })] }), showLoader ? (_jsx(Loader, { view: "loading", size: "xs" })) : (onCopyClick && (_jsx(ActionButton, { size: "s", onClick: onCopyClick, children: _jsx(Icon, { data: Copy, size: 16 }) })))] }), isExpanded && (_jsx("div", { className: b('container'), children: content.map((item) => (_jsx(Text, { className: b('content'), children: item }, item))) }))] }));
|
|
34
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ThinkingMessageContent } from '../../../types/messages';
|
|
2
|
+
import { BaseMessageAction } from '../../molecules/BaseMessage';
|
|
3
|
+
export type ThinkingMessageData = Omit<ThinkingMessageContent, 'type'>;
|
|
4
|
+
export type UseThinkingMessageOptions = ThinkingMessageData & {
|
|
5
|
+
defaultExpanded?: boolean;
|
|
6
|
+
showStatusIndicator?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ThinkingMessageAction = {
|
|
9
|
+
type: BaseMessageAction | string;
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
};
|
|
12
|
+
export declare function useThinkingMessage(options: UseThinkingMessageOptions): {
|
|
13
|
+
isExpanded: boolean;
|
|
14
|
+
toggleExpanded: () => void;
|
|
15
|
+
buttonTitle: string;
|
|
16
|
+
content: string[];
|
|
17
|
+
showLoader: boolean;
|
|
18
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { i18n } from './i18n';
|
|
3
|
+
export function useThinkingMessage(options) {
|
|
4
|
+
const { defaultExpanded = true, showStatusIndicator = true, data } = options;
|
|
5
|
+
const { status, content } = data;
|
|
6
|
+
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
|
|
7
|
+
const buttonTitle = useMemo(() => {
|
|
8
|
+
return i18n(`title-${status}`);
|
|
9
|
+
}, [status]);
|
|
10
|
+
const contentArray = useMemo(() => {
|
|
11
|
+
return Array.isArray(content) ? content : [content];
|
|
12
|
+
}, [content]);
|
|
13
|
+
const toggleExpanded = useCallback(() => {
|
|
14
|
+
setIsExpanded((prev) => !prev);
|
|
15
|
+
}, []);
|
|
16
|
+
return {
|
|
17
|
+
isExpanded,
|
|
18
|
+
toggleExpanded,
|
|
19
|
+
buttonTitle,
|
|
20
|
+
content: contentArray,
|
|
21
|
+
showLoader: showStatusIndicator && status === 'thinking',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import type { ToolMessageProps } from '../../../../types/tool';
|
|
3
|
+
declare const _default: Meta;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Playground: StoryFn<ToolMessageProps>;
|
|
6
|
+
export declare const WaitingSubmission: StoryObj<ToolMessageProps>;
|
|
7
|
+
export declare const WaitingConfirmation: StoryObj<ToolMessageProps>;
|
|
8
|
+
export declare const CustomHeaderActions: StoryObj<ToolMessageProps>;
|
|
9
|
+
export declare const CustomFooterActions: StoryObj<ToolMessageProps>;
|
|
10
|
+
export declare const Loading: StoryObj<ToolMessageProps>;
|
|
11
|
+
export declare const Error: StoryObj<ToolMessageProps>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Archive, Copy, Pencil } from '@gravity-ui/icons';
|
|
3
|
+
import { Icon, Text } from '@gravity-ui/uikit';
|
|
4
|
+
import { ToolMessage } from '..';
|
|
5
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
6
|
+
import { Showcase } from '../../../../demo/Showcase';
|
|
7
|
+
import { ShowcaseItem } from '../../../../demo/ShowcaseItem';
|
|
8
|
+
import { SwapArea } from '../../../../demo/SwapArea';
|
|
9
|
+
import MDXDocs from './Docs.mdx';
|
|
10
|
+
export default {
|
|
11
|
+
title: 'organisms/ToolMessage',
|
|
12
|
+
component: ToolMessage,
|
|
13
|
+
parameters: {
|
|
14
|
+
docs: {
|
|
15
|
+
page: MDXDocs,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
argTypes: {
|
|
19
|
+
toolName: {
|
|
20
|
+
control: 'text',
|
|
21
|
+
description: 'Name of the tool',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
const defaultDecorators = [
|
|
26
|
+
(Story) => (_jsx(Showcase, { children: _jsx(Story, {}) })),
|
|
27
|
+
];
|
|
28
|
+
const defaultArgs = {
|
|
29
|
+
toolName: 'Writing',
|
|
30
|
+
toolIcon: _jsx(Icon, { data: Pencil, size: 16 }),
|
|
31
|
+
headerContent: _jsx(Text, { color: "secondary", children: "expectScreenshotFixture.ts" }),
|
|
32
|
+
};
|
|
33
|
+
export const Playground = (args) => (_jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, Object.assign({}, args)) }));
|
|
34
|
+
Playground.args = Object.assign(Object.assign({}, defaultArgs), { status: 'success', bodyContent: _jsx(SwapArea, {}) });
|
|
35
|
+
export const WaitingSubmission = {
|
|
36
|
+
render: () => (_jsx(ShowcaseItem, { title: "Waiting Submission", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, { toolName: "Creating repository", status: "waitingSubmission", toolIcon: _jsx(Icon, { data: Archive, size: 16 }), bodyContent: _jsx(Text, { children: "Almost done creating your shiny new repository. Take a moment to review the name, visibility, and template. When you're ready, click 'Create repository' to finish!" }) }) }) })),
|
|
37
|
+
decorators: defaultDecorators,
|
|
38
|
+
};
|
|
39
|
+
export const WaitingConfirmation = {
|
|
40
|
+
render: () => (_jsx(ShowcaseItem, { title: "Waiting Confirmation", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, Object.assign({}, defaultArgs, { status: "waitingConfirmation", bodyContent: _jsx(SwapArea, {}) })) }) })),
|
|
41
|
+
decorators: defaultDecorators,
|
|
42
|
+
};
|
|
43
|
+
export const CustomHeaderActions = {
|
|
44
|
+
render: () => (_jsx(ShowcaseItem, { title: "With Custom Header Actions", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, Object.assign({}, defaultArgs, { headerActions: [
|
|
45
|
+
{
|
|
46
|
+
label: 'Copy',
|
|
47
|
+
onClick: () => alert('Copied'),
|
|
48
|
+
icon: _jsx(Icon, { data: Copy, size: 16 }),
|
|
49
|
+
},
|
|
50
|
+
] })) }) })),
|
|
51
|
+
decorators: defaultDecorators,
|
|
52
|
+
};
|
|
53
|
+
export const CustomFooterActions = {
|
|
54
|
+
render: () => (_jsx(ShowcaseItem, { title: "With Custom Footer Actions", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, Object.assign({}, defaultArgs, { status: "waitingConfirmation", footerActions: [
|
|
55
|
+
{
|
|
56
|
+
label: 'Custom action',
|
|
57
|
+
onClick: () => alert('Custom action'),
|
|
58
|
+
view: 'action',
|
|
59
|
+
},
|
|
60
|
+
], bodyContent: _jsx(SwapArea, {}), footerContent: "Custom footer content" })) }) })),
|
|
61
|
+
decorators: defaultDecorators,
|
|
62
|
+
};
|
|
63
|
+
export const Loading = {
|
|
64
|
+
render: () => (_jsx(ShowcaseItem, { title: "Loading", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, Object.assign({}, defaultArgs, { status: "loading" })) }) })),
|
|
65
|
+
decorators: defaultDecorators,
|
|
66
|
+
};
|
|
67
|
+
export const Error = {
|
|
68
|
+
render: () => (_jsx(ShowcaseItem, { title: "Error", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, Object.assign({}, defaultArgs, { status: "error", bodyContent: _jsx(SwapArea, {}) })) }) })),
|
|
69
|
+
decorators: defaultDecorators,
|
|
70
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"action-reject": "Reject",
|
|
3
|
+
"action-accept": "Accept",
|
|
4
|
+
"action-cancel": "Cancel",
|
|
5
|
+
"action-collapse": "Collapse",
|
|
6
|
+
"action-expand": "Expand",
|
|
7
|
+
"status-waiting-confirmation": "Awaiting confirmation",
|
|
8
|
+
"status-waiting-submission": "Awaiting form submission"
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const i18n: ((key: "action-reject" | "action-accept" | "action-cancel" | "action-collapse" | "action-expand" | "status-waiting-confirmation" | "status-waiting-submission", params?: import("@gravity-ui/i18n").Params) => string) & {
|
|
2
|
+
Translation: import("react").ComponentType<{
|
|
3
|
+
children: (props: {
|
|
4
|
+
t: (key: "action-reject" | "action-accept" | "action-cancel" | "action-collapse" | "action-expand" | "status-waiting-confirmation" | "status-waiting-submission", params?: import("@gravity-ui/i18n").Params) => string;
|
|
5
|
+
}) => React.ReactNode;
|
|
6
|
+
}>;
|
|
7
|
+
useTranslation: () => {
|
|
8
|
+
t: (key: "action-reject" | "action-accept" | "action-cancel" | "action-collapse" | "action-expand" | "status-waiting-confirmation" | "status-waiting-submission", params?: import("@gravity-ui/i18n").Params) => string;
|
|
9
|
+
};
|
|
10
|
+
keysetData: {
|
|
11
|
+
"g-aikit-ToolMessage": Record<"action-reject" | "action-accept" | "action-cancel" | "action-collapse" | "action-expand" | "status-waiting-confirmation" | "status-waiting-submission", import("@gravity-ui/i18n").KeyData>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"action-reject": "Отклонить",
|
|
3
|
+
"action-accept": "Принять",
|
|
4
|
+
"action-cancel": "Отменить",
|
|
5
|
+
"action-collapse": "Свернуть",
|
|
6
|
+
"action-expand": "Развернуть",
|
|
7
|
+
"status-waiting-confirmation": "Ожидание подтверждения",
|
|
8
|
+
"status-waiting-submission": "Ожидание отправки формы"
|
|
9
|
+
}
|