amis-core 2.7.2 → 2.8.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.js +4 -4
- package/esm/SchemaRenderer.js +23 -12
- package/esm/Scoped.js +49 -30
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +1 -1
- package/esm/actions/Action.js +32 -17
- package/esm/actions/AjaxAction.js +1 -1
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.js +1 -1
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +1 -1
- package/esm/actions/DialogAction.js +1 -1
- package/esm/actions/DrawerAction.js +1 -1
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/LinkAction.js +1 -1
- package/esm/actions/LoopAction.js +63 -34
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/SwitchAction.js +25 -12
- package/esm/actions/ToastAction.js +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.js +1 -1
- package/esm/components/PopOver.js +1 -1
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +29 -9
- package/esm/factory.js +1 -1
- package/esm/index.js +2 -2
- package/esm/locale.js +3 -3
- package/esm/renderers/Form.js +5 -36
- package/esm/renderers/Item.js +4 -4
- package/esm/renderers/Options.js +4 -4
- package/esm/renderers/Placeholder.js +1 -1
- package/esm/renderers/builtin.js +1 -1
- package/esm/renderers/register.js +3 -6
- package/esm/renderers/wrapControl.js +8 -4
- package/esm/store/app.js +1 -1
- package/esm/store/combo.d.ts +2335 -239
- package/esm/store/combo.js +1 -1
- package/esm/store/crud.js +54 -35
- package/esm/store/form.d.ts +1033 -16
- package/esm/store/form.js +27 -7
- package/esm/store/formItem.d.ts +9 -1
- package/esm/store/formItem.js +83 -45
- package/esm/store/iRenderer.js +1 -1
- 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 +1 -1
- package/esm/store/service.js +1 -1
- package/esm/store/table.d.ts +2180 -148
- package/esm/store/table.js +27 -17
- package/esm/store/table2.js +1 -1
- package/esm/theme.js +3 -3
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +4 -3
- package/esm/utils/DataSchema.js +4 -3
- package/esm/utils/DataScope.js +36 -16
- package/esm/utils/RootClose.js +3 -3
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.js +4 -4
- package/esm/utils/attachmentAdpator.js +1 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/columnsSplit.js +3 -5
- package/esm/utils/dataMapping.js +16 -6
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.js +28 -18
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.js +4 -3
- 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 +5 -7
- package/esm/utils/formatDuration.js +1 -1
- package/esm/utils/formula.js +1 -1
- 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.js +7 -7
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.js +1 -1
- package/esm/utils/image.js +1 -1
- 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/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.js +1 -1
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +1 -1
- package/esm/utils/position.js +1 -1
- package/esm/utils/prettyBytes.js +8 -1
- package/esm/utils/renderer-event.js +54 -29
- package/esm/utils/replaceText.js +16 -8
- package/esm/utils/resize-sensor.js +4 -2
- package/esm/utils/resolveVariable.js +1 -1
- package/esm/utils/resolveVariableAndFilter.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 +96 -75
- 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 +3 -3
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validations.js +4 -4
- package/lib/Root.js +1 -1
- package/lib/RootRenderer.js +3 -3
- package/lib/SchemaRenderer.js +22 -11
- package/lib/Scoped.js +48 -29
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +1 -1
- package/lib/actions/Action.js +31 -16
- package/lib/actions/AjaxAction.js +1 -1
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.js +1 -1
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +1 -1
- package/lib/actions/DialogAction.js +1 -1
- package/lib/actions/DrawerAction.js +1 -1
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/LinkAction.js +1 -1
- package/lib/actions/LoopAction.js +62 -33
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/SwitchAction.js +24 -11
- package/lib/actions/ToastAction.js +1 -1
- package/lib/components/LazyComponent.js +1 -1
- package/lib/components/Overlay.js +1 -1
- package/lib/components/PopOver.js +1 -1
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +29 -9
- package/lib/factory.js +1 -1
- package/lib/index.js +2 -2
- package/lib/locale.js +2 -2
- package/lib/renderers/Form.js +5 -36
- package/lib/renderers/Item.js +3 -3
- package/lib/renderers/Options.js +3 -3
- package/lib/renderers/Placeholder.js +1 -1
- package/lib/renderers/builtin.js +1 -1
- package/lib/renderers/register.js +3 -6
- package/lib/renderers/wrapControl.js +8 -4
- package/lib/store/app.js +1 -1
- package/lib/store/combo.d.ts +2335 -239
- package/lib/store/combo.js +1 -1
- package/lib/store/crud.js +53 -34
- package/lib/store/form.d.ts +1033 -16
- package/lib/store/form.js +26 -6
- package/lib/store/formItem.d.ts +9 -1
- package/lib/store/formItem.js +81 -43
- package/lib/store/iRenderer.js +1 -1
- 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 +1 -1
- package/lib/store/service.js +1 -1
- package/lib/store/table.d.ts +2180 -148
- package/lib/store/table.js +26 -16
- package/lib/store/table2.js +1 -1
- package/lib/theme.js +2 -2
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +4 -3
- package/lib/utils/DataSchema.js +4 -3
- package/lib/utils/DataScope.js +35 -15
- package/lib/utils/RootClose.js +2 -2
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.js +3 -3
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/columnsSplit.js +3 -5
- package/lib/utils/dataMapping.js +15 -5
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.js +27 -17
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.js +4 -3
- 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 +4 -6
- package/lib/utils/formatDuration.js +1 -1
- package/lib/utils/formula.js +1 -1
- 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.js +6 -6
- package/lib/utils/highlight.js +1 -1
- package/lib/utils/icon.js +1 -1
- package/lib/utils/image.js +1 -1
- 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/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.js +1 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +1 -1
- package/lib/utils/position.js +1 -1
- package/lib/utils/prettyBytes.js +8 -1
- package/lib/utils/renderer-event.js +53 -28
- package/lib/utils/replaceText.js +16 -8
- package/lib/utils/resize-sensor.js +4 -2
- package/lib/utils/resolveVariable.js +1 -1
- package/lib/utils/resolveVariableAndFilter.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 +96 -75
- 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 +2 -2
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validations.js +3 -3
- package/package.json +3 -3
package/esm/Root.js
CHANGED
package/esm/RootRenderer.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.
|
|
2
|
+
* amis-core v2.8.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __extends, __assign, __awaiter, __generator, __spreadArray, __rest, __decorate, __metadata } from 'tslib';
|
|
6
|
+
import { __extends, __assign, __awaiter, __generator, __spreadArray, __read, __rest, __decorate, __metadata } from 'tslib';
|
|
7
7
|
import { observer } from 'mobx-react';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { ScopedContext } from './Scoped.js';
|
|
@@ -192,7 +192,7 @@ var RootRenderer = /** @class */ (function (_super) {
|
|
|
192
192
|
var dialog = store.action.dialog;
|
|
193
193
|
if (dialog &&
|
|
194
194
|
dialog.onConfirm &&
|
|
195
|
-
dialog.onConfirm.apply(dialog, __spreadArray([values, action], args, false)) === false) {
|
|
195
|
+
dialog.onConfirm.apply(dialog, __spreadArray([values, action], __read(args), false)) === false) {
|
|
196
196
|
return;
|
|
197
197
|
}
|
|
198
198
|
store.closeDialog(true);
|
|
@@ -214,7 +214,7 @@ var RootRenderer = /** @class */ (function (_super) {
|
|
|
214
214
|
var drawer = store.action.drawer;
|
|
215
215
|
if (drawer &&
|
|
216
216
|
drawer.onConfirm &&
|
|
217
|
-
drawer.onConfirm.apply(drawer, __spreadArray([values, action], args, false)) === false) {
|
|
217
|
+
drawer.onConfirm.apply(drawer, __spreadArray([values, action], __read(args), false)) === false) {
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
220
220
|
store.closeDrawer();
|
package/esm/SchemaRenderer.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.
|
|
2
|
+
* amis-core v2.8.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __extends, __assign, __awaiter, __generator, __rest, __decorate, __metadata } from 'tslib';
|
|
6
|
+
import { __extends, __assign, __awaiter, __generator, __rest, __values, __decorate, __metadata } from 'tslib';
|
|
7
7
|
import difference from 'lodash/difference';
|
|
8
8
|
import omit from 'lodash/omit';
|
|
9
9
|
import React from 'react';
|
|
@@ -181,13 +181,14 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
181
181
|
this.forceUpdate();
|
|
182
182
|
};
|
|
183
183
|
SchemaRenderer.prototype.render = function () {
|
|
184
|
+
var e_1, _a;
|
|
184
185
|
var _this = this;
|
|
185
|
-
var
|
|
186
|
-
var
|
|
186
|
+
var _b, _c, _d;
|
|
187
|
+
var _e = this.props; _e.$path; var __ = _e.schema, rootStore = _e.rootStore, topStore = _e.topStore, render = _e.render, rest = __rest(_e, ["$path", "schema", "rootStore", "topStore", "render"]);
|
|
187
188
|
if (__ == null) {
|
|
188
189
|
return null;
|
|
189
190
|
}
|
|
190
|
-
var
|
|
191
|
+
var _f = this.resolveRenderer(this.props), $path = _f.path, schema = _f.schema;
|
|
191
192
|
var theme = this.props.env.theme;
|
|
192
193
|
if (Array.isArray(schema)) {
|
|
193
194
|
return render($path, schema, rest);
|
|
@@ -280,13 +281,14 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
280
281
|
}
|
|
281
282
|
// style 支持公式
|
|
282
283
|
if (schema.style) {
|
|
283
|
-
|
|
284
|
+
// schema.style是readonly属性
|
|
285
|
+
schema = __assign(__assign({}, schema), { style: buildStyle(schema.style, detectData) });
|
|
284
286
|
}
|
|
285
|
-
var isClassComponent = (
|
|
287
|
+
var isClassComponent = (_b = Component.prototype) === null || _b === void 0 ? void 0 : _b.isReactComponent;
|
|
286
288
|
var $schema = __assign(__assign({}, schema), exprProps);
|
|
287
289
|
var props = __assign(__assign(__assign(__assign(__assign({}, theme.getRendererConfig(renderer.name)), restSchema), chainEvents(rest, restSchema)), exprProps), {
|
|
288
290
|
// value: defaultValue, // 备注: 此处并没有将value传递给渲染器
|
|
289
|
-
defaultData: (
|
|
291
|
+
defaultData: (_c = restSchema.defaultData) !== null && _c !== void 0 ? _c : defaultData, defaultValue: (_d = restSchema.defaultValue) !== null && _d !== void 0 ? _d : defaultValue, defaultActiveKey: defaultActiveKey, propKey: propKey, $path: $path, $schema: $schema, ref: this.refFn, render: this.renderChild, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent });
|
|
290
292
|
if (disable !== undefined) {
|
|
291
293
|
props.disabled = disable;
|
|
292
294
|
}
|
|
@@ -295,12 +297,21 @@ var SchemaRenderer = /** @class */ (function (_super) {
|
|
|
295
297
|
}
|
|
296
298
|
// 自动解析变量模式,主要是方便直接引入第三方组件库,无需为了支持变量封装一层
|
|
297
299
|
if (renderer.autoVar) {
|
|
298
|
-
|
|
299
|
-
var
|
|
300
|
-
|
|
301
|
-
|
|
300
|
+
try {
|
|
301
|
+
for (var _g = __values(Object.keys($schema)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
302
|
+
var key = _h.value;
|
|
303
|
+
if (typeof props[key] === 'string') {
|
|
304
|
+
props[key] = resolveVariableAndFilter(props[key], props.data, '| raw');
|
|
305
|
+
}
|
|
302
306
|
}
|
|
303
307
|
}
|
|
308
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
309
|
+
finally {
|
|
310
|
+
try {
|
|
311
|
+
if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
|
|
312
|
+
}
|
|
313
|
+
finally { if (e_1) throw e_1.error; }
|
|
314
|
+
}
|
|
304
315
|
}
|
|
305
316
|
var component = isClassComponent ? (React.createElement(Component, __assign({}, props, { ref: this.childRef }))) : (React.createElement(Component, __assign({}, props)));
|
|
306
317
|
return this.props.env.enableAMISDebug ? (React.createElement(DebugWrapper, { renderer: renderer }, component)) : (component);
|
package/esm/Scoped.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.
|
|
2
|
+
* amis-core v2.8.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __assign, __extends, __rest, __decorate, __metadata } from 'tslib';
|
|
6
|
+
import { __values, __assign, __extends, __rest, __decorate, __metadata } from 'tslib';
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import find from 'lodash/find';
|
|
9
9
|
import values from 'lodash/values';
|
|
@@ -98,39 +98,58 @@ function createScopedTools(path, parent, env) {
|
|
|
98
98
|
root = root.parent;
|
|
99
99
|
}
|
|
100
100
|
eachTree([root], function (item) {
|
|
101
|
-
var
|
|
101
|
+
var e_1, _a, e_2, _b;
|
|
102
|
+
var _c, _d, _e, _f, _g, _h;
|
|
102
103
|
var scopedCmptList = item.getComponents() || [];
|
|
103
104
|
if (Array.isArray(scopedCmptList)) {
|
|
104
|
-
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
105
|
+
try {
|
|
106
|
+
for (var scopedCmptList_1 = __values(scopedCmptList), scopedCmptList_1_1 = scopedCmptList_1.next(); !scopedCmptList_1_1.done; scopedCmptList_1_1 = scopedCmptList_1.next()) {
|
|
107
|
+
var cmpt = scopedCmptList_1_1.value;
|
|
108
|
+
var pathKey = (_d = (_c = cmpt === null || cmpt === void 0 ? void 0 : cmpt.props) === null || _c === void 0 ? void 0 : _c.$path) !== null && _d !== void 0 ? _d : 'unknown';
|
|
109
|
+
var schema = (_f = (_e = cmpt === null || cmpt === void 0 ? void 0 : cmpt.props) === null || _e === void 0 ? void 0 : _e.$schema) !== null && _f !== void 0 ? _f : {};
|
|
110
|
+
var cmptSession = (_h = (_g = cmpt === null || cmpt === void 0 ? void 0 : cmpt.props.env) === null || _g === void 0 ? void 0 : _g.session) !== null && _h !== void 0 ? _h : 'global';
|
|
111
|
+
/** 仅查找当前session的组件 */
|
|
112
|
+
if (cmptMaps[pathKey] || session !== cmptSession) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
/** 非Scoped组件, 查找其所属的父容器 */
|
|
116
|
+
if ((cmpt === null || cmpt === void 0 ? void 0 : cmpt.setData) && typeof cmpt.setData === 'function') {
|
|
117
|
+
cmptMaps[pathKey] = cmpt;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
/** 查找Scoped组件中的引用 */
|
|
122
|
+
for (var _j = (e_2 = void 0, __values(Object.keys(schema))), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
123
|
+
var key = _k.value;
|
|
124
|
+
var expression = schema[key];
|
|
125
|
+
if (typeof expression === 'string' &&
|
|
126
|
+
isPureVariable(expression)) {
|
|
127
|
+
/** 考虑到数据映射函数的情况,将宿主变量提取出来 */
|
|
128
|
+
var host = expression
|
|
129
|
+
.substring(2, expression.length - 1)
|
|
130
|
+
.split('|')[0];
|
|
131
|
+
if (host && host === path) {
|
|
132
|
+
cmptMaps[pathKey] = cmpt;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
131
136
|
}
|
|
132
137
|
}
|
|
138
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
139
|
+
finally {
|
|
140
|
+
try {
|
|
141
|
+
if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
|
|
142
|
+
}
|
|
143
|
+
finally { if (e_2) throw e_2.error; }
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
148
|
+
finally {
|
|
149
|
+
try {
|
|
150
|
+
if (scopedCmptList_1_1 && !scopedCmptList_1_1.done && (_a = scopedCmptList_1.return)) _a.call(scopedCmptList_1);
|
|
133
151
|
}
|
|
152
|
+
finally { if (e_1) throw e_1.error; }
|
|
134
153
|
}
|
|
135
154
|
}
|
|
136
155
|
});
|
package/esm/WithRootStore.js
CHANGED
package/esm/WithStore.js
CHANGED
package/esm/actions/Action.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.
|
|
2
|
+
* amis-core v2.8.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __awaiter, __generator, __assign } from 'tslib';
|
|
6
|
+
import { __awaiter, __generator, __values, __assign } from 'tslib';
|
|
7
7
|
import omit from 'lodash/omit';
|
|
8
8
|
import '../utils/helper.js';
|
|
9
9
|
import { evalExpression } from '../utils/tpl.js';
|
|
@@ -94,18 +94,22 @@ var getOmitActionProp = function (type) {
|
|
|
94
94
|
return omitList;
|
|
95
95
|
};
|
|
96
96
|
var runActions = function (actions, renderer, event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
-
var
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
var actions_1, actions_1_1, actionConfig, actionInstrance, e_1_1;
|
|
98
|
+
var e_1, _a;
|
|
99
|
+
return __generator(this, function (_b) {
|
|
100
|
+
switch (_b.label) {
|
|
100
101
|
case 0:
|
|
101
102
|
if (!Array.isArray(actions)) {
|
|
102
103
|
actions = [actions];
|
|
103
104
|
}
|
|
104
|
-
|
|
105
|
-
_a.label = 1;
|
|
105
|
+
_b.label = 1;
|
|
106
106
|
case 1:
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
108
|
+
actions_1 = __values(actions), actions_1_1 = actions_1.next();
|
|
109
|
+
_b.label = 2;
|
|
110
|
+
case 2:
|
|
111
|
+
if (!!actions_1_1.done) return [3 /*break*/, 5];
|
|
112
|
+
actionConfig = actions_1_1.value;
|
|
109
113
|
actionInstrance = getActionByType(actionConfig.actionType);
|
|
110
114
|
// 如果存在指定组件ID,说明是组件专有动作
|
|
111
115
|
if (!actionInstrance && actionConfig.componentId) {
|
|
@@ -123,17 +127,28 @@ var runActions = function (actions, renderer, event) { return __awaiter(void 0,
|
|
|
123
127
|
}
|
|
124
128
|
// 这些节点的子节点运行逻辑由节点内部实现
|
|
125
129
|
return [4 /*yield*/, runAction(actionInstrance, actionConfig, renderer, event)];
|
|
126
|
-
case
|
|
130
|
+
case 3:
|
|
127
131
|
// 这些节点的子节点运行逻辑由节点内部实现
|
|
128
|
-
|
|
132
|
+
_b.sent();
|
|
129
133
|
if (event.stoped) {
|
|
130
|
-
return [3 /*break*/,
|
|
134
|
+
return [3 /*break*/, 5];
|
|
131
135
|
}
|
|
132
|
-
|
|
133
|
-
case
|
|
134
|
-
|
|
135
|
-
return [3 /*break*/,
|
|
136
|
-
case
|
|
136
|
+
_b.label = 4;
|
|
137
|
+
case 4:
|
|
138
|
+
actions_1_1 = actions_1.next();
|
|
139
|
+
return [3 /*break*/, 2];
|
|
140
|
+
case 5: return [3 /*break*/, 8];
|
|
141
|
+
case 6:
|
|
142
|
+
e_1_1 = _b.sent();
|
|
143
|
+
e_1 = { error: e_1_1 };
|
|
144
|
+
return [3 /*break*/, 8];
|
|
145
|
+
case 7:
|
|
146
|
+
try {
|
|
147
|
+
if (actions_1_1 && !actions_1_1.done && (_a = actions_1.return)) _a.call(actions_1);
|
|
148
|
+
}
|
|
149
|
+
finally { if (e_1) throw e_1.error; }
|
|
150
|
+
return [7 /*endfinally*/];
|
|
151
|
+
case 8: return [2 /*return*/];
|
|
137
152
|
}
|
|
138
153
|
});
|
|
139
154
|
}); };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.
|
|
2
|
+
* amis-core v2.8.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __awaiter, __generator } from 'tslib';
|
|
6
|
+
import { __awaiter, __generator, __values } from 'tslib';
|
|
7
7
|
import '../utils/helper.js';
|
|
8
8
|
import { registerAction, LoopStatus, runActions } from './Action.js';
|
|
9
9
|
import 'amis-formula';
|
|
@@ -26,9 +26,10 @@ var LoopAction = /** @class */ (function () {
|
|
|
26
26
|
LoopAction.prototype.run = function (action, renderer, event, mergeData) {
|
|
27
27
|
var _a, _b;
|
|
28
28
|
return __awaiter(this, void 0, void 0, function () {
|
|
29
|
-
var loopName, loopData, protoData,
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
var loopName, loopData, protoData, loopData_1, loopData_1_1, data, _c, _d, subAction, e_1_1, e_2_1;
|
|
30
|
+
var e_2, _e, e_1, _f;
|
|
31
|
+
return __generator(this, function (_g) {
|
|
32
|
+
switch (_g.label) {
|
|
32
33
|
case 0:
|
|
33
34
|
loopName = (_a = action.args) === null || _a === void 0 ? void 0 : _a.loopName;
|
|
34
35
|
if (typeof loopName !== 'string') {
|
|
@@ -38,60 +39,88 @@ var LoopAction = /** @class */ (function () {
|
|
|
38
39
|
loopData = resolveVariable(loopName, mergeData) || [];
|
|
39
40
|
if (!!loopData) return [3 /*break*/, 1];
|
|
40
41
|
console.error("\u6CA1\u6709\u627E\u5230\u6570\u636E ".concat(loopName));
|
|
41
|
-
return [3 /*break*/,
|
|
42
|
+
return [3 /*break*/, 18];
|
|
42
43
|
case 1:
|
|
43
44
|
if (!!Array.isArray(loopData)) return [3 /*break*/, 2];
|
|
44
45
|
console.error("".concat(loopName, " \u6570\u636E\u4E0D\u662F\u6570\u7EC4"));
|
|
45
|
-
return [3 /*break*/,
|
|
46
|
+
return [3 /*break*/, 18];
|
|
46
47
|
case 2:
|
|
47
|
-
if (!((_b = action.children) === null || _b === void 0 ? void 0 : _b.length)) return [3 /*break*/,
|
|
48
|
+
if (!((_b = action.children) === null || _b === void 0 ? void 0 : _b.length)) return [3 /*break*/, 18];
|
|
48
49
|
protoData = event.data;
|
|
49
|
-
|
|
50
|
-
_e.label = 3;
|
|
50
|
+
_g.label = 3;
|
|
51
51
|
case 3:
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
_g.trys.push([3, 15, 16, 17]);
|
|
53
|
+
loopData_1 = __values(loopData), loopData_1_1 = loopData_1.next();
|
|
54
|
+
_g.label = 4;
|
|
55
|
+
case 4:
|
|
56
|
+
if (!!loopData_1_1.done) return [3 /*break*/, 14];
|
|
57
|
+
data = loopData_1_1.value;
|
|
54
58
|
renderer.loopStatus = LoopStatus.NORMAL;
|
|
55
59
|
// 追加逻辑处理中的数据,事件数据优先,用完还要还原
|
|
56
60
|
event.setData(createObject(event.data, data));
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
_g.label = 5;
|
|
62
|
+
case 5:
|
|
63
|
+
_g.trys.push([5, 10, 11, 12]);
|
|
64
|
+
_c = (e_1 = void 0, __values(action.children)), _d = _c.next();
|
|
65
|
+
_g.label = 6;
|
|
66
|
+
case 6:
|
|
67
|
+
if (!!_d.done) return [3 /*break*/, 9];
|
|
68
|
+
subAction = _d.value;
|
|
62
69
|
// @ts-ignore
|
|
63
70
|
if (renderer.loopStatus === LoopStatus.CONTINUE) {
|
|
64
|
-
return [3 /*break*/,
|
|
71
|
+
return [3 /*break*/, 8];
|
|
65
72
|
}
|
|
66
73
|
return [4 /*yield*/, runActions(subAction, renderer, event)];
|
|
67
|
-
case
|
|
68
|
-
|
|
74
|
+
case 7:
|
|
75
|
+
_g.sent();
|
|
69
76
|
// @ts-ignore
|
|
70
77
|
if (renderer.loopStatus === LoopStatus.BREAK || event.stoped) {
|
|
71
78
|
// 还原事件数据
|
|
72
79
|
event.setData(protoData);
|
|
73
80
|
event.stopPropagation();
|
|
74
|
-
return [3 /*break*/,
|
|
81
|
+
return [3 /*break*/, 9];
|
|
75
82
|
}
|
|
76
|
-
|
|
77
|
-
case
|
|
78
|
-
_c
|
|
79
|
-
return [3 /*break*/,
|
|
80
|
-
case
|
|
83
|
+
_g.label = 8;
|
|
84
|
+
case 8:
|
|
85
|
+
_d = _c.next();
|
|
86
|
+
return [3 /*break*/, 6];
|
|
87
|
+
case 9: return [3 /*break*/, 12];
|
|
88
|
+
case 10:
|
|
89
|
+
e_1_1 = _g.sent();
|
|
90
|
+
e_1 = { error: e_1_1 };
|
|
91
|
+
return [3 /*break*/, 12];
|
|
92
|
+
case 11:
|
|
93
|
+
try {
|
|
94
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
95
|
+
}
|
|
96
|
+
finally { if (e_1) throw e_1.error; }
|
|
97
|
+
return [7 /*endfinally*/];
|
|
98
|
+
case 12:
|
|
81
99
|
if (event.stoped) {
|
|
82
100
|
// 还原事件数据
|
|
83
101
|
event.setData(protoData);
|
|
84
|
-
return [3 /*break*/,
|
|
102
|
+
return [3 /*break*/, 14];
|
|
85
103
|
}
|
|
86
|
-
|
|
87
|
-
case
|
|
88
|
-
|
|
89
|
-
return [3 /*break*/,
|
|
90
|
-
case
|
|
104
|
+
_g.label = 13;
|
|
105
|
+
case 13:
|
|
106
|
+
loopData_1_1 = loopData_1.next();
|
|
107
|
+
return [3 /*break*/, 4];
|
|
108
|
+
case 14: return [3 /*break*/, 17];
|
|
109
|
+
case 15:
|
|
110
|
+
e_2_1 = _g.sent();
|
|
111
|
+
e_2 = { error: e_2_1 };
|
|
112
|
+
return [3 /*break*/, 17];
|
|
113
|
+
case 16:
|
|
114
|
+
try {
|
|
115
|
+
if (loopData_1_1 && !loopData_1_1.done && (_e = loopData_1.return)) _e.call(loopData_1);
|
|
116
|
+
}
|
|
117
|
+
finally { if (e_2) throw e_2.error; }
|
|
118
|
+
return [7 /*endfinally*/];
|
|
119
|
+
case 17:
|
|
91
120
|
renderer.loopStatus = LoopStatus.NORMAL;
|
|
92
121
|
event.setData(protoData);
|
|
93
|
-
|
|
94
|
-
case
|
|
122
|
+
_g.label = 18;
|
|
123
|
+
case 18: return [2 /*return*/];
|
|
95
124
|
}
|
|
96
125
|
});
|
|
97
126
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.
|
|
2
|
+
* amis-core v2.8.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __awaiter, __generator } from 'tslib';
|
|
6
|
+
import { __awaiter, __generator, __values } from 'tslib';
|
|
7
7
|
import { evalExpression } from '../utils/tpl.js';
|
|
8
8
|
import { registerAction, runActions } from './Action.js';
|
|
9
9
|
|
|
@@ -15,28 +15,41 @@ var SwitchAction = /** @class */ (function () {
|
|
|
15
15
|
}
|
|
16
16
|
SwitchAction.prototype.run = function (action, renderer, event, mergeData) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function () {
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
var _a, _b, branch, e_1_1;
|
|
19
|
+
var e_1, _c;
|
|
20
|
+
return __generator(this, function (_d) {
|
|
21
|
+
switch (_d.label) {
|
|
21
22
|
case 0:
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
_d.trys.push([0, 5, 6, 7]);
|
|
24
|
+
_a = __values(action.children || []), _b = _a.next();
|
|
25
|
+
_d.label = 1;
|
|
24
26
|
case 1:
|
|
25
|
-
if (
|
|
26
|
-
branch =
|
|
27
|
+
if (!!_b.done) return [3 /*break*/, 4];
|
|
28
|
+
branch = _b.value;
|
|
27
29
|
if (!branch.expression) {
|
|
28
30
|
return [3 /*break*/, 3];
|
|
29
31
|
}
|
|
30
32
|
if (!evalExpression(branch.expression, mergeData)) return [3 /*break*/, 3];
|
|
31
33
|
return [4 /*yield*/, runActions(branch, renderer, event)];
|
|
32
34
|
case 2:
|
|
33
|
-
|
|
35
|
+
_d.sent();
|
|
34
36
|
// 去掉runAllMatch,这里只做排他,多个可以直接通过expression
|
|
35
37
|
return [3 /*break*/, 4];
|
|
36
38
|
case 3:
|
|
37
|
-
|
|
39
|
+
_b = _a.next();
|
|
38
40
|
return [3 /*break*/, 1];
|
|
39
|
-
case 4: return [
|
|
41
|
+
case 4: return [3 /*break*/, 7];
|
|
42
|
+
case 5:
|
|
43
|
+
e_1_1 = _d.sent();
|
|
44
|
+
e_1 = { error: e_1_1 };
|
|
45
|
+
return [3 /*break*/, 7];
|
|
46
|
+
case 6:
|
|
47
|
+
try {
|
|
48
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
49
|
+
}
|
|
50
|
+
finally { if (e_1) throw e_1.error; }
|
|
51
|
+
return [7 /*endfinally*/];
|
|
52
|
+
case 7: return [2 /*return*/];
|
|
40
53
|
}
|
|
41
54
|
});
|
|
42
55
|
});
|