@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,11 @@
|
|
|
1
|
+
import { Field } from "../form-builder-base-plugin/types";
|
|
2
|
+
|
|
3
|
+
export interface FormFillingPluginCtx {
|
|
4
|
+
fieldMap: Map<string, Field>;
|
|
5
|
+
|
|
6
|
+
valueMap: Map<string, unknown>;
|
|
7
|
+
|
|
8
|
+
subFieldsNameMap: Map<string, string>; // key sub field widget name, value parent field widget name
|
|
9
|
+
|
|
10
|
+
conversationId: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { FieldType, IAddress, ILocation } from '@baishuyun/types';
|
|
2
|
+
|
|
3
|
+
function isStringArray(value: unknown): value is string[] {
|
|
4
|
+
if (!Array.isArray(value)) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return value.every((item) => typeof item === 'string');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function isOptionArray(value: unknown): value is Array<{ label: string; value: string }> {
|
|
12
|
+
if (!Array.isArray(value)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return value.every(
|
|
17
|
+
(item) =>
|
|
18
|
+
typeof item === 'object' &&
|
|
19
|
+
item !== null &&
|
|
20
|
+
'label' in item &&
|
|
21
|
+
'value' in item &&
|
|
22
|
+
typeof (item as any).label === 'string' &&
|
|
23
|
+
typeof (item as any).value === 'string'
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const valueNormalizer = (value: string | string[]): string => {
|
|
28
|
+
if (isStringArray(value)) {
|
|
29
|
+
return value.join(', ');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isOptionArray(value)) {
|
|
33
|
+
const values = value.map((item) => item.value);
|
|
34
|
+
return values.join(', ');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return value;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const toHumanReadable = (value: unknown, type: FieldType): string | unknown => {
|
|
41
|
+
if (type === 'address' && typeof value === 'object') {
|
|
42
|
+
const v = value as IAddress;
|
|
43
|
+
return `${v.province} ${v.city} ${v.district} ${v.detail}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (type === 'location' && typeof value === 'object') {
|
|
47
|
+
const v = value as ILocation;
|
|
48
|
+
console.log('location info', v);
|
|
49
|
+
const lnglatXY = v.lnglatXY || ['', ''];
|
|
50
|
+
return `经度: ${lnglatXY[0] || ''}, 纬度: ${lnglatXY[1] || ''}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (Array.isArray(value)) {
|
|
54
|
+
return value.join(', ');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (isOptionArray(value)) {
|
|
58
|
+
const values = value.map((item) => item.value);
|
|
59
|
+
return values.join(', ');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return value;
|
|
63
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { MessageContent } from '../../../components/biz-comp/message-content';
|
|
2
|
+
import { Button } from '@/components/ui/button';
|
|
3
|
+
import { ConfirmTools } from '@baishuyun/agents';
|
|
4
|
+
import type { ConfirmTypes } from '@baishuyun/types';
|
|
5
|
+
import { ChatRequestOptions, ToolUIPart } from 'ai';
|
|
6
|
+
import { Suggestions } from '../../../components/biz-comp/suggestions';
|
|
7
|
+
|
|
8
|
+
export const Confirmer = ({
|
|
9
|
+
input,
|
|
10
|
+
type,
|
|
11
|
+
onConfirm,
|
|
12
|
+
onCancel,
|
|
13
|
+
}: {
|
|
14
|
+
type: ConfirmTypes;
|
|
15
|
+
onConfirm: (opt?: ChatRequestOptions, msg?: string) => void;
|
|
16
|
+
onCancel?: (opt?: ChatRequestOptions) => void;
|
|
17
|
+
} & Pick<ToolUIPart<ConfirmTools>, 'input'>) => {
|
|
18
|
+
// 建表、保存字段
|
|
19
|
+
if (type === 'tool-confirmToCreateForm' || type === 'tool-confirmToSaveCheckedFields') {
|
|
20
|
+
return (
|
|
21
|
+
<MessageContent className="gap-0 py-0" compact>
|
|
22
|
+
<Button
|
|
23
|
+
onClick={() => {
|
|
24
|
+
onConfirm({
|
|
25
|
+
body: {
|
|
26
|
+
stage: type === 'tool-confirmToCreateForm' ? 'build' : 'continue',
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
确认
|
|
32
|
+
</Button>
|
|
33
|
+
</MessageContent>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 是否继续创建关联表
|
|
38
|
+
if (type === 'tool-confirmToCreateRelatedForm' && input.forms.length > 0) {
|
|
39
|
+
return (
|
|
40
|
+
<MessageContent className="gap-0 py-0" compact>
|
|
41
|
+
<Button
|
|
42
|
+
onClick={() => {
|
|
43
|
+
onConfirm({
|
|
44
|
+
body: { stage: 'continue ' },
|
|
45
|
+
});
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
确认
|
|
49
|
+
</Button>
|
|
50
|
+
<Button
|
|
51
|
+
onClick={() => {
|
|
52
|
+
onCancel && onCancel();
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
跳过
|
|
56
|
+
</Button>
|
|
57
|
+
</MessageContent>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 继续为关联表创建字段
|
|
62
|
+
if (type === 'tool-confirmToCreateFieldsForRelatedForm') {
|
|
63
|
+
return (
|
|
64
|
+
<MessageContent className="gap-0 py-0" compact>
|
|
65
|
+
{
|
|
66
|
+
<Suggestions
|
|
67
|
+
items={input.forms}
|
|
68
|
+
onSelect={(name) => {
|
|
69
|
+
onConfirm(
|
|
70
|
+
{
|
|
71
|
+
body: { stage: 'design' },
|
|
72
|
+
},
|
|
73
|
+
name
|
|
74
|
+
);
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
}
|
|
78
|
+
<Button
|
|
79
|
+
onClick={() => {
|
|
80
|
+
onCancel && onCancel();
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
取消
|
|
84
|
+
</Button>
|
|
85
|
+
</MessageContent>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ConfirmTypes } from '@baishuyun/types';
|
|
2
|
+
import { memo, useEffect } from 'react';
|
|
3
|
+
import { FakeBotMessage } from '../../../components/biz-comp/FakeBotMsg';
|
|
4
|
+
import { usePlugin } from '@/hooks/use-plugin';
|
|
5
|
+
import { PLUGIN_NAME, DEFAULT_EVT } from '../const';
|
|
6
|
+
import { ModelFormBuilderPlugin } from '..';
|
|
7
|
+
|
|
8
|
+
const eventFactory: Record<
|
|
9
|
+
ConfirmTypes,
|
|
10
|
+
(plugin: ModelFormBuilderPlugin) => (output: string, input: any) => CustomEvent
|
|
11
|
+
> = {
|
|
12
|
+
'tool-confirmToCreateForm': (plugin) => (_: string, input: any) => {
|
|
13
|
+
return plugin.publicMethods!.dispatchCreateFormEvent(input.formName);
|
|
14
|
+
},
|
|
15
|
+
'tool-confirmToSaveCheckedFields': (plugin) => (_: string) => {
|
|
16
|
+
return plugin.publicMethods!.dispatchSaveFieldsEvent();
|
|
17
|
+
},
|
|
18
|
+
'tool-confirmToCreateFieldsForRelatedForm': (_) => (_: string) => {
|
|
19
|
+
// return plugin.publicMethods!.dispatchCreateFieldsForRelatedFormEvent();
|
|
20
|
+
// new CustomEvent("form-builder-RelatedFormFieldsConfirmed"),
|
|
21
|
+
return DEFAULT_EVT;
|
|
22
|
+
},
|
|
23
|
+
'tool-confirmToCreateRelatedForm': (_) => (_: string) => {
|
|
24
|
+
return DEFAULT_EVT;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const BaseDispatcher = ({
|
|
29
|
+
output,
|
|
30
|
+
input,
|
|
31
|
+
type,
|
|
32
|
+
}: {
|
|
33
|
+
output: string;
|
|
34
|
+
input: any;
|
|
35
|
+
type: ConfirmTypes;
|
|
36
|
+
}) => {
|
|
37
|
+
const plugin = usePlugin(PLUGIN_NAME);
|
|
38
|
+
if (!plugin) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const eventCreator = eventFactory[type];
|
|
44
|
+
if (eventCreator) {
|
|
45
|
+
const event = eventCreator(plugin as ModelFormBuilderPlugin)(output, input);
|
|
46
|
+
dispatchEvent(event);
|
|
47
|
+
}
|
|
48
|
+
}, []);
|
|
49
|
+
return <FakeBotMessage headless>{output}</FakeBotMessage>;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 确认事件分发
|
|
54
|
+
*/
|
|
55
|
+
export const GhostEvtDispatcher = memo(BaseDispatcher, (prevProps, nextProps) => {
|
|
56
|
+
if (prevProps.output !== nextProps.output) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (prevProps.type !== nextProps.type) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (prevProps.input !== nextProps.input) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return true;
|
|
69
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Confirmer } from '@/plugins/general-model-form-builder-plugin/components/confirmer';
|
|
2
|
+
import { FieldChecker } from '@/components/biz-comp/FieldChecker';
|
|
3
|
+
import { GhostEvtDispatcher } from '@/plugins/general-model-form-builder-plugin/components/ghost-evt-dispatcher';
|
|
4
|
+
import { MemoizedMarkdown } from '@/components/biz-comp/markdown';
|
|
5
|
+
import { MessageContent } from '@/components/biz-comp/message-content';
|
|
6
|
+
import { NewConfirmer } from '@/plugins/general-model-form-builder-plugin/components/new-confirmer';
|
|
7
|
+
import { cn, sanitizeText } from '@/lib/utils';
|
|
8
|
+
import {
|
|
9
|
+
APPROVAL,
|
|
10
|
+
ConfirmTools,
|
|
11
|
+
ContinueTools,
|
|
12
|
+
DesignConfirmPayload,
|
|
13
|
+
FormBuildTools,
|
|
14
|
+
SaveCheckedFieldsPayload,
|
|
15
|
+
ToolsCanBeExecutedDirectly,
|
|
16
|
+
ToolsRequiringConfirmation,
|
|
17
|
+
} from '@baishuyun/agents';
|
|
18
|
+
import { ConfirmDataPart, ConfirmTypes, MsgPartCompProps } from '@baishuyun/types';
|
|
19
|
+
import {
|
|
20
|
+
ChatRequestOptions,
|
|
21
|
+
DataUIPart,
|
|
22
|
+
getToolName,
|
|
23
|
+
InferUITools,
|
|
24
|
+
isToolUIPart,
|
|
25
|
+
TextUIPart,
|
|
26
|
+
ToolUIPart,
|
|
27
|
+
} from 'ai';
|
|
28
|
+
import { useCallback } from 'react';
|
|
29
|
+
|
|
30
|
+
export const ModelMessagePart = (props: MsgPartCompProps) => {
|
|
31
|
+
const { part: p, id, index, sendMessage, role, addToolOutput } = props;
|
|
32
|
+
|
|
33
|
+
const part = p as
|
|
34
|
+
| ToolUIPart<ConfirmTools | FormBuildTools | InferUITools<ContinueTools>>
|
|
35
|
+
| TextUIPart
|
|
36
|
+
| DataUIPart<ConfirmDataPart<DesignConfirmPayload | SaveCheckedFieldsPayload>>;
|
|
37
|
+
|
|
38
|
+
const key = `message-${id}-part-${index}-${part.type}`;
|
|
39
|
+
|
|
40
|
+
// markdown text
|
|
41
|
+
if (part.type === 'text' && part.text) {
|
|
42
|
+
return (
|
|
43
|
+
<div key={key}>
|
|
44
|
+
<MessageContent
|
|
45
|
+
className={cn({
|
|
46
|
+
'w-fit wrap-break-words rounded-2 px-3 py-2 text-right text-white': role === 'user',
|
|
47
|
+
'bg-transparent px-0 py-0 text-left': role === 'assistant',
|
|
48
|
+
})}
|
|
49
|
+
data-testid="message-content"
|
|
50
|
+
style={role === 'user' ? { backgroundColor: '#006cff' } : undefined}
|
|
51
|
+
>
|
|
52
|
+
<MemoizedMarkdown id={id} content={sanitizeText(part.text)} />
|
|
53
|
+
</MessageContent>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (part.type === 'data-confirm') {
|
|
59
|
+
const data = part.data;
|
|
60
|
+
return (
|
|
61
|
+
<NewConfirmer
|
|
62
|
+
key={key}
|
|
63
|
+
input={data.payload}
|
|
64
|
+
sendMessage={sendMessage}
|
|
65
|
+
onCancel={() => {}}
|
|
66
|
+
type={data.type as ConfirmTypes}
|
|
67
|
+
/>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
if (isToolUIPart<FormBuildTools>(part)) {
|
|
71
|
+
// 工具返回
|
|
72
|
+
const toolName = getToolName(part);
|
|
73
|
+
// 自定义确认提示
|
|
74
|
+
if (toolName === 'promptToCreateRelatedForm' && part.state === 'output-available') {
|
|
75
|
+
return (
|
|
76
|
+
<div key={key}>
|
|
77
|
+
<MessageContent className="gap-0 py-0" compact>
|
|
78
|
+
<MemoizedMarkdown
|
|
79
|
+
id={id}
|
|
80
|
+
content={sanitizeText(part.output ? '是否继续创建关联表?' : '表单创建已完成。')}
|
|
81
|
+
/>
|
|
82
|
+
</MessageContent>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 字段构建工具
|
|
88
|
+
if (part.state === 'output-available' && ToolsCanBeExecutedDirectly.has(toolName)) {
|
|
89
|
+
return (
|
|
90
|
+
<div key={key}>
|
|
91
|
+
<MessageContent className="gap-0 py-0" compact>
|
|
92
|
+
{part?.output && <FieldChecker field={part.output} />}
|
|
93
|
+
</MessageContent>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 确认工具
|
|
99
|
+
if (ToolsRequiringConfirmation.includes(toolName) && part.state === 'input-available') {
|
|
100
|
+
const handleConfirm = useCallback(
|
|
101
|
+
(opt?: ChatRequestOptions) => {
|
|
102
|
+
addToolOutput({
|
|
103
|
+
toolCallId: part.toolCallId,
|
|
104
|
+
tool: toolName,
|
|
105
|
+
output: APPROVAL.YES,
|
|
106
|
+
});
|
|
107
|
+
sendMessage(undefined, opt);
|
|
108
|
+
},
|
|
109
|
+
[part.toolCallId, toolName]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const handleCancle = useCallback(() => {
|
|
113
|
+
addToolOutput({
|
|
114
|
+
toolCallId: part.toolCallId,
|
|
115
|
+
tool: toolName,
|
|
116
|
+
output: APPROVAL.NO,
|
|
117
|
+
});
|
|
118
|
+
sendMessage();
|
|
119
|
+
}, [part.toolCallId, toolName]);
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<Confirmer
|
|
123
|
+
key={key}
|
|
124
|
+
input={part.input}
|
|
125
|
+
onConfirm={handleConfirm}
|
|
126
|
+
onCancel={handleCancle}
|
|
127
|
+
type={part.type as ConfirmTypes}
|
|
128
|
+
/>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// 确认事件分发
|
|
133
|
+
if (ToolsRequiringConfirmation.includes(toolName) && part.state === 'output-available') {
|
|
134
|
+
const p = part as ToolUIPart<ConfirmTools>;
|
|
135
|
+
return (
|
|
136
|
+
<GhostEvtDispatcher
|
|
137
|
+
input={p.input}
|
|
138
|
+
output={p.output}
|
|
139
|
+
type={p.type as ConfirmTypes}
|
|
140
|
+
key={part.toolCallId}
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return null;
|
|
147
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { MessageContent } from '../../../components/biz-comp/message-content';
|
|
2
|
+
import { OneTimeClickBtn } from '@/components/ui/one-time-click-btn';
|
|
3
|
+
import { ConfirmTools } from '@baishuyun/agents';
|
|
4
|
+
import type { ConfirmTypes } from '@baishuyun/types';
|
|
5
|
+
import { ChatRequestOptions, ToolUIPart } from 'ai';
|
|
6
|
+
import { Suggestions } from '../../../components/biz-comp/suggestions';
|
|
7
|
+
import { useState } from 'react';
|
|
8
|
+
import type { ChatMessage, UseChatHelpers } from '@baishuyun/types';
|
|
9
|
+
import { Button } from '../../../components/ui/button';
|
|
10
|
+
import { usePlugin } from '@/hooks/use-plugin';
|
|
11
|
+
import { PLUGIN_NAME } from '../const';
|
|
12
|
+
import { ModelFormBuilderPlugin } from '..';
|
|
13
|
+
|
|
14
|
+
export const NewConfirmer = ({
|
|
15
|
+
input,
|
|
16
|
+
type,
|
|
17
|
+
sendMessage,
|
|
18
|
+
onConfirm,
|
|
19
|
+
onCancel,
|
|
20
|
+
}: {
|
|
21
|
+
type: ConfirmTypes;
|
|
22
|
+
sendMessage: UseChatHelpers<ChatMessage>['sendMessage'];
|
|
23
|
+
onConfirm?: (opt?: ChatRequestOptions, msg?: string) => void;
|
|
24
|
+
onCancel?: (opt?: ChatRequestOptions) => void;
|
|
25
|
+
} & Pick<ToolUIPart<ConfirmTools>, 'input'>) => {
|
|
26
|
+
const [fieldsSaved, setFieldsSaved] = useState(false);
|
|
27
|
+
const [goOn, setGoOn] = useState(false);
|
|
28
|
+
const [skip, setSkip] = useState(false);
|
|
29
|
+
|
|
30
|
+
const plugin = usePlugin(PLUGIN_NAME) as ModelFormBuilderPlugin;
|
|
31
|
+
|
|
32
|
+
// 建表、保存字段
|
|
33
|
+
if (type === 'tool-confirmToCreateForm') {
|
|
34
|
+
return (
|
|
35
|
+
<MessageContent className="gap-0 py-0" compact>
|
|
36
|
+
<OneTimeClickBtn
|
|
37
|
+
onClick={() => {
|
|
38
|
+
plugin?.publicMethods?.dispatchCreateFormEvent(input.formName);
|
|
39
|
+
sendMessage(undefined, {
|
|
40
|
+
body: {
|
|
41
|
+
stage: 'build',
|
|
42
|
+
name: input.formName,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
确认
|
|
48
|
+
</OneTimeClickBtn>
|
|
49
|
+
</MessageContent>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (type === 'tool-confirmToSaveCheckedFields') {
|
|
54
|
+
const keys = Object.keys(input.relatedForms);
|
|
55
|
+
const hasRelatedForms = keys.length;
|
|
56
|
+
|
|
57
|
+
const prompts = `${keys.join('、')}暂无已有工作表,将为您继续创建工作表`;
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<MessageContent className="gap-0 py-0" compact>
|
|
61
|
+
<OneTimeClickBtn
|
|
62
|
+
onClick={() => {
|
|
63
|
+
plugin?.publicMethods?.dispatchSaveFieldsEvent();
|
|
64
|
+
setFieldsSaved(true);
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
保存字段
|
|
68
|
+
</OneTimeClickBtn>
|
|
69
|
+
|
|
70
|
+
{hasRelatedForms && fieldsSaved && !goOn && !skip ? (
|
|
71
|
+
<>
|
|
72
|
+
{prompts}
|
|
73
|
+
<OneTimeClickBtn
|
|
74
|
+
onClick={() => {
|
|
75
|
+
// sendMessage(undefined, {
|
|
76
|
+
// body: {
|
|
77
|
+
// stage: BuildStage.BUILD,
|
|
78
|
+
// name: input.formName,
|
|
79
|
+
// },
|
|
80
|
+
// });
|
|
81
|
+
//
|
|
82
|
+
// plugin?.publicMethods?.dispatchSaveFieldsEvent();
|
|
83
|
+
// dispatchEvent(
|
|
84
|
+
// new CustomEvent("form-builder-createRelatedForms", {
|
|
85
|
+
// detail: { forms: input.relatedForms },
|
|
86
|
+
// }),
|
|
87
|
+
// );
|
|
88
|
+
setGoOn(true);
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
继续创建?
|
|
92
|
+
</OneTimeClickBtn>
|
|
93
|
+
<OneTimeClickBtn
|
|
94
|
+
onClick={() => {
|
|
95
|
+
// sendMessage(undefined, {
|
|
96
|
+
// body: {
|
|
97
|
+
// stage: BuildStage.BUILD,
|
|
98
|
+
// name: input.formName,
|
|
99
|
+
// },
|
|
100
|
+
// });
|
|
101
|
+
//
|
|
102
|
+
// (dispatchEvent(new CustomEvent("form-builder-FieldsConfirmed")),
|
|
103
|
+
// setFieldsSaved(true));
|
|
104
|
+
setSkip(true);
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
跳过
|
|
108
|
+
</OneTimeClickBtn>
|
|
109
|
+
</>
|
|
110
|
+
) : null}
|
|
111
|
+
|
|
112
|
+
{goOn ? (
|
|
113
|
+
<>
|
|
114
|
+
请选择要创建的关联表:
|
|
115
|
+
<Suggestions
|
|
116
|
+
items={keys.map((f: string) => ({
|
|
117
|
+
title: f,
|
|
118
|
+
description: '',
|
|
119
|
+
}))}
|
|
120
|
+
onSelect={(name) => {
|
|
121
|
+
sendMessage(
|
|
122
|
+
{ text: name },
|
|
123
|
+
{
|
|
124
|
+
body: {
|
|
125
|
+
stage: 'design',
|
|
126
|
+
name,
|
|
127
|
+
},
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
}}
|
|
131
|
+
/>
|
|
132
|
+
</>
|
|
133
|
+
) : null}
|
|
134
|
+
</MessageContent>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 是否继续创建关联表
|
|
139
|
+
if (type === 'tool-confirmToCreateRelatedForm' && input.forms.length > 0) {
|
|
140
|
+
return (
|
|
141
|
+
<MessageContent className="gap-0 py-0" compact>
|
|
142
|
+
<Button
|
|
143
|
+
onClick={() => {
|
|
144
|
+
onConfirm?.({
|
|
145
|
+
body: { stage: 'continue' },
|
|
146
|
+
});
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
确认
|
|
150
|
+
</Button>
|
|
151
|
+
<Button
|
|
152
|
+
onClick={() => {
|
|
153
|
+
onCancel && onCancel();
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
跳过
|
|
157
|
+
</Button>
|
|
158
|
+
</MessageContent>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// 继续为关联表创建字段
|
|
163
|
+
if (type === 'tool-confirmToCreateFieldsForRelatedForm') {
|
|
164
|
+
return (
|
|
165
|
+
<MessageContent className="gap-0 py-0" compact>
|
|
166
|
+
{
|
|
167
|
+
<Suggestions
|
|
168
|
+
items={input.forms}
|
|
169
|
+
onSelect={(name) => {
|
|
170
|
+
onConfirm?.(
|
|
171
|
+
{
|
|
172
|
+
body: { stage: 'design' },
|
|
173
|
+
},
|
|
174
|
+
name
|
|
175
|
+
);
|
|
176
|
+
}}
|
|
177
|
+
/>
|
|
178
|
+
}
|
|
179
|
+
<Button
|
|
180
|
+
onClick={() => {
|
|
181
|
+
onCancel && onCancel();
|
|
182
|
+
}}
|
|
183
|
+
>
|
|
184
|
+
取消
|
|
185
|
+
</Button>
|
|
186
|
+
</MessageContent>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return null;
|
|
191
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PluginCustomComponent, PluginRegistryEntry } from '@baishuyun/types';
|
|
2
|
+
import { ModelFormBuilderPluginCtx } from './types';
|
|
3
|
+
import { ModelMessagePart } from './components/msg-part';
|
|
4
|
+
import { FormBuilderBasePlugin } from '../form-builder-base-plugin';
|
|
5
|
+
import { PLUGIN_NAME } from './const';
|
|
6
|
+
|
|
7
|
+
export class ModelFormBuilderPlugin extends FormBuilderBasePlugin<ModelFormBuilderPluginCtx> {
|
|
8
|
+
public pluginName: string = PLUGIN_NAME;
|
|
9
|
+
|
|
10
|
+
public customComponents?: Partial<PluginCustomComponent> | undefined = {
|
|
11
|
+
MessagePart: ModelMessagePart,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const ModelFormBuilderPluginRegisterEntry: PluginRegistryEntry<ModelFormBuilderPluginCtx> = {
|
|
16
|
+
Plugin: ModelFormBuilderPlugin,
|
|
17
|
+
createContext: () => {
|
|
18
|
+
return {};
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export interface ModelFormBuilderPluginCtx {}
|