@nocobase/flow-engine 2.0.0-alpha.9 → 2.0.0-beta.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/lib/BlockScopedFlowEngine.d.ts +23 -0
- package/lib/BlockScopedFlowEngine.js +92 -0
- package/lib/FlowDefinition.d.ts +6 -4
- package/lib/JSRunner.js +3 -0
- package/lib/ViewScopedFlowEngine.js +15 -1
- package/lib/acl/Acl.d.ts +12 -12
- package/lib/acl/Acl.js +78 -30
- package/lib/components/DynamicFlowsEditor.js +2 -4
- package/lib/components/FieldModelRenderer.js +10 -8
- package/lib/components/FieldSkeleton.d.ts +10 -0
- package/lib/components/FieldSkeleton.js +64 -0
- package/lib/components/FlowContextSelector.js +19 -3
- package/lib/components/FlowModelRenderer.d.ts +2 -1
- package/lib/components/FlowModelRenderer.js +34 -12
- package/lib/components/FormItem.js +5 -1
- package/lib/components/MobilePopup.d.ts +20 -0
- package/lib/components/MobilePopup.js +102 -0
- package/lib/components/MobilePopup.style.d.ts +17 -0
- package/lib/components/MobilePopup.style.js +186 -0
- package/lib/components/common/withFlowDesignMode.d.ts +1 -1
- package/lib/components/common/withFlowDesignMode.js +5 -5
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +3 -1
- package/lib/components/settings/independents/dropdown/FlowsDropdownButton.js +71 -53
- package/lib/components/settings/wrappers/component/SelectWithTitle.d.ts +19 -0
- package/lib/components/settings/wrappers/component/SelectWithTitle.js +136 -0
- package/lib/components/settings/wrappers/component/SwitchWithTitle.d.ts +10 -0
- package/lib/components/settings/wrappers/component/SwitchWithTitle.js +110 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +221 -93
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +71 -54
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +2 -2
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +63 -23
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +11 -6
- package/lib/components/settings/wrappers/embedded/FlowSettings.js +42 -28
- package/lib/components/settings/wrappers/embedded/FlowsSettings.js +3 -3
- package/lib/components/settings/wrappers/embedded/FlowsSettingsContent.js +52 -32
- package/lib/components/subModel/AddSubModelButton.d.ts +7 -0
- package/lib/components/subModel/AddSubModelButton.js +78 -8
- package/lib/components/subModel/LazyDropdown.js +14 -15
- package/lib/components/subModel/utils.d.ts +1 -1
- package/lib/components/subModel/utils.js +21 -11
- package/lib/components/variables/VariableInput.js +5 -3
- package/lib/components/variables/types.d.ts +2 -0
- package/lib/components/variables/utils.js +4 -2
- package/lib/data-source/index.d.ts +43 -4
- package/lib/data-source/index.js +104 -11
- package/lib/data-source/jioToJoiSchema.js +1 -0
- package/lib/emitter.d.ts +6 -0
- package/lib/emitter.js +12 -0
- package/lib/executor/FlowExecutor.js +48 -7
- package/lib/flow-registry/GlobalFlowRegistry.d.ts +1 -0
- package/lib/flow-registry/GlobalFlowRegistry.js +3 -0
- package/lib/flow-registry/InstanceFlowRegistry.d.ts +1 -0
- package/lib/flow-registry/InstanceFlowRegistry.js +3 -0
- package/lib/flowContext.d.ts +6 -0
- package/lib/flowContext.js +111 -30
- package/lib/flowEngine.d.ts +49 -0
- package/lib/flowEngine.js +265 -10
- package/lib/flowSettings.d.ts +4 -3
- package/lib/flowSettings.js +33 -11
- package/lib/hooks/useApplyAutoFlows.d.ts +1 -0
- package/lib/hooks/useApplyAutoFlows.js +2 -2
- package/lib/index.d.ts +4 -2
- package/lib/index.js +11 -5
- package/lib/locale/de-DE.json +62 -0
- package/lib/locale/en-US.json +57 -45
- package/lib/locale/es-ES.json +62 -0
- package/lib/locale/fr-FR.json +62 -0
- package/lib/locale/hu-HU.json +62 -0
- package/lib/locale/id-ID.json +62 -0
- package/lib/locale/index.d.ts +114 -90
- package/lib/locale/it-IT.json +62 -0
- package/lib/locale/ja-JP.json +62 -0
- package/lib/locale/ko-KR.json +62 -0
- package/lib/locale/nl-NL.json +62 -0
- package/lib/locale/pt-BR.json +62 -0
- package/lib/locale/ru-RU.json +62 -0
- package/lib/locale/tr-TR.json +62 -0
- package/lib/locale/uk-UA.json +62 -0
- package/lib/locale/vi-VN.json +62 -0
- package/lib/locale/zh-CN.json +58 -46
- package/lib/locale/zh-TW.json +62 -0
- package/lib/models/CollectionFieldModel.d.ts +6 -2
- package/lib/models/CollectionFieldModel.js +60 -14
- package/lib/models/flowModel.d.ts +43 -4
- package/lib/models/flowModel.js +128 -26
- package/lib/models/forkFlowModel.d.ts +6 -2
- package/lib/models/forkFlowModel.js +9 -2
- package/lib/provider.d.ts +3 -1
- package/lib/provider.js +4 -3
- package/lib/reactive/index.d.ts +10 -0
- package/lib/reactive/index.js +41 -0
- package/lib/reactive/observer.d.ts +19 -0
- package/lib/reactive/observer.js +109 -0
- package/lib/resources/baseRecordResource.d.ts +1 -0
- package/lib/resources/baseRecordResource.js +14 -3
- package/lib/resources/multiRecordResource.d.ts +4 -2
- package/lib/resources/multiRecordResource.js +15 -6
- package/lib/resources/singleRecordResource.js +6 -3
- package/lib/resources/sqlResource.d.ts +1 -0
- package/lib/resources/sqlResource.js +22 -25
- package/lib/runjs-context/contexts/base.js +42 -6
- package/lib/runjs-context/snippets/global/clipboard-copy-text.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/clipboard-copy-text.snippet.js +61 -0
- package/lib/runjs-context/snippets/index.js +3 -0
- package/lib/runjs-context/snippets/scene/block/render-antd-icons.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-antd-icons.snippet.js +65 -0
- package/lib/runjs-context/snippets/scene/block/render-button-handler.snippet.js +6 -4
- package/lib/runjs-context/snippets/scene/block/render-info-card.snippet.js +15 -16
- package/lib/runjs-context/snippets/scene/block/render-react-jsx.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-react-jsx.snippet.js +58 -0
- package/lib/runjs-context/snippets/scene/block/render-react.snippet.js +7 -7
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.js +24 -29
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.js +20 -21
- package/lib/scheduler/ModelOperationScheduler.d.ts +51 -0
- package/lib/scheduler/ModelOperationScheduler.js +262 -0
- package/lib/types.d.ts +42 -7
- package/lib/types.js +4 -3
- package/lib/utils/associationObjectVariable.d.ts +32 -0
- package/lib/utils/associationObjectVariable.js +157 -0
- package/lib/utils/createCollectionContextMeta.d.ts +1 -1
- package/lib/utils/createCollectionContextMeta.js +8 -4
- package/lib/utils/createEphemeralContext.d.ts +13 -0
- package/lib/utils/createEphemeralContext.js +140 -0
- package/lib/utils/flows.d.ts +10 -0
- package/lib/utils/flows.js +48 -0
- package/lib/utils/index.d.ts +7 -3
- package/lib/utils/index.js +20 -0
- package/lib/utils/jsxTransform.d.ts +15 -0
- package/lib/utils/jsxTransform.js +68 -0
- package/lib/utils/params-resolvers.js +3 -3
- package/lib/utils/parsePathnameToViewParams.d.ts +1 -1
- package/lib/utils/parsePathnameToViewParams.js +41 -5
- package/lib/utils/pruneFilter.d.ts +21 -0
- package/lib/utils/pruneFilter.js +52 -0
- package/lib/utils/safeGlobals.d.ts +5 -3
- package/lib/utils/safeGlobals.js +42 -1
- package/lib/utils/schema-utils.d.ts +6 -0
- package/lib/utils/schema-utils.js +71 -6
- package/lib/utils/serverContextParams.d.ts +3 -0
- package/lib/utils/serverContextParams.js +2 -0
- package/lib/utils/translation.d.ts +4 -1
- package/lib/utils/translation.js +6 -2
- package/lib/utils/variablesParams.d.ts +21 -5
- package/lib/utils/variablesParams.js +103 -34
- package/lib/views/DialogComponent.js +1 -5
- package/lib/views/DrawerComponent.js +18 -9
- package/lib/views/PageComponent.js +3 -4
- package/lib/views/ViewNavigation.d.ts +11 -15
- package/lib/views/ViewNavigation.js +37 -19
- package/lib/views/createViewMeta.d.ts +3 -2
- package/lib/views/createViewMeta.js +164 -53
- package/lib/views/useDialog.d.ts +2 -1
- package/lib/views/useDialog.js +36 -30
- package/lib/views/useDrawer.d.ts +2 -1
- package/lib/views/useDrawer.js +33 -26
- package/lib/views/usePage.d.ts +2 -1
- package/lib/views/usePage.js +40 -29
- package/package.json +6 -3
- package/src/BlockScopedFlowEngine.ts +88 -0
- package/src/JSRunner.ts +3 -0
- package/src/ViewScopedFlowEngine.ts +16 -0
- package/src/__tests__/JSRunner.test.ts +62 -53
- package/src/__tests__/blockScopedFlowEngine.test.ts +154 -0
- package/src/__tests__/createViewMeta.popup.test.ts +142 -0
- package/src/__tests__/flow-engine.test.ts +3 -0
- package/src/__tests__/flowContext.test.ts +70 -0
- package/src/__tests__/flowEngine.destroyModel.test.ts +74 -0
- package/src/__tests__/flowEngine.moveModel.test.ts +43 -0
- package/src/__tests__/flowEngine.removeModel.test.ts +72 -0
- package/src/__tests__/flowEngine.saveModel.test.ts +4 -0
- package/src/__tests__/flowModel.openView.navigation.test.ts +3 -2
- package/src/__tests__/flowSettings.open.test.tsx +2 -0
- package/src/__tests__/flowSettings.test.ts +2 -0
- package/src/__tests__/globalFlowRegistry.test.ts +1 -1
- package/src/__tests__/modelOperationScheduler.test.ts +346 -0
- package/src/__tests__/objectVariable.test.ts +464 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +12 -0
- package/src/__tests__/viewScopedFlowEngine.test.ts +98 -0
- package/src/acl/Acl.tsx +85 -31
- package/src/acl/__tests__/Acl.test.tsx +43 -1
- package/src/components/DynamicFlowsEditor.tsx +0 -10
- package/src/components/FieldModelRenderer.tsx +15 -8
- package/src/components/FieldSkeleton.tsx +27 -0
- package/src/components/FlowContextSelector.tsx +20 -2
- package/src/components/FlowModelRenderer.tsx +46 -12
- package/src/components/FormItem.tsx +8 -1
- package/src/components/MobilePopup.style.ts +220 -0
- package/src/components/MobilePopup.tsx +86 -0
- package/src/components/__tests__/FlowModelRenderer.test.tsx +89 -0
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +1 -1
- package/src/components/common/withFlowDesignMode.tsx +5 -5
- package/src/components/index.ts +1 -0
- package/src/components/settings/independents/dropdown/FlowsDropdownButton.tsx +34 -17
- package/src/components/settings/wrappers/component/SelectWithTitle.tsx +110 -0
- package/src/components/settings/wrappers/component/SwitchWithTitle.tsx +82 -0
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +260 -121
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +34 -18
- package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +56 -18
- package/src/components/settings/wrappers/contextual/StepSettings.tsx +1 -2
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +12 -6
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +565 -0
- package/src/components/settings/wrappers/embedded/FlowSettings.tsx +47 -35
- package/src/components/settings/wrappers/embedded/FlowsSettings.tsx +1 -1
- package/src/components/settings/wrappers/embedded/FlowsSettingsContent.tsx +64 -42
- package/src/components/subModel/AddSubModelButton.tsx +104 -9
- package/src/components/subModel/LazyDropdown.tsx +14 -14
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +168 -7
- package/src/components/subModel/__tests__/utils.test.ts +12 -12
- package/src/components/subModel/utils.ts +25 -6
- package/src/components/variables/VariableInput.tsx +5 -3
- package/src/components/variables/types.ts +2 -0
- package/src/components/variables/utils.ts +7 -3
- package/src/data-source/index.ts +169 -11
- package/src/data-source/jioToJoiSchema.ts +1 -0
- package/src/emitter.ts +14 -0
- package/src/executor/FlowExecutor.ts +56 -8
- package/src/executor/__tests__/ctx-defs-injection.test.ts +197 -0
- package/src/flow-registry/GlobalFlowRegistry.ts +1 -0
- package/src/flow-registry/InstanceFlowRegistry.ts +1 -0
- package/src/flow-registry/__tests__/globalFlowRegistry.test.ts +54 -0
- package/src/flowContext.ts +144 -29
- package/src/flowEngine.ts +328 -8
- package/src/flowSettings.ts +47 -19
- package/src/hooks/useApplyAutoFlows.ts +3 -3
- package/src/index.ts +4 -2
- package/src/locale/de-DE.json +62 -0
- package/src/locale/en-US.json +57 -45
- package/src/locale/es-ES.json +62 -0
- package/src/locale/fr-FR.json +62 -0
- package/src/locale/hu-HU.json +62 -0
- package/src/locale/id-ID.json +62 -0
- package/src/locale/it-IT.json +62 -0
- package/src/locale/ja-JP.json +62 -0
- package/src/locale/ko-KR.json +62 -0
- package/src/locale/nl-NL.json +62 -0
- package/src/locale/pt-BR.json +62 -0
- package/src/locale/ru-RU.json +62 -0
- package/src/locale/tr-TR.json +62 -0
- package/src/locale/uk-UA.json +62 -0
- package/src/locale/vi-VN.json +62 -0
- package/src/locale/zh-CN.json +58 -46
- package/src/locale/zh-TW.json +62 -0
- package/src/models/CollectionFieldModel.tsx +79 -17
- package/src/models/__tests__/dispatchEvent.behavior.test.ts +169 -0
- package/src/models/__tests__/flowEngine.resolveUse.test.ts +170 -0
- package/src/models/__tests__/flowModel.getFlows.sort.test.ts +29 -5
- package/src/models/__tests__/flowModel.scheduleModelOperation.test.tsx +129 -0
- package/src/models/__tests__/flowModel.test.ts +65 -27
- package/src/models/__tests__/forkFlowModel.test.ts +40 -7
- package/src/models/flowModel.tsx +192 -30
- package/src/models/forkFlowModel.ts +11 -3
- package/src/provider.tsx +5 -5
- package/src/reactive/__tests__/observer.test.tsx +211 -0
- package/src/reactive/index.ts +11 -0
- package/src/reactive/observer.tsx +101 -0
- package/src/resources/baseRecordResource.ts +15 -3
- package/src/resources/multiRecordResource.ts +17 -8
- package/src/resources/singleRecordResource.ts +6 -3
- package/src/resources/sqlResource.ts +22 -26
- package/src/runjs-context/contexts/base.ts +47 -6
- package/src/runjs-context/snippets/global/clipboard-copy-text.snippet.ts +42 -0
- package/src/runjs-context/snippets/index.ts +3 -0
- package/src/runjs-context/snippets/scene/block/render-antd-icons.snippet.ts +46 -0
- package/src/runjs-context/snippets/scene/block/render-button-handler.snippet.ts +6 -4
- package/src/runjs-context/snippets/scene/block/render-info-card.snippet.ts +15 -16
- package/src/runjs-context/snippets/scene/block/render-react-jsx.snippet.ts +39 -0
- package/src/runjs-context/snippets/scene/block/render-react.snippet.ts +7 -7
- package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +24 -29
- package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +20 -21
- package/src/scheduler/ModelOperationScheduler.ts +304 -0
- package/src/types.ts +50 -4
- package/src/utils/__tests__/createCollectionContextMeta.test.ts +51 -0
- package/src/utils/__tests__/flows.test.ts +65 -0
- package/src/utils/__tests__/jsxTransform.test.ts +38 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +25 -0
- package/src/utils/__tests__/pruneFilter.test.ts +38 -0
- package/src/utils/__tests__/safeGlobals.test.ts +23 -1
- package/src/utils/__tests__/utils.test.ts +114 -15
- package/src/utils/__tests__/variablesParams.test.ts +120 -0
- package/src/utils/associationObjectVariable.ts +180 -0
- package/src/utils/createCollectionContextMeta.ts +8 -3
- package/src/utils/createEphemeralContext.ts +142 -0
- package/src/utils/flows.ts +23 -0
- package/src/utils/index.ts +11 -2
- package/src/utils/jsxTransform.ts +39 -0
- package/src/utils/params-resolvers.ts +2 -2
- package/src/utils/parsePathnameToViewParams.ts +50 -6
- package/src/utils/pruneFilter.ts +41 -0
- package/src/utils/safeGlobals.ts +51 -4
- package/src/utils/schema-utils.ts +81 -3
- package/src/utils/serverContextParams.ts +5 -0
- package/src/utils/translation.ts +7 -2
- package/src/utils/variablesParams.ts +125 -42
- package/src/views/DialogComponent.tsx +1 -4
- package/src/views/DrawerComponent.tsx +19 -7
- package/src/views/PageComponent.tsx +2 -4
- package/src/views/ViewNavigation.ts +49 -43
- package/src/views/__tests__/FlowView.usePage.test.tsx +133 -0
- package/src/views/__tests__/ViewNavigation.test.ts +54 -34
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +132 -0
- package/src/views/createViewMeta.ts +179 -42
- package/src/views/useDialog.tsx +36 -24
- package/src/views/useDrawer.tsx +37 -24
- package/src/views/usePage.tsx +46 -27
|
@@ -11,15 +11,37 @@ import { Emitter } from '../emitter';
|
|
|
11
11
|
import { InstanceFlowRegistry } from '../flow-registry/InstanceFlowRegistry';
|
|
12
12
|
import { FlowContext, FlowModelContext, FlowRuntimeContext } from '../flowContext';
|
|
13
13
|
import { FlowEngine } from '../flowEngine';
|
|
14
|
-
import type { ActionDefinition, ArrayElementType, CreateModelOptions, CreateSubModelOptions, DefaultStructure, FlowDefinitionOptions, FlowModelMeta, FlowModelOptions, ModelConstructor, ParamObject, ParentFlowModel, PersistOptions, StepParams } from '../types';
|
|
14
|
+
import type { ActionDefinition, ArrayElementType, CreateModelOptions, CreateSubModelOptions, DefaultStructure, FlowDefinitionOptions, FlowModelMeta, FlowModelOptions, ModelConstructor, ParamObject, ParentFlowModel, PersistOptions, ResolveUseResult, StepParams } from '../types';
|
|
15
15
|
import { IModelComponentProps, ReadonlyModelProps } from '../types';
|
|
16
16
|
import { ModelActionRegistry } from '../action-registry/ModelActionRegistry';
|
|
17
17
|
import { ModelEventRegistry } from '../event-registry/ModelEventRegistry';
|
|
18
18
|
import { GlobalFlowRegistry } from '../flow-registry/GlobalFlowRegistry';
|
|
19
19
|
import { FlowDefinition } from '../FlowDefinition';
|
|
20
20
|
import { FlowSettingsOpenOptions } from '../flowSettings';
|
|
21
|
-
import type {
|
|
21
|
+
import type { ScheduleOptions } from '../scheduler/ModelOperationScheduler';
|
|
22
|
+
import type { DispatchEventOptions, EventDefinition } from '../types';
|
|
22
23
|
import { ForkFlowModel } from './forkFlowModel';
|
|
24
|
+
import type { MenuProps } from 'antd';
|
|
25
|
+
type BaseMenuItem = NonNullable<MenuProps['items']>[number];
|
|
26
|
+
type MenuLeafItem = Exclude<BaseMenuItem, {
|
|
27
|
+
children: MenuProps['items'];
|
|
28
|
+
}>;
|
|
29
|
+
export type FlowModelExtraMenuItem = Omit<MenuLeafItem, 'key'> & {
|
|
30
|
+
key: React.Key;
|
|
31
|
+
group?: string;
|
|
32
|
+
sort?: number;
|
|
33
|
+
onClick?: () => void;
|
|
34
|
+
};
|
|
35
|
+
type FlowModelExtraMenuItemInput = Omit<FlowModelExtraMenuItem, 'key'> & {
|
|
36
|
+
key?: React.Key;
|
|
37
|
+
};
|
|
38
|
+
type ExtraMenuItemEntry = {
|
|
39
|
+
group?: string;
|
|
40
|
+
sort?: number;
|
|
41
|
+
matcher?: (model: FlowModel) => boolean;
|
|
42
|
+
keyPrefix?: string;
|
|
43
|
+
items: FlowModelExtraMenuItemInput[] | ((model: FlowModel, t: (k: string, opt?: any) => string) => FlowModelExtraMenuItemInput[] | Promise<FlowModelExtraMenuItemInput[]>);
|
|
44
|
+
};
|
|
23
45
|
export declare enum ModelRenderMode {
|
|
24
46
|
ReactElement = "reactElement",
|
|
25
47
|
RenderFunction = "renderFunction"
|
|
@@ -27,7 +49,7 @@ export declare enum ModelRenderMode {
|
|
|
27
49
|
export declare class FlowModel<Structure extends DefaultStructure = DefaultStructure> {
|
|
28
50
|
#private;
|
|
29
51
|
/**
|
|
30
|
-
* 当
|
|
52
|
+
* 当 flowSettingsEnabled 且 model.hidden 为 true 时用于渲染设置态组件(实例方法,子类可覆盖)。
|
|
31
53
|
* 基类默认仅返回一个透明度降低的占位元素
|
|
32
54
|
*/
|
|
33
55
|
protected renderHiddenInConfig(): React.ReactNode | undefined;
|
|
@@ -41,7 +63,10 @@ export declare class FlowModel<Structure extends DefaultStructure = DefaultStruc
|
|
|
41
63
|
subModels: Structure['subModels'];
|
|
42
64
|
private _options;
|
|
43
65
|
protected _title: string;
|
|
66
|
+
protected _extraTitle: string;
|
|
44
67
|
isNew: boolean;
|
|
68
|
+
skeleton: any;
|
|
69
|
+
forbidden: any;
|
|
45
70
|
/**
|
|
46
71
|
* 所有 fork 实例的引用集合。
|
|
47
72
|
* 使用 Set 便于在销毁时主动遍历并调用 dispose,避免悬挂引用。
|
|
@@ -61,6 +86,7 @@ export declare class FlowModel<Structure extends DefaultStructure = DefaultStruc
|
|
|
61
86
|
* 原始 render 方法的引用
|
|
62
87
|
*/
|
|
63
88
|
private _originalRender;
|
|
89
|
+
protected renderOriginal(): React.ReactNode;
|
|
64
90
|
/**
|
|
65
91
|
* 缓存的响应式包装器组件(每个实例一个)
|
|
66
92
|
*/
|
|
@@ -90,10 +116,16 @@ export declare class FlowModel<Structure extends DefaultStructure = DefaultStruc
|
|
|
90
116
|
get subType(): "object" | "array";
|
|
91
117
|
get reactView(): import("../ReactView").ReactView;
|
|
92
118
|
get parentId(): string;
|
|
119
|
+
scheduleModelOperation(toUid: string, fn: (model: FlowModel) => Promise<void> | void, options?: ScheduleOptions): import("../scheduler/ModelOperationScheduler").ScheduledCancel;
|
|
93
120
|
static get meta(): FlowModelMeta;
|
|
94
121
|
static get globalFlowRegistry(): GlobalFlowRegistry;
|
|
95
122
|
protected static get actionRegistry(): ModelActionRegistry;
|
|
96
123
|
protected static get eventRegistry(): ModelEventRegistry;
|
|
124
|
+
/**
|
|
125
|
+
* 动态解析实际要实例化的模型类;可在子类中覆盖。
|
|
126
|
+
* 返回注册名或构造器,支持在 FlowEngine 中继续沿链解析。
|
|
127
|
+
*/
|
|
128
|
+
static resolveUse?(options: CreateModelOptions, engine: FlowEngine, parent?: FlowModel): ResolveUseResult | void;
|
|
97
129
|
/**
|
|
98
130
|
* 注册仅当前 FlowModel 类及其子类可用的 Action。
|
|
99
131
|
* 该注册是类级别的,不会影响全局(FlowEngine)的 Action 注册。
|
|
@@ -112,9 +144,11 @@ export declare class FlowModel<Structure extends DefaultStructure = DefaultStruc
|
|
|
112
144
|
* 批量注册仅当前 FlowModel 类及其子类可用的 Events。
|
|
113
145
|
*/
|
|
114
146
|
static registerEvents<TModel extends FlowModel = FlowModel>(events: Record<string, EventDefinition<TModel>>): void;
|
|
115
|
-
static buildChildrenFromModels(ctx: any, Models: Array<any>): import("..").SubModelItem[]
|
|
147
|
+
static buildChildrenFromModels(ctx: any, Models: Array<any>): Promise<import("..").SubModelItem[]>;
|
|
116
148
|
get title(): any;
|
|
149
|
+
get extraTitle(): any;
|
|
117
150
|
setTitle(value: string): void;
|
|
151
|
+
setExtraTitle(value: string): void;
|
|
118
152
|
setHidden(value: boolean): void;
|
|
119
153
|
_createSubModels(subModels: Record<string, CreateSubModelOptions | CreateSubModelOptions[]>): void;
|
|
120
154
|
/**
|
|
@@ -333,6 +367,10 @@ export declare class FlowModel<Structure extends DefaultStructure = DefaultStruc
|
|
|
333
367
|
* @returns A promise that resolves when the flow settings dialog is opened
|
|
334
368
|
*/
|
|
335
369
|
openFlowSettings(options?: Omit<FlowSettingsOpenOptions, 'model'>): Promise<boolean>;
|
|
370
|
+
/** 注册设置菜单的额外项(静态,按类缓存,可继承合并) */
|
|
371
|
+
static registerExtraMenuItems(opts: ExtraMenuItemEntry | ((model: FlowModel, t: (k: string, opt?: any) => string) => FlowModelExtraMenuItemInput[] | Promise<FlowModelExtraMenuItemInput[]>)): () => void;
|
|
372
|
+
static getExtraMenuItems(model: FlowModel, t: (k: string, opt?: any) => string): Promise<FlowModelExtraMenuItem[]>;
|
|
373
|
+
refresh(): Promise<void>;
|
|
336
374
|
}
|
|
337
375
|
export declare class ErrorFlowModel extends FlowModel {
|
|
338
376
|
errorMessage: string;
|
|
@@ -340,3 +378,4 @@ export declare class ErrorFlowModel extends FlowModel {
|
|
|
340
378
|
render(): React.JSX.Element;
|
|
341
379
|
}
|
|
342
380
|
export declare function defineFlow<TModel extends FlowModel = FlowModel>(definition: FlowDefinitionOptions): FlowDefinitionOptions<TModel>;
|
|
381
|
+
export {};
|
package/lib/models/flowModel.js
CHANGED
|
@@ -53,7 +53,6 @@ __export(flowModel_exports, {
|
|
|
53
53
|
});
|
|
54
54
|
module.exports = __toCommonJS(flowModel_exports);
|
|
55
55
|
var import_reactive = require("@formily/reactive");
|
|
56
|
-
var import_reactive_react = require("@formily/reactive-react");
|
|
57
56
|
var import_lodash = __toESM(require("lodash"));
|
|
58
57
|
var import_react = __toESM(require("react"));
|
|
59
58
|
var import_secure = require("uid/secure");
|
|
@@ -69,11 +68,13 @@ var import_utils2 = require("../components/subModel/utils");
|
|
|
69
68
|
var import_ModelEventRegistry = require("../event-registry/ModelEventRegistry");
|
|
70
69
|
var import_GlobalFlowRegistry = require("../flow-registry/GlobalFlowRegistry");
|
|
71
70
|
var import_forkFlowModel = require("./forkFlowModel");
|
|
71
|
+
var import__ = require("..");
|
|
72
72
|
var _flowContext;
|
|
73
73
|
const classActionRegistries = /* @__PURE__ */ new WeakMap();
|
|
74
74
|
const classEventRegistries = /* @__PURE__ */ new WeakMap();
|
|
75
75
|
const modelMetas = /* @__PURE__ */ new WeakMap();
|
|
76
76
|
const modelGlobalRegistries = /* @__PURE__ */ new WeakMap();
|
|
77
|
+
const classMenuExtensions = /* @__PURE__ */ new WeakMap();
|
|
77
78
|
var ModelRenderMode = /* @__PURE__ */ ((ModelRenderMode2) => {
|
|
78
79
|
ModelRenderMode2["ReactElement"] = "reactElement";
|
|
79
80
|
ModelRenderMode2["RenderFunction"] = "renderFunction";
|
|
@@ -91,8 +92,11 @@ const _FlowModel = class _FlowModel {
|
|
|
91
92
|
__publicField(this, "subModels");
|
|
92
93
|
__publicField(this, "_options");
|
|
93
94
|
__publicField(this, "_title");
|
|
95
|
+
__publicField(this, "_extraTitle");
|
|
94
96
|
__publicField(this, "isNew", false);
|
|
95
97
|
// 标记是否为新建状态
|
|
98
|
+
__publicField(this, "skeleton", null);
|
|
99
|
+
__publicField(this, "forbidden", null);
|
|
96
100
|
/**
|
|
97
101
|
* 所有 fork 实例的引用集合。
|
|
98
102
|
* 使用 Set 便于在销毁时主动遍历并调用 dispose,避免悬挂引用。
|
|
@@ -120,10 +124,11 @@ const _FlowModel = class _FlowModel {
|
|
|
120
124
|
__publicField(this, "flowRegistry");
|
|
121
125
|
__publicField(this, "_cleanRun");
|
|
122
126
|
__publicField(this, "_dispatchEventWithDebounce", import_lodash.default.debounce(
|
|
123
|
-
async (eventName, inputArgs, options)
|
|
127
|
+
async function(eventName, inputArgs, options) {
|
|
124
128
|
return this._dispatchEvent(eventName, inputArgs, options);
|
|
125
129
|
},
|
|
126
|
-
|
|
130
|
+
500,
|
|
131
|
+
{ leading: true }
|
|
127
132
|
));
|
|
128
133
|
/**
|
|
129
134
|
* 重新执行上一次的 beforeRender,保持参数一致
|
|
@@ -158,11 +163,15 @@ const _FlowModel = class _FlowModel {
|
|
|
158
163
|
this.subModels = {};
|
|
159
164
|
this.sortIndex = options.sortIndex || 0;
|
|
160
165
|
this._options = options;
|
|
166
|
+
this._title = "";
|
|
167
|
+
this._extraTitle = "";
|
|
161
168
|
(0, import_reactive.define)(this, {
|
|
162
169
|
hidden: import_reactive.observable,
|
|
163
170
|
props: import_reactive.observable,
|
|
164
171
|
subModels: import_reactive.observable.shallow,
|
|
165
172
|
stepParams: import_reactive.observable,
|
|
173
|
+
_title: import_reactive.observable,
|
|
174
|
+
_extraTitle: import_reactive.observable,
|
|
166
175
|
// setProps: action,
|
|
167
176
|
setProps: import_reactive.batch,
|
|
168
177
|
// setStepParams: action,
|
|
@@ -193,13 +202,16 @@ const _FlowModel = class _FlowModel {
|
|
|
193
202
|
this._cleanRun = !!options["cleanRun"];
|
|
194
203
|
}
|
|
195
204
|
/**
|
|
196
|
-
* 当
|
|
205
|
+
* 当 flowSettingsEnabled 且 model.hidden 为 true 时用于渲染设置态组件(实例方法,子类可覆盖)。
|
|
197
206
|
* 基类默认仅返回一个透明度降低的占位元素
|
|
198
207
|
*/
|
|
199
208
|
renderHiddenInConfig() {
|
|
200
209
|
var _a;
|
|
201
210
|
return /* @__PURE__ */ import_react.default.createElement("span", { style: { opacity: 0.5 } }, ((_a = this.translate) == null ? void 0 : _a.call(this, "Hidden")) || "Hidden");
|
|
202
211
|
}
|
|
212
|
+
renderOriginal() {
|
|
213
|
+
return this._originalRender();
|
|
214
|
+
}
|
|
203
215
|
/**
|
|
204
216
|
* 对外暴露的上下文:
|
|
205
217
|
*/
|
|
@@ -237,6 +249,10 @@ const _FlowModel = class _FlowModel {
|
|
|
237
249
|
get parentId() {
|
|
238
250
|
return this._options.parentId;
|
|
239
251
|
}
|
|
252
|
+
scheduleModelOperation(toUid, fn, options) {
|
|
253
|
+
var _a;
|
|
254
|
+
return (_a = this.flowEngine) == null ? void 0 : _a.scheduleModelOperation(this, toUid, fn, options);
|
|
255
|
+
}
|
|
240
256
|
static get meta() {
|
|
241
257
|
return modelMetas.get(this);
|
|
242
258
|
}
|
|
@@ -311,16 +327,22 @@ const _FlowModel = class _FlowModel {
|
|
|
311
327
|
static registerEvents(events) {
|
|
312
328
|
this.eventRegistry.registerEvents(events);
|
|
313
329
|
}
|
|
314
|
-
static buildChildrenFromModels(ctx, Models) {
|
|
315
|
-
return Models.map((M) => (0, import_utils2.buildSubModelItem)(M, ctx, true));
|
|
330
|
+
static async buildChildrenFromModels(ctx, Models) {
|
|
331
|
+
return Promise.all(Models.map((M) => (0, import_utils2.buildSubModelItem)(M, ctx, true)));
|
|
316
332
|
}
|
|
317
333
|
get title() {
|
|
318
334
|
var _a;
|
|
319
335
|
return this.translate(this._title) || this.translate((_a = this.constructor["meta"]) == null ? void 0 : _a.label);
|
|
320
336
|
}
|
|
337
|
+
get extraTitle() {
|
|
338
|
+
return this._extraTitle ? this.translate(this._extraTitle) : "";
|
|
339
|
+
}
|
|
321
340
|
setTitle(value) {
|
|
322
341
|
this._title = value;
|
|
323
342
|
}
|
|
343
|
+
setExtraTitle(value) {
|
|
344
|
+
this._extraTitle = value || "";
|
|
345
|
+
}
|
|
324
346
|
setHidden(value) {
|
|
325
347
|
this.hidden = !!value;
|
|
326
348
|
}
|
|
@@ -527,14 +549,15 @@ const _FlowModel = class _FlowModel {
|
|
|
527
549
|
const instanceKeys = new Set(instanceFlows.keys());
|
|
528
550
|
const staticEntries = Array.from(staticFlows.entries()).filter(([key]) => !instanceKeys.has(key));
|
|
529
551
|
const instanceEntries = Array.from(instanceFlows.entries());
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
const sa = a.sort ?? 0;
|
|
533
|
-
const sb = b.sort ?? 0;
|
|
552
|
+
const instanceEntriesWithIndex = instanceEntries.map((e, i) => ({ e, i }));
|
|
553
|
+
instanceEntriesWithIndex.sort((a, b) => {
|
|
554
|
+
const sa = a.e[1].sort ?? 0;
|
|
555
|
+
const sb = b.e[1].sort ?? 0;
|
|
534
556
|
if (sa !== sb) return sa - sb;
|
|
535
|
-
return
|
|
557
|
+
return a.i - b.i;
|
|
536
558
|
});
|
|
537
|
-
|
|
559
|
+
const merged = [...instanceEntriesWithIndex.map(({ e }) => e), ...staticEntries];
|
|
560
|
+
return new Map(merged);
|
|
538
561
|
}
|
|
539
562
|
setProps(props, value) {
|
|
540
563
|
if (typeof props === "string") {
|
|
@@ -567,6 +590,7 @@ const _FlowModel = class _FlowModel {
|
|
|
567
590
|
}
|
|
568
591
|
}
|
|
569
592
|
}
|
|
593
|
+
this.emitter.emit("onStepParamsChanged");
|
|
570
594
|
}
|
|
571
595
|
getStepParams(flowKey, stepKey) {
|
|
572
596
|
var _a;
|
|
@@ -606,7 +630,7 @@ const _FlowModel = class _FlowModel {
|
|
|
606
630
|
}
|
|
607
631
|
async dispatchEvent(eventName, inputArgs, options) {
|
|
608
632
|
const isBeforeRender = eventName === "beforeRender";
|
|
609
|
-
const defaults = isBeforeRender ? { sequential: true, useCache: true } : {};
|
|
633
|
+
const defaults = isBeforeRender ? { sequential: true, useCache: true } : { sequential: true };
|
|
610
634
|
const execOptions = {
|
|
611
635
|
sequential: (options == null ? void 0 : options.sequential) ?? defaults.sequential,
|
|
612
636
|
useCache: (options == null ? void 0 : options.useCache) ?? defaults.useCache
|
|
@@ -692,11 +716,11 @@ const _FlowModel = class _FlowModel {
|
|
|
692
716
|
}
|
|
693
717
|
if (this.shouldSkipReactiveWrapping()) {
|
|
694
718
|
const wrappedNonReactive = /* @__PURE__ */ __name(function() {
|
|
695
|
-
var _a, _b
|
|
696
|
-
const isConfigMode = !!((
|
|
719
|
+
var _a, _b;
|
|
720
|
+
const isConfigMode = !!((_a = this == null ? void 0 : this.context) == null ? void 0 : _a.flowSettingsEnabled);
|
|
697
721
|
if (this.hidden) {
|
|
698
722
|
if (!isConfigMode) return null;
|
|
699
|
-
const rendered = (
|
|
723
|
+
const rendered = (_b = this.renderHiddenInConfig) == null ? void 0 : _b.call(this);
|
|
700
724
|
const Cls = this.constructor;
|
|
701
725
|
const returnsFunction = Cls.renderMode === "renderFunction" /* RenderFunction */;
|
|
702
726
|
return returnsFunction ? typeof rendered === "function" ? rendered : () => rendered : rendered;
|
|
@@ -708,8 +732,8 @@ const _FlowModel = class _FlowModel {
|
|
|
708
732
|
return;
|
|
709
733
|
}
|
|
710
734
|
const createReactiveWrapper = /* @__PURE__ */ __name((modelInstance) => {
|
|
711
|
-
const ReactiveWrapper = (0,
|
|
712
|
-
var _a, _b
|
|
735
|
+
const ReactiveWrapper = (0, import__.observer)(() => {
|
|
736
|
+
var _a, _b;
|
|
713
737
|
const renderTarget = modelInstance;
|
|
714
738
|
if (renderTarget !== modelInstance && (renderTarget == null ? void 0 : renderTarget.localProps) !== void 0) {
|
|
715
739
|
renderTarget.localProps;
|
|
@@ -718,21 +742,31 @@ const _FlowModel = class _FlowModel {
|
|
|
718
742
|
modelInstance.props;
|
|
719
743
|
}
|
|
720
744
|
import_react.default.useEffect(() => {
|
|
745
|
+
var _a2, _b2;
|
|
721
746
|
if (typeof renderTarget.onMount === "function") {
|
|
722
747
|
renderTarget.onMount();
|
|
723
748
|
}
|
|
749
|
+
void ((_b2 = (_a2 = renderTarget.flowEngine) == null ? void 0 : _a2.emitter) == null ? void 0 : _b2.emitAsync("model:mounted", {
|
|
750
|
+
uid: renderTarget.uid,
|
|
751
|
+
model: renderTarget
|
|
752
|
+
}));
|
|
724
753
|
return () => {
|
|
754
|
+
var _a3, _b3;
|
|
725
755
|
if (typeof renderTarget.onUnmount === "function") {
|
|
726
756
|
renderTarget.onUnmount();
|
|
727
757
|
}
|
|
758
|
+
void ((_b3 = (_a3 = renderTarget.flowEngine) == null ? void 0 : _a3.emitter) == null ? void 0 : _b3.emitAsync("model:unmounted", {
|
|
759
|
+
uid: renderTarget.uid,
|
|
760
|
+
model: renderTarget
|
|
761
|
+
}));
|
|
728
762
|
};
|
|
729
763
|
}, [renderTarget]);
|
|
730
|
-
const isConfigMode = !!((
|
|
764
|
+
const isConfigMode = !!((_a = modelInstance == null ? void 0 : modelInstance.context) == null ? void 0 : _a.flowSettingsEnabled);
|
|
731
765
|
if (modelInstance.hidden) {
|
|
732
766
|
if (!isConfigMode) {
|
|
733
767
|
return null;
|
|
734
768
|
}
|
|
735
|
-
return (
|
|
769
|
+
return (_b = modelInstance.renderHiddenInConfig) == null ? void 0 : _b.call(modelInstance);
|
|
736
770
|
}
|
|
737
771
|
modelInstance.stepParams;
|
|
738
772
|
return originalRender.call(renderTarget);
|
|
@@ -812,7 +846,7 @@ const _FlowModel = class _FlowModel {
|
|
|
812
846
|
this.context.removeDelegate(this.parent.context);
|
|
813
847
|
}
|
|
814
848
|
addSubModel(subKey, options) {
|
|
815
|
-
var _a;
|
|
849
|
+
var _a, _b, _c;
|
|
816
850
|
const actualParent = this["master"] || this;
|
|
817
851
|
let model;
|
|
818
852
|
if (options instanceof _FlowModel) {
|
|
@@ -839,10 +873,16 @@ const _FlowModel = class _FlowModel {
|
|
|
839
873
|
model.sortIndex = maxSortIndex + 1;
|
|
840
874
|
subModels[subKey].push(model);
|
|
841
875
|
actualParent.emitter.emit("onSubModelAdded", model);
|
|
876
|
+
(_c = (_b = actualParent.flowEngine) == null ? void 0 : _b.emitter) == null ? void 0 : _c.emit("model:subModel:added", {
|
|
877
|
+
parentUid: actualParent.uid,
|
|
878
|
+
parent: actualParent,
|
|
879
|
+
subKey,
|
|
880
|
+
model
|
|
881
|
+
});
|
|
842
882
|
return model;
|
|
843
883
|
}
|
|
844
884
|
setSubModel(subKey, options) {
|
|
845
|
-
var _a;
|
|
885
|
+
var _a, _b, _c;
|
|
846
886
|
const actualParent = this["master"] || this;
|
|
847
887
|
let model;
|
|
848
888
|
if (options instanceof _FlowModel) {
|
|
@@ -863,6 +903,12 @@ const _FlowModel = class _FlowModel {
|
|
|
863
903
|
model.setParent(actualParent);
|
|
864
904
|
actualParent.subModels[subKey] = model;
|
|
865
905
|
actualParent.emitter.emit("onSubModelAdded", model);
|
|
906
|
+
(_c = (_b = actualParent.flowEngine) == null ? void 0 : _b.emitter) == null ? void 0 : _c.emit("model:subModel:added", {
|
|
907
|
+
parentUid: actualParent.uid,
|
|
908
|
+
parent: actualParent,
|
|
909
|
+
subKey,
|
|
910
|
+
model
|
|
911
|
+
});
|
|
866
912
|
return model;
|
|
867
913
|
}
|
|
868
914
|
filterSubModels(subKey, callback) {
|
|
@@ -934,7 +980,7 @@ const _FlowModel = class _FlowModel {
|
|
|
934
980
|
return cachedFork;
|
|
935
981
|
}
|
|
936
982
|
}
|
|
937
|
-
const forkId =
|
|
983
|
+
const forkId = (0, import_secure.uid)();
|
|
938
984
|
const fork = new import_forkFlowModel.ForkFlowModel(this, localProps, forkId);
|
|
939
985
|
if ((options == null ? void 0 : options.register) !== false) {
|
|
940
986
|
this.forks.add(fork);
|
|
@@ -1053,7 +1099,8 @@ const _FlowModel = class _FlowModel {
|
|
|
1053
1099
|
uid: this.uid,
|
|
1054
1100
|
...import_lodash.default.omit(this._options, ["flowEngine"]),
|
|
1055
1101
|
stepParams: this.stepParams,
|
|
1056
|
-
sortIndex: this.sortIndex
|
|
1102
|
+
sortIndex: this.sortIndex,
|
|
1103
|
+
flowRegistry: {}
|
|
1057
1104
|
};
|
|
1058
1105
|
const subModels = this.subModels;
|
|
1059
1106
|
for (const subModelKey in subModels) {
|
|
@@ -1068,8 +1115,7 @@ const _FlowModel = class _FlowModel {
|
|
|
1068
1115
|
}
|
|
1069
1116
|
}
|
|
1070
1117
|
for (const [key, flow] of this.flowRegistry.getFlows()) {
|
|
1071
|
-
data[
|
|
1072
|
-
data["flowRegistry"][key] = flow.toData();
|
|
1118
|
+
data.flowRegistry[key] = flow.toData();
|
|
1073
1119
|
}
|
|
1074
1120
|
return data;
|
|
1075
1121
|
}
|
|
@@ -1084,6 +1130,62 @@ const _FlowModel = class _FlowModel {
|
|
|
1084
1130
|
...options
|
|
1085
1131
|
});
|
|
1086
1132
|
}
|
|
1133
|
+
/** 注册设置菜单的额外项(静态,按类缓存,可继承合并) */
|
|
1134
|
+
static registerExtraMenuItems(opts) {
|
|
1135
|
+
const ModelClass = this;
|
|
1136
|
+
const registry = classMenuExtensions.get(ModelClass) || /* @__PURE__ */ new Set();
|
|
1137
|
+
let entry;
|
|
1138
|
+
if (typeof opts === "function") {
|
|
1139
|
+
entry = { items: opts };
|
|
1140
|
+
} else {
|
|
1141
|
+
entry = opts;
|
|
1142
|
+
}
|
|
1143
|
+
registry.add(entry);
|
|
1144
|
+
classMenuExtensions.set(ModelClass, registry);
|
|
1145
|
+
return () => {
|
|
1146
|
+
const reg = classMenuExtensions.get(ModelClass);
|
|
1147
|
+
reg == null ? void 0 : reg.delete(entry);
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
static async getExtraMenuItems(model, t) {
|
|
1151
|
+
const ModelClass = this;
|
|
1152
|
+
const collected = [];
|
|
1153
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1154
|
+
const walk = /* @__PURE__ */ __name(async (Cls) => {
|
|
1155
|
+
if (!Cls || seen.has(Cls)) return;
|
|
1156
|
+
seen.add(Cls);
|
|
1157
|
+
const reg = classMenuExtensions.get(Cls);
|
|
1158
|
+
if (reg) {
|
|
1159
|
+
for (const entry of reg) {
|
|
1160
|
+
if (entry.matcher && !entry.matcher(model)) continue;
|
|
1161
|
+
const items = typeof entry.items === "function" ? await entry.items(model, t) : await Promise.resolve(entry.items || []);
|
|
1162
|
+
const group = entry.group || "common-actions";
|
|
1163
|
+
const sort = entry.sort ?? 0;
|
|
1164
|
+
const prefix = entry.keyPrefix || Cls.name || "extra";
|
|
1165
|
+
(items || []).forEach((it, idx) => {
|
|
1166
|
+
if (!it) return;
|
|
1167
|
+
const key = it.key ?? `${prefix}-${group}-${idx}-${Math.random().toString(36).slice(2, 6)}`;
|
|
1168
|
+
collected.push({
|
|
1169
|
+
...it,
|
|
1170
|
+
key,
|
|
1171
|
+
group: it.group || group,
|
|
1172
|
+
sort: typeof it.sort === "number" ? it.sort : sort
|
|
1173
|
+
});
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
const ParentClass = Object.getPrototypeOf(Cls);
|
|
1178
|
+
const isFlowModelCtor = ParentClass === _FlowModel || (ParentClass == null ? void 0 : ParentClass.prototype) instanceof _FlowModel;
|
|
1179
|
+
if (isFlowModelCtor) {
|
|
1180
|
+
await walk(ParentClass);
|
|
1181
|
+
}
|
|
1182
|
+
}, "walk");
|
|
1183
|
+
await walk(ModelClass);
|
|
1184
|
+
return collected;
|
|
1185
|
+
}
|
|
1186
|
+
refresh() {
|
|
1187
|
+
return this.rerender();
|
|
1188
|
+
}
|
|
1087
1189
|
// =============================
|
|
1088
1190
|
// Dynamic flows (disabled)
|
|
1089
1191
|
// The following APIs are kept as comments to preserve context
|
|
@@ -31,7 +31,7 @@ export declare class ForkFlowModel<TMaster extends FlowModel = FlowModel> {
|
|
|
31
31
|
/** 是否已被释放 */
|
|
32
32
|
private disposed;
|
|
33
33
|
/** fork 在 master.forks 中的索引 */
|
|
34
|
-
readonly forkId:
|
|
34
|
+
readonly forkId: string;
|
|
35
35
|
/** 需要与 master 共享的属性列表 */
|
|
36
36
|
private static readonly SHARED_PROPERTIES;
|
|
37
37
|
/**
|
|
@@ -48,7 +48,7 @@ export declare class ForkFlowModel<TMaster extends FlowModel = FlowModel> {
|
|
|
48
48
|
* 注意:此属性通过 Proxy 在 get/set 陷阱中被动态访问,IDE 可能无法检测到使用, 切勿删除!
|
|
49
49
|
*/
|
|
50
50
|
private localProperties;
|
|
51
|
-
constructor(master: TMaster, initialProps?: IModelComponentProps, forkId?:
|
|
51
|
+
constructor(master: TMaster, initialProps?: IModelComponentProps, forkId?: string);
|
|
52
52
|
get context(): FlowModelContext;
|
|
53
53
|
/**
|
|
54
54
|
* 获取对象及其原型链上的属性描述符
|
|
@@ -58,6 +58,10 @@ export declare class ForkFlowModel<TMaster extends FlowModel = FlowModel> {
|
|
|
58
58
|
* 修改局部 props,仅影响当前 fork
|
|
59
59
|
*/
|
|
60
60
|
setProps(key: string | IModelComponentProps, value?: any): void;
|
|
61
|
+
/**
|
|
62
|
+
* 清理局部 props,仅影响当前 fork
|
|
63
|
+
*/
|
|
64
|
+
clearProps(): {};
|
|
61
65
|
/**
|
|
62
66
|
* render 依旧使用 master 的方法,但合并后的 props 需要透传
|
|
63
67
|
*/
|
|
@@ -38,9 +38,10 @@ __export(forkFlowModel_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(forkFlowModel_exports);
|
|
39
39
|
var import_reactive = require("@formily/reactive");
|
|
40
40
|
var import_flowContext = require("../flowContext");
|
|
41
|
+
var import_secure = require("uid/secure");
|
|
41
42
|
var _flowContext;
|
|
42
43
|
const _ForkFlowModel = class _ForkFlowModel {
|
|
43
|
-
constructor(master, initialProps = {}, forkId
|
|
44
|
+
constructor(master, initialProps = {}, forkId) {
|
|
44
45
|
/** 与 master 相同的 UID,用于日志调试 */
|
|
45
46
|
__publicField(this, "uid");
|
|
46
47
|
/** 调试标识,便于在日志或断言中快速识别 */
|
|
@@ -64,7 +65,7 @@ const _ForkFlowModel = class _ForkFlowModel {
|
|
|
64
65
|
this.master = master;
|
|
65
66
|
this.uid = master.uid;
|
|
66
67
|
this.localProps = { ...initialProps };
|
|
67
|
-
this.forkId = forkId;
|
|
68
|
+
this.forkId = forkId || (0, import_secure.uid)();
|
|
68
69
|
this.hidden = this.master.hidden;
|
|
69
70
|
(0, import_reactive.define)(this, {
|
|
70
71
|
localProps: import_reactive.observable,
|
|
@@ -178,6 +179,12 @@ const _ForkFlowModel = class _ForkFlowModel {
|
|
|
178
179
|
this.localProps = { ...this.localProps, ...key };
|
|
179
180
|
}
|
|
180
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* 清理局部 props,仅影响当前 fork
|
|
184
|
+
*/
|
|
185
|
+
clearProps() {
|
|
186
|
+
return this.localProps = {};
|
|
187
|
+
}
|
|
181
188
|
/**
|
|
182
189
|
* render 依旧使用 master 的方法,但合并后的 props 需要透传
|
|
183
190
|
*/
|
package/lib/provider.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export declare const FlowEngineProvider: React.FC<FlowEngineProviderProps>;
|
|
|
17
17
|
export declare const FlowEngineGlobalsContextProvider: React.FC<{
|
|
18
18
|
children: React.ReactNode;
|
|
19
19
|
}>;
|
|
20
|
-
export declare const useFlowEngine: (
|
|
20
|
+
export declare const useFlowEngine: ({ throwError }?: {
|
|
21
|
+
throwError?: boolean;
|
|
22
|
+
}) => FlowEngine;
|
|
21
23
|
export declare const useFlowEngineContext: () => FlowEngineContext;
|
|
22
24
|
export {};
|
package/lib/provider.js
CHANGED
|
@@ -58,6 +58,7 @@ const FlowEngineProvider = import_react.default.memo((props) => {
|
|
|
58
58
|
});
|
|
59
59
|
FlowEngineProvider.displayName = "FlowEngineProvider";
|
|
60
60
|
const FlowEngineGlobalsContextProvider = /* @__PURE__ */ __name(({ children }) => {
|
|
61
|
+
var _a;
|
|
61
62
|
const { modal, message, notification } = import_antd.App.useApp();
|
|
62
63
|
const [drawer, contextHolder] = (0, import_views.useDrawer)();
|
|
63
64
|
const [embed, pageContextHolder] = (0, import_views.usePage)();
|
|
@@ -91,11 +92,11 @@ const FlowEngineGlobalsContextProvider = /* @__PURE__ */ __name(({ children }) =
|
|
|
91
92
|
}
|
|
92
93
|
engine.reactView.refresh();
|
|
93
94
|
}, [engine, drawer, modal, message, notification, config, popover, token, dialog, embed]);
|
|
94
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
95
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd.ConfigProvider, { ...config, locale: (_a = engine.context.locales) == null ? void 0 : _a.antd, popupMatchSelectWidth: false }, children, contextHolder, popoverContextHolder, pageContextHolder, dialogContextHolder);
|
|
95
96
|
}, "FlowEngineGlobalsContextProvider");
|
|
96
|
-
const useFlowEngine = /* @__PURE__ */ __name(() => {
|
|
97
|
+
const useFlowEngine = /* @__PURE__ */ __name(({ throwError = true } = {}) => {
|
|
97
98
|
const context = (0, import_react.useContext)(FlowEngineReactContext);
|
|
98
|
-
if (!context) {
|
|
99
|
+
if (!context && throwError) {
|
|
99
100
|
throw new Error(
|
|
100
101
|
"useFlowEngine must be used within a FlowEngineProvider, and FlowEngineProvider must be supplied with an engine."
|
|
101
102
|
);
|
|
@@ -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
|
+
export * from '@formily/reactive';
|
|
10
|
+
export { observer, getPageActive } from './observer';
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var reactive_exports = {};
|
|
29
|
+
__export(reactive_exports, {
|
|
30
|
+
getPageActive: () => import_observer.getPageActive,
|
|
31
|
+
observer: () => import_observer.observer
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(reactive_exports);
|
|
34
|
+
__reExport(reactive_exports, require("@formily/reactive"), module.exports);
|
|
35
|
+
var import_observer = require("./observer");
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
getPageActive,
|
|
39
|
+
observer,
|
|
40
|
+
...require("@formily/reactive")
|
|
41
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
import { IObserverOptions, ReactFC } from '@formily/reactive-react';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { FlowEngineContext } from '..';
|
|
12
|
+
type ObserverComponentProps<P, Options extends IObserverOptions> = Options extends {
|
|
13
|
+
forwardRef: true;
|
|
14
|
+
} ? P & {
|
|
15
|
+
ref?: 'ref' extends keyof P ? P['ref'] : React.RefAttributes<any>;
|
|
16
|
+
} : React.PropsWithoutRef<P>;
|
|
17
|
+
export declare const observer: <P, Options extends IObserverOptions = IObserverOptions>(Component: ReactFC<P>, options?: Options) => React.MemoExoticComponent<ReactFC<ObserverComponentProps<P, Options>>>;
|
|
18
|
+
export declare function getPageActive(context: FlowEngineContext): boolean | undefined;
|
|
19
|
+
export {};
|