@nocobase/flow-engine 2.1.0-alpha.1 → 2.1.0-alpha.10
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 +201 -661
- package/README.md +79 -10
- package/lib/BlockScopedFlowEngine.js +0 -1
- package/lib/FlowDefinition.d.ts +2 -0
- package/lib/JSRunner.d.ts +15 -0
- package/lib/JSRunner.js +82 -7
- package/lib/ViewScopedFlowEngine.js +8 -1
- package/lib/acl/Acl.js +13 -3
- package/lib/components/FlowContextSelector.js +155 -10
- package/lib/components/MobilePopup.js +6 -5
- package/lib/components/dnd/gridDragPlanner.d.ts +1 -0
- package/lib/components/dnd/gridDragPlanner.js +59 -3
- 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 +21 -3
- package/lib/components/subModel/AddSubModelButton.js +16 -1
- package/lib/components/subModel/utils.js +2 -2
- 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 +84 -51
- package/lib/executor/FlowExecutor.d.ts +2 -1
- package/lib/executor/FlowExecutor.js +190 -26
- package/lib/flowContext.d.ts +230 -7
- package/lib/flowContext.js +2270 -148
- package/lib/flowEngine.d.ts +160 -1
- package/lib/flowEngine.js +383 -26
- package/lib/flowI18n.js +6 -4
- package/lib/flowSettings.d.ts +14 -6
- package/lib/flowSettings.js +51 -17
- package/lib/index.d.ts +7 -1
- package/lib/index.js +21 -0
- package/lib/lazy-helper.d.ts +14 -0
- package/lib/lazy-helper.js +71 -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.d.ts +7 -0
- package/lib/models/flowModel.js +83 -8
- package/lib/provider.js +7 -6
- 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/registry.d.ts +1 -1
- package/lib/runjs-context/setup.js +22 -9
- 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 +7 -1
- package/lib/scheduler/ModelOperationScheduler.js +28 -23
- package/lib/types.d.ts +63 -1
- 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 +49 -0
- package/lib/utils/params-resolvers.js +16 -9
- package/lib/utils/parsePathnameToViewParams.js +1 -1
- 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 +17 -1
- package/lib/utils/schema-utils.js +80 -0
- package/lib/views/FlowView.d.ts +7 -1
- 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/runViewBeforeClose.d.ts +10 -0
- package/lib/views/runViewBeforeClose.js +45 -0
- package/lib/views/useDialog.d.ts +2 -1
- package/lib/views/useDialog.js +28 -6
- package/lib/views/useDrawer.d.ts +2 -1
- package/lib/views/useDrawer.js +27 -5
- package/lib/views/usePage.d.ts +6 -1
- package/lib/views/usePage.js +53 -9
- 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 +5 -5
- package/src/BlockScopedFlowEngine.ts +2 -5
- package/src/JSRunner.ts +111 -5
- package/src/ViewScopedFlowEngine.ts +8 -0
- package/src/__tests__/JSRunner.test.ts +91 -1
- 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__/flowEngine.modelLoaders.test.ts +245 -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__/flowSettings.test.ts +94 -15
- package/src/__tests__/provider.test.tsx +0 -5
- package/src/__tests__/renderHiddenInConfig.test.tsx +6 -6
- package/src/__tests__/runjsContext.test.ts +23 -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 +72 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +166 -0
- package/src/__tests__/runjsSnippets.test.ts +40 -3
- package/src/__tests__/viewScopedFlowEngine.test.ts +3 -3
- package/src/acl/Acl.tsx +3 -3
- package/src/components/FlowContextSelector.tsx +208 -12
- package/src/components/MobilePopup.tsx +4 -2
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +3 -3
- package/src/components/__tests__/gridDragPlanner.test.ts +229 -1
- package/src/components/dnd/gridDragPlanner.ts +68 -2
- 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 +31 -4
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +157 -5
- package/src/components/subModel/AddSubModelButton.tsx +17 -1
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +142 -32
- package/src/components/subModel/utils.ts +1 -1
- 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 +88 -110
- package/src/executor/FlowExecutor.ts +230 -28
- package/src/executor/__tests__/flowExecutor.test.ts +123 -0
- package/src/flowContext.ts +2989 -212
- package/src/flowEngine.ts +427 -22
- package/src/flowI18n.ts +7 -5
- package/src/flowSettings.ts +58 -18
- package/src/index.ts +14 -1
- package/src/lazy-helper.tsx +57 -0
- 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 +768 -0
- package/src/models/__tests__/flowModel.clone.test.ts +416 -0
- package/src/models/__tests__/flowModel.test.ts +20 -4
- package/src/models/flowModel.tsx +112 -7
- package/src/provider.tsx +9 -7
- 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/registry.ts +1 -1
- package/src/runjs-context/setup.ts +24 -9
- 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 +41 -24
- package/src/types.ts +86 -1
- package/src/utils/__tests__/dateVariable.test.ts +101 -0
- package/src/utils/__tests__/params-resolvers.test.ts +40 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +7 -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 +157 -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 +38 -3
- package/src/utils/params-resolvers.ts +23 -9
- package/src/utils/parsePathnameToViewParams.ts +2 -2
- 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 +109 -1
- package/src/views/FlowView.tsx +11 -1
- package/src/views/__tests__/FlowView.usePage.test.tsx +54 -1
- package/src/views/__tests__/runViewBeforeClose.test.ts +30 -0
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +44 -16
- 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/runViewBeforeClose.ts +19 -0
- package/src/views/useDialog.tsx +34 -5
- package/src/views/useDrawer.tsx +33 -4
- package/src/views/usePage.tsx +63 -8
- package/src/views/usePopover.tsx +4 -1
- package/src/views/viewEvents.ts +55 -0
package/lib/flowSettings.js
CHANGED
|
@@ -62,7 +62,10 @@ var import_flowContext = require("./flowContext");
|
|
|
62
62
|
var import__ = require(".");
|
|
63
63
|
var import_useFlowSettingsContext = require("./hooks/useFlowSettingsContext");
|
|
64
64
|
var import_utils = require("./utils");
|
|
65
|
+
var import_exceptions = require("./utils/exceptions");
|
|
65
66
|
var import_useFlowStep = require("./hooks/useFlowStep");
|
|
67
|
+
var import_views = require("./views");
|
|
68
|
+
var import_lazy_helper = require("./lazy-helper");
|
|
66
69
|
var _forceEnabled, _emitter;
|
|
67
70
|
const Panel = import_antd.Collapse.Panel;
|
|
68
71
|
const _FlowSettings = class _FlowSettings {
|
|
@@ -71,10 +74,12 @@ const _FlowSettings = class _FlowSettings {
|
|
|
71
74
|
__publicField(this, "scopes", {});
|
|
72
75
|
__publicField(this, "antdComponentsLoaded", false);
|
|
73
76
|
__publicField(this, "enabled");
|
|
77
|
+
__publicField(this, "engine");
|
|
74
78
|
__privateAdd(this, _forceEnabled, false);
|
|
75
79
|
// 强制启用状态,主要用于设计模式下的强制启用
|
|
76
80
|
__publicField(this, "toolbarItems", []);
|
|
77
81
|
__privateAdd(this, _emitter, new import_emitter.Emitter());
|
|
82
|
+
this.engine = engine;
|
|
78
83
|
this.enabled = false;
|
|
79
84
|
engine.context.defineProperty("flowSettingsEnabled", {
|
|
80
85
|
get: /* @__PURE__ */ __name(() => this.enabled, "get"),
|
|
@@ -213,6 +218,29 @@ const _FlowSettings = class _FlowSettings {
|
|
|
213
218
|
this.components[name] = components[name];
|
|
214
219
|
});
|
|
215
220
|
}
|
|
221
|
+
registerComponentLoaders(loaders) {
|
|
222
|
+
Object.entries(loaders).forEach(([name, loader]) => {
|
|
223
|
+
if (this.components[name]) {
|
|
224
|
+
console.warn(`FlowSettings: Component with name '${name}' is already registered and will be overwritten.`);
|
|
225
|
+
}
|
|
226
|
+
this.components[name] = (0, import_lazy_helper.lazy)(async () => {
|
|
227
|
+
const loaded = await loader();
|
|
228
|
+
if (typeof loaded === "function") {
|
|
229
|
+
return { default: loaded };
|
|
230
|
+
}
|
|
231
|
+
if ((loaded == null ? void 0 : loaded.default) && typeof loaded.default === "function") {
|
|
232
|
+
return { default: loaded.default };
|
|
233
|
+
}
|
|
234
|
+
const namedComponent = loaded == null ? void 0 : loaded[name];
|
|
235
|
+
if (typeof namedComponent === "function") {
|
|
236
|
+
return { default: namedComponent };
|
|
237
|
+
}
|
|
238
|
+
throw new Error(
|
|
239
|
+
`FlowSettings: component loader for '${name}' must resolve to a React component or a module exporting it.`
|
|
240
|
+
);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
}
|
|
216
244
|
/**
|
|
217
245
|
* 添加作用域到 FlowSettings 的作用域注册表中。
|
|
218
246
|
* 这些作用域可以在 flow step 的 uiSchema 中使用。
|
|
@@ -232,27 +260,29 @@ const _FlowSettings = class _FlowSettings {
|
|
|
232
260
|
/**
|
|
233
261
|
* 启用流程设置组件的显示
|
|
234
262
|
* @example
|
|
235
|
-
* flowSettings.enable();
|
|
263
|
+
* await flowSettings.enable();
|
|
236
264
|
*/
|
|
237
|
-
enable() {
|
|
265
|
+
async enable() {
|
|
266
|
+
await this.engine.preloadModelLoaders();
|
|
238
267
|
this.enabled = true;
|
|
239
268
|
}
|
|
240
|
-
forceEnable() {
|
|
269
|
+
async forceEnable() {
|
|
270
|
+
await this.engine.preloadModelLoaders();
|
|
241
271
|
__privateSet(this, _forceEnabled, true);
|
|
242
272
|
this.enabled = true;
|
|
243
273
|
}
|
|
244
274
|
/**
|
|
245
275
|
* 禁用流程设置组件的显示
|
|
246
276
|
* @example
|
|
247
|
-
* flowSettings.disable();
|
|
277
|
+
* await flowSettings.disable();
|
|
248
278
|
*/
|
|
249
|
-
disable() {
|
|
279
|
+
async disable() {
|
|
250
280
|
if (__privateGet(this, _forceEnabled)) {
|
|
251
281
|
return;
|
|
252
282
|
}
|
|
253
283
|
this.enabled = false;
|
|
254
284
|
}
|
|
255
|
-
forceDisable() {
|
|
285
|
+
async forceDisable() {
|
|
256
286
|
__privateSet(this, _forceEnabled, false);
|
|
257
287
|
this.enabled = false;
|
|
258
288
|
}
|
|
@@ -536,12 +566,9 @@ const _FlowSettings = class _FlowSettings {
|
|
|
536
566
|
};
|
|
537
567
|
let modeProps = typeof resolvedUiMode === "object" && resolvedUiMode ? resolvedUiMode.props || {} : {};
|
|
538
568
|
if (modeType === "embed") {
|
|
539
|
-
const target = document.querySelector(
|
|
569
|
+
const target = document.querySelector(`#${import_views.GLOBAL_EMBED_CONTAINER_ID}`);
|
|
540
570
|
const onOpen = modeProps.onOpen;
|
|
541
571
|
const onClose = modeProps.onClose;
|
|
542
|
-
if (target) {
|
|
543
|
-
target.innerHTML = "";
|
|
544
|
-
}
|
|
545
572
|
modeProps = {
|
|
546
573
|
target,
|
|
547
574
|
styles: {
|
|
@@ -551,15 +578,19 @@ const _FlowSettings = class _FlowSettings {
|
|
|
551
578
|
},
|
|
552
579
|
...modeProps,
|
|
553
580
|
onOpen() {
|
|
554
|
-
target
|
|
555
|
-
|
|
556
|
-
|
|
581
|
+
if (target) {
|
|
582
|
+
target.style.width = modeProps.width || "33.3%";
|
|
583
|
+
target.style.maxWidth = modeProps.maxWidth || "800px";
|
|
584
|
+
target.style.minWidth = modeProps.minWidth || "0px";
|
|
585
|
+
}
|
|
557
586
|
onOpen == null ? void 0 : onOpen();
|
|
558
587
|
},
|
|
559
588
|
onClose() {
|
|
560
|
-
target.
|
|
561
|
-
|
|
562
|
-
|
|
589
|
+
if (target && target.dataset[import_views.EMBED_REPLACING_DATA_KEY] !== "1") {
|
|
590
|
+
target.style.width = "auto";
|
|
591
|
+
target.style.maxWidth = "none";
|
|
592
|
+
target.style.minWidth = "auto";
|
|
593
|
+
}
|
|
563
594
|
onClose == null ? void 0 : onClose();
|
|
564
595
|
}
|
|
565
596
|
};
|
|
@@ -711,7 +742,10 @@ const _FlowSettings = class _FlowSettings {
|
|
|
711
742
|
console.error("FlowSettings.open: onSaved callback error", cbErr);
|
|
712
743
|
}
|
|
713
744
|
} catch (err) {
|
|
714
|
-
if (err instanceof import_utils.
|
|
745
|
+
if (err instanceof import_utils.FlowCancelSaveException) {
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
if (err instanceof import_utils.FlowExitException || err instanceof import_exceptions.FlowExitAllException) {
|
|
715
749
|
currentView.close();
|
|
716
750
|
return;
|
|
717
751
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
export * from './types';
|
|
10
10
|
export * from './utils';
|
|
11
11
|
export { compileRunJs } from './utils/jsxTransform';
|
|
12
|
+
export { registerRunJSLib } from './runjsLibs';
|
|
13
|
+
export type { RunJSLibCache, RunJSLibLoader } from './runjsLibs';
|
|
12
14
|
export * from './resources';
|
|
13
15
|
export * from './flowEngine';
|
|
14
16
|
export * from './hooks';
|
|
@@ -25,8 +27,12 @@ export * from './JSRunner';
|
|
|
25
27
|
export { getRunJSDocFor, createJSRunnerWithVersion, getRunJSScenesForModel, getRunJSScenesForContext, } from './runjs-context/helpers';
|
|
26
28
|
export { RunJSContextRegistry, getModelClassName } from './runjs-context/registry';
|
|
27
29
|
export { setupRunJSContexts } from './runjs-context/setup';
|
|
28
|
-
export {
|
|
30
|
+
export type { RunJSContextContribution, RunJSContextContributionApi } from './runjs-context/contributions';
|
|
31
|
+
export { registerRunJSContextContribution } from './runjs-context/contributions';
|
|
32
|
+
export type { RunJSSnippetLoader } from './runjs-context/snippets';
|
|
33
|
+
export { getSnippetBody, listSnippetsForContext, registerRunJSSnippet } from './runjs-context/snippets';
|
|
29
34
|
export * from './views';
|
|
35
|
+
export { DATA_SOURCE_DIRTY_EVENT, ENGINE_SCOPE_KEY, getEmitterViewActivatedVersion, VIEW_ACTIVATED_EVENT, VIEW_ACTIVATED_VERSION, VIEW_ENGINE_SCOPE, } from './views/viewEvents';
|
|
30
36
|
export * from './FlowDefinition';
|
|
31
37
|
export { createViewScopedEngine } from './ViewScopedFlowEngine';
|
|
32
38
|
export { createBlockScopedEngine } from './BlockScopedFlowEngine';
|
package/lib/index.js
CHANGED
|
@@ -27,23 +27,33 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var src_exports = {};
|
|
29
29
|
__export(src_exports, {
|
|
30
|
+
DATA_SOURCE_DIRTY_EVENT: () => import_viewEvents.DATA_SOURCE_DIRTY_EVENT,
|
|
31
|
+
ENGINE_SCOPE_KEY: () => import_viewEvents.ENGINE_SCOPE_KEY,
|
|
30
32
|
RunJSContextRegistry: () => import_registry.RunJSContextRegistry,
|
|
33
|
+
VIEW_ACTIVATED_EVENT: () => import_viewEvents.VIEW_ACTIVATED_EVENT,
|
|
34
|
+
VIEW_ACTIVATED_VERSION: () => import_viewEvents.VIEW_ACTIVATED_VERSION,
|
|
35
|
+
VIEW_ENGINE_SCOPE: () => import_viewEvents.VIEW_ENGINE_SCOPE,
|
|
31
36
|
compileRunJs: () => import_jsxTransform.compileRunJs,
|
|
32
37
|
createBlockScopedEngine: () => import_BlockScopedFlowEngine.createBlockScopedEngine,
|
|
33
38
|
createJSRunnerWithVersion: () => import_helpers.createJSRunnerWithVersion,
|
|
34
39
|
createViewScopedEngine: () => import_ViewScopedFlowEngine.createViewScopedEngine,
|
|
40
|
+
getEmitterViewActivatedVersion: () => import_viewEvents.getEmitterViewActivatedVersion,
|
|
35
41
|
getModelClassName: () => import_registry.getModelClassName,
|
|
36
42
|
getRunJSDocFor: () => import_helpers.getRunJSDocFor,
|
|
37
43
|
getRunJSScenesForContext: () => import_helpers.getRunJSScenesForContext,
|
|
38
44
|
getRunJSScenesForModel: () => import_helpers.getRunJSScenesForModel,
|
|
39
45
|
getSnippetBody: () => import_snippets.getSnippetBody,
|
|
40
46
|
listSnippetsForContext: () => import_snippets.listSnippetsForContext,
|
|
47
|
+
registerRunJSContextContribution: () => import_contributions.registerRunJSContextContribution,
|
|
48
|
+
registerRunJSLib: () => import_runjsLibs.registerRunJSLib,
|
|
49
|
+
registerRunJSSnippet: () => import_snippets.registerRunJSSnippet,
|
|
41
50
|
setupRunJSContexts: () => import_setup.setupRunJSContexts
|
|
42
51
|
});
|
|
43
52
|
module.exports = __toCommonJS(src_exports);
|
|
44
53
|
__reExport(src_exports, require("./types"), module.exports);
|
|
45
54
|
__reExport(src_exports, require("./utils"), module.exports);
|
|
46
55
|
var import_jsxTransform = require("./utils/jsxTransform");
|
|
56
|
+
var import_runjsLibs = require("./runjsLibs");
|
|
47
57
|
__reExport(src_exports, require("./resources"), module.exports);
|
|
48
58
|
__reExport(src_exports, require("./flowEngine"), module.exports);
|
|
49
59
|
__reExport(src_exports, require("./hooks"), module.exports);
|
|
@@ -60,24 +70,35 @@ __reExport(src_exports, require("./JSRunner"), module.exports);
|
|
|
60
70
|
var import_helpers = require("./runjs-context/helpers");
|
|
61
71
|
var import_registry = require("./runjs-context/registry");
|
|
62
72
|
var import_setup = require("./runjs-context/setup");
|
|
73
|
+
var import_contributions = require("./runjs-context/contributions");
|
|
63
74
|
var import_snippets = require("./runjs-context/snippets");
|
|
64
75
|
__reExport(src_exports, require("./views"), module.exports);
|
|
76
|
+
var import_viewEvents = require("./views/viewEvents");
|
|
65
77
|
__reExport(src_exports, require("./FlowDefinition"), module.exports);
|
|
66
78
|
var import_ViewScopedFlowEngine = require("./ViewScopedFlowEngine");
|
|
67
79
|
var import_BlockScopedFlowEngine = require("./BlockScopedFlowEngine");
|
|
68
80
|
// Annotate the CommonJS export names for ESM import in node:
|
|
69
81
|
0 && (module.exports = {
|
|
82
|
+
DATA_SOURCE_DIRTY_EVENT,
|
|
83
|
+
ENGINE_SCOPE_KEY,
|
|
70
84
|
RunJSContextRegistry,
|
|
85
|
+
VIEW_ACTIVATED_EVENT,
|
|
86
|
+
VIEW_ACTIVATED_VERSION,
|
|
87
|
+
VIEW_ENGINE_SCOPE,
|
|
71
88
|
compileRunJs,
|
|
72
89
|
createBlockScopedEngine,
|
|
73
90
|
createJSRunnerWithVersion,
|
|
74
91
|
createViewScopedEngine,
|
|
92
|
+
getEmitterViewActivatedVersion,
|
|
75
93
|
getModelClassName,
|
|
76
94
|
getRunJSDocFor,
|
|
77
95
|
getRunJSScenesForContext,
|
|
78
96
|
getRunJSScenesForModel,
|
|
79
97
|
getSnippetBody,
|
|
80
98
|
listSnippetsForContext,
|
|
99
|
+
registerRunJSContextContribution,
|
|
100
|
+
registerRunJSLib,
|
|
101
|
+
registerRunJSSnippet,
|
|
81
102
|
setupRunJSContexts,
|
|
82
103
|
...require("./types"),
|
|
83
104
|
...require("./utils"),
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
type LazyComponentType<M extends Record<string, any>, K extends keyof M> = {
|
|
10
|
+
[P in K]: M[P];
|
|
11
|
+
};
|
|
12
|
+
export declare function lazy<M extends Record<'default', any>>(factory: () => Promise<M>): M['default'];
|
|
13
|
+
export declare function lazy<M extends Record<string, any>, K extends keyof M = keyof M>(factory: () => Promise<M>, ...componentNames: K[]): LazyComponentType<M, K>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var lazy_helper_exports = {};
|
|
39
|
+
__export(lazy_helper_exports, {
|
|
40
|
+
lazy: () => lazy
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(lazy_helper_exports);
|
|
43
|
+
var import_react = __toESM(require("react"));
|
|
44
|
+
function lazy(factory, ...componentNames) {
|
|
45
|
+
if (componentNames.length === 0) {
|
|
46
|
+
const LazyComponent = (0, import_react.lazy)(
|
|
47
|
+
() => factory().then((module2) => ({
|
|
48
|
+
default: module2.default
|
|
49
|
+
}))
|
|
50
|
+
);
|
|
51
|
+
const Component = /* @__PURE__ */ __name((props) => /* @__PURE__ */ import_react.default.createElement(import_react.default.Suspense, { fallback: null }, /* @__PURE__ */ import_react.default.createElement(LazyComponent, { ...props })), "Component");
|
|
52
|
+
return Component;
|
|
53
|
+
}
|
|
54
|
+
return componentNames.reduce(
|
|
55
|
+
(acc, name) => {
|
|
56
|
+
const LazyComponent = (0, import_react.lazy)(
|
|
57
|
+
() => factory().then((module2) => ({
|
|
58
|
+
default: module2[name]
|
|
59
|
+
}))
|
|
60
|
+
);
|
|
61
|
+
acc[name] = (props) => /* @__PURE__ */ import_react.default.createElement(import_react.default.Suspense, { fallback: null }, /* @__PURE__ */ import_react.default.createElement(LazyComponent, { ...props }));
|
|
62
|
+
return acc;
|
|
63
|
+
},
|
|
64
|
+
{}
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
__name(lazy, "lazy");
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
lazy
|
|
71
|
+
});
|
package/lib/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/lib/locale/index.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export declare const locales: {
|
|
|
71
71
|
"This is likely a NocoBase internals bug. Please open an issue at": string;
|
|
72
72
|
"This step has no configurable parameters": string;
|
|
73
73
|
"This variable is not available": string;
|
|
74
|
+
"Use return to output value": string;
|
|
74
75
|
"Try again": string;
|
|
75
76
|
"Template created": string;
|
|
76
77
|
"Template description": string;
|
|
@@ -79,6 +80,12 @@ export declare const locales: {
|
|
|
79
80
|
"UID copied to clipboard": string;
|
|
80
81
|
"createModelOptions must specify use property": string;
|
|
81
82
|
here: string;
|
|
83
|
+
"RunJS deprecated warning": string;
|
|
84
|
+
"RunJS deprecated warning with message": string;
|
|
85
|
+
"RunJS deprecated separator": string;
|
|
86
|
+
"RunJS deprecated replacedBy": string;
|
|
87
|
+
"RunJS deprecated since": string;
|
|
88
|
+
"RunJS deprecated removedIn": string;
|
|
82
89
|
};
|
|
83
90
|
'zh-CN': {
|
|
84
91
|
Add: string;
|
|
@@ -148,10 +155,17 @@ export declare const locales: {
|
|
|
148
155
|
"This is likely a NocoBase internals bug. Please open an issue at": string;
|
|
149
156
|
"This step has no configurable parameters": string;
|
|
150
157
|
"This variable is not available": string;
|
|
158
|
+
"Use return to output value": string;
|
|
151
159
|
"Try again": string;
|
|
152
160
|
"UID copied to clipboard": string;
|
|
153
161
|
"createModelOptions must specify use property": string;
|
|
154
162
|
here: string;
|
|
163
|
+
"RunJS deprecated warning": string;
|
|
164
|
+
"RunJS deprecated warning with message": string;
|
|
165
|
+
"RunJS deprecated separator": string;
|
|
166
|
+
"RunJS deprecated replacedBy": string;
|
|
167
|
+
"RunJS deprecated since": string;
|
|
168
|
+
"RunJS deprecated removedIn": string;
|
|
155
169
|
};
|
|
156
170
|
};
|
|
157
171
|
/**
|
package/lib/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
|
}
|
|
@@ -45,6 +45,7 @@ export declare class CollectionFieldModel<T extends DefaultStructure = DefaultSt
|
|
|
45
45
|
}): BindingOptions | null;
|
|
46
46
|
static bindModelToInterface(modelName: string, interfaceName: string | string[], options?: {
|
|
47
47
|
isDefault?: boolean;
|
|
48
|
+
order?: number;
|
|
48
49
|
defaultProps?: object | ((ctx: FlowEngineContext, fieldInstance: CollectionField) => object);
|
|
49
50
|
when?: (ctx: FlowEngineContext, fieldInstance: CollectionField) => boolean;
|
|
50
51
|
}): void;
|
|
@@ -182,7 +182,7 @@ const _CollectionFieldModel = class _CollectionFieldModel extends import_flowMod
|
|
|
182
182
|
if (!this.bindings.has(interfaceName)) {
|
|
183
183
|
return [];
|
|
184
184
|
}
|
|
185
|
-
const bindings = this.bindings.get(interfaceName);
|
|
185
|
+
const bindings = this.bindings.get(interfaceName).sort((a, b) => a.order - b.order);
|
|
186
186
|
return bindings.filter(
|
|
187
187
|
(binding) => ctx.engine.getModelClass(binding.modelName) && binding.when(ctx, collectionField)
|
|
188
188
|
);
|
|
@@ -245,7 +245,8 @@ const _CollectionFieldModel = class _CollectionFieldModel extends import_flowMod
|
|
|
245
245
|
modelName,
|
|
246
246
|
isDefault: options.isDefault || false,
|
|
247
247
|
defaultProps: options.defaultProps || null,
|
|
248
|
-
when: options.when || defaultWhen
|
|
248
|
+
when: options.when || defaultWhen,
|
|
249
|
+
order: options.order
|
|
249
250
|
});
|
|
250
251
|
this.currentBindings.set(interfaceName, bindings);
|
|
251
252
|
}
|
|
@@ -361,6 +361,13 @@ export declare class FlowModel<Structure extends DefaultStructure = DefaultStruc
|
|
|
361
361
|
}): Promise<void>;
|
|
362
362
|
get translate(): any;
|
|
363
363
|
serialize(): Record<string, any>;
|
|
364
|
+
/**
|
|
365
|
+
* 复制当前模型实例为一个新的实例。
|
|
366
|
+
* 新实例及其所有子模型都会有新的 uid,且不保留 root model 的 parent 关系。
|
|
367
|
+
* 内部所有引用旧 uid 的地方(如 parentId, parentUid 等)都会被替换为对应的新 uid。
|
|
368
|
+
* @returns {FlowModel} 复制后的新模型实例
|
|
369
|
+
*/
|
|
370
|
+
clone<T extends FlowModel = this>(): T;
|
|
364
371
|
/**
|
|
365
372
|
* Opens the flow settings dialog for this flow model.
|
|
366
373
|
* @param options - Configuration options for opening flow settings, excluding the model property
|
package/lib/models/flowModel.js
CHANGED
|
@@ -56,13 +56,11 @@ var import_reactive = require("@formily/reactive");
|
|
|
56
56
|
var import_lodash = __toESM(require("lodash"));
|
|
57
57
|
var import_react = __toESM(require("react"));
|
|
58
58
|
var import_secure = require("uid/secure");
|
|
59
|
-
var import_StepRequiredSettingsDialog = require("../components/settings/wrappers/contextual/StepRequiredSettingsDialog");
|
|
60
|
-
var import_StepSettingsDialog = require("../components/settings/wrappers/contextual/StepSettingsDialog");
|
|
61
59
|
var import_emitter = require("../emitter");
|
|
62
60
|
var import_InstanceFlowRegistry = require("../flow-registry/InstanceFlowRegistry");
|
|
63
61
|
var import_flowContext = require("../flowContext");
|
|
64
62
|
var import_utils = require("../utils");
|
|
65
|
-
var
|
|
63
|
+
var import_antd = require("antd");
|
|
66
64
|
var import_ModelActionRegistry = require("../action-registry/ModelActionRegistry");
|
|
67
65
|
var import_utils2 = require("../components/subModel/utils");
|
|
68
66
|
var import_ModelEventRegistry = require("../event-registry/ModelEventRegistry");
|
|
@@ -75,6 +73,16 @@ const classEventRegistries = /* @__PURE__ */ new WeakMap();
|
|
|
75
73
|
const modelMetas = /* @__PURE__ */ new WeakMap();
|
|
76
74
|
const modelGlobalRegistries = /* @__PURE__ */ new WeakMap();
|
|
77
75
|
const classMenuExtensions = /* @__PURE__ */ new WeakMap();
|
|
76
|
+
async function loadOpenStepSettingsDialog() {
|
|
77
|
+
const mod = await import("../components/settings/wrappers/contextual/StepSettingsDialog");
|
|
78
|
+
return mod.openStepSettingsDialog;
|
|
79
|
+
}
|
|
80
|
+
__name(loadOpenStepSettingsDialog, "loadOpenStepSettingsDialog");
|
|
81
|
+
async function loadOpenRequiredParamsStepFormDialog() {
|
|
82
|
+
const mod = await import("../components/settings/wrappers/contextual/StepRequiredSettingsDialog");
|
|
83
|
+
return mod.openRequiredParamsStepFormDialog;
|
|
84
|
+
}
|
|
85
|
+
__name(loadOpenRequiredParamsStepFormDialog, "loadOpenRequiredParamsStepFormDialog");
|
|
78
86
|
var ModelRenderMode = /* @__PURE__ */ ((ModelRenderMode2) => {
|
|
79
87
|
ModelRenderMode2["ReactElement"] = "reactElement";
|
|
80
88
|
ModelRenderMode2["RenderFunction"] = "renderFunction";
|
|
@@ -353,7 +361,18 @@ const _FlowModel = class _FlowModel {
|
|
|
353
361
|
const meta = Cls.meta;
|
|
354
362
|
const metaCreate = meta == null ? void 0 : meta.createModelOptions;
|
|
355
363
|
if (metaCreate && typeof metaCreate === "object" && metaCreate.subModels) {
|
|
356
|
-
|
|
364
|
+
const replaceArrays = /* @__PURE__ */ __name((objValue, srcValue) => {
|
|
365
|
+
if (Array.isArray(objValue) && Array.isArray(srcValue)) {
|
|
366
|
+
return srcValue;
|
|
367
|
+
}
|
|
368
|
+
return void 0;
|
|
369
|
+
}, "replaceArrays");
|
|
370
|
+
mergedSubModels = import_lodash.default.mergeWith(
|
|
371
|
+
{},
|
|
372
|
+
import_lodash.default.cloneDeep(metaCreate.subModels || {}),
|
|
373
|
+
import_lodash.default.cloneDeep(subModels || {}),
|
|
374
|
+
replaceArrays
|
|
375
|
+
);
|
|
357
376
|
}
|
|
358
377
|
} catch (e) {
|
|
359
378
|
}
|
|
@@ -1047,7 +1066,7 @@ const _FlowModel = class _FlowModel {
|
|
|
1047
1066
|
* @param {string} stepKey 步骤的唯一标识符
|
|
1048
1067
|
* @returns {void}
|
|
1049
1068
|
*/
|
|
1050
|
-
openStepSettingsDialog(flowKey, stepKey) {
|
|
1069
|
+
async openStepSettingsDialog(flowKey, stepKey) {
|
|
1051
1070
|
var _a;
|
|
1052
1071
|
const flow = this.getFlow(flowKey);
|
|
1053
1072
|
const step = (_a = flow == null ? void 0 : flow.steps) == null ? void 0 : _a[stepKey];
|
|
@@ -1058,7 +1077,8 @@ const _FlowModel = class _FlowModel {
|
|
|
1058
1077
|
const ctx = new import_flowContext.FlowRuntimeContext(this, flowKey, "settings");
|
|
1059
1078
|
(0, import_utils.setupRuntimeContextSteps)(ctx, flow.steps, this, flowKey);
|
|
1060
1079
|
ctx.defineProperty("currentStep", { value: step });
|
|
1061
|
-
|
|
1080
|
+
const openStepSettingsDialog = await loadOpenStepSettingsDialog();
|
|
1081
|
+
return openStepSettingsDialog({
|
|
1062
1082
|
model: this,
|
|
1063
1083
|
flowKey,
|
|
1064
1084
|
stepKey,
|
|
@@ -1073,7 +1093,8 @@ const _FlowModel = class _FlowModel {
|
|
|
1073
1093
|
* @returns {Promise<any>} 返回表单提交的值
|
|
1074
1094
|
*/
|
|
1075
1095
|
async configureRequiredSteps(dialogWidth, dialogTitle) {
|
|
1076
|
-
|
|
1096
|
+
const openRequiredParamsStepFormDialog = await loadOpenRequiredParamsStepFormDialog();
|
|
1097
|
+
return openRequiredParamsStepFormDialog({
|
|
1077
1098
|
model: this,
|
|
1078
1099
|
dialogWidth,
|
|
1079
1100
|
dialogTitle
|
|
@@ -1119,6 +1140,60 @@ const _FlowModel = class _FlowModel {
|
|
|
1119
1140
|
}
|
|
1120
1141
|
return data;
|
|
1121
1142
|
}
|
|
1143
|
+
/**
|
|
1144
|
+
* 复制当前模型实例为一个新的实例。
|
|
1145
|
+
* 新实例及其所有子模型都会有新的 uid,且不保留 root model 的 parent 关系。
|
|
1146
|
+
* 内部所有引用旧 uid 的地方(如 parentId, parentUid 等)都会被替换为对应的新 uid。
|
|
1147
|
+
* @returns {FlowModel} 复制后的新模型实例
|
|
1148
|
+
*/
|
|
1149
|
+
clone() {
|
|
1150
|
+
if (!this.flowEngine) {
|
|
1151
|
+
throw new Error("FlowEngine is not set on this model. Please set flowEngine before cloning.");
|
|
1152
|
+
}
|
|
1153
|
+
const serialized = this.serialize();
|
|
1154
|
+
const uidMap = /* @__PURE__ */ new Map();
|
|
1155
|
+
const collectUids = /* @__PURE__ */ __name((data) => {
|
|
1156
|
+
if (data.uid && typeof data.uid === "string") {
|
|
1157
|
+
uidMap.set(data.uid, (0, import_secure.uid)());
|
|
1158
|
+
}
|
|
1159
|
+
if (data.subModels) {
|
|
1160
|
+
for (const key in data.subModels) {
|
|
1161
|
+
const subModel = data.subModels[key];
|
|
1162
|
+
if (Array.isArray(subModel)) {
|
|
1163
|
+
subModel.forEach((item) => collectUids(item));
|
|
1164
|
+
} else if (subModel && typeof subModel === "object") {
|
|
1165
|
+
collectUids(subModel);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}, "collectUids");
|
|
1170
|
+
collectUids(serialized);
|
|
1171
|
+
const replaceUidReferences = /* @__PURE__ */ __name((data, isRoot = false) => {
|
|
1172
|
+
if (data === null || data === void 0) {
|
|
1173
|
+
return data;
|
|
1174
|
+
}
|
|
1175
|
+
if (typeof data === "string") {
|
|
1176
|
+
return uidMap.get(data) ?? data;
|
|
1177
|
+
}
|
|
1178
|
+
if (Array.isArray(data)) {
|
|
1179
|
+
return data.map((item) => replaceUidReferences(item, false));
|
|
1180
|
+
}
|
|
1181
|
+
if (typeof data === "object") {
|
|
1182
|
+
const result = {};
|
|
1183
|
+
for (const key in data) {
|
|
1184
|
+
if (!Object.prototype.hasOwnProperty.call(data, key)) continue;
|
|
1185
|
+
if (isRoot && key === "parentId") {
|
|
1186
|
+
continue;
|
|
1187
|
+
}
|
|
1188
|
+
result[key] = replaceUidReferences(data[key], false);
|
|
1189
|
+
}
|
|
1190
|
+
return result;
|
|
1191
|
+
}
|
|
1192
|
+
return data;
|
|
1193
|
+
}, "replaceUidReferences");
|
|
1194
|
+
const clonedData = replaceUidReferences(serialized, true);
|
|
1195
|
+
return this.flowEngine.createModel(clonedData);
|
|
1196
|
+
}
|
|
1122
1197
|
/**
|
|
1123
1198
|
* Opens the flow settings dialog for this flow model.
|
|
1124
1199
|
* @param options - Configuration options for opening flow settings, excluding the model property
|
|
@@ -1238,7 +1313,7 @@ const _ErrorFlowModel = class _ErrorFlowModel extends FlowModel {
|
|
|
1238
1313
|
this.errorMessage = msg;
|
|
1239
1314
|
}
|
|
1240
1315
|
render() {
|
|
1241
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
1316
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd.Typography.Text, { type: "danger" }, this.errorMessage);
|
|
1242
1317
|
}
|
|
1243
1318
|
};
|
|
1244
1319
|
__name(_ErrorFlowModel, "ErrorFlowModel");
|
package/lib/provider.js
CHANGED
|
@@ -79,17 +79,17 @@ const FlowEngineGlobalsContextProvider = /* @__PURE__ */ __name(({ children }) =
|
|
|
79
79
|
cache: false,
|
|
80
80
|
get: /* @__PURE__ */ __name((ctx) => new import_FlowView.FlowViewer(ctx, { drawer, embed, popover, dialog }), "get")
|
|
81
81
|
});
|
|
82
|
-
engine.context.defineProperty("themeToken", {
|
|
83
|
-
get: /* @__PURE__ */ __name(() => token, "get"),
|
|
84
|
-
observable: true,
|
|
85
|
-
cache: true
|
|
86
|
-
});
|
|
87
82
|
for (const item of Object.entries(context)) {
|
|
88
83
|
const [key, value] = item;
|
|
89
84
|
if (value) {
|
|
90
85
|
engine.context.defineProperty(key, { value });
|
|
91
86
|
}
|
|
92
87
|
}
|
|
88
|
+
engine.context.defineProperty("themeToken", {
|
|
89
|
+
get: /* @__PURE__ */ __name(() => token, "get"),
|
|
90
|
+
observable: true,
|
|
91
|
+
cache: true
|
|
92
|
+
});
|
|
93
93
|
engine.reactView.refresh();
|
|
94
94
|
}, [engine, drawer, modal, message, notification, config, popover, token, dialog, embed]);
|
|
95
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);
|
|
@@ -97,9 +97,10 @@ const FlowEngineGlobalsContextProvider = /* @__PURE__ */ __name(({ children }) =
|
|
|
97
97
|
const useFlowEngine = /* @__PURE__ */ __name(({ throwError = true } = {}) => {
|
|
98
98
|
const context = (0, import_react.useContext)(FlowEngineReactContext);
|
|
99
99
|
if (!context && throwError) {
|
|
100
|
-
|
|
100
|
+
console.warn(
|
|
101
101
|
"useFlowEngine must be used within a FlowEngineProvider, and FlowEngineProvider must be supplied with an engine."
|
|
102
102
|
);
|
|
103
|
+
return;
|
|
103
104
|
}
|
|
104
105
|
return context;
|
|
105
106
|
}, "useFlowEngine");
|
|
@@ -30,6 +30,11 @@ export declare abstract class BaseRecordResource<TData = any> extends APIResourc
|
|
|
30
30
|
runAction<TData = any, TMeta = any>(action: string, options: any): Promise<any>;
|
|
31
31
|
setResourceName(resourceName: string): this;
|
|
32
32
|
getResourceName(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Mark current resource as dirty on the root FlowEngine.
|
|
35
|
+
* Used to coordinate "refresh on active" across view stacks.
|
|
36
|
+
*/
|
|
37
|
+
protected markDataSourceDirty(resourceName?: string): void;
|
|
33
38
|
setSourceId(sourceId: string | number): this;
|
|
34
39
|
getSourceId(): string | number;
|
|
35
40
|
setDataSourceKey(dataSourceKey: string): this;
|