amis-core 2.6.0 → 2.6.1-alpha.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 +3 -3
- package/esm/RootRenderer.js +2 -2
- package/esm/SchemaRenderer.js +2 -2
- package/esm/Scoped.d.ts +1 -0
- package/esm/Scoped.js +60 -3
- package/esm/WithRootStore.js +2 -2
- package/esm/WithStore.js +2 -2
- package/esm/actions/Action.js +2 -2
- package/esm/actions/AjaxAction.js +2 -2
- package/esm/actions/BreakAction.js +2 -2
- package/esm/actions/BroadcastAction.js +2 -2
- package/esm/actions/CmptAction.d.ts +2 -0
- package/esm/actions/CmptAction.js +55 -39
- package/esm/actions/ContinueAction.js +2 -2
- package/esm/actions/CopyAction.js +2 -2
- package/esm/actions/CustomAction.js +2 -2
- package/esm/actions/DialogAction.js +2 -2
- package/esm/actions/DrawerAction.js +2 -2
- package/esm/actions/EmailAction.js +2 -2
- package/esm/actions/LinkAction.js +2 -2
- package/esm/actions/LoopAction.js +2 -2
- package/esm/actions/PageAction.js +2 -2
- package/esm/actions/ParallelAction.js +2 -2
- package/esm/actions/SwitchAction.js +2 -2
- package/esm/actions/ToastAction.js +2 -2
- package/esm/components/LazyComponent.js +2 -2
- package/esm/components/Overlay.js +2 -2
- package/esm/components/PopOver.js +2 -2
- package/esm/env.d.ts +8 -3
- package/esm/env.js +2 -2
- package/esm/envOverwrite.js +2 -2
- package/esm/factory.js +2 -2
- package/esm/index.d.ts +1 -1
- package/esm/index.js +10 -3
- package/esm/locale.js +2 -2
- package/esm/renderers/Form.js +2 -2
- package/esm/renderers/Item.js +2 -2
- package/esm/renderers/Options.js +2 -2
- package/esm/renderers/Placeholder.js +2 -2
- package/esm/renderers/builtin.js +2 -2
- package/esm/renderers/register.js +2 -2
- package/esm/renderers/wrapControl.js +2 -2
- package/esm/store/app.js +2 -2
- package/esm/store/combo.js +2 -2
- package/esm/store/crud.js +2 -2
- package/esm/store/form.js +2 -2
- package/esm/store/formItem.js +2 -2
- package/esm/store/iRenderer.js +2 -2
- package/esm/store/index.js +2 -2
- package/esm/store/list.js +2 -2
- package/esm/store/manager.js +2 -2
- package/esm/store/modal.js +2 -2
- package/esm/store/node.js +2 -2
- package/esm/store/pagination.js +2 -2
- package/esm/store/root.js +2 -2
- package/esm/store/service.js +2 -2
- package/esm/store/table.js +2 -2
- package/esm/store/table2.js +2 -2
- package/esm/theme.js +2 -2
- package/esm/types.d.ts +1 -0
- package/esm/utils/Animation.js +2 -2
- package/esm/utils/ColorScale.js +2 -2
- package/esm/utils/DataSchema.js +2 -2
- package/esm/utils/DataScope.js +2 -2
- package/esm/utils/RootClose.js +2 -2
- package/esm/utils/SimpleMap.js +2 -2
- package/esm/utils/api.js +7 -3
- package/esm/utils/attachmentAdpator.js +2 -2
- package/esm/utils/autobind.js +2 -2
- package/esm/utils/columnsSplit.js +2 -2
- package/esm/utils/dataMapping.js +2 -2
- package/esm/utils/date.js +2 -2
- package/esm/utils/debug.js +2 -2
- package/esm/utils/decodeEntity.js +2 -2
- package/esm/utils/dom.js +2 -2
- package/esm/utils/errors.js +2 -2
- package/esm/utils/escapeHtml.js +2 -2
- package/esm/utils/filter-schema.js +2 -2
- package/esm/utils/filter.js +2 -2
- package/esm/utils/formatDuration.js +2 -2
- package/esm/utils/formula.js +2 -2
- package/esm/utils/getVariable.js +2 -2
- package/esm/utils/grammar.js +2 -2
- package/esm/utils/handleAction.js +2 -2
- package/esm/utils/helper.js +2 -2
- package/esm/utils/highlight.js +2 -2
- package/esm/utils/icon.js +2 -2
- package/esm/utils/image.js +2 -2
- package/esm/utils/isPureVariable.js +2 -2
- package/esm/utils/json-schema-2-amis-schema.js +2 -2
- package/esm/utils/keyToPath.js +2 -2
- package/esm/utils/makeSorter.js +2 -2
- package/esm/utils/normalizeLink.js +2 -2
- package/esm/utils/normalizeOptions.js +2 -2
- package/esm/utils/object.js +2 -2
- package/esm/utils/offset.js +2 -2
- package/esm/utils/offsetParent.js +2 -2
- package/esm/utils/optionValueCompare.js +2 -2
- package/esm/utils/position.js +2 -2
- package/esm/utils/prettyBytes.js +2 -2
- package/esm/utils/renderer-event.js +2 -2
- package/esm/utils/replaceText.js +2 -2
- package/esm/utils/resize-sensor.js +2 -2
- package/esm/utils/resolveVariable.js +2 -2
- package/esm/utils/resolveVariableAndFilter.js +2 -2
- package/esm/utils/scrollPosition.js +2 -2
- package/esm/utils/string2regExp.js +2 -2
- package/esm/utils/stripNumber.js +2 -2
- package/esm/utils/style.js +2 -2
- package/esm/utils/toNumber.js +2 -2
- package/esm/utils/tokenize.js +2 -2
- package/esm/utils/tpl-builtin.js +2 -2
- package/esm/utils/tpl-lodash.js +2 -2
- package/esm/utils/tpl.js +2 -2
- package/esm/utils/uncontrollable.js +2 -2
- package/esm/utils/validations.js +2 -2
- package/lib/Root.js +4 -4
- package/lib/RootRenderer.js +2 -2
- package/lib/SchemaRenderer.js +2 -2
- package/lib/Scoped.d.ts +1 -0
- package/lib/Scoped.js +60 -2
- package/lib/WithRootStore.js +2 -2
- package/lib/WithStore.js +2 -2
- package/lib/actions/Action.js +2 -2
- package/lib/actions/AjaxAction.js +2 -2
- package/lib/actions/BreakAction.js +2 -2
- package/lib/actions/BroadcastAction.js +2 -2
- package/lib/actions/CmptAction.d.ts +2 -0
- package/lib/actions/CmptAction.js +55 -39
- package/lib/actions/ContinueAction.js +2 -2
- package/lib/actions/CopyAction.js +2 -2
- package/lib/actions/CustomAction.js +2 -2
- package/lib/actions/DialogAction.js +2 -2
- package/lib/actions/DrawerAction.js +2 -2
- package/lib/actions/EmailAction.js +2 -2
- package/lib/actions/LinkAction.js +2 -2
- package/lib/actions/LoopAction.js +2 -2
- package/lib/actions/PageAction.js +2 -2
- package/lib/actions/ParallelAction.js +2 -2
- package/lib/actions/SwitchAction.js +2 -2
- package/lib/actions/ToastAction.js +2 -2
- package/lib/components/LazyComponent.js +2 -2
- package/lib/components/Overlay.js +2 -2
- package/lib/components/PopOver.js +2 -2
- package/lib/env.d.ts +8 -3
- package/lib/env.js +2 -2
- package/lib/envOverwrite.js +2 -2
- package/lib/factory.js +2 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +10 -3
- package/lib/locale.js +2 -2
- package/lib/renderers/Form.js +2 -2
- package/lib/renderers/Item.js +2 -2
- package/lib/renderers/Options.js +2 -2
- package/lib/renderers/Placeholder.js +2 -2
- package/lib/renderers/builtin.js +2 -2
- package/lib/renderers/register.js +2 -2
- package/lib/renderers/wrapControl.js +2 -2
- package/lib/store/app.js +2 -2
- package/lib/store/combo.js +2 -2
- package/lib/store/crud.js +2 -2
- package/lib/store/form.js +2 -2
- package/lib/store/formItem.js +2 -2
- package/lib/store/iRenderer.js +2 -2
- package/lib/store/index.js +2 -2
- package/lib/store/list.js +2 -2
- package/lib/store/manager.js +2 -2
- package/lib/store/modal.js +2 -2
- package/lib/store/node.js +2 -2
- package/lib/store/pagination.js +2 -2
- package/lib/store/root.js +2 -2
- package/lib/store/service.js +2 -2
- package/lib/store/table.js +2 -2
- package/lib/store/table2.js +2 -2
- package/lib/theme.js +2 -2
- package/lib/types.d.ts +1 -0
- package/lib/utils/Animation.js +2 -2
- package/lib/utils/ColorScale.js +2 -2
- package/lib/utils/DataSchema.js +2 -2
- package/lib/utils/DataScope.js +2 -2
- package/lib/utils/RootClose.js +2 -2
- package/lib/utils/SimpleMap.js +2 -2
- package/lib/utils/api.js +7 -3
- package/lib/utils/attachmentAdpator.js +2 -2
- package/lib/utils/autobind.js +2 -2
- package/lib/utils/columnsSplit.js +2 -2
- package/lib/utils/dataMapping.js +2 -2
- package/lib/utils/date.js +2 -2
- package/lib/utils/debug.js +2 -2
- package/lib/utils/decodeEntity.js +2 -2
- package/lib/utils/dom.js +2 -2
- package/lib/utils/errors.js +2 -2
- package/lib/utils/escapeHtml.js +2 -2
- package/lib/utils/filter-schema.js +2 -2
- package/lib/utils/filter.js +2 -2
- package/lib/utils/formatDuration.js +2 -2
- package/lib/utils/formula.js +2 -2
- package/lib/utils/getVariable.js +2 -2
- package/lib/utils/grammar.js +2 -2
- package/lib/utils/handleAction.js +2 -2
- package/lib/utils/helper.js +2 -2
- package/lib/utils/highlight.js +2 -2
- package/lib/utils/icon.js +2 -2
- package/lib/utils/image.js +2 -2
- package/lib/utils/isPureVariable.js +2 -2
- package/lib/utils/json-schema-2-amis-schema.js +2 -2
- package/lib/utils/keyToPath.js +2 -2
- package/lib/utils/makeSorter.js +2 -2
- package/lib/utils/normalizeLink.js +2 -2
- package/lib/utils/normalizeOptions.js +2 -2
- package/lib/utils/object.js +2 -2
- package/lib/utils/offset.js +2 -2
- package/lib/utils/offsetParent.js +2 -2
- package/lib/utils/optionValueCompare.js +2 -2
- package/lib/utils/position.js +2 -2
- package/lib/utils/prettyBytes.js +2 -2
- package/lib/utils/renderer-event.js +2 -2
- package/lib/utils/replaceText.js +2 -2
- package/lib/utils/resize-sensor.js +2 -2
- package/lib/utils/resolveVariable.js +2 -2
- package/lib/utils/resolveVariableAndFilter.js +2 -2
- package/lib/utils/scrollPosition.js +2 -2
- package/lib/utils/string2regExp.js +2 -2
- package/lib/utils/stripNumber.js +2 -2
- package/lib/utils/style.js +2 -2
- package/lib/utils/toNumber.js +2 -2
- package/lib/utils/tokenize.js +2 -2
- package/lib/utils/tpl-builtin.js +2 -2
- package/lib/utils/tpl-lodash.js +2 -2
- package/lib/utils/tpl.js +2 -2
- package/lib/utils/uncontrollable.js +2 -2
- package/lib/utils/validations.js +2 -2
- package/package.json +3 -3
package/esm/Root.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.6.0
|
|
3
|
-
* Copyright 2018-
|
|
2
|
+
* amis-core v2.6.1-alpha.0
|
|
3
|
+
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { __extends, __rest, __assign, __decorate, __metadata } from 'tslib';
|
|
7
|
-
import isPlainObject from 'lodash/isPlainObject';
|
|
8
7
|
import React from 'react';
|
|
8
|
+
import isPlainObject from 'lodash/isPlainObject';
|
|
9
9
|
import { LocaleContext } from './locale.js';
|
|
10
10
|
import { RootRenderer } from './RootRenderer.js';
|
|
11
11
|
import { SchemaRenderer } from './SchemaRenderer.js';
|
package/esm/RootRenderer.js
CHANGED
package/esm/SchemaRenderer.js
CHANGED
package/esm/Scoped.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface ScopedComponentType extends React.Component<RendererProps> {
|
|
|
11
11
|
receive?: (values: RendererData, subPath?: string, replace?: boolean) => void;
|
|
12
12
|
reload?: (subPath?: string, query?: RendererData | null, ctx?: RendererData) => void;
|
|
13
13
|
context: any;
|
|
14
|
+
setData?: (value?: any, replace?: boolean, index?: number) => void;
|
|
14
15
|
}
|
|
15
16
|
export interface IScopedContext {
|
|
16
17
|
parent?: AliasIScopedContext;
|
package/esm/Scoped.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.6.0
|
|
3
|
-
* Copyright 2018-
|
|
2
|
+
* amis-core v2.6.1-alpha.0
|
|
3
|
+
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { __assign, __extends, __rest, __decorate, __metadata } from 'tslib';
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import find from 'lodash/find';
|
|
9
|
+
import values from 'lodash/values';
|
|
9
10
|
import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
10
11
|
import { registerFunction } from 'amis-formula';
|
|
11
12
|
import 'moment';
|
|
12
13
|
import 'lodash/isPlainObject';
|
|
13
14
|
import { getVariable } from './utils/getVariable.js';
|
|
15
|
+
import { isPureVariable } from './utils/isPureVariable.js';
|
|
14
16
|
import { dataMapping } from './utils/dataMapping.js';
|
|
15
17
|
import './utils/filter.js';
|
|
16
|
-
import { findTree, qsparse, qsstringify, parseQuery, autobind } from './utils/helper.js';
|
|
18
|
+
import { findTree, eachTree, qsparse, qsstringify, parseQuery, autobind } from './utils/helper.js';
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* @file 用来创建一个域,在这个域里面会把里面的运行时实例注册进来,方便组件之间的通信。
|
|
@@ -79,6 +81,61 @@ function createScopedTools(path, parent, env) {
|
|
|
79
81
|
});
|
|
80
82
|
return component;
|
|
81
83
|
},
|
|
84
|
+
/**
|
|
85
|
+
* 基于绑定的变量名称查找组件
|
|
86
|
+
* 支持形如${xxx}的格式
|
|
87
|
+
*
|
|
88
|
+
* @param session store的session, 默认为全局的
|
|
89
|
+
* @param path 变量路径, 包含命名空间
|
|
90
|
+
*/
|
|
91
|
+
getComponentsByRefPath: function (session, path) {
|
|
92
|
+
if (!path || typeof path !== 'string') {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
var cmptMaps = {};
|
|
96
|
+
var root = this;
|
|
97
|
+
while (root.parent) {
|
|
98
|
+
root = root.parent;
|
|
99
|
+
}
|
|
100
|
+
eachTree([root], function (item) {
|
|
101
|
+
var _a, _b, _c, _d, _e, _f;
|
|
102
|
+
var scopedCmptList = item.getComponents() || [];
|
|
103
|
+
if (Array.isArray(scopedCmptList)) {
|
|
104
|
+
for (var _i = 0, scopedCmptList_1 = scopedCmptList; _i < scopedCmptList_1.length; _i++) {
|
|
105
|
+
var cmpt = scopedCmptList_1[_i];
|
|
106
|
+
var pathKey = (_b = (_a = cmpt === null || cmpt === void 0 ? void 0 : cmpt.props) === null || _a === void 0 ? void 0 : _a.$path) !== null && _b !== void 0 ? _b : 'unknown';
|
|
107
|
+
var schema = (_d = (_c = cmpt === null || cmpt === void 0 ? void 0 : cmpt.props) === null || _c === void 0 ? void 0 : _c.$schema) !== null && _d !== void 0 ? _d : {};
|
|
108
|
+
var cmptSession = (_f = (_e = cmpt === null || cmpt === void 0 ? void 0 : cmpt.props.env) === null || _e === void 0 ? void 0 : _e.session) !== null && _f !== void 0 ? _f : 'global';
|
|
109
|
+
/** 仅查找当前session的组件 */
|
|
110
|
+
if (cmptMaps[pathKey] || session !== cmptSession) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
/** 非Scoped组件, 查找其所属的父容器 */
|
|
114
|
+
if ((cmpt === null || cmpt === void 0 ? void 0 : cmpt.setData) && typeof cmpt.setData === 'function') {
|
|
115
|
+
cmptMaps[pathKey] = cmpt;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
/** 查找Scoped组件中的引用 */
|
|
119
|
+
for (var _g = 0, _h = Object.keys(schema); _g < _h.length; _g++) {
|
|
120
|
+
var key = _h[_g];
|
|
121
|
+
var expression = schema[key];
|
|
122
|
+
if (typeof expression === 'string' &&
|
|
123
|
+
isPureVariable(expression)) {
|
|
124
|
+
/** 考虑到数据映射函数的情况,将宿主变量提取出来 */
|
|
125
|
+
var host = expression
|
|
126
|
+
.substring(2, expression.length - 1)
|
|
127
|
+
.split('|')[0];
|
|
128
|
+
if (host && host === path) {
|
|
129
|
+
cmptMaps[pathKey] = cmpt;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return values(cmptMaps);
|
|
138
|
+
},
|
|
82
139
|
getComponents: function () {
|
|
83
140
|
return components.concat();
|
|
84
141
|
},
|
package/esm/WithRootStore.js
CHANGED
package/esm/WithStore.js
CHANGED
package/esm/actions/Action.js
CHANGED
|
@@ -3,6 +3,8 @@ import { RendererAction, ListenerAction, ListenerContext } from './Action';
|
|
|
3
3
|
export interface ICmptAction extends ListenerAction {
|
|
4
4
|
actionType: 'setValue' | 'static' | 'nonstatic' | 'show' | 'visibility' | 'hidden' | 'enabled' | 'disabled' | 'usability' | 'reload';
|
|
5
5
|
args: {
|
|
6
|
+
/** actionType为setValue时,目标变量的path */
|
|
7
|
+
path?: string;
|
|
6
8
|
value?: string | {
|
|
7
9
|
[key: string]: string;
|
|
8
10
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.6.0
|
|
3
|
-
* Copyright 2018-
|
|
2
|
+
* amis-core v2.6.1-alpha.0
|
|
3
|
+
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { __awaiter, __generator } from 'tslib';
|
|
@@ -17,45 +17,61 @@ var CmptAction = /** @class */ (function () {
|
|
|
17
17
|
function CmptAction() {
|
|
18
18
|
}
|
|
19
19
|
CmptAction.prototype.run = function (action, renderer, event) {
|
|
20
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
21
21
|
return __awaiter(this, void 0, void 0, function () {
|
|
22
|
-
var component, dataMergeMode, visibility, usability;
|
|
23
|
-
return __generator(this, function (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
var component, dataMergeMode, visibility, usability, beforeSetData, path, res;
|
|
23
|
+
return __generator(this, function (_p) {
|
|
24
|
+
switch (_p.label) {
|
|
25
|
+
case 0:
|
|
26
|
+
component = action.componentId && renderer.props.$schema.id !== action.componentId
|
|
27
|
+
? (_a = event.context.scoped) === null || _a === void 0 ? void 0 : _a.getComponentById(action.componentId)
|
|
28
|
+
: renderer;
|
|
29
|
+
dataMergeMode = action.dataMergeMode || 'merge';
|
|
30
|
+
// 显隐&状态控制
|
|
31
|
+
if (['show', 'hidden', 'visibility'].includes(action.actionType)) {
|
|
32
|
+
visibility = action.actionType === 'visibility'
|
|
33
|
+
? (_b = action.args) === null || _b === void 0 ? void 0 : _b.value
|
|
34
|
+
: action.actionType === 'show';
|
|
35
|
+
return [2 /*return*/, renderer.props.topStore.setVisible(action.componentId, visibility)];
|
|
36
|
+
}
|
|
37
|
+
else if (['static', 'nonstatic'].includes(action.actionType)) {
|
|
38
|
+
return [2 /*return*/, renderer.props.topStore.setStatic(action.componentId, action.actionType === 'static')];
|
|
39
|
+
}
|
|
40
|
+
else if (['enabled', 'disabled', 'usability'].includes(action.actionType)) {
|
|
41
|
+
usability = action.actionType === 'usability'
|
|
42
|
+
? !((_c = action.args) === null || _c === void 0 ? void 0 : _c.value)
|
|
43
|
+
: action.actionType === 'disabled';
|
|
44
|
+
return [2 /*return*/, renderer.props.topStore.setDisable(action.componentId, usability)];
|
|
45
|
+
}
|
|
46
|
+
if (!(action.actionType === 'setValue')) return [3 /*break*/, 3];
|
|
47
|
+
beforeSetData = (_e = (_d = renderer === null || renderer === void 0 ? void 0 : renderer.props) === null || _d === void 0 ? void 0 : _d.env) === null || _e === void 0 ? void 0 : _e.beforeSetData;
|
|
48
|
+
path = (_f = action.args) === null || _f === void 0 ? void 0 : _f.path;
|
|
49
|
+
if (!(path &&
|
|
50
|
+
typeof path === 'string' &&
|
|
51
|
+
beforeSetData &&
|
|
52
|
+
typeof beforeSetData === 'function')) return [3 /*break*/, 2];
|
|
53
|
+
return [4 /*yield*/, beforeSetData(renderer, action, event)];
|
|
54
|
+
case 1:
|
|
55
|
+
res = _p.sent();
|
|
56
|
+
if (res === false) {
|
|
57
|
+
return [2 /*return*/];
|
|
58
|
+
}
|
|
59
|
+
_p.label = 2;
|
|
60
|
+
case 2:
|
|
61
|
+
if (component === null || component === void 0 ? void 0 : component.setData) {
|
|
62
|
+
return [2 /*return*/, component === null || component === void 0 ? void 0 : component.setData((_g = action.args) === null || _g === void 0 ? void 0 : _g.value, dataMergeMode === 'override', (_h = action.args) === null || _h === void 0 ? void 0 : _h.index)];
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return [2 /*return*/, (_k = component === null || component === void 0 ? void 0 : (_j = component.props).onChange) === null || _k === void 0 ? void 0 : _k.call(_j, (_l = action.args) === null || _l === void 0 ? void 0 : _l.value)];
|
|
66
|
+
}
|
|
67
|
+
case 3:
|
|
68
|
+
// 刷新
|
|
69
|
+
if (action.actionType === 'reload') {
|
|
70
|
+
return [2 /*return*/, (_m = component === null || component === void 0 ? void 0 : component.reload) === null || _m === void 0 ? void 0 : _m.call(component, undefined, action.data, undefined, undefined, dataMergeMode === 'override', action.args)];
|
|
71
|
+
}
|
|
72
|
+
// 执行组件动作
|
|
73
|
+
return [2 /*return*/, (_o = component === null || component === void 0 ? void 0 : component.doAction) === null || _o === void 0 ? void 0 : _o.call(component, action, action.args)];
|
|
34
74
|
}
|
|
35
|
-
else if (['static', 'nonstatic'].includes(action.actionType)) {
|
|
36
|
-
return [2 /*return*/, renderer.props.topStore.setStatic(action.componentId, action.actionType === 'static')];
|
|
37
|
-
}
|
|
38
|
-
else if (['enabled', 'disabled', 'usability'].includes(action.actionType)) {
|
|
39
|
-
usability = action.actionType === 'usability'
|
|
40
|
-
? !((_c = action.args) === null || _c === void 0 ? void 0 : _c.value)
|
|
41
|
-
: action.actionType === 'disabled';
|
|
42
|
-
return [2 /*return*/, renderer.props.topStore.setDisable(action.componentId, usability)];
|
|
43
|
-
}
|
|
44
|
-
// 数据更新
|
|
45
|
-
if (action.actionType === 'setValue') {
|
|
46
|
-
if (component === null || component === void 0 ? void 0 : component.setData) {
|
|
47
|
-
return [2 /*return*/, component === null || component === void 0 ? void 0 : component.setData((_d = action.args) === null || _d === void 0 ? void 0 : _d.value, dataMergeMode === 'override', (_e = action.args) === null || _e === void 0 ? void 0 : _e.index)];
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
return [2 /*return*/, (_g = component === null || component === void 0 ? void 0 : (_f = component.props).onChange) === null || _g === void 0 ? void 0 : _g.call(_f, (_h = action.args) === null || _h === void 0 ? void 0 : _h.value)];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// 刷新
|
|
54
|
-
if (action.actionType === 'reload') {
|
|
55
|
-
return [2 /*return*/, (_j = component === null || component === void 0 ? void 0 : component.reload) === null || _j === void 0 ? void 0 : _j.call(component, undefined, action.data, undefined, undefined, dataMergeMode === 'override', action.args)];
|
|
56
|
-
}
|
|
57
|
-
// 执行组件动作
|
|
58
|
-
return [2 /*return*/, (_k = component === null || component === void 0 ? void 0 : component.doAction) === null || _k === void 0 ? void 0 : _k.call(component, action, action.args)];
|
|
59
75
|
});
|
|
60
76
|
});
|
|
61
77
|
};
|
package/esm/env.d.ts
CHANGED
|
@@ -6,14 +6,17 @@ import { RendererConfig } from './factory';
|
|
|
6
6
|
import { ThemeInstance } from './theme';
|
|
7
7
|
import { ActionObject, Api, EventTrack, Payload, PlainObject, Schema, ToastConf, ToastLevel } from './types';
|
|
8
8
|
import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
9
|
-
import { IScopedContext } from './Scoped';
|
|
10
|
-
import { RendererEvent } from './utils/renderer-event';
|
|
9
|
+
import type { IScopedContext } from './Scoped';
|
|
10
|
+
import type { RendererEvent } from './utils/renderer-event';
|
|
11
|
+
import type { ListenerContext } from './actions/Action';
|
|
12
|
+
import type { ICmptAction } from './actions/CmptAction';
|
|
11
13
|
export interface wsObject {
|
|
12
14
|
url: string;
|
|
13
15
|
responseKey?: string;
|
|
14
16
|
body?: any;
|
|
15
17
|
}
|
|
16
18
|
export interface RendererEnv {
|
|
19
|
+
session?: string;
|
|
17
20
|
fetcher: (api: Api, data?: any, options?: object) => Promise<Payload>;
|
|
18
21
|
isCancel: (val: any) => boolean;
|
|
19
22
|
wsFetcher: (ws: wsObject, onMessage: (data: any) => void, onError: (error: any) => void) => void;
|
|
@@ -63,13 +66,15 @@ export interface RendererEnv {
|
|
|
63
66
|
[propName: string]: any;
|
|
64
67
|
};
|
|
65
68
|
/**
|
|
66
|
-
* 文本替换的黑名单,因为属性太多了所以改成黑名单的
|
|
69
|
+
* 文本替换的黑名单,因为属性太多了所以改成黑名单的 flags
|
|
67
70
|
*/
|
|
68
71
|
replaceTextIgnoreKeys?: String[];
|
|
69
72
|
/**
|
|
70
73
|
* 解析url参数
|
|
71
74
|
*/
|
|
72
75
|
parseLocation?: (location: any) => Object;
|
|
76
|
+
/** 数据更新前触发的Hook */
|
|
77
|
+
beforeSetData?: (renderer: ListenerContext, action: ICmptAction, event: RendererEvent<any, any>) => Promise<void | boolean>;
|
|
73
78
|
}
|
|
74
79
|
export declare const EnvContext: React.Context<void | RendererEnv>;
|
|
75
80
|
export interface EnvProps {
|
package/esm/env.js
CHANGED
package/esm/envOverwrite.js
CHANGED
package/esm/factory.js
CHANGED
package/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
/** @license amis v@version
|
|
3
2
|
*
|
|
4
3
|
* Copyright Baidu
|
|
@@ -6,6 +5,7 @@
|
|
|
6
5
|
* This source code is licensed under the Apache license found in the
|
|
7
6
|
* LICENSE file in the root directory of this source tree.
|
|
8
7
|
*/
|
|
8
|
+
/// <reference types="react" />
|
|
9
9
|
import { Renderer, getRendererByName, getRenderers, registerRenderer, unRegisterRenderer, resolveRenderer, filterSchema, clearStoresCache, updateEnv, addSchemaFilter, extendDefaultEnv } from './factory';
|
|
10
10
|
import type { RenderOptions, RendererConfig, RendererProps } from './factory';
|
|
11
11
|
import './renderers/builtin';
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v2.6.0
|
|
3
|
-
* Copyright 2018-
|
|
2
|
+
* amis-core v2.6.1-alpha.0
|
|
3
|
+
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { __assign } from 'tslib';
|
|
@@ -121,9 +121,16 @@ export { PaginationStore } from './store/pagination.js';
|
|
|
121
121
|
export { AppStore } from './store/app.js';
|
|
122
122
|
export { StoreNode } from './store/node.js';
|
|
123
123
|
|
|
124
|
+
/** @license amis v@version
|
|
125
|
+
*
|
|
126
|
+
* Copyright Baidu
|
|
127
|
+
*
|
|
128
|
+
* This source code is licensed under the Apache license found in the
|
|
129
|
+
* LICENSE file in the root directory of this source tree.
|
|
130
|
+
*/
|
|
124
131
|
var classPrefix = getClassPrefix();
|
|
125
132
|
// @ts-ignore
|
|
126
|
-
var version = '2.6.0';
|
|
133
|
+
var version = '2.6.1-alpha.0';
|
|
127
134
|
function render(schema, props, options, pathPrefix) {
|
|
128
135
|
if (props === void 0) { props = {}; }
|
|
129
136
|
if (options === void 0) { options = {}; }
|
package/esm/locale.js
CHANGED
package/esm/renderers/Form.js
CHANGED
package/esm/renderers/Item.js
CHANGED
package/esm/renderers/Options.js
CHANGED
package/esm/renderers/builtin.js
CHANGED