@nocobase/flow-engine 2.1.0-alpha.35 → 2.1.0-alpha.37
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/components/subModel/LazyDropdown.js +79 -33
- 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/index.d.ts +2 -0
- package/lib/index.js +7 -0
- package/lib/views/FlowView.js +11 -1
- package/lib/views/PageComponent.js +8 -6
- package/lib/views/usePage.d.ts +4 -11
- package/lib/views/usePage.js +301 -150
- package/package.json +4 -4
- package/src/components/subModel/LazyDropdown.tsx +89 -36
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +131 -4
- 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/index.ts +2 -0
- package/src/views/FlowView.tsx +11 -1
- package/src/views/PageComponent.tsx +7 -4
- package/src/views/__tests__/FlowView.usePage.test.tsx +243 -3
- package/src/views/usePage.tsx +364 -187
package/lib/views/usePage.js
CHANGED
|
@@ -58,6 +58,102 @@ var import_runViewBeforeClose = require("./runViewBeforeClose");
|
|
|
58
58
|
let uuid = 0;
|
|
59
59
|
const GLOBAL_EMBED_CONTAINER_ID = "nocobase-embed-container";
|
|
60
60
|
const EMBED_REPLACING_DATA_KEY = "nocobaseEmbedReplacing";
|
|
61
|
+
function isPromiseLike(value) {
|
|
62
|
+
return !!value && typeof value.then === "function";
|
|
63
|
+
}
|
|
64
|
+
__name(isPromiseLike, "isPromiseLike");
|
|
65
|
+
function closeReplacingGlobalEmbed(target, activeView) {
|
|
66
|
+
target.dataset[EMBED_REPLACING_DATA_KEY] = "1";
|
|
67
|
+
try {
|
|
68
|
+
const closeResult = activeView.close();
|
|
69
|
+
if (isPromiseLike(closeResult)) {
|
|
70
|
+
return Promise.resolve(closeResult).finally(() => {
|
|
71
|
+
delete target.dataset[EMBED_REPLACING_DATA_KEY];
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
delete target.dataset[EMBED_REPLACING_DATA_KEY];
|
|
75
|
+
return closeResult;
|
|
76
|
+
} catch (error) {
|
|
77
|
+
delete target.dataset[EMBED_REPLACING_DATA_KEY];
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
__name(closeReplacingGlobalEmbed, "closeReplacingGlobalEmbed");
|
|
82
|
+
function createPendingGlobalEmbedView(openedPromise, inputArgs, preventClose) {
|
|
83
|
+
let openedPage;
|
|
84
|
+
const pendingActions = {};
|
|
85
|
+
const readyPromise = openedPromise.then(({ page }) => {
|
|
86
|
+
openedPage = page;
|
|
87
|
+
if (openedPage) {
|
|
88
|
+
if ("beforeClose" in pendingActions) {
|
|
89
|
+
openedPage.beforeClose = pendingActions.beforeClose;
|
|
90
|
+
}
|
|
91
|
+
if ("update" in pendingActions) {
|
|
92
|
+
openedPage.update(pendingActions.update);
|
|
93
|
+
}
|
|
94
|
+
if ("footer" in pendingActions) {
|
|
95
|
+
openedPage.setFooter(pendingActions.footer);
|
|
96
|
+
}
|
|
97
|
+
if ("header" in pendingActions) {
|
|
98
|
+
openedPage.setHeader(pendingActions.header);
|
|
99
|
+
}
|
|
100
|
+
if (pendingActions.destroyed) {
|
|
101
|
+
openedPage.destroy(pendingActions.destroyed.result);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return { page };
|
|
105
|
+
});
|
|
106
|
+
return Object.assign(
|
|
107
|
+
readyPromise.then(({ page }) => page ? page : false),
|
|
108
|
+
{
|
|
109
|
+
type: "embed",
|
|
110
|
+
inputArgs,
|
|
111
|
+
preventClose,
|
|
112
|
+
Header: null,
|
|
113
|
+
Footer: null,
|
|
114
|
+
get beforeClose() {
|
|
115
|
+
return (openedPage == null ? void 0 : openedPage.beforeClose) ?? pendingActions.beforeClose;
|
|
116
|
+
},
|
|
117
|
+
set beforeClose(value) {
|
|
118
|
+
if (openedPage) {
|
|
119
|
+
openedPage.beforeClose = value;
|
|
120
|
+
} else {
|
|
121
|
+
pendingActions.beforeClose = value;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
close: /* @__PURE__ */ __name((result, force) => readyPromise.then(({ page }) => page ? page.close(result, force) : false), "close"),
|
|
125
|
+
destroy: /* @__PURE__ */ __name((result) => {
|
|
126
|
+
if (openedPage) {
|
|
127
|
+
openedPage.destroy(result);
|
|
128
|
+
} else {
|
|
129
|
+
pendingActions.destroyed = { result };
|
|
130
|
+
}
|
|
131
|
+
}, "destroy"),
|
|
132
|
+
update: /* @__PURE__ */ __name((newConfig) => {
|
|
133
|
+
if (openedPage) {
|
|
134
|
+
openedPage.update(newConfig);
|
|
135
|
+
} else {
|
|
136
|
+
pendingActions.update = { ...pendingActions.update, ...newConfig };
|
|
137
|
+
}
|
|
138
|
+
}, "update"),
|
|
139
|
+
setFooter: /* @__PURE__ */ __name((footer) => {
|
|
140
|
+
if (openedPage) {
|
|
141
|
+
openedPage.setFooter(footer);
|
|
142
|
+
} else {
|
|
143
|
+
pendingActions.footer = footer;
|
|
144
|
+
}
|
|
145
|
+
}, "setFooter"),
|
|
146
|
+
setHeader: /* @__PURE__ */ __name((header) => {
|
|
147
|
+
if (openedPage) {
|
|
148
|
+
openedPage.setHeader(header);
|
|
149
|
+
} else {
|
|
150
|
+
pendingActions.header = header;
|
|
151
|
+
}
|
|
152
|
+
}, "setHeader")
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
__name(createPendingGlobalEmbedView, "createPendingGlobalEmbedView");
|
|
61
157
|
const PageElementsHolder = import_react.default.memo(
|
|
62
158
|
import_react.default.forwardRef((props, ref) => {
|
|
63
159
|
const [elements, patchElement] = (0, import_usePatchElement.default)();
|
|
@@ -68,174 +164,229 @@ const PageElementsHolder = import_react.default.memo(
|
|
|
68
164
|
function usePage() {
|
|
69
165
|
const holderRef = import_react.default.useRef(null);
|
|
70
166
|
const globalEmbedActiveRef = import_react.default.useRef(null);
|
|
167
|
+
const globalEmbedReplacementTokenRef = import_react.default.useRef(0);
|
|
71
168
|
const open = /* @__PURE__ */ __name((config, flowContext) => {
|
|
72
|
-
var _a, _b, _c;
|
|
73
|
-
const parentEngine = flowContext == null ? void 0 : flowContext.engine;
|
|
74
|
-
uuid += 1;
|
|
75
|
-
const pageRef = import_react.default.createRef();
|
|
76
|
-
let closeFunc;
|
|
77
|
-
let resolvePromise;
|
|
78
|
-
const promise = new Promise((resolve) => {
|
|
79
|
-
resolvePromise = resolve;
|
|
80
|
-
});
|
|
81
|
-
const FooterComponent = /* @__PURE__ */ __name(({ children }) => {
|
|
82
|
-
import_react.default.useEffect(() => {
|
|
83
|
-
var _a2;
|
|
84
|
-
(_a2 = pageRef.current) == null ? void 0 : _a2.setFooter(children);
|
|
85
|
-
return () => {
|
|
86
|
-
var _a3;
|
|
87
|
-
(_a3 = pageRef.current) == null ? void 0 : _a3.setFooter(null);
|
|
88
|
-
};
|
|
89
|
-
}, [children]);
|
|
90
|
-
return null;
|
|
91
|
-
}, "FooterComponent");
|
|
92
|
-
const HeaderComponent = /* @__PURE__ */ __name((props) => {
|
|
93
|
-
import_react.default.useEffect(() => {
|
|
94
|
-
var _a2;
|
|
95
|
-
(_a2 = pageRef.current) == null ? void 0 : _a2.setHeader(props);
|
|
96
|
-
return () => {
|
|
97
|
-
var _a3;
|
|
98
|
-
(_a3 = pageRef.current) == null ? void 0 : _a3.setHeader(null);
|
|
99
|
-
};
|
|
100
|
-
}, [props]);
|
|
101
|
-
return null;
|
|
102
|
-
}, "HeaderComponent");
|
|
103
169
|
const {
|
|
104
170
|
target,
|
|
105
171
|
content,
|
|
106
172
|
preventClose,
|
|
107
173
|
inheritContext = true,
|
|
108
174
|
inputArgs: viewInputArgs = {},
|
|
175
|
+
onOpenCancelled,
|
|
109
176
|
...restConfig
|
|
110
177
|
} = config;
|
|
111
178
|
const isGlobalEmbedContainer = target instanceof HTMLElement && target.id === GLOBAL_EMBED_CONTAINER_ID;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
179
|
+
const openCurrentPage = /* @__PURE__ */ __name(() => {
|
|
180
|
+
var _a, _b, _c;
|
|
181
|
+
const parentEngine = flowContext == null ? void 0 : flowContext.engine;
|
|
182
|
+
uuid += 1;
|
|
183
|
+
const pageRef = import_react.default.createRef();
|
|
184
|
+
let closeFunc;
|
|
185
|
+
let resolvePromise;
|
|
186
|
+
const promise = new Promise((resolve) => {
|
|
187
|
+
resolvePromise = resolve;
|
|
188
|
+
});
|
|
189
|
+
const FooterComponent = /* @__PURE__ */ __name(({ children }) => {
|
|
190
|
+
import_react.default.useEffect(() => {
|
|
191
|
+
var _a2;
|
|
192
|
+
(_a2 = pageRef.current) == null ? void 0 : _a2.setFooter(children);
|
|
193
|
+
return () => {
|
|
194
|
+
var _a3;
|
|
195
|
+
(_a3 = pageRef.current) == null ? void 0 : _a3.setFooter(null);
|
|
196
|
+
};
|
|
197
|
+
}, [children]);
|
|
198
|
+
return null;
|
|
199
|
+
}, "FooterComponent");
|
|
200
|
+
const HeaderComponent = /* @__PURE__ */ __name((props) => {
|
|
201
|
+
import_react.default.useEffect(() => {
|
|
202
|
+
var _a2;
|
|
203
|
+
(_a2 = pageRef.current) == null ? void 0 : _a2.setHeader(props);
|
|
204
|
+
return () => {
|
|
205
|
+
var _a3;
|
|
206
|
+
(_a3 = pageRef.current) == null ? void 0 : _a3.setHeader(null);
|
|
207
|
+
};
|
|
208
|
+
}, [props]);
|
|
209
|
+
return null;
|
|
210
|
+
}, "HeaderComponent");
|
|
211
|
+
const ctx = new import_flowContext.FlowContext();
|
|
212
|
+
const scopedEngine = (0, import_ViewScopedFlowEngine.createViewScopedEngine)(flowContext.engine);
|
|
213
|
+
const openerEngine = (0, import_viewEvents.resolveOpenerEngine)(parentEngine, scopedEngine);
|
|
214
|
+
ctx.defineProperty("engine", { value: scopedEngine });
|
|
215
|
+
ctx.addDelegate(scopedEngine.context);
|
|
216
|
+
if (inheritContext) {
|
|
217
|
+
ctx.addDelegate(flowContext);
|
|
218
|
+
} else {
|
|
219
|
+
ctx.addDelegate(flowContext.engine.context);
|
|
119
220
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
(0
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
221
|
+
let destroyed = false;
|
|
222
|
+
let closingPromise;
|
|
223
|
+
const currentPage = {
|
|
224
|
+
type: "embed",
|
|
225
|
+
inputArgs: viewInputArgs,
|
|
226
|
+
preventClose: !!config.preventClose,
|
|
227
|
+
beforeClose: void 0,
|
|
228
|
+
destroy: /* @__PURE__ */ __name((result) => {
|
|
229
|
+
var _a2, _b2, _c2, _d, _e;
|
|
230
|
+
if (destroyed) return;
|
|
231
|
+
destroyed = true;
|
|
232
|
+
(_a2 = config.onClose) == null ? void 0 : _a2.call(config);
|
|
233
|
+
resolvePromise == null ? void 0 : resolvePromise(result);
|
|
234
|
+
(_b2 = pageRef.current) == null ? void 0 : _b2.destroy();
|
|
235
|
+
closeFunc == null ? void 0 : closeFunc();
|
|
236
|
+
if (isGlobalEmbedContainer && globalEmbedActiveRef.current === currentPage) {
|
|
237
|
+
globalEmbedActiveRef.current = null;
|
|
238
|
+
}
|
|
239
|
+
const isReplacing = isGlobalEmbedContainer && target instanceof HTMLElement && ((_c2 = target.dataset) == null ? void 0 : _c2[EMBED_REPLACING_DATA_KEY]) === "1";
|
|
240
|
+
if (!isReplacing) {
|
|
241
|
+
const openerEmitter = openerEngine == null ? void 0 : openerEngine.emitter;
|
|
242
|
+
(0, import_viewEvents.bumpViewActivatedVersion)(openerEmitter);
|
|
243
|
+
(_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 });
|
|
244
|
+
}
|
|
245
|
+
scopedEngine.unlinkFromStack();
|
|
246
|
+
}, "destroy"),
|
|
247
|
+
update: /* @__PURE__ */ __name((newConfig) => {
|
|
248
|
+
var _a2;
|
|
249
|
+
return (_a2 = pageRef.current) == null ? void 0 : _a2.update(newConfig);
|
|
250
|
+
}, "update"),
|
|
251
|
+
close: /* @__PURE__ */ __name((result, force) => {
|
|
252
|
+
if (destroyed) {
|
|
253
|
+
return Promise.resolve(true);
|
|
254
|
+
}
|
|
255
|
+
if (closingPromise) {
|
|
256
|
+
return closingPromise;
|
|
257
|
+
}
|
|
258
|
+
closingPromise = (async () => {
|
|
259
|
+
var _a2, _b2;
|
|
260
|
+
try {
|
|
261
|
+
if (preventClose && !force) {
|
|
262
|
+
closingPromise = void 0;
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
const shouldClose = await (0, import_runViewBeforeClose.runViewBeforeClose)(currentPage, { result, force });
|
|
266
|
+
if (destroyed) {
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
if (!shouldClose) {
|
|
270
|
+
closingPromise = void 0;
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
if (config.triggerByRouter && ((_b2 = (_a2 = config.inputArgs) == null ? void 0 : _a2.navigation) == null ? void 0 : _b2.back)) {
|
|
274
|
+
config.inputArgs.navigation.back();
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
currentPage.destroy(result);
|
|
278
|
+
return true;
|
|
279
|
+
} catch (error) {
|
|
280
|
+
if (!destroyed) {
|
|
281
|
+
closingPromise = void 0;
|
|
282
|
+
}
|
|
283
|
+
throw error;
|
|
284
|
+
}
|
|
285
|
+
})();
|
|
286
|
+
return closingPromise;
|
|
287
|
+
}, "close"),
|
|
288
|
+
Header: HeaderComponent,
|
|
289
|
+
Footer: FooterComponent,
|
|
290
|
+
setFooter: /* @__PURE__ */ __name((footer) => {
|
|
291
|
+
var _a2;
|
|
292
|
+
(_a2 = pageRef.current) == null ? void 0 : _a2.setFooter(footer);
|
|
293
|
+
}, "setFooter"),
|
|
294
|
+
setHeader: /* @__PURE__ */ __name((header) => {
|
|
295
|
+
var _a2;
|
|
296
|
+
(_a2 = pageRef.current) == null ? void 0 : _a2.setHeader(header);
|
|
297
|
+
}, "setHeader"),
|
|
298
|
+
navigation: (_a = config.inputArgs) == null ? void 0 : _a.navigation,
|
|
299
|
+
get record() {
|
|
300
|
+
return (0, import_variablesParams.getViewRecordFromParent)(flowContext, ctx);
|
|
165
301
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
302
|
+
};
|
|
303
|
+
ctx.defineProperty("view", {
|
|
304
|
+
get: /* @__PURE__ */ __name(() => currentPage, "get"),
|
|
305
|
+
// 仅当访问关联字段或前端无本地记录数据时,才交给服务端解析
|
|
306
|
+
resolveOnServer: (0, import_variablesParams.createViewRecordResolveOnServer)(ctx, () => (0, import_variablesParams.getViewRecordFromParent)(flowContext, ctx))
|
|
307
|
+
});
|
|
308
|
+
(0, import_createViewMeta.registerPopupVariable)(ctx, currentPage);
|
|
309
|
+
const PageWithContext = (0, import__.observer)(
|
|
310
|
+
() => {
|
|
311
|
+
var _a2, _b2, _c2, _d;
|
|
312
|
+
const mountedRef = import_react.default.useRef(false);
|
|
313
|
+
const pageContent = import_react.default.useMemo(
|
|
314
|
+
() => typeof content === "function" ? content(currentPage, ctx) : content,
|
|
315
|
+
[]
|
|
316
|
+
);
|
|
317
|
+
void ctx.themeToken;
|
|
318
|
+
import_react.default.useEffect(() => {
|
|
319
|
+
var _a3;
|
|
320
|
+
(_a3 = config.onOpen) == null ? void 0 : _a3.call(config, currentPage, ctx);
|
|
321
|
+
}, []);
|
|
322
|
+
if (((_b2 = (_a2 = config.inputArgs) == null ? void 0 : _a2.hidden) == null ? void 0 : _b2.value) && !mountedRef.current) {
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
mountedRef.current = true;
|
|
326
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
327
|
+
import_PageComponent.PageComponent,
|
|
328
|
+
{
|
|
329
|
+
ref: pageRef,
|
|
330
|
+
hidden: (_d = (_c2 = config.inputArgs) == null ? void 0 : _c2.hidden) == null ? void 0 : _d.value,
|
|
331
|
+
...restConfig,
|
|
332
|
+
onClose: () => {
|
|
333
|
+
return currentPage.close(config.result);
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
pageContent
|
|
337
|
+
);
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
displayName: "PageWithContext"
|
|
169
341
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
(_a2 = pageRef.current) == null ? void 0 : _a2.setFooter(footer);
|
|
178
|
-
}, "setFooter"),
|
|
179
|
-
setHeader: /* @__PURE__ */ __name((header) => {
|
|
180
|
-
var _a2;
|
|
181
|
-
(_a2 = pageRef.current) == null ? void 0 : _a2.setHeader(header);
|
|
182
|
-
}, "setHeader"),
|
|
183
|
-
navigation: (_a = config.inputArgs) == null ? void 0 : _a.navigation,
|
|
184
|
-
get record() {
|
|
185
|
-
return (0, import_variablesParams.getViewRecordFromParent)(flowContext, ctx);
|
|
342
|
+
);
|
|
343
|
+
const key = (viewInputArgs == null ? void 0 : viewInputArgs.viewUid) || `page-${uuid}`;
|
|
344
|
+
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)));
|
|
345
|
+
if (target && target instanceof HTMLElement) {
|
|
346
|
+
closeFunc = (_b = holderRef.current) == null ? void 0 : _b.patchElement(import_react_dom.default.createPortal(page, target, key));
|
|
347
|
+
} else {
|
|
348
|
+
closeFunc = (_c = holderRef.current) == null ? void 0 : _c.patchElement(page);
|
|
186
349
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
hidden: (_d = (_c2 = config.inputArgs) == null ? void 0 : _c2.hidden) == null ? void 0 : _d.value,
|
|
216
|
-
...restConfig,
|
|
217
|
-
onClose: () => {
|
|
218
|
-
currentPage.close(config.result);
|
|
350
|
+
if (isGlobalEmbedContainer) {
|
|
351
|
+
globalEmbedActiveRef.current = currentPage;
|
|
352
|
+
}
|
|
353
|
+
return Object.assign(promise, currentPage);
|
|
354
|
+
}, "openCurrentPage");
|
|
355
|
+
if (isGlobalEmbedContainer && globalEmbedActiveRef.current) {
|
|
356
|
+
const replacementToken = globalEmbedReplacementTokenRef.current += 1;
|
|
357
|
+
const cancelOpen = /* @__PURE__ */ __name(() => onOpenCancelled == null ? void 0 : onOpenCancelled(), "cancelOpen");
|
|
358
|
+
let closeResult;
|
|
359
|
+
try {
|
|
360
|
+
closeResult = closeReplacingGlobalEmbed(target, globalEmbedActiveRef.current);
|
|
361
|
+
} catch (error) {
|
|
362
|
+
cancelOpen();
|
|
363
|
+
throw error;
|
|
364
|
+
}
|
|
365
|
+
if (isPromiseLike(closeResult)) {
|
|
366
|
+
return createPendingGlobalEmbedView(
|
|
367
|
+
Promise.resolve(closeResult).then(
|
|
368
|
+
(closed) => {
|
|
369
|
+
if (closed === false || replacementToken !== globalEmbedReplacementTokenRef.current) {
|
|
370
|
+
cancelOpen();
|
|
371
|
+
return { page: null };
|
|
372
|
+
}
|
|
373
|
+
return { page: openCurrentPage() };
|
|
374
|
+
},
|
|
375
|
+
(error) => {
|
|
376
|
+
cancelOpen();
|
|
377
|
+
throw error;
|
|
219
378
|
}
|
|
220
|
-
|
|
221
|
-
|
|
379
|
+
),
|
|
380
|
+
viewInputArgs,
|
|
381
|
+
!!config.preventClose
|
|
222
382
|
);
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
displayName: "PageWithContext"
|
|
226
383
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
closeFunc = (_b = holderRef.current) == null ? void 0 : _b.patchElement(import_react_dom.default.createPortal(page, target, key));
|
|
232
|
-
} else {
|
|
233
|
-
closeFunc = (_c = holderRef.current) == null ? void 0 : _c.patchElement(page);
|
|
234
|
-
}
|
|
235
|
-
if (isGlobalEmbedContainer) {
|
|
236
|
-
globalEmbedActiveRef.current = { destroy: currentPage.destroy };
|
|
384
|
+
if (closeResult === false) {
|
|
385
|
+
cancelOpen();
|
|
386
|
+
return createPendingGlobalEmbedView(Promise.resolve({ page: null }), viewInputArgs, !!config.preventClose);
|
|
387
|
+
}
|
|
237
388
|
}
|
|
238
|
-
return
|
|
389
|
+
return openCurrentPage();
|
|
239
390
|
}, "open");
|
|
240
391
|
const api = import_react.default.useMemo(() => ({ open }), []);
|
|
241
392
|
return [api, /* @__PURE__ */ import_react.default.createElement(PageElementsHolder, { key: "page-holder", ref: holderRef })];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/flow-engine",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.37",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A standalone flow engine for NocoBase, managing workflows, models, and actions.",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@formily/antd-v5": "1.x",
|
|
10
10
|
"@formily/reactive": "2.x",
|
|
11
|
-
"@nocobase/sdk": "2.1.0-alpha.
|
|
12
|
-
"@nocobase/shared": "2.1.0-alpha.
|
|
11
|
+
"@nocobase/sdk": "2.1.0-alpha.37",
|
|
12
|
+
"@nocobase/shared": "2.1.0-alpha.37",
|
|
13
13
|
"ahooks": "^3.7.2",
|
|
14
14
|
"axios": "^1.7.0",
|
|
15
15
|
"dayjs": "^1.11.9",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
],
|
|
38
38
|
"author": "NocoBase Team",
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "8b45f4586ea5b386b376188cfc1012ec12e9bc8b"
|
|
41
41
|
}
|