amis-core 3.0.0 → 3.1.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.d.ts +89 -4
- package/esm/Root.js +15 -4
- package/esm/RootRenderer.d.ts +3 -1
- package/esm/RootRenderer.js +9 -3
- package/esm/SchemaRenderer.d.ts +3 -2
- package/esm/SchemaRenderer.js +26 -20
- package/esm/Scoped.d.ts +8 -0
- package/esm/Scoped.js +20 -5
- package/esm/StatusScoped.d.ts +58 -0
- package/esm/StatusScoped.js +54 -0
- package/esm/WithRootStore.d.ts +2 -2
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +6 -2
- package/esm/actions/Action.d.ts +1 -0
- package/esm/actions/Action.js +12 -4
- 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 +8 -7
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +4 -4
- package/esm/actions/DialogAction.d.ts +16 -2
- package/esm/actions/DialogAction.js +19 -7
- 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 +1 -1
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/components/CustomStyle.d.ts +13 -0
- package/esm/components/CustomStyle.js +18 -0
- package/esm/components/LazyComponent.d.ts +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.d.ts +1 -1
- package/esm/components/Overlay.js +1 -1
- package/esm/components/PopOver.d.ts +2 -2
- package/esm/components/PopOver.js +1 -1
- package/esm/env.d.ts +10 -2
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -5
- package/esm/factory.d.ts +3 -2
- package/esm/factory.js +1 -1
- package/esm/index.d.ts +4 -2
- package/esm/index.js +49 -28
- package/esm/locale.d.ts +2 -2
- package/esm/locale.js +10 -3
- package/esm/renderers/Form.d.ts +2 -1
- package/esm/renderers/Form.js +216 -180
- package/esm/renderers/Item.d.ts +55 -41
- package/esm/renderers/Item.js +24 -16
- package/esm/renderers/Options.js +9 -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 +2 -2
- package/esm/renderers/wrapControl.js +13 -16
- package/esm/store/app.d.ts +1 -0
- package/esm/store/app.js +1 -1
- package/esm/store/combo.d.ts +3 -0
- package/esm/store/combo.js +1 -1
- package/esm/store/crud.d.ts +2 -0
- package/esm/store/crud.js +12 -4
- package/esm/store/form.d.ts +1 -0
- package/esm/store/form.js +10 -4
- package/esm/store/formItem.js +1 -1
- package/esm/store/iRenderer.d.ts +1 -0
- package/esm/store/iRenderer.js +54 -13
- package/esm/store/index.js +1 -1
- package/esm/store/list.d.ts +1 -0
- package/esm/store/list.js +7 -3
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.d.ts +1 -0
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.d.ts +1 -0
- package/esm/store/pagination.js +1 -1
- package/esm/store/root.d.ts +4 -6
- package/esm/store/root.js +53 -24
- package/esm/store/service.d.ts +1 -0
- package/esm/store/service.js +1 -1
- package/esm/store/status.d.ts +12 -0
- package/esm/store/status.js +38 -0
- package/esm/store/table.d.ts +4 -0
- package/esm/store/table.js +10 -2
- package/esm/store/table2.d.ts +2 -1
- package/esm/store/table2.js +6 -6
- package/esm/theme.d.ts +1 -1
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +1 -1
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.js +1 -1
- package/esm/utils/DataScope.d.ts +3 -5
- package/esm/utils/DataScope.js +88 -31
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.js +6 -4
- package/esm/utils/attachmentAdpator.js +2 -2
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/dataMapping.js +1 -1
- package/esm/utils/date.d.ts +7 -0
- package/esm/utils/date.js +34 -2
- package/esm/utils/debug.js +1 -1
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.d.ts +2 -1
- package/esm/utils/dom.js +1 -1
- package/esm/utils/errors.js +1 -1
- package/esm/utils/escapeHtml.js +1 -1
- package/esm/utils/filter-schema.js +1 -1
- package/esm/utils/filter.js +1 -1
- package/esm/utils/formatDuration.js +1 -1
- package/esm/utils/formula.js +1 -1
- package/esm/utils/getVariable.js +1 -1
- package/esm/utils/grammar.js +3 -3
- package/esm/utils/handleAction.js +1 -1
- package/esm/utils/helper.d.ts +2 -2
- package/esm/utils/helper.js +25 -18
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.d.ts +1 -1
- package/esm/utils/icon.js +1 -1
- package/esm/utils/image.js +1 -1
- package/esm/utils/isPureVariable.js +3 -3
- 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/memoryParse.d.ts +17 -0
- package/esm/utils/memoryParse.js +26 -0
- package/esm/utils/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +4 -2
- package/esm/utils/object.d.ts +2 -0
- package/esm/utils/object.js +27 -2
- 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 +1 -1
- package/esm/utils/renderer-event.js +1 -1
- 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 +4 -3
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/resolveVariableAndFilterForAsync.js +5 -4
- 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.d.ts +5 -2
- package/esm/utils/style-helper.js +18 -6
- package/esm/utils/style.js +1 -1
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.d.ts +0 -1
- package/esm/utils/tokenize.js +3 -34
- package/esm/utils/tpl-builtin.js +5 -3
- 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.d.ts +89 -4
- package/lib/Root.js +15 -4
- package/lib/RootRenderer.d.ts +3 -1
- package/lib/RootRenderer.js +8 -2
- package/lib/SchemaRenderer.d.ts +3 -2
- package/lib/SchemaRenderer.js +26 -20
- package/lib/Scoped.d.ts +8 -0
- package/lib/Scoped.js +20 -4
- package/lib/StatusScoped.d.ts +58 -0
- package/lib/StatusScoped.js +63 -0
- package/lib/WithRootStore.d.ts +2 -2
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +6 -2
- package/lib/actions/Action.d.ts +1 -0
- package/lib/actions/Action.js +12 -4
- 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 +8 -7
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +4 -4
- package/lib/actions/DialogAction.d.ts +16 -2
- package/lib/actions/DialogAction.js +19 -7
- 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 +1 -1
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/components/CustomStyle.d.ts +13 -0
- package/lib/components/CustomStyle.js +22 -0
- package/lib/components/LazyComponent.d.ts +1 -1
- package/lib/components/LazyComponent.js +1 -1
- package/lib/components/Overlay.d.ts +1 -1
- package/lib/components/Overlay.js +1 -1
- package/lib/components/PopOver.d.ts +2 -2
- package/lib/components/PopOver.js +1 -1
- package/lib/env.d.ts +10 -2
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +1 -5
- package/lib/factory.d.ts +3 -2
- package/lib/factory.js +1 -1
- package/lib/index.d.ts +4 -2
- package/lib/index.js +50 -24
- package/lib/locale.d.ts +2 -2
- package/lib/locale.js +10 -3
- package/lib/renderers/Form.d.ts +2 -1
- package/lib/renderers/Form.js +215 -179
- package/lib/renderers/Item.d.ts +55 -41
- package/lib/renderers/Item.js +24 -16
- package/lib/renderers/Options.js +9 -2
- 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 +2 -2
- package/lib/renderers/wrapControl.js +12 -15
- package/lib/store/app.d.ts +1 -0
- package/lib/store/app.js +1 -1
- package/lib/store/combo.d.ts +3 -0
- package/lib/store/combo.js +1 -1
- package/lib/store/crud.d.ts +2 -0
- package/lib/store/crud.js +12 -4
- package/lib/store/form.d.ts +1 -0
- package/lib/store/form.js +10 -4
- package/lib/store/formItem.js +1 -1
- package/lib/store/iRenderer.d.ts +1 -0
- package/lib/store/iRenderer.js +53 -12
- package/lib/store/index.js +1 -1
- package/lib/store/list.d.ts +1 -0
- package/lib/store/list.js +7 -3
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.d.ts +1 -0
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.d.ts +1 -0
- package/lib/store/pagination.js +1 -1
- package/lib/store/root.d.ts +4 -6
- package/lib/store/root.js +52 -23
- package/lib/store/service.d.ts +1 -0
- package/lib/store/service.js +1 -1
- package/lib/store/status.d.ts +12 -0
- package/lib/store/status.js +42 -0
- package/lib/store/table.d.ts +4 -0
- package/lib/store/table.js +10 -2
- package/lib/store/table2.d.ts +2 -1
- package/lib/store/table2.js +6 -6
- package/lib/theme.d.ts +1 -1
- package/lib/theme.js +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.js +1 -1
- package/lib/utils/DataScope.d.ts +3 -5
- package/lib/utils/DataScope.js +86 -29
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.js +5 -3
- package/lib/utils/attachmentAdpator.js +2 -2
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/columnsSplit.js +1 -1
- package/lib/utils/dataMapping.js +1 -1
- package/lib/utils/date.d.ts +7 -0
- package/lib/utils/date.js +34 -1
- package/lib/utils/debug.js +1 -1
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.d.ts +2 -1
- package/lib/utils/dom.js +1 -1
- 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.js +1 -1
- package/lib/utils/getVariable.js +1 -1
- package/lib/utils/grammar.js +3 -3
- package/lib/utils/handleAction.js +1 -1
- package/lib/utils/helper.d.ts +2 -2
- package/lib/utils/helper.js +25 -18
- package/lib/utils/highlight.js +1 -1
- package/lib/utils/icon.d.ts +1 -1
- package/lib/utils/icon.js +1 -1
- package/lib/utils/image.js +1 -1
- package/lib/utils/isPureVariable.js +3 -3
- 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/memoryParse.d.ts +17 -0
- package/lib/utils/memoryParse.js +30 -0
- package/lib/utils/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +4 -2
- package/lib/utils/object.d.ts +2 -0
- package/lib/utils/object.js +28 -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 +1 -1
- package/lib/utils/renderer-event.js +1 -1
- 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 +3 -2
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/resolveVariableAndFilterForAsync.js +4 -3
- 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.d.ts +5 -2
- package/lib/utils/style-helper.js +18 -6
- package/lib/utils/style.js +1 -1
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.d.ts +0 -1
- package/lib/utils/tokenize.js +1 -33
- package/lib/utils/tpl-builtin.js +4 -2
- 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 +3 -3
package/lib/utils/DataScope.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -80,26 +80,89 @@ var DataScope = /** @class */ (function () {
|
|
|
80
80
|
}
|
|
81
81
|
return false;
|
|
82
82
|
};
|
|
83
|
+
DataScope.prototype.assignSchema = function (target, schema) {
|
|
84
|
+
var e_2, _a;
|
|
85
|
+
// key相同,type也相同
|
|
86
|
+
if (target.type && target.type === schema.type) {
|
|
87
|
+
if (target.type === 'array') {
|
|
88
|
+
// 先只考虑items,不考虑contains
|
|
89
|
+
if (target.items) {
|
|
90
|
+
if (Array.isArray(target.items)) {
|
|
91
|
+
if (schema.items) {
|
|
92
|
+
if (Array.isArray(schema.items)) {
|
|
93
|
+
// 如果都是数组,就后者覆盖前者
|
|
94
|
+
return schema.items;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// 否则,追加
|
|
98
|
+
return tslib.__assign(tslib.__assign({}, target), { items: tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(target.items), false), [schema.items], false) });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return tslib.__assign(tslib.__assign({}, target), schema);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// 非数组,则merge
|
|
107
|
+
return tslib.__assign(tslib.__assign({}, target), { items: this.assignSchema(target.items, schema.items) });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return schema;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (target.type === 'object' && target.properties) {
|
|
115
|
+
var properties = {};
|
|
116
|
+
try {
|
|
117
|
+
// 合并属性
|
|
118
|
+
for (var _b = tslib.__values(Array.from(new Set(tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(Object.keys(target.properties)), false), tslib.__read(Object.keys(schema.properties)), false)))), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
119
|
+
var key = _c.value;
|
|
120
|
+
var value = target.properties[key];
|
|
121
|
+
if (value) {
|
|
122
|
+
properties[key] = schema.properties[key]
|
|
123
|
+
? this.assignSchema(value, schema.properties[key])
|
|
124
|
+
: value;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
properties[key] = schema.properties[key];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
132
|
+
finally {
|
|
133
|
+
try {
|
|
134
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
135
|
+
}
|
|
136
|
+
finally { if (e_2) throw e_2.error; }
|
|
137
|
+
}
|
|
138
|
+
return tslib.__assign(tslib.__assign({}, target), { properties: properties });
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return schema;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
// key相同、type不同
|
|
146
|
+
if (Array.isArray(target.oneOf)) {
|
|
147
|
+
return tslib.__assign(tslib.__assign({}, target), { oneOf: tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(target.oneOf), false), [schema], false) });
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
return tslib.__assign(tslib.__assign({}, target), { oneOf: [target, schema] });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
83
154
|
DataScope.prototype.getMergedSchema = function () {
|
|
155
|
+
var _this = this;
|
|
84
156
|
var mergedSchema = {
|
|
85
157
|
type: 'object',
|
|
86
158
|
properties: {}
|
|
87
159
|
};
|
|
88
|
-
// todo 以后再来细化这一块,先粗略的写个大概
|
|
89
160
|
this.schemas.forEach(function (schema) {
|
|
90
161
|
var properties = schema.properties || {};
|
|
91
162
|
Object.keys(properties).forEach(function (key) {
|
|
92
163
|
var value = properties[key];
|
|
93
164
|
if (mergedSchema.properties[key]) {
|
|
94
|
-
|
|
95
|
-
mergedSchema.properties[key].oneOf.push();
|
|
96
|
-
}
|
|
97
|
-
else if (mergedSchema.properties[key].type &&
|
|
98
|
-
mergedSchema.properties[key].type !== value.type) {
|
|
99
|
-
mergedSchema.properties[key] = {
|
|
100
|
-
oneOf: [mergedSchema.properties[key], value]
|
|
101
|
-
};
|
|
102
|
-
}
|
|
165
|
+
mergedSchema.properties[key] = _this.assignSchema(mergedSchema.properties[key], value);
|
|
103
166
|
}
|
|
104
167
|
else {
|
|
105
168
|
mergedSchema.properties[key] = value;
|
|
@@ -108,23 +171,17 @@ var DataScope = /** @class */ (function () {
|
|
|
108
171
|
});
|
|
109
172
|
return mergedSchema;
|
|
110
173
|
};
|
|
111
|
-
DataScope.prototype.buildOptions = function (options, schema, path, key
|
|
112
|
-
/** 是否数组元素,数组元素的内容将获取每个成员的对应值 */
|
|
113
|
-
isArrayItem,
|
|
114
|
-
/** 不是所有的都可以选择,但不影响子元素 */
|
|
115
|
-
disabled) {
|
|
174
|
+
DataScope.prototype.buildOptions = function (options, schema, path, key) {
|
|
116
175
|
var _this = this;
|
|
117
176
|
var _a;
|
|
118
177
|
if (path === void 0) { path = ''; }
|
|
119
178
|
if (key === void 0) { key = ''; }
|
|
120
|
-
if (isArrayItem === void 0) { isArrayItem = false; }
|
|
121
179
|
// todo 支持 oneOf, anyOf
|
|
122
180
|
var option = {
|
|
123
181
|
label: schema.title || key,
|
|
124
182
|
value: path,
|
|
125
183
|
type: schema.type,
|
|
126
|
-
tag: (_a = schema.description) !== null && _a !== void 0 ? _a : schema.type
|
|
127
|
-
disabled: disabled
|
|
184
|
+
tag: (_a = schema.description) !== null && _a !== void 0 ? _a : schema.type
|
|
128
185
|
};
|
|
129
186
|
options.push(option);
|
|
130
187
|
if (schema.type === 'object' && schema.properties) {
|
|
@@ -132,17 +189,13 @@ var DataScope = /** @class */ (function () {
|
|
|
132
189
|
var keys = Object.keys(schema.properties);
|
|
133
190
|
keys.forEach(function (key) {
|
|
134
191
|
var child = schema.properties[key];
|
|
135
|
-
|
|
136
|
-
_this.buildOptions(option.children, child, newPath, key, isArrayItem, false);
|
|
192
|
+
_this.buildOptions(option.children, child, path + (path ? '.' : '') + key, key);
|
|
137
193
|
});
|
|
138
194
|
}
|
|
139
195
|
else if (schema.type === 'array' && schema.items) {
|
|
140
196
|
option.children = [];
|
|
141
|
-
this.buildOptions(option.children, tslib.__assign({ title: '成员' }, schema.items), path, 'items'
|
|
142
|
-
|
|
143
|
-
title: '总数',
|
|
144
|
-
type: 'number'
|
|
145
|
-
}, path + (path ? '.' : '') + 'length', 'length', true, isArrayItem);
|
|
197
|
+
this.buildOptions(option.children, tslib.__assign(tslib.__assign({ title: '成员' }, schema.items), { disabled: true }), path, 'items');
|
|
198
|
+
option.children = helper.mapTree(option.children, function (item) { return (tslib.__assign(tslib.__assign({}, item), { disabled: true })); });
|
|
146
199
|
}
|
|
147
200
|
};
|
|
148
201
|
DataScope.prototype.getDataPropsAsOptions = function () {
|
|
@@ -151,7 +204,7 @@ var DataScope = /** @class */ (function () {
|
|
|
151
204
|
return variables[0].children;
|
|
152
205
|
};
|
|
153
206
|
DataScope.prototype.getSchemaByPath = function (path) {
|
|
154
|
-
var
|
|
207
|
+
var e_3, _a;
|
|
155
208
|
var parts = keyToPath.keyToPath(path);
|
|
156
209
|
try {
|
|
157
210
|
for (var _b = tslib.__values(this.schemas), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -167,15 +220,19 @@ var DataScope = /** @class */ (function () {
|
|
|
167
220
|
}
|
|
168
221
|
}
|
|
169
222
|
}
|
|
170
|
-
catch (
|
|
223
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
171
224
|
finally {
|
|
172
225
|
try {
|
|
173
226
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
174
227
|
}
|
|
175
|
-
finally { if (
|
|
228
|
+
finally { if (e_3) throw e_3.error; }
|
|
176
229
|
}
|
|
177
230
|
return null;
|
|
178
231
|
};
|
|
232
|
+
DataScope.prototype.getSchemaById = function (id) {
|
|
233
|
+
var _a;
|
|
234
|
+
return (_a = this.schemas) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.$id === id; });
|
|
235
|
+
};
|
|
179
236
|
return DataScope;
|
|
180
237
|
}());
|
|
181
238
|
|
package/lib/utils/RootClose.js
CHANGED
package/lib/utils/SimpleMap.js
CHANGED
package/lib/utils/api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -14,6 +14,7 @@ var escapeHtml = require('./escapeHtml.js');
|
|
|
14
14
|
require('moment');
|
|
15
15
|
var object = require('./object.js');
|
|
16
16
|
var tokenize = require('./tokenize.js');
|
|
17
|
+
var memoryParse = require('./memoryParse.js');
|
|
17
18
|
var dataMapping = require('./dataMapping.js');
|
|
18
19
|
require('./filter.js');
|
|
19
20
|
var tpl = require('./tpl.js');
|
|
@@ -72,7 +73,7 @@ function buildApi(api, data, options) {
|
|
|
72
73
|
var raw = (api.url = api.url || '');
|
|
73
74
|
var ast = undefined;
|
|
74
75
|
try {
|
|
75
|
-
ast =
|
|
76
|
+
ast = memoryParse.memoryParse(api.url);
|
|
76
77
|
}
|
|
77
78
|
catch (e) {
|
|
78
79
|
console.warn("api \u914D\u7F6E\u8BED\u6CD5\u51FA\u9519\uFF1A".concat(e));
|
|
@@ -266,7 +267,8 @@ function responseAdaptor(ret, api) {
|
|
|
266
267
|
// 如果是文本类型就尝试解析一下
|
|
267
268
|
if (ret.headers &&
|
|
268
269
|
contentType.startsWith('text/') &&
|
|
269
|
-
!contentType.includes('markdown')
|
|
270
|
+
!contentType.includes('markdown') &&
|
|
271
|
+
api.responseType !== 'blob') {
|
|
270
272
|
try {
|
|
271
273
|
data = JSON.parse(data);
|
|
272
274
|
if (typeof data === 'undefined') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -22,7 +22,7 @@ function attachmentAdpator(response, __) {
|
|
|
22
22
|
if (disposition && disposition.indexOf('attachment') !== -1) {
|
|
23
23
|
// disposition 有可能是 attachment; filename="??.xlsx"; filename*=UTF-8''%E4%B8%AD%E6%96%87.xlsx
|
|
24
24
|
// 这种情况下最后一个才是正确的文件名
|
|
25
|
-
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)
|
|
25
|
+
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
|
|
26
26
|
var matches = disposition.match(filenameRegex);
|
|
27
27
|
if (matches && matches.length) {
|
|
28
28
|
filename = matches[1].replace("UTF-8''", '').replace(/['"]/g, '');
|
package/lib/utils/autobind.js
CHANGED
package/lib/utils/dataMapping.js
CHANGED
package/lib/utils/date.d.ts
CHANGED
|
@@ -2,3 +2,10 @@ import moment from 'moment';
|
|
|
2
2
|
export declare const relativeValueRe: RegExp;
|
|
3
3
|
export declare const filterDate: (value: string, data?: object, format?: string, utc?: boolean) => moment.Moment;
|
|
4
4
|
export declare function parseDuration(str: string): moment.Duration | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* 解析日期,先尝试用 format 解析,如果失败,再尝试用其他标准格式解析
|
|
7
|
+
* @param value
|
|
8
|
+
* @param format
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeDate(value: any, format?: string): moment.Moment | undefined;
|
package/lib/utils/date.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -84,7 +84,40 @@ function parseDuration(str) {
|
|
|
84
84
|
}
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* 解析日期,先尝试用 format 解析,如果失败,再尝试用其他标准格式解析
|
|
89
|
+
* @param value
|
|
90
|
+
* @param format
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
function normalizeDate(value, format) {
|
|
94
|
+
if (!value || value === '0') {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
var v = moment__default["default"](value, format, true);
|
|
98
|
+
if (v.isValid()) {
|
|
99
|
+
return v;
|
|
100
|
+
}
|
|
101
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
102
|
+
var formats = ['', 'YYYY-MM-DD HH:mm:ss', 'X'];
|
|
103
|
+
if (/^\d{10}((\.\d+)*)$/.test(value.toString())) {
|
|
104
|
+
formats = ['X', 'x', 'YYYY-MM-DD HH:mm:ss', ''];
|
|
105
|
+
}
|
|
106
|
+
else if (/^\d{13}((\.\d+)*)$/.test(value.toString())) {
|
|
107
|
+
formats = ['x', 'X', 'YYYY-MM-DD HH:mm:ss', ''];
|
|
108
|
+
}
|
|
109
|
+
while (formats.length) {
|
|
110
|
+
var format_1 = formats.shift();
|
|
111
|
+
var date = moment__default["default"](value, format_1);
|
|
112
|
+
if (date.isValid()) {
|
|
113
|
+
return date;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
87
119
|
|
|
88
120
|
exports.filterDate = filterDate;
|
|
121
|
+
exports.normalizeDate = normalizeDate;
|
|
89
122
|
exports.parseDuration = parseDuration;
|
|
90
123
|
exports.relativeValueRe = relativeValueRe;
|
package/lib/utils/debug.js
CHANGED
package/lib/utils/dom.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export declare function getContainer(container: any, defaultContainer: any): any;
|
|
2
3
|
export declare function ownerDocument(componentOrElement: any): Document;
|
|
3
4
|
export declare function calculatePosition(placement: any, overlayNode: any, target: HTMLElement, container: any, padding?: any, customOffset?: [number, number]): {
|
|
@@ -12,4 +13,4 @@ export declare function calculatePosition(placement: any, overlayNode: any, targ
|
|
|
12
13
|
*/
|
|
13
14
|
export declare function getStyleNumber(element: HTMLElement, styleName: string): number;
|
|
14
15
|
/** 根据关键字高亮显示文本内容 */
|
|
15
|
-
export declare function renderTextByKeyword(rendererText: string, curKeyword: string): string | JSX.Element;
|
|
16
|
+
export declare function renderTextByKeyword(rendererText: string, curKeyword: string): string | React.JSX.Element;
|
package/lib/utils/dom.js
CHANGED
package/lib/utils/errors.js
CHANGED
package/lib/utils/escapeHtml.js
CHANGED
package/lib/utils/filter.js
CHANGED
package/lib/utils/formula.js
CHANGED
package/lib/utils/getVariable.js
CHANGED
package/lib/utils/grammar.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var memoryParse = require('./memoryParse.js');
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @file 公式语法解析
|
|
@@ -36,7 +36,7 @@ function collectVariables(strOrAst, execMode) {
|
|
|
36
36
|
return COLLECT_EXPRESSION_CACHE[strOrAst];
|
|
37
37
|
}
|
|
38
38
|
var ast = typeof strOrAst === 'string'
|
|
39
|
-
?
|
|
39
|
+
? memoryParse.memoryParse(strOrAst, {
|
|
40
40
|
evalMode: execMode !== null && execMode !== void 0 ? execMode : false
|
|
41
41
|
})
|
|
42
42
|
: strOrAst;
|
package/lib/utils/helper.d.ts
CHANGED
|
@@ -131,7 +131,7 @@ export interface TreeArray extends Array<TreeItem> {
|
|
|
131
131
|
* @param {Function} iterator 处理函数,返回的数据会被替换成新的。
|
|
132
132
|
* @return {Tree} 返回处理过的 tree
|
|
133
133
|
*/
|
|
134
|
-
export declare function mapTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>) => T, level?: number, depthFirst?: boolean, paths?: Array<T>): any[];
|
|
134
|
+
export declare function mapTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>, indexes: Array<number>) => T, level?: number, depthFirst?: boolean, paths?: Array<T>, indexes?: Array<number>): any[];
|
|
135
135
|
/**
|
|
136
136
|
* 遍历树
|
|
137
137
|
* @param tree
|
|
@@ -163,7 +163,7 @@ export declare function getTree<T extends TreeItem>(tree: Array<T>, idx: Array<n
|
|
|
163
163
|
* @param tree
|
|
164
164
|
* @param iterator
|
|
165
165
|
*/
|
|
166
|
-
export declare function filterTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number) => any, level?: number, depthFirst?: boolean): T[];
|
|
166
|
+
export declare function filterTree<T extends TreeItem>(tree: Array<T>, iterator: (item: T, key: number, level: number, paths: Array<T>) => any, level?: number, depthFirst?: boolean, paths?: Array<T>): T[];
|
|
167
167
|
/**
|
|
168
168
|
* 判断树中每个节点是否满足某个条件。
|
|
169
169
|
* @param tree
|
package/lib/utils/helper.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -556,22 +556,23 @@ var uuidv4 = function () {
|
|
|
556
556
|
* @param {Function} iterator 处理函数,返回的数据会被替换成新的。
|
|
557
557
|
* @return {Tree} 返回处理过的 tree
|
|
558
558
|
*/
|
|
559
|
-
function mapTree(tree, iterator, level, depthFirst, paths) {
|
|
559
|
+
function mapTree(tree, iterator, level, depthFirst, paths, indexes) {
|
|
560
560
|
if (level === void 0) { level = 1; }
|
|
561
561
|
if (depthFirst === void 0) { depthFirst = false; }
|
|
562
562
|
if (paths === void 0) { paths = []; }
|
|
563
|
+
if (indexes === void 0) { indexes = []; }
|
|
563
564
|
return tree.map(function (item, index) {
|
|
564
565
|
if (depthFirst) {
|
|
565
566
|
var children = item.children
|
|
566
|
-
? mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item))
|
|
567
|
+
? mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item), indexes.concat(index))
|
|
567
568
|
: undefined;
|
|
568
569
|
children && (item = tslib.__assign(tslib.__assign({}, item), { children: children }));
|
|
569
|
-
item = iterator(item, index, level, paths) || tslib.__assign({}, item);
|
|
570
|
+
item = iterator(item, index, level, paths, indexes.concat(index)) || tslib.__assign({}, item);
|
|
570
571
|
return item;
|
|
571
572
|
}
|
|
572
|
-
item = iterator(item, index, level, paths) || tslib.__assign({}, item);
|
|
573
|
+
item = iterator(item, index, level, paths, indexes.concat(index)) || tslib.__assign({}, item);
|
|
573
574
|
if (item.children && item.children.splice) {
|
|
574
|
-
item.children = mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item));
|
|
575
|
+
item.children = mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item), indexes.concat(index));
|
|
575
576
|
}
|
|
576
577
|
return item;
|
|
577
578
|
});
|
|
@@ -586,10 +587,9 @@ function eachTree(tree, iterator, level, paths) {
|
|
|
586
587
|
if (paths === void 0) { paths = []; }
|
|
587
588
|
tree.map(function (item, index) {
|
|
588
589
|
var _a;
|
|
589
|
-
|
|
590
|
-
iterator(item, index, level, currentPath);
|
|
590
|
+
iterator(item, index, level, paths);
|
|
591
591
|
if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.splice) {
|
|
592
|
-
eachTree(item.children, iterator, level + 1,
|
|
592
|
+
eachTree(item.children, iterator, level + 1, paths.concat(item));
|
|
593
593
|
}
|
|
594
594
|
});
|
|
595
595
|
}
|
|
@@ -669,28 +669,29 @@ function getTree(tree, idx) {
|
|
|
669
669
|
* @param tree
|
|
670
670
|
* @param iterator
|
|
671
671
|
*/
|
|
672
|
-
function filterTree(tree, iterator, level, depthFirst) {
|
|
672
|
+
function filterTree(tree, iterator, level, depthFirst, paths) {
|
|
673
673
|
if (level === void 0) { level = 1; }
|
|
674
674
|
if (depthFirst === void 0) { depthFirst = false; }
|
|
675
|
+
if (paths === void 0) { paths = []; }
|
|
675
676
|
if (depthFirst) {
|
|
676
677
|
return tree
|
|
677
678
|
.map(function (item) {
|
|
678
679
|
var children = item.children
|
|
679
|
-
? filterTree(item.children, iterator, level + 1, depthFirst)
|
|
680
|
+
? filterTree(item.children, iterator, level + 1, depthFirst, paths.concat(item))
|
|
680
681
|
: undefined;
|
|
681
682
|
if (Array.isArray(children) && Array.isArray(item.children)) {
|
|
682
683
|
item = tslib.__assign(tslib.__assign({}, item), { children: children });
|
|
683
684
|
}
|
|
684
685
|
return item;
|
|
685
686
|
})
|
|
686
|
-
.filter(function (item, index) { return iterator(item, index, level); });
|
|
687
|
+
.filter(function (item, index) { return iterator(item, index, level, paths); });
|
|
687
688
|
}
|
|
688
689
|
return tree
|
|
689
|
-
.filter(function (item, index) { return iterator(item, index, level); })
|
|
690
|
+
.filter(function (item, index) { return iterator(item, index, level, paths); })
|
|
690
691
|
.map(function (item) {
|
|
691
692
|
var _a;
|
|
692
693
|
if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.splice) {
|
|
693
|
-
var children = filterTree(item.children, iterator, level + 1, depthFirst);
|
|
694
|
+
var children = filterTree(item.children, iterator, level + 1, depthFirst, paths.concat(item));
|
|
694
695
|
if (Array.isArray(children) && Array.isArray(item.children)) {
|
|
695
696
|
item = tslib.__assign(tslib.__assign({}, item), { children: children });
|
|
696
697
|
}
|
|
@@ -790,6 +791,9 @@ function spliceTree(tree, idx, deleteCount) {
|
|
|
790
791
|
* @param tree
|
|
791
792
|
*/
|
|
792
793
|
function getTreeDepth(tree) {
|
|
794
|
+
if (Array.isArray(tree) && tree.length === 0) {
|
|
795
|
+
return 0;
|
|
796
|
+
}
|
|
793
797
|
return Math.max.apply(Math, tslib.__spreadArray([], tslib.__read(tree.map(function (item) {
|
|
794
798
|
if (Array.isArray(item.children)) {
|
|
795
799
|
return 1 + getTreeDepth(item.children);
|
|
@@ -1283,14 +1287,17 @@ function isNumeric(value) {
|
|
|
1283
1287
|
* @param location Location对象,或者类Location结构的对象
|
|
1284
1288
|
*/
|
|
1285
1289
|
function parseQuery(location) {
|
|
1286
|
-
var _a
|
|
1290
|
+
var _a;
|
|
1287
1291
|
var query = (location && !(location instanceof Location) && (location === null || location === void 0 ? void 0 : location.query)) ||
|
|
1288
1292
|
(location && (location === null || location === void 0 ? void 0 : location.search) && qsparse(location.search.substring(1))) ||
|
|
1289
1293
|
(window.location.search && qsparse(window.location.search.substring(1)));
|
|
1290
1294
|
/* 处理hash中的query */
|
|
1291
|
-
var
|
|
1292
|
-
|
|
1293
|
-
|
|
1295
|
+
var hash = (_a = window.location) === null || _a === void 0 ? void 0 : _a.hash;
|
|
1296
|
+
var hashQuery = {};
|
|
1297
|
+
var idx = -1;
|
|
1298
|
+
if (typeof hash === 'string' && ~(idx = hash.indexOf('?'))) {
|
|
1299
|
+
hashQuery = qsparse(hash.substring(idx + 1));
|
|
1300
|
+
}
|
|
1294
1301
|
var normalizedQuery = isPlainObject__default["default"](query) ? query : {};
|
|
1295
1302
|
return merge__default["default"](normalizedQuery, hashQuery);
|
|
1296
1303
|
}
|
package/lib/utils/highlight.js
CHANGED
package/lib/utils/icon.d.ts
CHANGED
|
@@ -18,4 +18,4 @@ export interface IconCheckedSchemaNew {
|
|
|
18
18
|
* @param className 内部用的 className
|
|
19
19
|
* @param classNameProp amis 配置里设置的 className
|
|
20
20
|
*/
|
|
21
|
-
export declare const generateIcon: (cx: ClassNamesFn, icon?: string | IconCheckedSchema | React.ReactNode | IconCheckedSchemaNew, className?: string, classNameProp?: string) => JSX.Element | null | undefined;
|
|
21
|
+
export declare const generateIcon: (cx: ClassNamesFn, icon?: string | IconCheckedSchema | React.ReactNode | IconCheckedSchemaNew, className?: string, classNameProp?: string) => React.JSX.Element | null | undefined;
|
package/lib/utils/icon.js
CHANGED
package/lib/utils/image.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v3.
|
|
2
|
+
* amis-core v3.1.0
|
|
3
3
|
* Copyright 2018-2023 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var memoryParse = require('./memoryParse.js');
|
|
11
11
|
|
|
12
12
|
function isPureVariable(path) {
|
|
13
13
|
if (typeof path === 'string') {
|
|
14
14
|
try {
|
|
15
|
-
var ast =
|
|
15
|
+
var ast = memoryParse.memoryParse(path);
|
|
16
16
|
// 只有一个成员说明是纯表达式模式
|
|
17
17
|
return ast.body.length === 1 && ast.body[0].type === 'script';
|
|
18
18
|
}
|