@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,268 @@
|
|
|
1
|
+
import { createGlobalStyle } from 'antd-style';
|
|
2
|
+
|
|
3
|
+
export default createGlobalStyle`
|
|
4
|
+
.${(p) => p.theme.prefixCls}-operate-card {
|
|
5
|
+
width: 100%;
|
|
6
|
+
border-radius: ${(p) => p.theme.borderRadiusLG}px;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
background-color: ${(p) => p.theme.colorFillTertiary};
|
|
9
|
+
|
|
10
|
+
&-header {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
gap: 8px;
|
|
14
|
+
padding: 0 12px;
|
|
15
|
+
height: 32px;
|
|
16
|
+
|
|
17
|
+
&-icon {
|
|
18
|
+
font-size: 16px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&-title {
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
text-overflow: ellipsis;
|
|
24
|
+
white-space: nowrap;
|
|
25
|
+
font-size: 13px;
|
|
26
|
+
font-weight: 500;
|
|
27
|
+
color: ${(p) => p.theme.colorText};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&-description {
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
text-overflow: ellipsis;
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
font-size: 12px;
|
|
35
|
+
color: ${(p) => p.theme.colorTextTertiary};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&-arrow {
|
|
39
|
+
margin: 0 0 0 auto;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&-has-body {
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&-body {
|
|
48
|
+
opacity: 0;
|
|
49
|
+
animation: ${(p) =>
|
|
50
|
+
p.theme.prefixCls}-operate-card-body-open 0.2s ease-in-out forwards;
|
|
51
|
+
|
|
52
|
+
@keyframes ${(p) => p.theme.prefixCls}-operate-card-body-open {
|
|
53
|
+
from {
|
|
54
|
+
opacity: 0;
|
|
55
|
+
}
|
|
56
|
+
to {
|
|
57
|
+
opacity: 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
&-line-body {
|
|
65
|
+
margin: 0 12px 12px 20px;
|
|
66
|
+
border-left: 1px solid ${(p) => p.theme.colorBorderSecondary};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&-thinking {
|
|
70
|
+
padding-left: 16px;
|
|
71
|
+
font-size: 12px;
|
|
72
|
+
line-height: 20px;
|
|
73
|
+
color: ${(p) => p.theme.colorTextTertiary};
|
|
74
|
+
opacity: 0.85;
|
|
75
|
+
white-space: pre-wrap;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
&-todo-list {
|
|
80
|
+
|
|
81
|
+
&-item {
|
|
82
|
+
height: 32px;
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
padding: 0 12px;
|
|
86
|
+
gap: 8px;
|
|
87
|
+
|
|
88
|
+
color: ${(p) => p.theme.colorText};
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
&-done {
|
|
92
|
+
color: ${(p) => p.theme.colorTextTertiary};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&-icon {
|
|
96
|
+
font-size: 16px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&-title {
|
|
100
|
+
text-overflow: ellipsis;
|
|
101
|
+
overflow: hidden;
|
|
102
|
+
white-space: nowrap;
|
|
103
|
+
font-size: 12px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&-done {
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
&-web-search-item {
|
|
116
|
+
display: flex;
|
|
117
|
+
height: 32px;
|
|
118
|
+
align-items: center;
|
|
119
|
+
padding: 0 12px;
|
|
120
|
+
gap: 8px;
|
|
121
|
+
color: ${(p) => p.theme.colorText};
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
|
|
124
|
+
&-icon {
|
|
125
|
+
display: block;
|
|
126
|
+
width: 16px;
|
|
127
|
+
height: 16px;
|
|
128
|
+
border: 1px solid ${(p) => p.theme.colorBorderSecondary};
|
|
129
|
+
border-radius: 99px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&-title {
|
|
133
|
+
font-size: 12px;
|
|
134
|
+
overflow: hidden;
|
|
135
|
+
text-overflow: ellipsis;
|
|
136
|
+
white-space: nowrap;
|
|
137
|
+
color: ${(p) => p.theme.colorTextSecondary};
|
|
138
|
+
|
|
139
|
+
&:hover {
|
|
140
|
+
color: ${(p) => p.theme.colorText};
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
&-subTitle {
|
|
147
|
+
overflow: hidden;
|
|
148
|
+
text-overflow: ellipsis;
|
|
149
|
+
white-space: nowrap;
|
|
150
|
+
border-left: 1px solid ${(p) => p.theme.colorBorderSecondary};
|
|
151
|
+
font-size: 12px;
|
|
152
|
+
line-height: 1;
|
|
153
|
+
color: ${(p) => p.theme.colorTextTertiary};
|
|
154
|
+
padding-left: 8px;
|
|
155
|
+
margin-left: 4px;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
&-tool-call-block {
|
|
162
|
+
margin-left: 16px;
|
|
163
|
+
|
|
164
|
+
&-title {
|
|
165
|
+
font-size: 12px;
|
|
166
|
+
color: ${(p) => p.theme.colorText};
|
|
167
|
+
line-height: 20px;
|
|
168
|
+
margin-bottom: 4px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
&-content {
|
|
172
|
+
font-size: 12px;
|
|
173
|
+
line-height: 20px;
|
|
174
|
+
font-family: ${(p) => p.theme.fontFamilyCode};
|
|
175
|
+
border-radius: 6px;
|
|
176
|
+
padding: 8px;
|
|
177
|
+
background-color: ${(p) => p.theme.colorFillTertiary};
|
|
178
|
+
white-space: pre-wrap;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
&-tool-call-block ~ &-tool-call-block {
|
|
183
|
+
margin-top: 8px;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
&-device-action {
|
|
188
|
+
height: auto;
|
|
189
|
+
align-items: flex-start;
|
|
190
|
+
|
|
191
|
+
&-icon {
|
|
192
|
+
margin-top: 6px;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
&-time {
|
|
196
|
+
margin-bottom: 4px;
|
|
197
|
+
font-size: 12px;
|
|
198
|
+
line-height: 20px;
|
|
199
|
+
color: ${(p) => p.theme.colorTextSecondary};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
&-content {
|
|
203
|
+
|
|
204
|
+
width: 100%;
|
|
205
|
+
display: flex;
|
|
206
|
+
justify-content: space-between;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
&-description {
|
|
210
|
+
width: 0;
|
|
211
|
+
flex: 1;
|
|
212
|
+
margin: 8px 0 6px 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
&-image {
|
|
216
|
+
margin: 4px 0;
|
|
217
|
+
height: 32px;
|
|
218
|
+
margin-left: 8px;
|
|
219
|
+
display: block;
|
|
220
|
+
border-radius: 6px;
|
|
221
|
+
overflow: hidden;
|
|
222
|
+
border: 1px solid ${(p) => p.theme.colorBorderSecondary};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
&-rag-item {
|
|
230
|
+
margin-left: 16px;
|
|
231
|
+
|
|
232
|
+
&-title {
|
|
233
|
+
font-size: 12px;
|
|
234
|
+
color: ${(p) => p.theme.colorText};
|
|
235
|
+
line-height: 20px;
|
|
236
|
+
margin-bottom: 4px;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
&-content {
|
|
240
|
+
padding: 8px;
|
|
241
|
+
border-radius: 6px;
|
|
242
|
+
background-color: ${(p) => p.theme.colorFillTertiary};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
&-images {
|
|
246
|
+
margin-top: 8px;
|
|
247
|
+
padding: 8px;
|
|
248
|
+
display: flex;
|
|
249
|
+
gap: 8px;
|
|
250
|
+
background-color: ${(p) => p.theme.colorFillQuaternary};
|
|
251
|
+
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
&-footer {
|
|
255
|
+
display: block;
|
|
256
|
+
margin-top: 8px;
|
|
257
|
+
font-size: 12px;
|
|
258
|
+
line-height: 20px;
|
|
259
|
+
color: ${(p) => p.theme.colorTextTertiary};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
&-rag-item ~ &-rag-item {
|
|
265
|
+
margin-top: 8px;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { createContext } from "react";
|
|
2
|
+
import { ProviderProps } from './types';
|
|
3
|
+
import { DefaultCards } from '@agentscope-ai/chat';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const CustomCardsContext = createContext<ProviderProps['cardConfig']>(undefined);
|
|
7
|
+
|
|
8
|
+
export const CustomCardsProvider = function (props: Pick<ProviderProps, 'cardConfig' | 'children'>) {
|
|
9
|
+
return <CustomCardsContext.Provider value={props.cardConfig}>
|
|
10
|
+
{props.children}
|
|
11
|
+
</CustomCardsContext.Provider>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const useCustomCardsContext = () => {
|
|
15
|
+
const cardConfig = React.useContext(CustomCardsContext);
|
|
16
|
+
return React.useMemo(() => ({ ...DefaultCards, ...cardConfig }), [cardConfig]);
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { createContext } from "react";
|
|
3
|
+
import { ProviderProps } from './types';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const GlobalContext = createContext<Pick<ProviderProps, 'markdown'>>(undefined);
|
|
7
|
+
|
|
8
|
+
export const GlobalProvider = function (props: Pick<ProviderProps, 'markdown' | 'children'>) {
|
|
9
|
+
return <GlobalContext.Provider value={props}>
|
|
10
|
+
{props.children}
|
|
11
|
+
</GlobalContext.Provider>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const useGlobalContext = () => {
|
|
15
|
+
const context = React.useContext(GlobalContext);
|
|
16
|
+
return context || {};
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ConfigProvider } from "@agentscope-ai/design";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { CustomCardsProvider, CustomCardsContext, useCustomCardsContext } from './CustomCardsProvider';
|
|
4
|
+
import { GlobalProvider, GlobalContext, useGlobalContext } from './GlobalProvider';
|
|
5
|
+
import type { ProviderProps } from './types';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const SparkChatProvider = (props: ProviderProps) => {
|
|
9
|
+
const { children, cardConfig, markdown } = props;
|
|
10
|
+
return <GlobalProvider markdown={markdown}>
|
|
11
|
+
<CustomCardsProvider cardConfig={cardConfig}>
|
|
12
|
+
{children}
|
|
13
|
+
</CustomCardsProvider>
|
|
14
|
+
</GlobalProvider>
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export function useProviderContext() {
|
|
19
|
+
const context = React.useContext(ConfigProvider.ConfigContext);
|
|
20
|
+
return context;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export default SparkChatProvider;
|
|
25
|
+
export {
|
|
26
|
+
useCustomCardsContext,
|
|
27
|
+
CustomCardsProvider,
|
|
28
|
+
useGlobalContext,
|
|
29
|
+
CustomCardsContext,
|
|
30
|
+
GlobalProvider,
|
|
31
|
+
GlobalContext,
|
|
32
|
+
ProviderProps
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface ProviderProps {
|
|
2
|
+
/**
|
|
3
|
+
* @description 提供者组件的子元素,用于包装应用内容
|
|
4
|
+
* @descriptionEn Child elements of the provider component for wrapping application content
|
|
5
|
+
*/
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* @description 卡片配置对象,用于自定义不同类型卡片的渲染
|
|
9
|
+
* @descriptionEn Card configuration object for customizing rendering of different card types
|
|
10
|
+
*/
|
|
11
|
+
cardConfig: Record<string, any>;
|
|
12
|
+
/**
|
|
13
|
+
* @description Markdown渲染配置,用于控制文本显示效果
|
|
14
|
+
* @descriptionEn Markdown rendering configuration for controlling text display effects
|
|
15
|
+
*/
|
|
16
|
+
markdown?: {
|
|
17
|
+
/**
|
|
18
|
+
* @description 基础字体大小,影响所有Markdown内容的字体大小
|
|
19
|
+
* @descriptionEn Base font size that affects font size of all Markdown content
|
|
20
|
+
*/
|
|
21
|
+
baseFontSize?: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { createGlobalStyle } from 'antd-style';
|
|
3
|
+
import { useProviderContext } from '@agentscope-ai/chat'
|
|
4
|
+
import { SparkFalseLine } from "@agentscope-ai/icons";
|
|
5
|
+
import { Tooltip } from "@agentscope-ai/design";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
interface IItem {
|
|
9
|
+
icon: string | React.ReactNode;
|
|
10
|
+
label: string | React.ReactNode;
|
|
11
|
+
selectedLabel?: string | React.ReactNode;
|
|
12
|
+
tooltip?: string | React.ReactNode;
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
interface IProps {
|
|
16
|
+
options: IItem[],
|
|
17
|
+
value: string,
|
|
18
|
+
desc?: React.ReactNode | string;
|
|
19
|
+
onChange: (value: string) => void
|
|
20
|
+
style?: React.CSSProperties,
|
|
21
|
+
closeTip?: React.ReactNode | string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const Style = createGlobalStyle`
|
|
25
|
+
.${p => p.theme.prefixCls}-sender-mode-select {
|
|
26
|
+
position: relative;
|
|
27
|
+
height: 40px;
|
|
28
|
+
|
|
29
|
+
&-options {
|
|
30
|
+
position: absolute;
|
|
31
|
+
top: 4px;
|
|
32
|
+
left: 0;
|
|
33
|
+
right: 0;
|
|
34
|
+
display: flex;
|
|
35
|
+
gap: 8px;
|
|
36
|
+
transition: all 0.3s;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&-option {
|
|
40
|
+
height: 28px;
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
fonts: 14px;
|
|
44
|
+
padding: 0 8px;
|
|
45
|
+
border-radius: ${p => p.theme.borderRadius}px;
|
|
46
|
+
gap: 4px;
|
|
47
|
+
border: 1px solid ${p => p.theme.colorBorderSecondary};
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
color: ${p => p.theme.colorTextSecondary};
|
|
50
|
+
transition: all 0.3s;
|
|
51
|
+
|
|
52
|
+
&:hover {
|
|
53
|
+
border-color: ${p => p.theme.colorPrimary};
|
|
54
|
+
color: ${p => p.theme.colorPrimary};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&-display {
|
|
59
|
+
position: absolute;
|
|
60
|
+
top: 8px;
|
|
61
|
+
left: 0;
|
|
62
|
+
right: 0;
|
|
63
|
+
height: 40px;
|
|
64
|
+
border: 1px solid ${p => p.theme.colorBorderSecondary};
|
|
65
|
+
border-radius: ${p => p.theme.borderRadiusLG}px ${p => p.theme.borderRadiusLG}px 0 0;
|
|
66
|
+
background: ${p => p.theme.colorFillTertiary};
|
|
67
|
+
transition: all 0.3s;
|
|
68
|
+
|
|
69
|
+
&-flex {
|
|
70
|
+
display: flex;
|
|
71
|
+
justify-content: space-between;
|
|
72
|
+
align-items: center;
|
|
73
|
+
height: 32px;
|
|
74
|
+
padding: 0 12px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&-label {
|
|
78
|
+
width: 0;
|
|
79
|
+
flex: 1;
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
gap: 4px;
|
|
83
|
+
fontsize: 14px;
|
|
84
|
+
color: ${p => p.theme.colorTextSecondary};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&-desc {
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
margin: 0 12px 0 auto;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&-hide {
|
|
95
|
+
top: 45px;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
`
|
|
100
|
+
|
|
101
|
+
export default function (props: IProps) {
|
|
102
|
+
const { getPrefixCls } = useProviderContext();
|
|
103
|
+
const prefixCls = getPrefixCls('sender-mode-select');
|
|
104
|
+
|
|
105
|
+
const { value, onChange } = props;
|
|
106
|
+
|
|
107
|
+
const valueObject = useMemo(() => {
|
|
108
|
+
const item = props.options.find(item => item.value === value) || {};
|
|
109
|
+
return item;
|
|
110
|
+
}, [props.value]) as IItem;
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
const close = <SparkFalseLine onClick={() => onChange(undefined)} style={{ cursor: 'pointer', fontSize: 20 }} />
|
|
114
|
+
|
|
115
|
+
return <>
|
|
116
|
+
<Style />
|
|
117
|
+
<div className={prefixCls} style={props.style}>
|
|
118
|
+
<div className={(`${prefixCls}-options ${value ? `${prefixCls}-hide` : ''}`)}>
|
|
119
|
+
{
|
|
120
|
+
props.options.map(item => {
|
|
121
|
+
const node = <Display key={item.value} onClick={() => onChange(item.value)} className={(`${prefixCls}-option`)} {...item} />
|
|
122
|
+
return node;
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<div className={(`${prefixCls}-display ${value ? '' : `${prefixCls}-hide`}`)}>
|
|
128
|
+
<div className={(`${prefixCls}-display-flex`)}>
|
|
129
|
+
<Display {...valueObject} label={valueObject?.selectedLabel || valueObject?.label} className={(`${prefixCls}-display-label`)} />
|
|
130
|
+
{
|
|
131
|
+
props.desc && <div className={(`${prefixCls}-display-desc`)}>{props.desc}</div>
|
|
132
|
+
}
|
|
133
|
+
{
|
|
134
|
+
props.closeTip ? <Tooltip title={props.closeTip}>
|
|
135
|
+
{close}
|
|
136
|
+
</Tooltip> :
|
|
137
|
+
close
|
|
138
|
+
}
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</>
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function Display(props: IItem & { className?: string, onClick?: () => void }) {
|
|
146
|
+
|
|
147
|
+
const node = <div className={props.className} onClick={props.onClick}>
|
|
148
|
+
{props.icon}
|
|
149
|
+
{props.label}
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
if (props.tooltip) {
|
|
154
|
+
return <Tooltip title={props.tooltip} placement="topLeft">
|
|
155
|
+
{node}
|
|
156
|
+
</Tooltip>
|
|
157
|
+
} else {
|
|
158
|
+
return node;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { CloseOutlined } from '@ant-design/icons';
|
|
2
|
+
import { Button } from 'antd';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import CSSMotion, { type MotionEventHandler } from 'rc-motion';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
|
|
7
|
+
export interface SendHeaderContextProps {
|
|
8
|
+
/**
|
|
9
|
+
* @description 自定义CSS类名前缀,用于样式隔离和主题定制
|
|
10
|
+
* @descriptionEn Custom CSS class name prefix for style isolation and theme customization
|
|
11
|
+
*/
|
|
12
|
+
prefixCls: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const SendHeaderContext = React.createContext<SendHeaderContextProps>({} as any);
|
|
16
|
+
|
|
17
|
+
export type SemanticType = 'header' | 'content';
|
|
18
|
+
|
|
19
|
+
export interface SenderHeaderProps {
|
|
20
|
+
/**
|
|
21
|
+
* @description 是否强制渲染组件,即使不可见也保持DOM结构
|
|
22
|
+
* @descriptionEn Whether to force render the component, maintaining DOM structure even when invisible
|
|
23
|
+
*/
|
|
24
|
+
forceRender?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @description 是否展开头部区域,控制显示状态
|
|
27
|
+
* @descriptionEn Whether to expand the header area, controls display state
|
|
28
|
+
*/
|
|
29
|
+
open?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @description 展开状态变化时的回调函数
|
|
32
|
+
* @descriptionEn Callback function when expand state changes
|
|
33
|
+
*/
|
|
34
|
+
onOpenChange?: (open: boolean) => void;
|
|
35
|
+
/**
|
|
36
|
+
* @description 头部标题内容,支持文本或React元素
|
|
37
|
+
* @descriptionEn Header title content, supports text or React elements
|
|
38
|
+
*/
|
|
39
|
+
title?: React.ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* @description 头部内容区域,用于显示额外的信息或控件
|
|
42
|
+
* @descriptionEn Header content area for displaying additional information or controls
|
|
43
|
+
*/
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* @description 组件的CSS类名
|
|
47
|
+
* @descriptionEn CSS class name for the component
|
|
48
|
+
*/
|
|
49
|
+
className?: string;
|
|
50
|
+
/**
|
|
51
|
+
* @description 组件的内联样式对象
|
|
52
|
+
* @descriptionEn Inline style object for the component
|
|
53
|
+
*/
|
|
54
|
+
style?: React.CSSProperties;
|
|
55
|
+
/**
|
|
56
|
+
* @description 语义化CSS类名,用于为不同区域添加自定义类名
|
|
57
|
+
* @descriptionEn Semantic CSS class names for adding custom classes to different areas
|
|
58
|
+
*/
|
|
59
|
+
classNames?: Partial<Record<SemanticType, string>>;
|
|
60
|
+
/**
|
|
61
|
+
* @description 语义化样式对象,用于精确控制不同区域的样式
|
|
62
|
+
* @descriptionEn Semantic style object for precise control of different area styles
|
|
63
|
+
*/
|
|
64
|
+
styles?: Partial<Record<SemanticType, React.CSSProperties>>;
|
|
65
|
+
/**
|
|
66
|
+
* @description 是否显示关闭按钮,用于控制头部区域的展开/收起
|
|
67
|
+
* @descriptionEn Whether to show close button for controlling header area expand/collapse
|
|
68
|
+
*/
|
|
69
|
+
closable?: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const collapseHeight: MotionEventHandler = () => ({
|
|
73
|
+
height: 0,
|
|
74
|
+
});
|
|
75
|
+
const expandedHeight: MotionEventHandler = (ele) => ({
|
|
76
|
+
height: ele.scrollHeight,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export default function SenderHeader(props: SenderHeaderProps) {
|
|
80
|
+
const {
|
|
81
|
+
title,
|
|
82
|
+
onOpenChange,
|
|
83
|
+
open,
|
|
84
|
+
children,
|
|
85
|
+
className,
|
|
86
|
+
style,
|
|
87
|
+
classNames: classes = {},
|
|
88
|
+
styles = {},
|
|
89
|
+
closable,
|
|
90
|
+
forceRender,
|
|
91
|
+
} = props;
|
|
92
|
+
|
|
93
|
+
const { prefixCls } = React.useContext(SendHeaderContext);
|
|
94
|
+
|
|
95
|
+
const headerCls = `${prefixCls}-header`;
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<CSSMotion
|
|
99
|
+
motionEnter
|
|
100
|
+
motionLeave
|
|
101
|
+
motionName={`${headerCls}-motion`}
|
|
102
|
+
leavedClassName={`${headerCls}-motion-hidden`}
|
|
103
|
+
onEnterStart={collapseHeight}
|
|
104
|
+
onEnterActive={expandedHeight}
|
|
105
|
+
onLeaveStart={expandedHeight}
|
|
106
|
+
onLeaveActive={collapseHeight}
|
|
107
|
+
visible={open}
|
|
108
|
+
forceRender={forceRender}
|
|
109
|
+
>
|
|
110
|
+
{({ className: motionClassName, style: motionStyle }) => {
|
|
111
|
+
return (
|
|
112
|
+
<div
|
|
113
|
+
className={classNames(headerCls, motionClassName, className)}
|
|
114
|
+
style={{
|
|
115
|
+
...motionStyle,
|
|
116
|
+
...style,
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
{/* Header */}
|
|
120
|
+
{(closable !== false || title) && (
|
|
121
|
+
<div
|
|
122
|
+
className={
|
|
123
|
+
// We follow antd naming standard here.
|
|
124
|
+
// So the header part is use `-header` suffix.
|
|
125
|
+
// Though its little bit weird for double `-header`.
|
|
126
|
+
classNames(`${headerCls}-header`, classes.header)
|
|
127
|
+
}
|
|
128
|
+
style={{
|
|
129
|
+
...styles.header,
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
<div className={`${headerCls}-title`}>{title}</div>
|
|
133
|
+
{closable !== false && (
|
|
134
|
+
<div className={`${headerCls}-close`}>
|
|
135
|
+
<Button
|
|
136
|
+
type="text"
|
|
137
|
+
icon={<CloseOutlined />}
|
|
138
|
+
size="small"
|
|
139
|
+
onClick={() => {
|
|
140
|
+
onOpenChange?.(!open);
|
|
141
|
+
}}
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
)}
|
|
145
|
+
</div>
|
|
146
|
+
)}
|
|
147
|
+
|
|
148
|
+
{/* Content */}
|
|
149
|
+
{children && (
|
|
150
|
+
<div
|
|
151
|
+
className={classNames(`${headerCls}-content`, classes.content)}
|
|
152
|
+
style={{
|
|
153
|
+
...styles.content,
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
{children}
|
|
157
|
+
</div>
|
|
158
|
+
)}
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
}}
|
|
162
|
+
</CSSMotion>
|
|
163
|
+
);
|
|
164
|
+
}
|