@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,491 @@
|
|
|
1
|
+
import { Button, Flex, Input } from 'antd';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import { useMergedState } from 'rc-util';
|
|
4
|
+
import pickAttrs from 'rc-util/lib/pickAttrs';
|
|
5
|
+
import getValue from 'rc-util/lib/utils/get';
|
|
6
|
+
import React, { useState } from 'react';
|
|
7
|
+
import useProxyImperativeHandle from '../Util/hooks/use-proxy-imperative-handle';
|
|
8
|
+
import { useProviderContext } from '@agentscope-ai/chat';
|
|
9
|
+
import SenderHeader, { SendHeaderContext } from './SenderHeader';
|
|
10
|
+
import { ActionButtonContext } from './components/ActionButton';
|
|
11
|
+
import ClearButton from './components/ClearButton';
|
|
12
|
+
import LoadingButton from './components/LoadingButton';
|
|
13
|
+
import SendButton from './components/SendButton';
|
|
14
|
+
import SpeechButton from './components/SpeechButton';
|
|
15
|
+
import Style from './style';
|
|
16
|
+
import useSpeech, { type AllowSpeech } from './useSpeech';
|
|
17
|
+
import ModeSelect from './ModeSelect';
|
|
18
|
+
import type { InputRef as AntdInputRef, ButtonProps, GetProps } from 'antd';
|
|
19
|
+
import { SparkEnlargeLine, SparkShrinkLine } from '@agentscope-ai/icons';
|
|
20
|
+
import { IconButton } from '@agentscope-ai/design';
|
|
21
|
+
|
|
22
|
+
export type SubmitType = 'enter' | 'shiftEnter' | false;
|
|
23
|
+
|
|
24
|
+
type TextareaProps = GetProps<typeof Input.TextArea>;
|
|
25
|
+
|
|
26
|
+
export interface SenderComponents {
|
|
27
|
+
input?: React.ComponentType<TextareaProps>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ActionsRender = (
|
|
31
|
+
ori: React.ReactNode,
|
|
32
|
+
info: {
|
|
33
|
+
components: {
|
|
34
|
+
SendButton: React.ComponentType<ButtonProps>;
|
|
35
|
+
ClearButton: React.ComponentType<ButtonProps>;
|
|
36
|
+
LoadingButton: React.ComponentType<ButtonProps>;
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
) => React.ReactNode;
|
|
40
|
+
|
|
41
|
+
export interface SenderProps extends Pick<TextareaProps, 'placeholder' | 'onKeyPress'> {
|
|
42
|
+
/**
|
|
43
|
+
* @description 输入框的默认初始值,仅在非受控模式下生效
|
|
44
|
+
* @descriptionEn Default initial value for the input field, only effective in uncontrolled mode
|
|
45
|
+
*/
|
|
46
|
+
defaultValue?: string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @description 输入框的当前值,用于受控组件模式
|
|
50
|
+
* @descriptionEn Current value of the input field for controlled component mode
|
|
51
|
+
*/
|
|
52
|
+
value?: string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @description 是否显示回复中的加载状态,影响按钮和输入框的交互
|
|
56
|
+
* @descriptionEn Whether to display loading state during reply, affects button and input interaction
|
|
57
|
+
*/
|
|
58
|
+
loading?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* @description 是否将输入框设置为只读模式,禁止用户编辑
|
|
61
|
+
* @descriptionEn Whether to set the input field to read-only mode, preventing user editing
|
|
62
|
+
*/
|
|
63
|
+
readOnly?: boolean;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @description 消息提交的方式,影响发送按钮的行为和快捷键
|
|
67
|
+
* @descriptionEn Method for message submission, affects send button behavior and keyboard shortcuts
|
|
68
|
+
*/
|
|
69
|
+
submitType?: SubmitType;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @description 是否禁用整个发送器组件,包括输入框和按钮
|
|
73
|
+
* @descriptionEn Whether to disable the entire sender component, including input field and buttons
|
|
74
|
+
*/
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @description 用户提交消息时的回调函数,接收消息内容作为参数
|
|
79
|
+
* @descriptionEn Callback function when user submits a message, receives message content as parameter
|
|
80
|
+
*/
|
|
81
|
+
onSubmit?: (message: string) => void;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @description 输入框值发生变化时的回调函数,用于实时处理用户输入
|
|
85
|
+
* @descriptionEn Callback function when input value changes, for real-time processing of user input
|
|
86
|
+
*/
|
|
87
|
+
onChange?: (
|
|
88
|
+
value: string,
|
|
89
|
+
event?: React.FormEvent<HTMLTextAreaElement> | React.ChangeEvent<HTMLTextAreaElement>,
|
|
90
|
+
) => void;
|
|
91
|
+
/**
|
|
92
|
+
* @description 用户取消操作时的回调函数,通常用于清空输入或重置状态
|
|
93
|
+
* @descriptionEn Callback function when user cancels operation, usually for clearing input or resetting state
|
|
94
|
+
*/
|
|
95
|
+
onCancel?: VoidFunction;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @description 键盘事件处理函数,用于自定义键盘快捷键和特殊按键行为
|
|
99
|
+
* @descriptionEn Keyboard event handler for custom keyboard shortcuts and special key behaviors
|
|
100
|
+
*/
|
|
101
|
+
onKeyDown?: React.KeyboardEventHandler<any>;
|
|
102
|
+
/**
|
|
103
|
+
* @description 语义化样式对象,用于精确控制不同区域的样式
|
|
104
|
+
* @descriptionEn Semantic style object for precise control of different area styles
|
|
105
|
+
*/
|
|
106
|
+
styles?: {
|
|
107
|
+
prefix?: React.CSSProperties;
|
|
108
|
+
input?: React.CSSProperties;
|
|
109
|
+
actions?: React.CSSProperties;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* @description 自定义根容器的CSS类名,用于覆盖默认样式
|
|
113
|
+
* @descriptionEn Custom CSS class name for the root container to override default styles
|
|
114
|
+
*/
|
|
115
|
+
rootClassName?: string;
|
|
116
|
+
/**
|
|
117
|
+
* @description 语义化CSS类名,用于为不同区域添加自定义类名
|
|
118
|
+
* @descriptionEn Semantic CSS class names for adding custom classes to different areas
|
|
119
|
+
*/
|
|
120
|
+
classNames?: {
|
|
121
|
+
prefix?: string;
|
|
122
|
+
input?: string;
|
|
123
|
+
actions?: string;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* @description 样式
|
|
127
|
+
* @descriptionEn Style
|
|
128
|
+
*/
|
|
129
|
+
style?: React.CSSProperties;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @description 类名
|
|
133
|
+
* @descriptionEn Classname
|
|
134
|
+
*/
|
|
135
|
+
className?: string;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @description 前缀 UI
|
|
139
|
+
* @descriptionEn Prefix UI
|
|
140
|
+
*/
|
|
141
|
+
prefix?: React.ReactNode | React.ReactNode[];
|
|
142
|
+
/**
|
|
143
|
+
* @description 头部 UI
|
|
144
|
+
* @descriptionEn Header UI
|
|
145
|
+
*/
|
|
146
|
+
header?: React.ReactNode;
|
|
147
|
+
/**
|
|
148
|
+
* @description 最大文本长度
|
|
149
|
+
* @descriptionEn Max content length
|
|
150
|
+
*/
|
|
151
|
+
maxLength?: number;
|
|
152
|
+
/**
|
|
153
|
+
* @description 是否可缩放
|
|
154
|
+
* @descriptionEn scalable
|
|
155
|
+
*/
|
|
156
|
+
scalable?: boolean;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @description 初始行数,默认 2,移动端使用建议设置 1 行
|
|
160
|
+
* @descriptionEn Initial rows, default 2, recommend 1 for mobile
|
|
161
|
+
*/
|
|
162
|
+
initialRows?: number;
|
|
163
|
+
/**
|
|
164
|
+
* @description 是否支持语音输入
|
|
165
|
+
* @descriptionEn Allow speech input
|
|
166
|
+
*/
|
|
167
|
+
allowSpeech?: boolean;
|
|
168
|
+
// prefixCls?: string;
|
|
169
|
+
// onPaste?: React.ClipboardEventHandler<HTMLElement>;
|
|
170
|
+
// onPasteFile?: (file: File) => void;
|
|
171
|
+
// components?: SenderComponents;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export type SenderRef = {
|
|
175
|
+
nativeElement: HTMLDivElement;
|
|
176
|
+
} & Pick<AntdInputRef, 'focus' | 'blur'>;
|
|
177
|
+
|
|
178
|
+
function getComponent<T>(
|
|
179
|
+
components: SenderComponents | undefined,
|
|
180
|
+
path: string[],
|
|
181
|
+
defaultComponent: React.ComponentType<T>,
|
|
182
|
+
): React.ComponentType<T> {
|
|
183
|
+
return getValue(components, path) || defaultComponent;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const ForwardSender = React.forwardRef<SenderRef, SenderProps>((props, ref) => {
|
|
187
|
+
const {
|
|
188
|
+
styles = {},
|
|
189
|
+
classNames = {},
|
|
190
|
+
className,
|
|
191
|
+
rootClassName,
|
|
192
|
+
style,
|
|
193
|
+
defaultValue,
|
|
194
|
+
value,
|
|
195
|
+
readOnly,
|
|
196
|
+
submitType = 'enter',
|
|
197
|
+
onSubmit,
|
|
198
|
+
loading,
|
|
199
|
+
onCancel,
|
|
200
|
+
onChange,
|
|
201
|
+
// @ts-ignore
|
|
202
|
+
actions,
|
|
203
|
+
onKeyPress,
|
|
204
|
+
onKeyDown,
|
|
205
|
+
disabled,
|
|
206
|
+
header,
|
|
207
|
+
// @ts-ignore
|
|
208
|
+
onPaste,
|
|
209
|
+
// @ts-ignore
|
|
210
|
+
allowSpeech,
|
|
211
|
+
// @ts-ignore
|
|
212
|
+
onPasteFile,
|
|
213
|
+
// @ts-ignore
|
|
214
|
+
components,
|
|
215
|
+
initialRows = 2,
|
|
216
|
+
scalable,
|
|
217
|
+
...rest
|
|
218
|
+
} = props as (SenderProps & { zoomable?: boolean });
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
const zoomable = scalable;
|
|
222
|
+
|
|
223
|
+
const [zoom, setZoom] = useState(zoomable ? false : undefined);
|
|
224
|
+
|
|
225
|
+
const autoSize = React.useMemo(() => {
|
|
226
|
+
return zoom ? { maxRows: 10, minRows: 10 } : { maxRows: 10, minRows: initialRows };
|
|
227
|
+
}, [zoomable, zoom]);
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
const { direction, getPrefixCls } = useProviderContext();
|
|
233
|
+
const prefixCls = getPrefixCls('sender');
|
|
234
|
+
|
|
235
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
236
|
+
const inputRef = React.useRef<AntdInputRef>(null);
|
|
237
|
+
|
|
238
|
+
useProxyImperativeHandle(ref, () => ({
|
|
239
|
+
nativeElement: containerRef.current!,
|
|
240
|
+
focus: inputRef.current?.focus!,
|
|
241
|
+
blur: inputRef.current?.blur!,
|
|
242
|
+
}));
|
|
243
|
+
|
|
244
|
+
const inputCls = `${prefixCls}-input`;
|
|
245
|
+
|
|
246
|
+
const mergedCls = classnames(
|
|
247
|
+
prefixCls,
|
|
248
|
+
className,
|
|
249
|
+
rootClassName,
|
|
250
|
+
{
|
|
251
|
+
[`${prefixCls}-rtl`]: direction === 'rtl',
|
|
252
|
+
[`${prefixCls}-disabled`]: disabled,
|
|
253
|
+
},
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
const actionBtnCls = `${prefixCls}-actions-btn`;
|
|
257
|
+
const actionListCls = `${prefixCls}-actions-list`;
|
|
258
|
+
|
|
259
|
+
const [innerValue, setInnerValue] = useMergedState(defaultValue || '', {
|
|
260
|
+
value,
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const triggerValueChange: SenderProps['onChange'] = (nextValue, event) => {
|
|
264
|
+
setInnerValue(nextValue);
|
|
265
|
+
|
|
266
|
+
if (onChange) {
|
|
267
|
+
onChange(nextValue, event);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const [speechPermission, triggerSpeech, speechRecording] = useSpeech((transcript) => {
|
|
272
|
+
triggerValueChange(`${innerValue} ${transcript}`);
|
|
273
|
+
}, allowSpeech);
|
|
274
|
+
|
|
275
|
+
const InputTextArea = getComponent(components, ['input'], Input.TextArea);
|
|
276
|
+
|
|
277
|
+
const domProps = pickAttrs(rest, {
|
|
278
|
+
attr: true,
|
|
279
|
+
aria: true,
|
|
280
|
+
data: true,
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
const inputProps: typeof domProps = {
|
|
284
|
+
...domProps,
|
|
285
|
+
ref: inputRef,
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
// ============================ Events ============================
|
|
289
|
+
const triggerSend = () => {
|
|
290
|
+
if (innerValue && onSubmit && !loading) {
|
|
291
|
+
onSubmit(innerValue);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
const triggerClear = () => {
|
|
296
|
+
triggerValueChange('');
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// ============================ Submit ============================
|
|
300
|
+
const isCompositionRef = React.useRef(false);
|
|
301
|
+
|
|
302
|
+
const onInternalCompositionStart = () => {
|
|
303
|
+
isCompositionRef.current = true;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const onInternalCompositionEnd = () => {
|
|
307
|
+
isCompositionRef.current = false;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const onInternalKeyPress: TextareaProps['onKeyPress'] = (e) => {
|
|
311
|
+
const canSubmit = e.key === 'Enter' && !isCompositionRef.current;
|
|
312
|
+
|
|
313
|
+
// Check for `submitType` to submit
|
|
314
|
+
switch (submitType) {
|
|
315
|
+
case 'enter':
|
|
316
|
+
if (canSubmit && !e.shiftKey) {
|
|
317
|
+
e.preventDefault();
|
|
318
|
+
triggerSend();
|
|
319
|
+
}
|
|
320
|
+
break;
|
|
321
|
+
|
|
322
|
+
case 'shiftEnter':
|
|
323
|
+
if (canSubmit && e.shiftKey) {
|
|
324
|
+
e.preventDefault();
|
|
325
|
+
triggerSend();
|
|
326
|
+
}
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (onKeyPress) {
|
|
331
|
+
onKeyPress(e);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
const onInternalPaste: React.ClipboardEventHandler<HTMLElement> = (e) => {
|
|
336
|
+
// Get file
|
|
337
|
+
const file = e.clipboardData?.files[0];
|
|
338
|
+
if (file && onPasteFile) {
|
|
339
|
+
onPasteFile(file);
|
|
340
|
+
e.preventDefault();
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
onPaste?.(e);
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
// ============================ Focus =============================
|
|
347
|
+
const onContentMouseDown: React.MouseEventHandler<HTMLDivElement> = (e) => {
|
|
348
|
+
// If input focused but click on the container,
|
|
349
|
+
// input will lose focus.
|
|
350
|
+
// We call `preventDefault` to prevent this behavior
|
|
351
|
+
if (e.target !== containerRef.current?.querySelector(`.${inputCls}`)) {
|
|
352
|
+
e.preventDefault();
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
inputRef.current?.focus();
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
const prefix = React.useMemo(() => {
|
|
359
|
+
const nodes = Array.isArray(props.prefix) ? [...props.prefix] : [props.prefix];
|
|
360
|
+
|
|
361
|
+
if (zoomable) {
|
|
362
|
+
nodes.push(
|
|
363
|
+
<IconButton
|
|
364
|
+
key="zoom"
|
|
365
|
+
onClick={() => setZoom(!zoom)}
|
|
366
|
+
bordered={false}
|
|
367
|
+
icon={zoom ? <SparkShrinkLine /> : <SparkEnlargeLine />}
|
|
368
|
+
/>
|
|
369
|
+
)
|
|
370
|
+
}
|
|
371
|
+
return nodes;
|
|
372
|
+
}, [props.prefix, zoomable, zoom, allowSpeech])
|
|
373
|
+
|
|
374
|
+
let actionNode: React.ReactNode = (
|
|
375
|
+
<Flex className={`${actionListCls}-presets`}>
|
|
376
|
+
{loading ? <LoadingButton /> : <SendButton />}
|
|
377
|
+
</Flex>
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
if (typeof actions === 'function') {
|
|
381
|
+
actionNode = actions(actionNode, {
|
|
382
|
+
components: {
|
|
383
|
+
SendButton,
|
|
384
|
+
ClearButton,
|
|
385
|
+
LoadingButton,
|
|
386
|
+
},
|
|
387
|
+
});
|
|
388
|
+
} else if (actions) {
|
|
389
|
+
actionNode = actions;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const contextValue = {
|
|
393
|
+
prefixCls: actionBtnCls,
|
|
394
|
+
onSend: triggerSend,
|
|
395
|
+
onSendDisabled: !innerValue,
|
|
396
|
+
onClear: triggerClear,
|
|
397
|
+
onClearDisabled: !innerValue,
|
|
398
|
+
onCancel,
|
|
399
|
+
onCancelDisabled: !loading,
|
|
400
|
+
onSpeech: () => triggerSpeech(false),
|
|
401
|
+
onSpeechDisabled: !speechPermission,
|
|
402
|
+
speechRecording,
|
|
403
|
+
disabled,
|
|
404
|
+
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return <>
|
|
408
|
+
<Style />
|
|
409
|
+
|
|
410
|
+
<div ref={containerRef} className={mergedCls} style={style}>
|
|
411
|
+
{header && (
|
|
412
|
+
<SendHeaderContext.Provider value={{ prefixCls }}>{header}</SendHeaderContext.Provider>
|
|
413
|
+
)}
|
|
414
|
+
|
|
415
|
+
<div className={`${prefixCls}-content`}>
|
|
416
|
+
<InputTextArea
|
|
417
|
+
{...inputProps}
|
|
418
|
+
disabled={disabled}
|
|
419
|
+
style={styles.input}
|
|
420
|
+
className={classnames(inputCls, classNames.input)}
|
|
421
|
+
autoSize={autoSize}
|
|
422
|
+
value={innerValue.slice(0, props.maxLength || Number.MAX_SAFE_INTEGER)}
|
|
423
|
+
onChange={(event) => {
|
|
424
|
+
triggerValueChange(
|
|
425
|
+
(event.target as HTMLTextAreaElement).value,
|
|
426
|
+
event as React.ChangeEvent<HTMLTextAreaElement>,
|
|
427
|
+
);
|
|
428
|
+
triggerSpeech(true);
|
|
429
|
+
}}
|
|
430
|
+
onPressEnter={onInternalKeyPress}
|
|
431
|
+
onCompositionStart={onInternalCompositionStart}
|
|
432
|
+
onCompositionEnd={onInternalCompositionEnd}
|
|
433
|
+
onKeyDown={onKeyDown}
|
|
434
|
+
onPaste={onInternalPaste}
|
|
435
|
+
variant="borderless"
|
|
436
|
+
readOnly={readOnly}
|
|
437
|
+
/>
|
|
438
|
+
|
|
439
|
+
<div className={`${prefixCls}-content-bottom`}>
|
|
440
|
+
{prefix.length > 0 && (
|
|
441
|
+
<div
|
|
442
|
+
className={classnames(
|
|
443
|
+
`${prefixCls}-prefix`,
|
|
444
|
+
classNames.prefix,
|
|
445
|
+
)}
|
|
446
|
+
style={styles.prefix}
|
|
447
|
+
>
|
|
448
|
+
<Flex gap={8}>
|
|
449
|
+
{allowSpeech && <ActionButtonContext.Provider
|
|
450
|
+
value={contextValue}
|
|
451
|
+
>
|
|
452
|
+
<SpeechButton />
|
|
453
|
+
</ActionButtonContext.Provider>}
|
|
454
|
+
{prefix}
|
|
455
|
+
</Flex>
|
|
456
|
+
</div>
|
|
457
|
+
)}
|
|
458
|
+
<div
|
|
459
|
+
className={classnames(
|
|
460
|
+
actionListCls,
|
|
461
|
+
classNames.actions,
|
|
462
|
+
)}
|
|
463
|
+
style={styles.actions}
|
|
464
|
+
>
|
|
465
|
+
{
|
|
466
|
+
props.maxLength ? <div className={`${actionListCls}-length`}>
|
|
467
|
+
{innerValue.length}/{props.maxLength}
|
|
468
|
+
</div> : null
|
|
469
|
+
}
|
|
470
|
+
<ActionButtonContext.Provider
|
|
471
|
+
value={contextValue}
|
|
472
|
+
>
|
|
473
|
+
{actionNode}
|
|
474
|
+
</ActionButtonContext.Provider>
|
|
475
|
+
</div>
|
|
476
|
+
</div>
|
|
477
|
+
</div>
|
|
478
|
+
</div>
|
|
479
|
+
</>
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
type CompoundedSender = typeof ForwardSender & {
|
|
483
|
+
Header: typeof SenderHeader;
|
|
484
|
+
ModeSelect: typeof ModeSelect;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
const Sender = ForwardSender as CompoundedSender;
|
|
488
|
+
Sender.Header = SenderHeader;
|
|
489
|
+
Sender.ModeSelect = ModeSelect;
|
|
490
|
+
|
|
491
|
+
export default Sender;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
group:
|
|
3
|
+
title: 输入
|
|
4
|
+
order: 2
|
|
5
|
+
title: ChatInput
|
|
6
|
+
description: AI输入框
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<DemoTitle title="ChatInput" desc="AI输入框" llmTxtName="Sender"></DemoTitle>
|
|
10
|
+
|
|
11
|
+
<code src="./demo/basic.tsx" center height="350">示例</code>
|
|
12
|
+
|
|
13
|
+
<Install>import { ChatInput } from '@agentscope-ai/chat'</Install>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
#### 对话输入框示例
|
|
17
|
+
|
|
18
|
+
以下是此组件的示例和变体
|
|
19
|
+
|
|
20
|
+
<code src="./demo/loading.tsx" center height="350">生成中暂停</code>
|
|
21
|
+
<code src="./demo/withImage.tsx" center height="350">上传图片</code>
|
|
22
|
+
<code src="./demo/withFile.tsx" center height="350">上传文件</code>
|
|
23
|
+
<code src="./demo/moreMode.tsx" center height="350">自定义模式</code>
|
|
24
|
+
<code src="./demo/morePrefixAction.tsx" center height="350">自定义功能</code>
|
|
25
|
+
<code src="./demo/asr.tsx" center height="350">语音发送</code>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#### API
|
|
29
|
+
|
|
30
|
+
<ApiParser source="./index.tsx" id="SenderProps"></ApiParser>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { createGlobalStyle } from 'antd-style';
|
|
2
|
+
|
|
3
|
+
const IndexStyle = createGlobalStyle`
|
|
4
|
+
.${(p) => p.theme.prefixCls}-sender {
|
|
5
|
+
position: relative;
|
|
6
|
+
width: 100%;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
box-shadow: 0px 12px 24px -16px rgba(54, 54, 73, 0.04),
|
|
9
|
+
0px 12px 40px 0px rgba(51, 51, 71, 0.08),
|
|
10
|
+
0px 0px 1px 0px rgba(44, 44, 54, 0.02);
|
|
11
|
+
background-color: ${(p) => p.theme.colorBgBase};
|
|
12
|
+
border-radius: ${(p) => p.theme.borderRadiusLG}px;
|
|
13
|
+
border-color: ${(p) => p.theme.colorBorderSecondary};
|
|
14
|
+
border-width: 0;
|
|
15
|
+
border-style: solid;
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
|
|
18
|
+
&:after {
|
|
19
|
+
content: '';
|
|
20
|
+
position: absolute;
|
|
21
|
+
inset: 0;
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
transition: border-color ${(p) => p.theme.motionDurationSlow};
|
|
24
|
+
border-radius: inherit;
|
|
25
|
+
border-style: inherit;
|
|
26
|
+
border-color: inherit;
|
|
27
|
+
border-width: ${(p) => p.theme.lineWidth}px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:focus-within {
|
|
31
|
+
box-shadow: 0px 12px 24px -16px rgba(54, 54, 73, 0.04),
|
|
32
|
+
0px 12px 40px 0px rgba(51, 51, 71, 0.08),
|
|
33
|
+
0px 0px 1px 0px rgba(44, 44, 54, 0.02);
|
|
34
|
+
border-color: ${(p) => p.theme.colorPrimaryHover};
|
|
35
|
+
|
|
36
|
+
&:after {
|
|
37
|
+
border-width: ${(p) => p.theme.lineWidth}px;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&-disabled {
|
|
42
|
+
.${(p) => p.theme.prefixCls}-sender-content,
|
|
43
|
+
.${(p) => p.theme.prefixCls}-sender-header {
|
|
44
|
+
background-color: ${(p) => p.theme.colorBgContainerDisabled};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&.${(p) => p.theme.prefixCls}-sender-rtl {
|
|
49
|
+
direction: rtl;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&-content {
|
|
53
|
+
width: 100%;
|
|
54
|
+
padding: 8px;
|
|
55
|
+
box-sizing: border-box;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&-content-bottom {
|
|
60
|
+
margin-top: 4px;
|
|
61
|
+
display: flex;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&-prefix {
|
|
65
|
+
flex: 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&-input {
|
|
69
|
+
margin: 4px 0;
|
|
70
|
+
padding: 0 8px;
|
|
71
|
+
border-radius: 0;
|
|
72
|
+
align-self: center;
|
|
73
|
+
font-size: 14px;
|
|
74
|
+
line-height: 22px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&-actions-list {
|
|
78
|
+
flex: none;
|
|
79
|
+
display: flex;
|
|
80
|
+
margin: 0 0 0 auto;
|
|
81
|
+
|
|
82
|
+
&-presets {
|
|
83
|
+
gap: ${(p) => p.theme.paddingXS}px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&-length {
|
|
87
|
+
font-size: 12px;
|
|
88
|
+
line-height: 1;
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
padding: 0 12px;
|
|
92
|
+
color: ${(p) => p.theme.colorTextTertiary};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&-recording {
|
|
97
|
+
height: 30px;
|
|
98
|
+
padding: 0 8px;
|
|
99
|
+
&-icon {
|
|
100
|
+
display: block;
|
|
101
|
+
width: 100%;
|
|
102
|
+
height: 30px;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&-actions-btn {
|
|
107
|
+
&-disabled {
|
|
108
|
+
background: ${(p) => `var(--${p.theme.prefixCls}-color-fill-disable)`};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&-loading-button {
|
|
112
|
+
padding: 0;
|
|
113
|
+
border: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&-loading-icon {
|
|
117
|
+
height: ${(p) => p.theme.controlHeight}px;
|
|
118
|
+
width: ${(p) => p.theme.controlHeight}px;
|
|
119
|
+
vertical-align: top;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&-recording-icon {
|
|
123
|
+
height: 1.2em;
|
|
124
|
+
width: 1.2em;
|
|
125
|
+
vertical-align: top;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.${(p) => p.theme.prefixCls}-sender {
|
|
133
|
+
&-header {
|
|
134
|
+
&-motion {
|
|
135
|
+
transition: height .3s, border .3s;
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
&-enter-start,
|
|
138
|
+
&-leave-active {
|
|
139
|
+
border-bottom-color: transparent;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&-hidden {
|
|
143
|
+
display: none;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
`;
|
|
149
|
+
|
|
150
|
+
export default IndexStyle;
|