amis-core 3.1.1 → 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 +6 -2
- package/esm/Scoped.d.ts +4 -1
- package/esm/Scoped.js +9 -5
- package/esm/StatusScoped.js +1 -1
- package/esm/WithRootStore.d.ts +4 -24
- package/esm/WithRootStore.js +12 -4
- package/esm/WithStore.js +23 -16
- package/esm/actions/Action.d.ts +1 -0
- package/esm/actions/Action.js +70 -45
- 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 +47 -32
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +3 -2
- package/esm/actions/DialogAction.d.ts +2 -0
- package/esm/actions/DialogAction.js +39 -23
- 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 +3 -2
- package/esm/components/PopOver.js +3 -2
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.js +2 -2
- package/esm/index.d.ts +3 -1
- package/esm/index.js +16 -14
- package/esm/locale.js +1 -1
- package/esm/polyfills.d.ts +3 -0
- package/esm/polyfills.js +18 -0
- package/esm/renderers/Form.d.ts +7 -7
- package/esm/renderers/Form.js +182 -128
- package/esm/renderers/Item.d.ts +82 -77
- package/esm/renderers/Item.js +90 -74
- 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.d.ts +4 -24
- package/esm/renderers/wrapControl.js +140 -88
- package/esm/store/app.js +42 -4
- package/esm/store/combo.d.ts +564 -1892
- package/esm/store/combo.js +9 -2
- package/esm/store/crud.d.ts +4 -2
- package/esm/store/crud.js +17 -4
- package/esm/store/form.d.ts +182 -882
- package/esm/store/form.js +83 -81
- package/esm/store/formItem.d.ts +6 -2
- package/esm/store/formItem.js +19 -3
- package/esm/store/iRenderer.js +3 -2
- package/esm/store/index.js +1 -1
- package/esm/store/list.d.ts +1 -0
- package/esm/store/list.js +8 -2
- 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 +3 -2
- package/esm/store/service.js +17 -12
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +604 -2020
- package/esm/store/table.js +86 -56
- 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 +22 -5
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.d.ts +3 -2
- package/esm/utils/DataSchema.js +27 -7
- package/esm/utils/DataScope.d.ts +10 -3
- package/esm/utils/DataScope.js +50 -12
- 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 +152 -112
- package/esm/utils/arraySlice.d.ts +1 -0
- package/esm/utils/arraySlice.js +76 -0
- 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 +29 -19
- 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 +4 -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 +19 -2
- package/esm/utils/helper.js +69 -10
- 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 +2 -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 +18 -9
- 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 +13 -6
- package/lib/Scoped.d.ts +4 -1
- package/lib/Scoped.js +19 -13
- package/lib/StatusScoped.js +5 -2
- package/lib/WithRootStore.d.ts +4 -24
- package/lib/WithRootStore.js +15 -4
- package/lib/WithStore.js +27 -17
- package/lib/actions/Action.d.ts +1 -0
- package/lib/actions/Action.js +70 -45
- 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 +47 -32
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +9 -5
- package/lib/actions/DialogAction.d.ts +2 -0
- package/lib/actions/DialogAction.js +39 -23
- 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 +15 -14
- package/lib/components/PopOver.js +12 -10
- package/lib/env.js +4 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.js +11 -9
- package/lib/index.d.ts +3 -1
- package/lib/index.js +26 -19
- package/lib/locale.js +6 -3
- package/lib/polyfills.d.ts +3 -0
- package/lib/polyfills.js +20 -0
- package/lib/renderers/Form.d.ts +7 -7
- package/lib/renderers/Form.js +194 -135
- package/lib/renderers/Item.d.ts +82 -77
- package/lib/renderers/Item.js +126 -104
- 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.d.ts +4 -24
- package/lib/renderers/wrapControl.js +143 -88
- package/lib/store/app.js +44 -3
- package/lib/store/combo.d.ts +564 -1892
- package/lib/store/combo.js +9 -2
- package/lib/store/crud.d.ts +4 -2
- package/lib/store/crud.js +17 -4
- package/lib/store/form.d.ts +182 -882
- package/lib/store/form.js +81 -79
- package/lib/store/formItem.d.ts +6 -2
- package/lib/store/formItem.js +19 -3
- package/lib/store/iRenderer.js +9 -5
- package/lib/store/index.js +1 -1
- package/lib/store/list.d.ts +1 -0
- package/lib/store/list.js +8 -2
- 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 +9 -5
- package/lib/store/service.js +17 -12
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +604 -2020
- package/lib/store/table.js +85 -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 +22 -5
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.d.ts +3 -2
- package/lib/utils/DataSchema.js +27 -7
- package/lib/utils/DataScope.d.ts +10 -3
- package/lib/utils/DataScope.js +50 -11
- 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 +151 -111
- package/lib/utils/arraySlice.d.ts +1 -0
- package/lib/utils/arraySlice.js +80 -0
- 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 +29 -19
- 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 +10 -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 +19 -2
- package/lib/utils/helper.js +70 -9
- 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 +2 -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 +18 -9
- 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 +9 -4
package/lib/Scoped.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
|
|
|
@@ -22,30 +22,34 @@ require('./utils/filter.js');
|
|
|
22
22
|
var helper = require('./utils/helper.js');
|
|
23
23
|
require('./utils/api.js');
|
|
24
24
|
require('./utils/ColorScale.js');
|
|
25
|
-
require('
|
|
25
|
+
require('./utils/columnsSplit.js');
|
|
26
26
|
require('./utils/DataSchema.js');
|
|
27
27
|
require('./utils/DataScope.js');
|
|
28
28
|
require('./utils/debug.js');
|
|
29
|
-
require('
|
|
29
|
+
require('./utils/dom.js');
|
|
30
30
|
require('./utils/errors.js');
|
|
31
31
|
var tpl = require('./utils/tpl.js');
|
|
32
32
|
require('classnames');
|
|
33
33
|
require('lodash/isObject');
|
|
34
34
|
require('lodash/isString');
|
|
35
35
|
require('lodash/isBoolean');
|
|
36
|
-
require('
|
|
36
|
+
require('./utils/highlight.js');
|
|
37
|
+
require('./utils/icon.js');
|
|
37
38
|
require('./utils/image.js');
|
|
39
|
+
require('lodash/isEqual');
|
|
38
40
|
require('./actions/Action.js');
|
|
39
41
|
require('lodash/debounce');
|
|
40
42
|
require('lodash/cloneDeep');
|
|
41
43
|
require('./utils/resize-sensor.js');
|
|
42
44
|
require('react-overlays/useRootClose');
|
|
45
|
+
require('react-dom');
|
|
43
46
|
require('./utils/SimpleMap.js');
|
|
44
47
|
require('lodash/mapValues');
|
|
45
48
|
require('lodash/camelCase');
|
|
46
49
|
require('uncontrollable');
|
|
47
50
|
require('./utils/validations.js');
|
|
48
51
|
require('./utils/resolveCondition.js');
|
|
52
|
+
require('mobx');
|
|
49
53
|
require('./utils/Animation.js');
|
|
50
54
|
|
|
51
55
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -55,10 +59,9 @@ var find__default = /*#__PURE__*/_interopDefaultLegacy(find);
|
|
|
55
59
|
var values__default = /*#__PURE__*/_interopDefaultLegacy(values);
|
|
56
60
|
var hoistNonReactStatic__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonReactStatic);
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*/
|
|
62
|
+
var __react_jsx__ = require('react');
|
|
63
|
+
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
|
|
64
|
+
(__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
62
65
|
/**
|
|
63
66
|
* target 里面可能包含 ?xxx=xxx,这种情况下,需要把 ?xxx=xxx 保留下来,然后对前面的部分进行 filter
|
|
64
67
|
* 因为后面会对 query 部分做不一样的处理。会保留原始的值。而不是会转成字符串。
|
|
@@ -75,13 +78,16 @@ function filterTarget(target, data) {
|
|
|
75
78
|
}
|
|
76
79
|
var rootScopedContext = createScopedTools('');
|
|
77
80
|
var ScopedContext = React__default["default"].createContext(rootScopedContext);
|
|
78
|
-
function createScopedTools(path, parent, env) {
|
|
81
|
+
function createScopedTools(path, parent, env, rendererType) {
|
|
79
82
|
var components = [];
|
|
80
83
|
var self = {
|
|
84
|
+
rendererType: rendererType,
|
|
85
|
+
component: undefined,
|
|
81
86
|
parent: parent,
|
|
82
87
|
registerComponent: function (component) {
|
|
83
88
|
// 不要把自己注册在自己的 Scoped 上,自己的 Scoped 是给子节点们注册的。
|
|
84
89
|
if (component.props.$path === path && parent) {
|
|
90
|
+
self.component = component;
|
|
85
91
|
return parent.registerComponent(component);
|
|
86
92
|
}
|
|
87
93
|
if (!~components.indexOf(component)) {
|
|
@@ -345,12 +351,12 @@ function closeDialog(component) {
|
|
|
345
351
|
.forEach(closeDialog);
|
|
346
352
|
component.props.onClose && component.props.onClose();
|
|
347
353
|
}
|
|
348
|
-
function HocScoped(ComposedComponent) {
|
|
354
|
+
function HocScoped(ComposedComponent, rendererType) {
|
|
349
355
|
var ScopedComponent = /** @class */ (function (_super) {
|
|
350
356
|
tslib.__extends(ScopedComponent, _super);
|
|
351
357
|
function ScopedComponent(props, context) {
|
|
352
358
|
var _this = _super.call(this, props) || this;
|
|
353
|
-
_this.scoped = createScopedTools(_this.props.$path, context, _this.props.env);
|
|
359
|
+
_this.scoped = createScopedTools(_this.props.$path, context, _this.props.env, rendererType);
|
|
354
360
|
var scopeRef = props.scopeRef;
|
|
355
361
|
scopeRef && scopeRef(_this.scoped);
|
|
356
362
|
return _this;
|
|
@@ -371,8 +377,8 @@ function HocScoped(ComposedComponent) {
|
|
|
371
377
|
};
|
|
372
378
|
ScopedComponent.prototype.render = function () {
|
|
373
379
|
var _a = this.props; _a.scopeRef; var rest = tslib.__rest(_a, ["scopeRef"]);
|
|
374
|
-
return (
|
|
375
|
-
|
|
380
|
+
return (_J$X_(ScopedContext.Provider, { value: this.scoped },
|
|
381
|
+
_J$X_(ComposedComponent, tslib.__assign({}, rest /* todo */, { ref: this.childRef }))));
|
|
376
382
|
};
|
|
377
383
|
ScopedComponent.displayName = "Scoped(".concat(ComposedComponent.displayName || ComposedComponent.name, ")");
|
|
378
384
|
ScopedComponent.contextType = ScopedContext;
|
package/lib/StatusScoped.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
|
|
|
@@ -18,6 +18,9 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
18
18
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
19
19
|
var hoistNonReactStatic__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonReactStatic);
|
|
20
20
|
|
|
21
|
+
var __react_jsx__ = require('react');
|
|
22
|
+
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
|
|
23
|
+
(__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
21
24
|
function StatusScoped(ComposedComponent) {
|
|
22
25
|
var _a;
|
|
23
26
|
var result = hoistNonReactStatic__default["default"]((_a = /** @class */ (function (_super) {
|
|
@@ -50,7 +53,7 @@ function StatusScoped(ComposedComponent) {
|
|
|
50
53
|
var refConfig = ((_a = ComposedComponent.prototype) === null || _a === void 0 ? void 0 : _a.isReactComponent)
|
|
51
54
|
? { ref: this.childRef }
|
|
52
55
|
: { forwardedRef: this.childRef };
|
|
53
|
-
return (
|
|
56
|
+
return (_J$X_(ComposedComponent, tslib.__assign({}, this.props, injectedProps, refConfig)));
|
|
54
57
|
};
|
|
55
58
|
return class_1;
|
|
56
59
|
}(React__default["default"].Component)),
|
package/lib/WithRootStore.d.ts
CHANGED
|
@@ -333,30 +333,10 @@ export declare const RootStoreContext: React.Context<{
|
|
|
333
333
|
export declare function withRootStore<T extends React.ComponentType<React.ComponentProps<T> & {
|
|
334
334
|
rootStore: IRendererStore;
|
|
335
335
|
}>>(ComposedComponent: T): {
|
|
336
|
-
new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
forceUpdate(callback?: (() => void) | undefined): void;
|
|
341
|
-
readonly props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>;
|
|
342
|
-
state: Readonly<{}>;
|
|
343
|
-
refs: {
|
|
344
|
-
[key: string]: React.ReactInstance;
|
|
345
|
-
};
|
|
346
|
-
componentDidMount?(): void;
|
|
347
|
-
shouldComponentUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
348
|
-
componentWillUnmount?(): void;
|
|
349
|
-
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
350
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>, prevState: Readonly<{}>): any;
|
|
351
|
-
componentDidUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
352
|
-
componentWillMount?(): void;
|
|
353
|
-
UNSAFE_componentWillMount?(): void;
|
|
354
|
-
componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>, nextContext: any): void;
|
|
355
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>, nextContext: any): void;
|
|
356
|
-
componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>, nextState: Readonly<{}>, nextContext: any): void;
|
|
357
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>, nextState: Readonly<{}>, nextContext: any): void;
|
|
358
|
-
};
|
|
359
|
-
new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>, context: any): {
|
|
336
|
+
new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>): {
|
|
337
|
+
ref: any;
|
|
338
|
+
getWrappedInstance(): any;
|
|
339
|
+
refFn(ref: any): void;
|
|
360
340
|
render(): React.JSX.Element;
|
|
361
341
|
context: unknown;
|
|
362
342
|
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
package/lib/WithRootStore.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
|
|
|
@@ -16,20 +16,31 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
16
16
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
17
|
var hoistNonReactStatic__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonReactStatic);
|
|
18
18
|
|
|
19
|
+
var __react_jsx__ = require('react');
|
|
20
|
+
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
|
|
21
|
+
(__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
19
22
|
var RootStoreContext = React__default["default"].createContext(undefined);
|
|
20
23
|
function withRootStore(ComposedComponent) {
|
|
21
24
|
var _a;
|
|
22
25
|
var result = hoistNonReactStatic__default["default"]((_a = /** @class */ (function (_super) {
|
|
23
26
|
tslib.__extends(class_1, _super);
|
|
24
|
-
function class_1() {
|
|
25
|
-
|
|
27
|
+
function class_1(props) {
|
|
28
|
+
var _this = _super.call(this, props) || this;
|
|
29
|
+
_this.refFn = _this.refFn.bind(_this);
|
|
30
|
+
return _this;
|
|
26
31
|
}
|
|
32
|
+
class_1.prototype.getWrappedInstance = function () {
|
|
33
|
+
return this.ref.control;
|
|
34
|
+
};
|
|
35
|
+
class_1.prototype.refFn = function (ref) {
|
|
36
|
+
this.ref = ref;
|
|
37
|
+
};
|
|
27
38
|
class_1.prototype.render = function () {
|
|
28
39
|
var rootStore = this.context;
|
|
29
40
|
var injectedProps = {
|
|
30
41
|
rootStore: rootStore
|
|
31
42
|
};
|
|
32
|
-
return (
|
|
43
|
+
return (_J$X_(ComposedComponent, tslib.__assign({}, this.props, injectedProps, { ref: this.refFn })));
|
|
33
44
|
};
|
|
34
45
|
return class_1;
|
|
35
46
|
}(React__default["default"].Component)),
|
package/lib/WithStore.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
|
|
|
@@ -18,6 +18,7 @@ var helper = require('./utils/helper.js');
|
|
|
18
18
|
require('amis-formula');
|
|
19
19
|
require('moment');
|
|
20
20
|
var object = require('./utils/object.js');
|
|
21
|
+
var tokenize = require('./utils/tokenize.js');
|
|
21
22
|
var dataMapping = require('./utils/dataMapping.js');
|
|
22
23
|
require('./utils/filter.js');
|
|
23
24
|
var WithRootStore = require('./WithRootStore.js');
|
|
@@ -27,6 +28,9 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
27
28
|
var hoistNonReactStatic__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonReactStatic);
|
|
28
29
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
29
30
|
|
|
31
|
+
var __react_jsx__ = require('react');
|
|
32
|
+
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
|
|
33
|
+
(__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
30
34
|
function HocStoreFactory(renderer) {
|
|
31
35
|
return function (Component) {
|
|
32
36
|
var StoreFactory = /** @class */ (function (_super) {
|
|
@@ -106,20 +110,26 @@ function HocStoreFactory(renderer) {
|
|
|
106
110
|
if (extendsData === false) {
|
|
107
111
|
if (shouldSync === true ||
|
|
108
112
|
prevProps.defaultData !== props.defaultData ||
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
(props.trackExpression
|
|
114
|
+
? tokenize.tokenize(props.trackExpression, props.data) !==
|
|
115
|
+
tokenize.tokenize(props.trackExpression, prevProps.data)
|
|
116
|
+
: helper.isObjectShallowModified(prevProps.data, props.data) ||
|
|
117
|
+
//
|
|
118
|
+
// 特殊处理 CRUD。
|
|
119
|
+
// CRUD 中 toolbar 里面的 data 是空对象,但是 __super 会不一样
|
|
120
|
+
(props.data &&
|
|
121
|
+
prevProps.data &&
|
|
122
|
+
props.data.__super !== prevProps.data.__super))) {
|
|
116
123
|
store.initData(object.extendObject(props.data, tslib.__assign(tslib.__assign(tslib.__assign({}, (store.hasRemoteData ? store.data : null)), this.formatData(props.defaultData)), this.formatData(props.data))));
|
|
117
124
|
}
|
|
118
125
|
}
|
|
119
126
|
else if (shouldSync === true ||
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
(props.trackExpression
|
|
128
|
+
? tokenize.tokenize(props.trackExpression, props.data) !==
|
|
129
|
+
tokenize.tokenize(props.trackExpression, prevProps.data)
|
|
130
|
+
: helper.isObjectShallowModified(prevProps.data, props.data) ||
|
|
131
|
+
(props.syncSuperStore !== false &&
|
|
132
|
+
helper.isSuperDataModified(props.data, prevProps.data, store)))) {
|
|
123
133
|
if (props.store && props.store.data === props.data) {
|
|
124
134
|
store.initData(object.createObject(props.store.data, props.syncSuperStore === false
|
|
125
135
|
? tslib.__assign({}, store.data) : helper.syncDataFromSuper(store.data, props.store.data, prevProps.scope, store, props.syncSuperStore === true)));
|
|
@@ -132,9 +142,8 @@ function HocStoreFactory(renderer) {
|
|
|
132
142
|
store.initData(object.createObject(props.scope, props.data));
|
|
133
143
|
}
|
|
134
144
|
}
|
|
135
|
-
else if (
|
|
136
|
-
!props.store ||
|
|
137
|
-
props.data !== props.store.data) &&
|
|
145
|
+
else if (!props.trackExpression &&
|
|
146
|
+
(!props.store || props.data !== props.store.data) &&
|
|
138
147
|
props.data &&
|
|
139
148
|
props.data.__super) {
|
|
140
149
|
// 这个用法很少,当 data.__super 值发生变化时,更新 store.data
|
|
@@ -145,9 +154,10 @@ function HocStoreFactory(renderer) {
|
|
|
145
154
|
}
|
|
146
155
|
// nextProps.data.__super !== props.data.__super) &&
|
|
147
156
|
}
|
|
148
|
-
else if (props.
|
|
157
|
+
else if (!props.trackExpression &&
|
|
158
|
+
props.scope &&
|
|
149
159
|
props.data === props.store.data &&
|
|
150
|
-
|
|
160
|
+
prevProps.data !== props.data) {
|
|
151
161
|
// 只有父级数据变动的时候才应该进来,
|
|
152
162
|
// 目前看来这个 case 很少有情况下能进来
|
|
153
163
|
store.initData(object.createObject(props.scope, tslib.__assign({}, store.data)));
|
|
@@ -175,7 +185,7 @@ function HocStoreFactory(renderer) {
|
|
|
175
185
|
if (this.state.hidden || this.state.visible === false) {
|
|
176
186
|
return null;
|
|
177
187
|
}
|
|
178
|
-
return (
|
|
188
|
+
return (_J$X_(Component, tslib.__assign({}, rest /* todo */, this.state, { ref: this.refFn, data: this.store.data, dataUpdatedAt: this.store.updatedAt, store: this.store, scope: this.store.data, render: this.renderChild })));
|
|
179
189
|
};
|
|
180
190
|
StoreFactory.displayName = "WithStore(".concat(Component.displayName || Component.name, ")");
|
|
181
191
|
StoreFactory.ComposedComponent = Component;
|
package/lib/actions/Action.d.ts
CHANGED
package/lib/actions/Action.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
|
|
|
@@ -96,7 +96,7 @@ var getOmitActionProp = function (type) {
|
|
|
96
96
|
omitList = ['drawer'];
|
|
97
97
|
break;
|
|
98
98
|
case 'confirmDialog':
|
|
99
|
-
omitList = ['
|
|
99
|
+
omitList = ['dialog'];
|
|
100
100
|
break;
|
|
101
101
|
case 'reload':
|
|
102
102
|
omitList = ['resetPage'];
|
|
@@ -125,11 +125,20 @@ var runActions = function (actions, renderer, event) { return tslib.__awaiter(vo
|
|
|
125
125
|
// 如果存在指定组件ID,说明是组件专有动作
|
|
126
126
|
if (!actionInstrance &&
|
|
127
127
|
(actionConfig.componentId || actionConfig.componentName)) {
|
|
128
|
-
actionInstrance =
|
|
128
|
+
actionInstrance = [
|
|
129
|
+
'static',
|
|
130
|
+
'nonstatic',
|
|
131
|
+
'show',
|
|
132
|
+
'visibility',
|
|
133
|
+
'hidden',
|
|
134
|
+
'enabled',
|
|
135
|
+
'disabled',
|
|
136
|
+
'usability'
|
|
137
|
+
].includes(actionConfig.actionType)
|
|
138
|
+
? getActionByType('status')
|
|
139
|
+
: getActionByType('component');
|
|
129
140
|
}
|
|
130
|
-
else if (
|
|
131
|
-
actionConfig.actionType === 'link' ||
|
|
132
|
-
actionConfig.actionType === 'jump') {
|
|
141
|
+
else if (['url', 'link', 'jump'].includes(actionConfig.actionType)) {
|
|
133
142
|
// 打开页面动作
|
|
134
143
|
actionInstrance = getActionByType('openlink');
|
|
135
144
|
}
|
|
@@ -166,14 +175,16 @@ var runActions = function (actions, renderer, event) { return tslib.__awaiter(vo
|
|
|
166
175
|
}); };
|
|
167
176
|
// 执行动作,与原有动作处理打通
|
|
168
177
|
var runAction = function (actionInstrance, actionConfig, renderer, event) { return tslib.__awaiter(void 0, void 0, void 0, function () {
|
|
169
|
-
var additional, mergeData, expression, isStop, preventDefault,
|
|
170
|
-
var _a, _b, _c;
|
|
171
|
-
return tslib.__generator(this, function (
|
|
172
|
-
switch (
|
|
178
|
+
var additional, action, mergeData, expression, isStop, preventDefault, key, api, args, afterMappingData, actionData, data, stopped, actionResult, stopPropagation;
|
|
179
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
180
|
+
return tslib.__generator(this, function (_u) {
|
|
181
|
+
switch (_u.label) {
|
|
173
182
|
case 0:
|
|
174
183
|
additional = {
|
|
175
184
|
event: event
|
|
176
185
|
};
|
|
186
|
+
action = tslib.__assign({}, actionConfig);
|
|
187
|
+
action.args = tslib.__assign({}, actionConfig.args);
|
|
177
188
|
// __rendererData默认为renderer.props.data,兼容表单项值变化时的data读取
|
|
178
189
|
if (!event.data.__rendererData) {
|
|
179
190
|
additional = {
|
|
@@ -184,36 +195,47 @@ var runAction = function (actionInstrance, actionConfig, renderer, event) { retu
|
|
|
184
195
|
mergeData = object.createObject(object.createObject(renderer.props.data.__super
|
|
185
196
|
? object.createObject(renderer.props.data.__super, additional)
|
|
186
197
|
: additional, renderer.props.data), event.data);
|
|
187
|
-
expression = (_a =
|
|
198
|
+
expression = (_a = action.expression) !== null && _a !== void 0 ? _a : action.execOn;
|
|
188
199
|
isStop = false;
|
|
189
200
|
if (!expression) return [3 /*break*/, 2];
|
|
190
201
|
return [4 /*yield*/, tpl.evalExpressionWithConditionBuilder(expression, mergeData, true)];
|
|
191
202
|
case 1:
|
|
192
|
-
isStop = !(
|
|
193
|
-
|
|
203
|
+
isStop = !(_u.sent());
|
|
204
|
+
_u.label = 2;
|
|
194
205
|
case 2:
|
|
195
206
|
if (isStop) {
|
|
196
207
|
return [2 /*return*/];
|
|
197
208
|
}
|
|
198
209
|
preventDefault = false;
|
|
199
|
-
if (!
|
|
200
|
-
return [4 /*yield*/, tpl.evalExpressionWithConditionBuilder(
|
|
210
|
+
if (!action.preventDefault) return [3 /*break*/, 4];
|
|
211
|
+
return [4 /*yield*/, tpl.evalExpressionWithConditionBuilder(action.preventDefault, mergeData, false)];
|
|
201
212
|
case 3:
|
|
202
|
-
preventDefault =
|
|
203
|
-
|
|
213
|
+
preventDefault = _u.sent();
|
|
214
|
+
_u.label = 4;
|
|
204
215
|
case 4:
|
|
205
|
-
stopPropagation = false;
|
|
206
|
-
if (!actionConfig.stopPropagation) return [3 /*break*/, 6];
|
|
207
|
-
return [4 /*yield*/, tpl.evalExpressionWithConditionBuilder(actionConfig.stopPropagation, mergeData, false)];
|
|
208
|
-
case 5:
|
|
209
|
-
stopPropagation = _d.sent();
|
|
210
|
-
_d.label = 6;
|
|
211
|
-
case 6:
|
|
212
216
|
key = {
|
|
213
|
-
componentId: dataMapping.dataMapping(
|
|
214
|
-
componentName: dataMapping.dataMapping(
|
|
217
|
+
componentId: dataMapping.dataMapping(action.componentId, mergeData),
|
|
218
|
+
componentName: dataMapping.dataMapping(action.componentName, mergeData)
|
|
215
219
|
};
|
|
216
|
-
|
|
220
|
+
// 兼容args包裹的用法
|
|
221
|
+
if (action.actionType === 'dialog') {
|
|
222
|
+
action.dialog = tslib.__assign({}, ((_b = action.dialog) !== null && _b !== void 0 ? _b : (_c = action.args) === null || _c === void 0 ? void 0 : _c.dialog));
|
|
223
|
+
(_d = action.args) === null || _d === void 0 ? true : delete _d.dialog;
|
|
224
|
+
}
|
|
225
|
+
else if (action.actionType === 'drawer') {
|
|
226
|
+
action.drawer = tslib.__assign({}, ((_e = action.drawer) !== null && _e !== void 0 ? _e : (_f = action.args) === null || _f === void 0 ? void 0 : _f.drawer));
|
|
227
|
+
(_g = action.args) === null || _g === void 0 ? true : delete _g.drawer;
|
|
228
|
+
}
|
|
229
|
+
else if (action.actionType === 'ajax') {
|
|
230
|
+
api = (_h = action.api) !== null && _h !== void 0 ? _h : (_j = action.args) === null || _j === void 0 ? void 0 : _j.api;
|
|
231
|
+
action.api = typeof api === 'string' ? api : tslib.__assign({}, api);
|
|
232
|
+
action.options = tslib.__assign({}, ((_k = action.options) !== null && _k !== void 0 ? _k : (_l = action.args) === null || _l === void 0 ? void 0 : _l.options));
|
|
233
|
+
action.messages = tslib.__assign({}, ((_m = action.messages) !== null && _m !== void 0 ? _m : (_o = action.args) === null || _o === void 0 ? void 0 : _o.messages));
|
|
234
|
+
(_p = action.args) === null || _p === void 0 ? true : delete _p.api;
|
|
235
|
+
(_q = action.args) === null || _q === void 0 ? true : delete _q.options;
|
|
236
|
+
(_r = action.args) === null || _r === void 0 ? true : delete _r.messages;
|
|
237
|
+
}
|
|
238
|
+
args = dataMapping.dataMapping(action.args, mergeData, function (key) {
|
|
217
239
|
return [
|
|
218
240
|
'adaptor',
|
|
219
241
|
'responseAdaptor',
|
|
@@ -222,31 +244,34 @@ var runAction = function (actionInstrance, actionConfig, renderer, event) { retu
|
|
|
222
244
|
'condition'
|
|
223
245
|
].includes(key);
|
|
224
246
|
});
|
|
225
|
-
afterMappingData = dataMapping.dataMapping(
|
|
247
|
+
afterMappingData = dataMapping.dataMapping(action.data, mergeData);
|
|
226
248
|
actionData = args && Object.keys(args).length
|
|
227
|
-
? omit__default["default"](tslib.__assign(tslib.__assign({}, args), (afterMappingData !== null && afterMappingData !== void 0 ? afterMappingData : {})), getOmitActionProp(
|
|
249
|
+
? omit__default["default"](tslib.__assign(tslib.__assign({}, args), (afterMappingData !== null && afterMappingData !== void 0 ? afterMappingData : {})), getOmitActionProp(action.actionType))
|
|
228
250
|
: afterMappingData;
|
|
229
|
-
data =
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
stoped = false;
|
|
237
|
-
return [4 /*yield*/, actionInstrance.run(tslib.__assign(tslib.__assign(tslib.__assign({}, actionConfig), { args: args, data: data }), key), renderer, event, mergeData)];
|
|
238
|
-
case 7:
|
|
239
|
-
actionResult = _d.sent();
|
|
251
|
+
data = actionData !== undefined ? actionData : mergeData;
|
|
252
|
+
(_s = console.group) === null || _s === void 0 ? void 0 : _s.call(console, "run action ".concat(action.actionType));
|
|
253
|
+
console.debug("[".concat(action.actionType, "] action args, data"), args, data);
|
|
254
|
+
stopped = false;
|
|
255
|
+
return [4 /*yield*/, actionInstrance.run(tslib.__assign(tslib.__assign(tslib.__assign({}, action), { args: args, data: action.actionType === 'reload' ? actionData : data }), key), renderer, event, mergeData)];
|
|
256
|
+
case 5:
|
|
257
|
+
actionResult = _u.sent();
|
|
240
258
|
// 二次确认弹窗如果取消,则终止后续动作
|
|
241
|
-
if ((
|
|
242
|
-
|
|
259
|
+
if ((action === null || action === void 0 ? void 0 : action.actionType) === 'confirmDialog' && !actionResult) {
|
|
260
|
+
stopped = true;
|
|
243
261
|
}
|
|
244
|
-
|
|
245
|
-
(
|
|
262
|
+
stopPropagation = false;
|
|
263
|
+
if (!action.stopPropagation) return [3 /*break*/, 7];
|
|
264
|
+
return [4 /*yield*/, tpl.evalExpressionWithConditionBuilder(action.stopPropagation, mergeData, false)];
|
|
265
|
+
case 6:
|
|
266
|
+
stopPropagation = _u.sent();
|
|
267
|
+
_u.label = 7;
|
|
268
|
+
case 7:
|
|
269
|
+
console.debug("[".concat(action.actionType, "] action end event"), event);
|
|
270
|
+
(_t = console.groupEnd) === null || _t === void 0 ? void 0 : _t.call(console);
|
|
246
271
|
// 阻止原有动作执行
|
|
247
272
|
preventDefault && event.preventDefault();
|
|
248
273
|
// 阻止后续动作执行
|
|
249
|
-
(stopPropagation ||
|
|
274
|
+
(stopPropagation || stopped) && event.stopPropagation();
|
|
250
275
|
return [2 /*return*/];
|
|
251
276
|
}
|
|
252
277
|
});
|
|
@@ -3,15 +3,13 @@ import { RendererEvent } from '../utils/renderer-event';
|
|
|
3
3
|
import { RendererAction, ListenerAction, ListenerContext } from './Action';
|
|
4
4
|
export interface IAjaxAction extends ListenerAction {
|
|
5
5
|
action: 'ajax';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
failed: string;
|
|
11
|
-
};
|
|
12
|
-
options?: Record<string, any>;
|
|
13
|
-
[propName: string]: any;
|
|
6
|
+
api: Api;
|
|
7
|
+
messages?: {
|
|
8
|
+
success: string;
|
|
9
|
+
failed: string;
|
|
14
10
|
};
|
|
11
|
+
options?: Record<string, any>;
|
|
12
|
+
[propName: string]: any;
|
|
15
13
|
}
|
|
16
14
|
/**
|
|
17
15
|
* 发送请求动作
|
|
@@ -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
|
|
|
@@ -27,39 +27,41 @@ var AjaxAction = /** @class */ (function () {
|
|
|
27
27
|
this.fetcherType = fetcherType;
|
|
28
28
|
}
|
|
29
29
|
AjaxAction.prototype.run = function (action, renderer, event) {
|
|
30
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
31
31
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
32
|
-
var env, result, responseData, msg, e_1, result;
|
|
33
|
-
var
|
|
34
|
-
return tslib.__generator(this, function (
|
|
35
|
-
switch (
|
|
32
|
+
var env, silent, messages, result, responseData, msg, e_1, result;
|
|
33
|
+
var _o;
|
|
34
|
+
return tslib.__generator(this, function (_p) {
|
|
35
|
+
switch (_p.label) {
|
|
36
36
|
case 0:
|
|
37
37
|
if (!((_a = renderer.props.env) === null || _a === void 0 ? void 0 : _a.fetcher)) {
|
|
38
38
|
throw new Error('env.fetcher is required!');
|
|
39
39
|
}
|
|
40
40
|
if (this.fetcherType === 'download' && action.actionType === 'download') {
|
|
41
|
-
if (
|
|
42
|
-
action.
|
|
41
|
+
if (action.api) {
|
|
42
|
+
action.api.responseType = 'blob';
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
env = event.context.env;
|
|
46
|
-
|
|
46
|
+
silent = (_b = action === null || action === void 0 ? void 0 : action.options) === null || _b === void 0 ? void 0 : _b.silent;
|
|
47
|
+
messages = (_c = action === null || action === void 0 ? void 0 : action.api) === null || _c === void 0 ? void 0 : _c.messages;
|
|
48
|
+
_p.label = 1;
|
|
47
49
|
case 1:
|
|
48
|
-
|
|
49
|
-
return [4 /*yield*/, env.fetcher(
|
|
50
|
+
_p.trys.push([1, 3, , 4]);
|
|
51
|
+
return [4 /*yield*/, env.fetcher(action === null || action === void 0 ? void 0 : action.api, (_d = action.data) !== null && _d !== void 0 ? _d : {}, (_e = action === null || action === void 0 ? void 0 : action.options) !== null && _e !== void 0 ? _e : {})];
|
|
50
52
|
case 2:
|
|
51
|
-
result =
|
|
53
|
+
result = _p.sent();
|
|
52
54
|
responseData = !helper.isEmpty(result.data) || result.ok
|
|
53
55
|
? api.normalizeApiResponseData(result.data)
|
|
54
56
|
: null;
|
|
55
57
|
// 记录请求返回的数据
|
|
56
|
-
event.setData(object.createObject(event.data, tslib.__assign(tslib.__assign({}, responseData), (
|
|
57
|
-
if (!
|
|
58
|
+
event.setData(object.createObject(event.data, tslib.__assign(tslib.__assign({}, responseData), (_o = { responseData: responseData }, _o[action.outputVar || 'responseResult'] = tslib.__assign(tslib.__assign({}, responseData), { responseData: responseData, responseStatus: result.status, responseMsg: result.msg }), _o))));
|
|
59
|
+
if (!silent) {
|
|
58
60
|
if (!result.ok) {
|
|
59
|
-
throw new errors.ServerError((
|
|
61
|
+
throw new errors.ServerError((_h = (_f = messages === null || messages === void 0 ? void 0 : messages.failed) !== null && _f !== void 0 ? _f : (_g = action.messages) === null || _g === void 0 ? void 0 : _g.failed) !== null && _h !== void 0 ? _h : result.msg, result);
|
|
60
62
|
}
|
|
61
63
|
else {
|
|
62
|
-
msg = (
|
|
64
|
+
msg = (_m = (_l = (_j = messages === null || messages === void 0 ? void 0 : messages.success) !== null && _j !== void 0 ? _j : (_k = action.messages) === null || _k === void 0 ? void 0 : _k.success) !== null && _l !== void 0 ? _l : result.msg) !== null && _m !== void 0 ? _m : result.defaultMsg;
|
|
63
65
|
msg &&
|
|
64
66
|
env.notify('success', msg, result.msgTimeout !== undefined
|
|
65
67
|
? {
|
|
@@ -71,8 +73,8 @@ var AjaxAction = /** @class */ (function () {
|
|
|
71
73
|
}
|
|
72
74
|
return [2 /*return*/, result.data];
|
|
73
75
|
case 3:
|
|
74
|
-
e_1 =
|
|
75
|
-
if (!
|
|
76
|
+
e_1 = _p.sent();
|
|
77
|
+
if (!silent) {
|
|
76
78
|
if (e_1.type === 'ServerError') {
|
|
77
79
|
result = e_1.response;
|
|
78
80
|
env.notify('error', e_1.message, result.msgTimeout !== undefined
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { RendererEvent } from '../utils/renderer-event';
|
|
2
2
|
import { RendererAction, ListenerAction, ListenerContext } from './Action';
|
|
3
3
|
export interface ICmptAction extends ListenerAction {
|
|
4
|
-
actionType:
|
|
4
|
+
actionType: string;
|
|
5
5
|
args: {
|
|
6
|
-
/** actionType为setValue时,目标变量的path */
|
|
7
6
|
path?: string;
|
|
8
7
|
value?: string | {
|
|
9
8
|
[key: string]: string;
|