@nocobase/flow-engine 2.1.21 → 2.1.23
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/MobilePopup.js +28 -10
- package/lib/components/MobilePopup.style.js +12 -2
- package/lib/utils/dirtyAwareApiClient.js +267 -13
- package/package.json +4 -4
- package/src/components/MobilePopup.style.ts +13 -2
- package/src/components/MobilePopup.tsx +30 -10
- package/src/components/__tests__/MobilePopup.test.tsx +109 -0
- package/src/utils/__tests__/dirtyAwareApiClient.test.ts +321 -0
- package/src/utils/dirtyAwareApiClient.ts +325 -13
|
@@ -48,14 +48,34 @@ var import_lazy_helper = require("../lazy-helper");
|
|
|
48
48
|
const { Popup } = (0, import_lazy_helper.lazy)(() => import("antd-mobile"), "Popup");
|
|
49
49
|
const { CloseOutline } = (0, import_lazy_helper.lazy)(() => import("antd-mobile-icons"), "CloseOutline");
|
|
50
50
|
const MobilePopup = /* @__PURE__ */ __name((props) => {
|
|
51
|
+
var _a;
|
|
51
52
|
const { title, visible, onClose: closePopup, children, minHeight, className, footer } = props;
|
|
52
53
|
const { t } = (0, import_react_i18next.useTranslation)();
|
|
53
54
|
const { componentCls, hashId } = (0, import_MobilePopup.useMobileActionDrawerStyle)();
|
|
54
|
-
const
|
|
55
|
+
const bodyStyles = (_a = props.styles) == null ? void 0 : _a.body;
|
|
56
|
+
const popupStyle = (0, import_react.useMemo)(() => {
|
|
55
57
|
return {
|
|
56
|
-
minHeight
|
|
58
|
+
minHeight: (bodyStyles == null ? void 0 : bodyStyles.minHeight) ?? minHeight,
|
|
59
|
+
height: bodyStyles == null ? void 0 : bodyStyles.height,
|
|
60
|
+
maxHeight: bodyStyles == null ? void 0 : bodyStyles.maxHeight
|
|
57
61
|
};
|
|
58
|
-
}, [minHeight]);
|
|
62
|
+
}, [bodyStyles == null ? void 0 : bodyStyles.height, bodyStyles == null ? void 0 : bodyStyles.maxHeight, bodyStyles == null ? void 0 : bodyStyles.minHeight, minHeight]);
|
|
63
|
+
const bodyStyle = (0, import_react.useMemo)(() => {
|
|
64
|
+
return {
|
|
65
|
+
padding: 0,
|
|
66
|
+
...bodyStyles
|
|
67
|
+
};
|
|
68
|
+
}, [bodyStyles]);
|
|
69
|
+
const handleCloseKeyDown = (0, import_react.useCallback)(
|
|
70
|
+
(event) => {
|
|
71
|
+
if (event.key !== "Enter" && event.key !== " ") {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
closePopup();
|
|
76
|
+
},
|
|
77
|
+
[closePopup]
|
|
78
|
+
);
|
|
59
79
|
const theme = (0, import_react.useMemo)(() => {
|
|
60
80
|
return {
|
|
61
81
|
token: {
|
|
@@ -75,21 +95,19 @@ const MobilePopup = /* @__PURE__ */ __name((props) => {
|
|
|
75
95
|
onClose: closePopup,
|
|
76
96
|
onMaskClick: closePopup,
|
|
77
97
|
bodyClassName: "nb-mobile-action-drawer-body",
|
|
78
|
-
bodyStyle
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
maskStyle: style,
|
|
82
|
-
style,
|
|
98
|
+
bodyStyle,
|
|
99
|
+
style: popupStyle,
|
|
83
100
|
destroyOnClose: true
|
|
84
101
|
},
|
|
85
|
-
/* @__PURE__ */ import_react.default.createElement("div", { className: "nb-mobile-action-drawer-header" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "nb-mobile-action-drawer-placeholder" }, /* @__PURE__ */ import_react.default.createElement(CloseOutline, null)), /* @__PURE__ */ import_react.default.createElement("span",
|
|
102
|
+
/* @__PURE__ */ import_react.default.createElement("div", { className: "nb-mobile-action-drawer-header" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "nb-mobile-action-drawer-placeholder" }, /* @__PURE__ */ import_react.default.createElement(CloseOutline, null)), /* @__PURE__ */ import_react.default.createElement("span", { className: "nb-mobile-action-drawer-title" }, title), /* @__PURE__ */ import_react.default.createElement(
|
|
86
103
|
"span",
|
|
87
104
|
{
|
|
88
105
|
className: "nb-mobile-action-drawer-close-icon",
|
|
89
106
|
onClick: closePopup,
|
|
90
107
|
role: "button",
|
|
91
108
|
tabIndex: 0,
|
|
92
|
-
"aria-label": t("Close")
|
|
109
|
+
"aria-label": t("Close"),
|
|
110
|
+
onKeyDown: handleCloseKeyDown
|
|
93
111
|
},
|
|
94
112
|
/* @__PURE__ */ import_react.default.createElement(CloseOutline, null)
|
|
95
113
|
)),
|
|
@@ -98,7 +98,7 @@ const genStyleHook = /* @__PURE__ */ __name((component, styleFn) => {
|
|
|
98
98
|
);
|
|
99
99
|
const memoizedWrapSSR = (0, import_react.useMemo)(() => {
|
|
100
100
|
return wrapSSR;
|
|
101
|
-
}, [
|
|
101
|
+
}, [wrapSSR]);
|
|
102
102
|
return {
|
|
103
103
|
wrapSSR: memoizedWrapSSR,
|
|
104
104
|
hashId,
|
|
@@ -119,7 +119,7 @@ const useMobileActionDrawerStyle = genStyleHook("nb-mobile-action-drawer", (toke
|
|
|
119
119
|
borderBottom: `1px solid ${token.colorSplit}`,
|
|
120
120
|
position: "sticky",
|
|
121
121
|
top: 0,
|
|
122
|
-
backgroundColor:
|
|
122
|
+
backgroundColor: token.colorBgContainer,
|
|
123
123
|
zIndex: 1e3,
|
|
124
124
|
// to match the button named 'Add block'
|
|
125
125
|
"& + .nb-grid-container > .nb-grid > .nb-grid-warp > .ant-btn": {
|
|
@@ -129,11 +129,21 @@ const useMobileActionDrawerStyle = genStyleHook("nb-mobile-action-drawer", (toke
|
|
|
129
129
|
".nb-mobile-action-drawer-placeholder": {
|
|
130
130
|
display: "inline-block",
|
|
131
131
|
padding: 12,
|
|
132
|
+
flex: "0 0 auto",
|
|
132
133
|
visibility: "hidden"
|
|
133
134
|
},
|
|
135
|
+
".nb-mobile-action-drawer-title": {
|
|
136
|
+
flex: "1 1 auto",
|
|
137
|
+
minWidth: 0,
|
|
138
|
+
overflow: "hidden",
|
|
139
|
+
textAlign: "center",
|
|
140
|
+
textOverflow: "ellipsis",
|
|
141
|
+
whiteSpace: "nowrap"
|
|
142
|
+
},
|
|
134
143
|
".nb-mobile-action-drawer-close-icon": {
|
|
135
144
|
display: "inline-block",
|
|
136
145
|
padding: 12,
|
|
146
|
+
flex: "0 0 auto",
|
|
137
147
|
cursor: "pointer"
|
|
138
148
|
},
|
|
139
149
|
".nb-mobile-action-drawer-body": {
|
|
@@ -31,8 +31,10 @@ __export(dirtyAwareApiClient_exports, {
|
|
|
31
31
|
getDirtyAwareApiClient: () => getDirtyAwareApiClient
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(dirtyAwareApiClient_exports);
|
|
34
|
+
var import_sdk = require("@nocobase/sdk");
|
|
34
35
|
var import_dataSourceDirty = require("./dataSourceDirty");
|
|
35
36
|
const SKIP_DATA_SOURCE_DIRTY = "__nocobaseSkipDataSourceDirty";
|
|
37
|
+
const DIRTY_DISPATCH_TOKEN = Symbol("nocobaseDirtyDispatchToken");
|
|
36
38
|
const dirtyAwareApiClientCache = /* @__PURE__ */ new WeakMap();
|
|
37
39
|
const dirtyAwareApiClientProxies = /* @__PURE__ */ new WeakSet();
|
|
38
40
|
const MUTATING_RESOURCE_ACTIONS = [
|
|
@@ -288,6 +290,43 @@ function resolveDirtyResourceAction(options, context) {
|
|
|
288
290
|
return parseDirtyResourceActionFromUrl(options == null ? void 0 : options.url, context);
|
|
289
291
|
}
|
|
290
292
|
__name(resolveDirtyResourceAction, "resolveDirtyResourceAction");
|
|
293
|
+
function getDirtyResourceActionDispatchKey(dirtyResourceAction, headers) {
|
|
294
|
+
if (!dirtyResourceAction) {
|
|
295
|
+
return void 0;
|
|
296
|
+
}
|
|
297
|
+
return JSON.stringify([
|
|
298
|
+
dirtyResourceAction.dataSourceKey || (0, import_dataSourceDirty.getDataSourceKeyFromHeaders)(headers),
|
|
299
|
+
dirtyResourceAction.resourceName,
|
|
300
|
+
dirtyResourceAction.actionName
|
|
301
|
+
]);
|
|
302
|
+
}
|
|
303
|
+
__name(getDirtyResourceActionDispatchKey, "getDirtyResourceActionDispatchKey");
|
|
304
|
+
function getRequestDispatchKey(options, context) {
|
|
305
|
+
return getDirtyResourceActionDispatchKey(resolveDirtyResourceAction(options, context), options.headers);
|
|
306
|
+
}
|
|
307
|
+
__name(getRequestDispatchKey, "getRequestDispatchKey");
|
|
308
|
+
function getResourceDispatchKey(name, of, headers) {
|
|
309
|
+
const resourceName = String(name ?? "").trim();
|
|
310
|
+
if (!resourceName) {
|
|
311
|
+
return void 0;
|
|
312
|
+
}
|
|
313
|
+
return JSON.stringify([resourceName, String(of ?? ""), (0, import_dataSourceDirty.getDataSourceKeyFromHeaders)(headers)]);
|
|
314
|
+
}
|
|
315
|
+
__name(getResourceDispatchKey, "getResourceDispatchKey");
|
|
316
|
+
function getMatchingRequestToken(token, requestKey) {
|
|
317
|
+
if (!token || !requestKey || token.requestKey && token.requestKey !== requestKey) {
|
|
318
|
+
return void 0;
|
|
319
|
+
}
|
|
320
|
+
return token;
|
|
321
|
+
}
|
|
322
|
+
__name(getMatchingRequestToken, "getMatchingRequestToken");
|
|
323
|
+
function getMatchingResourceToken(token, resourceKey) {
|
|
324
|
+
if (!token || !resourceKey || token.resourceKey && token.resourceKey !== resourceKey) {
|
|
325
|
+
return void 0;
|
|
326
|
+
}
|
|
327
|
+
return token;
|
|
328
|
+
}
|
|
329
|
+
__name(getMatchingResourceToken, "getMatchingResourceToken");
|
|
291
330
|
function markResourceActionDataSourceDirty(context, dirtyResourceAction, headers) {
|
|
292
331
|
(0, import_dataSourceDirty.markDataSourceDirty)({
|
|
293
332
|
engine: context.engine,
|
|
@@ -297,7 +336,19 @@ function markResourceActionDataSourceDirty(context, dirtyResourceAction, headers
|
|
|
297
336
|
});
|
|
298
337
|
}
|
|
299
338
|
__name(markResourceActionDataSourceDirty, "markResourceActionDataSourceDirty");
|
|
300
|
-
function
|
|
339
|
+
function markResourceActionDataSourceDirtyOnce(token, context, dirtyResourceAction, headers) {
|
|
340
|
+
if (token.skip || token.marked || !dirtyResourceAction || !isMutatingResourceAction(dirtyResourceAction.actionName)) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
token.marked = true;
|
|
344
|
+
markResourceActionDataSourceDirty(context, dirtyResourceAction, headers);
|
|
345
|
+
}
|
|
346
|
+
__name(markResourceActionDataSourceDirtyOnce, "markResourceActionDataSourceDirtyOnce");
|
|
347
|
+
function isObjectRecord(value) {
|
|
348
|
+
return !!value && typeof value === "object";
|
|
349
|
+
}
|
|
350
|
+
__name(isObjectRecord, "isObjectRecord");
|
|
351
|
+
function createDirtyAwareResource(context, resource, resourceName, resourceOf, headers, requestTokenStack, parentToken) {
|
|
301
352
|
return new Proxy(resource, {
|
|
302
353
|
get(target, prop, receiver) {
|
|
303
354
|
const original = Reflect.get(target, prop, receiver);
|
|
@@ -306,10 +357,38 @@ function createDirtyAwareResource(context, resource, resourceName, resourceOf, h
|
|
|
306
357
|
}
|
|
307
358
|
const action = original;
|
|
308
359
|
return async (...args) => {
|
|
309
|
-
const
|
|
360
|
+
const actionOptions = isObjectRecord(args[1]) ? args[1] : void 0;
|
|
310
361
|
const dirtyResourceAction = resolveDirtyResourceActionFromResource(resourceName, resourceOf, prop, context);
|
|
311
|
-
|
|
312
|
-
|
|
362
|
+
const requestKey = getDirtyResourceActionDispatchKey(dirtyResourceAction, headers);
|
|
363
|
+
const resourceKey = getResourceDispatchKey(resourceName, resourceOf, headers);
|
|
364
|
+
const inheritedToken = getMatchingRequestToken(
|
|
365
|
+
actionOptions == null ? void 0 : actionOptions[DIRTY_DISPATCH_TOKEN],
|
|
366
|
+
requestKey
|
|
367
|
+
) || getMatchingRequestToken(parentToken, requestKey);
|
|
368
|
+
const token = inheritedToken || { marked: false, skip: false };
|
|
369
|
+
const ownsToken = !inheritedToken;
|
|
370
|
+
token.requestKey ||= requestKey;
|
|
371
|
+
token.resourceKey ||= resourceKey;
|
|
372
|
+
if (actionOptions == null ? void 0 : actionOptions[SKIP_DATA_SOURCE_DIRTY]) {
|
|
373
|
+
token.skip = true;
|
|
374
|
+
}
|
|
375
|
+
const forwardedArgs = actionOptions || args[1] == null ? [
|
|
376
|
+
args[0],
|
|
377
|
+
{
|
|
378
|
+
...actionOptions,
|
|
379
|
+
[DIRTY_DISPATCH_TOKEN]: token
|
|
380
|
+
}
|
|
381
|
+
] : args;
|
|
382
|
+
let actionResult;
|
|
383
|
+
requestTokenStack.push({ key: requestKey, token });
|
|
384
|
+
try {
|
|
385
|
+
actionResult = Reflect.apply(action, receiver, forwardedArgs);
|
|
386
|
+
} finally {
|
|
387
|
+
requestTokenStack.pop();
|
|
388
|
+
}
|
|
389
|
+
const result = await actionResult;
|
|
390
|
+
if (ownsToken) {
|
|
391
|
+
markResourceActionDataSourceDirtyOnce(token, context, dirtyResourceAction, headers);
|
|
313
392
|
}
|
|
314
393
|
return result;
|
|
315
394
|
};
|
|
@@ -318,31 +397,206 @@ function createDirtyAwareResource(context, resource, resourceName, resourceOf, h
|
|
|
318
397
|
}
|
|
319
398
|
__name(createDirtyAwareResource, "createDirtyAwareResource");
|
|
320
399
|
function createDirtyAwareApiClient(api, context) {
|
|
400
|
+
const baseResource = api.resource;
|
|
401
|
+
const baseRequest = api.request;
|
|
402
|
+
const shouldUseResourceDispatchReceiver = baseResource === import_sdk.APIClient.prototype.resource;
|
|
403
|
+
const shouldUseRequestDispatchReceiver = baseRequest === import_sdk.APIClient.prototype.request;
|
|
404
|
+
const resourceTokenStack = [];
|
|
405
|
+
const requestTokenStack = [];
|
|
406
|
+
let hasResourceOverride = false;
|
|
407
|
+
let resourceOverride;
|
|
408
|
+
let hasRequestOverride = false;
|
|
409
|
+
let requestOverride;
|
|
410
|
+
const getCurrentResource = /* @__PURE__ */ __name(() => hasResourceOverride ? resourceOverride : resource, "getCurrentResource");
|
|
411
|
+
const getCurrentRequest = /* @__PURE__ */ __name(() => hasRequestOverride ? requestOverride : request, "getCurrentRequest");
|
|
412
|
+
const dispatchResource = /* @__PURE__ */ __name((token, args) => {
|
|
413
|
+
const resourceKey = getResourceDispatchKey(args[0], args[1], args[2]);
|
|
414
|
+
const activeToken = getMatchingResourceToken(token, resourceKey);
|
|
415
|
+
const shouldWrapActions = !!activeToken && hasResourceOverride;
|
|
416
|
+
if (activeToken) {
|
|
417
|
+
activeToken.resourceKey ||= resourceKey;
|
|
418
|
+
resourceTokenStack.push({ key: resourceKey, token: activeToken });
|
|
419
|
+
}
|
|
420
|
+
try {
|
|
421
|
+
const resourceInstance = Reflect.apply(getCurrentResource(), proxy, args);
|
|
422
|
+
if (!shouldWrapActions || !activeToken) {
|
|
423
|
+
return resourceInstance;
|
|
424
|
+
}
|
|
425
|
+
return new Proxy(resourceInstance, {
|
|
426
|
+
get(target, prop, receiver) {
|
|
427
|
+
const original = Reflect.get(target, prop, receiver);
|
|
428
|
+
if (typeof prop !== "string" || typeof original !== "function" || !isMutatingResourceAction(prop)) {
|
|
429
|
+
return original;
|
|
430
|
+
}
|
|
431
|
+
const action = original;
|
|
432
|
+
return (...actionArgs) => {
|
|
433
|
+
const actionOptions = isObjectRecord(actionArgs[1]) ? actionArgs[1] : void 0;
|
|
434
|
+
const forwardedArgs = actionOptions || actionArgs[1] == null ? [
|
|
435
|
+
actionArgs[0],
|
|
436
|
+
{
|
|
437
|
+
...actionOptions,
|
|
438
|
+
[DIRTY_DISPATCH_TOKEN]: activeToken
|
|
439
|
+
}
|
|
440
|
+
] : actionArgs;
|
|
441
|
+
resourceTokenStack.push({ key: resourceKey, token: activeToken });
|
|
442
|
+
requestTokenStack.push({ key: activeToken.requestKey, token: activeToken });
|
|
443
|
+
try {
|
|
444
|
+
return Reflect.apply(action, receiver, forwardedArgs);
|
|
445
|
+
} finally {
|
|
446
|
+
requestTokenStack.pop();
|
|
447
|
+
resourceTokenStack.pop();
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
} finally {
|
|
453
|
+
if (activeToken) {
|
|
454
|
+
resourceTokenStack.pop();
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}, "dispatchResource");
|
|
458
|
+
const createDispatchReceiver = /* @__PURE__ */ __name((token) => {
|
|
459
|
+
const receiver = Object.create(api);
|
|
460
|
+
Object.defineProperties(receiver, {
|
|
461
|
+
request: {
|
|
462
|
+
configurable: true,
|
|
463
|
+
value: /* @__PURE__ */ __name((config) => {
|
|
464
|
+
const options = config;
|
|
465
|
+
const requestKey = getRequestDispatchKey(options, context);
|
|
466
|
+
const stackFrame = requestTokenStack.at(-1);
|
|
467
|
+
const activeToken = getMatchingRequestToken(options == null ? void 0 : options[DIRTY_DISPATCH_TOKEN], requestKey) || (requestKey && (stackFrame == null ? void 0 : stackFrame.key) === requestKey ? stackFrame.token : void 0) || getMatchingRequestToken(token, requestKey);
|
|
468
|
+
const { [DIRTY_DISPATCH_TOKEN]: _dirtyDispatchToken, ...cleanOptions } = options;
|
|
469
|
+
const configWithToken = activeToken ? { ...cleanOptions, [DIRTY_DISPATCH_TOKEN]: activeToken } : cleanOptions;
|
|
470
|
+
if (activeToken) {
|
|
471
|
+
activeToken.requestKey ||= requestKey;
|
|
472
|
+
requestTokenStack.push({ key: requestKey, token: activeToken });
|
|
473
|
+
}
|
|
474
|
+
try {
|
|
475
|
+
return Reflect.apply(getCurrentRequest(), proxy, [configWithToken]);
|
|
476
|
+
} finally {
|
|
477
|
+
if (activeToken) {
|
|
478
|
+
requestTokenStack.pop();
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}, "value")
|
|
482
|
+
},
|
|
483
|
+
resource: {
|
|
484
|
+
configurable: true,
|
|
485
|
+
value: /* @__PURE__ */ __name((...args) => {
|
|
486
|
+
const resourceKey = getResourceDispatchKey(args[0], args[1], args[2]);
|
|
487
|
+
const stackFrame = resourceTokenStack.at(-1);
|
|
488
|
+
const activeToken = getMatchingResourceToken(token, resourceKey) || (resourceKey && (stackFrame == null ? void 0 : stackFrame.key) === resourceKey ? stackFrame.token : void 0);
|
|
489
|
+
return dispatchResource(activeToken, args);
|
|
490
|
+
}, "value")
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
return receiver;
|
|
494
|
+
}, "createDispatchReceiver");
|
|
321
495
|
const resource = /* @__PURE__ */ __name((name, of, headers, cancel) => {
|
|
322
|
-
const
|
|
323
|
-
|
|
496
|
+
const resourceKey = getResourceDispatchKey(name, of, headers);
|
|
497
|
+
const stackFrame = resourceTokenStack.at(-1);
|
|
498
|
+
const parentToken = resourceKey && (stackFrame == null ? void 0 : stackFrame.key) === resourceKey ? stackFrame.token : void 0;
|
|
499
|
+
const receiver = createDispatchReceiver(parentToken);
|
|
500
|
+
const resourceInstance = Reflect.apply(baseResource, shouldUseResourceDispatchReceiver ? receiver : api, [
|
|
501
|
+
name,
|
|
502
|
+
of,
|
|
503
|
+
headers,
|
|
504
|
+
cancel
|
|
505
|
+
]);
|
|
506
|
+
return createDirtyAwareResource(context, resourceInstance, name, of, headers, requestTokenStack, parentToken);
|
|
324
507
|
}, "resource");
|
|
325
508
|
const request = /* @__PURE__ */ __name((config) => {
|
|
326
509
|
const options = config;
|
|
510
|
+
const requestKey = getRequestDispatchKey(options, context);
|
|
511
|
+
const stackFrame = requestTokenStack.at(-1);
|
|
512
|
+
const inheritedToken = getMatchingRequestToken(options == null ? void 0 : options[DIRTY_DISPATCH_TOKEN], requestKey) || (requestKey && (stackFrame == null ? void 0 : stackFrame.key) === requestKey ? stackFrame.token : void 0);
|
|
513
|
+
const token = inheritedToken || { marked: false, skip: false };
|
|
514
|
+
const ownsToken = !inheritedToken;
|
|
515
|
+
token.requestKey ||= requestKey;
|
|
516
|
+
if (typeof options.resource === "string") {
|
|
517
|
+
token.resourceKey ||= getResourceDispatchKey(options.resource, options.resourceOf, options.headers);
|
|
518
|
+
}
|
|
327
519
|
const skipDataSourceDirty = options == null ? void 0 : options[SKIP_DATA_SOURCE_DIRTY];
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
520
|
+
if (skipDataSourceDirty) {
|
|
521
|
+
token.skip = true;
|
|
522
|
+
}
|
|
523
|
+
const dirtyResourceAction = resolveDirtyResourceAction(options, context);
|
|
524
|
+
const {
|
|
525
|
+
[DIRTY_DISPATCH_TOKEN]: _dirtyDispatchToken,
|
|
526
|
+
[SKIP_DATA_SOURCE_DIRTY]: _skipDataSourceDirty,
|
|
527
|
+
...cleanConfig
|
|
528
|
+
} = options;
|
|
529
|
+
const receiver = createDispatchReceiver(token);
|
|
530
|
+
return Reflect.apply(baseRequest, shouldUseRequestDispatchReceiver ? receiver : api, [cleanConfig]).then((result) => {
|
|
531
|
+
if (ownsToken) {
|
|
532
|
+
markResourceActionDataSourceDirtyOnce(token, context, dirtyResourceAction, options.headers);
|
|
333
533
|
}
|
|
334
534
|
return result;
|
|
335
535
|
});
|
|
336
536
|
}, "request");
|
|
537
|
+
const isLockedOwnProperty = /* @__PURE__ */ __name((target, prop) => {
|
|
538
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
539
|
+
return !!descriptor && !descriptor.configurable;
|
|
540
|
+
}, "isLockedOwnProperty");
|
|
337
541
|
const proxy = new Proxy(api, {
|
|
338
542
|
get(target, prop, receiver) {
|
|
339
543
|
if (prop === "resource") {
|
|
340
|
-
|
|
544
|
+
if (isLockedOwnProperty(target, prop)) {
|
|
545
|
+
return Reflect.get(target, prop, receiver);
|
|
546
|
+
}
|
|
547
|
+
return hasResourceOverride ? resourceOverride : resource;
|
|
341
548
|
}
|
|
342
549
|
if (prop === "request") {
|
|
343
|
-
|
|
550
|
+
if (isLockedOwnProperty(target, prop)) {
|
|
551
|
+
return Reflect.get(target, prop, receiver);
|
|
552
|
+
}
|
|
553
|
+
return hasRequestOverride ? requestOverride : request;
|
|
344
554
|
}
|
|
345
555
|
return Reflect.get(target, prop, receiver);
|
|
556
|
+
},
|
|
557
|
+
set(target, prop, value, receiver) {
|
|
558
|
+
if (prop === "resource") {
|
|
559
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
560
|
+
if (descriptor && (!descriptor.configurable || !Reflect.isExtensible(target))) {
|
|
561
|
+
return false;
|
|
562
|
+
}
|
|
563
|
+
hasResourceOverride = true;
|
|
564
|
+
resourceOverride = value;
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
567
|
+
if (prop === "request") {
|
|
568
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
569
|
+
if (descriptor && (!descriptor.configurable || !Reflect.isExtensible(target))) {
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
hasRequestOverride = true;
|
|
573
|
+
requestOverride = value;
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
return Reflect.set(target, prop, value, receiver);
|
|
577
|
+
},
|
|
578
|
+
deleteProperty(target, prop) {
|
|
579
|
+
if (prop !== "resource" && prop !== "request") {
|
|
580
|
+
return Reflect.deleteProperty(target, prop);
|
|
581
|
+
}
|
|
582
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
583
|
+
if (descriptor && (!descriptor.configurable || !Reflect.isExtensible(target))) {
|
|
584
|
+
return false;
|
|
585
|
+
}
|
|
586
|
+
if (prop === "resource") {
|
|
587
|
+
hasResourceOverride = false;
|
|
588
|
+
resourceOverride = void 0;
|
|
589
|
+
} else {
|
|
590
|
+
hasRequestOverride = false;
|
|
591
|
+
requestOverride = void 0;
|
|
592
|
+
}
|
|
593
|
+
return true;
|
|
594
|
+
},
|
|
595
|
+
defineProperty(target, prop, descriptor) {
|
|
596
|
+
if (prop === "resource" || prop === "request") {
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
return Reflect.defineProperty(target, prop, descriptor);
|
|
346
600
|
}
|
|
347
601
|
});
|
|
348
602
|
dirtyAwareApiClientProxies.add(proxy);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/flow-engine",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.23",
|
|
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.
|
|
12
|
-
"@nocobase/shared": "2.1.
|
|
11
|
+
"@nocobase/sdk": "2.1.23",
|
|
12
|
+
"@nocobase/shared": "2.1.23",
|
|
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": "ae4b0097a6c5e4a1347431a5fde24676032ce0ce"
|
|
41
41
|
}
|
|
@@ -124,7 +124,7 @@ const genStyleHook = <ComponentName extends OverrideComponent>(
|
|
|
124
124
|
// 等 https://github.com/ant-design/cssinjs/pull/176 合并后,可以去掉这层缓存
|
|
125
125
|
const memoizedWrapSSR = useMemo(() => {
|
|
126
126
|
return wrapSSR;
|
|
127
|
-
}, [
|
|
127
|
+
}, [wrapSSR]);
|
|
128
128
|
|
|
129
129
|
return {
|
|
130
130
|
wrapSSR: memoizedWrapSSR,
|
|
@@ -147,7 +147,7 @@ export const useMobileActionDrawerStyle = genStyleHook('nb-mobile-action-drawer'
|
|
|
147
147
|
borderBottom: `1px solid ${token.colorSplit}`,
|
|
148
148
|
position: 'sticky',
|
|
149
149
|
top: 0,
|
|
150
|
-
backgroundColor:
|
|
150
|
+
backgroundColor: token.colorBgContainer,
|
|
151
151
|
zIndex: 1000,
|
|
152
152
|
|
|
153
153
|
// to match the button named 'Add block'
|
|
@@ -159,12 +159,23 @@ export const useMobileActionDrawerStyle = genStyleHook('nb-mobile-action-drawer'
|
|
|
159
159
|
'.nb-mobile-action-drawer-placeholder': {
|
|
160
160
|
display: 'inline-block',
|
|
161
161
|
padding: 12,
|
|
162
|
+
flex: '0 0 auto',
|
|
162
163
|
visibility: 'hidden',
|
|
163
164
|
},
|
|
164
165
|
|
|
166
|
+
'.nb-mobile-action-drawer-title': {
|
|
167
|
+
flex: '1 1 auto',
|
|
168
|
+
minWidth: 0,
|
|
169
|
+
overflow: 'hidden',
|
|
170
|
+
textAlign: 'center',
|
|
171
|
+
textOverflow: 'ellipsis',
|
|
172
|
+
whiteSpace: 'nowrap',
|
|
173
|
+
},
|
|
174
|
+
|
|
165
175
|
'.nb-mobile-action-drawer-close-icon': {
|
|
166
176
|
display: 'inline-block',
|
|
167
177
|
padding: 12,
|
|
178
|
+
flex: '0 0 auto',
|
|
168
179
|
cursor: 'pointer',
|
|
169
180
|
},
|
|
170
181
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { ConfigProvider } from 'antd';
|
|
11
|
-
import React, { FC, ReactNode, useMemo } from 'react';
|
|
11
|
+
import React, { FC, ReactNode, useCallback, useMemo } from 'react';
|
|
12
12
|
import { useMobileActionDrawerStyle } from './MobilePopup.style';
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
14
|
import { lazy } from '../lazy-helper';
|
|
@@ -31,11 +31,33 @@ export const MobilePopup: FC<MobilePopupProps> = (props) => {
|
|
|
31
31
|
const { t } = useTranslation();
|
|
32
32
|
const { componentCls, hashId } = useMobileActionDrawerStyle();
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const bodyStyles = (props as MobilePopupProps & { styles?: { body?: React.CSSProperties } }).styles?.body;
|
|
35
|
+
const popupStyle = useMemo(() => {
|
|
35
36
|
return {
|
|
36
|
-
minHeight,
|
|
37
|
+
minHeight: bodyStyles?.minHeight ?? minHeight,
|
|
38
|
+
height: bodyStyles?.height,
|
|
39
|
+
maxHeight: bodyStyles?.maxHeight,
|
|
37
40
|
};
|
|
38
|
-
}, [minHeight]);
|
|
41
|
+
}, [bodyStyles?.height, bodyStyles?.maxHeight, bodyStyles?.minHeight, minHeight]);
|
|
42
|
+
|
|
43
|
+
const bodyStyle = useMemo(() => {
|
|
44
|
+
return {
|
|
45
|
+
padding: 0,
|
|
46
|
+
...bodyStyles,
|
|
47
|
+
};
|
|
48
|
+
}, [bodyStyles]);
|
|
49
|
+
|
|
50
|
+
const handleCloseKeyDown = useCallback(
|
|
51
|
+
(event: React.KeyboardEvent<HTMLSpanElement>) => {
|
|
52
|
+
if (event.key !== 'Enter' && event.key !== ' ') {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
closePopup();
|
|
58
|
+
},
|
|
59
|
+
[closePopup],
|
|
60
|
+
);
|
|
39
61
|
|
|
40
62
|
const theme = useMemo(() => {
|
|
41
63
|
return {
|
|
@@ -57,11 +79,8 @@ export const MobilePopup: FC<MobilePopupProps> = (props) => {
|
|
|
57
79
|
onClose={closePopup}
|
|
58
80
|
onMaskClick={closePopup}
|
|
59
81
|
bodyClassName="nb-mobile-action-drawer-body"
|
|
60
|
-
bodyStyle={
|
|
61
|
-
|
|
62
|
-
}}
|
|
63
|
-
maskStyle={style}
|
|
64
|
-
style={style}
|
|
82
|
+
bodyStyle={bodyStyle}
|
|
83
|
+
style={popupStyle}
|
|
65
84
|
destroyOnClose
|
|
66
85
|
>
|
|
67
86
|
<div className="nb-mobile-action-drawer-header">
|
|
@@ -69,13 +88,14 @@ export const MobilePopup: FC<MobilePopupProps> = (props) => {
|
|
|
69
88
|
<span className="nb-mobile-action-drawer-placeholder">
|
|
70
89
|
<CloseOutline />
|
|
71
90
|
</span>
|
|
72
|
-
<span>{title}</span>
|
|
91
|
+
<span className="nb-mobile-action-drawer-title">{title}</span>
|
|
73
92
|
<span
|
|
74
93
|
className="nb-mobile-action-drawer-close-icon"
|
|
75
94
|
onClick={closePopup}
|
|
76
95
|
role="button"
|
|
77
96
|
tabIndex={0}
|
|
78
97
|
aria-label={t('Close')}
|
|
98
|
+
onKeyDown={handleCloseKeyDown}
|
|
79
99
|
>
|
|
80
100
|
<CloseOutline />
|
|
81
101
|
</span>
|