@baishuyun/chat-sdk 0.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.ts +21 -0
- package/.storybook/preview-head.html +1 -0
- package/.storybook/preview.ts +16 -0
- package/.turbo/turbo-build.log +82 -0
- package/components.json +22 -0
- package/dist/chat-sdk.js +55613 -0
- package/dist/chat-sdk.js.map +1 -0
- package/dist/chat-sdk.umd.cjs +661 -0
- package/dist/chat-sdk.umd.cjs.map +1 -0
- package/dist/chat.d.ts +5 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/components/biz-comp/FakeBotMsg.d.ts +7 -0
- package/dist/components/biz-comp/FakeBotMsg.d.ts.map +1 -0
- package/dist/components/biz-comp/FieldChecker.d.ts +16 -0
- package/dist/components/biz-comp/FieldChecker.d.ts.map +1 -0
- package/dist/components/biz-comp/FieldCheckerListMsg.d.ts +12 -0
- package/dist/components/biz-comp/FieldCheckerListMsg.d.ts.map +1 -0
- package/dist/components/biz-comp/FieldValueChecker.d.ts +14 -0
- package/dist/components/biz-comp/FieldValueChecker.d.ts.map +1 -0
- package/dist/components/biz-comp/SubformFieldsValueChecker.d.ts +20 -0
- package/dist/components/biz-comp/SubformFieldsValueChecker.d.ts.map +1 -0
- package/dist/components/biz-comp/chat-client.d.ts +13 -0
- package/dist/components/biz-comp/chat-client.d.ts.map +1 -0
- package/dist/components/biz-comp/chat-frame.d.ts +6 -0
- package/dist/components/biz-comp/chat-frame.d.ts.map +1 -0
- package/dist/components/biz-comp/conversation.d.ts +10 -0
- package/dist/components/biz-comp/conversation.d.ts.map +1 -0
- package/dist/components/biz-comp/dock-btn.d.ts +2 -0
- package/dist/components/biz-comp/dock-btn.d.ts.map +1 -0
- package/dist/components/biz-comp/field-icon.d.ts +5 -0
- package/dist/components/biz-comp/field-icon.d.ts.map +1 -0
- package/dist/components/biz-comp/markdown-part.d.ts +5 -0
- package/dist/components/biz-comp/markdown-part.d.ts.map +1 -0
- package/dist/components/biz-comp/markdown.d.ts +5 -0
- package/dist/components/biz-comp/markdown.d.ts.map +1 -0
- package/dist/components/biz-comp/message-content.d.ts +6 -0
- package/dist/components/biz-comp/message-content.d.ts.map +1 -0
- package/dist/components/biz-comp/messages.d.ts +3 -0
- package/dist/components/biz-comp/messages.d.ts.map +1 -0
- package/dist/components/biz-comp/multi-modal-input/attachment-btn.d.ts +9 -0
- package/dist/components/biz-comp/multi-modal-input/attachment-btn.d.ts.map +1 -0
- package/dist/components/biz-comp/multi-modal-input/clear-btn.d.ts +7 -0
- package/dist/components/biz-comp/multi-modal-input/clear-btn.d.ts.map +1 -0
- package/dist/components/biz-comp/multi-modal-input/index.d.ts +21 -0
- package/dist/components/biz-comp/multi-modal-input/index.d.ts.map +1 -0
- package/dist/components/biz-comp/multi-modal-input/preview-attachment.d.ts +12 -0
- package/dist/components/biz-comp/multi-modal-input/preview-attachment.d.ts.map +1 -0
- package/dist/components/biz-comp/multi-modal-input/prompt-input.d.ts +35 -0
- package/dist/components/biz-comp/multi-modal-input/prompt-input.d.ts.map +1 -0
- package/dist/components/biz-comp/opening-lines.d.ts +3 -0
- package/dist/components/biz-comp/opening-lines.d.ts.map +1 -0
- package/dist/components/biz-comp/preview-message-wrapper.d.ts +9 -0
- package/dist/components/biz-comp/preview-message-wrapper.d.ts.map +1 -0
- package/dist/components/biz-comp/preview-message.d.ts +11 -0
- package/dist/components/biz-comp/preview-message.d.ts.map +1 -0
- package/dist/components/biz-comp/response.d.ts +6 -0
- package/dist/components/biz-comp/response.d.ts.map +1 -0
- package/dist/components/biz-comp/suggestions.d.ts +7 -0
- package/dist/components/biz-comp/suggestions.d.ts.map +1 -0
- package/dist/components/bs-ui/abs-fullscreen-gradient-bg.d.ts +9 -0
- package/dist/components/bs-ui/abs-fullscreen-gradient-bg.d.ts.map +1 -0
- package/dist/components/bs-ui/attachments-previewer.d.ts +15 -0
- package/dist/components/bs-ui/attachments-previewer.d.ts.map +1 -0
- package/dist/components/bs-ui/border-color-animation.d.ts +9 -0
- package/dist/components/bs-ui/border-color-animation.d.ts.map +1 -0
- package/dist/components/bs-ui/bot-avatar-name.d.ts +6 -0
- package/dist/components/bs-ui/bot-avatar-name.d.ts.map +1 -0
- package/dist/components/bs-ui/bot-icon.d.ts +5 -0
- package/dist/components/bs-ui/bot-icon.d.ts.map +1 -0
- package/dist/components/bs-ui/bs-icons.d.ts +39 -0
- package/dist/components/bs-ui/bs-icons.d.ts.map +1 -0
- package/dist/components/bs-ui/card.d.ts +10 -0
- package/dist/components/bs-ui/card.d.ts.map +1 -0
- package/dist/components/bs-ui/chat-area-header.d.ts +9 -0
- package/dist/components/bs-ui/chat-area-header.d.ts.map +1 -0
- package/dist/components/bs-ui/collapsible-txt-msg.d.ts +10 -0
- package/dist/components/bs-ui/collapsible-txt-msg.d.ts.map +1 -0
- package/dist/components/bs-ui/confirm-dialog.d.ts +26 -0
- package/dist/components/bs-ui/confirm-dialog.d.ts.map +1 -0
- package/dist/components/bs-ui/fields-generating-indicator.d.ts +2 -0
- package/dist/components/bs-ui/fields-generating-indicator.d.ts.map +1 -0
- package/dist/components/bs-ui/fields-portal.d.ts +8 -0
- package/dist/components/bs-ui/fields-portal.d.ts.map +1 -0
- package/dist/components/bs-ui/fields-previewer.d.ts +12 -0
- package/dist/components/bs-ui/fields-previewer.d.ts.map +1 -0
- package/dist/components/bs-ui/font-icon.d.ts +6 -0
- package/dist/components/bs-ui/font-icon.d.ts.map +1 -0
- package/dist/components/bs-ui/form-info-editor.d.ts +37 -0
- package/dist/components/bs-ui/form-info-editor.d.ts.map +1 -0
- package/dist/components/bs-ui/generate-animation.d.ts +4 -0
- package/dist/components/bs-ui/generate-animation.d.ts.map +1 -0
- package/dist/components/bs-ui/icon-btn.d.ts +7 -0
- package/dist/components/bs-ui/icon-btn.d.ts.map +1 -0
- package/dist/components/bs-ui/line-checker.d.ts +15 -0
- package/dist/components/bs-ui/line-checker.d.ts.map +1 -0
- package/dist/components/bs-ui/linear-gradient-border-btn.d.ts +10 -0
- package/dist/components/bs-ui/linear-gradient-border-btn.d.ts.map +1 -0
- package/dist/components/bs-ui/linear-gradient-color-bg-animation.d.ts +8 -0
- package/dist/components/bs-ui/linear-gradient-color-bg-animation.d.ts.map +1 -0
- package/dist/components/bs-ui/option-item.d.ts +9 -0
- package/dist/components/bs-ui/option-item.d.ts.map +1 -0
- package/dist/components/bs-ui/previewer-header.d.ts +13 -0
- package/dist/components/bs-ui/previewer-header.d.ts.map +1 -0
- package/dist/components/bs-ui/primary-confirm-btn.d.ts +7 -0
- package/dist/components/bs-ui/primary-confirm-btn.d.ts.map +1 -0
- package/dist/components/bs-ui/primary-entry-btn.d.ts +9 -0
- package/dist/components/bs-ui/primary-entry-btn.d.ts.map +1 -0
- package/dist/components/bs-ui/tab-radio-group.d.ts +16 -0
- package/dist/components/bs-ui/tab-radio-group.d.ts.map +1 -0
- package/dist/components/bs-ui/tooltip.d.ts +5 -0
- package/dist/components/bs-ui/tooltip.d.ts.map +1 -0
- package/dist/components/bs-ui/user-txt-msg-bubble.d.ts +6 -0
- package/dist/components/bs-ui/user-txt-msg-bubble.d.ts.map +1 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/button.d.ts +12 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/checkbox.d.ts +5 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/collapsible.d.ts +6 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/dialog.d.ts +24 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +28 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/icons.d.ts +176 -0
- package/dist/components/ui/icons.d.ts.map +1 -0
- package/dist/components/ui/input-group.d.ts +17 -0
- package/dist/components/ui/input-group.d.ts.map +1 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/label.d.ts +6 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/one-time-click-btn.d.ts +4 -0
- package/dist/components/ui/one-time-click-btn.d.ts.map +1 -0
- package/dist/components/ui/select.d.ts +14 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/spinner.d.ts +3 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/tabs.d.ts +8 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/textarea.d.ts +4 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/tooltip.d.ts +8 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/web-comp/fields-previewer-web-component.d.ts +61 -0
- package/dist/components/web-comp/fields-previewer-web-component.d.ts.map +1 -0
- package/dist/const/index.d.ts +4 -0
- package/dist/const/index.d.ts.map +1 -0
- package/dist/const/ui.d.ts +4 -0
- package/dist/const/ui.d.ts.map +1 -0
- package/dist/hooks/use-evt-bus.d.ts +2 -0
- package/dist/hooks/use-evt-bus.d.ts.map +1 -0
- package/dist/hooks/use-evt.d.ts +3 -0
- package/dist/hooks/use-evt.d.ts.map +1 -0
- package/dist/hooks/use-frame-mode.d.ts +5 -0
- package/dist/hooks/use-frame-mode.d.ts.map +1 -0
- package/dist/hooks/use-plugin-component.d.ts +5 -0
- package/dist/hooks/use-plugin-component.d.ts.map +1 -0
- package/dist/hooks/use-plugin-ctx.d.ts +3 -0
- package/dist/hooks/use-plugin-ctx.d.ts.map +1 -0
- package/dist/hooks/use-plugin-custom-components.d.ts +4 -0
- package/dist/hooks/use-plugin-custom-components.d.ts.map +1 -0
- package/dist/hooks/use-plugin-life-cycle-chain-runner.d.ts +5 -0
- package/dist/hooks/use-plugin-life-cycle-chain-runner.d.ts.map +1 -0
- package/dist/hooks/use-plugin-list.d.ts +2 -0
- package/dist/hooks/use-plugin-list.d.ts.map +1 -0
- package/dist/hooks/use-plugin.d.ts +2 -0
- package/dist/hooks/use-plugin.d.ts.map +1 -0
- package/dist/hooks/use-shadow.d.ts +25 -0
- package/dist/hooks/use-shadow.d.ts.map +1 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/event-emitter.d.ts +39 -0
- package/dist/lib/event-emitter.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +30 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/plugins/form-builder-base-plugin/const.d.ts +3 -0
- package/dist/plugins/form-builder-base-plugin/const.d.ts.map +1 -0
- package/dist/plugins/form-builder-base-plugin/index.d.ts +7 -0
- package/dist/plugins/form-builder-base-plugin/index.d.ts.map +1 -0
- package/dist/plugins/form-builder-base-plugin/types.d.ts +12 -0
- package/dist/plugins/form-builder-base-plugin/types.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/FormFillingOpeningLines.d.ts +2 -0
- package/dist/plugins/form-filling-plugin/components/FormFillingOpeningLines.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/avatar.d.ts +5 -0
- package/dist/plugins/form-filling-plugin/components/avatar.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/entry-btn.d.ts +3 -0
- package/dist/plugins/form-filling-plugin/components/entry-btn.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/components/msg-part.d.ts +3 -0
- package/dist/plugins/form-filling-plugin/components/msg-part.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/const.d.ts +612 -0
- package/dist/plugins/form-filling-plugin/const.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/index.d.ts +13 -0
- package/dist/plugins/form-filling-plugin/index.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/types.d.ts +8 -0
- package/dist/plugins/form-filling-plugin/types.d.ts.map +1 -0
- package/dist/plugins/form-filling-plugin/utils.d.ts +4 -0
- package/dist/plugins/form-filling-plugin/utils.d.ts.map +1 -0
- package/dist/plugins/general-model-form-builder-plugin/components/confirmer.d.ts +9 -0
- package/dist/plugins/general-model-form-builder-plugin/components/confirmer.d.ts.map +1 -0
- package/dist/plugins/general-model-form-builder-plugin/components/ghost-evt-dispatcher.d.ts +10 -0
- package/dist/plugins/general-model-form-builder-plugin/components/ghost-evt-dispatcher.d.ts.map +1 -0
- package/dist/plugins/general-model-form-builder-plugin/components/msg-part.d.ts +3 -0
- package/dist/plugins/general-model-form-builder-plugin/components/msg-part.d.ts.map +1 -0
- package/dist/plugins/general-model-form-builder-plugin/components/new-confirmer.d.ts +10 -0
- package/dist/plugins/general-model-form-builder-plugin/components/new-confirmer.d.ts.map +1 -0
- package/dist/plugins/general-model-form-builder-plugin/const.d.ts +3 -0
- package/dist/plugins/general-model-form-builder-plugin/const.d.ts.map +1 -0
- package/dist/plugins/general-model-form-builder-plugin/index.d.ts +9 -0
- package/dist/plugins/general-model-form-builder-plugin/index.d.ts.map +1 -0
- package/dist/plugins/general-model-form-builder-plugin/types.d.ts +3 -0
- package/dist/plugins/general-model-form-builder-plugin/types.d.ts.map +1 -0
- package/dist/plugins/mcp-form-builder-plugin/components/create-form-confirm.d.ts +7 -0
- package/dist/plugins/mcp-form-builder-plugin/components/create-form-confirm.d.ts.map +1 -0
- package/dist/plugins/mcp-form-builder-plugin/components/entry-btn.d.ts +3 -0
- package/dist/plugins/mcp-form-builder-plugin/components/entry-btn.d.ts.map +1 -0
- package/dist/plugins/mcp-form-builder-plugin/components/follow-up.d.ts +3 -0
- package/dist/plugins/mcp-form-builder-plugin/components/follow-up.d.ts.map +1 -0
- package/dist/plugins/mcp-form-builder-plugin/components/msg-part.d.ts +3 -0
- package/dist/plugins/mcp-form-builder-plugin/components/msg-part.d.ts.map +1 -0
- package/dist/plugins/mcp-form-builder-plugin/const/index.d.ts +12 -0
- package/dist/plugins/mcp-form-builder-plugin/const/index.d.ts.map +1 -0
- package/dist/plugins/mcp-form-builder-plugin/hooks/index.d.ts +1 -0
- package/dist/plugins/mcp-form-builder-plugin/hooks/index.d.ts.map +1 -0
- package/dist/plugins/mcp-form-builder-plugin/hooks/use-fields-confirmed.d.ts +2 -0
- package/dist/plugins/mcp-form-builder-plugin/hooks/use-fields-confirmed.d.ts.map +1 -0
- package/dist/plugins/mcp-form-builder-plugin/index.d.ts +23 -0
- package/dist/plugins/mcp-form-builder-plugin/index.d.ts.map +1 -0
- package/dist/plugins/mcp-form-builder-plugin/types.d.ts +17 -0
- package/dist/plugins/mcp-form-builder-plugin/types.d.ts.map +1 -0
- package/dist/plugins/mcp-form-builder-plugin/utils/index.d.ts +51 -0
- package/dist/plugins/mcp-form-builder-plugin/utils/index.d.ts.map +1 -0
- package/dist/sdk.impl.d.ts +21 -0
- package/dist/sdk.impl.d.ts.map +1 -0
- package/dist/store/context.d.ts +12 -0
- package/dist/store/context.d.ts.map +1 -0
- package/dist/store/index.d.ts +13 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/stories/AbsFullscreenGradientBg.stories.d.ts +17 -0
- package/dist/stories/AbsFullscreenGradientBg.stories.d.ts.map +1 -0
- package/dist/stories/AttachmentsPreviewer.stories.d.ts +16 -0
- package/dist/stories/AttachmentsPreviewer.stories.d.ts.map +1 -0
- package/dist/stories/BorderColorAnimation.stories.d.ts +24 -0
- package/dist/stories/BorderColorAnimation.stories.d.ts.map +1 -0
- package/dist/stories/BotAvatarAndName.stories.d.ts +18 -0
- package/dist/stories/BotAvatarAndName.stories.d.ts.map +1 -0
- package/dist/stories/BotIcon.stories.d.ts +17 -0
- package/dist/stories/BotIcon.stories.d.ts.map +1 -0
- package/dist/stories/BsTooltip.stories.d.ts +7 -0
- package/dist/stories/BsTooltip.stories.d.ts.map +1 -0
- package/dist/stories/Card.stories.d.ts +14 -0
- package/dist/stories/Card.stories.d.ts.map +1 -0
- package/dist/stories/ChatAreaHeader.stories.d.ts +14 -0
- package/dist/stories/ChatAreaHeader.stories.d.ts.map +1 -0
- package/dist/stories/CollapsibleTextMsg.stories.d.ts +16 -0
- package/dist/stories/CollapsibleTextMsg.stories.d.ts.map +1 -0
- package/dist/stories/ConfirmDialog.stories.d.ts +61 -0
- package/dist/stories/ConfirmDialog.stories.d.ts.map +1 -0
- package/dist/stories/FormInfoEditor.stories.d.ts +15 -0
- package/dist/stories/FormInfoEditor.stories.d.ts.map +1 -0
- package/dist/stories/GenerateAnimation.stories.d.ts +16 -0
- package/dist/stories/GenerateAnimation.stories.d.ts.map +1 -0
- package/dist/stories/IconBtn.stories.d.ts +14 -0
- package/dist/stories/IconBtn.stories.d.ts.map +1 -0
- package/dist/stories/IconLib.d.ts +12 -0
- package/dist/stories/IconLib.d.ts.map +1 -0
- package/dist/stories/Icons.stories.d.ts +24 -0
- package/dist/stories/Icons.stories.d.ts.map +1 -0
- package/dist/stories/LineChecker.stories.d.ts +23 -0
- package/dist/stories/LineChecker.stories.d.ts.map +1 -0
- package/dist/stories/LinearGradientBorderBtn.stories.d.ts +22 -0
- package/dist/stories/LinearGradientBorderBtn.stories.d.ts.map +1 -0
- package/dist/stories/LinearGradientColorBgAnimation.stories.d.ts +23 -0
- package/dist/stories/LinearGradientColorBgAnimation.stories.d.ts.map +1 -0
- package/dist/stories/OptionItem.stories.d.ts +20 -0
- package/dist/stories/OptionItem.stories.d.ts.map +1 -0
- package/dist/stories/PreviewerHeader.stories.d.ts +9 -0
- package/dist/stories/PreviewerHeader.stories.d.ts.map +1 -0
- package/dist/stories/PrimaryConfirmBtn.stories.d.ts +16 -0
- package/dist/stories/PrimaryConfirmBtn.stories.d.ts.map +1 -0
- package/dist/stories/PrimaryEntryBtn.stories.d.ts +26 -0
- package/dist/stories/PrimaryEntryBtn.stories.d.ts.map +1 -0
- package/dist/stories/TabRadioGroup.stories.d.ts +18 -0
- package/dist/stories/TabRadioGroup.stories.d.ts.map +1 -0
- package/dist/stories/UserTextMsgBubble.stories.d.ts +14 -0
- package/dist/stories/UserTextMsgBubble.stories.d.ts.map +1 -0
- package/dist/stories/fields-generating.stories.d.ts +14 -0
- package/dist/stories/fields-generating.stories.d.ts.map +1 -0
- package/dist/stories/fields-previewer.stories.d.ts +18 -0
- package/dist/stories/fields-previewer.stories.d.ts.map +1 -0
- package/package.json +76 -0
- package/scripts/inline-style-inject.ts +36 -0
- package/src/chat.tsx +56 -0
- package/src/components/biz-comp/FakeBotMsg.tsx +52 -0
- package/src/components/biz-comp/FieldChecker.tsx +114 -0
- package/src/components/biz-comp/FieldCheckerListMsg.tsx +34 -0
- package/src/components/biz-comp/FieldValueChecker.tsx +98 -0
- package/src/components/biz-comp/SubformFieldsValueChecker.tsx +166 -0
- package/src/components/biz-comp/chat-client.tsx +206 -0
- package/src/components/biz-comp/chat-frame.tsx +25 -0
- package/src/components/biz-comp/conversation.tsx +70 -0
- package/src/components/biz-comp/dock-btn.tsx +52 -0
- package/src/components/biz-comp/field-icon.tsx +8 -0
- package/src/components/biz-comp/markdown-part.tsx +48 -0
- package/src/components/biz-comp/markdown.tsx +36 -0
- package/src/components/biz-comp/message-content.tsx +21 -0
- package/src/components/biz-comp/messages.tsx +42 -0
- package/src/components/biz-comp/multi-modal-input/attachment-btn.tsx +30 -0
- package/src/components/biz-comp/multi-modal-input/clear-btn.tsx +42 -0
- package/src/components/biz-comp/multi-modal-input/index.tsx +422 -0
- package/src/components/biz-comp/multi-modal-input/preview-attachment.tsx +72 -0
- package/src/components/biz-comp/multi-modal-input/prompt-input.tsx +260 -0
- package/src/components/biz-comp/opening-lines.tsx +34 -0
- package/src/components/biz-comp/preview-message-wrapper.tsx +55 -0
- package/src/components/biz-comp/preview-message.tsx +91 -0
- package/src/components/biz-comp/response.tsx +23 -0
- package/src/components/biz-comp/suggestions.tsx +78 -0
- package/src/components/bs-ui/abs-fullscreen-gradient-bg.tsx +34 -0
- package/src/components/bs-ui/attachments-previewer.tsx +229 -0
- package/src/components/bs-ui/border-color-animation.tsx +58 -0
- package/src/components/bs-ui/bot-avatar-name.tsx +25 -0
- package/src/components/bs-ui/bot-icon.tsx +23 -0
- package/src/components/bs-ui/bs-icons.tsx +801 -0
- package/src/components/bs-ui/card.tsx +37 -0
- package/src/components/bs-ui/chat-area-header.tsx +41 -0
- package/src/components/bs-ui/collapsible-txt-msg.tsx +50 -0
- package/src/components/bs-ui/confirm-dialog.tsx +128 -0
- package/src/components/bs-ui/fields-generating-indicator.tsx +50 -0
- package/src/components/bs-ui/fields-portal.tsx +18 -0
- package/src/components/bs-ui/fields-previewer.tsx +109 -0
- package/src/components/bs-ui/font-icon.tsx +17 -0
- package/src/components/bs-ui/form-info-editor.tsx +286 -0
- package/src/components/bs-ui/generate-animation.tsx +54 -0
- package/src/components/bs-ui/icon-btn.tsx +31 -0
- package/src/components/bs-ui/line-checker.tsx +129 -0
- package/src/components/bs-ui/linear-gradient-border-btn.tsx +48 -0
- package/src/components/bs-ui/linear-gradient-color-bg-animation.tsx +103 -0
- package/src/components/bs-ui/option-item.tsx +28 -0
- package/src/components/bs-ui/previewer-header.tsx +134 -0
- package/src/components/bs-ui/primary-confirm-btn.tsx +46 -0
- package/src/components/bs-ui/primary-entry-btn.tsx +37 -0
- package/src/components/bs-ui/tab-radio-group.tsx +73 -0
- package/src/components/bs-ui/tooltip.tsx +18 -0
- package/src/components/bs-ui/user-txt-msg-bubble.tsx +19 -0
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/button.tsx +51 -0
- package/src/components/ui/card.tsx +76 -0
- package/src/components/ui/checkbox.tsx +29 -0
- package/src/components/ui/collapsible.tsx +9 -0
- package/src/components/ui/dialog.tsx +104 -0
- package/src/components/ui/dropdown-menu.tsx +199 -0
- package/src/components/ui/icons.tsx +1288 -0
- package/src/components/ui/input-group.tsx +172 -0
- package/src/components/ui/input.tsx +22 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/one-time-click-btn.tsx +32 -0
- package/src/components/ui/select.tsx +157 -0
- package/src/components/ui/spinner.tsx +17 -0
- package/src/components/ui/tabs.tsx +53 -0
- package/src/components/ui/textarea.tsx +22 -0
- package/src/components/ui/tooltip.tsx +34 -0
- package/src/components/web-comp/fields-previewer-web-component.ts +259 -0
- package/src/const/index.ts +61 -0
- package/src/const/ui.ts +7 -0
- package/src/global.d.ts +1 -0
- package/src/hooks/use-evt-bus.ts +11 -0
- package/src/hooks/use-evt.ts +17 -0
- package/src/hooks/use-frame-mode.ts +13 -0
- package/src/hooks/use-plugin-component.ts +12 -0
- package/src/hooks/use-plugin-ctx.ts +12 -0
- package/src/hooks/use-plugin-custom-components.ts +31 -0
- package/src/hooks/use-plugin-life-cycle-chain-runner.ts +26 -0
- package/src/hooks/use-plugin-list.ts +11 -0
- package/src/hooks/use-plugin.ts +11 -0
- package/src/hooks/use-shadow.ts +128 -0
- package/src/index.tsx +10 -0
- package/src/lib/event-emitter.ts +93 -0
- package/src/lib/utils.ts +222 -0
- package/src/plugins/form-builder-base-plugin/const.ts +27 -0
- package/src/plugins/form-builder-base-plugin/index.ts +45 -0
- package/src/plugins/form-builder-base-plugin/types.ts +13 -0
- package/src/plugins/form-filling-plugin/components/FormFillingOpeningLines.tsx +3 -0
- package/src/plugins/form-filling-plugin/components/avatar.tsx +14 -0
- package/src/plugins/form-filling-plugin/components/entry-btn.tsx +15 -0
- package/src/plugins/form-filling-plugin/components/msg-part.tsx +90 -0
- package/src/plugins/form-filling-plugin/const.ts +595 -0
- package/src/plugins/form-filling-plugin/index.ts +135 -0
- package/src/plugins/form-filling-plugin/types.ts +11 -0
- package/src/plugins/form-filling-plugin/utils.ts +63 -0
- package/src/plugins/general-model-form-builder-plugin/components/confirmer.tsx +90 -0
- package/src/plugins/general-model-form-builder-plugin/components/ghost-evt-dispatcher.tsx +69 -0
- package/src/plugins/general-model-form-builder-plugin/components/msg-part.tsx +147 -0
- package/src/plugins/general-model-form-builder-plugin/components/new-confirmer.tsx +191 -0
- package/src/plugins/general-model-form-builder-plugin/const.ts +3 -0
- package/src/plugins/general-model-form-builder-plugin/index.ts +20 -0
- package/src/plugins/general-model-form-builder-plugin/types.ts +1 -0
- package/src/plugins/mcp-form-builder-plugin/components/create-form-confirm.tsx +126 -0
- package/src/plugins/mcp-form-builder-plugin/components/entry-btn.tsx +9 -0
- package/src/plugins/mcp-form-builder-plugin/components/follow-up.tsx +15 -0
- package/src/plugins/mcp-form-builder-plugin/components/msg-part.tsx +135 -0
- package/src/plugins/mcp-form-builder-plugin/const/index.ts +13 -0
- package/src/plugins/mcp-form-builder-plugin/hooks/index.ts +0 -0
- package/src/plugins/mcp-form-builder-plugin/hooks/use-fields-confirmed.ts +12 -0
- package/src/plugins/mcp-form-builder-plugin/index.ts +225 -0
- package/src/plugins/mcp-form-builder-plugin/types.ts +21 -0
- package/src/plugins/mcp-form-builder-plugin/utils/index.ts +450 -0
- package/src/sdk.impl.tsx +108 -0
- package/src/store/context.tsx +22 -0
- package/src/store/index.ts +53 -0
- package/src/stories/AbsFullscreenGradientBg.stories.tsx +36 -0
- package/src/stories/AttachmentsPreviewer.stories.tsx +188 -0
- package/src/stories/BorderColorAnimation.stories.tsx +60 -0
- package/src/stories/BotAvatarAndName.stories.ts +24 -0
- package/src/stories/BotIcon.stories.ts +22 -0
- package/src/stories/BsTooltip.stories.tsx +32 -0
- package/src/stories/Card.stories.tsx +28 -0
- package/src/stories/ChatAreaHeader.stories.ts +26 -0
- package/src/stories/CollapsibleTextMsg.stories.ts +44 -0
- package/src/stories/ConfirmDialog.stories.tsx +123 -0
- package/src/stories/FormInfoEditor.stories.tsx +183 -0
- package/src/stories/GenerateAnimation.stories.ts +20 -0
- package/src/stories/IconBtn.stories.tsx +26 -0
- package/src/stories/IconLib.tsx +47 -0
- package/src/stories/Icons.stories.ts +22 -0
- package/src/stories/LineChecker.stories.tsx +134 -0
- package/src/stories/LinearGradientBorderBtn.stories.tsx +86 -0
- package/src/stories/LinearGradientColorBgAnimation.stories.tsx +60 -0
- package/src/stories/OptionItem.stories.tsx +77 -0
- package/src/stories/PreviewerHeader.stories.tsx +45 -0
- package/src/stories/PrimaryConfirmBtn.stories.ts +37 -0
- package/src/stories/PrimaryEntryBtn.stories.tsx +74 -0
- package/src/stories/TabRadioGroup.stories.tsx +84 -0
- package/src/stories/UserTextMsgBubble.stories.ts +24 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +1 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/demo.css +539 -0
- package/src/stories/assets/demo_index.html +7988 -0
- package/src/stories/assets/discord.svg +1 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +1 -0
- package/src/stories/assets/iconfont.css +1377 -0
- package/src/stories/assets/iconfont.eot +0 -0
- package/src/stories/assets/iconfont.json +2382 -0
- package/src/stories/assets/iconfont.svg +697 -0
- package/src/stories/assets/iconfont.ttf +0 -0
- package/src/stories/assets/iconfont.woff +0 -0
- package/src/stories/assets/iconfont.woff2 +0 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +1 -0
- package/src/stories/assets/youtube.svg +1 -0
- package/src/stories/fields-generating.stories.tsx +22 -0
- package/src/stories/fields-previewer.stories.tsx +67 -0
- package/src/style.css +172 -0
- package/stats.html +4949 -0
- package/tailwind.config.js +49 -0
- package/tsconfig.json +13 -0
- package/vite.config.ts +38 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { memo, ReactNode } from 'react';
|
|
2
|
+
import { CollapsibleTxtMsg } from '../bs-ui/collapsible-txt-msg';
|
|
3
|
+
import { FieldChecker, FieldCheckerProps } from './FieldChecker';
|
|
4
|
+
import { EditIcon, LetterAIcon } from '../bs-ui/bs-icons';
|
|
5
|
+
import { FieldValueChecker, FieldValueCheckerProps } from './FieldValueChecker';
|
|
6
|
+
|
|
7
|
+
export const FieldCheckerListMsg = memo(
|
|
8
|
+
({ fields, children }: { fields: Array<FieldCheckerProps>; children?: ReactNode }) => {
|
|
9
|
+
return (
|
|
10
|
+
<CollapsibleTxtMsg title="字段生成" icon={<LetterAIcon />} defaultOpen>
|
|
11
|
+
{fields.map((f) => (
|
|
12
|
+
<FieldChecker {...f} />
|
|
13
|
+
))}
|
|
14
|
+
{children}
|
|
15
|
+
</CollapsibleTxtMsg>
|
|
16
|
+
);
|
|
17
|
+
},
|
|
18
|
+
(p1, p2) => {
|
|
19
|
+
return p1.fields.length === p2.fields.length;
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const FieldValueCheckerListMsg = memo(
|
|
24
|
+
({ props, children }: { props: Array<FieldValueCheckerProps>; children?: ReactNode }) => {
|
|
25
|
+
return (
|
|
26
|
+
<CollapsibleTxtMsg title="字段填写" icon={<EditIcon />} defaultOpen>
|
|
27
|
+
{props.map((f) => (
|
|
28
|
+
<FieldValueChecker {...f} />
|
|
29
|
+
))}
|
|
30
|
+
{children}
|
|
31
|
+
</CollapsibleTxtMsg>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Checkbox } from '@/components/ui/checkbox';
|
|
2
|
+
import { memo, useEffect } from 'react';
|
|
3
|
+
import { Label } from '@/components/ui/label';
|
|
4
|
+
import { FieldType, ValueOf } from '@baishuyun/types';
|
|
5
|
+
import { FieldTypeNameMap } from '@/const';
|
|
6
|
+
import { ToolUIPart } from 'ai';
|
|
7
|
+
import { FieldsTools } from '@baishuyun/agents';
|
|
8
|
+
import { cn, isSubformFieldEqual } from '@/lib/utils';
|
|
9
|
+
import { toHumanReadable } from '@/plugins/form-filling-plugin/utils';
|
|
10
|
+
import { SubformFieldsValueChecker } from './SubformFieldsValueChecker';
|
|
11
|
+
import LineChecker from '../bs-ui/line-checker';
|
|
12
|
+
|
|
13
|
+
type Field = ValueOf<Pick<ToolUIPart<FieldsTools>, 'output'>>;
|
|
14
|
+
|
|
15
|
+
export interface FieldValueCheckerProps {
|
|
16
|
+
field: ValueOf<Pick<ToolUIPart<FieldsTools>, 'output'>>;
|
|
17
|
+
isSubField?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
onChange?: (checked: boolean, field: Field, parentFieldName?: string, index?: number) => void;
|
|
20
|
+
onLoaded?: (field: Field) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const FieldValueChecker = memo(
|
|
24
|
+
({ field, disabled, isSubField, onChange, onLoaded }: FieldValueCheckerProps) => {
|
|
25
|
+
const { widget, label } = field;
|
|
26
|
+
if (!widget) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const { type, value: v } = widget;
|
|
31
|
+
|
|
32
|
+
const t = type as FieldType;
|
|
33
|
+
|
|
34
|
+
const value = toHumanReadable(v, t);
|
|
35
|
+
|
|
36
|
+
if (!FieldTypeNameMap.hasOwnProperty(type)) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const typeDesc = FieldTypeNameMap[t] || FieldTypeNameMap.unknown;
|
|
41
|
+
|
|
42
|
+
const isSubForm = type === 'subform';
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
onLoaded?.(field);
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
const handleCheck = (checked: boolean) => {
|
|
49
|
+
onChange?.(checked, field);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const extraPadding = isSubField ? 'pl-6' : '';
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<>
|
|
56
|
+
<LineChecker
|
|
57
|
+
title={label}
|
|
58
|
+
disabled={disabled}
|
|
59
|
+
defaultChecked={true}
|
|
60
|
+
onCheckedChange={handleCheck}
|
|
61
|
+
className={extraPadding}
|
|
62
|
+
shortDesc={isSubForm ? '' : (value as string)}
|
|
63
|
+
// extra={typeDesc}
|
|
64
|
+
/>
|
|
65
|
+
{isSubForm && (
|
|
66
|
+
<SubformFieldsValueChecker
|
|
67
|
+
subformField={field}
|
|
68
|
+
onChange={(detail) => {
|
|
69
|
+
onChange?.(detail.checked, detail.field, detail.parentFieldName, detail.row);
|
|
70
|
+
}}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
(p1, p2) => {
|
|
77
|
+
// 标签一致
|
|
78
|
+
const isLabelEqual = p1.field?.label === p2.field?.label;
|
|
79
|
+
if (!isLabelEqual) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// id 一致
|
|
84
|
+
const isFieldNameEqual = p1.field?.widget?.widgetName === p2.field?.widget?.widgetName;
|
|
85
|
+
if (!isFieldNameEqual) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 禁用状态一致
|
|
90
|
+
const isDisabledEqual = p1.disabled === p2.disabled;
|
|
91
|
+
if (!isDisabledEqual) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 进一步比较子表单下的字段
|
|
96
|
+
return isSubformFieldEqual(p1?.field, p2?.field);
|
|
97
|
+
}
|
|
98
|
+
);
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { memo, useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { FieldType, ValueOf } from '@baishuyun/types';
|
|
3
|
+
import { FieldTypeNameMap } from '@/const';
|
|
4
|
+
import { ToolUIPart } from 'ai';
|
|
5
|
+
import { FieldsTools } from '@baishuyun/agents';
|
|
6
|
+
import { toHumanReadable } from '@/plugins/form-filling-plugin/utils';
|
|
7
|
+
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '../ui/collapsible';
|
|
8
|
+
import LineChecker from '../bs-ui/line-checker';
|
|
9
|
+
|
|
10
|
+
const Checker = ({
|
|
11
|
+
disabled,
|
|
12
|
+
onCheckedChange,
|
|
13
|
+
|
|
14
|
+
label,
|
|
15
|
+
val,
|
|
16
|
+
desc,
|
|
17
|
+
}: {
|
|
18
|
+
label: string;
|
|
19
|
+
val: string;
|
|
20
|
+
onCheckedChange: (v: boolean) => void;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
desc: string;
|
|
23
|
+
}) => {
|
|
24
|
+
return (
|
|
25
|
+
<LineChecker
|
|
26
|
+
title={label}
|
|
27
|
+
disabled={disabled}
|
|
28
|
+
defaultChecked={true}
|
|
29
|
+
onCheckedChange={onCheckedChange}
|
|
30
|
+
className="pl-[36px]"
|
|
31
|
+
shortDesc={val}
|
|
32
|
+
// extra={desc}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const SubFieldChecker = memo(
|
|
38
|
+
({
|
|
39
|
+
field,
|
|
40
|
+
onCheckedChange,
|
|
41
|
+
}: {
|
|
42
|
+
onCheckedChange: (
|
|
43
|
+
checked: boolean,
|
|
44
|
+
field: ValueOf<Pick<ToolUIPart<FieldsTools>, 'output'>>
|
|
45
|
+
) => void;
|
|
46
|
+
field: ValueOf<Pick<ToolUIPart<FieldsTools>, 'output'>>;
|
|
47
|
+
}) => {
|
|
48
|
+
const { widget, label } = field;
|
|
49
|
+
if (!widget) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { type, value: v } = widget;
|
|
54
|
+
const t = type as FieldType;
|
|
55
|
+
if (!FieldTypeNameMap.hasOwnProperty(t)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const value = toHumanReadable(v, t);
|
|
60
|
+
|
|
61
|
+
const typeDesc = FieldTypeNameMap[t] || FieldTypeNameMap.unknown;
|
|
62
|
+
|
|
63
|
+
const handleCheckChange = useCallback(
|
|
64
|
+
(v: boolean) => {
|
|
65
|
+
onCheckedChange(v, field);
|
|
66
|
+
},
|
|
67
|
+
[field]
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
// 默认勾选上
|
|
72
|
+
handleCheckChange(true);
|
|
73
|
+
}, []);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Checker
|
|
77
|
+
desc={typeDesc}
|
|
78
|
+
label={label}
|
|
79
|
+
val={value as string}
|
|
80
|
+
onCheckedChange={handleCheckChange}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
(p1, p2) => {
|
|
85
|
+
console.log(p1, p2);
|
|
86
|
+
const isNameEqual = p1.field.widget?.widgetName === p2.field.widget?.widgetName;
|
|
87
|
+
return isNameEqual;
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
type F = ValueOf<Pick<ToolUIPart<FieldsTools>, 'output'>>;
|
|
92
|
+
|
|
93
|
+
interface generatedField {
|
|
94
|
+
label: string;
|
|
95
|
+
fieldName: string;
|
|
96
|
+
fieldType: string;
|
|
97
|
+
value: any;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
type onSubformFieldChangeParam = {
|
|
101
|
+
checked: boolean;
|
|
102
|
+
field: F;
|
|
103
|
+
parentFieldName: string;
|
|
104
|
+
row?: number;
|
|
105
|
+
col?: number;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 专门渲染子表单下的字段勾选
|
|
110
|
+
*/
|
|
111
|
+
export const SubformFieldsValueChecker = ({
|
|
112
|
+
subformField,
|
|
113
|
+
onChange,
|
|
114
|
+
}: {
|
|
115
|
+
onChange: (p: onSubformFieldChangeParam) => void;
|
|
116
|
+
subformField: ValueOf<Pick<ToolUIPart<FieldsTools>, 'output'>>;
|
|
117
|
+
}) => {
|
|
118
|
+
if (!subformField.widget.value || !subformField.widget.value.length) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const subformRecords = subformField.widget.value;
|
|
123
|
+
|
|
124
|
+
// 默认展开
|
|
125
|
+
const [openAll, setOpenAll] = useState(true);
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<Collapsible open={openAll} onOpenChange={setOpenAll}>
|
|
129
|
+
{/* <CollapsibleTrigger>子表单数据</CollapsibleTrigger> */}
|
|
130
|
+
<CollapsibleContent>
|
|
131
|
+
{subformRecords.map((rowData: generatedField[], row: number) => {
|
|
132
|
+
return (
|
|
133
|
+
<Collapsible defaultOpen={true} key={row}>
|
|
134
|
+
{/* <CollapsibleTrigger>Row {row + 1}</CollapsibleTrigger> */}
|
|
135
|
+
<CollapsibleContent>
|
|
136
|
+
{rowData.map((fData: generatedField, col: number) => {
|
|
137
|
+
return (
|
|
138
|
+
<SubFieldChecker
|
|
139
|
+
field={{
|
|
140
|
+
label: fData.label,
|
|
141
|
+
widget: {
|
|
142
|
+
widgetName: fData.fieldName,
|
|
143
|
+
type: fData.fieldType,
|
|
144
|
+
value: fData.value,
|
|
145
|
+
},
|
|
146
|
+
}}
|
|
147
|
+
onCheckedChange={(checked: boolean, field: F) => {
|
|
148
|
+
onChange({
|
|
149
|
+
checked,
|
|
150
|
+
field,
|
|
151
|
+
row,
|
|
152
|
+
col,
|
|
153
|
+
parentFieldName: subformField.widget.widgetName,
|
|
154
|
+
});
|
|
155
|
+
}}
|
|
156
|
+
/>
|
|
157
|
+
);
|
|
158
|
+
})}
|
|
159
|
+
</CollapsibleContent>
|
|
160
|
+
</Collapsible>
|
|
161
|
+
);
|
|
162
|
+
})}
|
|
163
|
+
</CollapsibleContent>
|
|
164
|
+
</Collapsible>
|
|
165
|
+
);
|
|
166
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import React, { ComponentType, useEffect } from 'react';
|
|
2
|
+
import { ChatStore } from '@/store';
|
|
3
|
+
import { ChatSDK } from '@/.';
|
|
4
|
+
import { ChatStoreProvider, useChatStore } from '@/store/context';
|
|
5
|
+
import { Chat } from '@/chat';
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
import { ReactPortal } from 'react';
|
|
8
|
+
import { createPortal } from 'react-dom';
|
|
9
|
+
import { useFrameMode } from '@/hooks/use-frame-mode';
|
|
10
|
+
import { PrimaryEntryBtn } from '../bs-ui/primary-entry-btn';
|
|
11
|
+
import { useShadow } from '@/hooks/use-shadow';
|
|
12
|
+
import { ChatAreaHeader } from '../bs-ui/chat-area-header';
|
|
13
|
+
import { useDefaultPluginCustomComponent } from '@/hooks/use-plugin-custom-components';
|
|
14
|
+
import { BotAvatarAndName } from '../bs-ui/bot-avatar-name';
|
|
15
|
+
|
|
16
|
+
const ChatSlot = ({ client }: { client?: ChatSDK }) => {
|
|
17
|
+
const { chatVisible, setChatVisible, setFrameMode } = useChatStore((store) => ({
|
|
18
|
+
chatVisible: store.chatAreaVisible,
|
|
19
|
+
setFrameMode: store.setFrameMode,
|
|
20
|
+
setChatVisible: store.setChatAreaVisible,
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
const { mode, setMode } = useFrameMode();
|
|
24
|
+
|
|
25
|
+
const isFloat = mode === 'float';
|
|
26
|
+
const isEmbedded = mode === 'dock';
|
|
27
|
+
|
|
28
|
+
const modeCls = cn({
|
|
29
|
+
'fixed z-50 rounded-lg shadow-lg': isFloat,
|
|
30
|
+
hidden: !chatVisible,
|
|
31
|
+
'static w-full h-full shadow-md': isEmbedded,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const avatarComInfo = useDefaultPluginCustomComponent('AvatarAndName');
|
|
35
|
+
const Avatar: ComponentType<{ variant?: 'default' | 'active' }> | undefined =
|
|
36
|
+
avatarComInfo?.Component;
|
|
37
|
+
const avatarJsx = Avatar ? (
|
|
38
|
+
<Avatar variant="active" />
|
|
39
|
+
) : (
|
|
40
|
+
<BotAvatarAndName name={'AI表单搭建'} variant="active" />
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const modeStyle = isFloat
|
|
44
|
+
? {
|
|
45
|
+
width: 354,
|
|
46
|
+
height: 'calc(100% - 20px)',
|
|
47
|
+
bottom: '10px',
|
|
48
|
+
right: '10px',
|
|
49
|
+
zIndex: client?.options?.safeZIndex ?? 0 + 1,
|
|
50
|
+
}
|
|
51
|
+
: {};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className={cn('bg-white flex flex-col overflow-hidden', modeCls)} style={modeStyle}>
|
|
55
|
+
<ChatAreaHeader
|
|
56
|
+
onDockClick={() => {
|
|
57
|
+
const isFloat = mode === 'float';
|
|
58
|
+
isFloat ? setMode('dock') : setMode('float');
|
|
59
|
+
}}
|
|
60
|
+
avatar={avatarJsx}
|
|
61
|
+
onCloseClick={() => {
|
|
62
|
+
setChatVisible(false);
|
|
63
|
+
setFrameMode('float');
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
<Chat client={client!} />
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const ChatContent: React.FC<{ client?: ChatSDK }> = ({ client }): ReactPortal | null => {
|
|
72
|
+
const { chatVisible } = useChatStore((store) => ({
|
|
73
|
+
chatVisible: store.chatAreaVisible,
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
const fullCls = ['h-full', 'w-full'];
|
|
77
|
+
const fullStyle = { height: '100%', width: '100%' };
|
|
78
|
+
|
|
79
|
+
// 调用通用Hook创建Shadow DOM
|
|
80
|
+
const { shadowContainer: chatContentEl } = useShadow({
|
|
81
|
+
id: 'chat-sdk-content',
|
|
82
|
+
style: client?.options?.style || '', // 注入SDK配置的样式
|
|
83
|
+
rootEl: client?.options?.el || document.body, // 挂载到SDK指定的根元素
|
|
84
|
+
containerClasses: chatVisible ? fullCls : [],
|
|
85
|
+
wrapperClasses: chatVisible ? fullCls : [],
|
|
86
|
+
wrapperStyle: chatVisible ? fullStyle : {},
|
|
87
|
+
extraHtml: client?.options?.extraHtml || '', // 注入额外的HTML
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const root = client?.options?.el;
|
|
92
|
+
if (!root) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
root.style.pointerEvents = chatVisible ? 'auto' : 'none';
|
|
97
|
+
}, [chatVisible]);
|
|
98
|
+
|
|
99
|
+
if (!chatContentEl) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return createPortal(<ChatSlot client={client} />, chatContentEl) as ReactPortal;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const ChatEntryBtn = ({ client }: { client?: ChatSDK }) => {
|
|
107
|
+
const { bottom = 10, right = 10 } = client?.options?.btnOffset || {};
|
|
108
|
+
|
|
109
|
+
const { entryVisible, entryWrapper, setChatVisible, setFrameMode, chatVisible } = useChatStore(
|
|
110
|
+
(store) => ({
|
|
111
|
+
setFrameMode: store.setFrameMode,
|
|
112
|
+
entryWrapper: store.chatEntryElWrapper,
|
|
113
|
+
chatVisible: store.chatAreaVisible,
|
|
114
|
+
entryVisible: store.chatEntryVisible,
|
|
115
|
+
setChatVisible: store.setChatAreaVisible,
|
|
116
|
+
})
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const hasWrapper = Boolean(entryWrapper);
|
|
120
|
+
|
|
121
|
+
const EntryInfo = useDefaultPluginCustomComponent('EntryButton');
|
|
122
|
+
const EntryCom = EntryInfo?.Component;
|
|
123
|
+
|
|
124
|
+
const entryStyle: React.CSSProperties = hasWrapper
|
|
125
|
+
? {
|
|
126
|
+
cursor: 'pointer',
|
|
127
|
+
}
|
|
128
|
+
: {
|
|
129
|
+
position: 'fixed',
|
|
130
|
+
cursor: 'pointer',
|
|
131
|
+
bottom,
|
|
132
|
+
right,
|
|
133
|
+
zIndex: client?.options?.safeZIndex,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const EntryJsx = EntryCom ? (
|
|
137
|
+
<EntryCom
|
|
138
|
+
chatVisible={chatVisible}
|
|
139
|
+
onClick={() => {
|
|
140
|
+
setFrameMode('dock');
|
|
141
|
+
setChatVisible(true);
|
|
142
|
+
}}
|
|
143
|
+
style={entryStyle}
|
|
144
|
+
/>
|
|
145
|
+
) : (
|
|
146
|
+
<PrimaryEntryBtn
|
|
147
|
+
style={entryStyle}
|
|
148
|
+
minimal={chatVisible}
|
|
149
|
+
onClick={() => {
|
|
150
|
+
setFrameMode('dock');
|
|
151
|
+
setChatVisible(true);
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
AI助手
|
|
155
|
+
</PrimaryEntryBtn>
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const { shadowContainer: shadowEntry, destroy: destroyShadowEntry } = useShadow({
|
|
159
|
+
id: 'chat-sdk-entry',
|
|
160
|
+
rootEl: entryWrapper,
|
|
161
|
+
containerClasses: ['inline-flex'],
|
|
162
|
+
wrapperClasses: ['inline-flex'],
|
|
163
|
+
style: client?.options?.style || '', // 注入SDK配置的样式
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
if (!entryVisible) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (hasWrapper) {
|
|
171
|
+
if (!shadowEntry) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return createPortal(EntryJsx, shadowEntry) as ReactPortal;
|
|
176
|
+
} else {
|
|
177
|
+
destroyShadowEntry();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return EntryJsx;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const ChatWidgets = ({ client }: { client?: ChatSDK }) => {
|
|
184
|
+
const { mode } = useChatStore((store) => ({
|
|
185
|
+
mode: store.frameMode,
|
|
186
|
+
}));
|
|
187
|
+
|
|
188
|
+
useEffect(() => {
|
|
189
|
+
client?.options?.onFrameModeChange?.(mode);
|
|
190
|
+
}, [mode]);
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<>
|
|
194
|
+
<ChatContent client={client} />
|
|
195
|
+
<ChatEntryBtn client={client} />
|
|
196
|
+
</>
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export const ChatClient = ({ store, client }: { client?: ChatSDK; store: ChatStore }) => {
|
|
201
|
+
return (
|
|
202
|
+
<ChatStoreProvider store={store}>
|
|
203
|
+
<ChatWidgets client={client} />
|
|
204
|
+
</ChatStoreProvider>
|
|
205
|
+
);
|
|
206
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export const ChatFrame = (props: {
|
|
4
|
+
messagesArea: ReactNode;
|
|
5
|
+
inputArea: ReactNode;
|
|
6
|
+
}) => {
|
|
7
|
+
const { messagesArea, inputArea } = props;
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div className="chat-frame flex flex-col h-full min-h-0">
|
|
11
|
+
<div
|
|
12
|
+
className="messages-area flex-1 flex m-h-0"
|
|
13
|
+
style={{ flex: "1 1 auto", minHeight: 0 }}
|
|
14
|
+
>
|
|
15
|
+
{messagesArea}
|
|
16
|
+
</div>
|
|
17
|
+
<div
|
|
18
|
+
style={{ flex: "0 0 auto", minHeight: 100 }}
|
|
19
|
+
className="input-area flex-0 shrink-0 p-4"
|
|
20
|
+
>
|
|
21
|
+
{inputArea}
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import React, { useCallback } from "react";
|
|
3
|
+
import {
|
|
4
|
+
StickToBottom,
|
|
5
|
+
StickToBottomProps,
|
|
6
|
+
useStickToBottomContext,
|
|
7
|
+
} from "use-stick-to-bottom";
|
|
8
|
+
import { Button } from "@/components/ui/button";
|
|
9
|
+
import cn from "classnames";
|
|
10
|
+
|
|
11
|
+
export type ConversationProps = ComponentProps<typeof StickToBottom>;
|
|
12
|
+
|
|
13
|
+
export const Conversation: React.FC<StickToBottomProps> = ({
|
|
14
|
+
className,
|
|
15
|
+
...props
|
|
16
|
+
}) => (
|
|
17
|
+
<StickToBottom
|
|
18
|
+
className={cn(
|
|
19
|
+
"relative flex-1 touch-pan-y overflow-y-auto flex will-change-scroll",
|
|
20
|
+
className,
|
|
21
|
+
)}
|
|
22
|
+
style={{ minHeight: 0, height: "100%" }}
|
|
23
|
+
initial="smooth"
|
|
24
|
+
resize="smooth"
|
|
25
|
+
role="log"
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export type ConversationContentProps = ComponentProps<
|
|
31
|
+
typeof StickToBottom.Content
|
|
32
|
+
>;
|
|
33
|
+
|
|
34
|
+
export const ConversationContent = ({
|
|
35
|
+
className,
|
|
36
|
+
...props
|
|
37
|
+
}: ConversationContentProps) => (
|
|
38
|
+
<StickToBottom.Content className={cn("p-4", className)} {...props} />
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export type ConversationScrollButtonProps = ComponentProps<typeof Button>;
|
|
42
|
+
|
|
43
|
+
export const ConversationScrollButton = ({
|
|
44
|
+
className,
|
|
45
|
+
...props
|
|
46
|
+
}: ConversationScrollButtonProps) => {
|
|
47
|
+
const { isAtBottom, scrollToBottom } = useStickToBottomContext();
|
|
48
|
+
|
|
49
|
+
const handleScrollToBottom = useCallback(() => {
|
|
50
|
+
scrollToBottom();
|
|
51
|
+
}, [scrollToBottom]);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
!isAtBottom && (
|
|
55
|
+
<Button
|
|
56
|
+
className={cn(
|
|
57
|
+
"-translate-x-1/2 absolute bottom-4 left-1/2 z-10 rounded-full shadow-lg",
|
|
58
|
+
className,
|
|
59
|
+
)}
|
|
60
|
+
onClick={handleScrollToBottom}
|
|
61
|
+
size="icon"
|
|
62
|
+
type="button"
|
|
63
|
+
variant="outline"
|
|
64
|
+
{...props}
|
|
65
|
+
>
|
|
66
|
+
↓
|
|
67
|
+
</Button>
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useFrameMode } from "@/hooks/use-frame-mode";
|
|
2
|
+
import { Button } from "../ui/button";
|
|
3
|
+
|
|
4
|
+
export const DockBtn = () => {
|
|
5
|
+
const { mode, setMode } = useFrameMode();
|
|
6
|
+
|
|
7
|
+
// if (mode === "dock") {
|
|
8
|
+
// return null;
|
|
9
|
+
// }
|
|
10
|
+
const isFloat = mode === "float";
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Button
|
|
14
|
+
variant="ghost"
|
|
15
|
+
onClick={() => {
|
|
16
|
+
isFloat ? setMode("dock") : setMode("float");
|
|
17
|
+
}}
|
|
18
|
+
>
|
|
19
|
+
{!isFloat ? (
|
|
20
|
+
<svg
|
|
21
|
+
data-testid="geist-icon"
|
|
22
|
+
height="16"
|
|
23
|
+
stroke-linejoin="round"
|
|
24
|
+
viewBox="0 0 16 16"
|
|
25
|
+
width="16"
|
|
26
|
+
>
|
|
27
|
+
<path
|
|
28
|
+
fill-rule="evenodd"
|
|
29
|
+
clip-rule="evenodd"
|
|
30
|
+
d="M1.99939 10.25V11H3.49939V10.25V4.56008L12.7191 13.7798L13.2495 14.3101L14.3101 13.2494L13.7798 12.7191L4.56121 3.50058H10.25H11V2.00058H10.25H2.99939C2.4471 2.00058 1.99939 2.4483 1.99939 3.00058V10.25Z"
|
|
31
|
+
fill="currentColor"
|
|
32
|
+
></path>
|
|
33
|
+
</svg>
|
|
34
|
+
) : (
|
|
35
|
+
<svg
|
|
36
|
+
data-testid="geist-icon"
|
|
37
|
+
height="16"
|
|
38
|
+
stroke-linejoin="round"
|
|
39
|
+
viewBox="0 0 16 16"
|
|
40
|
+
width="16"
|
|
41
|
+
>
|
|
42
|
+
<path
|
|
43
|
+
fill-rule="evenodd"
|
|
44
|
+
clip-rule="evenodd"
|
|
45
|
+
d="M12.4994 11.4399V5.74999V4.99999H13.9994V5.74999V12.9994C13.9994 13.5517 13.5517 13.9994 12.9994 13.9994H5.74999H4.99999V12.4994H5.74999H11.4376L2.21908 3.28092L1.68875 2.75059L2.74941 1.68993L3.27974 2.22026L12.4994 11.4399Z"
|
|
46
|
+
fill="currentColor"
|
|
47
|
+
></path>
|
|
48
|
+
</svg>
|
|
49
|
+
)}
|
|
50
|
+
</Button>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FIELD_ICON_CODE_MAP } from '@/const';
|
|
2
|
+
import { FieldType } from '@baishuyun/types';
|
|
3
|
+
import { FontIcon } from '../bs-ui/font-icon';
|
|
4
|
+
|
|
5
|
+
export const FieldIcon = ({ type }: { type: FieldType }) => {
|
|
6
|
+
const code = FIELD_ICON_CODE_MAP[type] || 'icon-unknown';
|
|
7
|
+
return <FontIcon code={code} />;
|
|
8
|
+
};
|