@nocobase/flow-engine 2.0.0-alpha.2
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/LICENSE +661 -0
- package/README.md +30 -0
- package/lib/ContextPathProxy.d.ts +17 -0
- package/lib/ContextPathProxy.js +65 -0
- package/lib/ElementProxy.d.ts +17 -0
- package/lib/ElementProxy.js +93 -0
- package/lib/FlowContextProvider.d.ts +24 -0
- package/lib/FlowContextProvider.js +82 -0
- package/lib/FlowDefinition.d.ts +423 -0
- package/lib/FlowDefinition.js +257 -0
- package/lib/JSRunner.d.ts +32 -0
- package/lib/JSRunner.js +95 -0
- package/lib/ReactView.d.ts +20 -0
- package/lib/ReactView.js +120 -0
- package/lib/ViewScopedFlowEngine.d.ts +23 -0
- package/lib/ViewScopedFlowEngine.js +81 -0
- package/lib/acl/Acl.d.ts +31 -0
- package/lib/acl/Acl.js +115 -0
- package/lib/action-registry/BaseActionRegistry.d.ts +23 -0
- package/lib/action-registry/BaseActionRegistry.js +57 -0
- package/lib/action-registry/EngineActionRegistry.d.ts +20 -0
- package/lib/action-registry/EngineActionRegistry.js +47 -0
- package/lib/action-registry/ModelActionRegistry.d.ts +34 -0
- package/lib/action-registry/ModelActionRegistry.js +79 -0
- package/lib/components/DynamicFlowsEditor.d.ts +17 -0
- package/lib/components/DynamicFlowsEditor.js +49 -0
- package/lib/components/FieldModelRenderer.d.ts +10 -0
- package/lib/components/FieldModelRenderer.js +94 -0
- package/lib/components/FlowContextSelector.d.ts +11 -0
- package/lib/components/FlowContextSelector.js +221 -0
- package/lib/components/FlowErrorFallback.d.ts +25 -0
- package/lib/components/FlowErrorFallback.js +264 -0
- package/lib/components/FlowModelRenderer.d.ts +64 -0
- package/lib/components/FlowModelRenderer.js +254 -0
- package/lib/components/FormItem.d.ts +18 -0
- package/lib/components/FormItem.js +147 -0
- package/lib/components/common/FlowSettingsButton.d.ts +11 -0
- package/lib/components/common/FlowSettingsButton.js +66 -0
- package/lib/components/common/index.d.ts +9 -0
- package/lib/components/common/index.js +30 -0
- package/lib/components/common/withFlowDesignMode.d.ts +26 -0
- package/lib/components/common/withFlowDesignMode.js +61 -0
- package/lib/components/dnd/getMousePositionOnElement.d.ts +50 -0
- package/lib/components/dnd/getMousePositionOnElement.js +95 -0
- package/lib/components/dnd/index.d.ts +24 -0
- package/lib/components/dnd/index.js +164 -0
- package/lib/components/dnd/moveBlock.d.ts +33 -0
- package/lib/components/dnd/moveBlock.js +302 -0
- package/lib/components/index.d.ts +18 -0
- package/lib/components/index.js +48 -0
- package/lib/components/settings/independents/dropdown/FlowsDropdownButton.d.ts +46 -0
- package/lib/components/settings/independents/dropdown/FlowsDropdownButton.js +225 -0
- package/lib/components/settings/independents/dropdown/index.d.ts +9 -0
- package/lib/components/settings/independents/dropdown/index.js +30 -0
- package/lib/components/settings/independents/index.d.ts +1 -0
- package/lib/components/settings/independents/index.js +30 -0
- package/lib/components/settings/index.d.ts +10 -0
- package/lib/components/settings/index.js +32 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.d.ts +24 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +501 -0
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.d.ts +45 -0
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +231 -0
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +111 -0
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +484 -0
- package/lib/components/settings/wrappers/contextual/StepRequiredSettingsDialog.d.ts +26 -0
- package/lib/components/settings/wrappers/contextual/StepRequiredSettingsDialog.js +342 -0
- package/lib/components/settings/wrappers/contextual/StepSettings.d.ts +23 -0
- package/lib/components/settings/wrappers/contextual/StepSettings.js +110 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.d.ts +20 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +206 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDrawer.d.ts +20 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDrawer.js +47 -0
- package/lib/components/settings/wrappers/contextual/index.d.ts +14 -0
- package/lib/components/settings/wrappers/contextual/index.js +40 -0
- package/lib/components/settings/wrappers/embedded/FlowSettings.d.ts +33 -0
- package/lib/components/settings/wrappers/embedded/FlowSettings.js +207 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettings.d.ts +41 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettings.js +84 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettingsContent.d.ts +16 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettingsContent.js +88 -0
- package/lib/components/settings/wrappers/embedded/index.d.ts +10 -0
- package/lib/components/settings/wrappers/embedded/index.js +32 -0
- package/lib/components/settings/wrappers/index.d.ts +2 -0
- package/lib/components/settings/wrappers/index.js +32 -0
- package/lib/components/subModel/AddSubModelButton.d.ts +62 -0
- package/lib/components/subModel/AddSubModelButton.js +415 -0
- package/lib/components/subModel/LazyDropdown.d.ts +55 -0
- package/lib/components/subModel/LazyDropdown.js +524 -0
- package/lib/components/subModel/index.d.ts +10 -0
- package/lib/components/subModel/index.js +32 -0
- package/lib/components/subModel/utils.d.ts +34 -0
- package/lib/components/subModel/utils.js +287 -0
- package/lib/components/variables/InlineVariableTag.d.ts +21 -0
- package/lib/components/variables/InlineVariableTag.js +123 -0
- package/lib/components/variables/SlateVariableEditor.d.ts +46 -0
- package/lib/components/variables/SlateVariableEditor.js +302 -0
- package/lib/components/variables/VariableInput.d.ts +11 -0
- package/lib/components/variables/VariableInput.js +322 -0
- package/lib/components/variables/VariableTag.d.ts +11 -0
- package/lib/components/variables/VariableTag.js +148 -0
- package/lib/components/variables/VariableTrigger.d.ts +20 -0
- package/lib/components/variables/VariableTrigger.js +136 -0
- package/lib/components/variables/index.d.ts +15 -0
- package/lib/components/variables/index.js +53 -0
- package/lib/components/variables/types.d.ts +93 -0
- package/lib/components/variables/types.js +24 -0
- package/lib/components/variables/useResolvedMetaTree.d.ts +19 -0
- package/lib/components/variables/useResolvedMetaTree.js +91 -0
- package/lib/components/variables/utils.d.ts +22 -0
- package/lib/components/variables/utils.js +177 -0
- package/lib/data-source/index.d.ts +180 -0
- package/lib/data-source/index.js +733 -0
- package/lib/data-source/jioToJoiSchema.d.ts +19 -0
- package/lib/data-source/jioToJoiSchema.js +114 -0
- package/lib/decorators/index.d.ts +9 -0
- package/lib/decorators/index.js +36 -0
- package/lib/decorators/largeField.d.ts +9 -0
- package/lib/decorators/largeField.js +42 -0
- package/lib/emitter.d.ts +16 -0
- package/lib/emitter.js +58 -0
- package/lib/event-registry/BaseEventRegistry.d.ts +22 -0
- package/lib/event-registry/BaseEventRegistry.js +57 -0
- package/lib/event-registry/EngineEventRegistry.d.ts +19 -0
- package/lib/event-registry/EngineEventRegistry.js +47 -0
- package/lib/event-registry/ModelEventRegistry.d.ts +33 -0
- package/lib/event-registry/ModelEventRegistry.js +79 -0
- package/lib/executor/FlowExecutor.d.ts +26 -0
- package/lib/executor/FlowExecutor.js +262 -0
- package/lib/flow-registry/BaseFlowRegistry.d.ts +46 -0
- package/lib/flow-registry/BaseFlowRegistry.js +86 -0
- package/lib/flow-registry/GlobalFlowRegistry.d.ts +22 -0
- package/lib/flow-registry/GlobalFlowRegistry.js +95 -0
- package/lib/flow-registry/InstanceFlowRegistry.d.ts +21 -0
- package/lib/flow-registry/InstanceFlowRegistry.js +59 -0
- package/lib/flow-registry/index.d.ts +11 -0
- package/lib/flow-registry/index.js +34 -0
- package/lib/flowContext.d.ts +215 -0
- package/lib/flowContext.js +1266 -0
- package/lib/flowEngine.d.ts +340 -0
- package/lib/flowEngine.js +781 -0
- package/lib/flowI18n.d.ts +46 -0
- package/lib/flowI18n.js +117 -0
- package/lib/flowSettings.d.ts +266 -0
- package/lib/flowSettings.js +850 -0
- package/lib/hooks/index.d.ts +14 -0
- package/lib/hooks/index.js +40 -0
- package/lib/hooks/useApplyAutoFlows.d.ts +21 -0
- package/lib/hooks/useApplyAutoFlows.js +62 -0
- package/lib/hooks/useFlowModel.d.ts +29 -0
- package/lib/hooks/useFlowModel.js +72 -0
- package/lib/hooks/useFlowModelById.d.ts +11 -0
- package/lib/hooks/useFlowModelById.js +61 -0
- package/lib/hooks/useFlowSettingsContext.d.ts +20 -0
- package/lib/hooks/useFlowSettingsContext.js +61 -0
- package/lib/hooks/useFlowStep.d.ts +17 -0
- package/lib/hooks/useFlowStep.js +56 -0
- package/lib/hooks/useNiceDropdownMaxHeight.d.ts +13 -0
- package/lib/hooks/useNiceDropdownMaxHeight.js +52 -0
- package/lib/index.d.ts +27 -0
- package/lib/index.js +73 -0
- package/lib/locale/en-US.json +61 -0
- package/lib/locale/index.d.ts +141 -0
- package/lib/locale/index.js +70 -0
- package/lib/locale/zh-CN.json +61 -0
- package/lib/models/CollectionFieldModel.d.ts +50 -0
- package/lib/models/CollectionFieldModel.js +242 -0
- package/lib/models/DisplayItemModel.d.ts +12 -0
- package/lib/models/DisplayItemModel.js +41 -0
- package/lib/models/EditableItemModel.d.ts +12 -0
- package/lib/models/EditableItemModel.js +41 -0
- package/lib/models/FilterableItemModel.d.ts +12 -0
- package/lib/models/FilterableItemModel.js +41 -0
- package/lib/models/flowModel.d.ts +344 -0
- package/lib/models/flowModel.js +1133 -0
- package/lib/models/forkFlowModel.d.ts +83 -0
- package/lib/models/forkFlowModel.js +257 -0
- package/lib/models/index.d.ts +14 -0
- package/lib/models/index.js +40 -0
- package/lib/provider.d.ts +22 -0
- package/lib/provider.js +114 -0
- package/lib/resources/apiResource.d.ts +34 -0
- package/lib/resources/apiResource.js +153 -0
- package/lib/resources/baseRecordResource.d.ts +61 -0
- package/lib/resources/baseRecordResource.js +264 -0
- package/lib/resources/filterItem.d.ts +33 -0
- package/lib/resources/filterItem.js +93 -0
- package/lib/resources/flowResource.d.ts +45 -0
- package/lib/resources/flowResource.js +146 -0
- package/lib/resources/index.d.ts +15 -0
- package/lib/resources/index.js +42 -0
- package/lib/resources/multiRecordResource.d.ts +53 -0
- package/lib/resources/multiRecordResource.js +230 -0
- package/lib/resources/singleRecordResource.d.ts +23 -0
- package/lib/resources/singleRecordResource.js +111 -0
- package/lib/resources/sqlResource.d.ts +73 -0
- package/lib/resources/sqlResource.js +294 -0
- package/lib/runjs-context/contexts/FlowRunJSContext.d.ts +38 -0
- package/lib/runjs-context/contexts/FlowRunJSContext.js +217 -0
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +66 -0
- package/lib/runjs-context/contexts/JSBlockRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +78 -0
- package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.d.ts +12 -0
- package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.js +59 -0
- package/lib/runjs-context/contexts/JSFieldRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSFieldRunJSContext.js +70 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +66 -0
- package/lib/runjs-context/contexts/JSRecordActionRunJSContext.d.ts +12 -0
- package/lib/runjs-context/contexts/JSRecordActionRunJSContext.js +61 -0
- package/lib/runjs-context/contexts/LinkageRunJSContext.d.ts +12 -0
- package/lib/runjs-context/contexts/LinkageRunJSContext.js +62 -0
- package/lib/runjs-context/helpers.d.ts +17 -0
- package/lib/runjs-context/helpers.js +79 -0
- package/lib/runjs-context/index.d.ts +19 -0
- package/lib/runjs-context/index.js +57 -0
- package/lib/runjs-context/registry.d.ts +17 -0
- package/lib/runjs-context/registry.js +93 -0
- package/lib/runjs-context/snippets/global/api-request-get.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/api-request-get.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/api-request-post.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/api-request-post.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/console-log-ctx.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/console-log-ctx.snippet.js +41 -0
- package/lib/runjs-context/snippets/global/copy-record-json.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/copy-record-json.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/copy-to-clipboard.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/copy-to-clipboard.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/log-json-record.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/log-json-record.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/message-error.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/message-error.snippet.js +41 -0
- package/lib/runjs-context/snippets/global/message-success.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/message-success.snippet.js +41 -0
- package/lib/runjs-context/snippets/global/notification-open.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/notification-open.snippet.js +43 -0
- package/lib/runjs-context/snippets/global/open-view-dialog.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/open-view-dialog.snippet.js +47 -0
- package/lib/runjs-context/snippets/global/open-view-drawer.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/open-view-drawer.snippet.js +47 -0
- package/lib/runjs-context/snippets/global/requireAsync.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/requireAsync.snippet.js +46 -0
- package/lib/runjs-context/snippets/global/sleep.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/sleep.snippet.js +43 -0
- package/lib/runjs-context/snippets/global/try-catch-async.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/try-catch-async.snippet.js +44 -0
- package/lib/runjs-context/snippets/global/view-navigation-push.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/view-navigation-push.snippet.js +44 -0
- package/lib/runjs-context/snippets/global/window-open.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/window-open.snippet.js +41 -0
- package/lib/runjs-context/snippets/index.d.ts +11 -0
- package/lib/runjs-context/snippets/index.js +94 -0
- package/lib/runjs-context/snippets/libs/echarts-init.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/libs/echarts-init.snippet.js +46 -0
- package/lib/runjs-context/snippets/scene/actions/collection-selected-count.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/actions/collection-selected-count.snippet.js +44 -0
- package/lib/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.js +43 -0
- package/lib/runjs-context/snippets/scene/actions/record-id-message.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/actions/record-id-message.snippet.js +43 -0
- package/lib/runjs-context/snippets/scene/actions/run-action-basic.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/actions/run-action-basic.snippet.js +40 -0
- package/lib/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.js +46 -0
- package/lib/runjs-context/snippets/scene/jsblock/append-style.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/append-style.snippet.js +42 -0
- package/lib/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.js +46 -0
- package/lib/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.js +41 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-basic.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-basic.snippet.js +41 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.js +46 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-card.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-card.snippet.js +45 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-react.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-react.snippet.js +56 -0
- package/lib/runjs-context/snippets/scene/jsfield/color-by-value.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsfield/color-by-value.snippet.js +42 -0
- package/lib/runjs-context/snippets/scene/jsfield/format-number.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsfield/format-number.snippet.js +41 -0
- package/lib/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.js +40 -0
- package/lib/runjs-context/snippets/scene/jsitem/render-basic.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsitem/render-basic.snippet.js +44 -0
- package/lib/runjs-context/snippets/scene/linkage/set-disabled.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/linkage/set-disabled.snippet.js +60 -0
- package/lib/runjs-context/snippets/scene/linkage/set-field-value.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/linkage/set-field-value.snippet.js +59 -0
- package/lib/runjs-context/snippets/scene/linkage/set-required.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/linkage/set-required.snippet.js +60 -0
- package/lib/runjs-context/snippets/scene/linkage/toggle-visible.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/linkage/toggle-visible.snippet.js +60 -0
- package/lib/runjs-context/snippets/types.d.ts +16 -0
- package/lib/runjs-context/snippets/types.js +24 -0
- package/lib/types.d.ts +398 -0
- package/lib/types.js +43 -0
- package/lib/utils/autoFlowError.d.ts +16 -0
- package/lib/utils/autoFlowError.js +53 -0
- package/lib/utils/constants.d.ts +29 -0
- package/lib/utils/constants.js +77 -0
- package/lib/utils/context.d.ts +40 -0
- package/lib/utils/context.js +63 -0
- package/lib/utils/createCollectionContextMeta.d.ts +11 -0
- package/lib/utils/createCollectionContextMeta.js +117 -0
- package/lib/utils/exceptions.d.ts +22 -0
- package/lib/utils/exceptions.js +62 -0
- package/lib/utils/flow-definitions.d.ts +11 -0
- package/lib/utils/flow-definitions.js +40 -0
- package/lib/utils/index.d.ts +22 -0
- package/lib/utils/index.js +117 -0
- package/lib/utils/inheritance.d.ts +16 -0
- package/lib/utils/inheritance.js +53 -0
- package/lib/utils/params-resolvers.d.ts +51 -0
- package/lib/utils/params-resolvers.js +309 -0
- package/lib/utils/parsePathnameToViewParams.d.ts +34 -0
- package/lib/utils/parsePathnameToViewParams.js +84 -0
- package/lib/utils/safeGlobals.d.ts +16 -0
- package/lib/utils/safeGlobals.js +179 -0
- package/lib/utils/schema-utils.d.ts +40 -0
- package/lib/utils/schema-utils.js +161 -0
- package/lib/utils/serverContextParams.d.ts +28 -0
- package/lib/utils/serverContextParams.js +106 -0
- package/lib/utils/setupRuntimeContextSteps.d.ts +19 -0
- package/lib/utils/setupRuntimeContextSteps.js +88 -0
- package/lib/utils/translation.d.ts +18 -0
- package/lib/utils/translation.js +58 -0
- package/lib/utils/variablesParams.d.ts +51 -0
- package/lib/utils/variablesParams.js +150 -0
- package/lib/views/DialogComponent.d.ts +22 -0
- package/lib/views/DialogComponent.js +98 -0
- package/lib/views/DrawerComponent.d.ts +11 -0
- package/lib/views/DrawerComponent.js +101 -0
- package/lib/views/FlowView.d.ts +76 -0
- package/lib/views/FlowView.js +81 -0
- package/lib/views/PageComponent.d.ts +10 -0
- package/lib/views/PageComponent.js +167 -0
- package/lib/views/ViewNavigation.d.ts +45 -0
- package/lib/views/ViewNavigation.js +97 -0
- package/lib/views/createViewMeta.d.ts +16 -0
- package/lib/views/createViewMeta.js +171 -0
- package/lib/views/index.d.ts +13 -0
- package/lib/views/index.js +48 -0
- package/lib/views/useDialog.d.ts +32 -0
- package/lib/views/useDialog.js +199 -0
- package/lib/views/useDrawer.d.ts +33 -0
- package/lib/views/useDrawer.js +206 -0
- package/lib/views/usePage.d.ts +32 -0
- package/lib/views/usePage.js +193 -0
- package/lib/views/usePatchElement.d.ts +10 -0
- package/lib/views/usePatchElement.js +54 -0
- package/lib/views/usePopover.d.ts +17 -0
- package/lib/views/usePopover.js +159 -0
- package/package.json +37 -0
- package/src/ContextPathProxy.ts +45 -0
- package/src/ElementProxy.ts +69 -0
- package/src/FlowContextProvider.tsx +40 -0
- package/src/FlowDefinition.ts +275 -0
- package/src/JSRunner.ts +84 -0
- package/src/ReactView.tsx +104 -0
- package/src/ViewScopedFlowEngine.ts +75 -0
- package/src/__tests__/ElementProxy.test.ts +51 -0
- package/src/__tests__/JSRunner.test.ts +92 -0
- package/src/__tests__/ReactView.test.tsx +63 -0
- package/src/__tests__/context-path-proxy.test.ts +35 -0
- package/src/__tests__/flow-engine.test.ts +189 -0
- package/src/__tests__/flowContext.test.ts +2012 -0
- package/src/__tests__/flowEngine.saveModel.test.ts +171 -0
- package/src/__tests__/flowI18n.test.ts +28 -0
- package/src/__tests__/flowModel.getFlows.test.ts +61 -0
- package/src/__tests__/flowModel.openView.navigation.test.ts +78 -0
- package/src/__tests__/flowRuntimeContext.test.ts +187 -0
- package/src/__tests__/flowSettings.open.test.tsx +1920 -0
- package/src/__tests__/flowSettings.test.ts +566 -0
- package/src/__tests__/globalFlowRegistry.test.ts +77 -0
- package/src/__tests__/isFieldInterfaceMatch.test.ts +51 -0
- package/src/__tests__/metaTreeNodeCache.test.ts +234 -0
- package/src/__tests__/path-aggregation.test.ts +85 -0
- package/src/__tests__/provider.test.tsx +28 -0
- package/src/__tests__/renderHiddenInConfig.test.tsx +91 -0
- package/src/__tests__/runjsContext.test.ts +60 -0
- package/src/__tests__/viewScopedFlowEngine.test.ts +212 -0
- package/src/acl/Acl.tsx +109 -0
- package/src/acl/__tests__/Acl.test.tsx +72 -0
- package/src/action-registry/BaseActionRegistry.ts +46 -0
- package/src/action-registry/EngineActionRegistry.ts +32 -0
- package/src/action-registry/ModelActionRegistry.ts +75 -0
- package/src/action-registry/__tests__/engineActionRegistry.test.ts +43 -0
- package/src/action-registry/__tests__/modelActionRegistry.test.ts +107 -0
- package/src/components/DynamicFlowsEditor.tsx +318 -0
- package/src/components/FieldModelRenderer.tsx +62 -0
- package/src/components/FlowContextSelector.tsx +255 -0
- package/src/components/FlowErrorFallback.tsx +316 -0
- package/src/components/FlowModelRenderer.tsx +428 -0
- package/src/components/FormItem.tsx +130 -0
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +226 -0
- package/src/components/common/FlowSettingsButton.tsx +30 -0
- package/src/components/common/index.ts +10 -0
- package/src/components/common/withFlowDesignMode.tsx +49 -0
- package/src/components/dnd/getMousePositionOnElement.ts +115 -0
- package/src/components/dnd/index.tsx +128 -0
- package/src/components/dnd/moveBlock.ts +379 -0
- package/src/components/index.ts +20 -0
- package/src/components/settings/independents/dropdown/FlowsDropdownButton.tsx +279 -0
- package/src/components/settings/independents/dropdown/index.ts +10 -0
- package/src/components/settings/independents/index.ts +2 -0
- package/src/components/settings/index.ts +11 -0
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +617 -0
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +292 -0
- package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +655 -0
- package/src/components/settings/wrappers/contextual/StepRequiredSettingsDialog.tsx +446 -0
- package/src/components/settings/wrappers/contextual/StepSettings.tsx +109 -0
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +217 -0
- package/src/components/settings/wrappers/contextual/StepSettingsDrawer.tsx +32 -0
- package/src/components/settings/wrappers/contextual/index.ts +15 -0
- package/src/components/settings/wrappers/embedded/FlowSettings.tsx +258 -0
- package/src/components/settings/wrappers/embedded/FlowsSettings.tsx +111 -0
- package/src/components/settings/wrappers/embedded/FlowsSettingsContent.tsx +96 -0
- package/src/components/settings/wrappers/embedded/index.ts +11 -0
- package/src/components/settings/wrappers/index.ts +5 -0
- package/src/components/subModel/AddSubModelButton.tsx +575 -0
- package/src/components/subModel/LazyDropdown.tsx +714 -0
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +1185 -0
- package/src/components/subModel/__tests__/buildWrapperFieldChildren.test.ts +192 -0
- package/src/components/subModel/__tests__/utils.test.ts +425 -0
- package/src/components/subModel/index.ts +12 -0
- package/src/components/subModel/utils.ts +278 -0
- package/src/components/variables/InlineVariableTag.tsx +97 -0
- package/src/components/variables/SlateVariableEditor.tsx +384 -0
- package/src/components/variables/VariableInput.tsx +342 -0
- package/src/components/variables/VariableTag.tsx +123 -0
- package/src/components/variables/VariableTrigger.tsx +116 -0
- package/src/components/variables/__tests__/FlowContextSelector.test.tsx +553 -0
- package/src/components/variables/__tests__/VariableInput.test.tsx +550 -0
- package/src/components/variables/__tests__/VariableTag.test.tsx +347 -0
- package/src/components/variables/__tests__/test-utils.tsx +62 -0
- package/src/components/variables/__tests__/utils.test.ts +310 -0
- package/src/components/variables/index.ts +16 -0
- package/src/components/variables/types.ts +100 -0
- package/src/components/variables/useResolvedMetaTree.ts +76 -0
- package/src/components/variables/utils.ts +192 -0
- package/src/data-source/__tests__/collection.test.ts +58 -0
- package/src/data-source/__tests__/index.test.ts +82 -0
- package/src/data-source/__tests__/jioToJoiSchema.test.ts +56 -0
- package/src/data-source/index.ts +812 -0
- package/src/data-source/jioToJoiSchema.ts +103 -0
- package/src/decorators/index.ts +10 -0
- package/src/decorators/largeField.ts +14 -0
- package/src/emitter.ts +33 -0
- package/src/event-registry/BaseEventRegistry.ts +40 -0
- package/src/event-registry/EngineEventRegistry.ts +26 -0
- package/src/event-registry/ModelEventRegistry.ts +69 -0
- package/src/event-registry/__tests__/engineEventRegistry.test.ts +48 -0
- package/src/executor/FlowExecutor.ts +256 -0
- package/src/executor/__tests__/eventStep.test.ts +157 -0
- package/src/executor/__tests__/flowExecutor.test.ts +163 -0
- package/src/flow-registry/BaseFlowRegistry.ts +91 -0
- package/src/flow-registry/GlobalFlowRegistry.ts +82 -0
- package/src/flow-registry/InstanceFlowRegistry.ts +39 -0
- package/src/flow-registry/__tests__/globalFlowRegistry.test.ts +141 -0
- package/src/flow-registry/__tests__/instance-and-global-registry.test.ts +67 -0
- package/src/flow-registry/__tests__/instanceFlowRegistry.test.ts +83 -0
- package/src/flow-registry/index.ts +12 -0
- package/src/flowContext.ts +1639 -0
- package/src/flowEngine.ts +905 -0
- package/src/flowI18n.ts +96 -0
- package/src/flowSettings.ts +1045 -0
- package/src/hooks/index.ts +15 -0
- package/src/hooks/useApplyAutoFlows.ts +51 -0
- package/src/hooks/useFlowModel.tsx +59 -0
- package/src/hooks/useFlowModelById.ts +37 -0
- package/src/hooks/useFlowSettingsContext.tsx +37 -0
- package/src/hooks/useFlowStep.tsx +19 -0
- package/src/hooks/useNiceDropdownMaxHeight.ts +34 -0
- package/src/index.ts +38 -0
- package/src/locale/en-US.json +61 -0
- package/src/locale/index.ts +38 -0
- package/src/locale/zh-CN.json +61 -0
- package/src/models/CollectionFieldModel.tsx +269 -0
- package/src/models/DisplayItemModel.tsx +13 -0
- package/src/models/EditableItemModel.tsx +13 -0
- package/src/models/FilterableItemModel.tsx +13 -0
- package/src/models/__tests__/CollectionFieldModel.test.ts +122 -0
- package/src/models/__tests__/defaultParams-on-create.test.ts +83 -0
- package/src/models/__tests__/flow-model-oninit.test.ts +44 -0
- package/src/models/__tests__/flowModel.actions.integration.test.ts +100 -0
- package/src/models/__tests__/flowModel.getFlows.sort.test.ts +100 -0
- package/src/models/__tests__/flowModel.test.ts +2746 -0
- package/src/models/__tests__/flowRegistry.test.ts +512 -0
- package/src/models/__tests__/forkFlowModel.test.ts +1047 -0
- package/src/models/__tests__/model-actions.test.ts +70 -0
- package/src/models/__tests__/model-events.test.ts +69 -0
- package/src/models/flowModel.tsx +1398 -0
- package/src/models/forkFlowModel.ts +287 -0
- package/src/models/index.ts +17 -0
- package/src/provider.tsx +101 -0
- package/src/resources/__tests__/apiResource.test.ts +201 -0
- package/src/resources/__tests__/baseRecordResource.test.ts +262 -0
- package/src/resources/__tests__/filterItem.test.ts +260 -0
- package/src/resources/__tests__/flowResource.test.ts +127 -0
- package/src/resources/apiResource.ts +148 -0
- package/src/resources/baseRecordResource.ts +279 -0
- package/src/resources/filterItem.ts +74 -0
- package/src/resources/flowResource.ts +143 -0
- package/src/resources/index.ts +17 -0
- package/src/resources/multiRecordResource.ts +219 -0
- package/src/resources/singleRecordResource.ts +83 -0
- package/src/resources/sqlResource.ts +299 -0
- package/src/runjs-context/contexts/FlowRunJSContext.ts +190 -0
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +39 -0
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +52 -0
- package/src/runjs-context/contexts/JSCollectionActionRunJSContext.ts +32 -0
- package/src/runjs-context/contexts/JSFieldRunJSContext.ts +43 -0
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +39 -0
- package/src/runjs-context/contexts/JSRecordActionRunJSContext.ts +34 -0
- package/src/runjs-context/contexts/LinkageRunJSContext.ts +35 -0
- package/src/runjs-context/helpers.ts +56 -0
- package/src/runjs-context/index.ts +20 -0
- package/src/runjs-context/registry.ts +65 -0
- package/src/runjs-context/snippets/global/api-request-get.snippet.ts +20 -0
- package/src/runjs-context/snippets/global/api-request-post.snippet.ts +20 -0
- package/src/runjs-context/snippets/global/console-log-ctx.snippet.ts +19 -0
- package/src/runjs-context/snippets/global/copy-record-json.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/copy-to-clipboard.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/log-json-record.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/message-error.snippet.ts +20 -0
- package/src/runjs-context/snippets/global/message-success.snippet.ts +20 -0
- package/src/runjs-context/snippets/global/notification-open.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/open-view-dialog.snippet.ts +26 -0
- package/src/runjs-context/snippets/global/open-view-drawer.snippet.ts +26 -0
- package/src/runjs-context/snippets/global/requireAsync.snippet.ts +24 -0
- package/src/runjs-context/snippets/global/sleep.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/try-catch-async.snippet.ts +22 -0
- package/src/runjs-context/snippets/global/view-navigation-push.snippet.ts +23 -0
- package/src/runjs-context/snippets/global/window-open.snippet.ts +19 -0
- package/src/runjs-context/snippets/index.ts +59 -0
- package/src/runjs-context/snippets/libs/echarts-init.snippet.ts +24 -0
- package/src/runjs-context/snippets/scene/actions/collection-selected-count.snippet.ts +22 -0
- package/src/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.ts +21 -0
- package/src/runjs-context/snippets/scene/actions/record-id-message.snippet.ts +21 -0
- package/src/runjs-context/snippets/scene/actions/run-action-basic.snippet.ts +18 -0
- package/src/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.ts +29 -0
- package/src/runjs-context/snippets/scene/jsblock/append-style.snippet.ts +20 -0
- package/src/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.ts +24 -0
- package/src/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.ts +19 -0
- package/src/runjs-context/snippets/scene/jsblock/render-basic.snippet.ts +24 -0
- package/src/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.ts +24 -0
- package/src/runjs-context/snippets/scene/jsblock/render-card.snippet.ts +30 -0
- package/src/runjs-context/snippets/scene/jsblock/render-react.snippet.ts +34 -0
- package/src/runjs-context/snippets/scene/jsfield/color-by-value.snippet.ts +20 -0
- package/src/runjs-context/snippets/scene/jsfield/format-number.snippet.ts +19 -0
- package/src/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.ts +18 -0
- package/src/runjs-context/snippets/scene/jsitem/render-basic.snippet.ts +27 -0
- package/src/runjs-context/snippets/scene/linkage/set-disabled.snippet.ts +38 -0
- package/src/runjs-context/snippets/scene/linkage/set-field-value.snippet.ts +37 -0
- package/src/runjs-context/snippets/scene/linkage/set-required.snippet.ts +38 -0
- package/src/runjs-context/snippets/scene/linkage/toggle-visible.snippet.ts +38 -0
- package/src/runjs-context/snippets/types.ts +17 -0
- package/src/types.ts +474 -0
- package/src/utils/__tests__/context.test.ts +93 -0
- package/src/utils/__tests__/params-resolvers.test.ts +652 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +104 -0
- package/src/utils/__tests__/safeGlobals.test.ts +29 -0
- package/src/utils/__tests__/utils.test.ts +1021 -0
- package/src/utils/__tests__/variablesParams.test.ts +52 -0
- package/src/utils/autoFlowError.ts +29 -0
- package/src/utils/constants.ts +60 -0
- package/src/utils/context.ts +70 -0
- package/src/utils/createCollectionContextMeta.ts +122 -0
- package/src/utils/exceptions.ts +36 -0
- package/src/utils/flow-definitions.ts +16 -0
- package/src/utils/index.ts +63 -0
- package/src/utils/inheritance.ts +39 -0
- package/src/utils/params-resolvers.ts +482 -0
- package/src/utils/parsePathnameToViewParams.ts +103 -0
- package/src/utils/safeGlobals.ts +188 -0
- package/src/utils/schema-utils.ts +201 -0
- package/src/utils/serverContextParams.ts +111 -0
- package/src/utils/setupRuntimeContextSteps.ts +89 -0
- package/src/utils/translation.ts +37 -0
- package/src/utils/variablesParams.ts +175 -0
- package/src/views/DialogComponent.tsx +79 -0
- package/src/views/DrawerComponent.tsx +72 -0
- package/src/views/FlowView.tsx +103 -0
- package/src/views/PageComponent.tsx +150 -0
- package/src/views/ViewNavigation.ts +122 -0
- package/src/views/__tests__/FlowView.test.ts +31 -0
- package/src/views/__tests__/ViewNavigation.test.ts +191 -0
- package/src/views/__tests__/usePatchElement.test.tsx +28 -0
- package/src/views/createViewMeta.ts +157 -0
- package/src/views/index.tsx +14 -0
- package/src/views/useDialog.tsx +192 -0
- package/src/views/useDrawer.tsx +205 -0
- package/src/views/usePage.tsx +182 -0
- package/src/views/usePatchElement.tsx +27 -0
- package/src/views/usePopover.tsx +131 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { uid } from '@formily/shared';
|
|
11
|
+
import _ from 'lodash';
|
|
12
|
+
import { ElementPosition } from './getMousePositionOnElement';
|
|
13
|
+
|
|
14
|
+
type MoveDirection =
|
|
15
|
+
| 'insert-row-above'
|
|
16
|
+
| 'insert-row-below'
|
|
17
|
+
| 'insert-same-column-above'
|
|
18
|
+
| 'insert-same-column-below'
|
|
19
|
+
| 'insert-column-left'
|
|
20
|
+
| 'insert-column-right';
|
|
21
|
+
|
|
22
|
+
interface GridLayoutData {
|
|
23
|
+
rows: Record<string, string[][]>;
|
|
24
|
+
sizes: Record<string, number[]>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const findModelUidPosition = (uid: string, rows: Record<string, string[][]>) => {
|
|
28
|
+
// 找到 sourceUid 和 targetUid 的位置
|
|
29
|
+
let result: { rowId: string; columnIndex: number; itemIndex: number } | null = null;
|
|
30
|
+
|
|
31
|
+
for (const [rowId, columns] of Object.entries(rows)) {
|
|
32
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex++) {
|
|
33
|
+
const column = columns[columnIndex];
|
|
34
|
+
for (let itemIndex = 0; itemIndex < column.length; itemIndex++) {
|
|
35
|
+
if (column[itemIndex] === uid) {
|
|
36
|
+
result = { rowId, columnIndex, itemIndex };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const moveBlock = ({
|
|
46
|
+
sourceUid,
|
|
47
|
+
targetUid,
|
|
48
|
+
direction,
|
|
49
|
+
layoutData,
|
|
50
|
+
}: {
|
|
51
|
+
sourceUid: string;
|
|
52
|
+
targetUid: string;
|
|
53
|
+
direction: MoveDirection;
|
|
54
|
+
layoutData: GridLayoutData;
|
|
55
|
+
}): GridLayoutData => {
|
|
56
|
+
const { rows, sizes } = layoutData;
|
|
57
|
+
const newSizes = _.cloneDeep(sizes);
|
|
58
|
+
let newRows = _.cloneDeep(rows);
|
|
59
|
+
|
|
60
|
+
// 找到 sourceUid 和 targetUid 的位置
|
|
61
|
+
let sourcePosition: { rowId: string; columnIndex: number; itemIndex: number } | null = null;
|
|
62
|
+
let targetPosition: { rowId: string; columnIndex: number; itemIndex: number } | null = null;
|
|
63
|
+
|
|
64
|
+
for (const [rowId, columns] of Object.entries(newRows)) {
|
|
65
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex++) {
|
|
66
|
+
const column = columns[columnIndex];
|
|
67
|
+
for (let itemIndex = 0; itemIndex < column.length; itemIndex++) {
|
|
68
|
+
if (column[itemIndex] === sourceUid) {
|
|
69
|
+
sourcePosition = { rowId, columnIndex, itemIndex };
|
|
70
|
+
}
|
|
71
|
+
if (column[itemIndex] === targetUid) {
|
|
72
|
+
targetPosition = { rowId, columnIndex, itemIndex };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!sourcePosition || !targetPosition) {
|
|
79
|
+
return layoutData; // 如果没有找到 sourceUid 或 targetUid,直接返回原数据
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const removeOldSourceUid = () => {
|
|
83
|
+
// 从原位置移除 sourceUid
|
|
84
|
+
newRows[sourcePosition.rowId][sourcePosition.columnIndex].splice(sourcePosition.itemIndex, 1);
|
|
85
|
+
|
|
86
|
+
// 如果列变空了,移除该列
|
|
87
|
+
if (newRows[sourcePosition.rowId][sourcePosition.columnIndex].length === 0) {
|
|
88
|
+
newRows[sourcePosition.rowId]?.splice(sourcePosition.columnIndex, 1);
|
|
89
|
+
newSizes[sourcePosition.rowId]?.splice(sourcePosition.columnIndex, 1);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 如果行变空了,移除该行
|
|
93
|
+
if (newRows[sourcePosition.rowId].length === 0) {
|
|
94
|
+
delete newRows[sourcePosition.rowId];
|
|
95
|
+
delete newSizes[sourcePosition.rowId];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 移除完之后,重新设置 sourcePosition 和 targetPosition
|
|
99
|
+
for (const [rowId, columns] of Object.entries(newRows)) {
|
|
100
|
+
for (let columnIndex = 0; columnIndex < columns.length; columnIndex++) {
|
|
101
|
+
const column = columns[columnIndex];
|
|
102
|
+
for (let itemIndex = 0; itemIndex < column.length; itemIndex++) {
|
|
103
|
+
if (column[itemIndex] === sourceUid) {
|
|
104
|
+
sourcePosition = { rowId, columnIndex, itemIndex };
|
|
105
|
+
}
|
|
106
|
+
if (column[itemIndex] === targetUid) {
|
|
107
|
+
targetPosition = { rowId, columnIndex, itemIndex };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
switch (direction) {
|
|
115
|
+
case 'insert-row-above': {
|
|
116
|
+
// 检查 targetUid 上面是否有其他同列的 uid
|
|
117
|
+
if (targetPosition.itemIndex > 0) {
|
|
118
|
+
return layoutData; // 无效操作,直接返回原数据
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
removeOldSourceUid();
|
|
122
|
+
|
|
123
|
+
// 创建新行 ID
|
|
124
|
+
const newRowId = uid();
|
|
125
|
+
|
|
126
|
+
// 插入到目标行前面
|
|
127
|
+
newRows = insertKey({
|
|
128
|
+
obj: newRows,
|
|
129
|
+
newKey: newRowId,
|
|
130
|
+
newValue: [[sourceUid]],
|
|
131
|
+
referenceKey: targetPosition.rowId,
|
|
132
|
+
position: 'before',
|
|
133
|
+
});
|
|
134
|
+
newSizes[newRowId] = [24];
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
case 'insert-row-below': {
|
|
139
|
+
// 检查 targetUid 所在行的后面是否有同名的 sourceUid
|
|
140
|
+
const nextRowKey = getNextKey(newRows, targetPosition.rowId);
|
|
141
|
+
|
|
142
|
+
if (nextRowKey === sourcePosition.rowId && newRows[nextRowKey].length === 1) {
|
|
143
|
+
return layoutData; // 无效操作,直接返回原数据
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
removeOldSourceUid();
|
|
147
|
+
|
|
148
|
+
// 创建新行ID
|
|
149
|
+
const newRowId = uid();
|
|
150
|
+
|
|
151
|
+
// 插入到目标行后面
|
|
152
|
+
newRows = insertKey({
|
|
153
|
+
obj: newRows,
|
|
154
|
+
newKey: newRowId,
|
|
155
|
+
newValue: [[sourceUid]],
|
|
156
|
+
referenceKey: targetPosition.rowId,
|
|
157
|
+
position: 'after',
|
|
158
|
+
});
|
|
159
|
+
newSizes[newRowId] = [24];
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
case 'insert-same-column-above': {
|
|
164
|
+
removeOldSourceUid();
|
|
165
|
+
|
|
166
|
+
const column = newRows[targetPosition.rowId][targetPosition.columnIndex];
|
|
167
|
+
if (column[targetPosition.itemIndex - 1] === sourceUid) {
|
|
168
|
+
return layoutData; // 无效操作,直接返回原数据
|
|
169
|
+
}
|
|
170
|
+
column.splice(targetPosition.itemIndex, 0, sourceUid);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
case 'insert-same-column-below': {
|
|
175
|
+
removeOldSourceUid();
|
|
176
|
+
|
|
177
|
+
const column = newRows[targetPosition.rowId][targetPosition.columnIndex];
|
|
178
|
+
if (column[targetPosition.itemIndex + 1] === sourceUid) {
|
|
179
|
+
return layoutData; // 无效操作,直接返回原数据
|
|
180
|
+
}
|
|
181
|
+
column.splice(targetPosition.itemIndex + 1, 0, sourceUid);
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
case 'insert-column-left': {
|
|
186
|
+
removeOldSourceUid();
|
|
187
|
+
|
|
188
|
+
// 在目标列左侧插入新列
|
|
189
|
+
newRows[targetPosition.rowId].splice(targetPosition.columnIndex, 0, [sourceUid]);
|
|
190
|
+
|
|
191
|
+
// 重新计算列宽
|
|
192
|
+
const currentSizes = newSizes[targetPosition.rowId] || [];
|
|
193
|
+
const columnCount = newRows[targetPosition.rowId].length || 0;
|
|
194
|
+
const newColumnWidth = Math.floor(24 / columnCount);
|
|
195
|
+
const remainingWidth = 24 - newColumnWidth;
|
|
196
|
+
|
|
197
|
+
// 按原比例分配剩余宽度
|
|
198
|
+
const totalOldWidth = currentSizes.reduce((sum, size) => sum + size, 0);
|
|
199
|
+
const adjustedSizes = currentSizes.map((size) => Math.floor((size / totalOldWidth) * remainingWidth));
|
|
200
|
+
|
|
201
|
+
// 插入新列宽度
|
|
202
|
+
adjustedSizes.splice(targetPosition.columnIndex, 0, newColumnWidth);
|
|
203
|
+
|
|
204
|
+
// 处理舍入误差
|
|
205
|
+
const totalNewWidth = adjustedSizes.reduce((sum, size) => sum + size, 0);
|
|
206
|
+
if (totalNewWidth < 24) {
|
|
207
|
+
adjustedSizes[adjustedSizes.length - 1] += 24 - totalNewWidth;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
newSizes[targetPosition.rowId] = adjustedSizes;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
case 'insert-column-right': {
|
|
215
|
+
removeOldSourceUid();
|
|
216
|
+
|
|
217
|
+
// 在目标列右侧插入新列
|
|
218
|
+
newRows[targetPosition.rowId].splice(targetPosition.columnIndex + 1, 0, [sourceUid]);
|
|
219
|
+
|
|
220
|
+
// 重新计算列宽
|
|
221
|
+
const currentSizes = newSizes[targetPosition.rowId] || [];
|
|
222
|
+
const columnCount = newRows[targetPosition.rowId]?.length || 0;
|
|
223
|
+
const newColumnWidth = Math.floor(24 / columnCount);
|
|
224
|
+
const remainingWidth = 24 - newColumnWidth;
|
|
225
|
+
|
|
226
|
+
// 按原比例分配剩余宽度
|
|
227
|
+
const totalOldWidth = currentSizes.reduce((sum, size) => sum + size, 0);
|
|
228
|
+
const adjustedSizes = currentSizes.map((size) => Math.floor((size / totalOldWidth) * remainingWidth));
|
|
229
|
+
|
|
230
|
+
// 插入新列宽度
|
|
231
|
+
adjustedSizes.splice(targetPosition.columnIndex + 1, 0, newColumnWidth);
|
|
232
|
+
|
|
233
|
+
// 处理舍入误差
|
|
234
|
+
const totalNewWidth = adjustedSizes.reduce((sum, size) => sum + size, 0);
|
|
235
|
+
if (totalNewWidth < 24) {
|
|
236
|
+
adjustedSizes[adjustedSizes.length - 1] += 24 - totalNewWidth;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
newSizes[targetPosition.rowId] = adjustedSizes;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return recalculateAllRowSizesWithProportion({ rows: newRows, sizes: newSizes });
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* 将鼠标在元素上的位置转换为区块移动方向
|
|
249
|
+
*
|
|
250
|
+
* @param position 鼠标在元素上的位置
|
|
251
|
+
* @returns 对应的移动方向
|
|
252
|
+
*/
|
|
253
|
+
export const positionToDirection = (position: ElementPosition): MoveDirection => {
|
|
254
|
+
switch (position) {
|
|
255
|
+
case ElementPosition.TOP:
|
|
256
|
+
return 'insert-same-column-above';
|
|
257
|
+
case ElementPosition.BOTTOM:
|
|
258
|
+
return 'insert-same-column-below';
|
|
259
|
+
case ElementPosition.LEFT:
|
|
260
|
+
return 'insert-column-left';
|
|
261
|
+
case ElementPosition.RIGHT:
|
|
262
|
+
return 'insert-column-right';
|
|
263
|
+
case ElementPosition.TOP_EDGE:
|
|
264
|
+
return 'insert-row-above';
|
|
265
|
+
case ElementPosition.BOTTOM_EDGE:
|
|
266
|
+
return 'insert-row-below';
|
|
267
|
+
case ElementPosition.LEFT_EDGE:
|
|
268
|
+
return 'insert-column-left';
|
|
269
|
+
case ElementPosition.RIGHT_EDGE:
|
|
270
|
+
return 'insert-column-right';
|
|
271
|
+
default:
|
|
272
|
+
throw new Error(`Unsupported position: ${position}`);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
function insertKey({
|
|
277
|
+
obj,
|
|
278
|
+
newKey,
|
|
279
|
+
newValue,
|
|
280
|
+
referenceKey,
|
|
281
|
+
position,
|
|
282
|
+
}: {
|
|
283
|
+
obj: Record<string, any>;
|
|
284
|
+
newKey: string;
|
|
285
|
+
newValue: any;
|
|
286
|
+
referenceKey: string;
|
|
287
|
+
position: 'before' | 'after';
|
|
288
|
+
}) {
|
|
289
|
+
const result: Record<string, any> = {};
|
|
290
|
+
|
|
291
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
292
|
+
if (position === 'before' && key === referenceKey) {
|
|
293
|
+
result[newKey] = newValue;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
result[key] = value;
|
|
297
|
+
|
|
298
|
+
if (position === 'after' && key === referenceKey) {
|
|
299
|
+
result[newKey] = newValue;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return result;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function getNextKey(obj: Record<string, any>, currentKey: string): string | null {
|
|
307
|
+
const keys = Object.keys(obj);
|
|
308
|
+
const index = keys.indexOf(currentKey);
|
|
309
|
+
return index >= 0 && index < keys.length - 1 ? keys[index + 1] : null;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* 重新计算所有行的列宽,保持原有比例的同时确保总宽度为24
|
|
314
|
+
* @param layoutData 当前的布局数据
|
|
315
|
+
* @returns 更新后的布局数据
|
|
316
|
+
*/
|
|
317
|
+
function recalculateAllRowSizesWithProportion(layoutData: GridLayoutData): GridLayoutData {
|
|
318
|
+
const { rows, sizes } = layoutData;
|
|
319
|
+
const newSizes = _.cloneDeep(sizes);
|
|
320
|
+
|
|
321
|
+
for (const [rowId, columns] of Object.entries(rows)) {
|
|
322
|
+
const columnCount = columns.length;
|
|
323
|
+
const currentSizes = sizes[rowId] || [];
|
|
324
|
+
|
|
325
|
+
if (columnCount === 0) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// 如果当前没有尺寸信息或尺寸数量不匹配,使用均等分配
|
|
330
|
+
if (currentSizes.length !== columnCount || currentSizes.every((size) => size === 0)) {
|
|
331
|
+
const baseWidth = Math.floor(24 / columnCount);
|
|
332
|
+
const remainder = 24 % columnCount;
|
|
333
|
+
const newRowSizes = new Array(columnCount).fill(baseWidth);
|
|
334
|
+
|
|
335
|
+
for (let i = 0; i < remainder; i++) {
|
|
336
|
+
newRowSizes[i] += 1;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
newSizes[rowId] = newRowSizes;
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// 计算当前总宽度
|
|
344
|
+
const currentTotal = currentSizes.reduce((sum, size) => sum + size, 0);
|
|
345
|
+
|
|
346
|
+
if (currentTotal === 0) {
|
|
347
|
+
// 如果当前总宽度为0,使用均等分配
|
|
348
|
+
const baseWidth = Math.floor(24 / columnCount);
|
|
349
|
+
const remainder = 24 % columnCount;
|
|
350
|
+
const newRowSizes = new Array(columnCount).fill(baseWidth);
|
|
351
|
+
|
|
352
|
+
for (let i = 0; i < remainder; i++) {
|
|
353
|
+
newRowSizes[i] += 1;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
newSizes[rowId] = newRowSizes;
|
|
357
|
+
} else {
|
|
358
|
+
// 按比例重新分配
|
|
359
|
+
const newRowSizes = currentSizes.map((size) => Math.floor((size / currentTotal) * 24));
|
|
360
|
+
|
|
361
|
+
// 处理舍入误差
|
|
362
|
+
const actualTotal = newRowSizes.reduce((sum, size) => sum + size, 0);
|
|
363
|
+
const diff = 24 - actualTotal;
|
|
364
|
+
|
|
365
|
+
// 将差值分配给最后几列
|
|
366
|
+
for (let i = newRowSizes.length - 1; i >= 0 && diff > 0; i--) {
|
|
367
|
+
const add = Math.min(diff, 1);
|
|
368
|
+
newRowSizes[i] += add;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
newSizes[rowId] = newRowSizes;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return {
|
|
376
|
+
rows,
|
|
377
|
+
sizes: newSizes,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export * from './common/FlowSettingsButton';
|
|
11
|
+
export * from './dnd';
|
|
12
|
+
export * from './FieldModelRenderer';
|
|
13
|
+
export * from './FlowContextSelector';
|
|
14
|
+
export * from './FlowErrorFallback';
|
|
15
|
+
export * from './FlowModelRenderer';
|
|
16
|
+
export * from './FormItem';
|
|
17
|
+
export * from './settings';
|
|
18
|
+
export * from './subModel';
|
|
19
|
+
export * from './variables';
|
|
20
|
+
//
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { DownOutlined, SettingOutlined } from '@ant-design/icons';
|
|
11
|
+
import { observer } from '@formily/react';
|
|
12
|
+
import { Alert, Button, Dropdown, Space } from 'antd';
|
|
13
|
+
import React, { useCallback } from 'react';
|
|
14
|
+
import { useFlowModelById } from '../../../../hooks';
|
|
15
|
+
import { FlowModel } from '../../../../models';
|
|
16
|
+
|
|
17
|
+
// 支持两种使用方式的接口定义
|
|
18
|
+
interface ModelProvidedProps {
|
|
19
|
+
model: FlowModel;
|
|
20
|
+
text?: string;
|
|
21
|
+
icon?: React.ReactNode;
|
|
22
|
+
size?: 'small' | 'middle' | 'large';
|
|
23
|
+
type?: 'default' | 'primary' | 'dashed' | 'link' | 'text';
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
showDropdownIcon?: boolean;
|
|
26
|
+
onClick?: () => void;
|
|
27
|
+
style?: React.CSSProperties;
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface ModelByIdProps {
|
|
32
|
+
uid: string;
|
|
33
|
+
modelClassName: string;
|
|
34
|
+
text?: string;
|
|
35
|
+
icon?: React.ReactNode;
|
|
36
|
+
size?: 'small' | 'middle' | 'large';
|
|
37
|
+
type?: 'default' | 'primary' | 'dashed' | 'link' | 'text';
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
showDropdownIcon?: boolean;
|
|
40
|
+
onClick?: () => void;
|
|
41
|
+
style?: React.CSSProperties;
|
|
42
|
+
className?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type FlowsDropdownButtonProps = ModelProvidedProps | ModelByIdProps;
|
|
46
|
+
|
|
47
|
+
// 判断是否是通过ID获取模型的props
|
|
48
|
+
const isModelByIdProps = (props: FlowsDropdownButtonProps): props is ModelByIdProps => {
|
|
49
|
+
return 'uid' in props && 'modelClassName' in props && Boolean(props.uid) && Boolean(props.modelClassName);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 可自定义的下拉菜单触发按钮组件
|
|
54
|
+
* 支持两种使用方式:
|
|
55
|
+
* 1. 直接提供model: <FlowsDropdownButton model={myModel} />
|
|
56
|
+
* 2. 通过uid和modelClassName获取model: <FlowsDropdownButton uid="model1" modelClassName="MyModel" />
|
|
57
|
+
*
|
|
58
|
+
* 菜单结构:按flow分组显示steps
|
|
59
|
+
*/
|
|
60
|
+
export const FlowsDropdownButton: React.FC<FlowsDropdownButtonProps> = (props) => {
|
|
61
|
+
if (isModelByIdProps(props)) {
|
|
62
|
+
const { uid, modelClassName, ...restProps } = props;
|
|
63
|
+
return <FlowsDropdownButtonWithModelById uid={uid} modelClassName={modelClassName} {...restProps} />;
|
|
64
|
+
} else {
|
|
65
|
+
const { model, ...restProps } = props;
|
|
66
|
+
return <FlowsDropdownButtonWithModel model={model} {...restProps} />;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// 使用传入的model
|
|
71
|
+
const FlowsDropdownButtonWithModel: React.FC<ModelProvidedProps> = observer(
|
|
72
|
+
({
|
|
73
|
+
model,
|
|
74
|
+
text = '流程配置',
|
|
75
|
+
icon = <SettingOutlined />,
|
|
76
|
+
size = 'middle',
|
|
77
|
+
type = 'default',
|
|
78
|
+
disabled = false,
|
|
79
|
+
showDropdownIcon = true,
|
|
80
|
+
onClick,
|
|
81
|
+
style,
|
|
82
|
+
className,
|
|
83
|
+
}) => {
|
|
84
|
+
const handleClick = () => {
|
|
85
|
+
onClick?.();
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const handleMenuClick = useCallback(
|
|
89
|
+
({ key }: { key: string }) => {
|
|
90
|
+
// key格式为 "flowKey:stepKey"
|
|
91
|
+
const [flowKey, stepKey] = key.split(':');
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
model.openFlowSettings({
|
|
95
|
+
flowKey,
|
|
96
|
+
stepKey,
|
|
97
|
+
});
|
|
98
|
+
} catch (error) {
|
|
99
|
+
// 用户取消或出错
|
|
100
|
+
console.log('配置弹窗已取消或出错:', error);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
[model],
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
if (!model) {
|
|
107
|
+
return <Alert message="提供的模型无效" type="error" />;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 获取可配置的flows和steps
|
|
111
|
+
const getConfigurableFlowsAndSteps = useCallback(() => {
|
|
112
|
+
try {
|
|
113
|
+
// const ModelClass = model.constructor as typeof FlowModel;
|
|
114
|
+
const flows = model.getFlows();
|
|
115
|
+
|
|
116
|
+
const flowsArray = Array.from(flows.values());
|
|
117
|
+
|
|
118
|
+
return flowsArray
|
|
119
|
+
.map((flow) => {
|
|
120
|
+
const configurableSteps = Object.entries(flow.steps)
|
|
121
|
+
.map(([stepKey, stepDefinition]) => {
|
|
122
|
+
const actionStep = stepDefinition;
|
|
123
|
+
|
|
124
|
+
// 如果步骤设置了 hideInSettings: true,则跳过此步骤
|
|
125
|
+
if (actionStep.hideInSettings) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// 从step获取uiSchema(如果存在)
|
|
130
|
+
const stepUiSchema = actionStep.uiSchema || {};
|
|
131
|
+
|
|
132
|
+
// 如果step使用了action,也获取action的uiSchema
|
|
133
|
+
let actionUiSchema = {};
|
|
134
|
+
if (actionStep.use) {
|
|
135
|
+
const action = model.flowEngine?.getAction?.(actionStep.use);
|
|
136
|
+
if (action && action.uiSchema) {
|
|
137
|
+
actionUiSchema = action.uiSchema;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// 合并uiSchema,确保step的uiSchema优先级更高
|
|
142
|
+
const mergedUiSchema = { ...actionUiSchema };
|
|
143
|
+
|
|
144
|
+
// 将stepUiSchema中的字段合并到mergedUiSchema
|
|
145
|
+
Object.entries(stepUiSchema).forEach(([fieldKey, schema]) => {
|
|
146
|
+
if (mergedUiSchema[fieldKey]) {
|
|
147
|
+
mergedUiSchema[fieldKey] = { ...mergedUiSchema[fieldKey], ...schema };
|
|
148
|
+
} else {
|
|
149
|
+
mergedUiSchema[fieldKey] = schema;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// 如果没有可配置的UI Schema,返回null
|
|
154
|
+
if (Object.keys(mergedUiSchema).length === 0) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
stepKey,
|
|
160
|
+
step: actionStep,
|
|
161
|
+
uiSchema: mergedUiSchema,
|
|
162
|
+
title: actionStep.title || stepKey,
|
|
163
|
+
};
|
|
164
|
+
})
|
|
165
|
+
.filter(Boolean);
|
|
166
|
+
|
|
167
|
+
return configurableSteps.length > 0 ? { flow, steps: configurableSteps } : null;
|
|
168
|
+
})
|
|
169
|
+
.filter(Boolean);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.warn('[FlowsDropdownButton] 获取可配置flows失败:', error);
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
}, [model]);
|
|
175
|
+
|
|
176
|
+
const configurableFlowsAndSteps = getConfigurableFlowsAndSteps();
|
|
177
|
+
|
|
178
|
+
// 构建菜单项
|
|
179
|
+
const buildMenuItems = () => {
|
|
180
|
+
const items = [];
|
|
181
|
+
|
|
182
|
+
configurableFlowsAndSteps.forEach(({ flow, steps }) => {
|
|
183
|
+
// 始终按flow分组显示
|
|
184
|
+
items.push({
|
|
185
|
+
key: `flow-group-${flow.key}`,
|
|
186
|
+
label: flow.title || flow.key,
|
|
187
|
+
type: 'group',
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
steps.forEach((stepInfo) => {
|
|
191
|
+
items.push({
|
|
192
|
+
key: `${flow.key}:${stepInfo.stepKey}`,
|
|
193
|
+
icon: <SettingOutlined />,
|
|
194
|
+
label: stepInfo.title,
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
return items;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const menuItems = buildMenuItems();
|
|
203
|
+
|
|
204
|
+
const button = (
|
|
205
|
+
<Button
|
|
206
|
+
type={type}
|
|
207
|
+
size={size}
|
|
208
|
+
disabled={disabled}
|
|
209
|
+
icon={icon}
|
|
210
|
+
onClick={handleClick}
|
|
211
|
+
style={style}
|
|
212
|
+
className={className}
|
|
213
|
+
>
|
|
214
|
+
<Space>
|
|
215
|
+
{text}
|
|
216
|
+
{showDropdownIcon && <DownOutlined />}
|
|
217
|
+
</Space>
|
|
218
|
+
</Button>
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
// 如果没有可配置的flows,返回普通按钮
|
|
222
|
+
if (configurableFlowsAndSteps.length === 0) {
|
|
223
|
+
return button;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<>
|
|
228
|
+
<Dropdown
|
|
229
|
+
menu={{
|
|
230
|
+
items: menuItems,
|
|
231
|
+
onClick: handleMenuClick,
|
|
232
|
+
}}
|
|
233
|
+
trigger={['click']}
|
|
234
|
+
placement="bottomRight"
|
|
235
|
+
>
|
|
236
|
+
{button}
|
|
237
|
+
</Dropdown>
|
|
238
|
+
</>
|
|
239
|
+
);
|
|
240
|
+
},
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
// 通过useFlowModelById hook获取model
|
|
244
|
+
const FlowsDropdownButtonWithModelById: React.FC<ModelByIdProps> = observer(
|
|
245
|
+
({
|
|
246
|
+
uid,
|
|
247
|
+
modelClassName,
|
|
248
|
+
text = '流程配置',
|
|
249
|
+
icon = <SettingOutlined />,
|
|
250
|
+
size = 'middle',
|
|
251
|
+
type = 'default',
|
|
252
|
+
disabled = false,
|
|
253
|
+
showDropdownIcon = true,
|
|
254
|
+
onClick,
|
|
255
|
+
style,
|
|
256
|
+
className,
|
|
257
|
+
}) => {
|
|
258
|
+
const model = useFlowModelById(uid, modelClassName);
|
|
259
|
+
|
|
260
|
+
if (!model) {
|
|
261
|
+
return <Alert message={`未找到ID为 ${uid} 的模型`} type="error" />;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return (
|
|
265
|
+
<FlowsDropdownButtonWithModel
|
|
266
|
+
model={model}
|
|
267
|
+
text={text}
|
|
268
|
+
icon={icon}
|
|
269
|
+
size={size}
|
|
270
|
+
type={type}
|
|
271
|
+
disabled={disabled}
|
|
272
|
+
showDropdownIcon={showDropdownIcon}
|
|
273
|
+
onClick={onClick}
|
|
274
|
+
style={style}
|
|
275
|
+
className={className}
|
|
276
|
+
/>
|
|
277
|
+
);
|
|
278
|
+
},
|
|
279
|
+
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export * from './FlowsDropdownButton';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export * from './independents';
|
|
11
|
+
export * from './wrappers';
|