@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,13 @@
|
|
|
1
|
+
export declare const i18n: ((key: "show-more-button", params?: import("@gravity-ui/i18n").Params) => string) & {
|
|
2
|
+
Translation: import("react").ComponentType<{
|
|
3
|
+
children: (props: {
|
|
4
|
+
t: (key: "show-more-button", params?: import("@gravity-ui/i18n").Params) => string;
|
|
5
|
+
}) => React.ReactNode;
|
|
6
|
+
}>;
|
|
7
|
+
useTranslation: () => {
|
|
8
|
+
t: (key: "show-more-button", params?: import("@gravity-ui/i18n").Params) => string;
|
|
9
|
+
};
|
|
10
|
+
keysetData: {
|
|
11
|
+
"g-aikit-EmptyContainer": Record<"show-more-button", import("@gravity-ui/i18n").KeyData>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './EmptyContainer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './EmptyContainer';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChatType } from '../../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Props for ChatItem component
|
|
5
|
+
*/
|
|
6
|
+
export interface ChatItemProps {
|
|
7
|
+
chat: ChatType;
|
|
8
|
+
showActions: boolean;
|
|
9
|
+
onChatClick: (chat: ChatType) => void;
|
|
10
|
+
onDeleteClick?: (e: React.MouseEvent, chat: ChatType) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Chat item component with hover state for actions
|
|
14
|
+
*
|
|
15
|
+
* @returns React element
|
|
16
|
+
*/
|
|
17
|
+
export declare function ChatItem({ chat, showActions, onChatClick, onDeleteClick }: ChatItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { TrashBin } from '@gravity-ui/icons';
|
|
4
|
+
import { Icon, Text } from '@gravity-ui/uikit';
|
|
5
|
+
import { block } from '../../../utils/cn';
|
|
6
|
+
import { ActionButton } from '../../atoms/ActionButton';
|
|
7
|
+
import { i18n } from './i18n';
|
|
8
|
+
const b = block('history');
|
|
9
|
+
/**
|
|
10
|
+
* Chat item component with hover state for actions
|
|
11
|
+
*
|
|
12
|
+
* @returns React element
|
|
13
|
+
*/
|
|
14
|
+
export function ChatItem({ chat, showActions, onChatClick, onDeleteClick }) {
|
|
15
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
16
|
+
const showDeleteButton = showActions && onDeleteClick && isHovered;
|
|
17
|
+
return (_jsxs("div", { className: b('chat-item'), onClick: () => onChatClick(chat), onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), children: [_jsx("div", { className: b('chat-content'), children: _jsx(Text, { variant: "body-1", children: chat.lastMessage || chat.name }) }), showDeleteButton && (_jsx(ActionButton, { view: "flat", size: "s", color: "secondary", className: b('delete-button'), onClick: (e) => onDeleteClick(e, chat), tooltipTitle: i18n('tooltip-delete'), children: _jsx(Icon, { className: b('icon-button'), data: TrashBin, size: 16 }) }))] }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for DateHeaderItem component
|
|
3
|
+
*/
|
|
4
|
+
export interface DateHeaderItemProps {
|
|
5
|
+
date: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Date header component for grouping chats
|
|
9
|
+
*
|
|
10
|
+
* @returns React element
|
|
11
|
+
*/
|
|
12
|
+
export declare function DateHeaderItem({ date }: DateHeaderItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { block } from '../../../utils/cn';
|
|
3
|
+
import { ChatDate } from '../../atoms/ChatDate';
|
|
4
|
+
const b = block('history');
|
|
5
|
+
/**
|
|
6
|
+
* Date header component for grouping chats
|
|
7
|
+
*
|
|
8
|
+
* @returns React element
|
|
9
|
+
*/
|
|
10
|
+
export function DateHeaderItem({ date }) {
|
|
11
|
+
return (_jsx("div", { className: b('date-header'), children: _jsx(ChatDate, { date: new Date(date), relative: true }) }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DOMProps, QAProps } from '@gravity-ui/uikit';
|
|
3
|
+
import { ChatType } from '../../../types';
|
|
4
|
+
import { ChatFilterFunction } from '../../../utils/chatUtils';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the History component
|
|
7
|
+
*/
|
|
8
|
+
export interface HistoryProps extends QAProps, DOMProps {
|
|
9
|
+
/** Array of chat items */
|
|
10
|
+
chats: ChatType[];
|
|
11
|
+
/** Currently selected chat */
|
|
12
|
+
selectedChat?: ChatType | null;
|
|
13
|
+
/** Callback when a chat is selected */
|
|
14
|
+
onSelectChat?: (chat: ChatType) => void;
|
|
15
|
+
/** Callback when a chat is deleted */
|
|
16
|
+
onDeleteChat?: (chat: ChatType) => void;
|
|
17
|
+
/** Callback to load more chats */
|
|
18
|
+
onLoadMore?: () => void;
|
|
19
|
+
/** Whether there are more chats to load */
|
|
20
|
+
hasMore?: boolean;
|
|
21
|
+
/** Enable search functionality */
|
|
22
|
+
searchable?: boolean;
|
|
23
|
+
/** Group chats by date or none */
|
|
24
|
+
groupBy?: 'date' | 'none';
|
|
25
|
+
/** Show action buttons (delete, etc.) */
|
|
26
|
+
showActions?: boolean;
|
|
27
|
+
/** Empty state placeholder */
|
|
28
|
+
emptyPlaceholder?: React.ReactNode;
|
|
29
|
+
/** Additional CSS class */
|
|
30
|
+
className?: string;
|
|
31
|
+
/** Custom filter function for search */
|
|
32
|
+
filterFunction?: ChatFilterFunction;
|
|
33
|
+
/** Control popup open state */
|
|
34
|
+
open?: boolean;
|
|
35
|
+
/** Callback when popup open state changes */
|
|
36
|
+
onOpenChange?: (open: boolean) => void;
|
|
37
|
+
/** Anchor element for the popup */
|
|
38
|
+
anchorElement: HTMLElement | null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* History component - wraps HistoryList in a Popup
|
|
42
|
+
*
|
|
43
|
+
* @param props - Component props
|
|
44
|
+
* @returns React component
|
|
45
|
+
*/
|
|
46
|
+
export declare function History(props: HistoryProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Popup } from '@gravity-ui/uikit';
|
|
3
|
+
import { HistoryList } from './HistoryList';
|
|
4
|
+
/**
|
|
5
|
+
* History component - wraps HistoryList in a Popup
|
|
6
|
+
*
|
|
7
|
+
* @param props - Component props
|
|
8
|
+
* @returns React component
|
|
9
|
+
*/
|
|
10
|
+
export function History(props) {
|
|
11
|
+
const { chats, selectedChat, onSelectChat, onDeleteChat, onLoadMore, hasMore = false, searchable = true, groupBy = 'date', showActions = true, emptyPlaceholder, className, qa, style, filterFunction, open = false, onOpenChange, anchorElement, } = props;
|
|
12
|
+
const handleChatClick = () => {
|
|
13
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false);
|
|
14
|
+
};
|
|
15
|
+
return (_jsx(Popup, { anchorElement: anchorElement, placement: "bottom-end", open: open, onOpenChange: onOpenChange, children: _jsx(HistoryList, { chats: chats, selectedChat: selectedChat, onSelectChat: onSelectChat, onDeleteChat: onDeleteChat, onLoadMore: onLoadMore, hasMore: hasMore, searchable: searchable, groupBy: groupBy, showActions: showActions, emptyPlaceholder: emptyPlaceholder, className: className, qa: qa, style: style, filterFunction: filterFunction, onChatClick: handleChatClick }) }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DOMProps, QAProps } from '@gravity-ui/uikit';
|
|
3
|
+
import { ChatType } from '../../../types';
|
|
4
|
+
import { ChatFilterFunction } from '../../../utils/chatUtils';
|
|
5
|
+
import './History.scss';
|
|
6
|
+
/**
|
|
7
|
+
* Props for the HistoryList component
|
|
8
|
+
*/
|
|
9
|
+
export interface HistoryListProps extends QAProps, DOMProps {
|
|
10
|
+
/** Array of chat items */
|
|
11
|
+
chats: ChatType[];
|
|
12
|
+
/** Currently selected chat */
|
|
13
|
+
selectedChat?: ChatType | null;
|
|
14
|
+
/** Callback when a chat is selected */
|
|
15
|
+
onSelectChat?: (chat: ChatType) => void;
|
|
16
|
+
/** Callback when a chat is deleted */
|
|
17
|
+
onDeleteChat?: (chat: ChatType) => void;
|
|
18
|
+
/** Callback to load more chats */
|
|
19
|
+
onLoadMore?: () => void;
|
|
20
|
+
/** Whether there are more chats to load */
|
|
21
|
+
hasMore?: boolean;
|
|
22
|
+
/** Enable search functionality */
|
|
23
|
+
searchable?: boolean;
|
|
24
|
+
/** Group chats by date or none */
|
|
25
|
+
groupBy?: 'date' | 'none';
|
|
26
|
+
/** Show action buttons (delete, etc.) */
|
|
27
|
+
showActions?: boolean;
|
|
28
|
+
/** Empty state placeholder */
|
|
29
|
+
emptyPlaceholder?: React.ReactNode;
|
|
30
|
+
/** Additional CSS class */
|
|
31
|
+
className?: string;
|
|
32
|
+
/** Custom filter function for search */
|
|
33
|
+
filterFunction?: ChatFilterFunction;
|
|
34
|
+
/** Callback when chat is clicked (for closing popup in parent) */
|
|
35
|
+
onChatClick?: (chat: ChatType) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* HistoryList component - displays a list of chats with search, grouping, and actions
|
|
39
|
+
*
|
|
40
|
+
* @param props - Component props
|
|
41
|
+
* @returns React component
|
|
42
|
+
*/
|
|
43
|
+
export declare function HistoryList(props: HistoryListProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Button, List } from '@gravity-ui/uikit';
|
|
4
|
+
import { defaultChatFilter, groupChatsByDate } from '../../../utils/chatUtils';
|
|
5
|
+
import { block } from '../../../utils/cn';
|
|
6
|
+
import { ChatItem } from './ChatItem';
|
|
7
|
+
import { DateHeaderItem } from './DateHeaderItem';
|
|
8
|
+
import { i18n } from './i18n';
|
|
9
|
+
import './History.scss';
|
|
10
|
+
const b = block('history');
|
|
11
|
+
/**
|
|
12
|
+
* HistoryList component - displays a list of chats with search, grouping, and actions
|
|
13
|
+
*
|
|
14
|
+
* @param props - Component props
|
|
15
|
+
* @returns React component
|
|
16
|
+
*/
|
|
17
|
+
export function HistoryList(props) {
|
|
18
|
+
const { chats, selectedChat, onSelectChat, onDeleteChat, onLoadMore, hasMore = false, searchable = true, groupBy = 'date', showActions = true, emptyPlaceholder, className, qa, style, filterFunction = defaultChatFilter, onChatClick, } = props;
|
|
19
|
+
// Group chats if needed
|
|
20
|
+
const groupedChats = useMemo(() => {
|
|
21
|
+
if (groupBy === 'none') {
|
|
22
|
+
return new Map([['all', chats]]);
|
|
23
|
+
}
|
|
24
|
+
return groupChatsByDate(chats);
|
|
25
|
+
}, [chats, groupBy]);
|
|
26
|
+
// Convert grouped chats to list items
|
|
27
|
+
const listItems = useMemo(() => {
|
|
28
|
+
const items = [];
|
|
29
|
+
// Sort groups by date (newest first)
|
|
30
|
+
const sortedGroups = Array.from(groupedChats.entries()).sort(([dateA], [dateB]) => {
|
|
31
|
+
if (dateA === 'all')
|
|
32
|
+
return 0;
|
|
33
|
+
return new Date(dateB).getTime() - new Date(dateA).getTime();
|
|
34
|
+
});
|
|
35
|
+
sortedGroups.forEach(([dateKey, groupChats]) => {
|
|
36
|
+
// Skip empty groups (important for filtering)
|
|
37
|
+
if (groupChats.length === 0) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
// Add date header for grouped view only if there are chats in this group
|
|
41
|
+
if (groupBy === 'date' && dateKey !== 'all') {
|
|
42
|
+
items.push({
|
|
43
|
+
type: 'date-header',
|
|
44
|
+
disabled: true,
|
|
45
|
+
date: dateKey,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
// Add chat items
|
|
49
|
+
groupChats.forEach((chat) => {
|
|
50
|
+
items.push(Object.assign({ type: 'chat' }, chat));
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
return items;
|
|
54
|
+
}, [groupedChats, groupBy]);
|
|
55
|
+
const selectedItemIndex = useMemo(() => {
|
|
56
|
+
return listItems.findIndex((item) => item.type === 'chat' && item.id === (selectedChat === null || selectedChat === void 0 ? void 0 : selectedChat.id));
|
|
57
|
+
}, [listItems, selectedChat]);
|
|
58
|
+
const handleChatClick = (chat) => {
|
|
59
|
+
onSelectChat === null || onSelectChat === void 0 ? void 0 : onSelectChat(chat);
|
|
60
|
+
onChatClick === null || onChatClick === void 0 ? void 0 : onChatClick(chat);
|
|
61
|
+
};
|
|
62
|
+
const handleDeleteClick = (e, chat) => {
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
onDeleteChat === null || onDeleteChat === void 0 ? void 0 : onDeleteChat(chat);
|
|
65
|
+
};
|
|
66
|
+
// Wrap filter function to hide date headers when filter is active
|
|
67
|
+
const wrappedFilterFunction = useMemo(() => {
|
|
68
|
+
return (filter) => {
|
|
69
|
+
const userFilter = filterFunction(filter);
|
|
70
|
+
return (item) => {
|
|
71
|
+
// Hide date headers when searching (they will be empty after chat filtering)
|
|
72
|
+
if (filter && item.type === 'date-header') {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return userFilter(item);
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}, [filterFunction]);
|
|
79
|
+
const renderItem = (item) => {
|
|
80
|
+
if (item.type === 'date-header') {
|
|
81
|
+
return _jsx(DateHeaderItem, { date: item.date }, `date-${item.date}`);
|
|
82
|
+
}
|
|
83
|
+
return (_jsx(ChatItem, { chat: item, showActions: showActions, onChatClick: handleChatClick, onDeleteClick: onDeleteChat ? handleDeleteClick : undefined }, item.id));
|
|
84
|
+
};
|
|
85
|
+
const emptyState = emptyPlaceholder || _jsx("div", { className: b('empty'), children: i18n('empty-state') });
|
|
86
|
+
return (_jsxs("div", { className: b('container', className), "data-qa": qa, style: style, children: [_jsx("div", { className: b('list-wrapper'), children: _jsx(List, { items: listItems, renderItem: renderItem, virtualized: false, filterable: searchable, filterItem: wrappedFilterFunction, filterPlaceholder: i18n('search-placeholder'), filterClassName: b('filter'), emptyPlaceholder: emptyState, selectedItemIndex: selectedItemIndex, itemsClassName: b('list'), itemClassName: b('list-item') }) }), hasMore && onLoadMore && (_jsx(Button, { view: "flat-action", size: "m", width: "max", onClick: onLoadMore, children: i18n('action-load-more') }))] }));
|
|
87
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { History } from '..';
|
|
3
|
+
declare const _default: Meta;
|
|
4
|
+
export default _default;
|
|
5
|
+
type Story = StoryObj<typeof History>;
|
|
6
|
+
export declare const Playground: Story;
|
|
7
|
+
export declare const WithSelectedChat: Story;
|
|
8
|
+
export declare const WithLoadMore: Story;
|
|
9
|
+
export declare const WithoutSearch: Story;
|
|
10
|
+
export declare const WithoutGrouping: Story;
|
|
11
|
+
export declare const WithoutActions: Story;
|
|
12
|
+
export declare const EmptyState: Story;
|
|
13
|
+
export declare const WithLoadMoreAndDelete: Story;
|
|
14
|
+
export declare const Interactive: Story;
|
|
15
|
+
export declare const WithCustomEmptyPlaceholder: Story;
|
|
16
|
+
export declare const WithCustomFilter: Story;
|
|
17
|
+
export declare const NotForceOpen: Story;
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useRef, useState } from 'react';
|
|
14
|
+
import { ClockArrowRotateLeft } from '@gravity-ui/icons';
|
|
15
|
+
import { Icon } from '@gravity-ui/uikit';
|
|
16
|
+
import { History } from '..';
|
|
17
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
18
|
+
import { ActionButton } from '../../../atoms/ActionButton';
|
|
19
|
+
import MDXDocs from './Docs.mdx';
|
|
20
|
+
export default {
|
|
21
|
+
title: 'templates/History',
|
|
22
|
+
component: History,
|
|
23
|
+
parameters: {
|
|
24
|
+
docs: {
|
|
25
|
+
page: MDXDocs,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
// Generate mock chats
|
|
30
|
+
const generateMockChats = (count) => {
|
|
31
|
+
const now = new Date();
|
|
32
|
+
const chats = [];
|
|
33
|
+
for (let i = 0; i < count; i++) {
|
|
34
|
+
const daysAgo = Math.floor(i / 3); // Group 3 chats per day
|
|
35
|
+
const date = new Date(now);
|
|
36
|
+
date.setDate(date.getDate() - daysAgo);
|
|
37
|
+
chats.push({
|
|
38
|
+
id: `chat-${i}`,
|
|
39
|
+
name: `Chat ${i + 1}`,
|
|
40
|
+
createTime: date.toISOString(),
|
|
41
|
+
lastMessage: i % 3 === 0
|
|
42
|
+
? `Looooooooong last message for example ellipsis from chat ${i + 1}`
|
|
43
|
+
: `Last message from chat ${i + 1}`,
|
|
44
|
+
metadata: {},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return chats;
|
|
48
|
+
};
|
|
49
|
+
const mockChats = generateMockChats(15);
|
|
50
|
+
function HistoryWithTrigger(_a) {
|
|
51
|
+
var { initialOpen = true } = _a, props = __rest(_a, ["initialOpen"]);
|
|
52
|
+
const [open, setOpen] = useState(initialOpen);
|
|
53
|
+
const anchorRef = useRef(null);
|
|
54
|
+
return (_jsxs("div", { style: { paddingLeft: '400px' }, children: [_jsx(ActionButton, { ref: anchorRef, view: "flat", size: "m", onClick: () => setOpen(!open), tooltipTitle: "Chat History", children: _jsx(Icon, { data: ClockArrowRotateLeft, size: 16 }) }), _jsx(History, Object.assign({}, props, { open: open, onOpenChange: setOpen, anchorElement: anchorRef.current }))] }));
|
|
55
|
+
}
|
|
56
|
+
const defaultDecorators = [
|
|
57
|
+
(Story) => (_jsx(ContentWrapper, { width: "600px", height: "800px", children: _jsx(Story, {}) })),
|
|
58
|
+
];
|
|
59
|
+
export const Playground = {
|
|
60
|
+
args: {
|
|
61
|
+
chats: mockChats,
|
|
62
|
+
searchable: true,
|
|
63
|
+
groupBy: 'date',
|
|
64
|
+
showActions: true,
|
|
65
|
+
onSelectChat: (chat) => {
|
|
66
|
+
// eslint-disable-next-line no-console
|
|
67
|
+
console.log('Selected chat:', chat);
|
|
68
|
+
},
|
|
69
|
+
onDeleteChat: (chat) => {
|
|
70
|
+
// eslint-disable-next-line no-console
|
|
71
|
+
console.log('Delete chat:', chat);
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
render: (args) => _jsx(HistoryWithTrigger, Object.assign({}, args)),
|
|
75
|
+
decorators: defaultDecorators,
|
|
76
|
+
};
|
|
77
|
+
export const WithSelectedChat = {
|
|
78
|
+
args: {
|
|
79
|
+
chats: mockChats,
|
|
80
|
+
selectedChat: mockChats[2],
|
|
81
|
+
searchable: true,
|
|
82
|
+
groupBy: 'date',
|
|
83
|
+
showActions: true,
|
|
84
|
+
onSelectChat: (chat) => {
|
|
85
|
+
// eslint-disable-next-line no-console
|
|
86
|
+
console.log('Selected chat:', chat);
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
render: (args) => _jsx(HistoryWithTrigger, Object.assign({}, args)),
|
|
90
|
+
decorators: defaultDecorators,
|
|
91
|
+
};
|
|
92
|
+
export const WithLoadMore = {
|
|
93
|
+
args: {
|
|
94
|
+
searchable: true,
|
|
95
|
+
groupBy: 'date',
|
|
96
|
+
showActions: true,
|
|
97
|
+
onSelectChat: (chat) => {
|
|
98
|
+
// eslint-disable-next-line no-console
|
|
99
|
+
console.log('Selected chat:', chat);
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
render: (args) => {
|
|
103
|
+
const [chats, setChats] = useState(mockChats.slice(0, 6));
|
|
104
|
+
const [hasMore, setHasMore] = useState(true);
|
|
105
|
+
const handleLoadMore = () => {
|
|
106
|
+
// eslint-disable-next-line no-console
|
|
107
|
+
console.log('Loading more chats...');
|
|
108
|
+
const currentLength = chats.length;
|
|
109
|
+
const nextChats = mockChats.slice(0, currentLength + 6);
|
|
110
|
+
setChats(nextChats);
|
|
111
|
+
if (nextChats.length >= mockChats.length) {
|
|
112
|
+
setHasMore(false);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
return (_jsx(HistoryWithTrigger, Object.assign({}, args, { chats: chats, hasMore: hasMore, onLoadMore: handleLoadMore })));
|
|
116
|
+
},
|
|
117
|
+
decorators: defaultDecorators,
|
|
118
|
+
};
|
|
119
|
+
export const WithoutSearch = {
|
|
120
|
+
args: {
|
|
121
|
+
chats: mockChats,
|
|
122
|
+
searchable: false,
|
|
123
|
+
groupBy: 'date',
|
|
124
|
+
showActions: true,
|
|
125
|
+
onSelectChat: (chat) => {
|
|
126
|
+
// eslint-disable-next-line no-console
|
|
127
|
+
console.log('Selected chat:', chat);
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
render: (args) => _jsx(HistoryWithTrigger, Object.assign({}, args)),
|
|
131
|
+
decorators: defaultDecorators,
|
|
132
|
+
};
|
|
133
|
+
export const WithoutGrouping = {
|
|
134
|
+
args: {
|
|
135
|
+
chats: mockChats,
|
|
136
|
+
searchable: true,
|
|
137
|
+
groupBy: 'none',
|
|
138
|
+
showActions: true,
|
|
139
|
+
onSelectChat: (chat) => {
|
|
140
|
+
// eslint-disable-next-line no-console
|
|
141
|
+
console.log('Selected chat:', chat);
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
render: (args) => _jsx(HistoryWithTrigger, Object.assign({}, args)),
|
|
145
|
+
decorators: defaultDecorators,
|
|
146
|
+
};
|
|
147
|
+
export const WithoutActions = {
|
|
148
|
+
args: {
|
|
149
|
+
chats: mockChats,
|
|
150
|
+
searchable: true,
|
|
151
|
+
groupBy: 'date',
|
|
152
|
+
showActions: false,
|
|
153
|
+
onSelectChat: (chat) => {
|
|
154
|
+
// eslint-disable-next-line no-console
|
|
155
|
+
console.log('Selected chat:', chat);
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
render: (args) => _jsx(HistoryWithTrigger, Object.assign({}, args)),
|
|
159
|
+
decorators: defaultDecorators,
|
|
160
|
+
};
|
|
161
|
+
export const EmptyState = {
|
|
162
|
+
args: {
|
|
163
|
+
chats: [],
|
|
164
|
+
searchable: true,
|
|
165
|
+
groupBy: 'date',
|
|
166
|
+
showActions: true,
|
|
167
|
+
},
|
|
168
|
+
render: (args) => _jsx(HistoryWithTrigger, Object.assign({}, args)),
|
|
169
|
+
decorators: defaultDecorators,
|
|
170
|
+
};
|
|
171
|
+
export const WithLoadMoreAndDelete = {
|
|
172
|
+
args: {
|
|
173
|
+
chats: mockChats,
|
|
174
|
+
searchable: true,
|
|
175
|
+
groupBy: 'date',
|
|
176
|
+
showActions: true,
|
|
177
|
+
hasMore: true,
|
|
178
|
+
onSelectChat: (chat) => {
|
|
179
|
+
// eslint-disable-next-line no-console
|
|
180
|
+
console.log('Selected chat:', chat);
|
|
181
|
+
},
|
|
182
|
+
onDeleteChat: (chat) => {
|
|
183
|
+
// eslint-disable-next-line no-console
|
|
184
|
+
console.log('Delete chat:', chat);
|
|
185
|
+
},
|
|
186
|
+
onLoadMore: () => {
|
|
187
|
+
// eslint-disable-next-line no-console
|
|
188
|
+
console.log('Load more chats');
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
render: (args) => _jsx(HistoryWithTrigger, Object.assign({}, args)),
|
|
192
|
+
decorators: defaultDecorators,
|
|
193
|
+
};
|
|
194
|
+
export const Interactive = {
|
|
195
|
+
args: {
|
|
196
|
+
searchable: true,
|
|
197
|
+
groupBy: 'date',
|
|
198
|
+
showActions: true,
|
|
199
|
+
},
|
|
200
|
+
render: (args) => {
|
|
201
|
+
const [chats, setChats] = useState(mockChats);
|
|
202
|
+
const [selectedChat, setSelectedChat] = useState(null);
|
|
203
|
+
const handleDeleteChat = (chat) => {
|
|
204
|
+
setChats((prev) => prev.filter((c) => c.id !== chat.id));
|
|
205
|
+
if ((selectedChat === null || selectedChat === void 0 ? void 0 : selectedChat.id) === chat.id) {
|
|
206
|
+
setSelectedChat(null);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
return (_jsx(HistoryWithTrigger, Object.assign({}, args, { chats: chats, selectedChat: selectedChat, onSelectChat: setSelectedChat, onDeleteChat: handleDeleteChat })));
|
|
210
|
+
},
|
|
211
|
+
decorators: defaultDecorators,
|
|
212
|
+
};
|
|
213
|
+
export const WithCustomEmptyPlaceholder = {
|
|
214
|
+
args: {
|
|
215
|
+
chats: [],
|
|
216
|
+
searchable: true,
|
|
217
|
+
groupBy: 'date',
|
|
218
|
+
showActions: true,
|
|
219
|
+
emptyPlaceholder: (_jsxs("div", { style: {
|
|
220
|
+
padding: '40px',
|
|
221
|
+
color: '#999',
|
|
222
|
+
width: '100%',
|
|
223
|
+
display: 'flex',
|
|
224
|
+
flexDirection: 'column',
|
|
225
|
+
alignItems: 'center',
|
|
226
|
+
justifyContent: 'center',
|
|
227
|
+
}, children: [_jsx("div", { style: {
|
|
228
|
+
fontSize: '48px',
|
|
229
|
+
height: '48px',
|
|
230
|
+
display: 'flex',
|
|
231
|
+
alignItems: 'center',
|
|
232
|
+
justifyContent: 'center',
|
|
233
|
+
marginBottom: '16px',
|
|
234
|
+
}, children: "\uD83D\uDCAC" }), _jsx("div", { style: {
|
|
235
|
+
fontSize: '16px',
|
|
236
|
+
fontWeight: 'bold',
|
|
237
|
+
marginBottom: '8px',
|
|
238
|
+
}, children: "No conversations yet" }), _jsx("div", { style: { fontSize: '14px' }, children: "Start a new chat to begin" })] })),
|
|
239
|
+
},
|
|
240
|
+
render: (args) => _jsx(HistoryWithTrigger, Object.assign({}, args)),
|
|
241
|
+
decorators: defaultDecorators,
|
|
242
|
+
};
|
|
243
|
+
export const WithCustomFilter = {
|
|
244
|
+
args: {
|
|
245
|
+
chats: mockChats,
|
|
246
|
+
searchable: true,
|
|
247
|
+
groupBy: 'date',
|
|
248
|
+
showActions: true,
|
|
249
|
+
onSelectChat: (chat) => {
|
|
250
|
+
// eslint-disable-next-line no-console
|
|
251
|
+
console.log('Selected chat:', chat);
|
|
252
|
+
},
|
|
253
|
+
// Custom filter that searches only in chat names (not in messages)
|
|
254
|
+
filterFunction: (filter) => (item) => {
|
|
255
|
+
if (item.type === 'date-header') {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
return item.name.toLowerCase().includes(filter.toLowerCase());
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
render: (args) => _jsx(HistoryWithTrigger, Object.assign({}, args)),
|
|
262
|
+
decorators: defaultDecorators,
|
|
263
|
+
};
|
|
264
|
+
export const NotForceOpen = {
|
|
265
|
+
args: {
|
|
266
|
+
chats: mockChats,
|
|
267
|
+
searchable: true,
|
|
268
|
+
groupBy: 'date',
|
|
269
|
+
showActions: true,
|
|
270
|
+
onSelectChat: (chat) => {
|
|
271
|
+
// eslint-disable-next-line no-console
|
|
272
|
+
console.log('Selected chat:', chat);
|
|
273
|
+
},
|
|
274
|
+
onDeleteChat: (chat) => {
|
|
275
|
+
// eslint-disable-next-line no-console
|
|
276
|
+
console.log('Delete chat:', chat);
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
render: (args) => _jsx(HistoryWithTrigger, Object.assign({ initialOpen: false }, args)),
|
|
280
|
+
decorators: defaultDecorators,
|
|
281
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const i18n: ((key: "action-load-more" | "search-placeholder" | "empty-state" | "tooltip-history" | "tooltip-delete", params?: import("@gravity-ui/i18n").Params) => string) & {
|
|
2
|
+
Translation: import("react").ComponentType<{
|
|
3
|
+
children: (props: {
|
|
4
|
+
t: (key: "action-load-more" | "search-placeholder" | "empty-state" | "tooltip-history" | "tooltip-delete", params?: import("@gravity-ui/i18n").Params) => string;
|
|
5
|
+
}) => React.ReactNode;
|
|
6
|
+
}>;
|
|
7
|
+
useTranslation: () => {
|
|
8
|
+
t: (key: "action-load-more" | "search-placeholder" | "empty-state" | "tooltip-history" | "tooltip-delete", params?: import("@gravity-ui/i18n").Params) => string;
|
|
9
|
+
};
|
|
10
|
+
keysetData: {
|
|
11
|
+
"g-aikit-History": Record<"action-load-more" | "search-placeholder" | "empty-state" | "tooltip-history" | "tooltip-delete", import("@gravity-ui/i18n").KeyData>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { History } from './History';
|
|
2
|
+
export type { HistoryProps } from './History';
|
|
3
|
+
export { HistoryList } from './HistoryList';
|
|
4
|
+
export type { HistoryListProps } from './HistoryList';
|
|
5
|
+
export { ChatItem } from './ChatItem';
|
|
6
|
+
export type { ChatItemProps } from './ChatItem';
|
|
7
|
+
export { DateHeaderItem } from './DateHeaderItem';
|
|
8
|
+
export type { DateHeaderItemProps } from './DateHeaderItem';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RELATIVE_DATE_THRESHOLD = 7;
|