@agentscope-ai/chat 1.1.20 → 1.1.22
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/bin/client.js +1 -1
- package/components/AGUI/components/HelpModal/icons.tsx +68 -0
- package/components/AGUI/components/HelpModal/index.tsx +1 -0
- package/components/AGUI/components/HelpModal/modal.tsx +101 -0
- package/components/AGUI/components/chat/Button.tsx +18 -0
- package/components/AGUI/components/chat/Chat.tsx +780 -0
- package/components/AGUI/components/chat/ChatContext.tsx +248 -0
- package/components/AGUI/components/chat/CodeBlock.tsx +406 -0
- package/components/AGUI/components/chat/Header.tsx +22 -0
- package/components/AGUI/components/chat/Icons.tsx +237 -0
- package/components/AGUI/components/chat/ImageUploadQueue.tsx +77 -0
- package/components/AGUI/components/chat/Input.tsx +24 -0
- package/components/AGUI/components/chat/Markdown.tsx +134 -0
- package/components/AGUI/components/chat/Messages.tsx +259 -0
- package/components/AGUI/components/chat/Modal.tsx +133 -0
- package/components/AGUI/components/chat/Popup.tsx +57 -0
- package/components/AGUI/components/chat/PoweredByTag.tsx +29 -0
- package/components/AGUI/components/chat/Sidebar.tsx +74 -0
- package/components/AGUI/components/chat/Suggestion.tsx +132 -0
- package/components/AGUI/components/chat/Suggestions.tsx +20 -0
- package/components/AGUI/components/chat/Textarea.tsx +61 -0
- package/components/AGUI/components/chat/Window.tsx +152 -0
- package/components/AGUI/components/chat/index.tsx +11 -0
- package/components/AGUI/components/chat/messages/AssistantMessage.tsx +69 -0
- package/components/AGUI/components/chat/messages/RenderActionExecutionMessage.tsx +129 -0
- package/components/AGUI/components/chat/messages/RenderAgentStateMessage.tsx +116 -0
- package/components/AGUI/components/chat/messages/RenderImageMessage.tsx +64 -0
- package/components/AGUI/components/chat/messages/RenderResultMessage.tsx +26 -0
- package/components/AGUI/components/chat/messages/RenderTextMessage.tsx +51 -0
- package/components/AGUI/components/chat/messages/UserMessage.tsx +10 -0
- package/components/AGUI/components/chat/props.ts +186 -0
- package/components/AGUI/components/index.ts +1 -0
- package/components/AGUI/context/index.ts +1 -0
- package/components/AGUI/hooks/index.ts +1 -0
- package/components/AGUI/hooks/use-copilot-chat-suggestions.tsx +122 -0
- package/components/AGUI/hooks/use-copy-to-clipboard.tsx +29 -0
- package/components/AGUI/hooks/use-dark-mode.ts +10 -0
- package/components/AGUI/hooks/use-push-to-talk.tsx +166 -0
- package/components/AGUI/index.tsx +4 -0
- package/components/AGUI/lib/utils.test.ts +7 -0
- package/components/AGUI/lib/utils.ts +27 -0
- package/components/AGUI/styles.css +0 -0
- package/components/AGUI/types/css.ts +0 -0
- package/components/AGUI/types/index.ts +1 -0
- package/components/AGUI/types/suggestions.ts +6 -0
- package/components/Accordion/Accordion.tsx +203 -0
- package/components/Accordion/BodyContent.tsx +28 -0
- package/components/Accordion/DeepThinking.tsx +91 -0
- package/components/Accordion/SoftLightTitle.tsx +13 -0
- package/components/Accordion/demo/search.tsx +39 -0
- package/components/Accordion/demo/steps.tsx +135 -0
- package/components/Accordion/demo/thinking.tsx +62 -0
- package/components/Accordion/index.en-US.md +34 -0
- package/components/Accordion/index.tsx +3 -0
- package/components/Accordion/index.zh-CN.md +34 -0
- package/components/Accordion/style.ts +208 -0
- package/components/AgentScopeRuntimeWebUI/demo/index.tsx +4 -0
- package/components/AgentScopeRuntimeWebUI/index.tsx +3 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Builder.tsx +82 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Card.tsx +52 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Actions.tsx +39 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Builder.tsx +205 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Card.tsx +44 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Error.tsx +7 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Message.tsx +23 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Reasoning.tsx +16 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Tool.tsx +19 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/index.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/types.tsx +100 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Input/index.tsx +77 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Input/useAttachments.tsx +53 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/MessageList/index.tsx +30 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Welcome/index.tsx +66 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Welcome/styles.ts +51 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/index.tsx +5 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatController.tsx +130 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatMessageHandler.tsx +87 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatRequest.tsx +114 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatSessionHandler.tsx +50 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/index.tsx +18 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/styles.tsx +59 -0
- package/components/AgentScopeRuntimeWebUI/lib/ChatAnywhere/ComposedProvider.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/ChatAnywhere/index.tsx +29 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereControl.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereInputContext.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereLayoutContext.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereMessagesContext.tsx +82 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereOptionsContext.tsx +76 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereSessionsContext.tsx +111 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/useChatAnywhereEventEmitter.tsx +30 -0
- package/components/AgentScopeRuntimeWebUI/lib/Header/index.tsx +45 -0
- package/components/AgentScopeRuntimeWebUI/lib/Header/styles.ts +23 -0
- package/components/AgentScopeRuntimeWebUI/lib/Layout/index.tsx +45 -0
- package/components/AgentScopeRuntimeWebUI/lib/Layout/styles.tsx +104 -0
- package/components/AgentScopeRuntimeWebUI/lib/Sessions/index.tsx +114 -0
- package/components/AgentScopeRuntimeWebUI/lib/Sessions/styles.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/FormItem.tsx +37 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/OptionsEditor.tsx +163 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/defaultConfig.ts +43 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/index.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/index.tsx +57 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/sessionApi/index.ts +51 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/IChatAnywhere.ts +358 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/IMessages.tsx +52 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/ISessions.tsx +29 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/index.tsx +3 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/FormItem.tsx +37 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/OptionsEditor.tsx +163 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/defaultConfig.ts +43 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/index.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/starter/index.tsx +57 -0
- package/components/AgentScopeRuntimeWebUI/starter/sessionApi/index.ts +51 -0
- package/components/Attachments/DropArea.tsx +97 -0
- package/components/Attachments/FileList/AudioIcon.tsx +20 -0
- package/components/Attachments/FileList/FileListCard.tsx +270 -0
- package/components/Attachments/FileList/Progress.tsx +30 -0
- package/components/Attachments/FileList/VideoIcon.tsx +20 -0
- package/components/Attachments/FileList/index.tsx +201 -0
- package/components/Attachments/PlaceholderUploader.tsx +124 -0
- package/components/Attachments/SilentUploader.tsx +39 -0
- package/components/Attachments/context.tsx +11 -0
- package/components/Attachments/demo/basic.tsx +71 -0
- package/components/Attachments/index.en-US.md.bk +10 -0
- package/components/Attachments/index.tsx +274 -0
- package/components/Attachments/index.zh-CN.md.bk +10 -0
- package/components/Attachments/style/fileCard.ts +163 -0
- package/components/Attachments/style/index.ts +232 -0
- package/components/Attachments/util.ts +56 -0
- package/components/Bubble/Avatar.tsx +39 -0
- package/components/Bubble/Bubble.tsx +131 -0
- package/components/Bubble/BubbleList.tsx +105 -0
- package/components/Bubble/Cards.tsx +61 -0
- package/components/Bubble/Footer.tsx +55 -0
- package/components/Bubble/Interrupted.tsx +82 -0
- package/components/Bubble/ScrollToBottom.tsx +42 -0
- package/components/Bubble/Spin.tsx +13 -0
- package/components/Bubble/demo/assistantWithCode.tsx +60 -0
- package/components/Bubble/demo/assistantWithErrorStatus.tsx +102 -0
- package/components/Bubble/demo/assistantWithImage.tsx +46 -0
- package/components/Bubble/demo/assistantWithProcess.tsx +103 -0
- package/components/Bubble/demo/assistantWithSearch.tsx +69 -0
- package/components/Bubble/demo/assistantWithThinking.tsx +54 -0
- package/components/Bubble/demo/basic.tsx +55 -0
- package/components/Bubble/demo/userWithFile.tsx +27 -0
- package/components/Bubble/demo/userWithImage.tsx +26 -0
- package/components/Bubble/hooks/useDisplayData.ts +0 -0
- package/components/Bubble/hooks/useListData.ts +0 -0
- package/components/Bubble/index.en-US.md +33 -0
- package/components/Bubble/index.tsx +21 -0
- package/components/Bubble/index.zh-CN.md +33 -0
- package/components/Bubble/interface.ts +71 -0
- package/components/Bubble/loading.tsx +15 -0
- package/components/Bubble/style/avatar.ts +43 -0
- package/components/Bubble/style/footer.ts +45 -0
- package/components/Bubble/style/index.ts +192 -0
- package/components/Bubble/style/list.ts +51 -0
- package/components/ChatAnywhere/Chat/Ref.tsx +20 -0
- package/components/ChatAnywhere/Chat/index.tsx +56 -0
- package/components/ChatAnywhere/Chat/style.ts +59 -0
- package/components/ChatAnywhere/Header/index.tsx +37 -0
- package/components/ChatAnywhere/Header/style.ts +27 -0
- package/components/ChatAnywhere/Input/index.tsx +158 -0
- package/components/ChatAnywhere/Input/style.ts +14 -0
- package/components/ChatAnywhere/Layout/index.tsx +70 -0
- package/components/ChatAnywhere/Layout/style.ts +51 -0
- package/components/ChatAnywhere/SessionList/index.tsx +122 -0
- package/components/ChatAnywhere/SessionList/style.ts +53 -0
- package/components/ChatAnywhere/hooks/ChatAnywhereProvider.tsx +219 -0
- package/components/ChatAnywhere/hooks/types.ts +333 -0
- package/components/ChatAnywhere/hooks/useInput.tsx +22 -0
- package/components/ChatAnywhere/hooks/useMessages.tsx +63 -0
- package/components/ChatAnywhere/hooks/useSessionList.tsx +123 -0
- package/components/ChatAnywhere/index.tsx +49 -0
- package/components/Conversations/GroupTitle.tsx +28 -0
- package/components/Conversations/Item.tsx +189 -0
- package/components/Conversations/demo/basic.tsx +107 -0
- package/components/Conversations/demo/timeline.tsx +111 -0
- package/components/Conversations/demo/timestamp.tsx +110 -0
- package/components/Conversations/hooks/useGroupable.ts +81 -0
- package/components/Conversations/index.en-US.md +32 -0
- package/components/Conversations/index.tsx +176 -0
- package/components/Conversations/index.zh-CN.md +31 -0
- package/components/Conversations/interface.ts +69 -0
- package/components/Conversations/style.ts +153 -0
- package/components/DefaultCards/DeepThinking/index.tsx +33 -0
- package/components/DefaultCards/Files/index.tsx +69 -0
- package/components/DefaultCards/Footer/index.tsx +16 -0
- package/components/DefaultCards/Images/index.tsx +53 -0
- package/components/DefaultCards/Interrupted/index.tsx +13 -0
- package/components/DefaultCards/Text/index.tsx +13 -0
- package/components/DefaultCards/index.tsx +6 -0
- package/components/DeviceAction/actionMap.tsx +100 -0
- package/components/DeviceAction/demo/index.tsx +132 -0
- package/components/DeviceAction/index.en-US.md +19 -0
- package/components/DeviceAction/index.tsx +75 -0
- package/components/DeviceAction/index.zh-CN.md +19 -0
- package/components/Disclaimer/demo/index.tsx +4 -0
- package/components/Disclaimer/demo/withLink.tsx +4 -0
- package/components/Disclaimer/index.en-US.md +23 -0
- package/components/Disclaimer/index.tsx +42 -0
- package/components/Disclaimer/index.zh-CN.md +24 -0
- package/components/Disclaimer/style.ts +17 -0
- package/components/ImageGenerator/demo/basic.tsx +23 -0
- package/components/ImageGenerator/demo/custom.tsx +56 -0
- package/components/ImageGenerator/demo/size.tsx +15 -0
- package/components/ImageGenerator/index.en-US.md +23 -0
- package/components/ImageGenerator/index.tsx +124 -0
- package/components/ImageGenerator/index.zh-CN.md +23 -0
- package/components/ImageGenerator/style.ts +99 -0
- package/components/Markdown/Markdown/AnimationNode.tsx +89 -0
- package/components/Markdown/Markdown/Markdown.tsx +61 -0
- package/components/Markdown/Markdown/core/Parser.ts +52 -0
- package/components/Markdown/Markdown/core/Renderer.ts +121 -0
- package/components/Markdown/Markdown/core/index.ts +4 -0
- package/components/Markdown/Markdown/defaultComponents/CodeBlock.tsx +113 -0
- package/components/Markdown/Markdown/defaultComponents/DisabledImage.tsx +3 -0
- package/components/Markdown/Markdown/defaultComponents/Media.tsx +71 -0
- package/components/Markdown/Markdown/hooks/index.ts +4 -0
- package/components/Markdown/Markdown/hooks/useAnimation.tsx +27 -0
- package/components/Markdown/Markdown/hooks/useCitationsData.tsx +36 -0
- package/components/Markdown/Markdown/hooks/useStreaming.ts +503 -0
- package/components/Markdown/Markdown/hooks/useTyping.ts +22 -0
- package/components/Markdown/Markdown/index.tsx +198 -0
- package/components/Markdown/Markdown/interface.ts +217 -0
- package/components/Markdown/Markdown/style.ts +152 -0
- package/components/Markdown/demo/basic.tsx +107 -0
- package/components/Markdown/demo/citations.tsx +47 -0
- package/components/Markdown/demo/cursor.tsx +9 -0
- package/components/Markdown/demo/latex.tsx +77 -0
- package/components/Markdown/demo/typing.tsx +82 -0
- package/components/Markdown/index.en-US.md +27 -0
- package/components/Markdown/index.ts +1 -0
- package/components/Markdown/index.zh-CN.md +28 -0
- package/components/Markdown/plugins/citations/CitationComponent.tsx +72 -0
- package/components/Markdown/plugins/citations/index.tsx +37 -0
- package/components/Markdown/plugins/cursor/Dot.tsx +106 -0
- package/components/Markdown/plugins/cursor/Underline.tsx +38 -0
- package/components/Markdown/plugins/cursor/index.tsx +59 -0
- package/components/Markdown/plugins/latex/index.ts +109 -0
- package/components/Markdown/plugins/type.ts +71 -0
- package/components/Mermaid/demo/basic.tsx +12 -0
- package/components/Mermaid/demo/class.tsx +31 -0
- package/components/Mermaid/demo/flowchart.tsx +13 -0
- package/components/Mermaid/demo/sequence.tsx +18 -0
- package/components/Mermaid/demo/state.tsx +16 -0
- package/components/Mermaid/demo/timeline.tsx +15 -0
- package/components/Mermaid/index.en-US.md +27 -0
- package/components/Mermaid/index.tsx +118 -0
- package/components/Mermaid/index.zh-CN.md +27 -0
- package/components/OperateCard/OperateCard.tsx +93 -0
- package/components/OperateCard/demo/index.tsx +35 -0
- package/components/OperateCard/demo/rag.tsx +19 -0
- package/components/OperateCard/demo/thinking.tsx +17 -0
- package/components/OperateCard/demo/todo.tsx +28 -0
- package/components/OperateCard/demo/toolCall.tsx +14 -0
- package/components/OperateCard/demo/webSearch.tsx +12 -0
- package/components/OperateCard/index.en-US.md +51 -0
- package/components/OperateCard/index.tsx +1 -0
- package/components/OperateCard/index.zh-CN.md +51 -0
- package/components/OperateCard/preset/Rag.tsx +90 -0
- package/components/OperateCard/preset/Thinking.tsx +45 -0
- package/components/OperateCard/preset/TodoList.tsx +73 -0
- package/components/OperateCard/preset/ToolCall.tsx +67 -0
- package/components/OperateCard/preset/WebSearch.tsx +65 -0
- package/components/OperateCard/preset/index.tsx +5 -0
- package/components/OperateCard/style.ts +268 -0
- package/components/Provider/CustomCardsProvider.tsx +17 -0
- package/components/Provider/GlobalProvider.tsx +17 -0
- package/components/Provider/index.tsx +33 -0
- package/components/Provider/types.ts +23 -0
- package/components/ResponsesAPI/index.tsx +0 -0
- package/components/Sender/ModeSelect/index.tsx +160 -0
- package/components/Sender/ModeSelect/styles.ts +0 -0
- package/components/Sender/SenderHeader.tsx +164 -0
- package/components/Sender/StopLoading.tsx +48 -0
- package/components/Sender/components/ActionButton.tsx +106 -0
- package/components/Sender/components/ClearButton.tsx +10 -0
- package/components/Sender/components/LoadingButton.tsx +26 -0
- package/components/Sender/components/SendButton.tsx +22 -0
- package/components/Sender/components/SpeechButton/RecordingIcon.tsx +68 -0
- package/components/Sender/components/SpeechButton/index.tsx +30 -0
- package/components/Sender/demo/asr.tsx +7 -0
- package/components/Sender/demo/basic.tsx +7 -0
- package/components/Sender/demo/loading.tsx +5 -0
- package/components/Sender/demo/moreMode.tsx +45 -0
- package/components/Sender/demo/morePrefixAction.tsx +40 -0
- package/components/Sender/demo/withFile.tsx +54 -0
- package/components/Sender/demo/withImage.tsx +52 -0
- package/components/Sender/index.en-US.md +29 -0
- package/components/Sender/index.tsx +491 -0
- package/components/Sender/index.zh-CN.md +30 -0
- package/components/Sender/style/index.ts +150 -0
- package/components/Sender/useSpeech.ts +133 -0
- package/components/StatusCard/demo/index.tsx +32 -0
- package/components/StatusCard/index.en-US.md +30 -0
- package/components/StatusCard/index.tsx +162 -0
- package/components/StatusCard/index.zh-CN.md +27 -0
- package/components/StatusCard/style.ts +119 -0
- package/components/Stream/index.ts +203 -0
- package/components/Util/hooks/use-proxy-imperative-handle.ts +25 -0
- package/components/Util/sleep.ts +3 -0
- package/components/Util/type.ts +1 -0
- package/components/Util/warning.ts +118 -0
- package/components/Version/index.ts +3 -0
- package/components/Voice/Recorder.tsx +3 -0
- package/components/Voice/demo/index.tsx +0 -0
- package/components/Voice/index.en-US.md +8 -0
- package/components/Voice/index.tsx +0 -0
- package/components/Voice/index.zh-CN.md +9 -0
- package/components/Welcome/demo/EyeFollower.tsx +161 -0
- package/components/Welcome/demo/demo0.tsx +14 -0
- package/components/Welcome/demo/demo1.tsx +16 -0
- package/components/Welcome/demo/demo2.tsx +30 -0
- package/components/Welcome/demo/demo3.tsx +16 -0
- package/components/Welcome/index.en-US.md +28 -0
- package/components/Welcome/index.tsx +72 -0
- package/components/Welcome/index.zh-CN.md +28 -0
- package/components/index.ts +88 -0
- package/components/overview.en-US.md +10 -0
- package/components/overview.zh-CN.md +10 -0
- package/lib/AgentScopeRuntimeWebUI/index.d.ts +1 -0
- package/lib/AgentScopeRuntimeWebUI/index.js +1 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/FormItem.d.ts +9 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/FormItem.js +33 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/OptionsEditor.d.ts +7 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/OptionsEditor.js +188 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/defaultConfig.d.ts +29 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/defaultConfig.js +35 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/index.d.ts +6 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/index.js +49 -0
- package/lib/AgentScopeRuntimeWebUI/starter/index.d.ts +1 -0
- package/lib/AgentScopeRuntimeWebUI/starter/index.js +70 -0
- package/lib/AgentScopeRuntimeWebUI/starter/sessionApi/index.d.ts +14 -0
- package/lib/AgentScopeRuntimeWebUI/starter/sessionApi/index.js +143 -0
- package/package.json +3 -2
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { LeftOutlined, RightOutlined } from '@ant-design/icons';
|
|
2
|
+
import { Button, type UploadProps } from 'antd';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { CSSMotionList } from 'rc-motion';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { Attachment } from '..';
|
|
7
|
+
import FileListCard from './FileListCard';
|
|
8
|
+
|
|
9
|
+
export interface FileListProps {
|
|
10
|
+
/**
|
|
11
|
+
* @description 自定义CSS类名前缀,用于样式隔离和主题定制
|
|
12
|
+
* @descriptionEn Custom CSS class name prefix for style isolation and theme customization
|
|
13
|
+
*/
|
|
14
|
+
prefixCls: string;
|
|
15
|
+
/**
|
|
16
|
+
* @description 文件附件数据数组,包含所有要显示的文件信息
|
|
17
|
+
* @descriptionEn File attachment data array containing all file information to display
|
|
18
|
+
*/
|
|
19
|
+
items: Attachment[];
|
|
20
|
+
/**
|
|
21
|
+
* @description 文件移除时的回调函数,用于处理文件删除操作
|
|
22
|
+
* @descriptionEn Callback function when file is removed for handling file deletion operations
|
|
23
|
+
*/
|
|
24
|
+
onRemove: (item: Attachment) => void;
|
|
25
|
+
/**
|
|
26
|
+
* @description 文件列表的溢出处理方式,影响滚动和布局行为
|
|
27
|
+
* @descriptionEn Overflow handling method for file list, affects scrolling and layout behavior
|
|
28
|
+
*/
|
|
29
|
+
overflow?: 'scrollX' | 'scrollY' | 'wrap';
|
|
30
|
+
/**
|
|
31
|
+
* @description 上传组件的属性配置,用于控制上传行为
|
|
32
|
+
* @descriptionEn Upload component props configuration for controlling upload behavior
|
|
33
|
+
*/
|
|
34
|
+
upload: UploadProps;
|
|
35
|
+
|
|
36
|
+
// Semantic
|
|
37
|
+
/**
|
|
38
|
+
* @description 文件列表容器的CSS类名
|
|
39
|
+
* @descriptionEn CSS class name for the file list container
|
|
40
|
+
*/
|
|
41
|
+
listClassName?: string;
|
|
42
|
+
/**
|
|
43
|
+
* @description 文件列表容器的内联样式对象
|
|
44
|
+
* @descriptionEn Inline style object for the file list container
|
|
45
|
+
*/
|
|
46
|
+
listStyle?: React.CSSProperties;
|
|
47
|
+
/**
|
|
48
|
+
* @description 文件列表项的CSS类名
|
|
49
|
+
* @descriptionEn CSS class name for file list items
|
|
50
|
+
*/
|
|
51
|
+
itemClassName?: string;
|
|
52
|
+
/**
|
|
53
|
+
* @description 文件列表项的内联样式对象
|
|
54
|
+
* @descriptionEn Inline style object for file list items
|
|
55
|
+
*/
|
|
56
|
+
itemStyle?: React.CSSProperties;
|
|
57
|
+
/**
|
|
58
|
+
* @description 渲染类型,目前仅支持默认渲染模式
|
|
59
|
+
* @descriptionEn Render type, currently only supports default render mode
|
|
60
|
+
*/
|
|
61
|
+
renderType?: 'default',
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const TOLERANCE = 1;
|
|
65
|
+
|
|
66
|
+
export default function FileList(props: FileListProps) {
|
|
67
|
+
const {
|
|
68
|
+
prefixCls,
|
|
69
|
+
items,
|
|
70
|
+
onRemove,
|
|
71
|
+
overflow,
|
|
72
|
+
listClassName,
|
|
73
|
+
listStyle,
|
|
74
|
+
itemClassName,
|
|
75
|
+
itemStyle,
|
|
76
|
+
} = props;
|
|
77
|
+
|
|
78
|
+
const listCls = `${prefixCls}-list`;
|
|
79
|
+
|
|
80
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
81
|
+
|
|
82
|
+
const [firstMount, setFirstMount] = React.useState(false);
|
|
83
|
+
|
|
84
|
+
React.useEffect(() => {
|
|
85
|
+
setFirstMount(true);
|
|
86
|
+
return () => {
|
|
87
|
+
setFirstMount(false);
|
|
88
|
+
};
|
|
89
|
+
}, []);
|
|
90
|
+
|
|
91
|
+
// ================================= Scroll =================================
|
|
92
|
+
const [pingStart, setPingStart] = React.useState(false);
|
|
93
|
+
const [pingEnd, setPingEnd] = React.useState(false);
|
|
94
|
+
|
|
95
|
+
const checkPing = () => {
|
|
96
|
+
const containerEle = containerRef.current;
|
|
97
|
+
|
|
98
|
+
if (!containerEle) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (overflow === 'scrollX') {
|
|
103
|
+
setPingStart(Math.abs(containerEle.scrollLeft) >= TOLERANCE);
|
|
104
|
+
setPingEnd(
|
|
105
|
+
containerEle.scrollWidth - containerEle.clientWidth - Math.abs(containerEle.scrollLeft) >=
|
|
106
|
+
TOLERANCE,
|
|
107
|
+
);
|
|
108
|
+
} else if (overflow === 'scrollY') {
|
|
109
|
+
setPingStart(containerEle.scrollTop !== 0);
|
|
110
|
+
setPingEnd(containerEle.scrollHeight - containerEle.clientHeight !== containerEle.scrollTop);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
React.useEffect(() => {
|
|
115
|
+
checkPing();
|
|
116
|
+
}, [overflow]);
|
|
117
|
+
|
|
118
|
+
const onScrollOffset = (offset: -1 | 1) => {
|
|
119
|
+
const containerEle = containerRef.current;
|
|
120
|
+
|
|
121
|
+
if (containerEle) {
|
|
122
|
+
containerEle.scrollTo({
|
|
123
|
+
left: containerEle.scrollLeft + offset * containerEle.clientWidth,
|
|
124
|
+
behavior: 'smooth',
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const onScrollLeft = () => {
|
|
130
|
+
onScrollOffset(-1);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const onScrollRight = () => {
|
|
134
|
+
onScrollOffset(1);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<div
|
|
139
|
+
className={classnames(
|
|
140
|
+
listCls,
|
|
141
|
+
{
|
|
142
|
+
[`${listCls}-overflow-${props.overflow}`]: overflow,
|
|
143
|
+
[`${listCls}-overflow-ping-start`]: pingStart,
|
|
144
|
+
[`${listCls}-overflow-ping-end`]: pingEnd,
|
|
145
|
+
},
|
|
146
|
+
listClassName,
|
|
147
|
+
)}
|
|
148
|
+
ref={containerRef}
|
|
149
|
+
onScroll={checkPing}
|
|
150
|
+
style={listStyle}
|
|
151
|
+
>
|
|
152
|
+
<CSSMotionList
|
|
153
|
+
keys={items.map((item) => ({
|
|
154
|
+
key: item.uid,
|
|
155
|
+
item,
|
|
156
|
+
}))}
|
|
157
|
+
motionName={`${listCls}-card-motion`}
|
|
158
|
+
component={false}
|
|
159
|
+
motionAppear={firstMount}
|
|
160
|
+
motionLeave
|
|
161
|
+
motionEnter
|
|
162
|
+
>
|
|
163
|
+
{({ key, item, className: motionCls, style: motionStyle }) => {
|
|
164
|
+
return (
|
|
165
|
+
<FileListCard
|
|
166
|
+
key={key}
|
|
167
|
+
prefixCls={prefixCls}
|
|
168
|
+
item={item}
|
|
169
|
+
onRemove={onRemove}
|
|
170
|
+
className={classnames(motionCls, itemClassName)}
|
|
171
|
+
style={{
|
|
172
|
+
...motionStyle,
|
|
173
|
+
...itemStyle,
|
|
174
|
+
}}
|
|
175
|
+
renderType={props.renderType}
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
}}
|
|
179
|
+
</CSSMotionList>
|
|
180
|
+
|
|
181
|
+
{overflow === 'scrollX' && (
|
|
182
|
+
<>
|
|
183
|
+
<Button
|
|
184
|
+
size="small"
|
|
185
|
+
shape="circle"
|
|
186
|
+
className={`${listCls}-prev-btn`}
|
|
187
|
+
icon={<LeftOutlined />}
|
|
188
|
+
onClick={onScrollLeft}
|
|
189
|
+
/>
|
|
190
|
+
<Button
|
|
191
|
+
size="small"
|
|
192
|
+
shape="circle"
|
|
193
|
+
className={`${listCls}-next-btn`}
|
|
194
|
+
icon={<RightOutlined />}
|
|
195
|
+
onClick={onScrollRight}
|
|
196
|
+
/>
|
|
197
|
+
</>
|
|
198
|
+
)}
|
|
199
|
+
</div>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Flex, GetRef, Typography, Upload, type UploadProps } from 'antd';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { AttachmentContext } from './context';
|
|
5
|
+
|
|
6
|
+
export interface PlaceholderConfig {
|
|
7
|
+
/**
|
|
8
|
+
* @description 占位符的图标元素,用于视觉引导
|
|
9
|
+
* @descriptionEn Icon element for the placeholder for visual guidance
|
|
10
|
+
*/
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* @description 占位符的主标题文本,用于说明功能
|
|
14
|
+
* @descriptionEn Main title text for the placeholder for explaining functionality
|
|
15
|
+
*/
|
|
16
|
+
title?: React.ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* @description 占位符的描述文本,用于提供详细说明
|
|
19
|
+
* @descriptionEn Description text for the placeholder for providing detailed explanation
|
|
20
|
+
*/
|
|
21
|
+
description?: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type PlaceholderType = PlaceholderConfig | React.ReactElement;
|
|
25
|
+
|
|
26
|
+
export interface PlaceholderProps {
|
|
27
|
+
/**
|
|
28
|
+
* @description 自定义CSS类名前缀,用于样式隔离和主题定制
|
|
29
|
+
* @descriptionEn Custom CSS class name prefix for style isolation and theme customization
|
|
30
|
+
*/
|
|
31
|
+
prefixCls: string;
|
|
32
|
+
/**
|
|
33
|
+
* @description 占位符配置,支持配置对象或自定义React元素
|
|
34
|
+
* @descriptionEn Placeholder configuration, supports config object or custom React elements
|
|
35
|
+
*/
|
|
36
|
+
placeholder?: PlaceholderType;
|
|
37
|
+
/**
|
|
38
|
+
* @description 上传组件的属性配置,用于控制上传行为
|
|
39
|
+
* @descriptionEn Upload component props configuration for controlling upload behavior
|
|
40
|
+
*/
|
|
41
|
+
upload?: UploadProps;
|
|
42
|
+
/**
|
|
43
|
+
* @description 组件的CSS类名
|
|
44
|
+
* @descriptionEn CSS class name for the component
|
|
45
|
+
*/
|
|
46
|
+
className?: string;
|
|
47
|
+
/**
|
|
48
|
+
* @description 组件的内联样式对象
|
|
49
|
+
* @descriptionEn Inline style object for the component
|
|
50
|
+
*/
|
|
51
|
+
style?: React.CSSProperties;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function Placeholder(props: PlaceholderProps, ref: React.Ref<GetRef<typeof Upload>>) {
|
|
55
|
+
const { prefixCls, placeholder = {}, upload, className, style } = props;
|
|
56
|
+
|
|
57
|
+
const placeholderCls = `${prefixCls}-placeholder`;
|
|
58
|
+
|
|
59
|
+
const placeholderConfig = (placeholder || {}) as PlaceholderConfig;
|
|
60
|
+
|
|
61
|
+
const { disabled } = React.useContext(AttachmentContext);
|
|
62
|
+
|
|
63
|
+
const [dragIn, setDragIn] = React.useState(false);
|
|
64
|
+
|
|
65
|
+
const onDragEnter = () => {
|
|
66
|
+
setDragIn(true);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const onDragLeave = (e: React.DragEvent) => {
|
|
70
|
+
// Leave the div should end
|
|
71
|
+
if (!(e.currentTarget as HTMLElement).contains(e.relatedTarget as HTMLElement)) {
|
|
72
|
+
setDragIn(false);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const onDrop = () => {
|
|
77
|
+
setDragIn(false);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const node = React.isValidElement(placeholder) ? (
|
|
81
|
+
placeholder
|
|
82
|
+
) : (
|
|
83
|
+
<Flex align="center" justify="center" vertical className={`${placeholderCls}-inner`}>
|
|
84
|
+
<Typography.Text className={`${placeholderCls}-icon`}>
|
|
85
|
+
{placeholderConfig.icon}
|
|
86
|
+
</Typography.Text>
|
|
87
|
+
<Typography.Title className={`${placeholderCls}-title`} level={5}>
|
|
88
|
+
{placeholderConfig.title}
|
|
89
|
+
</Typography.Title>
|
|
90
|
+
<Typography.Text className={`${placeholderCls}-description`} type="secondary">
|
|
91
|
+
{placeholderConfig.description}
|
|
92
|
+
</Typography.Text>
|
|
93
|
+
</Flex>
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div
|
|
98
|
+
className={classNames(
|
|
99
|
+
placeholderCls,
|
|
100
|
+
{
|
|
101
|
+
[`${placeholderCls}-drag-in`]: dragIn,
|
|
102
|
+
[`${placeholderCls}-disabled`]: disabled,
|
|
103
|
+
},
|
|
104
|
+
className,
|
|
105
|
+
)}
|
|
106
|
+
onDragEnter={onDragEnter}
|
|
107
|
+
onDragLeave={onDragLeave}
|
|
108
|
+
onDrop={onDrop}
|
|
109
|
+
aria-hidden={disabled}
|
|
110
|
+
style={style}
|
|
111
|
+
>
|
|
112
|
+
<Upload.Dragger
|
|
113
|
+
showUploadList={false}
|
|
114
|
+
{...upload}
|
|
115
|
+
ref={ref}
|
|
116
|
+
style={{ padding: 0, border: 0, background: 'transparent' }}
|
|
117
|
+
>
|
|
118
|
+
{node}
|
|
119
|
+
</Upload.Dragger>
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export default React.forwardRef(Placeholder);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type GetRef, Upload, type UploadProps } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
export interface SilentUploaderProps {
|
|
5
|
+
/**
|
|
6
|
+
* @description 要包装的子元素,通常是触发上传的按钮或区域
|
|
7
|
+
* @descriptionEn Child element to be wrapped, usually a button or area that triggers upload
|
|
8
|
+
*/
|
|
9
|
+
children: React.ReactElement;
|
|
10
|
+
/**
|
|
11
|
+
* @description 上传组件的属性配置,用于控制上传行为
|
|
12
|
+
* @descriptionEn Upload component props configuration for controlling upload behavior
|
|
13
|
+
*/
|
|
14
|
+
upload: UploadProps;
|
|
15
|
+
/**
|
|
16
|
+
* @description 自定义根容器的CSS类名,用于覆盖默认样式
|
|
17
|
+
* @descriptionEn Custom CSS class name for the root container to override default styles
|
|
18
|
+
*/
|
|
19
|
+
rootClassName?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* SilentUploader is only wrap children with antd Upload component.
|
|
24
|
+
*/
|
|
25
|
+
function SilentUploader(props: SilentUploaderProps, ref: React.Ref<GetRef<typeof Upload>>) {
|
|
26
|
+
const { children, upload, rootClassName } = props;
|
|
27
|
+
|
|
28
|
+
const uploadRef = React.useRef<GetRef<typeof Upload>>(null);
|
|
29
|
+
React.useImperativeHandle(ref, () => uploadRef.current!);
|
|
30
|
+
|
|
31
|
+
// ============================ Render ============================
|
|
32
|
+
return (
|
|
33
|
+
<Upload {...upload} showUploadList={false} rootClassName={rootClassName} ref={uploadRef}>
|
|
34
|
+
{children}
|
|
35
|
+
</Upload>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default React.forwardRef(SilentUploader);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface AttachmentContextProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 是否禁用附件功能,影响所有子组件的交互状态
|
|
6
|
+
* @descriptionEn Whether to disable attachment functionality, affects interaction state of all child components
|
|
7
|
+
*/
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const AttachmentContext = React.createContext<AttachmentContextProps>(null!);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Attachments } from '@agentscope-ai/chat';
|
|
2
|
+
import { App, Flex } from 'antd';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
const Demo = () => {
|
|
6
|
+
const filesList = [
|
|
7
|
+
{
|
|
8
|
+
uid: '1',
|
|
9
|
+
name: 'excel-file.xlsx',
|
|
10
|
+
size: 111111,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
uid: '2',
|
|
14
|
+
name: 'word-file.docx',
|
|
15
|
+
size: 222222,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
uid: '3',
|
|
19
|
+
name: 'image-file.png',
|
|
20
|
+
size: 333333,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
uid: '4',
|
|
24
|
+
name: 'pdf-file.pdf',
|
|
25
|
+
size: 444444,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
uid: '5',
|
|
29
|
+
name: 'ppt-file.pptx',
|
|
30
|
+
size: 555555,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
uid: '6',
|
|
34
|
+
name: 'video-file.mp4',
|
|
35
|
+
size: 666666,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
uid: '7',
|
|
39
|
+
name: 'audio-file.mp3',
|
|
40
|
+
size: 777777,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
uid: '8',
|
|
44
|
+
name: 'zip-file.zip',
|
|
45
|
+
size: 888888,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
uid: '9',
|
|
49
|
+
name: 'markdown-file.md',
|
|
50
|
+
size: 999999,
|
|
51
|
+
description: 'Custom description here',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
uid: '10',
|
|
55
|
+
name: 'image-file.png',
|
|
56
|
+
thumbUrl: 'https://gw.alicdn.com/imgextra/i4/O1CN01sjZ4Uu1erFDOC6IkA_!!6000000003924-2-tps-396-224.png',
|
|
57
|
+
url: 'https://gw.alicdn.com/imgextra/i4/O1CN01sjZ4Uu1erFDOC6IkA_!!6000000003924-2-tps-396-224.png',
|
|
58
|
+
size: 123456,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<Flex gap="middle" wrap>
|
|
64
|
+
{filesList.map((file, index) => (
|
|
65
|
+
<Attachments.FileCard key={index} item={file} />
|
|
66
|
+
))}
|
|
67
|
+
</Flex>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default () => <Demo />;
|