@nocobase/flow-engine 2.0.0-beta.9 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/BlockScopedFlowEngine.js +0 -1
- package/lib/FlowDefinition.d.ts +2 -0
- package/lib/JSRunner.d.ts +6 -0
- package/lib/JSRunner.js +32 -2
- package/lib/ViewScopedFlowEngine.js +3 -0
- package/lib/acl/Acl.js +13 -3
- package/lib/components/FlowContextSelector.js +155 -10
- package/lib/components/settings/wrappers/component/SwitchWithTitle.js +2 -1
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +76 -15
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +24 -4
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +5 -1
- package/lib/components/variables/VariableInput.js +9 -4
- package/lib/components/variables/VariableTag.js +46 -39
- package/lib/components/variables/utils.d.ts +7 -0
- package/lib/components/variables/utils.js +42 -2
- package/lib/data-source/index.d.ts +7 -27
- package/lib/data-source/index.js +81 -51
- package/lib/executor/FlowExecutor.d.ts +2 -1
- package/lib/executor/FlowExecutor.js +163 -22
- package/lib/flowContext.d.ts +230 -7
- package/lib/flowContext.js +2267 -148
- package/lib/flowEngine.d.ts +21 -0
- package/lib/flowEngine.js +56 -8
- package/lib/flowI18n.js +6 -4
- package/lib/flowSettings.js +17 -11
- package/lib/index.d.ts +7 -1
- package/lib/index.js +21 -0
- package/lib/locale/en-US.json +9 -2
- package/lib/locale/index.d.ts +14 -0
- package/lib/locale/zh-CN.json +8 -1
- package/lib/models/CollectionFieldModel.d.ts +1 -0
- package/lib/models/CollectionFieldModel.js +3 -2
- package/lib/models/flowModel.js +12 -1
- package/lib/provider.js +5 -5
- package/lib/resources/baseRecordResource.d.ts +5 -0
- package/lib/resources/baseRecordResource.js +24 -0
- package/lib/resources/multiRecordResource.d.ts +1 -0
- package/lib/resources/multiRecordResource.js +11 -4
- package/lib/resources/singleRecordResource.js +2 -0
- package/lib/resources/sqlResource.d.ts +4 -3
- package/lib/resources/sqlResource.js +8 -3
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +12 -2
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +2 -2
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.js +125 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +12 -2
- package/lib/runjs-context/contexts/base.js +706 -41
- package/lib/runjs-context/contributions.d.ts +33 -0
- package/lib/runjs-context/contributions.js +88 -0
- package/lib/runjs-context/helpers.js +12 -1
- package/lib/runjs-context/setup.js +6 -0
- package/lib/runjs-context/snippets/global/api-request.snippet.js +3 -3
- package/lib/runjs-context/snippets/global/import-esm.snippet.js +2 -3
- package/lib/runjs-context/snippets/global/query-selector.snippet.js +8 -3
- package/lib/runjs-context/snippets/global/require-amd.snippet.js +1 -1
- package/lib/runjs-context/snippets/index.d.ts +11 -1
- package/lib/runjs-context/snippets/index.js +61 -40
- package/lib/runjs-context/snippets/scene/block/add-event-listener.snippet.js +10 -7
- package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/echarts-init.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/block/render-react.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/block/resource-example.snippet.js +5 -5
- package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.js +6 -6
- package/lib/runjs-context/snippets/scene/block/vue-component.snippet.js +3 -4
- package/lib/runjs-context/snippets/scene/detail/color-by-value.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.js +20 -3
- package/lib/runjs-context/snippets/scene/detail/format-number.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/innerHTML-value.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.js +3 -3
- package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.js +1 -1
- package/lib/runjs-context/snippets/scene/form/render-basic.snippet.js +2 -2
- package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.js +6 -3
- package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.js +3 -1
- package/lib/runjsLibs.d.ts +28 -0
- package/lib/runjsLibs.js +532 -0
- package/lib/scheduler/ModelOperationScheduler.d.ts +2 -0
- package/lib/scheduler/ModelOperationScheduler.js +25 -21
- package/lib/types.d.ts +27 -0
- package/lib/utils/associationObjectVariable.d.ts +2 -2
- package/lib/utils/createCollectionContextMeta.js +1 -0
- package/lib/utils/createEphemeralContext.js +2 -2
- package/lib/utils/dateVariable.d.ts +16 -0
- package/lib/utils/dateVariable.js +380 -0
- package/lib/utils/exceptions.d.ts +7 -0
- package/lib/utils/exceptions.js +10 -0
- package/lib/utils/index.d.ts +8 -3
- package/lib/utils/index.js +45 -0
- package/lib/utils/params-resolvers.js +16 -9
- package/lib/utils/resolveModuleUrl.d.ts +58 -0
- package/lib/utils/resolveModuleUrl.js +65 -0
- package/lib/utils/resolveRunJSObjectValues.d.ts +16 -0
- package/lib/utils/resolveRunJSObjectValues.js +61 -0
- package/lib/utils/runjsModuleLoader.d.ts +58 -0
- package/lib/utils/runjsModuleLoader.js +422 -0
- package/lib/utils/runjsTemplateCompat.d.ts +35 -0
- package/lib/utils/runjsTemplateCompat.js +743 -0
- package/lib/utils/runjsValue.d.ts +29 -0
- package/lib/utils/runjsValue.js +275 -0
- package/lib/utils/safeGlobals.d.ts +18 -8
- package/lib/utils/safeGlobals.js +164 -17
- package/lib/utils/schema-utils.d.ts +10 -0
- package/lib/utils/schema-utils.js +61 -0
- package/lib/views/createViewMeta.d.ts +0 -7
- package/lib/views/createViewMeta.js +19 -70
- package/lib/views/index.d.ts +1 -2
- package/lib/views/index.js +4 -3
- package/lib/views/useDialog.js +7 -2
- package/lib/views/useDrawer.js +7 -2
- package/lib/views/usePage.d.ts +4 -0
- package/lib/views/usePage.js +43 -6
- package/lib/views/usePopover.js +4 -1
- package/lib/views/viewEvents.d.ts +17 -0
- package/lib/views/viewEvents.js +90 -0
- package/package.json +4 -4
- package/src/BlockScopedFlowEngine.ts +2 -5
- package/src/JSRunner.ts +44 -2
- package/src/ViewScopedFlowEngine.ts +4 -0
- package/src/__tests__/JSRunner.test.ts +64 -0
- package/src/__tests__/createViewMeta.popup.test.ts +62 -1
- package/src/__tests__/flowContext.test.ts +693 -1
- package/src/__tests__/flowEngine.dataSourceDirty.test.ts +63 -0
- package/src/__tests__/flowModel.openView.navigation.test.ts +28 -0
- package/src/__tests__/flowRunJSContextDefine.test.ts +63 -0
- package/src/__tests__/flowRuntimeContext.test.ts +2 -1
- package/src/__tests__/flowSettings.open.test.tsx +123 -19
- package/src/__tests__/runjsContext.test.ts +10 -7
- package/src/__tests__/runjsContextImplementations.test.ts +34 -3
- package/src/__tests__/runjsContextRuntime.test.ts +3 -3
- package/src/__tests__/runjsContributions.test.ts +89 -0
- package/src/__tests__/runjsExternalLibs.test.ts +242 -0
- package/src/__tests__/runjsLibsLazyLoading.test.ts +44 -0
- package/src/__tests__/runjsLocales.test.ts +4 -1
- package/src/__tests__/runjsPreprocessDefault.test.ts +49 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +166 -0
- package/src/__tests__/runjsSnippets.test.ts +40 -3
- package/src/acl/Acl.tsx +3 -3
- package/src/components/FlowContextSelector.tsx +208 -12
- package/src/components/settings/wrappers/component/SwitchWithTitle.tsx +2 -1
- package/src/components/settings/wrappers/component/__tests__/InlineControls.test.tsx +74 -0
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +109 -16
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +41 -7
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +13 -2
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +157 -5
- package/src/components/variables/VariableInput.tsx +12 -4
- package/src/components/variables/VariableTag.tsx +54 -45
- package/src/components/variables/__tests__/FlowContextSelector.test.tsx +260 -3
- package/src/components/variables/__tests__/VariableTag.test.tsx +50 -0
- package/src/components/variables/__tests__/utils.test.ts +81 -3
- package/src/components/variables/utils.ts +67 -6
- package/src/data-source/index.ts +85 -110
- package/src/executor/FlowExecutor.ts +200 -23
- package/src/executor/__tests__/flowExecutor.test.ts +66 -0
- package/src/flowContext.ts +2986 -211
- package/src/flowEngine.ts +59 -8
- package/src/flowI18n.ts +7 -5
- package/src/flowSettings.ts +18 -12
- package/src/index.ts +14 -1
- package/src/locale/en-US.json +9 -2
- package/src/locale/zh-CN.json +8 -1
- package/src/models/CollectionFieldModel.tsx +3 -1
- package/src/models/__tests__/dispatchEvent.when.test.ts +554 -0
- package/src/models/__tests__/flowModel.test.ts +20 -4
- package/src/models/flowModel.tsx +13 -1
- package/src/provider.tsx +7 -6
- package/src/resources/__tests__/multiRecordResource.test.ts +44 -0
- package/src/resources/__tests__/sqlResource.test.ts +60 -0
- package/src/resources/baseRecordResource.ts +31 -0
- package/src/resources/multiRecordResource.ts +11 -4
- package/src/resources/singleRecordResource.ts +3 -0
- package/src/resources/sqlResource.ts +11 -6
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +10 -0
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +6 -2
- package/src/runjs-context/contexts/JSEditableFieldRunJSContext.ts +106 -0
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +10 -0
- package/src/runjs-context/contexts/base.ts +715 -44
- package/src/runjs-context/contributions.ts +88 -0
- package/src/runjs-context/helpers.ts +11 -1
- package/src/runjs-context/setup.ts +6 -0
- package/src/runjs-context/snippets/global/api-request.snippet.ts +3 -3
- package/src/runjs-context/snippets/global/import-esm.snippet.ts +2 -3
- package/src/runjs-context/snippets/global/query-selector.snippet.ts +8 -3
- package/src/runjs-context/snippets/global/require-amd.snippet.ts +1 -1
- package/src/runjs-context/snippets/index.ts +75 -41
- package/src/runjs-context/snippets/scene/block/add-event-listener.snippet.ts +11 -13
- package/src/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/block/chartjs-bar.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/echarts-init.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/render-iframe.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/block/render-react.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/block/resource-example.snippet.ts +6 -11
- package/src/runjs-context/snippets/scene/block/three-users-orbit.snippet.ts +6 -6
- package/src/runjs-context/snippets/scene/block/vue-component.snippet.ts +3 -4
- package/src/runjs-context/snippets/scene/detail/color-by-value.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.ts +20 -3
- package/src/runjs-context/snippets/scene/detail/format-number.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/innerHTML-value.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/detail/percentage-bar.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/detail/relative-time.snippet.ts +3 -3
- package/src/runjs-context/snippets/scene/detail/status-tag.snippet.ts +2 -2
- package/src/runjs-context/snippets/scene/form/cascade-select.snippet.ts +1 -1
- package/src/runjs-context/snippets/scene/form/render-basic.snippet.ts +3 -8
- package/src/runjs-context/snippets/scene/table/cell-open-dialog.snippet.ts +6 -3
- package/src/runjs-context/snippets/scene/table/concat-fields.snippet.ts +3 -1
- package/src/runjsLibs.ts +622 -0
- package/src/scheduler/ModelOperationScheduler.ts +27 -21
- package/src/types.ts +38 -1
- package/src/utils/__tests__/dateVariable.test.ts +101 -0
- package/src/utils/__tests__/params-resolvers.test.ts +40 -0
- package/src/utils/__tests__/runjsRequireAsyncAutoWhitelist.test.ts +38 -0
- package/src/utils/__tests__/runjsTemplateCompat.test.ts +159 -0
- package/src/utils/__tests__/runjsValue.test.ts +44 -0
- package/src/utils/__tests__/safeGlobals.test.ts +57 -2
- package/src/utils/__tests__/utils.test.ts +95 -0
- package/src/utils/associationObjectVariable.ts +2 -2
- package/src/utils/createCollectionContextMeta.ts +1 -0
- package/src/utils/createEphemeralContext.ts +5 -4
- package/src/utils/dateVariable.ts +397 -0
- package/src/utils/exceptions.ts +11 -0
- package/src/utils/index.ts +37 -3
- package/src/utils/params-resolvers.ts +23 -9
- package/src/utils/resolveModuleUrl.ts +91 -0
- package/src/utils/resolveRunJSObjectValues.ts +46 -0
- package/src/utils/runjsModuleLoader.ts +553 -0
- package/src/utils/runjsTemplateCompat.ts +828 -0
- package/src/utils/runjsValue.ts +287 -0
- package/src/utils/safeGlobals.ts +188 -17
- package/src/utils/schema-utils.ts +79 -0
- package/src/views/__tests__/FlowView.usePage.test.tsx +54 -1
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +35 -8
- package/src/views/__tests__/viewEvents.resolveOpenerEngine.test.ts +28 -0
- package/src/views/createViewMeta.ts +22 -75
- package/src/views/index.tsx +1 -2
- package/src/views/useDialog.tsx +8 -1
- package/src/views/useDrawer.tsx +8 -1
- package/src/views/usePage.tsx +51 -5
- package/src/views/usePopover.tsx +4 -1
- package/src/views/viewEvents.ts +55 -0
package/src/flowEngine.ts
CHANGED
|
@@ -119,6 +119,18 @@ export class FlowEngine {
|
|
|
119
119
|
|
|
120
120
|
private _resources = new Map<string, typeof FlowResource>();
|
|
121
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Data change registry used to coordinate "refresh on active" across view-scoped engines.
|
|
124
|
+
*
|
|
125
|
+
* Keyed by: dataSourceKey -> resourceName -> version.
|
|
126
|
+
* - mark: increments version
|
|
127
|
+
* - get: returns current version (default 0)
|
|
128
|
+
*
|
|
129
|
+
* NOTE: ViewScopedFlowEngine proxies delegate non-local fields/methods to parents, so this
|
|
130
|
+
* registry naturally lives on the root engine instance and is shared across the whole view stack.
|
|
131
|
+
*/
|
|
132
|
+
private _dataSourceDirtyVersions: Map<string, Map<string, number>> = new Map();
|
|
133
|
+
|
|
122
134
|
/**
|
|
123
135
|
* 引擎事件总线(目前用于模型生命周期等事件)。
|
|
124
136
|
* ViewScopedFlowEngine 持有自己的实例,实现作用域隔离。
|
|
@@ -198,6 +210,35 @@ export class FlowEngine {
|
|
|
198
210
|
}
|
|
199
211
|
}
|
|
200
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Mark a data source resource as "dirty" (changed).
|
|
215
|
+
* This is used by data blocks to decide whether to refresh when a view becomes active.
|
|
216
|
+
*/
|
|
217
|
+
public markDataSourceDirty(dataSourceKey: string, resourceName: string): number {
|
|
218
|
+
const dsKey = String(dataSourceKey || 'main');
|
|
219
|
+
const resName = String(resourceName || '');
|
|
220
|
+
if (!resName) return this.getDataSourceDirtyVersion(dsKey, resName);
|
|
221
|
+
|
|
222
|
+
const ds = this._dataSourceDirtyVersions.get(dsKey) || new Map<string, number>();
|
|
223
|
+
if (!this._dataSourceDirtyVersions.has(dsKey)) {
|
|
224
|
+
this._dataSourceDirtyVersions.set(dsKey, ds);
|
|
225
|
+
}
|
|
226
|
+
const next = (ds.get(resName) || 0) + 1;
|
|
227
|
+
ds.set(resName, next);
|
|
228
|
+
return next;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Get current dirty version for a data source resource.
|
|
233
|
+
* Returns 0 when no writes have been recorded.
|
|
234
|
+
*/
|
|
235
|
+
public getDataSourceDirtyVersion(dataSourceKey: string, resourceName: string): number {
|
|
236
|
+
const dsKey = String(dataSourceKey || 'main');
|
|
237
|
+
const resName = String(resourceName || '');
|
|
238
|
+
if (!resName) return 0;
|
|
239
|
+
return this._dataSourceDirtyVersions.get(dsKey)?.get(resName) || 0;
|
|
240
|
+
}
|
|
241
|
+
|
|
201
242
|
/** 在目标模型生命周期达成时执行操作(仅在 View 引擎本地存储计划) */
|
|
202
243
|
public scheduleModelOperation(
|
|
203
244
|
fromModelOrUid: FlowModel | string,
|
|
@@ -866,16 +907,26 @@ export class FlowEngine {
|
|
|
866
907
|
*/
|
|
867
908
|
async loadModel<T extends FlowModel = FlowModel>(options): Promise<T | null> {
|
|
868
909
|
if (!this.ensureModelRepository()) return;
|
|
869
|
-
const
|
|
870
|
-
if (
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
910
|
+
const refresh = !!options?.refresh;
|
|
911
|
+
if (!refresh) {
|
|
912
|
+
const model = this.findModelByParentId(options.parentId, options.subKey);
|
|
913
|
+
if (model) {
|
|
914
|
+
return model as T;
|
|
915
|
+
}
|
|
916
|
+
const hydrated = this.hydrateModelFromPreviousEngines<T>(options);
|
|
917
|
+
if (hydrated) {
|
|
918
|
+
return hydrated as T;
|
|
919
|
+
}
|
|
876
920
|
}
|
|
877
921
|
const data = await this._modelRepository.findOne(options);
|
|
878
|
-
|
|
922
|
+
if (!data?.uid) return null;
|
|
923
|
+
if (refresh) {
|
|
924
|
+
const existing = this.getModel(data.uid);
|
|
925
|
+
if (existing) {
|
|
926
|
+
this.removeModelWithSubModels(existing.uid);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
return this.createModel<T>(data as any);
|
|
879
930
|
}
|
|
880
931
|
|
|
881
932
|
/**
|
package/src/flowI18n.ts
CHANGED
|
@@ -33,15 +33,17 @@ export class FlowI18n {
|
|
|
33
33
|
return keyOrTemplate;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
if (options?.compareWith && keyOrTemplate === options.compareWith) {
|
|
37
|
+
return keyOrTemplate;
|
|
38
|
+
}
|
|
38
39
|
|
|
39
40
|
// 检查翻译结果是否包含模板语法,如果有则进行模板编译
|
|
40
|
-
if (this.isTemplate(
|
|
41
|
-
|
|
41
|
+
if (this.isTemplate(keyOrTemplate)) {
|
|
42
|
+
return this.compileTemplate(keyOrTemplate);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
// 先尝试一次翻译
|
|
46
|
+
return this.translateKey(keyOrTemplate, options);
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
/**
|
package/src/flowSettings.ts
CHANGED
|
@@ -23,6 +23,7 @@ import type { FlowModel } from './models';
|
|
|
23
23
|
import { ParamObject, StepSettingsDialogProps, ToolbarItemConfig } from './types';
|
|
24
24
|
import {
|
|
25
25
|
compileUiSchema,
|
|
26
|
+
FlowCancelSaveException,
|
|
26
27
|
FlowExitException,
|
|
27
28
|
getT,
|
|
28
29
|
resolveDefaultParams,
|
|
@@ -31,7 +32,9 @@ import {
|
|
|
31
32
|
setupRuntimeContextSteps,
|
|
32
33
|
shouldHideStepInSettings,
|
|
33
34
|
} from './utils';
|
|
35
|
+
import { FlowExitAllException } from './utils/exceptions';
|
|
34
36
|
import { FlowStepContext } from './hooks/useFlowStep';
|
|
37
|
+
import { GLOBAL_EMBED_CONTAINER_ID, EMBED_REPLACING_DATA_KEY } from './views';
|
|
35
38
|
|
|
36
39
|
const Panel = Collapse.Panel;
|
|
37
40
|
|
|
@@ -682,14 +685,10 @@ export class FlowSettings {
|
|
|
682
685
|
typeof resolvedUiMode === 'object' && resolvedUiMode ? resolvedUiMode.props || {} : {};
|
|
683
686
|
|
|
684
687
|
if (modeType === 'embed') {
|
|
685
|
-
const target = document.querySelector<HTMLDivElement>(
|
|
688
|
+
const target = document.querySelector<HTMLDivElement>(`#${GLOBAL_EMBED_CONTAINER_ID}`);
|
|
686
689
|
const onOpen = modeProps.onOpen;
|
|
687
690
|
const onClose = modeProps.onClose;
|
|
688
691
|
|
|
689
|
-
if (target) {
|
|
690
|
-
target.innerHTML = ''; // 清空容器内原有内容
|
|
691
|
-
}
|
|
692
|
-
|
|
693
692
|
modeProps = {
|
|
694
693
|
target,
|
|
695
694
|
styles: {
|
|
@@ -699,15 +698,19 @@ export class FlowSettings {
|
|
|
699
698
|
},
|
|
700
699
|
...modeProps,
|
|
701
700
|
onOpen() {
|
|
702
|
-
target
|
|
703
|
-
|
|
704
|
-
|
|
701
|
+
if (target) {
|
|
702
|
+
target.style.width = modeProps.width || '33.3%';
|
|
703
|
+
target.style.maxWidth = modeProps.maxWidth || '800px';
|
|
704
|
+
target.style.minWidth = modeProps.minWidth || '0px';
|
|
705
|
+
}
|
|
705
706
|
onOpen?.();
|
|
706
707
|
},
|
|
707
708
|
onClose() {
|
|
708
|
-
target.
|
|
709
|
-
|
|
710
|
-
|
|
709
|
+
if (target && target.dataset[EMBED_REPLACING_DATA_KEY] !== '1') {
|
|
710
|
+
target.style.width = 'auto';
|
|
711
|
+
target.style.maxWidth = 'none';
|
|
712
|
+
target.style.minWidth = 'auto';
|
|
713
|
+
}
|
|
711
714
|
onClose?.();
|
|
712
715
|
},
|
|
713
716
|
};
|
|
@@ -902,7 +905,10 @@ export class FlowSettings {
|
|
|
902
905
|
console.error('FlowSettings.open: onSaved callback error', cbErr);
|
|
903
906
|
}
|
|
904
907
|
} catch (err) {
|
|
905
|
-
if (err instanceof
|
|
908
|
+
if (err instanceof FlowCancelSaveException) {
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
if (err instanceof FlowExitException || err instanceof FlowExitAllException) {
|
|
906
912
|
currentView.close();
|
|
907
913
|
return;
|
|
908
914
|
}
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,8 @@ export * from './types';
|
|
|
13
13
|
// 工具函数
|
|
14
14
|
export * from './utils';
|
|
15
15
|
export { compileRunJs } from './utils/jsxTransform';
|
|
16
|
+
export { registerRunJSLib } from './runjsLibs';
|
|
17
|
+
export type { RunJSLibCache, RunJSLibLoader } from './runjsLibs';
|
|
16
18
|
|
|
17
19
|
// 资源类
|
|
18
20
|
export * from './resources';
|
|
@@ -39,9 +41,20 @@ export {
|
|
|
39
41
|
} from './runjs-context/helpers';
|
|
40
42
|
export { RunJSContextRegistry, getModelClassName } from './runjs-context/registry';
|
|
41
43
|
export { setupRunJSContexts } from './runjs-context/setup';
|
|
42
|
-
export {
|
|
44
|
+
export type { RunJSContextContribution, RunJSContextContributionApi } from './runjs-context/contributions';
|
|
45
|
+
export { registerRunJSContextContribution } from './runjs-context/contributions';
|
|
46
|
+
export type { RunJSSnippetLoader } from './runjs-context/snippets';
|
|
47
|
+
export { getSnippetBody, listSnippetsForContext, registerRunJSSnippet } from './runjs-context/snippets';
|
|
43
48
|
|
|
44
49
|
export * from './views';
|
|
50
|
+
export {
|
|
51
|
+
DATA_SOURCE_DIRTY_EVENT,
|
|
52
|
+
ENGINE_SCOPE_KEY,
|
|
53
|
+
getEmitterViewActivatedVersion,
|
|
54
|
+
VIEW_ACTIVATED_EVENT,
|
|
55
|
+
VIEW_ACTIVATED_VERSION,
|
|
56
|
+
VIEW_ENGINE_SCOPE,
|
|
57
|
+
} from './views/viewEvents';
|
|
45
58
|
|
|
46
59
|
export * from './FlowDefinition';
|
|
47
60
|
export { createViewScopedEngine } from './ViewScopedFlowEngine';
|
package/src/locale/en-US.json
CHANGED
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"This is likely a NocoBase internals bug. Please open an issue at": "This is likely a NocoBase internals bug. Please open an issue at",
|
|
63
63
|
"This step has no configurable parameters": "This step has no configurable parameters",
|
|
64
64
|
"This variable is not available": "This variable is not available",
|
|
65
|
+
"Use return to output value": "Use return to output value",
|
|
65
66
|
"Try again": "Try again",
|
|
66
67
|
"Template created": "Template created",
|
|
67
68
|
"Template description": "Template description",
|
|
@@ -69,5 +70,11 @@
|
|
|
69
70
|
"Template name is required": "Template name is required",
|
|
70
71
|
"UID copied to clipboard": "UID copied to clipboard",
|
|
71
72
|
"createModelOptions must specify use property": "createModelOptions must specify \"use\" property",
|
|
72
|
-
"here": "here"
|
|
73
|
-
}
|
|
73
|
+
"here": "here",
|
|
74
|
+
"RunJS deprecated warning": "[RunJS][Deprecated] {{api}} is deprecated{{location}}",
|
|
75
|
+
"RunJS deprecated warning with message": "[RunJS][Deprecated] {{api}} {{message}}{{location}}",
|
|
76
|
+
"RunJS deprecated separator": "; ",
|
|
77
|
+
"RunJS deprecated replacedBy": "Use {{replacedBy}} instead",
|
|
78
|
+
"RunJS deprecated since": "since {{since}}",
|
|
79
|
+
"RunJS deprecated removedIn": "will be removed in {{removedIn}}"
|
|
80
|
+
}
|
package/src/locale/zh-CN.json
CHANGED
|
@@ -66,8 +66,15 @@
|
|
|
66
66
|
"This is likely a NocoBase internals bug. Please open an issue at": "这可能是 NocoBase 内部错误。请在以下地址提交问题",
|
|
67
67
|
"This step has no configurable parameters": "此步骤没有可配置的参数",
|
|
68
68
|
"This variable is not available": "此变量不可用",
|
|
69
|
+
"Use return to output value": "使用 return 返回最终值",
|
|
69
70
|
"Try again": "重试",
|
|
70
71
|
"UID copied to clipboard": "UID 已复制到剪贴板",
|
|
71
72
|
"createModelOptions must specify use property": "createModelOptions 必须指定 \"use\" 属性",
|
|
72
|
-
"here": "这里"
|
|
73
|
+
"here": "这里",
|
|
74
|
+
"RunJS deprecated warning": "[RunJS][已废弃] {{api}}{{location}}",
|
|
75
|
+
"RunJS deprecated warning with message": "[RunJS][已废弃] {{api}} {{message}}{{location}}",
|
|
76
|
+
"RunJS deprecated separator": ";",
|
|
77
|
+
"RunJS deprecated replacedBy": "建议使用:{{replacedBy}}",
|
|
78
|
+
"RunJS deprecated since": "自 {{since}} 起",
|
|
79
|
+
"RunJS deprecated removedIn": "将在 {{removedIn}} 移除"
|
|
73
80
|
}
|
|
@@ -190,7 +190,7 @@ export class CollectionFieldModel<T extends DefaultStructure = DefaultStructure>
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
// Filter the mappings based on the `when` condition
|
|
193
|
-
const bindings = this.bindings.get(interfaceName);
|
|
193
|
+
const bindings = this.bindings.get(interfaceName).sort((a, b) => a.order - b.order);
|
|
194
194
|
return bindings.filter(
|
|
195
195
|
(binding) => ctx.engine.getModelClass(binding.modelName) && binding.when(ctx, collectionField),
|
|
196
196
|
);
|
|
@@ -261,6 +261,7 @@ export class CollectionFieldModel<T extends DefaultStructure = DefaultStructure>
|
|
|
261
261
|
interfaceName: string | string[],
|
|
262
262
|
options: {
|
|
263
263
|
isDefault?: boolean;
|
|
264
|
+
order?: number;
|
|
264
265
|
defaultProps?: object | ((ctx: FlowEngineContext, fieldInstance: CollectionField) => object);
|
|
265
266
|
when?: (ctx: FlowEngineContext, fieldInstance: CollectionField) => boolean;
|
|
266
267
|
} = {},
|
|
@@ -281,6 +282,7 @@ export class CollectionFieldModel<T extends DefaultStructure = DefaultStructure>
|
|
|
281
282
|
isDefault: options.isDefault || false,
|
|
282
283
|
defaultProps: options.defaultProps || null,
|
|
283
284
|
when: options.when || defaultWhen,
|
|
285
|
+
order: options.order,
|
|
284
286
|
});
|
|
285
287
|
|
|
286
288
|
// Update the map
|