@nocobase/flow-engine 2.1.0-alpha.4 → 2.1.0-alpha.45
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/FlowContextProvider.d.ts +5 -1
- package/lib/FlowContextProvider.js +9 -2
- package/lib/JSRunner.d.ts +10 -1
- package/lib/JSRunner.js +50 -5
- package/lib/ViewScopedFlowEngine.js +5 -1
- package/lib/components/FieldModelRenderer.js +2 -2
- package/lib/components/FlowModelRenderer.d.ts +3 -1
- package/lib/components/FlowModelRenderer.js +12 -6
- package/lib/components/FormItem.d.ts +6 -0
- package/lib/components/FormItem.js +11 -3
- package/lib/components/MobilePopup.js +6 -5
- package/lib/components/dnd/gridDragPlanner.d.ts +59 -2
- package/lib/components/dnd/gridDragPlanner.js +613 -21
- package/lib/components/dnd/index.d.ts +31 -2
- package/lib/components/dnd/index.js +244 -23
- package/lib/components/settings/wrappers/component/SelectWithTitle.d.ts +2 -1
- package/lib/components/settings/wrappers/component/SelectWithTitle.js +14 -12
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.d.ts +3 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +76 -11
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +23 -43
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +352 -295
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +16 -2
- package/lib/components/settings/wrappers/contextual/useFloatToolbarPortal.d.ts +36 -0
- package/lib/components/settings/wrappers/contextual/useFloatToolbarPortal.js +274 -0
- package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.d.ts +30 -0
- package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.js +315 -0
- package/lib/components/subModel/AddSubModelButton.js +27 -1
- package/lib/components/subModel/LazyDropdown.js +293 -52
- package/lib/components/subModel/index.d.ts +1 -0
- package/lib/components/subModel/index.js +19 -0
- package/lib/components/subModel/utils.d.ts +1 -1
- package/lib/components/subModel/utils.js +9 -3
- package/lib/components/variables/VariableHybridInput.d.ts +27 -0
- package/lib/components/variables/VariableHybridInput.js +499 -0
- package/lib/components/variables/index.d.ts +2 -0
- package/lib/components/variables/index.js +3 -0
- package/lib/data-source/index.d.ts +84 -0
- package/lib/data-source/index.js +259 -5
- package/lib/executor/FlowExecutor.js +32 -9
- package/lib/flow-registry/DetachedFlowRegistry.d.ts +21 -0
- package/lib/flow-registry/DetachedFlowRegistry.js +80 -0
- package/lib/flow-registry/index.d.ts +1 -0
- package/lib/flow-registry/index.js +3 -1
- package/lib/flowContext.d.ts +3 -0
- package/lib/flowContext.js +46 -1
- package/lib/flowEngine.d.ts +151 -1
- package/lib/flowEngine.js +392 -18
- package/lib/flowI18n.js +2 -1
- package/lib/flowSettings.d.ts +14 -6
- package/lib/flowSettings.js +34 -6
- package/lib/index.d.ts +2 -0
- package/lib/index.js +7 -0
- package/lib/lazy-helper.d.ts +14 -0
- package/lib/lazy-helper.js +71 -0
- package/lib/locale/en-US.json +1 -0
- package/lib/locale/index.d.ts +2 -0
- package/lib/locale/zh-CN.json +1 -0
- package/lib/models/DisplayItemModel.d.ts +1 -1
- package/lib/models/EditableItemModel.d.ts +1 -1
- package/lib/models/FilterableItemModel.d.ts +1 -1
- package/lib/models/flowModel.d.ts +13 -10
- package/lib/models/flowModel.js +81 -21
- package/lib/provider.js +38 -23
- package/lib/reactive/observer.js +46 -16
- package/lib/runjs-context/registry.d.ts +1 -1
- package/lib/runjs-context/setup.js +20 -12
- package/lib/runjs-context/snippets/index.js +13 -2
- package/lib/runjs-context/snippets/scene/detail/set-field-style.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/set-field-style.snippet.js +50 -0
- package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.js +54 -0
- package/lib/scheduler/ModelOperationScheduler.d.ts +5 -1
- package/lib/scheduler/ModelOperationScheduler.js +3 -2
- package/lib/types.d.ts +50 -2
- package/lib/types.js +1 -0
- package/lib/utils/createCollectionContextMeta.js +6 -2
- package/lib/utils/index.d.ts +3 -2
- package/lib/utils/index.js +7 -0
- package/lib/utils/parsePathnameToViewParams.d.ts +5 -1
- package/lib/utils/parsePathnameToViewParams.js +29 -5
- package/lib/utils/randomId.d.ts +39 -0
- package/lib/utils/randomId.js +45 -0
- package/lib/utils/runjsTemplateCompat.js +1 -1
- package/lib/utils/runjsValue.js +41 -11
- package/lib/utils/schema-utils.d.ts +7 -1
- package/lib/utils/schema-utils.js +19 -0
- package/lib/views/FlowView.d.ts +7 -1
- package/lib/views/FlowView.js +11 -1
- package/lib/views/PageComponent.js +8 -6
- package/lib/views/ViewNavigation.d.ts +12 -2
- package/lib/views/ViewNavigation.js +28 -9
- package/lib/views/createViewMeta.js +114 -50
- package/lib/views/inheritLayoutContext.d.ts +10 -0
- package/lib/views/inheritLayoutContext.js +50 -0
- 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 +22 -3
- package/lib/views/useDrawer.d.ts +2 -1
- package/lib/views/useDrawer.js +22 -3
- package/lib/views/usePage.d.ts +5 -11
- package/lib/views/usePage.js +304 -144
- package/package.json +6 -5
- package/src/FlowContextProvider.tsx +9 -1
- package/src/JSRunner.ts +68 -4
- package/src/ViewScopedFlowEngine.ts +4 -0
- package/src/__tests__/JSRunner.test.ts +27 -1
- package/src/__tests__/createViewMeta.popup.test.ts +115 -1
- package/src/__tests__/flow-engine.test.ts +166 -0
- package/src/__tests__/flowContext.test.ts +82 -1
- package/src/__tests__/flowEngine.modelLoaders.test.ts +245 -0
- package/src/__tests__/flowEngine.removeModel.test.ts +47 -3
- package/src/__tests__/flowSettings.test.ts +94 -15
- package/src/__tests__/objectVariable.test.ts +24 -0
- package/src/__tests__/provider.test.tsx +24 -2
- package/src/__tests__/renderHiddenInConfig.test.tsx +6 -6
- package/src/__tests__/runjsContext.test.ts +16 -0
- package/src/__tests__/runjsContextRuntime.test.ts +2 -0
- package/src/__tests__/runjsPreprocessDefault.test.ts +23 -0
- package/src/__tests__/runjsSnippets.test.ts +21 -0
- package/src/__tests__/viewScopedFlowEngine.test.ts +3 -3
- package/src/components/FieldModelRenderer.tsx +2 -1
- package/src/components/FlowModelRenderer.tsx +18 -6
- package/src/components/FormItem.tsx +7 -1
- package/src/components/MobilePopup.tsx +4 -2
- package/src/components/__tests__/FlowModelRenderer.test.tsx +65 -2
- package/src/components/__tests__/FormItem.test.tsx +25 -0
- package/src/components/__tests__/dnd.test.ts +44 -0
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +20 -10
- package/src/components/__tests__/gridDragPlanner.test.ts +558 -3
- package/src/components/dnd/__tests__/DndProvider.test.tsx +98 -0
- package/src/components/dnd/gridDragPlanner.ts +758 -19
- package/src/components/dnd/index.tsx +305 -28
- package/src/components/settings/wrappers/component/SelectWithTitle.tsx +21 -9
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +99 -11
- package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +487 -440
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +18 -2
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +194 -5
- package/src/components/settings/wrappers/contextual/__tests__/FlowsFloatContextMenu.test.tsx +778 -0
- package/src/components/settings/wrappers/contextual/useFloatToolbarPortal.ts +360 -0
- package/src/components/settings/wrappers/contextual/useFloatToolbarVisibility.ts +361 -0
- package/src/components/subModel/AddSubModelButton.tsx +32 -2
- package/src/components/subModel/LazyDropdown.tsx +332 -56
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +522 -37
- package/src/components/subModel/__tests__/utils.test.ts +24 -0
- package/src/components/subModel/index.ts +1 -0
- package/src/components/subModel/utils.ts +7 -1
- package/src/components/variables/VariableHybridInput.tsx +531 -0
- package/src/components/variables/index.ts +2 -0
- package/src/data-source/__tests__/collection.test.ts +41 -2
- package/src/data-source/__tests__/index.test.ts +68 -1
- package/src/data-source/index.ts +322 -6
- package/src/executor/FlowExecutor.ts +35 -10
- package/src/executor/__tests__/flowExecutor.test.ts +85 -0
- package/src/flow-registry/DetachedFlowRegistry.ts +46 -0
- package/src/flow-registry/__tests__/detachedFlowRegistry.test.ts +47 -0
- package/src/flow-registry/index.ts +1 -0
- package/src/flowContext.ts +50 -3
- package/src/flowEngine.ts +449 -14
- package/src/flowI18n.ts +2 -1
- package/src/flowSettings.ts +40 -6
- package/src/index.ts +2 -0
- package/src/lazy-helper.tsx +57 -0
- package/src/locale/en-US.json +1 -0
- package/src/locale/zh-CN.json +1 -0
- package/src/models/DisplayItemModel.tsx +1 -1
- package/src/models/EditableItemModel.tsx +1 -1
- package/src/models/FilterableItemModel.tsx +1 -1
- package/src/models/__tests__/dispatchEvent.when.test.ts +214 -0
- package/src/models/__tests__/flowEngine.resolveUse.test.ts +0 -15
- package/src/models/__tests__/flowModel.test.ts +80 -37
- package/src/models/flowModel.tsx +122 -36
- package/src/provider.tsx +41 -25
- package/src/reactive/__tests__/observer.test.tsx +82 -0
- package/src/reactive/observer.tsx +87 -25
- package/src/runjs-context/registry.ts +1 -1
- package/src/runjs-context/setup.ts +22 -12
- package/src/runjs-context/snippets/index.ts +12 -1
- package/src/runjs-context/snippets/scene/detail/set-field-style.snippet.ts +30 -0
- package/src/runjs-context/snippets/scene/table/set-cell-style.snippet.ts +34 -0
- package/src/scheduler/ModelOperationScheduler.ts +14 -3
- package/src/types.ts +62 -0
- package/src/utils/__tests__/createCollectionContextMeta.test.ts +48 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +28 -0
- package/src/utils/__tests__/runjsValue.test.ts +11 -0
- package/src/utils/__tests__/utils.test.ts +62 -0
- package/src/utils/createCollectionContextMeta.ts +6 -2
- package/src/utils/index.ts +5 -1
- package/src/utils/parsePathnameToViewParams.ts +47 -7
- package/src/utils/randomId.ts +48 -0
- package/src/utils/runjsTemplateCompat.ts +1 -1
- package/src/utils/runjsValue.ts +50 -11
- package/src/utils/schema-utils.ts +30 -1
- package/src/views/FlowView.tsx +22 -2
- package/src/views/PageComponent.tsx +7 -4
- package/src/views/ViewNavigation.ts +46 -9
- package/src/views/__tests__/FlowView.usePage.test.tsx +243 -3
- package/src/views/__tests__/ViewNavigation.test.ts +52 -0
- package/src/views/__tests__/inheritLayoutContext.test.ts +53 -0
- package/src/views/__tests__/runViewBeforeClose.test.ts +30 -0
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +13 -12
- package/src/views/createViewMeta.ts +106 -34
- package/src/views/inheritLayoutContext.ts +26 -0
- package/src/views/runViewBeforeClose.ts +19 -0
- package/src/views/useDialog.tsx +27 -3
- package/src/views/useDrawer.tsx +27 -3
- package/src/views/usePage.tsx +367 -179
package/lib/utils/runjsValue.js
CHANGED
|
@@ -231,6 +231,34 @@ function normalizeSubPath(raw) {
|
|
|
231
231
|
return { subPath: s, wildcard: false };
|
|
232
232
|
}
|
|
233
233
|
__name(normalizeSubPath, "normalizeSubPath");
|
|
234
|
+
function extractCtxRootUsage(expr) {
|
|
235
|
+
const raw = String(expr || "").trim();
|
|
236
|
+
if (!raw || raw === "ctx") return null;
|
|
237
|
+
const dotMatch = raw.match(/^ctx\.([a-zA-Z_$][a-zA-Z0-9_$]*)([\s\S]*)$/);
|
|
238
|
+
if (dotMatch) {
|
|
239
|
+
const varName = dotMatch[1] || "";
|
|
240
|
+
const rest = dotMatch[2] || "";
|
|
241
|
+
const normalized = normalizeSubPath(rest);
|
|
242
|
+
return {
|
|
243
|
+
varName,
|
|
244
|
+
subPath: normalized.subPath,
|
|
245
|
+
wildcard: normalized.wildcard
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const bracketMatch = raw.match(/^ctx\s*\[\s*(['"])([a-zA-Z_$][a-zA-Z0-9_$]*)\1\s*\]([\s\S]*)$/);
|
|
249
|
+
if (bracketMatch) {
|
|
250
|
+
const varName = bracketMatch[2] || "";
|
|
251
|
+
const rest = bracketMatch[3] || "";
|
|
252
|
+
const normalized = normalizeSubPath(rest);
|
|
253
|
+
return {
|
|
254
|
+
varName,
|
|
255
|
+
subPath: normalized.subPath,
|
|
256
|
+
wildcard: normalized.wildcard
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
__name(extractCtxRootUsage, "extractCtxRootUsage");
|
|
234
262
|
function extractUsedVariablePathsFromRunJS(code) {
|
|
235
263
|
if (typeof code !== "string" || !code.trim()) return {};
|
|
236
264
|
const src = stripStringsAndComments(code);
|
|
@@ -242,23 +270,25 @@ function extractUsedVariablePathsFromRunJS(code) {
|
|
|
242
270
|
set.add(subPath || "");
|
|
243
271
|
usage.set(varName, set);
|
|
244
272
|
}, "add");
|
|
273
|
+
const addCtxUsage = /* @__PURE__ */ __name((expr) => {
|
|
274
|
+
const hit = extractCtxRootUsage(expr);
|
|
275
|
+
if (!(hit == null ? void 0 : hit.varName)) return;
|
|
276
|
+
add(hit.varName, hit.wildcard ? "" : hit.subPath);
|
|
277
|
+
}, "addCtxUsage");
|
|
245
278
|
const dotRe = /ctx\.([a-zA-Z_$][a-zA-Z0-9_$]*(?:(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)|(?:\[[^\]]+\]))*)(?!\s*\()/g;
|
|
246
279
|
let match;
|
|
247
280
|
while (match = dotRe.exec(src)) {
|
|
248
|
-
|
|
249
|
-
const firstKeyMatch = pathAfterCtx.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);
|
|
250
|
-
if (!firstKeyMatch) continue;
|
|
251
|
-
const firstKey = firstKeyMatch[1];
|
|
252
|
-
const rest = pathAfterCtx.slice(firstKey.length);
|
|
253
|
-
const { subPath, wildcard } = normalizeSubPath(rest);
|
|
254
|
-
add(firstKey, wildcard ? "" : subPath);
|
|
281
|
+
addCtxUsage(`ctx.${match[1] || ""}`);
|
|
255
282
|
}
|
|
256
283
|
const bracketRootRe = /ctx\s*\[\s*(['"])([a-zA-Z_$][a-zA-Z0-9_$]*)\1\s*\]((?:(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)|(?:\[[^\]]+\]))*)(?!\s*\()/g;
|
|
257
284
|
while (match = bracketRootRe.exec(srcWithStrings)) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
285
|
+
addCtxUsage(`ctx['${match[2] || ""}']${match[3] || ""}`);
|
|
286
|
+
}
|
|
287
|
+
const getVarRe = /ctx\.getVar\s*\(\s*(['"])((?:\\.|(?!\1)[\s\S])*)\1\s*\)/g;
|
|
288
|
+
while (match = getVarRe.exec(srcWithStrings)) {
|
|
289
|
+
const expr = String(match[2] || "").replace(/\\'/g, "'").replace(/\\"/g, '"').trim();
|
|
290
|
+
if (!expr.startsWith("ctx")) continue;
|
|
291
|
+
addCtxUsage(expr);
|
|
262
292
|
}
|
|
263
293
|
const out = {};
|
|
264
294
|
for (const [k, set] of usage.entries()) {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type { ISchema } from '@formily/json-schema';
|
|
10
10
|
import type { FlowModel } from '../models';
|
|
11
11
|
import { FlowRuntimeContext } from '../flowContext';
|
|
12
|
-
import type { StepDefinition, StepUIMode } from '../types';
|
|
12
|
+
import type { EventDefinition, StepDefinition, StepUIMode } from '../types';
|
|
13
13
|
/**
|
|
14
14
|
* 解析 uiMode,支持静态值和函数形式
|
|
15
15
|
* 函数可以接收 FlowRuntimeContext
|
|
@@ -38,6 +38,12 @@ export declare function compileUiSchema(scope: Record<string, any>, uiSchema: an
|
|
|
38
38
|
* @returns 合并后的uiSchema对象,如果为空则返回null
|
|
39
39
|
*/
|
|
40
40
|
export declare function resolveStepUiSchema<TModel extends FlowModel = FlowModel>(model: TModel, flow: any, step: StepDefinition): Promise<Record<string, ISchema> | null>;
|
|
41
|
+
/**
|
|
42
|
+
* 判断事件在设置菜单中是否应被隐藏。
|
|
43
|
+
* - 支持 EventDefinition.hideInSettings。
|
|
44
|
+
* - hideInSettings 可为布尔值或函数(接收 FlowRuntimeContext)。
|
|
45
|
+
*/
|
|
46
|
+
export declare function shouldHideEventInSettings<TModel extends FlowModel = FlowModel>(model: TModel, flow: any, event: EventDefinition<TModel> | undefined): Promise<boolean>;
|
|
41
47
|
/**
|
|
42
48
|
* 判断步骤在设置菜单中是否应被隐藏。
|
|
43
49
|
* - 支持 StepDefinition.hideInSettings 与 ActionDefinition.hideInSettings(step 优先)。
|
|
@@ -31,6 +31,7 @@ __export(schema_utils_exports, {
|
|
|
31
31
|
resolveStepDisabledInSettings: () => resolveStepDisabledInSettings,
|
|
32
32
|
resolveStepUiSchema: () => resolveStepUiSchema,
|
|
33
33
|
resolveUiMode: () => resolveUiMode,
|
|
34
|
+
shouldHideEventInSettings: () => shouldHideEventInSettings,
|
|
34
35
|
shouldHideStepInSettings: () => shouldHideStepInSettings
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(schema_utils_exports);
|
|
@@ -195,6 +196,23 @@ async function resolveStepUiSchema(model, flow, step) {
|
|
|
195
196
|
return resolvedStepUiSchema;
|
|
196
197
|
}
|
|
197
198
|
__name(resolveStepUiSchema, "resolveStepUiSchema");
|
|
199
|
+
async function shouldHideEventInSettings(model, flow, event) {
|
|
200
|
+
if (!event) return true;
|
|
201
|
+
const { hideInSettings } = event;
|
|
202
|
+
if (typeof hideInSettings === "function") {
|
|
203
|
+
try {
|
|
204
|
+
const ctx = new import_flowContext.FlowRuntimeContext(model, flow.key, "settings");
|
|
205
|
+
(0, import_setupRuntimeContextSteps.setupRuntimeContextSteps)(ctx, flow.steps || {}, model, flow.key);
|
|
206
|
+
const result = await hideInSettings(ctx);
|
|
207
|
+
return !!result;
|
|
208
|
+
} catch (error) {
|
|
209
|
+
console.warn(`Error evaluating hideInSettings for event '${event.name || ""}' in flow '${flow.key}':`, error);
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return !!hideInSettings;
|
|
214
|
+
}
|
|
215
|
+
__name(shouldHideEventInSettings, "shouldHideEventInSettings");
|
|
198
216
|
async function shouldHideStepInSettings(model, flow, step) {
|
|
199
217
|
var _a;
|
|
200
218
|
if (!step) return true;
|
|
@@ -283,5 +301,6 @@ __name(resolveStepDisabledInSettings, "resolveStepDisabledInSettings");
|
|
|
283
301
|
resolveStepDisabledInSettings,
|
|
284
302
|
resolveStepUiSchema,
|
|
285
303
|
resolveUiMode,
|
|
304
|
+
shouldHideEventInSettings,
|
|
286
305
|
shouldHideStepInSettings
|
|
287
306
|
});
|
package/lib/views/FlowView.d.ts
CHANGED
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
import { PopoverProps as AntdPopoverProps } from 'antd';
|
|
11
11
|
import { FlowContext } from '../flowContext';
|
|
12
12
|
import { ViewNavigation } from './ViewNavigation';
|
|
13
|
+
export type FlowViewBeforeClosePayload = {
|
|
14
|
+
result?: any;
|
|
15
|
+
force?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type FlowViewBeforeCloseHandler = (payload: FlowViewBeforeClosePayload) => Promise<boolean | void> | boolean | void;
|
|
13
18
|
export type FlowView = {
|
|
14
19
|
type: 'drawer' | 'popover' | 'dialog' | 'embed';
|
|
15
20
|
inputArgs: any;
|
|
@@ -20,8 +25,9 @@ export type FlowView = {
|
|
|
20
25
|
Footer: React.FC<{
|
|
21
26
|
children?: React.ReactNode;
|
|
22
27
|
}> | null;
|
|
23
|
-
close: (result?: any, force?: boolean) => void;
|
|
28
|
+
close: (result?: any, force?: boolean) => Promise<boolean | void> | boolean | void;
|
|
24
29
|
update: (newConfig: any) => void;
|
|
30
|
+
beforeClose?: FlowViewBeforeCloseHandler;
|
|
25
31
|
navigation?: ViewNavigation;
|
|
26
32
|
/** 页面的销毁方法 */
|
|
27
33
|
destroy?: () => void;
|
package/lib/views/FlowView.js
CHANGED
|
@@ -47,11 +47,21 @@ const _FlowViewer = class _FlowViewer {
|
|
|
47
47
|
if (this.types[type]) {
|
|
48
48
|
zIndex += 1;
|
|
49
49
|
const onClose = others.onClose;
|
|
50
|
+
let zIndexReleased = false;
|
|
51
|
+
const releaseZIndex = /* @__PURE__ */ __name(() => {
|
|
52
|
+
if (!zIndexReleased) {
|
|
53
|
+
zIndexReleased = true;
|
|
54
|
+
zIndex -= 1;
|
|
55
|
+
}
|
|
56
|
+
}, "releaseZIndex");
|
|
50
57
|
const _zIndex = others.zIndex;
|
|
51
58
|
others.onClose = (...args) => {
|
|
52
59
|
onClose == null ? void 0 : onClose(...args);
|
|
53
|
-
|
|
60
|
+
releaseZIndex();
|
|
54
61
|
};
|
|
62
|
+
if (type === "embed") {
|
|
63
|
+
others.onOpenCancelled = releaseZIndex;
|
|
64
|
+
}
|
|
55
65
|
if (type !== "embed") {
|
|
56
66
|
others.zIndex = _zIndex ?? this.getNextZIndex();
|
|
57
67
|
}
|
|
@@ -55,8 +55,9 @@ const PageComponent = (0, import_react.forwardRef)((props, ref) => {
|
|
|
55
55
|
hidden,
|
|
56
56
|
title: _title,
|
|
57
57
|
styles = {},
|
|
58
|
-
zIndex = 4
|
|
58
|
+
zIndex = 4,
|
|
59
59
|
// 这个默认值是为了防止表格的阴影显示到子页面上面
|
|
60
|
+
onClose
|
|
60
61
|
} = mergedProps;
|
|
61
62
|
const closedRef = (0, import_react.useRef)(false);
|
|
62
63
|
const flowEngine = (0, import_provider.useFlowEngine)();
|
|
@@ -114,11 +115,12 @@ const PageComponent = (0, import_react.forwardRef)((props, ref) => {
|
|
|
114
115
|
type: "text",
|
|
115
116
|
size: "small",
|
|
116
117
|
icon: /* @__PURE__ */ import_react.default.createElement(import_icons.CloseOutlined, null),
|
|
117
|
-
onClick: () => {
|
|
118
|
-
var _a;
|
|
118
|
+
onClick: async () => {
|
|
119
119
|
if (!closedRef.current) {
|
|
120
|
-
|
|
121
|
-
(
|
|
120
|
+
const closed = await (onClose == null ? void 0 : onClose());
|
|
121
|
+
if (closed !== false) {
|
|
122
|
+
closedRef.current = true;
|
|
123
|
+
}
|
|
122
124
|
}
|
|
123
125
|
},
|
|
124
126
|
style: {
|
|
@@ -138,7 +140,7 @@ const PageComponent = (0, import_react.forwardRef)((props, ref) => {
|
|
|
138
140
|
)),
|
|
139
141
|
extra && /* @__PURE__ */ import_react.default.createElement("div", null, extra)
|
|
140
142
|
);
|
|
141
|
-
}, [header, _title, flowEngine.context.themeToken, styles.header,
|
|
143
|
+
}, [header, _title, flowEngine.context.themeToken, styles.header, onClose]);
|
|
142
144
|
const FooterComponent = (0, import_react.useMemo)(() => {
|
|
143
145
|
if (!footer) return null;
|
|
144
146
|
const token = flowEngine.context.themeToken;
|
|
@@ -11,6 +11,14 @@ import { ViewParam as SharedViewParam } from '../utils';
|
|
|
11
11
|
type ViewParams = Omit<SharedViewParam, 'viewUid'> & {
|
|
12
12
|
viewUid?: string;
|
|
13
13
|
};
|
|
14
|
+
export interface GeneratePathnameFromViewParamsOptions {
|
|
15
|
+
prefix?: string;
|
|
16
|
+
basePath?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ViewNavigationOptions {
|
|
19
|
+
basePath?: string;
|
|
20
|
+
layoutBasePath?: string;
|
|
21
|
+
}
|
|
14
22
|
/**
|
|
15
23
|
* 将 ViewParam 数组转换为 pathname
|
|
16
24
|
*
|
|
@@ -24,12 +32,13 @@ type ViewParams = Omit<SharedViewParam, 'viewUid'> & {
|
|
|
24
32
|
* generatePathnameFromViewParams([{ viewUid: 'xxx' }, { viewUid: 'yyy' }]) // '/admin/xxx/view/yyy'
|
|
25
33
|
* ```
|
|
26
34
|
*/
|
|
27
|
-
export declare function generatePathnameFromViewParams(viewParams: ViewParams[]): string;
|
|
35
|
+
export declare function generatePathnameFromViewParams(viewParams: ViewParams[], options?: GeneratePathnameFromViewParamsOptions): string;
|
|
28
36
|
export declare class ViewNavigation {
|
|
29
37
|
viewStack: ReadonlyArray<ViewParams>;
|
|
30
38
|
ctx: FlowEngineContext;
|
|
31
39
|
viewParams: ViewParams;
|
|
32
|
-
|
|
40
|
+
private readonly basePath?;
|
|
41
|
+
constructor(ctx: FlowEngineContext, viewParams: ViewParams[], options?: ViewNavigationOptions);
|
|
33
42
|
setViewStack(viewParams: ViewParams[]): void;
|
|
34
43
|
changeTo(viewParam: ViewParams): void;
|
|
35
44
|
navigateTo(viewParam: ViewParams, opts?: {
|
|
@@ -37,5 +46,6 @@ export declare class ViewNavigation {
|
|
|
37
46
|
state?: any;
|
|
38
47
|
}): void;
|
|
39
48
|
back(): void;
|
|
49
|
+
private getLayoutBasePath;
|
|
40
50
|
}
|
|
41
51
|
export {};
|
|
@@ -43,11 +43,21 @@ function encodeFilterByTk(val) {
|
|
|
43
43
|
return encodeURIComponent(String(val));
|
|
44
44
|
}
|
|
45
45
|
__name(encodeFilterByTk, "encodeFilterByTk");
|
|
46
|
-
function
|
|
46
|
+
function hasUsableSourceId(sourceId) {
|
|
47
|
+
return sourceId !== void 0 && sourceId !== null && String(sourceId) !== "";
|
|
48
|
+
}
|
|
49
|
+
__name(hasUsableSourceId, "hasUsableSourceId");
|
|
50
|
+
function normalizeBasePath(basePath) {
|
|
51
|
+
const value = basePath || "/admin";
|
|
52
|
+
return `/${value.replace(/^\/+/, "").replace(/\/+$/, "")}`;
|
|
53
|
+
}
|
|
54
|
+
__name(normalizeBasePath, "normalizeBasePath");
|
|
55
|
+
function generatePathnameFromViewParams(viewParams, options = {}) {
|
|
56
|
+
const basePath = normalizeBasePath(options.basePath || options.prefix);
|
|
47
57
|
if (!viewParams || viewParams.length === 0) {
|
|
48
|
-
return
|
|
58
|
+
return basePath;
|
|
49
59
|
}
|
|
50
|
-
const segments =
|
|
60
|
+
const segments = basePath.replace(/^\/+/, "").split("/").filter(Boolean);
|
|
51
61
|
viewParams.forEach((viewParam, index) => {
|
|
52
62
|
if (index > 0) {
|
|
53
63
|
segments.push("view");
|
|
@@ -62,8 +72,8 @@ function generatePathnameFromViewParams(viewParams) {
|
|
|
62
72
|
segments.push("filterbytk", encoded);
|
|
63
73
|
}
|
|
64
74
|
}
|
|
65
|
-
if (viewParam.sourceId) {
|
|
66
|
-
segments.push("sourceid", viewParam.sourceId);
|
|
75
|
+
if (hasUsableSourceId(viewParam.sourceId)) {
|
|
76
|
+
segments.push("sourceid", String(viewParam.sourceId));
|
|
67
77
|
}
|
|
68
78
|
});
|
|
69
79
|
return "/" + segments.join("/");
|
|
@@ -74,9 +84,11 @@ const _ViewNavigation = class _ViewNavigation {
|
|
|
74
84
|
// 只能通过 setViewStack 修改
|
|
75
85
|
ctx;
|
|
76
86
|
viewParams;
|
|
77
|
-
|
|
87
|
+
basePath;
|
|
88
|
+
constructor(ctx, viewParams, options = {}) {
|
|
78
89
|
this.setViewStack(viewParams);
|
|
79
90
|
this.ctx = ctx;
|
|
91
|
+
this.basePath = options.basePath || options.layoutBasePath;
|
|
80
92
|
(0, import_reactive.define)(this, {
|
|
81
93
|
viewParams: import_reactive.observable
|
|
82
94
|
});
|
|
@@ -92,19 +104,26 @@ const _ViewNavigation = class _ViewNavigation {
|
|
|
92
104
|
}
|
|
93
105
|
return { ...item };
|
|
94
106
|
});
|
|
95
|
-
const newPathname = generatePathnameFromViewParams(newViewStack);
|
|
107
|
+
const newPathname = generatePathnameFromViewParams(newViewStack, { basePath: this.getLayoutBasePath() });
|
|
96
108
|
this.ctx.router.navigate(newPathname, { replace: true });
|
|
97
109
|
}
|
|
98
110
|
navigateTo(viewParam, opts) {
|
|
99
|
-
const newViewPathname = generatePathnameFromViewParams([...this.viewStack, viewParam]
|
|
111
|
+
const newViewPathname = generatePathnameFromViewParams([...this.viewStack, viewParam], {
|
|
112
|
+
basePath: this.getLayoutBasePath()
|
|
113
|
+
});
|
|
100
114
|
const newPathname = newViewPathname;
|
|
101
115
|
this.ctx.router.navigate(newPathname, opts);
|
|
102
116
|
}
|
|
103
117
|
back() {
|
|
104
118
|
const prevStack = this.viewStack.slice(0, -1);
|
|
105
|
-
const prevPath = generatePathnameFromViewParams(prevStack);
|
|
119
|
+
const prevPath = generatePathnameFromViewParams(prevStack, { basePath: this.getLayoutBasePath() });
|
|
106
120
|
this.ctx.router.navigate(prevPath, { replace: true });
|
|
107
121
|
}
|
|
122
|
+
getLayoutBasePath() {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
const routePath = (_a = this.ctx.layout) == null ? void 0 : _a.routePath;
|
|
125
|
+
return this.basePath || ((_b = this.ctx.layoutRoute) == null ? void 0 : _b.basePathname) || ((routePath == null ? void 0 : routePath.startsWith("/")) ? routePath : "/admin");
|
|
126
|
+
}
|
|
108
127
|
};
|
|
109
128
|
__name(_ViewNavigation, "ViewNavigation");
|
|
110
129
|
let ViewNavigation = _ViewNavigation;
|
|
@@ -33,6 +33,75 @@ __export(createViewMeta_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(createViewMeta_exports);
|
|
35
35
|
var import_variablesParams = require("../utils/variablesParams");
|
|
36
|
+
function isDefined(value) {
|
|
37
|
+
return value !== void 0 && value !== null;
|
|
38
|
+
}
|
|
39
|
+
__name(isDefined, "isDefined");
|
|
40
|
+
function isSameViewParamValue(left, right) {
|
|
41
|
+
if (left === right) return true;
|
|
42
|
+
if (!isDefined(left) || !isDefined(right)) return false;
|
|
43
|
+
try {
|
|
44
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
45
|
+
} catch (_) {
|
|
46
|
+
return String(left) === String(right);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
__name(isSameViewParamValue, "isSameViewParamValue");
|
|
50
|
+
function getViewStack(view) {
|
|
51
|
+
var _a;
|
|
52
|
+
const stack = (_a = view == null ? void 0 : view.navigation) == null ? void 0 : _a.viewStack;
|
|
53
|
+
return Array.isArray(stack) ? stack : [];
|
|
54
|
+
}
|
|
55
|
+
__name(getViewStack, "getViewStack");
|
|
56
|
+
function getAnchoredViewStackIndex(view, stack = getViewStack(view)) {
|
|
57
|
+
var _a;
|
|
58
|
+
if (!stack.length) return -1;
|
|
59
|
+
const args = (view == null ? void 0 : view.inputArgs) || {};
|
|
60
|
+
const navParams = ((_a = view == null ? void 0 : view.navigation) == null ? void 0 : _a.viewParams) || {};
|
|
61
|
+
const viewUid = args.viewUid ?? navParams.viewUid;
|
|
62
|
+
if (!viewUid) {
|
|
63
|
+
return stack.length - 1;
|
|
64
|
+
}
|
|
65
|
+
const candidates = stack.map((item, index) => ({ item, index })).filter(({ item }) => (item == null ? void 0 : item.viewUid) === viewUid);
|
|
66
|
+
if (!candidates.length) {
|
|
67
|
+
return stack.length - 1;
|
|
68
|
+
}
|
|
69
|
+
const keys = ["filterByTk", "sourceId", "tabUid"];
|
|
70
|
+
let bestIndex = candidates[candidates.length - 1].index;
|
|
71
|
+
let bestScore = -1;
|
|
72
|
+
for (const { item, index } of candidates) {
|
|
73
|
+
let score = 0;
|
|
74
|
+
let matched = true;
|
|
75
|
+
for (const key of keys) {
|
|
76
|
+
if (!isDefined(args[key])) continue;
|
|
77
|
+
if (!isSameViewParamValue(item == null ? void 0 : item[key], args[key])) {
|
|
78
|
+
matched = false;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
score += 1;
|
|
82
|
+
}
|
|
83
|
+
if (!matched) continue;
|
|
84
|
+
if (score >= bestScore) {
|
|
85
|
+
bestIndex = index;
|
|
86
|
+
bestScore = score;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return bestIndex;
|
|
90
|
+
}
|
|
91
|
+
__name(getAnchoredViewStackIndex, "getAnchoredViewStackIndex");
|
|
92
|
+
function getPopupView(ctx, anchorView) {
|
|
93
|
+
return anchorView ?? ctx.view;
|
|
94
|
+
}
|
|
95
|
+
__name(getPopupView, "getPopupView");
|
|
96
|
+
function isPopupView(view) {
|
|
97
|
+
var _a;
|
|
98
|
+
if (!view) return false;
|
|
99
|
+
const stack = getViewStack(view);
|
|
100
|
+
const openerUids = (_a = view == null ? void 0 : view.inputArgs) == null ? void 0 : _a.openerUids;
|
|
101
|
+
const hasOpener = Array.isArray(openerUids) && openerUids.length > 0;
|
|
102
|
+
return getAnchoredViewStackIndex(view, stack) >= 1 || hasOpener;
|
|
103
|
+
}
|
|
104
|
+
__name(isPopupView, "isPopupView");
|
|
36
105
|
function isPlainObject(val) {
|
|
37
106
|
if (val === null || typeof val !== "object") return false;
|
|
38
107
|
const proto = Object.getPrototypeOf(val);
|
|
@@ -83,17 +152,9 @@ function makeMetaFromValue(value, title, seen) {
|
|
|
83
152
|
__name(makeMetaFromValue, "makeMetaFromValue");
|
|
84
153
|
function createPopupMeta(ctx, anchorView) {
|
|
85
154
|
const t = /* @__PURE__ */ __name((k) => ctx.t(k), "t");
|
|
86
|
-
const
|
|
87
|
-
var _a, _b;
|
|
88
|
-
if (!view) return false;
|
|
89
|
-
const stack = Array.isArray((_a = view.navigation) == null ? void 0 : _a.viewStack) ? view.navigation.viewStack : [];
|
|
90
|
-
const openerUids = (_b = view == null ? void 0 : view.inputArgs) == null ? void 0 : _b.openerUids;
|
|
91
|
-
const hasOpener = Array.isArray(openerUids) && openerUids.length > 0;
|
|
92
|
-
return stack.length >= 2 || hasOpener;
|
|
93
|
-
}, "isPopupView");
|
|
94
|
-
const hasPopupNow = /* @__PURE__ */ __name(() => isPopupView(anchorView ?? ctx.view), "hasPopupNow");
|
|
155
|
+
const hasPopupNow = /* @__PURE__ */ __name((flowCtx = ctx) => isPopupView(getPopupView(flowCtx, anchorView)), "hasPopupNow");
|
|
95
156
|
const resolveRecordRef = /* @__PURE__ */ __name(async (flowCtx) => {
|
|
96
|
-
const view = anchorView
|
|
157
|
+
const view = getPopupView(flowCtx, anchorView);
|
|
97
158
|
if (!view || !isPopupView(view)) return void 0;
|
|
98
159
|
const base = await buildPopupRuntime(flowCtx, view);
|
|
99
160
|
const res = base == null ? void 0 : base.resource;
|
|
@@ -116,25 +177,26 @@ function createPopupMeta(ctx, anchorView) {
|
|
|
116
177
|
return ((_d = (_c = ds == null ? void 0 : ds.collectionManager) == null ? void 0 : _c.getCollection) == null ? void 0 : _d.call(_c, ref.collection)) || null;
|
|
117
178
|
}, "getCurrentCollection");
|
|
118
179
|
const getParentRecordRef = /* @__PURE__ */ __name(async (level, flowCtx) => {
|
|
119
|
-
var _a, _b, _c, _d, _e, _f
|
|
180
|
+
var _a, _b, _c, _d, _e, _f;
|
|
120
181
|
try {
|
|
121
182
|
const useCtx = flowCtx || ctx;
|
|
122
|
-
const
|
|
123
|
-
const stack =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
183
|
+
const view = getPopupView(useCtx, anchorView);
|
|
184
|
+
const stack = getViewStack(view);
|
|
185
|
+
const currentIndex = getAnchoredViewStackIndex(view, stack);
|
|
186
|
+
if (currentIndex < 1 || level < 1) return void 0;
|
|
187
|
+
const idx = currentIndex - level;
|
|
188
|
+
if (idx < 1) return void 0;
|
|
127
189
|
const parent = stack[idx];
|
|
128
190
|
if (!(parent == null ? void 0 : parent.viewUid)) return void 0;
|
|
129
|
-
let model = (
|
|
191
|
+
let model = (_a = useCtx.engine) == null ? void 0 : _a.getModel(parent.viewUid, true);
|
|
130
192
|
if (!model) {
|
|
131
193
|
try {
|
|
132
194
|
model = await useCtx.engine.loadModel({ uid: parent.viewUid });
|
|
133
195
|
} catch (e) {
|
|
134
|
-
(
|
|
196
|
+
(_c = (_b = useCtx.logger || ctx.logger) == null ? void 0 : _b.warn) == null ? void 0 : _c.call(_b, { err: e }, "[FlowEngine] popup.getParentRecordRef loadModel failed");
|
|
135
197
|
}
|
|
136
198
|
}
|
|
137
|
-
const params = ((
|
|
199
|
+
const params = ((_d = model == null ? void 0 : model.getStepParams) == null ? void 0 : _d.call(model, "popupSettings", "openView")) || {};
|
|
138
200
|
const collection = params == null ? void 0 : params.collectionName;
|
|
139
201
|
const dataSourceKey = (params == null ? void 0 : params.dataSourceKey) || "main";
|
|
140
202
|
const filterByTk = (parent == null ? void 0 : parent.filterByTk) ?? (parent == null ? void 0 : parent.sourceId);
|
|
@@ -148,16 +210,16 @@ function createPopupMeta(ctx, anchorView) {
|
|
|
148
210
|
};
|
|
149
211
|
return ref;
|
|
150
212
|
} catch (e) {
|
|
151
|
-
(
|
|
213
|
+
(_f = (_e = (flowCtx == null ? void 0 : flowCtx.logger) || ctx.logger) == null ? void 0 : _e.warn) == null ? void 0 : _f.call(_e, { err: e }, "[FlowEngine] popup.getParentRecordRef failed");
|
|
152
214
|
return void 0;
|
|
153
215
|
}
|
|
154
216
|
}, "getParentRecordRef");
|
|
155
217
|
const hasParentNow = /* @__PURE__ */ __name((level) => {
|
|
156
|
-
var _a;
|
|
157
218
|
try {
|
|
158
|
-
const
|
|
159
|
-
const stack =
|
|
160
|
-
|
|
219
|
+
const view = getPopupView(ctx, anchorView);
|
|
220
|
+
const stack = getViewStack(view);
|
|
221
|
+
const currentIndex = getAnchoredViewStackIndex(view, stack);
|
|
222
|
+
return currentIndex - level >= 1;
|
|
161
223
|
} catch (_) {
|
|
162
224
|
return false;
|
|
163
225
|
}
|
|
@@ -220,10 +282,11 @@ function createPopupMeta(ctx, anchorView) {
|
|
|
220
282
|
disabled: /* @__PURE__ */ __name(() => !hasPopupNow(), "disabled"),
|
|
221
283
|
hidden: /* @__PURE__ */ __name(() => !hasPopupNow(), "hidden"),
|
|
222
284
|
buildVariablesParams: /* @__PURE__ */ __name(async (c) => {
|
|
223
|
-
var _a, _b, _c, _d
|
|
224
|
-
if (!hasPopupNow()) return void 0;
|
|
285
|
+
var _a, _b, _c, _d;
|
|
286
|
+
if (!hasPopupNow(c)) return void 0;
|
|
225
287
|
const ref = await resolveRecordRef(c);
|
|
226
|
-
const
|
|
288
|
+
const view = getPopupView(c, anchorView);
|
|
289
|
+
const inputArgs = view == null ? void 0 : view.inputArgs;
|
|
227
290
|
const params = {};
|
|
228
291
|
if (ref) {
|
|
229
292
|
const merged = { ...ref };
|
|
@@ -236,9 +299,9 @@ function createPopupMeta(ctx, anchorView) {
|
|
|
236
299
|
params.record = merged;
|
|
237
300
|
}
|
|
238
301
|
try {
|
|
239
|
-
const
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
302
|
+
const stack = getViewStack(view);
|
|
303
|
+
const currentIndex = getAnchoredViewStackIndex(view, stack);
|
|
304
|
+
if (currentIndex >= 2) {
|
|
242
305
|
let cur = params;
|
|
243
306
|
let level = 1;
|
|
244
307
|
let parentRef = await getParentRecordRef(level, c);
|
|
@@ -251,7 +314,7 @@ function createPopupMeta(ctx, anchorView) {
|
|
|
251
314
|
}
|
|
252
315
|
}
|
|
253
316
|
} catch (err) {
|
|
254
|
-
(
|
|
317
|
+
(_b = (_a = c.logger) == null ? void 0 : _a.debug) == null ? void 0 : _b.call(_a, { err }, "[FlowEngine] buildVariablesParams: build parent-chain failed");
|
|
255
318
|
}
|
|
256
319
|
try {
|
|
257
320
|
const srcId = inputArgs == null ? void 0 : inputArgs.sourceId;
|
|
@@ -268,12 +331,12 @@ function createPopupMeta(ctx, anchorView) {
|
|
|
268
331
|
}
|
|
269
332
|
}
|
|
270
333
|
} catch (err) {
|
|
271
|
-
(
|
|
334
|
+
(_d = (_c = c.logger) == null ? void 0 : _c.debug) == null ? void 0 : _d.call(_c, { err }, "[FlowEngine] buildVariablesParams: infer sourceRecord failed");
|
|
272
335
|
}
|
|
273
336
|
return params;
|
|
274
337
|
}, "buildVariablesParams"),
|
|
275
338
|
properties: /* @__PURE__ */ __name(async () => {
|
|
276
|
-
var _a, _b, _c, _d
|
|
339
|
+
var _a, _b, _c, _d;
|
|
277
340
|
const props = {};
|
|
278
341
|
props.uid = { type: "string", title: t("Popup uid") };
|
|
279
342
|
const recordRef = await resolveRecordRef(ctx);
|
|
@@ -292,20 +355,21 @@ function createPopupMeta(ctx, anchorView) {
|
|
|
292
355
|
props.record = recordFactory;
|
|
293
356
|
}
|
|
294
357
|
try {
|
|
295
|
-
const
|
|
358
|
+
const view = getPopupView(ctx, anchorView);
|
|
359
|
+
const inputArgs = view == null ? void 0 : view.inputArgs;
|
|
296
360
|
const srcId = inputArgs == null ? void 0 : inputArgs.sourceId;
|
|
297
361
|
let assoc = inputArgs == null ? void 0 : inputArgs.associationName;
|
|
298
362
|
let dsKey = (inputArgs == null ? void 0 : inputArgs.dataSourceKey) || "main";
|
|
299
363
|
if (!assoc || typeof assoc !== "string" || !assoc.includes(".")) {
|
|
300
|
-
const
|
|
301
|
-
const
|
|
302
|
-
const
|
|
303
|
-
if (
|
|
304
|
-
let model = (
|
|
364
|
+
const stack = getViewStack(view);
|
|
365
|
+
const currentIndex = getAnchoredViewStackIndex(view, stack);
|
|
366
|
+
const current = currentIndex >= 0 ? stack == null ? void 0 : stack[currentIndex] : void 0;
|
|
367
|
+
if (current == null ? void 0 : current.viewUid) {
|
|
368
|
+
let model = (_a = ctx == null ? void 0 : ctx.engine) == null ? void 0 : _a.getModel(current.viewUid, true);
|
|
305
369
|
if (!model) {
|
|
306
|
-
model = await ctx.engine.loadModel({ uid:
|
|
370
|
+
model = await ctx.engine.loadModel({ uid: current.viewUid });
|
|
307
371
|
}
|
|
308
|
-
const p = ((
|
|
372
|
+
const p = ((_b = model == null ? void 0 : model.getStepParams) == null ? void 0 : _b.call(model, "popupSettings", "openView")) || {};
|
|
309
373
|
assoc = (p == null ? void 0 : p.associationName) || assoc;
|
|
310
374
|
dsKey = (p == null ? void 0 : p.dataSourceKey) || dsKey;
|
|
311
375
|
}
|
|
@@ -333,7 +397,7 @@ function createPopupMeta(ctx, anchorView) {
|
|
|
333
397
|
}
|
|
334
398
|
}
|
|
335
399
|
} catch (err) {
|
|
336
|
-
(
|
|
400
|
+
(_d = (_c = ctx.logger) == null ? void 0 : _c.debug) == null ? void 0 : _d.call(_c, { err }, "[FlowEngine] popup.properties: build sourceRecord failed");
|
|
337
401
|
}
|
|
338
402
|
const resourceMeta = {
|
|
339
403
|
type: "object",
|
|
@@ -362,12 +426,12 @@ function createPopupMeta(ctx, anchorView) {
|
|
|
362
426
|
}
|
|
363
427
|
__name(createPopupMeta, "createPopupMeta");
|
|
364
428
|
async function buildPopupRuntime(ctx, view) {
|
|
365
|
-
var _a
|
|
366
|
-
const
|
|
367
|
-
const
|
|
429
|
+
var _a;
|
|
430
|
+
const stack = getViewStack(view);
|
|
431
|
+
const currentIndex = getAnchoredViewStackIndex(view, stack);
|
|
368
432
|
const openerUids = (_a = view == null ? void 0 : view.inputArgs) == null ? void 0 : _a.openerUids;
|
|
369
433
|
const hasOpener = Array.isArray(openerUids) && openerUids.length > 0;
|
|
370
|
-
const hasStackPopup =
|
|
434
|
+
const hasStackPopup = currentIndex >= 1;
|
|
371
435
|
const isPopup = hasStackPopup || hasOpener;
|
|
372
436
|
if (!isPopup) return void 0;
|
|
373
437
|
if (!stack.length) {
|
|
@@ -386,12 +450,12 @@ async function buildPopupRuntime(ctx, view) {
|
|
|
386
450
|
};
|
|
387
451
|
}
|
|
388
452
|
const buildNode = /* @__PURE__ */ __name(async (idx) => {
|
|
389
|
-
var _a2,
|
|
453
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
390
454
|
if (idx < 0 || !((_a2 = stack[idx]) == null ? void 0 : _a2.viewUid)) return void 0;
|
|
391
455
|
const viewUid = stack[idx].viewUid;
|
|
392
|
-
let model = (
|
|
456
|
+
let model = (_b = ctx.engine) == null ? void 0 : _b.getModel(viewUid, true);
|
|
393
457
|
if (!model) {
|
|
394
|
-
model = await ((
|
|
458
|
+
model = await ((_c = ctx.engine) == null ? void 0 : _c.loadModel({ uid: viewUid }));
|
|
395
459
|
}
|
|
396
460
|
const p = ((_d = model == null ? void 0 : model.getStepParams) == null ? void 0 : _d.call(model, "popupSettings", "openView")) || {};
|
|
397
461
|
const collectionName = p == null ? void 0 : p.collectionName;
|
|
@@ -410,7 +474,7 @@ async function buildPopupRuntime(ctx, view) {
|
|
|
410
474
|
if (parentNode) node.parent = parentNode;
|
|
411
475
|
return node;
|
|
412
476
|
}, "buildNode");
|
|
413
|
-
const currentNode = await buildNode(
|
|
477
|
+
const currentNode = await buildNode(currentIndex);
|
|
414
478
|
return currentNode;
|
|
415
479
|
}
|
|
416
480
|
__name(buildPopupRuntime, "buildPopupRuntime");
|
|
@@ -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
|
+
import { FlowContext } from '../flowContext';
|
|
10
|
+
export declare function inheritLayoutContextForDetachedView(viewContext: FlowContext, sourceContext: FlowContext): void;
|