@nocobase/flow-engine 2.0.0-beta.2 → 2.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/BlockScopedFlowEngine.js +0 -1
- package/lib/JSRunner.d.ts +6 -0
- package/lib/JSRunner.js +2 -1
- package/lib/ViewScopedFlowEngine.js +3 -0
- package/lib/acl/Acl.js +13 -3
- package/lib/components/dnd/gridDragPlanner.d.ts +1 -0
- package/lib/components/dnd/gridDragPlanner.js +53 -1
- package/lib/components/settings/wrappers/component/SwitchWithTitle.js +2 -1
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +11 -3
- package/lib/components/variables/VariableInput.js +8 -2
- package/lib/data-source/index.js +6 -0
- package/lib/executor/FlowExecutor.d.ts +2 -1
- package/lib/executor/FlowExecutor.js +156 -22
- package/lib/flowContext.d.ts +4 -1
- package/lib/flowContext.js +176 -107
- package/lib/flowEngine.d.ts +21 -0
- package/lib/flowEngine.js +38 -0
- package/lib/flowSettings.js +12 -10
- package/lib/index.d.ts +3 -0
- package/lib/index.js +16 -0
- 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 +66 -1
- 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 +1 -0
- package/lib/resources/sqlResource.js +8 -3
- package/lib/runjs-context/contexts/base.js +10 -4
- package/lib/runjsLibs.d.ts +28 -0
- package/lib/runjsLibs.js +532 -0
- package/lib/scheduler/ModelOperationScheduler.d.ts +2 -0
- package/lib/scheduler/ModelOperationScheduler.js +21 -21
- package/lib/types.d.ts +15 -0
- package/lib/utils/createCollectionContextMeta.js +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +10 -0
- package/lib/utils/params-resolvers.js +16 -9
- package/lib/utils/resolveModuleUrl.d.ts +58 -0
- package/lib/utils/resolveModuleUrl.js +65 -0
- package/lib/utils/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/safeGlobals.d.ts +5 -9
- package/lib/utils/safeGlobals.js +129 -17
- package/lib/views/createViewMeta.d.ts +0 -7
- package/lib/views/createViewMeta.js +19 -70
- package/lib/views/index.d.ts +1 -2
- package/lib/views/index.js +4 -3
- package/lib/views/useDialog.js +8 -3
- package/lib/views/useDrawer.js +7 -2
- package/lib/views/usePage.d.ts +4 -0
- package/lib/views/usePage.js +43 -6
- package/lib/views/usePopover.js +4 -1
- package/lib/views/viewEvents.d.ts +17 -0
- package/lib/views/viewEvents.js +90 -0
- package/package.json +4 -4
- package/src/BlockScopedFlowEngine.ts +2 -5
- package/src/JSRunner.ts +8 -1
- package/src/ViewScopedFlowEngine.ts +4 -0
- package/src/__tests__/createViewMeta.popup.test.ts +62 -1
- package/src/__tests__/flowEngine.dataSourceDirty.test.ts +63 -0
- package/src/__tests__/flowSettings.open.test.tsx +69 -15
- package/src/__tests__/provider.test.tsx +0 -5
- package/src/__tests__/runjsExternalLibs.test.ts +242 -0
- package/src/__tests__/runjsLibsLazyLoading.test.ts +44 -0
- package/src/__tests__/runjsPreprocessDefault.test.ts +49 -0
- package/src/acl/Acl.tsx +3 -3
- package/src/components/__tests__/gridDragPlanner.test.ts +141 -1
- package/src/components/dnd/gridDragPlanner.ts +60 -0
- 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 +11 -3
- package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +63 -4
- package/src/components/variables/VariableInput.tsx +8 -2
- package/src/data-source/index.ts +6 -0
- package/src/executor/FlowExecutor.ts +193 -23
- package/src/executor/__tests__/flowExecutor.test.ts +66 -0
- package/src/flowContext.ts +234 -118
- package/src/flowEngine.ts +41 -0
- package/src/flowSettings.ts +12 -11
- package/src/index.ts +10 -0
- package/src/models/CollectionFieldModel.tsx +3 -1
- package/src/models/__tests__/dispatchEvent.when.test.ts +356 -0
- package/src/models/__tests__/flowModel.clone.test.ts +416 -0
- package/src/models/__tests__/flowModel.test.ts +16 -0
- package/src/models/flowModel.tsx +94 -1
- 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 +8 -3
- package/src/runjs-context/contexts/base.ts +9 -2
- package/src/runjsLibs.ts +622 -0
- package/src/scheduler/ModelOperationScheduler.ts +23 -21
- package/src/types.ts +26 -1
- package/src/utils/__tests__/params-resolvers.test.ts +40 -0
- package/src/utils/__tests__/runjsRequireAsyncAutoWhitelist.test.ts +38 -0
- package/src/utils/__tests__/runjsTemplateCompat.test.ts +159 -0
- package/src/utils/__tests__/safeGlobals.test.ts +49 -2
- package/src/utils/createCollectionContextMeta.ts +1 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/params-resolvers.ts +23 -9
- package/src/utils/resolveModuleUrl.ts +91 -0
- package/src/utils/runjsModuleLoader.ts +553 -0
- package/src/utils/runjsTemplateCompat.ts +828 -0
- package/src/utils/safeGlobals.ts +133 -16
- package/src/views/__tests__/FlowView.usePage.test.tsx +54 -1
- package/src/views/__tests__/useDialog.closeDestroy.test.tsx +35 -8
- package/src/views/__tests__/viewEvents.resolveOpenerEngine.test.ts +28 -0
- package/src/views/createViewMeta.ts +22 -75
- package/src/views/index.tsx +1 -2
- package/src/views/useDialog.tsx +9 -2
- package/src/views/useDrawer.tsx +8 -1
- package/src/views/usePage.tsx +51 -5
- package/src/views/usePopover.tsx +4 -1
- package/src/views/viewEvents.ts +55 -0
|
@@ -6,13 +6,9 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* - 不允许随意访问未声明的属性,最小权限原则
|
|
15
|
-
*/
|
|
16
|
-
export declare function createSafeWindow(extra?: Record<string, any>): {};
|
|
17
|
-
export declare function createSafeDocument(extra?: Record<string, any>): {};
|
|
9
|
+
export declare function registerRunJSSafeWindowGlobals(keys: Iterable<string> | null | undefined): void;
|
|
10
|
+
export declare function registerRunJSSafeDocumentGlobals(keys: Iterable<string> | null | undefined): void;
|
|
11
|
+
export declare function __resetRunJSSafeGlobalsRegistryForTests(): void;
|
|
12
|
+
export declare function createSafeWindow(extra?: Record<string, any>): Record<string, any>;
|
|
13
|
+
export declare function createSafeDocument(extra?: Record<string, any>): Record<string, any>;
|
|
18
14
|
export declare function createSafeNavigator(extra?: Record<string, any>): {};
|
package/lib/utils/safeGlobals.js
CHANGED
|
@@ -27,14 +27,73 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var safeGlobals_exports = {};
|
|
29
29
|
__export(safeGlobals_exports, {
|
|
30
|
+
__resetRunJSSafeGlobalsRegistryForTests: () => __resetRunJSSafeGlobalsRegistryForTests,
|
|
30
31
|
createSafeDocument: () => createSafeDocument,
|
|
31
32
|
createSafeNavigator: () => createSafeNavigator,
|
|
32
|
-
createSafeWindow: () => createSafeWindow
|
|
33
|
+
createSafeWindow: () => createSafeWindow,
|
|
34
|
+
registerRunJSSafeDocumentGlobals: () => registerRunJSSafeDocumentGlobals,
|
|
35
|
+
registerRunJSSafeWindowGlobals: () => registerRunJSSafeWindowGlobals
|
|
33
36
|
});
|
|
34
37
|
module.exports = __toCommonJS(safeGlobals_exports);
|
|
38
|
+
function getRunJSSafeGlobalsRegistry() {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const g = globalThis;
|
|
41
|
+
if (((_a = g.__nocobaseRunJSSafeGlobalsRegistry) == null ? void 0 : _a.windowAllow) && ((_b = g.__nocobaseRunJSSafeGlobalsRegistry) == null ? void 0 : _b.documentAllow)) {
|
|
42
|
+
return g.__nocobaseRunJSSafeGlobalsRegistry;
|
|
43
|
+
}
|
|
44
|
+
const reg = {
|
|
45
|
+
windowAllow: /* @__PURE__ */ new Set(),
|
|
46
|
+
documentAllow: /* @__PURE__ */ new Set()
|
|
47
|
+
};
|
|
48
|
+
g.__nocobaseRunJSSafeGlobalsRegistry = reg;
|
|
49
|
+
return reg;
|
|
50
|
+
}
|
|
51
|
+
__name(getRunJSSafeGlobalsRegistry, "getRunJSSafeGlobalsRegistry");
|
|
52
|
+
function registerRunJSSafeWindowGlobals(keys) {
|
|
53
|
+
if (!keys) return;
|
|
54
|
+
const reg = getRunJSSafeGlobalsRegistry();
|
|
55
|
+
for (const k of keys) {
|
|
56
|
+
if (typeof k !== "string") continue;
|
|
57
|
+
const key = k.trim();
|
|
58
|
+
if (!key) continue;
|
|
59
|
+
reg.windowAllow.add(key);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
__name(registerRunJSSafeWindowGlobals, "registerRunJSSafeWindowGlobals");
|
|
63
|
+
function registerRunJSSafeDocumentGlobals(keys) {
|
|
64
|
+
if (!keys) return;
|
|
65
|
+
const reg = getRunJSSafeGlobalsRegistry();
|
|
66
|
+
for (const k of keys) {
|
|
67
|
+
if (typeof k !== "string") continue;
|
|
68
|
+
const key = k.trim();
|
|
69
|
+
if (!key) continue;
|
|
70
|
+
reg.documentAllow.add(key);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
__name(registerRunJSSafeDocumentGlobals, "registerRunJSSafeDocumentGlobals");
|
|
74
|
+
function __resetRunJSSafeGlobalsRegistryForTests() {
|
|
75
|
+
var _a, _b, _c, _d;
|
|
76
|
+
const g = globalThis;
|
|
77
|
+
if (g.__nocobaseRunJSSafeGlobalsRegistry) {
|
|
78
|
+
try {
|
|
79
|
+
(_b = (_a = g.__nocobaseRunJSSafeGlobalsRegistry.windowAllow) == null ? void 0 : _a.clear) == null ? void 0 : _b.call(_a);
|
|
80
|
+
(_d = (_c = g.__nocobaseRunJSSafeGlobalsRegistry.documentAllow) == null ? void 0 : _c.clear) == null ? void 0 : _d.call(_c);
|
|
81
|
+
} catch {
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
__name(__resetRunJSSafeGlobalsRegistryForTests, "__resetRunJSSafeGlobalsRegistryForTests");
|
|
86
|
+
function isAllowedDynamicWindowKey(key) {
|
|
87
|
+
return getRunJSSafeGlobalsRegistry().windowAllow.has(key);
|
|
88
|
+
}
|
|
89
|
+
__name(isAllowedDynamicWindowKey, "isAllowedDynamicWindowKey");
|
|
90
|
+
function isAllowedDynamicDocumentKey(key) {
|
|
91
|
+
return getRunJSSafeGlobalsRegistry().documentAllow.has(key);
|
|
92
|
+
}
|
|
93
|
+
__name(isAllowedDynamicDocumentKey, "isAllowedDynamicDocumentKey");
|
|
35
94
|
function createSafeWindow(extra) {
|
|
36
95
|
const getSafeBaseHref = /* @__PURE__ */ __name(() => `${window.location.origin}${window.location.pathname}`, "getSafeBaseHref");
|
|
37
|
-
const safeOpen = /* @__PURE__ */ __name((url,
|
|
96
|
+
const safeOpen = /* @__PURE__ */ __name((url, target2, features) => {
|
|
38
97
|
const isSafeUrl = /* @__PURE__ */ __name((u) => {
|
|
39
98
|
try {
|
|
40
99
|
const parsed = new URL(u, getSafeBaseHref());
|
|
@@ -145,15 +204,40 @@ function createSafeWindow(extra) {
|
|
|
145
204
|
location: safeLocation,
|
|
146
205
|
...extra || {}
|
|
147
206
|
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
{
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
throw new Error(`Access to global property "${prop}" is not allowed.`);
|
|
207
|
+
const target = /* @__PURE__ */ Object.create(null);
|
|
208
|
+
return new Proxy(target, {
|
|
209
|
+
get(t, prop) {
|
|
210
|
+
if (typeof prop !== "string") {
|
|
211
|
+
return Reflect.get(t, prop);
|
|
154
212
|
}
|
|
213
|
+
if (prop in allowedGlobals) return allowedGlobals[prop];
|
|
214
|
+
if (Object.prototype.hasOwnProperty.call(t, prop)) return t[prop];
|
|
215
|
+
if (isAllowedDynamicWindowKey(prop)) {
|
|
216
|
+
const v = window[prop];
|
|
217
|
+
if (typeof v === "function") return v.bind(window);
|
|
218
|
+
return v;
|
|
219
|
+
}
|
|
220
|
+
throw new Error(`Access to global property "${prop}" is not allowed.`);
|
|
221
|
+
},
|
|
222
|
+
set(t, prop, value) {
|
|
223
|
+
if (typeof prop !== "string") {
|
|
224
|
+
Reflect.set(t, prop, value);
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
if (prop in allowedGlobals) {
|
|
228
|
+
throw new Error(`Mutation of global property "${prop}" is not allowed.`);
|
|
229
|
+
}
|
|
230
|
+
t[prop] = value;
|
|
231
|
+
return true;
|
|
232
|
+
},
|
|
233
|
+
has(t, prop) {
|
|
234
|
+
if (typeof prop !== "string") return Reflect.has(t, prop);
|
|
235
|
+
if (prop in allowedGlobals) return true;
|
|
236
|
+
if (Object.prototype.hasOwnProperty.call(t, prop)) return true;
|
|
237
|
+
if (isAllowedDynamicWindowKey(prop)) return true;
|
|
238
|
+
return false;
|
|
155
239
|
}
|
|
156
|
-
);
|
|
240
|
+
});
|
|
157
241
|
}
|
|
158
242
|
__name(createSafeWindow, "createSafeWindow");
|
|
159
243
|
function createSafeDocument(extra) {
|
|
@@ -163,15 +247,40 @@ function createSafeDocument(extra) {
|
|
|
163
247
|
querySelectorAll: document.querySelectorAll.bind(document),
|
|
164
248
|
...extra || {}
|
|
165
249
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
250
|
+
const target = /* @__PURE__ */ Object.create(null);
|
|
251
|
+
return new Proxy(target, {
|
|
252
|
+
get(t, prop) {
|
|
253
|
+
if (typeof prop !== "string") {
|
|
254
|
+
return Reflect.get(t, prop);
|
|
255
|
+
}
|
|
256
|
+
if (prop in allowed) return allowed[prop];
|
|
257
|
+
if (Object.prototype.hasOwnProperty.call(t, prop)) return t[prop];
|
|
258
|
+
if (isAllowedDynamicDocumentKey(prop)) {
|
|
259
|
+
const v = document[prop];
|
|
260
|
+
if (typeof v === "function") return v.bind(document);
|
|
261
|
+
return v;
|
|
262
|
+
}
|
|
263
|
+
throw new Error(`Access to document property "${prop}" is not allowed.`);
|
|
264
|
+
},
|
|
265
|
+
set(t, prop, value) {
|
|
266
|
+
if (typeof prop !== "string") {
|
|
267
|
+
Reflect.set(t, prop, value);
|
|
268
|
+
return true;
|
|
172
269
|
}
|
|
270
|
+
if (prop in allowed) {
|
|
271
|
+
throw new Error(`Mutation of document property "${prop}" is not allowed.`);
|
|
272
|
+
}
|
|
273
|
+
t[prop] = value;
|
|
274
|
+
return true;
|
|
275
|
+
},
|
|
276
|
+
has(t, prop) {
|
|
277
|
+
if (typeof prop !== "string") return Reflect.has(t, prop);
|
|
278
|
+
if (prop in allowed) return true;
|
|
279
|
+
if (Object.prototype.hasOwnProperty.call(t, prop)) return true;
|
|
280
|
+
if (isAllowedDynamicDocumentKey(prop)) return true;
|
|
281
|
+
return false;
|
|
173
282
|
}
|
|
174
|
-
);
|
|
283
|
+
});
|
|
175
284
|
}
|
|
176
285
|
__name(createSafeDocument, "createSafeDocument");
|
|
177
286
|
function createSafeNavigator(extra) {
|
|
@@ -214,7 +323,10 @@ function createSafeNavigator(extra) {
|
|
|
214
323
|
__name(createSafeNavigator, "createSafeNavigator");
|
|
215
324
|
// Annotate the CommonJS export names for ESM import in node:
|
|
216
325
|
0 && (module.exports = {
|
|
326
|
+
__resetRunJSSafeGlobalsRegistryForTests,
|
|
217
327
|
createSafeDocument,
|
|
218
328
|
createSafeNavigator,
|
|
219
|
-
createSafeWindow
|
|
329
|
+
createSafeWindow,
|
|
330
|
+
registerRunJSSafeDocumentGlobals,
|
|
331
|
+
registerRunJSSafeWindowGlobals
|
|
220
332
|
});
|
|
@@ -8,13 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { FlowContext, PropertyMetaFactory } from '../flowContext';
|
|
10
10
|
import type { FlowView } from './FlowView';
|
|
11
|
-
/**
|
|
12
|
-
* Create a meta factory for ctx.view that includes:
|
|
13
|
-
* - buildVariablesParams: { record } via inferRecordRef
|
|
14
|
-
* - properties.record: full collection meta via buildRecordMeta
|
|
15
|
-
* - type/preventClose/inputArgs/navigation fields for better variable selection UX
|
|
16
|
-
*/
|
|
17
|
-
export declare function createViewMeta(ctx: FlowContext): PropertyMetaFactory;
|
|
18
11
|
/**
|
|
19
12
|
* 为 ctx.popup 构建元信息:
|
|
20
13
|
* - popup.record:当前弹窗记录(服务端解析)
|
|
@@ -29,7 +29,6 @@ var createViewMeta_exports = {};
|
|
|
29
29
|
__export(createViewMeta_exports, {
|
|
30
30
|
buildPopupRuntime: () => buildPopupRuntime,
|
|
31
31
|
createPopupMeta: () => createPopupMeta,
|
|
32
|
-
createViewMeta: () => createViewMeta,
|
|
33
32
|
registerPopupVariable: () => registerPopupVariable
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(createViewMeta_exports);
|
|
@@ -82,67 +81,15 @@ function makeMetaFromValue(value, title, seen) {
|
|
|
82
81
|
return { type: "any", title };
|
|
83
82
|
}
|
|
84
83
|
__name(makeMetaFromValue, "makeMetaFromValue");
|
|
85
|
-
function createViewMeta(ctx) {
|
|
86
|
-
const viewTitle = ctx.t("\u5F53\u524D\u89C6\u56FE");
|
|
87
|
-
const factory = /* @__PURE__ */ __name(async () => {
|
|
88
|
-
const view = ctx.view;
|
|
89
|
-
return {
|
|
90
|
-
type: "object",
|
|
91
|
-
title: ctx.t("\u5F53\u524D\u89C6\u56FE"),
|
|
92
|
-
buildVariablesParams: /* @__PURE__ */ __name((c) => {
|
|
93
|
-
const params = (0, import_variablesParams.inferViewRecordRef)(c);
|
|
94
|
-
if (params) {
|
|
95
|
-
return {
|
|
96
|
-
record: params
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
return void 0;
|
|
100
|
-
}, "buildVariablesParams"),
|
|
101
|
-
properties: /* @__PURE__ */ __name(async () => {
|
|
102
|
-
var _a, _b, _c;
|
|
103
|
-
const props = {};
|
|
104
|
-
const refNow = (0, import_variablesParams.inferViewRecordRef)(ctx);
|
|
105
|
-
if (refNow && refNow.collection) {
|
|
106
|
-
const recordFactory = /* @__PURE__ */ __name(async () => {
|
|
107
|
-
var _a2, _b2, _c2, _d;
|
|
108
|
-
try {
|
|
109
|
-
const ref = (0, import_variablesParams.inferViewRecordRef)(ctx);
|
|
110
|
-
if (!(ref == null ? void 0 : ref.collection)) return null;
|
|
111
|
-
const dsKey = ref.dataSourceKey || "main";
|
|
112
|
-
const ds = (_b2 = (_a2 = ctx.dataSourceManager) == null ? void 0 : _a2.getDataSource) == null ? void 0 : _b2.call(_a2, dsKey);
|
|
113
|
-
const col = (_d = (_c2 = ds == null ? void 0 : ds.collectionManager) == null ? void 0 : _c2.getCollection) == null ? void 0 : _d.call(_c2, ref.collection);
|
|
114
|
-
if (!col) return null;
|
|
115
|
-
return await (0, import_variablesParams.buildRecordMeta)(
|
|
116
|
-
() => col,
|
|
117
|
-
ctx.t("\u5F53\u524D\u89C6\u56FE\u8BB0\u5F55"),
|
|
118
|
-
(c) => (0, import_variablesParams.inferViewRecordRef)(c)
|
|
119
|
-
);
|
|
120
|
-
} catch (e) {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
}, "recordFactory");
|
|
124
|
-
recordFactory.title = ctx.t("\u5F53\u524D\u89C6\u56FE\u8BB0\u5F55");
|
|
125
|
-
recordFactory.hasChildren = true;
|
|
126
|
-
props.record = recordFactory;
|
|
127
|
-
}
|
|
128
|
-
props.type = { type: "string", title: ((_a = ctx.t) == null ? void 0 : _a.call(ctx, "\u7C7B\u578B")) || "\u7C7B\u578B" };
|
|
129
|
-
props.preventClose = { type: "boolean", title: ((_b = ctx.t) == null ? void 0 : _b.call(ctx, "\u662F\u5426\u5141\u8BB8\u5173\u95ED")) || "\u662F\u5426\u5141\u8BB8\u5173\u95ED" };
|
|
130
|
-
props.inputArgs = makeMetaFromValue(view == null ? void 0 : view.inputArgs, ((_c = ctx.t) == null ? void 0 : _c.call(ctx, "\u8F93\u5165\u53C2\u6570")) || "\u8F93\u5165\u53C2\u6570");
|
|
131
|
-
return props;
|
|
132
|
-
}, "properties")
|
|
133
|
-
};
|
|
134
|
-
}, "factory");
|
|
135
|
-
factory.title = viewTitle;
|
|
136
|
-
return factory;
|
|
137
|
-
}
|
|
138
|
-
__name(createViewMeta, "createViewMeta");
|
|
139
84
|
function createPopupMeta(ctx, anchorView) {
|
|
140
85
|
const t = /* @__PURE__ */ __name((k) => ctx.t(k), "t");
|
|
141
86
|
const isPopupView = /* @__PURE__ */ __name((view) => {
|
|
142
|
-
var _a;
|
|
87
|
+
var _a, _b;
|
|
143
88
|
if (!view) return false;
|
|
144
89
|
const stack = Array.isArray((_a = view.navigation) == null ? void 0 : _a.viewStack) ? view.navigation.viewStack : [];
|
|
145
|
-
|
|
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;
|
|
146
93
|
}, "isPopupView");
|
|
147
94
|
const hasPopupNow = /* @__PURE__ */ __name(() => isPopupView(anchorView ?? ctx.view), "hasPopupNow");
|
|
148
95
|
const resolveRecordRef = /* @__PURE__ */ __name(async (flowCtx) => {
|
|
@@ -329,18 +276,21 @@ function createPopupMeta(ctx, anchorView) {
|
|
|
329
276
|
var _a, _b, _c, _d, _e, _f;
|
|
330
277
|
const props = {};
|
|
331
278
|
props.uid = { type: "string", title: t("Popup uid") };
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
()
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
279
|
+
const recordRef = await resolveRecordRef(ctx);
|
|
280
|
+
if (recordRef) {
|
|
281
|
+
const recordFactory = /* @__PURE__ */ __name(async () => {
|
|
282
|
+
const col = await getCurrentCollection();
|
|
283
|
+
if (!col) return null;
|
|
284
|
+
return await (0, import_variablesParams.buildRecordMeta)(
|
|
285
|
+
() => col,
|
|
286
|
+
t("Current popup record"),
|
|
287
|
+
(c) => resolveRecordRef(c)
|
|
288
|
+
);
|
|
289
|
+
}, "recordFactory");
|
|
290
|
+
recordFactory.title = t("Current popup record");
|
|
291
|
+
recordFactory.hasChildren = true;
|
|
292
|
+
props.record = recordFactory;
|
|
293
|
+
}
|
|
344
294
|
try {
|
|
345
295
|
const inputArgs = (_a = ctx.view) == null ? void 0 : _a.inputArgs;
|
|
346
296
|
const srcId = inputArgs == null ? void 0 : inputArgs.sourceId;
|
|
@@ -483,6 +433,5 @@ __name(registerPopupVariable, "registerPopupVariable");
|
|
|
483
433
|
0 && (module.exports = {
|
|
484
434
|
buildPopupRuntime,
|
|
485
435
|
createPopupMeta,
|
|
486
|
-
createViewMeta,
|
|
487
436
|
registerPopupVariable
|
|
488
437
|
});
|
package/lib/views/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { useDialog } from './useDialog';
|
|
10
10
|
export { useDrawer } from './useDrawer';
|
|
11
|
-
export { usePage } from './usePage';
|
|
11
|
+
export { usePage, GLOBAL_EMBED_CONTAINER_ID, EMBED_REPLACING_DATA_KEY } from './usePage';
|
|
12
12
|
export { usePopover } from './usePopover';
|
|
13
13
|
export { ViewNavigation } from './ViewNavigation';
|
|
14
|
-
export { createViewMeta } from './createViewMeta';
|
package/lib/views/index.js
CHANGED
|
@@ -26,8 +26,9 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
26
26
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
27
|
var views_exports = {};
|
|
28
28
|
__export(views_exports, {
|
|
29
|
+
EMBED_REPLACING_DATA_KEY: () => import_usePage.EMBED_REPLACING_DATA_KEY,
|
|
30
|
+
GLOBAL_EMBED_CONTAINER_ID: () => import_usePage.GLOBAL_EMBED_CONTAINER_ID,
|
|
29
31
|
ViewNavigation: () => import_ViewNavigation.ViewNavigation,
|
|
30
|
-
createViewMeta: () => import_createViewMeta.createViewMeta,
|
|
31
32
|
useDialog: () => import_useDialog.useDialog,
|
|
32
33
|
useDrawer: () => import_useDrawer.useDrawer,
|
|
33
34
|
usePage: () => import_usePage.usePage,
|
|
@@ -39,11 +40,11 @@ var import_useDrawer = require("./useDrawer");
|
|
|
39
40
|
var import_usePage = require("./usePage");
|
|
40
41
|
var import_usePopover = require("./usePopover");
|
|
41
42
|
var import_ViewNavigation = require("./ViewNavigation");
|
|
42
|
-
var import_createViewMeta = require("./createViewMeta");
|
|
43
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
44
|
0 && (module.exports = {
|
|
45
|
+
EMBED_REPLACING_DATA_KEY,
|
|
46
|
+
GLOBAL_EMBED_CONTAINER_ID,
|
|
45
47
|
ViewNavigation,
|
|
46
|
-
createViewMeta,
|
|
47
48
|
useDialog,
|
|
48
49
|
useDrawer,
|
|
49
50
|
usePage,
|
package/lib/views/useDialog.js
CHANGED
|
@@ -48,6 +48,7 @@ var import_FlowContextProvider = require("../FlowContextProvider");
|
|
|
48
48
|
var import_createViewMeta = require("./createViewMeta");
|
|
49
49
|
var import_DialogComponent = __toESM(require("./DialogComponent"));
|
|
50
50
|
var import_usePatchElement = __toESM(require("./usePatchElement"));
|
|
51
|
+
var import_viewEvents = require("./viewEvents");
|
|
51
52
|
var import_provider = require("../provider");
|
|
52
53
|
var import_ViewScopedFlowEngine = require("../ViewScopedFlowEngine");
|
|
53
54
|
var import_variablesParams = require("../utils/variablesParams");
|
|
@@ -56,6 +57,7 @@ function useDialog() {
|
|
|
56
57
|
const holderRef = React.useRef(null);
|
|
57
58
|
const open = /* @__PURE__ */ __name((config, flowContext) => {
|
|
58
59
|
var _a, _b, _c;
|
|
60
|
+
const parentEngine = flowContext == null ? void 0 : flowContext.engine;
|
|
59
61
|
uuid += 1;
|
|
60
62
|
const dialogRef = React.createRef();
|
|
61
63
|
let closeFunc;
|
|
@@ -93,6 +95,7 @@ function useDialog() {
|
|
|
93
95
|
}, "HeaderComponent");
|
|
94
96
|
const ctx = new import_flowContext.FlowContext();
|
|
95
97
|
const scopedEngine = (0, import_ViewScopedFlowEngine.createViewScopedEngine)(flowContext.engine);
|
|
98
|
+
const openerEngine = (0, import_viewEvents.resolveOpenerEngine)(parentEngine, scopedEngine);
|
|
96
99
|
ctx.defineProperty("engine", { value: scopedEngine });
|
|
97
100
|
ctx.addDelegate(scopedEngine.context);
|
|
98
101
|
if (config.inheritContext !== false) {
|
|
@@ -105,11 +108,14 @@ function useDialog() {
|
|
|
105
108
|
inputArgs: config.inputArgs || {},
|
|
106
109
|
preventClose: !!config.preventClose,
|
|
107
110
|
destroy: /* @__PURE__ */ __name((result) => {
|
|
108
|
-
var _a2, _b2;
|
|
111
|
+
var _a2, _b2, _c2, _d;
|
|
109
112
|
(_a2 = config.onClose) == null ? void 0 : _a2.call(config);
|
|
110
113
|
(_b2 = dialogRef.current) == null ? void 0 : _b2.destroy();
|
|
111
114
|
closeFunc == null ? void 0 : closeFunc();
|
|
112
115
|
resolvePromise == null ? void 0 : resolvePromise(result);
|
|
116
|
+
const openerEmitter = openerEngine == null ? void 0 : openerEngine.emitter;
|
|
117
|
+
(0, import_viewEvents.bumpViewActivatedVersion)(openerEmitter);
|
|
118
|
+
(_d = openerEmitter == null ? void 0 : openerEmitter.emit) == null ? void 0 : _d.call(openerEmitter, import_viewEvents.VIEW_ACTIVATED_EVENT, { type: "dialog", viewUid: (_c2 = currentDialog == null ? void 0 : currentDialog.inputArgs) == null ? void 0 : _c2.viewUid });
|
|
113
119
|
scopedEngine.unlinkFromStack();
|
|
114
120
|
}, "destroy"),
|
|
115
121
|
update: /* @__PURE__ */ __name((newConfig) => {
|
|
@@ -146,7 +152,6 @@ function useDialog() {
|
|
|
146
152
|
};
|
|
147
153
|
ctx.defineProperty("view", {
|
|
148
154
|
get: /* @__PURE__ */ __name(() => currentDialog, "get"),
|
|
149
|
-
// meta: createViewMeta(ctx),
|
|
150
155
|
resolveOnServer: (0, import_variablesParams.createViewRecordResolveOnServer)(ctx, () => (0, import_variablesParams.getViewRecordFromParent)(flowContext, ctx))
|
|
151
156
|
});
|
|
152
157
|
(0, import_createViewMeta.registerPopupVariable)(ctx, currentDialog);
|
|
@@ -170,9 +175,9 @@ function useDialog() {
|
|
|
170
175
|
className: "nb-dialog-overflow-hidden",
|
|
171
176
|
ref: dialogRef,
|
|
172
177
|
hidden: (_d = (_c2 = config.inputArgs) == null ? void 0 : _c2.hidden) == null ? void 0 : _d.value,
|
|
173
|
-
...config,
|
|
174
178
|
footer: currentFooter,
|
|
175
179
|
header: currentHeader,
|
|
180
|
+
...config,
|
|
176
181
|
onCancel: () => {
|
|
177
182
|
currentDialog.close(config.result);
|
|
178
183
|
}
|
package/lib/views/useDrawer.js
CHANGED
|
@@ -48,6 +48,7 @@ var import_FlowContextProvider = require("../FlowContextProvider");
|
|
|
48
48
|
var import_createViewMeta = require("./createViewMeta");
|
|
49
49
|
var import_DrawerComponent = __toESM(require("./DrawerComponent"));
|
|
50
50
|
var import_usePatchElement = __toESM(require("./usePatchElement"));
|
|
51
|
+
var import_viewEvents = require("./viewEvents");
|
|
51
52
|
var import_provider = require("../provider");
|
|
52
53
|
var import_ViewScopedFlowEngine = require("../ViewScopedFlowEngine");
|
|
53
54
|
var import_variablesParams = require("../utils/variablesParams");
|
|
@@ -76,6 +77,7 @@ function useDrawer() {
|
|
|
76
77
|
RenderNestedDrawer.displayName = "RenderNestedDrawer";
|
|
77
78
|
const open = /* @__PURE__ */ __name((config, flowContext) => {
|
|
78
79
|
var _a, _b;
|
|
80
|
+
const parentEngine = flowContext.engine;
|
|
79
81
|
const drawerRef = React.createRef();
|
|
80
82
|
let closeFunc;
|
|
81
83
|
let resolvePromise;
|
|
@@ -112,6 +114,7 @@ function useDrawer() {
|
|
|
112
114
|
}, "HeaderComponent");
|
|
113
115
|
const ctx = new import_flowContext.FlowContext();
|
|
114
116
|
const scopedEngine = (0, import_ViewScopedFlowEngine.createViewScopedEngine)(flowContext.engine);
|
|
117
|
+
const openerEngine = (0, import_viewEvents.resolveOpenerEngine)(parentEngine, scopedEngine);
|
|
115
118
|
ctx.defineProperty("engine", { value: scopedEngine });
|
|
116
119
|
ctx.addDelegate(scopedEngine.context);
|
|
117
120
|
if (config.inheritContext !== false) {
|
|
@@ -124,11 +127,14 @@ function useDrawer() {
|
|
|
124
127
|
inputArgs: config.inputArgs || {},
|
|
125
128
|
preventClose: !!config.preventClose,
|
|
126
129
|
destroy: /* @__PURE__ */ __name((result) => {
|
|
127
|
-
var _a2, _b2;
|
|
130
|
+
var _a2, _b2, _c, _d;
|
|
128
131
|
(_a2 = config.onClose) == null ? void 0 : _a2.call(config);
|
|
129
132
|
(_b2 = drawerRef.current) == null ? void 0 : _b2.destroy();
|
|
130
133
|
closeFunc == null ? void 0 : closeFunc();
|
|
131
134
|
resolvePromise == null ? void 0 : resolvePromise(result);
|
|
135
|
+
const openerEmitter = openerEngine == null ? void 0 : openerEngine.emitter;
|
|
136
|
+
(0, import_viewEvents.bumpViewActivatedVersion)(openerEmitter);
|
|
137
|
+
(_d = openerEmitter == null ? void 0 : openerEmitter.emit) == null ? void 0 : _d.call(openerEmitter, import_viewEvents.VIEW_ACTIVATED_EVENT, { type: "drawer", viewUid: (_c = currentDrawer == null ? void 0 : currentDrawer.inputArgs) == null ? void 0 : _c.viewUid });
|
|
132
138
|
scopedEngine.unlinkFromStack();
|
|
133
139
|
}, "destroy"),
|
|
134
140
|
update: /* @__PURE__ */ __name((newConfig) => {
|
|
@@ -165,7 +171,6 @@ function useDrawer() {
|
|
|
165
171
|
};
|
|
166
172
|
ctx.defineProperty("view", {
|
|
167
173
|
get: /* @__PURE__ */ __name(() => currentDrawer, "get"),
|
|
168
|
-
// meta: createViewMeta(ctx),
|
|
169
174
|
resolveOnServer: (0, import_variablesParams.createViewRecordResolveOnServer)(ctx, () => (0, import_variablesParams.getViewRecordFromParent)(flowContext, ctx))
|
|
170
175
|
});
|
|
171
176
|
(0, import_createViewMeta.registerPopupVariable)(ctx, currentDrawer);
|
package/lib/views/usePage.d.ts
CHANGED
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import React from 'react';
|
|
10
|
+
/** Global embed container element ID */
|
|
11
|
+
export declare const GLOBAL_EMBED_CONTAINER_ID = "nocobase-embed-container";
|
|
12
|
+
/** Dataset key used to signal embed replacement in progress (skip style reset on close) */
|
|
13
|
+
export declare const EMBED_REPLACING_DATA_KEY = "nocobaseEmbedReplacing";
|
|
10
14
|
export declare function usePage(): (React.JSX.Element | {
|
|
11
15
|
open: (config: any, flowContext: any) => Promise<unknown> & {
|
|
12
16
|
type: "embed";
|
package/lib/views/usePage.js
CHANGED
|
@@ -37,6 +37,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
38
|
var usePage_exports = {};
|
|
39
39
|
__export(usePage_exports, {
|
|
40
|
+
EMBED_REPLACING_DATA_KEY: () => EMBED_REPLACING_DATA_KEY,
|
|
41
|
+
GLOBAL_EMBED_CONTAINER_ID: () => GLOBAL_EMBED_CONTAINER_ID,
|
|
40
42
|
usePage: () => usePage
|
|
41
43
|
});
|
|
42
44
|
module.exports = __toCommonJS(usePage_exports);
|
|
@@ -48,22 +50,26 @@ var import_FlowContextProvider = require("../FlowContextProvider");
|
|
|
48
50
|
var import_createViewMeta = require("./createViewMeta");
|
|
49
51
|
var import_PageComponent = require("./PageComponent");
|
|
50
52
|
var import_usePatchElement = __toESM(require("./usePatchElement"));
|
|
53
|
+
var import_viewEvents = require("./viewEvents");
|
|
51
54
|
var import_provider = require("../provider");
|
|
52
55
|
var import_ViewScopedFlowEngine = require("../ViewScopedFlowEngine");
|
|
53
56
|
var import_variablesParams = require("../utils/variablesParams");
|
|
54
57
|
let uuid = 0;
|
|
58
|
+
const GLOBAL_EMBED_CONTAINER_ID = "nocobase-embed-container";
|
|
59
|
+
const EMBED_REPLACING_DATA_KEY = "nocobaseEmbedReplacing";
|
|
55
60
|
const PageElementsHolder = import_react.default.memo(
|
|
56
61
|
import_react.default.forwardRef((props, ref) => {
|
|
57
62
|
const [elements, patchElement] = (0, import_usePatchElement.default)();
|
|
58
63
|
import_react.default.useImperativeHandle(ref, () => ({ patchElement }), [patchElement]);
|
|
59
|
-
console.log("[NocoBase] Rendering PageElementsHolder with elements count:", elements.length);
|
|
60
64
|
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, elements);
|
|
61
65
|
})
|
|
62
66
|
);
|
|
63
67
|
function usePage() {
|
|
64
68
|
const holderRef = import_react.default.useRef(null);
|
|
69
|
+
const globalEmbedActiveRef = import_react.default.useRef(null);
|
|
65
70
|
const open = /* @__PURE__ */ __name((config, flowContext) => {
|
|
66
71
|
var _a, _b, _c;
|
|
72
|
+
const parentEngine = flowContext == null ? void 0 : flowContext.engine;
|
|
67
73
|
uuid += 1;
|
|
68
74
|
const pageRef = import_react.default.createRef();
|
|
69
75
|
let closeFunc;
|
|
@@ -93,9 +99,27 @@ function usePage() {
|
|
|
93
99
|
}, [props]);
|
|
94
100
|
return null;
|
|
95
101
|
}, "HeaderComponent");
|
|
96
|
-
const {
|
|
102
|
+
const {
|
|
103
|
+
target,
|
|
104
|
+
content,
|
|
105
|
+
preventClose,
|
|
106
|
+
inheritContext = true,
|
|
107
|
+
inputArgs: viewInputArgs = {},
|
|
108
|
+
...restConfig
|
|
109
|
+
} = config;
|
|
110
|
+
const isGlobalEmbedContainer = target instanceof HTMLElement && target.id === GLOBAL_EMBED_CONTAINER_ID;
|
|
111
|
+
if (isGlobalEmbedContainer && globalEmbedActiveRef.current) {
|
|
112
|
+
try {
|
|
113
|
+
target.dataset[EMBED_REPLACING_DATA_KEY] = "1";
|
|
114
|
+
globalEmbedActiveRef.current.destroy();
|
|
115
|
+
} finally {
|
|
116
|
+
delete target.dataset[EMBED_REPLACING_DATA_KEY];
|
|
117
|
+
globalEmbedActiveRef.current = null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
97
120
|
const ctx = new import_flowContext.FlowContext();
|
|
98
121
|
const scopedEngine = (0, import_ViewScopedFlowEngine.createViewScopedEngine)(flowContext.engine);
|
|
122
|
+
const openerEngine = (0, import_viewEvents.resolveOpenerEngine)(parentEngine, scopedEngine);
|
|
99
123
|
ctx.defineProperty("engine", { value: scopedEngine });
|
|
100
124
|
ctx.addDelegate(scopedEngine.context);
|
|
101
125
|
if (inheritContext) {
|
|
@@ -105,14 +129,23 @@ function usePage() {
|
|
|
105
129
|
}
|
|
106
130
|
const currentPage = {
|
|
107
131
|
type: "embed",
|
|
108
|
-
inputArgs:
|
|
132
|
+
inputArgs: viewInputArgs,
|
|
109
133
|
preventClose: !!config.preventClose,
|
|
110
134
|
destroy: /* @__PURE__ */ __name((result) => {
|
|
111
|
-
var _a2, _b2;
|
|
135
|
+
var _a2, _b2, _c2, _d, _e;
|
|
112
136
|
(_a2 = config.onClose) == null ? void 0 : _a2.call(config);
|
|
113
137
|
resolvePromise == null ? void 0 : resolvePromise(result);
|
|
114
138
|
(_b2 = pageRef.current) == null ? void 0 : _b2.destroy();
|
|
115
139
|
closeFunc == null ? void 0 : closeFunc();
|
|
140
|
+
if (isGlobalEmbedContainer) {
|
|
141
|
+
globalEmbedActiveRef.current = null;
|
|
142
|
+
}
|
|
143
|
+
const isReplacing = isGlobalEmbedContainer && target instanceof HTMLElement && ((_c2 = target.dataset) == null ? void 0 : _c2[EMBED_REPLACING_DATA_KEY]) === "1";
|
|
144
|
+
if (!isReplacing) {
|
|
145
|
+
const openerEmitter = openerEngine == null ? void 0 : openerEngine.emitter;
|
|
146
|
+
(0, import_viewEvents.bumpViewActivatedVersion)(openerEmitter);
|
|
147
|
+
(_e = openerEmitter == null ? void 0 : openerEmitter.emit) == null ? void 0 : _e.call(openerEmitter, import_viewEvents.VIEW_ACTIVATED_EVENT, { type: "embed", viewUid: (_d = currentPage == null ? void 0 : currentPage.inputArgs) == null ? void 0 : _d.viewUid });
|
|
148
|
+
}
|
|
116
149
|
scopedEngine.unlinkFromStack();
|
|
117
150
|
}, "destroy"),
|
|
118
151
|
update: /* @__PURE__ */ __name((newConfig) => {
|
|
@@ -147,7 +180,6 @@ function usePage() {
|
|
|
147
180
|
};
|
|
148
181
|
ctx.defineProperty("view", {
|
|
149
182
|
get: /* @__PURE__ */ __name(() => currentPage, "get"),
|
|
150
|
-
// meta: createViewMeta(ctx),
|
|
151
183
|
// 仅当访问关联字段或前端无本地记录数据时,才交给服务端解析
|
|
152
184
|
resolveOnServer: (0, import_variablesParams.createViewRecordResolveOnServer)(ctx, () => (0, import_variablesParams.getViewRecordFromParent)(flowContext, ctx))
|
|
153
185
|
});
|
|
@@ -186,13 +218,16 @@ function usePage() {
|
|
|
186
218
|
displayName: "PageWithContext"
|
|
187
219
|
}
|
|
188
220
|
);
|
|
189
|
-
const key = (
|
|
221
|
+
const key = (viewInputArgs == null ? void 0 : viewInputArgs.viewUid) || `page-${uuid}`;
|
|
190
222
|
const page = /* @__PURE__ */ import_react.default.createElement(import_provider.FlowEngineProvider, { key, engine: scopedEngine }, /* @__PURE__ */ import_react.default.createElement(import_FlowContextProvider.FlowViewContextProvider, { context: ctx }, /* @__PURE__ */ import_react.default.createElement(PageWithContext, null)));
|
|
191
223
|
if (target && target instanceof HTMLElement) {
|
|
192
224
|
closeFunc = (_b = holderRef.current) == null ? void 0 : _b.patchElement(import_react_dom.default.createPortal(page, target, key));
|
|
193
225
|
} else {
|
|
194
226
|
closeFunc = (_c = holderRef.current) == null ? void 0 : _c.patchElement(page);
|
|
195
227
|
}
|
|
228
|
+
if (isGlobalEmbedContainer) {
|
|
229
|
+
globalEmbedActiveRef.current = { destroy: currentPage.destroy };
|
|
230
|
+
}
|
|
196
231
|
return Object.assign(promise, currentPage);
|
|
197
232
|
}, "open");
|
|
198
233
|
const api = import_react.default.useMemo(() => ({ open }), []);
|
|
@@ -201,5 +236,7 @@ function usePage() {
|
|
|
201
236
|
__name(usePage, "usePage");
|
|
202
237
|
// Annotate the CommonJS export names for ESM import in node:
|
|
203
238
|
0 && (module.exports = {
|
|
239
|
+
EMBED_REPLACING_DATA_KEY,
|
|
240
|
+
GLOBAL_EMBED_CONTAINER_ID,
|
|
204
241
|
usePage
|
|
205
242
|
});
|
package/lib/views/usePopover.js
CHANGED
|
@@ -68,8 +68,11 @@ const PopoverComponent = React.forwardRef(({ afterClose, content, placement, rec
|
|
|
68
68
|
destroyTooltipOnHide: true,
|
|
69
69
|
content: config.content,
|
|
70
70
|
placement: config.placement,
|
|
71
|
-
getPopupContainer: () => document.body,
|
|
71
|
+
getPopupContainer: () => document.querySelector("#nocobase-app-container") || document.body,
|
|
72
72
|
onOpenChange: (nextOpen) => {
|
|
73
|
+
if (!nextOpen && config.preventClose) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
73
76
|
setVisible(nextOpen);
|
|
74
77
|
if (!nextOpen) {
|
|
75
78
|
afterClose == null ? void 0 : afterClose();
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { FlowEngine } from '../flowEngine';
|
|
10
|
+
export declare const VIEW_ACTIVATED_VERSION: unique symbol;
|
|
11
|
+
export declare const VIEW_ACTIVATED_EVENT: "view:activated";
|
|
12
|
+
export declare const DATA_SOURCE_DIRTY_EVENT: "dataSource:dirty";
|
|
13
|
+
export declare const ENGINE_SCOPE_KEY: "__NOCOBASE_ENGINE_SCOPE__";
|
|
14
|
+
export declare const VIEW_ENGINE_SCOPE: "view";
|
|
15
|
+
export declare function getEmitterViewActivatedVersion(emitter: any): number;
|
|
16
|
+
export declare function bumpViewActivatedVersion(emitter: any): number;
|
|
17
|
+
export declare function resolveOpenerEngine(parentEngine: FlowEngine, scopedEngine: FlowEngine): FlowEngine | undefined;
|