@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.
Files changed (209) hide show
  1. package/LICENSE +201 -661
  2. package/README.md +79 -10
  3. package/lib/FlowContextProvider.d.ts +5 -1
  4. package/lib/FlowContextProvider.js +9 -2
  5. package/lib/JSRunner.d.ts +10 -1
  6. package/lib/JSRunner.js +50 -5
  7. package/lib/ViewScopedFlowEngine.js +5 -1
  8. package/lib/components/FieldModelRenderer.js +2 -2
  9. package/lib/components/FlowModelRenderer.d.ts +3 -1
  10. package/lib/components/FlowModelRenderer.js +12 -6
  11. package/lib/components/FormItem.d.ts +6 -0
  12. package/lib/components/FormItem.js +11 -3
  13. package/lib/components/MobilePopup.js +6 -5
  14. package/lib/components/dnd/gridDragPlanner.d.ts +59 -2
  15. package/lib/components/dnd/gridDragPlanner.js +613 -21
  16. package/lib/components/dnd/index.d.ts +31 -2
  17. package/lib/components/dnd/index.js +244 -23
  18. package/lib/components/settings/wrappers/component/SelectWithTitle.d.ts +2 -1
  19. package/lib/components/settings/wrappers/component/SelectWithTitle.js +14 -12
  20. package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.d.ts +3 -0
  21. package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +76 -11
  22. package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +23 -43
  23. package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +352 -295
  24. package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +16 -2
  25. package/lib/components/settings/wrappers/contextual/useFloatToolbarPortal.d.ts +36 -0
  26. package/lib/components/settings/wrappers/contextual/useFloatToolbarPortal.js +274 -0
  27. package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.d.ts +30 -0
  28. package/lib/components/settings/wrappers/contextual/useFloatToolbarVisibility.js +315 -0
  29. package/lib/components/subModel/AddSubModelButton.js +27 -1
  30. package/lib/components/subModel/LazyDropdown.js +293 -52
  31. package/lib/components/subModel/index.d.ts +1 -0
  32. package/lib/components/subModel/index.js +19 -0
  33. package/lib/components/subModel/utils.d.ts +1 -1
  34. package/lib/components/subModel/utils.js +9 -3
  35. package/lib/components/variables/VariableHybridInput.d.ts +27 -0
  36. package/lib/components/variables/VariableHybridInput.js +499 -0
  37. package/lib/components/variables/index.d.ts +2 -0
  38. package/lib/components/variables/index.js +3 -0
  39. package/lib/data-source/index.d.ts +84 -0
  40. package/lib/data-source/index.js +259 -5
  41. package/lib/executor/FlowExecutor.js +32 -9
  42. package/lib/flow-registry/DetachedFlowRegistry.d.ts +21 -0
  43. package/lib/flow-registry/DetachedFlowRegistry.js +80 -0
  44. package/lib/flow-registry/index.d.ts +1 -0
  45. package/lib/flow-registry/index.js +3 -1
  46. package/lib/flowContext.d.ts +3 -0
  47. package/lib/flowContext.js +46 -1
  48. package/lib/flowEngine.d.ts +151 -1
  49. package/lib/flowEngine.js +392 -18
  50. package/lib/flowI18n.js +2 -1
  51. package/lib/flowSettings.d.ts +14 -6
  52. package/lib/flowSettings.js +34 -6
  53. package/lib/index.d.ts +2 -0
  54. package/lib/index.js +7 -0
  55. package/lib/lazy-helper.d.ts +14 -0
  56. package/lib/lazy-helper.js +71 -0
  57. package/lib/locale/en-US.json +1 -0
  58. package/lib/locale/index.d.ts +2 -0
  59. package/lib/locale/zh-CN.json +1 -0
  60. package/lib/models/DisplayItemModel.d.ts +1 -1
  61. package/lib/models/EditableItemModel.d.ts +1 -1
  62. package/lib/models/FilterableItemModel.d.ts +1 -1
  63. package/lib/models/flowModel.d.ts +13 -10
  64. package/lib/models/flowModel.js +81 -21
  65. package/lib/provider.js +38 -23
  66. package/lib/reactive/observer.js +46 -16
  67. package/lib/runjs-context/registry.d.ts +1 -1
  68. package/lib/runjs-context/setup.js +20 -12
  69. package/lib/runjs-context/snippets/index.js +13 -2
  70. package/lib/runjs-context/snippets/scene/detail/set-field-style.snippet.d.ts +11 -0
  71. package/lib/runjs-context/snippets/scene/detail/set-field-style.snippet.js +50 -0
  72. package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.d.ts +11 -0
  73. package/lib/runjs-context/snippets/scene/table/set-cell-style.snippet.js +54 -0
  74. package/lib/scheduler/ModelOperationScheduler.d.ts +5 -1
  75. package/lib/scheduler/ModelOperationScheduler.js +3 -2
  76. package/lib/types.d.ts +50 -2
  77. package/lib/types.js +1 -0
  78. package/lib/utils/createCollectionContextMeta.js +6 -2
  79. package/lib/utils/index.d.ts +3 -2
  80. package/lib/utils/index.js +7 -0
  81. package/lib/utils/parsePathnameToViewParams.d.ts +5 -1
  82. package/lib/utils/parsePathnameToViewParams.js +29 -5
  83. package/lib/utils/randomId.d.ts +39 -0
  84. package/lib/utils/randomId.js +45 -0
  85. package/lib/utils/runjsTemplateCompat.js +1 -1
  86. package/lib/utils/runjsValue.js +41 -11
  87. package/lib/utils/schema-utils.d.ts +7 -1
  88. package/lib/utils/schema-utils.js +19 -0
  89. package/lib/views/FlowView.d.ts +7 -1
  90. package/lib/views/FlowView.js +11 -1
  91. package/lib/views/PageComponent.js +8 -6
  92. package/lib/views/ViewNavigation.d.ts +12 -2
  93. package/lib/views/ViewNavigation.js +28 -9
  94. package/lib/views/createViewMeta.js +114 -50
  95. package/lib/views/inheritLayoutContext.d.ts +10 -0
  96. package/lib/views/inheritLayoutContext.js +50 -0
  97. package/lib/views/runViewBeforeClose.d.ts +10 -0
  98. package/lib/views/runViewBeforeClose.js +45 -0
  99. package/lib/views/useDialog.d.ts +2 -1
  100. package/lib/views/useDialog.js +22 -3
  101. package/lib/views/useDrawer.d.ts +2 -1
  102. package/lib/views/useDrawer.js +22 -3
  103. package/lib/views/usePage.d.ts +5 -11
  104. package/lib/views/usePage.js +304 -144
  105. package/package.json +6 -5
  106. package/src/FlowContextProvider.tsx +9 -1
  107. package/src/JSRunner.ts +68 -4
  108. package/src/ViewScopedFlowEngine.ts +4 -0
  109. package/src/__tests__/JSRunner.test.ts +27 -1
  110. package/src/__tests__/createViewMeta.popup.test.ts +115 -1
  111. package/src/__tests__/flow-engine.test.ts +166 -0
  112. package/src/__tests__/flowContext.test.ts +82 -1
  113. package/src/__tests__/flowEngine.modelLoaders.test.ts +245 -0
  114. package/src/__tests__/flowEngine.removeModel.test.ts +47 -3
  115. package/src/__tests__/flowSettings.test.ts +94 -15
  116. package/src/__tests__/objectVariable.test.ts +24 -0
  117. package/src/__tests__/provider.test.tsx +24 -2
  118. package/src/__tests__/renderHiddenInConfig.test.tsx +6 -6
  119. package/src/__tests__/runjsContext.test.ts +16 -0
  120. package/src/__tests__/runjsContextRuntime.test.ts +2 -0
  121. package/src/__tests__/runjsPreprocessDefault.test.ts +23 -0
  122. package/src/__tests__/runjsSnippets.test.ts +21 -0
  123. package/src/__tests__/viewScopedFlowEngine.test.ts +3 -3
  124. package/src/components/FieldModelRenderer.tsx +2 -1
  125. package/src/components/FlowModelRenderer.tsx +18 -6
  126. package/src/components/FormItem.tsx +7 -1
  127. package/src/components/MobilePopup.tsx +4 -2
  128. package/src/components/__tests__/FlowModelRenderer.test.tsx +65 -2
  129. package/src/components/__tests__/FormItem.test.tsx +25 -0
  130. package/src/components/__tests__/dnd.test.ts +44 -0
  131. package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +20 -10
  132. package/src/components/__tests__/gridDragPlanner.test.ts +558 -3
  133. package/src/components/dnd/__tests__/DndProvider.test.tsx +98 -0
  134. package/src/components/dnd/gridDragPlanner.ts +758 -19
  135. package/src/components/dnd/index.tsx +305 -28
  136. package/src/components/settings/wrappers/component/SelectWithTitle.tsx +21 -9
  137. package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +99 -11
  138. package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +487 -440
  139. package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +18 -2
  140. package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +194 -5
  141. package/src/components/settings/wrappers/contextual/__tests__/FlowsFloatContextMenu.test.tsx +778 -0
  142. package/src/components/settings/wrappers/contextual/useFloatToolbarPortal.ts +360 -0
  143. package/src/components/settings/wrappers/contextual/useFloatToolbarVisibility.ts +361 -0
  144. package/src/components/subModel/AddSubModelButton.tsx +32 -2
  145. package/src/components/subModel/LazyDropdown.tsx +332 -56
  146. package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +522 -37
  147. package/src/components/subModel/__tests__/utils.test.ts +24 -0
  148. package/src/components/subModel/index.ts +1 -0
  149. package/src/components/subModel/utils.ts +7 -1
  150. package/src/components/variables/VariableHybridInput.tsx +531 -0
  151. package/src/components/variables/index.ts +2 -0
  152. package/src/data-source/__tests__/collection.test.ts +41 -2
  153. package/src/data-source/__tests__/index.test.ts +68 -1
  154. package/src/data-source/index.ts +322 -6
  155. package/src/executor/FlowExecutor.ts +35 -10
  156. package/src/executor/__tests__/flowExecutor.test.ts +85 -0
  157. package/src/flow-registry/DetachedFlowRegistry.ts +46 -0
  158. package/src/flow-registry/__tests__/detachedFlowRegistry.test.ts +47 -0
  159. package/src/flow-registry/index.ts +1 -0
  160. package/src/flowContext.ts +50 -3
  161. package/src/flowEngine.ts +449 -14
  162. package/src/flowI18n.ts +2 -1
  163. package/src/flowSettings.ts +40 -6
  164. package/src/index.ts +2 -0
  165. package/src/lazy-helper.tsx +57 -0
  166. package/src/locale/en-US.json +1 -0
  167. package/src/locale/zh-CN.json +1 -0
  168. package/src/models/DisplayItemModel.tsx +1 -1
  169. package/src/models/EditableItemModel.tsx +1 -1
  170. package/src/models/FilterableItemModel.tsx +1 -1
  171. package/src/models/__tests__/dispatchEvent.when.test.ts +214 -0
  172. package/src/models/__tests__/flowEngine.resolveUse.test.ts +0 -15
  173. package/src/models/__tests__/flowModel.test.ts +80 -37
  174. package/src/models/flowModel.tsx +122 -36
  175. package/src/provider.tsx +41 -25
  176. package/src/reactive/__tests__/observer.test.tsx +82 -0
  177. package/src/reactive/observer.tsx +87 -25
  178. package/src/runjs-context/registry.ts +1 -1
  179. package/src/runjs-context/setup.ts +22 -12
  180. package/src/runjs-context/snippets/index.ts +12 -1
  181. package/src/runjs-context/snippets/scene/detail/set-field-style.snippet.ts +30 -0
  182. package/src/runjs-context/snippets/scene/table/set-cell-style.snippet.ts +34 -0
  183. package/src/scheduler/ModelOperationScheduler.ts +14 -3
  184. package/src/types.ts +62 -0
  185. package/src/utils/__tests__/createCollectionContextMeta.test.ts +48 -0
  186. package/src/utils/__tests__/parsePathnameToViewParams.test.ts +28 -0
  187. package/src/utils/__tests__/runjsValue.test.ts +11 -0
  188. package/src/utils/__tests__/utils.test.ts +62 -0
  189. package/src/utils/createCollectionContextMeta.ts +6 -2
  190. package/src/utils/index.ts +5 -1
  191. package/src/utils/parsePathnameToViewParams.ts +47 -7
  192. package/src/utils/randomId.ts +48 -0
  193. package/src/utils/runjsTemplateCompat.ts +1 -1
  194. package/src/utils/runjsValue.ts +50 -11
  195. package/src/utils/schema-utils.ts +30 -1
  196. package/src/views/FlowView.tsx +22 -2
  197. package/src/views/PageComponent.tsx +7 -4
  198. package/src/views/ViewNavigation.ts +46 -9
  199. package/src/views/__tests__/FlowView.usePage.test.tsx +243 -3
  200. package/src/views/__tests__/ViewNavigation.test.ts +52 -0
  201. package/src/views/__tests__/inheritLayoutContext.test.ts +53 -0
  202. package/src/views/__tests__/runViewBeforeClose.test.ts +30 -0
  203. package/src/views/__tests__/useDialog.closeDestroy.test.tsx +13 -12
  204. package/src/views/createViewMeta.ts +106 -34
  205. package/src/views/inheritLayoutContext.ts +26 -0
  206. package/src/views/runViewBeforeClose.ts +19 -0
  207. package/src/views/useDialog.tsx +27 -3
  208. package/src/views/useDrawer.tsx +27 -3
  209. package/src/views/usePage.tsx +367 -179
@@ -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
- const pathAfterCtx = match[1] || "";
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
- const varName = match[2] || "";
259
- const rest = match[3] || "";
260
- const { subPath, wildcard } = normalizeSubPath(rest);
261
- add(varName, wildcard ? "" : subPath);
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
  });
@@ -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;
@@ -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
- zIndex -= 1;
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
- closedRef.current = true;
121
- (_a = props.onClose) == null ? void 0 : _a.call(props);
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, props.onClose]);
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
- constructor(ctx: FlowEngineContext, viewParams: ViewParams[]);
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 generatePathnameFromViewParams(viewParams) {
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 "/admin";
58
+ return basePath;
49
59
  }
50
- const segments = ["admin"];
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
- constructor(ctx, viewParams) {
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 isPopupView = /* @__PURE__ */ __name((view) => {
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 ?? flowCtx.view;
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, _g;
180
+ var _a, _b, _c, _d, _e, _f;
120
181
  try {
121
182
  const useCtx = flowCtx || ctx;
122
- const nav = (_a = useCtx.view) == null ? void 0 : _a.navigation;
123
- const stack = Array.isArray(nav == null ? void 0 : nav.viewStack) ? nav.viewStack : [];
124
- if (stack.length < 2 || level < 1) return void 0;
125
- const idx = stack.length - 1 - level;
126
- if (idx < 0) return void 0;
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 = (_b = useCtx.engine) == null ? void 0 : _b.getModel(parent.viewUid, true);
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
- (_d = (_c = useCtx.logger || ctx.logger) == null ? void 0 : _c.warn) == null ? void 0 : _d.call(_c, { err: e }, "[FlowEngine] popup.getParentRecordRef loadModel failed");
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 = ((_e = model == null ? void 0 : model.getStepParams) == null ? void 0 : _e.call(model, "popupSettings", "openView")) || {};
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
- (_g = (_f = (flowCtx == null ? void 0 : flowCtx.logger) || ctx.logger) == null ? void 0 : _f.warn) == null ? void 0 : _g.call(_f, { err: e }, "[FlowEngine] popup.getParentRecordRef failed");
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 nav = (_a = anchorView ?? ctx.view) == null ? void 0 : _a.navigation;
159
- const stack = Array.isArray(nav == null ? void 0 : nav.viewStack) ? nav.viewStack : [];
160
- return stack.length >= level + 1;
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, _e, _f;
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 inputArgs = (_a = c.view) == null ? void 0 : _a.inputArgs;
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 nav = (_b = c.view) == null ? void 0 : _b.navigation;
240
- const stack = Array.isArray(nav == null ? void 0 : nav.viewStack) ? nav.viewStack : [];
241
- if (stack.length >= 2) {
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
- (_d = (_c = c.logger) == null ? void 0 : _c.debug) == null ? void 0 : _d.call(_c, { err }, "[FlowEngine] buildVariablesParams: build parent-chain failed");
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
- (_f = (_e = c.logger) == null ? void 0 : _e.debug) == null ? void 0 : _f.call(_e, { err }, "[FlowEngine] buildVariablesParams: infer sourceRecord failed");
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, _e, _f;
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 inputArgs = (_a = ctx.view) == null ? void 0 : _a.inputArgs;
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 nav = (_b = ctx.view) == null ? void 0 : _b.navigation;
301
- const stack = Array.isArray(nav == null ? void 0 : nav.viewStack) ? nav.viewStack : [];
302
- const last = stack == null ? void 0 : stack[stack.length - 1];
303
- if (last == null ? void 0 : last.viewUid) {
304
- let model = (_c = ctx == null ? void 0 : ctx.engine) == null ? void 0 : _c.getModel(last.viewUid, true);
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: last.viewUid });
370
+ model = await ctx.engine.loadModel({ uid: current.viewUid });
307
371
  }
308
- const p = ((_d = model == null ? void 0 : model.getStepParams) == null ? void 0 : _d.call(model, "popupSettings", "openView")) || {};
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
- (_f = (_e = ctx.logger) == null ? void 0 : _e.debug) == null ? void 0 : _f.call(_e, { err }, "[FlowEngine] popup.properties: build sourceRecord failed");
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, _b, _c;
366
- const nav = view == null ? void 0 : view.navigation;
367
- const stack = Array.isArray(nav == null ? void 0 : nav.viewStack) ? nav.viewStack : [];
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 = stack.length >= 2;
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, _b2, _c2, _d, _e, _f;
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 = (_b2 = ctx.engine) == null ? void 0 : _b2.getModel(viewUid, true);
456
+ let model = (_b = ctx.engine) == null ? void 0 : _b.getModel(viewUid, true);
393
457
  if (!model) {
394
- model = await ((_c2 = ctx.engine) == null ? void 0 : _c2.loadModel({ uid: viewUid }));
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((((_c = (_b = view == null ? void 0 : view.navigation) == null ? void 0 : _b.viewStack) == null ? void 0 : _c.length) || 1) - 1);
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;