amis-core 3.2.0 → 3.3.0
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/esm/Root.js +1 -1
- package/esm/RootRenderer.d.ts +1 -1
- package/esm/RootRenderer.js +3 -3
- package/esm/SchemaRenderer.js +5 -2
- package/esm/Scoped.d.ts +4 -1
- package/esm/Scoped.js +8 -5
- package/esm/StatusScoped.js +1 -1
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +1 -1
- package/esm/actions/Action.d.ts +1 -0
- package/esm/actions/Action.js +62 -37
- package/esm/actions/AjaxAction.d.ts +6 -8
- package/esm/actions/AjaxAction.js +20 -18
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.d.ts +1 -2
- package/esm/actions/CmptAction.js +46 -31
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +2 -2
- package/esm/actions/DialogAction.js +5 -6
- package/esm/actions/DrawerAction.js +4 -4
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/LinkAction.js +1 -1
- package/esm/actions/LoopAction.js +1 -1
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/StatusAction.d.ts +15 -0
- package/esm/actions/StatusAction.js +49 -0
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/actions/index.d.ts +1 -0
- package/esm/components/CustomStyle.js +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.js +2 -2
- package/esm/components/PopOver.js +2 -2
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.js +2 -2
- package/esm/index.d.ts +2 -1
- package/esm/index.js +13 -13
- package/esm/locale.js +1 -1
- package/esm/polyfills.js +1 -1
- package/esm/renderers/Form.d.ts +6 -6
- package/esm/renderers/Form.js +168 -124
- package/esm/renderers/Item.d.ts +42 -66
- package/esm/renderers/Item.js +11 -41
- package/esm/renderers/Options.js +1 -2
- package/esm/renderers/Placeholder.js +1 -1
- package/esm/renderers/builtin.js +1 -1
- package/esm/renderers/register.js +1 -1
- package/esm/renderers/wrapControl.js +101 -47
- package/esm/store/app.js +8 -4
- package/esm/store/combo.d.ts +444 -1912
- package/esm/store/combo.js +9 -2
- package/esm/store/crud.d.ts +1 -0
- package/esm/store/crud.js +11 -5
- package/esm/store/form.d.ts +132 -892
- package/esm/store/form.js +83 -81
- package/esm/store/formItem.d.ts +5 -2
- package/esm/store/formItem.js +13 -2
- package/esm/store/iRenderer.js +2 -2
- package/esm/store/index.js +1 -1
- package/esm/store/list.js +1 -1
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.js +1 -1
- package/esm/store/root.js +2 -2
- package/esm/store/service.js +4 -4
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +503 -2040
- package/esm/store/table.js +79 -55
- package/esm/store/table2.d.ts +49 -0
- package/esm/store/table2.js +37 -4
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +17 -3
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.js +1 -1
- package/esm/utils/DataScope.js +1 -1
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.d.ts +2 -2
- package/esm/utils/api.js +113 -81
- package/esm/utils/arraySlice.js +1 -1
- package/esm/utils/attachmentAdpator.js +1 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/dataMapping.js +4 -2
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.d.ts +2 -0
- package/esm/utils/debug.js +34 -7
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.js +1 -1
- package/esm/utils/errors.js +1 -1
- package/esm/utils/escapeHtml.js +1 -1
- package/esm/utils/filter-schema.js +1 -1
- package/esm/utils/filter.js +1 -1
- package/esm/utils/formatDuration.js +1 -1
- package/esm/utils/formula.d.ts +0 -1
- package/esm/utils/formula.js +6 -9
- package/esm/utils/getVariable.js +1 -1
- package/esm/utils/grammar.js +1 -1
- package/esm/utils/handleAction.js +1 -1
- package/esm/utils/helper.d.ts +11 -1
- package/esm/utils/helper.js +14 -2
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.d.ts +4 -2
- package/esm/utils/icon.js +3 -2
- package/esm/utils/image.js +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/isPureVariable.js +1 -1
- package/esm/utils/json-schema-2-amis-schema.js +1 -1
- package/esm/utils/keyToPath.js +1 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/math.d.ts +3 -0
- package/esm/utils/math.js +52 -0
- package/esm/utils/memoryParse.js +1 -1
- package/esm/utils/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.d.ts +7 -0
- package/esm/utils/object.js +13 -2
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +2 -2
- package/esm/utils/position.js +1 -1
- package/esm/utils/prettyBytes.js +1 -1
- package/esm/utils/renderer-event.d.ts +1 -1
- package/esm/utils/renderer-event.js +14 -6
- package/esm/utils/replaceText.js +1 -1
- package/esm/utils/resize-sensor.js +1 -1
- package/esm/utils/resolveCondition.js +1 -1
- package/esm/utils/resolveVariable.js +1 -1
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
- package/esm/utils/scrollPosition.js +1 -1
- package/esm/utils/string2regExp.js +1 -1
- package/esm/utils/stripNumber.js +1 -1
- package/esm/utils/style-helper.js +1 -1
- package/esm/utils/style.js +1 -1
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.js +1 -1
- package/esm/utils/tpl-lodash.js +1 -1
- package/esm/utils/tpl.js +1 -1
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validations.js +1 -1
- package/lib/Root.js +10 -7
- package/lib/RootRenderer.d.ts +1 -1
- package/lib/RootRenderer.js +11 -8
- package/lib/SchemaRenderer.js +12 -6
- package/lib/Scoped.d.ts +4 -1
- package/lib/Scoped.js +18 -13
- package/lib/StatusScoped.js +5 -2
- package/lib/WithRootStore.js +5 -2
- package/lib/WithStore.js +5 -2
- package/lib/actions/Action.d.ts +1 -0
- package/lib/actions/Action.js +62 -37
- package/lib/actions/AjaxAction.d.ts +6 -8
- package/lib/actions/AjaxAction.js +20 -18
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.d.ts +1 -2
- package/lib/actions/CmptAction.js +46 -31
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +8 -5
- package/lib/actions/DialogAction.js +5 -6
- package/lib/actions/DrawerAction.js +4 -4
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/LinkAction.js +1 -1
- package/lib/actions/LoopAction.js +1 -1
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/StatusAction.d.ts +15 -0
- package/lib/actions/StatusAction.js +53 -0
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/actions/index.d.ts +1 -0
- package/lib/components/CustomStyle.js +1 -1
- package/lib/components/LazyComponent.js +12 -14
- package/lib/components/Overlay.js +14 -14
- package/lib/components/PopOver.js +11 -10
- package/lib/env.js +4 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.js +11 -9
- package/lib/index.d.ts +2 -1
- package/lib/index.js +21 -19
- package/lib/locale.js +6 -3
- package/lib/polyfills.js +1 -1
- package/lib/renderers/Form.d.ts +6 -6
- package/lib/renderers/Form.js +180 -131
- package/lib/renderers/Item.d.ts +42 -66
- package/lib/renderers/Item.js +51 -75
- package/lib/renderers/Options.js +10 -5
- package/lib/renderers/Placeholder.js +1 -1
- package/lib/renderers/builtin.js +1 -1
- package/lib/renderers/register.js +1 -1
- package/lib/renderers/wrapControl.js +104 -47
- package/lib/store/app.js +14 -7
- package/lib/store/combo.d.ts +444 -1912
- package/lib/store/combo.js +9 -2
- package/lib/store/crud.d.ts +1 -0
- package/lib/store/crud.js +11 -5
- package/lib/store/form.d.ts +132 -892
- package/lib/store/form.js +81 -79
- package/lib/store/formItem.d.ts +5 -2
- package/lib/store/formItem.js +13 -2
- package/lib/store/iRenderer.js +8 -5
- package/lib/store/index.js +1 -1
- package/lib/store/list.js +1 -1
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.js +1 -1
- package/lib/store/root.js +8 -5
- package/lib/store/service.js +4 -4
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +503 -2040
- package/lib/store/table.js +79 -55
- package/lib/store/table2.d.ts +49 -0
- package/lib/store/table2.js +36 -3
- package/lib/theme.js +6 -3
- package/lib/types.d.ts +17 -3
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.js +1 -1
- package/lib/utils/DataScope.js +1 -1
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.d.ts +2 -2
- package/lib/utils/api.js +113 -81
- package/lib/utils/arraySlice.js +1 -1
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/columnsSplit.js +8 -6
- package/lib/utils/dataMapping.js +4 -2
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.d.ts +2 -0
- package/lib/utils/debug.js +61 -33
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.js +7 -5
- package/lib/utils/errors.js +1 -1
- package/lib/utils/escapeHtml.js +1 -1
- package/lib/utils/filter-schema.js +1 -1
- package/lib/utils/filter.js +1 -1
- package/lib/utils/formatDuration.js +1 -1
- package/lib/utils/formula.d.ts +0 -1
- package/lib/utils/formula.js +6 -10
- package/lib/utils/getVariable.js +1 -1
- package/lib/utils/grammar.js +1 -1
- package/lib/utils/handleAction.js +1 -1
- package/lib/utils/helper.d.ts +11 -1
- package/lib/utils/helper.js +14 -1
- package/lib/utils/highlight.js +8 -9
- package/lib/utils/icon.d.ts +4 -2
- package/lib/utils/icon.js +12 -10
- package/lib/utils/image.js +1 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/isPureVariable.js +1 -1
- package/lib/utils/json-schema-2-amis-schema.js +1 -1
- package/lib/utils/keyToPath.js +1 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/math.d.ts +3 -0
- package/lib/utils/math.js +58 -0
- package/lib/utils/memoryParse.js +1 -1
- package/lib/utils/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.d.ts +7 -0
- package/lib/utils/object.js +13 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +7 -3
- package/lib/utils/position.js +1 -1
- package/lib/utils/prettyBytes.js +1 -1
- package/lib/utils/renderer-event.d.ts +1 -1
- package/lib/utils/renderer-event.js +13 -5
- package/lib/utils/replaceText.js +1 -1
- package/lib/utils/resize-sensor.js +1 -1
- package/lib/utils/resolveCondition.js +1 -1
- package/lib/utils/resolveVariable.js +1 -1
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
- package/lib/utils/scrollPosition.js +1 -1
- package/lib/utils/string2regExp.js +1 -1
- package/lib/utils/stripNumber.js +1 -1
- package/lib/utils/style-helper.js +1 -1
- package/lib/utils/style.js +1 -1
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.js +1 -1
- package/lib/utils/tpl-lodash.js +1 -1
- package/lib/utils/tpl.js +1 -1
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validations.js +1 -1
- package/package.json +5 -5
package/esm/utils/api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -47,10 +47,10 @@ function buildApi(api, data, options) {
|
|
|
47
47
|
api.headers = dataMapping(api.headers, data, undefined, false);
|
|
48
48
|
}
|
|
49
49
|
if (api.requestAdaptor && typeof api.requestAdaptor === 'string') {
|
|
50
|
-
api.requestAdaptor =
|
|
50
|
+
api.requestAdaptor = str2AsyncFunction(api.requestAdaptor, 'api', 'context');
|
|
51
51
|
}
|
|
52
52
|
if (api.adaptor && typeof api.adaptor === 'string') {
|
|
53
|
-
api.adaptor =
|
|
53
|
+
api.adaptor = str2AsyncFunction(api.adaptor, 'payload', 'response', 'api', 'context');
|
|
54
54
|
}
|
|
55
55
|
if (!data) {
|
|
56
56
|
return api;
|
|
@@ -354,68 +354,84 @@ function wrapFetcher(fn, tracker) {
|
|
|
354
354
|
}
|
|
355
355
|
var wrappedFetcher = function (api, data, options) {
|
|
356
356
|
var _a, _b, _c;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
:
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
357
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
358
|
+
var apiCache, timeStamp;
|
|
359
|
+
return __generator(this, function (_d) {
|
|
360
|
+
switch (_d.label) {
|
|
361
|
+
case 0:
|
|
362
|
+
api = buildApi(api, data, options);
|
|
363
|
+
if (!api.requestAdaptor) return [3 /*break*/, 2];
|
|
364
|
+
debug('api', 'before requestAdaptor', api);
|
|
365
|
+
return [4 /*yield*/, api.requestAdaptor(api, data)];
|
|
366
|
+
case 1:
|
|
367
|
+
api = (_d.sent()) || api;
|
|
368
|
+
debug('api', 'after requestAdaptor', api);
|
|
369
|
+
_d.label = 2;
|
|
370
|
+
case 2:
|
|
371
|
+
if (api.data &&
|
|
372
|
+
(api.data instanceof FormData ||
|
|
373
|
+
hasFile(api.data) ||
|
|
374
|
+
api.dataType === 'form-data')) {
|
|
375
|
+
api.data =
|
|
376
|
+
api.data instanceof FormData
|
|
377
|
+
? api.data
|
|
378
|
+
: object2formData(api.data, api.qsOptions);
|
|
379
|
+
}
|
|
380
|
+
else if (api.data &&
|
|
381
|
+
typeof api.data !== 'string' &&
|
|
382
|
+
api.dataType === 'form') {
|
|
383
|
+
api.data = qsstringify(api.data, api.qsOptions);
|
|
384
|
+
api.headers = api.headers || (api.headers = {});
|
|
385
|
+
api.headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
386
|
+
}
|
|
387
|
+
else if (api.data &&
|
|
388
|
+
typeof api.data !== 'string' &&
|
|
389
|
+
api.dataType === 'json') {
|
|
390
|
+
api.data = JSON.stringify(api.data);
|
|
391
|
+
api.headers = api.headers || (api.headers = {});
|
|
392
|
+
api.headers['Content-Type'] = 'application/json';
|
|
393
|
+
}
|
|
394
|
+
// 如果发送适配器中设置了 mockResponse
|
|
395
|
+
// 则直接跳过请求发送
|
|
396
|
+
if (api.mockResponse) {
|
|
397
|
+
return [2 /*return*/, wrapAdaptor(Promise.resolve(api.mockResponse), api, data)];
|
|
398
|
+
}
|
|
399
|
+
if (!isValidApi(api.url)) {
|
|
400
|
+
throw new Error("invalid api url:".concat(api.url));
|
|
401
|
+
}
|
|
402
|
+
debug('api', 'request api', api);
|
|
403
|
+
tracker === null || tracker === void 0 ? void 0 : tracker({ eventType: 'api', eventData: omit(api, ['config', 'data', 'body']) }, api.data);
|
|
404
|
+
if (((_a = api.method) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === 'jsonp') {
|
|
405
|
+
return [2 /*return*/, wrapAdaptor(jsonpFetcher(api), api, data)];
|
|
406
|
+
}
|
|
407
|
+
if (((_b = api.method) === null || _b === void 0 ? void 0 : _b.toLocaleLowerCase()) === 'js') {
|
|
408
|
+
return [2 /*return*/, wrapAdaptor(jsFetcher(fn, api), api, data)];
|
|
409
|
+
}
|
|
410
|
+
if (typeof api.cache === 'number' && api.cache > 0) {
|
|
411
|
+
apiCache = getApiCache(api);
|
|
412
|
+
return [2 /*return*/, wrapAdaptor(apiCache
|
|
413
|
+
? apiCache.cachedPromise
|
|
414
|
+
: setApiCache(api, fn(api)), api, data)];
|
|
415
|
+
}
|
|
416
|
+
// IE 下 get 请求会被缓存,所以自动加个时间戳
|
|
417
|
+
if (isIE && api && ((_c = api.method) === null || _c === void 0 ? void 0 : _c.toLocaleLowerCase()) === 'get') {
|
|
418
|
+
timeStamp = "_t=".concat(Date.now());
|
|
419
|
+
if (api.url.indexOf('?') === -1) {
|
|
420
|
+
api.url = api.url + "?".concat(timeStamp);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
api.url = api.url + "&".concat(timeStamp);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return [2 /*return*/, wrapAdaptor(fn(api), api, data)];
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
});
|
|
414
430
|
};
|
|
415
431
|
wrappedFetcher._wrappedFetcher = true;
|
|
416
432
|
return wrappedFetcher;
|
|
417
433
|
}
|
|
418
|
-
function wrapAdaptor(promise, api) {
|
|
434
|
+
function wrapAdaptor(promise, api, context) {
|
|
419
435
|
var _this = this;
|
|
420
436
|
var adaptor = api.adaptor;
|
|
421
437
|
return adaptor
|
|
@@ -426,7 +442,7 @@ function wrapAdaptor(promise, api) {
|
|
|
426
442
|
switch (_a.label) {
|
|
427
443
|
case 0:
|
|
428
444
|
debug('api', 'before adaptor data', response.data);
|
|
429
|
-
result = adaptor(response.data, response, api);
|
|
445
|
+
result = adaptor(response.data, response, api, context);
|
|
430
446
|
if (!(result === null || result === void 0 ? void 0 : result.then)) return [3 /*break*/, 2];
|
|
431
447
|
return [4 /*yield*/, result];
|
|
432
448
|
case 1:
|
|
@@ -540,41 +556,57 @@ function isApiOutdated(prevApi, nextApi, prevData, nextData) {
|
|
|
540
556
|
return true;
|
|
541
557
|
}
|
|
542
558
|
nextApi = normalizeApi(nextApi);
|
|
559
|
+
prevApi = (prevApi ? normalizeApi(prevApi) : prevApi);
|
|
543
560
|
if (nextApi.autoRefresh === false) {
|
|
544
561
|
return false;
|
|
545
562
|
}
|
|
563
|
+
// api 本身有变化
|
|
564
|
+
if ((prevApi && prevApi.url !== nextApi.url) || !prevApi) {
|
|
565
|
+
return !!(isValidApi(nextApi.url) &&
|
|
566
|
+
(!nextApi.sendOn || evalExpression(nextApi.sendOn, nextData)));
|
|
567
|
+
}
|
|
546
568
|
var trackExpression = (_a = nextApi.trackExpression) !== null && _a !== void 0 ? _a : nextApi.url;
|
|
547
569
|
if (typeof trackExpression !== 'string' || !~trackExpression.indexOf('$')) {
|
|
548
570
|
return false;
|
|
549
571
|
}
|
|
550
572
|
var isModified = false;
|
|
551
|
-
if (prevApi) {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
tokenize(prevApi.trackExpression || '', prevData) !==
|
|
556
|
-
tokenize(nextApi.trackExpression || '', nextData);
|
|
557
|
-
}
|
|
558
|
-
else {
|
|
559
|
-
prevApi = buildApi(prevApi, prevData, {
|
|
560
|
-
ignoreData: true
|
|
561
|
-
});
|
|
562
|
-
nextApi = buildApi(nextApi, nextData, {
|
|
563
|
-
ignoreData: true
|
|
564
|
-
});
|
|
565
|
-
isModified = prevApi.url !== nextApi.url;
|
|
566
|
-
}
|
|
573
|
+
if (nextApi.trackExpression || prevApi.trackExpression) {
|
|
574
|
+
isModified =
|
|
575
|
+
tokenize(prevApi.trackExpression || '', prevData) !==
|
|
576
|
+
tokenize(nextApi.trackExpression || '', nextData);
|
|
567
577
|
}
|
|
568
578
|
else {
|
|
569
|
-
|
|
579
|
+
prevApi = buildApi(prevApi, prevData, {
|
|
580
|
+
ignoreData: true
|
|
581
|
+
});
|
|
582
|
+
nextApi = buildApi(nextApi, nextData, {
|
|
583
|
+
ignoreData: true
|
|
584
|
+
});
|
|
585
|
+
isModified = prevApi.url !== nextApi.url;
|
|
570
586
|
}
|
|
571
587
|
return !!(isModified &&
|
|
572
588
|
isValidApi(nextApi.url) &&
|
|
573
589
|
(!nextApi.sendOn || evalExpression(nextApi.sendOn, nextData)));
|
|
574
590
|
}
|
|
575
591
|
function isValidApi(api) {
|
|
576
|
-
|
|
577
|
-
|
|
592
|
+
if (!api || typeof api !== 'string') {
|
|
593
|
+
return false;
|
|
594
|
+
}
|
|
595
|
+
var idx = api.indexOf('://');
|
|
596
|
+
// 不允许直接相对路径写 api
|
|
597
|
+
// 不允许 :// 结尾
|
|
598
|
+
if ((!~idx && api[0] !== '/') || (~idx && idx + 3 === api.length)) {
|
|
599
|
+
return false;
|
|
600
|
+
}
|
|
601
|
+
try {
|
|
602
|
+
// 不补一个协议,URL 判断为 false
|
|
603
|
+
api = (~idx ? '' : 'schema://domain') + api;
|
|
604
|
+
new URL(api);
|
|
605
|
+
}
|
|
606
|
+
catch (error) {
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
return true;
|
|
578
610
|
}
|
|
579
611
|
function isEffectiveApi(api, data, initFetch, initFetchOn) {
|
|
580
612
|
if (!api) {
|
package/esm/utils/arraySlice.js
CHANGED
package/esm/utils/autobind.js
CHANGED
package/esm/utils/dataMapping.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -131,7 +131,9 @@ function dataMapping(to, from, ignoreFunction, convertKeyToPath, ignoreIfNotMatc
|
|
|
131
131
|
else if (value === '$$') {
|
|
132
132
|
setVariable(ret, key, from, convertKeyToPath);
|
|
133
133
|
}
|
|
134
|
-
else if (
|
|
134
|
+
else if (typeof value === 'string' &&
|
|
135
|
+
value.length > 0 &&
|
|
136
|
+
value[0] === '$') {
|
|
135
137
|
var v = resolveMapping(value, from, undefined, ignoreIfNotMatch);
|
|
136
138
|
setVariable(ret, key, v, convertKeyToPath);
|
|
137
139
|
if (v === '__undefined') {
|
package/esm/utils/date.js
CHANGED
package/esm/utils/debug.d.ts
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* amis 运行时调试功能,为了避免循环引用,这个组件不要依赖 amis 里的组件
|
|
3
3
|
*/
|
|
4
4
|
import React, { Component } from 'react';
|
|
5
|
+
export declare const JsonView: React.LazyExoticComponent<React.ComponentType<import("react-json-view").ReactJsonViewProps>>;
|
|
5
6
|
export declare function enableDebug(): void;
|
|
7
|
+
export declare function disableDebug(): void;
|
|
6
8
|
interface DebugWrapperProps {
|
|
7
9
|
renderer: any;
|
|
8
10
|
children?: React.ReactNode;
|
package/esm/utils/debug.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { __decorate, __metadata, __values, __read, __extends } from 'tslib';
|
|
7
7
|
import React, { useRef, useState, useEffect, Component } from 'react';
|
|
8
8
|
import cx from 'classnames';
|
|
9
|
-
import { findDOMNode, render } from 'react-dom';
|
|
10
|
-
import JsonView from 'react-json-view';
|
|
9
|
+
import { findDOMNode, render, unmountComponentAtNode } from 'react-dom';
|
|
11
10
|
import { observable, autorun } from 'mobx';
|
|
12
11
|
import { observer } from 'mobx-react';
|
|
13
12
|
import { uuidv4 } from './helper.js';
|
|
@@ -16,6 +15,7 @@ import { position } from './position.js';
|
|
|
16
15
|
/**
|
|
17
16
|
* amis 运行时调试功能,为了避免循环引用,这个组件不要依赖 amis 里的组件
|
|
18
17
|
*/
|
|
18
|
+
var JsonView = React.lazy(function () { return import('react-json-view'); });
|
|
19
19
|
/** @class */ ((function () {
|
|
20
20
|
function Log() {
|
|
21
21
|
this.cat = '';
|
|
@@ -113,7 +113,8 @@ var LogView = observer(function (_a) {
|
|
|
113
113
|
log.cat,
|
|
114
114
|
"] ",
|
|
115
115
|
log.msg),
|
|
116
|
-
log.ext ? (React.createElement(
|
|
116
|
+
log.ext ? (React.createElement(React.Suspense, { fallback: React.createElement("div", null, "Loading...") },
|
|
117
|
+
React.createElement(JsonView, { name: null, theme: "monokai", src: JSON.parse(log.ext), collapsed: true, enableClipboard: false, displayDataTypes: false, collapseStringsAfterLength: ellipsisThreshold, iconStyle: "square" }))) : null));
|
|
117
118
|
})));
|
|
118
119
|
});
|
|
119
120
|
var AMISDebug = observer(function (_a) {
|
|
@@ -143,7 +144,8 @@ var AMISDebug = observer(function (_a) {
|
|
|
143
144
|
React.createElement("h3", null,
|
|
144
145
|
"Data Level-",
|
|
145
146
|
level),
|
|
146
|
-
React.createElement(
|
|
147
|
+
React.createElement(React.Suspense, { fallback: React.createElement("div", null, "Loading...") },
|
|
148
|
+
React.createElement(JsonView, { key: "dataview-".concat(stack), name: null, theme: "monokai", src: stack, collapsed: level === 0 ? false : true, enableClipboard: false, displayDataTypes: false, iconStyle: "square" }))));
|
|
147
149
|
level += 1;
|
|
148
150
|
}
|
|
149
151
|
}
|
|
@@ -254,7 +256,7 @@ function handleMouseclick(e) {
|
|
|
254
256
|
}
|
|
255
257
|
var dom = e.target;
|
|
256
258
|
var target = dom.closest("[data-debug-id]");
|
|
257
|
-
if (target) {
|
|
259
|
+
if (target && !target.closest('.AMISDebug')) {
|
|
258
260
|
store.activeId = target.getAttribute('data-debug-id');
|
|
259
261
|
store.tab = 'inspect';
|
|
260
262
|
}
|
|
@@ -294,6 +296,7 @@ autorun(function () {
|
|
|
294
296
|
});
|
|
295
297
|
// 页面中只能有一个实例
|
|
296
298
|
var isEnabled = false;
|
|
299
|
+
var unmount;
|
|
297
300
|
function enableDebug() {
|
|
298
301
|
if (isEnabled) {
|
|
299
302
|
return;
|
|
@@ -302,12 +305,36 @@ function enableDebug() {
|
|
|
302
305
|
var amisDebugElement = document.createElement('div');
|
|
303
306
|
document.body.appendChild(amisDebugElement);
|
|
304
307
|
var element = React.createElement(AMISDebug, { store: store });
|
|
308
|
+
// if (parseInt(version.split('.')[0], 10) >= 18) {
|
|
309
|
+
// const root = createRoot(amisDebugElement);
|
|
310
|
+
// root.render(element);
|
|
311
|
+
// unmount = () => {
|
|
312
|
+
// root.unmount();
|
|
313
|
+
// document.body.removeChild(amisDebugElement);
|
|
314
|
+
// };
|
|
315
|
+
// } else {
|
|
305
316
|
render(element, amisDebugElement);
|
|
317
|
+
unmount = function () {
|
|
318
|
+
unmountComponentAtNode(amisDebugElement);
|
|
319
|
+
document.body.removeChild(amisDebugElement);
|
|
320
|
+
};
|
|
321
|
+
// }
|
|
306
322
|
document.body.appendChild(amisHoverBox);
|
|
307
323
|
document.body.appendChild(amisActiveBox);
|
|
308
324
|
document.addEventListener('mousemove', handleMouseMove);
|
|
309
325
|
document.addEventListener('click', handleMouseclick);
|
|
310
326
|
}
|
|
327
|
+
function disableDebug() {
|
|
328
|
+
if (!isEnabled) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
isEnabled = false;
|
|
332
|
+
unmount === null || unmount === void 0 ? void 0 : unmount();
|
|
333
|
+
document.body.removeChild(amisHoverBox);
|
|
334
|
+
document.body.removeChild(amisActiveBox);
|
|
335
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
336
|
+
document.removeEventListener('click', handleMouseclick);
|
|
337
|
+
}
|
|
311
338
|
var DebugWrapper = /** @class */ (function (_super) {
|
|
312
339
|
__extends(DebugWrapper, _super);
|
|
313
340
|
function DebugWrapper() {
|
|
@@ -386,4 +413,4 @@ function warning(cat, msg, ext) {
|
|
|
386
413
|
store.logs.push(log);
|
|
387
414
|
}
|
|
388
415
|
|
|
389
|
-
export { DebugWrapper, debug, enableDebug, warning };
|
|
416
|
+
export { DebugWrapper, JsonView, debug, disableDebug, enableDebug, warning };
|
package/esm/utils/dom.js
CHANGED
package/esm/utils/errors.js
CHANGED
package/esm/utils/escapeHtml.js
CHANGED
package/esm/utils/filter.js
CHANGED
package/esm/utils/formula.d.ts
CHANGED
package/esm/utils/formula.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import isObject from 'lodash/isObject';
|
|
7
7
|
import isString from 'lodash/isString';
|
|
8
8
|
import isBoolean from 'lodash/isBoolean';
|
|
9
9
|
import { evaluate, getFilters } from 'amis-formula';
|
|
@@ -114,7 +114,7 @@ var FormulaExec = {
|
|
|
114
114
|
},
|
|
115
115
|
collect: function (expression) {
|
|
116
116
|
var variables = [];
|
|
117
|
-
if (
|
|
117
|
+
if (isObject(expression) || isString(expression)) {
|
|
118
118
|
// 仅对 Object类型 和 String类型 进行变量提取
|
|
119
119
|
variables = collectVariables(expression);
|
|
120
120
|
}
|
|
@@ -198,7 +198,8 @@ function isNeedFormula(expression, prevData, curData) {
|
|
|
198
198
|
try {
|
|
199
199
|
var variables = FormulaExec.collect(expression);
|
|
200
200
|
return variables.some(function (variable) {
|
|
201
|
-
return FormulaExec.var(variable, prevData) !==
|
|
201
|
+
return FormulaExec.var(variable, prevData) !==
|
|
202
|
+
FormulaExec.var(variable, curData);
|
|
202
203
|
});
|
|
203
204
|
}
|
|
204
205
|
catch (e) {
|
|
@@ -206,10 +207,6 @@ function isNeedFormula(expression, prevData, curData) {
|
|
|
206
207
|
return false;
|
|
207
208
|
}
|
|
208
209
|
}
|
|
209
|
-
function isNowFormula(expression) {
|
|
210
|
-
var block = expression.split(/\${|\||}/).filter(function (item) { return item; });
|
|
211
|
-
return block[1] === 'now';
|
|
212
|
-
}
|
|
213
210
|
// 将 \${xx} 替换成 ${xx}
|
|
214
211
|
function replaceExpression(expression) {
|
|
215
212
|
if (expression &&
|
|
@@ -220,4 +217,4 @@ function replaceExpression(expression) {
|
|
|
220
217
|
return expression;
|
|
221
218
|
}
|
|
222
219
|
|
|
223
|
-
export { FormulaExec, formulaExec, isExpression, isNeedFormula,
|
|
220
|
+
export { FormulaExec, formulaExec, isExpression, isNeedFormula, registerFormulaExec, replaceExpression };
|
package/esm/utils/getVariable.js
CHANGED
package/esm/utils/grammar.js
CHANGED
package/esm/utils/helper.d.ts
CHANGED
|
@@ -268,6 +268,15 @@ export declare function loadScript(src: string): Promise<void>;
|
|
|
268
268
|
export declare function loadStyle(href: string): Promise<void>;
|
|
269
269
|
export declare class SkipOperation extends Error {
|
|
270
270
|
}
|
|
271
|
+
export declare class ValidateError extends Error {
|
|
272
|
+
name: 'ValidateError';
|
|
273
|
+
detail: {
|
|
274
|
+
[propName: string]: Array<string> | string;
|
|
275
|
+
};
|
|
276
|
+
constructor(message: string, error: {
|
|
277
|
+
[propName: string]: Array<string> | string;
|
|
278
|
+
});
|
|
279
|
+
}
|
|
271
280
|
/**
|
|
272
281
|
* 深度查找具有某个 key 名字段的对象,实际实现是 internalFindObjectsWithKey,这里包一层是为了做循环引用检测
|
|
273
282
|
* @param obj
|
|
@@ -283,7 +292,8 @@ export declare function getPropValue<T extends {
|
|
|
283
292
|
name?: string;
|
|
284
293
|
data?: any;
|
|
285
294
|
defaultValue?: any;
|
|
286
|
-
|
|
295
|
+
canAccessSuperData?: boolean;
|
|
296
|
+
}>(props: T, getter?: (props: T) => any, canAccessSuper?: boolean | undefined): any;
|
|
287
297
|
export declare function detectPropValueChanged<T extends {
|
|
288
298
|
value?: any;
|
|
289
299
|
name?: string;
|
package/esm/utils/helper.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.3.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -1041,6 +1041,17 @@ var SkipOperation = /** @class */ (function (_super) {
|
|
|
1041
1041
|
}
|
|
1042
1042
|
return SkipOperation;
|
|
1043
1043
|
}(Error));
|
|
1044
|
+
var ValidateError = /** @class */ (function (_super) {
|
|
1045
|
+
__extends(ValidateError, _super);
|
|
1046
|
+
function ValidateError(message, error) {
|
|
1047
|
+
var _this = _super.call(this) || this;
|
|
1048
|
+
_this.name = 'ValidateError';
|
|
1049
|
+
_this.message = message;
|
|
1050
|
+
_this.detail = error;
|
|
1051
|
+
return _this;
|
|
1052
|
+
}
|
|
1053
|
+
return ValidateError;
|
|
1054
|
+
}(Error));
|
|
1044
1055
|
/**
|
|
1045
1056
|
* 检查对象是否有循环引用,来自 https://stackoverflow.com/a/34909127
|
|
1046
1057
|
* @param obj
|
|
@@ -1123,6 +1134,7 @@ function resolveValueByName(data, name, canAccessSuper) {
|
|
|
1123
1134
|
// 统一的获取 value 值方法
|
|
1124
1135
|
function getPropValue(props, getter, canAccessSuper) {
|
|
1125
1136
|
var _a, _b;
|
|
1137
|
+
if (canAccessSuper === void 0) { canAccessSuper = props.canAccessSuperData; }
|
|
1126
1138
|
var name = props.name, value = props.value, data = props.data, defaultValue = props.defaultValue;
|
|
1127
1139
|
return ((_b = (_a = value !== null && value !== void 0 ? value : getter === null || getter === void 0 ? void 0 : getter(props)) !== null && _a !== void 0 ? _a : resolveValueByName(data, name, canAccessSuper)) !== null && _b !== void 0 ? _b : defaultValue);
|
|
1128
1140
|
}
|
|
@@ -1337,4 +1349,4 @@ function parseQuery(location) {
|
|
|
1337
1349
|
return merge(normalizedQuery, hashQuery);
|
|
1338
1350
|
}
|
|
1339
1351
|
|
|
1340
|
-
export { JSONTraverse, JSONValueMap, SkipOperation, __uri, anyChanged, autobind, bulkBindFunctions, camel, chainEvents, chainFunctions, convertArrayValueToMoment, detectPropValueChanged, difference, eachTree, everyTree, filterTree, findIndex, findObjectsWithKey, findTree, findTreeAll, findTreeIndex, flattenTree, flattenTreeWithLeafNodes, getLevelFromClassName, getPropValue, getRange, getScrollParent, getScrollbarWidth, getTree, getTreeAncestors, getTreeDepth, getTreeParent, getWidthRate, guid, hasAbility, hasFile, hasOwnPropertyInPath, hasVisibleExpression, hashCode, immutableExtends, injectPropsToObject, isArrayChildrenModified, isBreakpoint, isClickOnInput, isDisabled, isEmpty, isMobile, isNumeric, isObjectShallowModified, isSuperDataModified, isUnfolded, isVisible, lcFirst, loadScript, loadStyle, makeColumnClassBuild, makeHorizontalDeeper, mapObject, mapTree, noop, normalizeNodePath, object2formData, omitControls, padArr, parseQuery, pickEventsProps, preventDefault, promisify, qsparse, qsstringify, range, removeHTMLTag, repeatCount, rmUndefined, someTree, sortArray, spliceTree, syncDataFromSuper, ucFirst, until, uuid, uuidv4, visibilityFilter };
|
|
1352
|
+
export { JSONTraverse, JSONValueMap, SkipOperation, ValidateError, __uri, anyChanged, autobind, bulkBindFunctions, camel, chainEvents, chainFunctions, convertArrayValueToMoment, detectPropValueChanged, difference, eachTree, everyTree, filterTree, findIndex, findObjectsWithKey, findTree, findTreeAll, findTreeIndex, flattenTree, flattenTreeWithLeafNodes, getLevelFromClassName, getPropValue, getRange, getScrollParent, getScrollbarWidth, getTree, getTreeAncestors, getTreeDepth, getTreeParent, getWidthRate, guid, hasAbility, hasFile, hasOwnPropertyInPath, hasVisibleExpression, hashCode, immutableExtends, injectPropsToObject, isArrayChildrenModified, isBreakpoint, isClickOnInput, isDisabled, isEmpty, isMobile, isNumeric, isObjectShallowModified, isSuperDataModified, isUnfolded, isVisible, lcFirst, loadScript, loadStyle, makeColumnClassBuild, makeHorizontalDeeper, mapObject, mapTree, noop, normalizeNodePath, object2formData, omitControls, padArr, parseQuery, pickEventsProps, preventDefault, promisify, qsparse, qsstringify, range, removeHTMLTag, repeatCount, rmUndefined, someTree, sortArray, spliceTree, syncDataFromSuper, ucFirst, until, uuid, uuidv4, visibilityFilter };
|
package/esm/utils/highlight.js
CHANGED