amis-core 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/Root.js +1 -1
- package/esm/RootRenderer.d.ts +1 -1
- package/esm/RootRenderer.js +3 -3
- package/esm/SchemaRenderer.js +5 -2
- package/esm/Scoped.d.ts +4 -1
- package/esm/Scoped.js +8 -5
- package/esm/StatusScoped.js +1 -1
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +1 -1
- package/esm/actions/Action.d.ts +1 -0
- package/esm/actions/Action.js +62 -37
- package/esm/actions/AjaxAction.d.ts +6 -8
- package/esm/actions/AjaxAction.js +20 -18
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.d.ts +1 -2
- package/esm/actions/CmptAction.js +46 -31
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +2 -2
- package/esm/actions/DialogAction.js +5 -6
- package/esm/actions/DrawerAction.js +4 -4
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/LinkAction.js +1 -1
- package/esm/actions/LoopAction.js +1 -1
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/StatusAction.d.ts +15 -0
- package/esm/actions/StatusAction.js +49 -0
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/actions/index.d.ts +1 -0
- package/esm/components/CustomStyle.js +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.js +2 -2
- package/esm/components/PopOver.js +2 -2
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.js +2 -2
- package/esm/index.d.ts +2 -1
- package/esm/index.js +13 -13
- package/esm/locale.js +1 -1
- package/esm/polyfills.js +1 -1
- package/esm/renderers/Form.d.ts +6 -6
- package/esm/renderers/Form.js +168 -124
- package/esm/renderers/Item.d.ts +42 -66
- package/esm/renderers/Item.js +11 -41
- package/esm/renderers/Options.js +1 -2
- package/esm/renderers/Placeholder.js +1 -1
- package/esm/renderers/builtin.js +1 -1
- package/esm/renderers/register.js +1 -1
- package/esm/renderers/wrapControl.js +101 -47
- package/esm/store/app.js +8 -4
- package/esm/store/combo.d.ts +444 -1912
- package/esm/store/combo.js +9 -2
- package/esm/store/crud.d.ts +1 -0
- package/esm/store/crud.js +11 -5
- package/esm/store/form.d.ts +132 -892
- package/esm/store/form.js +83 -81
- package/esm/store/formItem.d.ts +5 -2
- package/esm/store/formItem.js +13 -2
- package/esm/store/iRenderer.js +2 -2
- package/esm/store/index.js +1 -1
- package/esm/store/list.js +1 -1
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.js +1 -1
- package/esm/store/root.js +2 -2
- package/esm/store/service.js +4 -4
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +503 -2040
- package/esm/store/table.js +79 -55
- package/esm/store/table2.d.ts +49 -0
- package/esm/store/table2.js +37 -4
- package/esm/theme.js +1 -1
- package/esm/types.d.ts +17 -3
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.js +1 -1
- package/esm/utils/DataScope.js +1 -1
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.d.ts +2 -2
- package/esm/utils/api.js +113 -81
- package/esm/utils/arraySlice.js +1 -1
- package/esm/utils/attachmentAdpator.js +1 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/dataMapping.js +4 -2
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.d.ts +2 -0
- package/esm/utils/debug.js +34 -7
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.js +1 -1
- package/esm/utils/errors.js +1 -1
- package/esm/utils/escapeHtml.js +1 -1
- package/esm/utils/filter-schema.js +1 -1
- package/esm/utils/filter.js +1 -1
- package/esm/utils/formatDuration.js +1 -1
- package/esm/utils/formula.d.ts +0 -1
- package/esm/utils/formula.js +6 -9
- package/esm/utils/getVariable.js +1 -1
- package/esm/utils/grammar.js +1 -1
- package/esm/utils/handleAction.js +1 -1
- package/esm/utils/helper.d.ts +11 -1
- package/esm/utils/helper.js +14 -2
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.d.ts +4 -2
- package/esm/utils/icon.js +3 -2
- package/esm/utils/image.js +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/isPureVariable.js +1 -1
- package/esm/utils/json-schema-2-amis-schema.js +1 -1
- package/esm/utils/keyToPath.js +1 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/math.d.ts +3 -0
- package/esm/utils/math.js +52 -0
- package/esm/utils/memoryParse.js +1 -1
- package/esm/utils/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.d.ts +7 -0
- package/esm/utils/object.js +13 -2
- package/esm/utils/offset.js +1 -1
- package/esm/utils/offsetParent.js +1 -1
- package/esm/utils/optionValueCompare.js +2 -2
- package/esm/utils/position.js +1 -1
- package/esm/utils/prettyBytes.js +1 -1
- package/esm/utils/renderer-event.d.ts +1 -1
- package/esm/utils/renderer-event.js +14 -6
- package/esm/utils/replaceText.js +1 -1
- package/esm/utils/resize-sensor.js +1 -1
- package/esm/utils/resolveCondition.js +1 -1
- package/esm/utils/resolveVariable.js +1 -1
- package/esm/utils/resolveVariableAndFilter.js +1 -1
- package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
- package/esm/utils/scrollPosition.js +1 -1
- package/esm/utils/string2regExp.js +1 -1
- package/esm/utils/stripNumber.js +1 -1
- package/esm/utils/style-helper.js +1 -1
- package/esm/utils/style.js +1 -1
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.js +1 -1
- package/esm/utils/tpl-lodash.js +1 -1
- package/esm/utils/tpl.js +1 -1
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validations.js +1 -1
- package/lib/Root.js +10 -7
- package/lib/RootRenderer.d.ts +1 -1
- package/lib/RootRenderer.js +11 -8
- package/lib/SchemaRenderer.js +12 -6
- package/lib/Scoped.d.ts +4 -1
- package/lib/Scoped.js +18 -13
- package/lib/StatusScoped.js +5 -2
- package/lib/WithRootStore.js +5 -2
- package/lib/WithStore.js +5 -2
- package/lib/actions/Action.d.ts +1 -0
- package/lib/actions/Action.js +62 -37
- package/lib/actions/AjaxAction.d.ts +6 -8
- package/lib/actions/AjaxAction.js +20 -18
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.d.ts +1 -2
- package/lib/actions/CmptAction.js +46 -31
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +8 -5
- package/lib/actions/DialogAction.js +5 -6
- package/lib/actions/DrawerAction.js +4 -4
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/LinkAction.js +1 -1
- package/lib/actions/LoopAction.js +1 -1
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/StatusAction.d.ts +15 -0
- package/lib/actions/StatusAction.js +53 -0
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/actions/index.d.ts +1 -0
- package/lib/components/CustomStyle.js +1 -1
- package/lib/components/LazyComponent.js +12 -14
- package/lib/components/Overlay.js +14 -14
- package/lib/components/PopOver.js +11 -10
- package/lib/env.js +4 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.js +11 -9
- package/lib/index.d.ts +2 -1
- package/lib/index.js +21 -19
- package/lib/locale.js +6 -3
- package/lib/polyfills.js +1 -1
- package/lib/renderers/Form.d.ts +6 -6
- package/lib/renderers/Form.js +180 -131
- package/lib/renderers/Item.d.ts +42 -66
- package/lib/renderers/Item.js +51 -75
- package/lib/renderers/Options.js +10 -5
- package/lib/renderers/Placeholder.js +1 -1
- package/lib/renderers/builtin.js +1 -1
- package/lib/renderers/register.js +1 -1
- package/lib/renderers/wrapControl.js +104 -47
- package/lib/store/app.js +14 -7
- package/lib/store/combo.d.ts +444 -1912
- package/lib/store/combo.js +9 -2
- package/lib/store/crud.d.ts +1 -0
- package/lib/store/crud.js +11 -5
- package/lib/store/form.d.ts +132 -892
- package/lib/store/form.js +81 -79
- package/lib/store/formItem.d.ts +5 -2
- package/lib/store/formItem.js +13 -2
- package/lib/store/iRenderer.js +8 -5
- package/lib/store/index.js +1 -1
- package/lib/store/list.js +1 -1
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.js +1 -1
- package/lib/store/root.js +8 -5
- package/lib/store/service.js +4 -4
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +503 -2040
- package/lib/store/table.js +79 -55
- package/lib/store/table2.d.ts +49 -0
- package/lib/store/table2.js +36 -3
- package/lib/theme.js +6 -3
- package/lib/types.d.ts +17 -3
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.js +1 -1
- package/lib/utils/DataScope.js +1 -1
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.d.ts +2 -2
- package/lib/utils/api.js +113 -81
- package/lib/utils/arraySlice.js +1 -1
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/columnsSplit.js +8 -6
- package/lib/utils/dataMapping.js +4 -2
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.d.ts +2 -0
- package/lib/utils/debug.js +61 -33
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.js +7 -5
- package/lib/utils/errors.js +1 -1
- package/lib/utils/escapeHtml.js +1 -1
- package/lib/utils/filter-schema.js +1 -1
- package/lib/utils/filter.js +1 -1
- package/lib/utils/formatDuration.js +1 -1
- package/lib/utils/formula.d.ts +0 -1
- package/lib/utils/formula.js +6 -10
- package/lib/utils/getVariable.js +1 -1
- package/lib/utils/grammar.js +1 -1
- package/lib/utils/handleAction.js +1 -1
- package/lib/utils/helper.d.ts +11 -1
- package/lib/utils/helper.js +14 -1
- package/lib/utils/highlight.js +8 -9
- package/lib/utils/icon.d.ts +4 -2
- package/lib/utils/icon.js +12 -10
- package/lib/utils/image.js +1 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/isPureVariable.js +1 -1
- package/lib/utils/json-schema-2-amis-schema.js +1 -1
- package/lib/utils/keyToPath.js +1 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/math.d.ts +3 -0
- package/lib/utils/math.js +58 -0
- package/lib/utils/memoryParse.js +1 -1
- package/lib/utils/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.d.ts +7 -0
- package/lib/utils/object.js +13 -1
- package/lib/utils/offset.js +1 -1
- package/lib/utils/offsetParent.js +1 -1
- package/lib/utils/optionValueCompare.js +7 -3
- package/lib/utils/position.js +1 -1
- package/lib/utils/prettyBytes.js +1 -1
- package/lib/utils/renderer-event.d.ts +1 -1
- package/lib/utils/renderer-event.js +13 -5
- package/lib/utils/replaceText.js +1 -1
- package/lib/utils/resize-sensor.js +1 -1
- package/lib/utils/resolveCondition.js +1 -1
- package/lib/utils/resolveVariable.js +1 -1
- package/lib/utils/resolveVariableAndFilter.js +1 -1
- package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
- package/lib/utils/scrollPosition.js +1 -1
- package/lib/utils/string2regExp.js +1 -1
- package/lib/utils/stripNumber.js +1 -1
- package/lib/utils/style-helper.js +1 -1
- package/lib/utils/style.js +1 -1
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.js +1 -1
- package/lib/utils/tpl-lodash.js +1 -1
- package/lib/utils/tpl.js +1 -1
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validations.js +1 -1
- package/package.json +5 -5
|
@@ -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
|
|
|
@@ -9,7 +9,7 @@ import debounce from 'lodash/debounce';
|
|
|
9
9
|
import isEqual from 'lodash/isEqual';
|
|
10
10
|
import { ComboStore } from '../store/combo.js';
|
|
11
11
|
import { guid, promisify, anyChanged } from '../utils/helper.js';
|
|
12
|
-
import { isExpression, FormulaExec, replaceExpression, isNeedFormula
|
|
12
|
+
import { isExpression, FormulaExec, replaceExpression, isNeedFormula } from '../utils/formula.js';
|
|
13
13
|
import { ScopedContext } from '../Scoped.js';
|
|
14
14
|
import { FormItemStore } from '../store/formItem.js';
|
|
15
15
|
import { isAlive } from 'mobx-state-tree';
|
|
@@ -26,14 +26,14 @@ function wrapControl(ComposedComponent) {
|
|
|
26
26
|
__extends(class_1, _super);
|
|
27
27
|
function class_1(props) {
|
|
28
28
|
var _this = this;
|
|
29
|
-
var _a
|
|
29
|
+
var _a;
|
|
30
30
|
_this = _super.call(this, props) || this;
|
|
31
31
|
_this.value = undefined;
|
|
32
32
|
_this.lazyEmitChange = debounce(_this.emitChange.bind(_this), 250, {
|
|
33
33
|
trailing: true,
|
|
34
34
|
leading: false
|
|
35
35
|
});
|
|
36
|
-
var
|
|
36
|
+
var _b = _this.props, form = _b.formStore, formItem = _b.formItem, rootStore = _b.rootStore, store = _b.store, onChange = _b.onChange, data = _b.data, inputGroupControl = _b.inputGroupControl, _c = _b.$schema, name = _c.name, id = _c.id, type = _c.type, required = _c.required, validations = _c.validations, validationErrors = _c.validationErrors, unique = _c.unique, value = _c.value, extraName = _c.extraName; _c.multiple; var delimiter = _c.delimiter, valueField = _c.valueField, labelField = _c.labelField, joinValues = _c.joinValues, extractValue = _c.extractValue, selectFirst = _c.selectFirst, autoFill = _c.autoFill, clearValueOnHidden = _c.clearValueOnHidden, validateApi = _c.validateApi, minLength = _c.minLength, maxLength = _c.maxLength, validateOnChange = _c.validateOnChange, label = _c.label;
|
|
37
37
|
_this.getValue = _this.getValue.bind(_this);
|
|
38
38
|
_this.setValue = _this.setValue.bind(_this);
|
|
39
39
|
_this.handleChange = _this.handleChange.bind(_this);
|
|
@@ -64,7 +64,7 @@ function wrapControl(ComposedComponent) {
|
|
|
64
64
|
_this.model = model;
|
|
65
65
|
// @issue 打算干掉这个
|
|
66
66
|
formItem === null || formItem === void 0 ? void 0 : formItem.addSubFormItem(model);
|
|
67
|
-
model.config(__assign(__assign({}, pick(__assign(__assign({}, ComposedComponent.defaultProps), _this.props.$schema), ['multiple'])), { id: id, type: type, required: required, unique: unique, value: value, isValueSchemaExp: isExpression(value), rules: validations, messages: validationErrors, delimiter: delimiter, valueField: valueField, labelField: labelField, joinValues: joinValues, extractValue: extractValue, selectFirst: selectFirst, autoFill: autoFill, clearValueOnHidden: clearValueOnHidden, validateApi: validateApi, minLength: minLength, maxLength: maxLength, validateOnChange: validateOnChange, label: label, inputGroupControl: inputGroupControl }));
|
|
67
|
+
model.config(__assign(__assign({}, pick(__assign(__assign({}, ComposedComponent.defaultProps), _this.props.$schema), ['multiple'])), { id: id, type: type, required: required, unique: unique, value: value, isValueSchemaExp: isExpression(value), rules: validations, messages: validationErrors, delimiter: delimiter, valueField: valueField, labelField: labelField, joinValues: joinValues, extractValue: extractValue, selectFirst: selectFirst, autoFill: autoFill, clearValueOnHidden: clearValueOnHidden, validateApi: validateApi, minLength: minLength, maxLength: maxLength, validateOnChange: validateOnChange, label: label, inputGroupControl: inputGroupControl, extraName: extraName }));
|
|
68
68
|
// issue 这个逻辑应该在 combo 里面自己实现。
|
|
69
69
|
if (_this.model.unique &&
|
|
70
70
|
((_a = form === null || form === void 0 ? void 0 : form.parentStore) === null || _a === void 0 ? void 0 : _a.storeType) === ComboStore.name) {
|
|
@@ -76,19 +76,39 @@ function wrapControl(ComposedComponent) {
|
|
|
76
76
|
model.changeTmpValue(propValue, 'controlled');
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
|
-
// 备注: 此处的 value 是 schema 中的 value(和props.defaultValue相同)
|
|
80
79
|
var isExp = isExpression(value);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
if (isExp) {
|
|
81
|
+
model.changeTmpValue(FormulaExec['formula'](value, data), // 对组件默认值进行运算
|
|
82
|
+
'formulaChanged');
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
var initialValue = model.extraName
|
|
86
|
+
? [
|
|
87
|
+
store === null || store === void 0 ? void 0 : store.getValueByName(model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData),
|
|
88
|
+
store === null || store === void 0 ? void 0 : store.getValueByName(model.extraName, form === null || form === void 0 ? void 0 : form.canAccessSuperData)
|
|
89
|
+
]
|
|
90
|
+
: store === null || store === void 0 ? void 0 : store.getValueByName(model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData);
|
|
91
|
+
if (model.extraName &&
|
|
92
|
+
initialValue.every(function (item) { return item === undefined; })) {
|
|
93
|
+
initialValue = undefined;
|
|
94
|
+
}
|
|
95
|
+
model.changeTmpValue(initialValue !== null && initialValue !== void 0 ? initialValue : replaceExpression(value), typeof initialValue !== 'undefined'
|
|
96
|
+
? 'initialValue'
|
|
97
|
+
: 'defaultValue');
|
|
98
|
+
}
|
|
86
99
|
}
|
|
87
100
|
if (onChange &&
|
|
88
101
|
value !== undefined &&
|
|
89
102
|
model.tmpValue !== undefined) {
|
|
90
103
|
// 组件默认值支持表达式需要: 避免初始化时上下文中丢失组件默认值
|
|
91
|
-
|
|
104
|
+
if (model.extraName) {
|
|
105
|
+
var values = model.splitExtraValue(model.tmpValue);
|
|
106
|
+
onChange(values[0], model.name, false, true);
|
|
107
|
+
onChange(values[1], model.extraName, false, true);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
onChange(model.tmpValue, model.name, false, true);
|
|
111
|
+
}
|
|
92
112
|
}
|
|
93
113
|
else if (onChange &&
|
|
94
114
|
typeof propValue === 'undefined' &&
|
|
@@ -98,7 +118,14 @@ function wrapControl(ComposedComponent) {
|
|
|
98
118
|
// 对应 issue 为 https://github.com/baidu/amis/issues/2674
|
|
99
119
|
(store === null || store === void 0 ? void 0 : store.storeType) !== TableStore.name) {
|
|
100
120
|
// 如果没有初始值,通过 onChange 设置过去
|
|
101
|
-
|
|
121
|
+
if (model.extraName) {
|
|
122
|
+
var values = model.splitExtraValue(model.tmpValue);
|
|
123
|
+
onChange(values[0], model.name, false, true);
|
|
124
|
+
onChange(values[1], model.extraName, false, true);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
onChange(model.tmpValue, model.name, false, true);
|
|
128
|
+
}
|
|
102
129
|
}
|
|
103
130
|
return _this;
|
|
104
131
|
}
|
|
@@ -125,7 +152,7 @@ function wrapControl(ComposedComponent) {
|
|
|
125
152
|
}
|
|
126
153
|
};
|
|
127
154
|
class_1.prototype.componentDidUpdate = function (prevProps) {
|
|
128
|
-
var _a, _b;
|
|
155
|
+
var _a, _b, _c;
|
|
129
156
|
var props = this.props;
|
|
130
157
|
props.formStore;
|
|
131
158
|
var model = this.model;
|
|
@@ -150,7 +177,8 @@ function wrapControl(ComposedComponent) {
|
|
|
150
177
|
'validateApi',
|
|
151
178
|
'minLength',
|
|
152
179
|
'maxLength',
|
|
153
|
-
'label'
|
|
180
|
+
'label',
|
|
181
|
+
'extraName'
|
|
154
182
|
], prevProps.$schema, props.$schema)) {
|
|
155
183
|
model.config({
|
|
156
184
|
required: props.$schema.required,
|
|
@@ -173,7 +201,8 @@ function wrapControl(ComposedComponent) {
|
|
|
173
201
|
minLength: props.$schema.minLength,
|
|
174
202
|
maxLength: props.$schema.maxLength,
|
|
175
203
|
label: props.$schema.label,
|
|
176
|
-
inputGroupControl: props === null || props === void 0 ? void 0 : props.inputGroupControl
|
|
204
|
+
inputGroupControl: props === null || props === void 0 ? void 0 : props.inputGroupControl,
|
|
205
|
+
extraName: props.$schema.extraName
|
|
177
206
|
});
|
|
178
207
|
}
|
|
179
208
|
// 此处需要同时考虑 defaultValue 和 value
|
|
@@ -187,31 +216,27 @@ function wrapControl(ComposedComponent) {
|
|
|
187
216
|
}
|
|
188
217
|
else if (model &&
|
|
189
218
|
typeof props.defaultValue !== 'undefined' &&
|
|
190
|
-
isExpression(props.defaultValue)
|
|
191
|
-
|
|
192
|
-
// 渲染器中的 defaultValue 优先(备注: SchemaRenderer中会将 value 改成 defaultValue)
|
|
193
|
-
if (!isEqual(props.defaultValue, prevProps.defaultValue) ||
|
|
219
|
+
isExpression(props.defaultValue) &&
|
|
220
|
+
(!isEqual(props.defaultValue, prevProps.defaultValue) ||
|
|
194
221
|
(props.data !== prevProps.data &&
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
222
|
+
isNeedFormula(props.defaultValue, props.data, prevProps.data)))) {
|
|
223
|
+
var curResult = FormulaExec['formula'](props.defaultValue, props.data);
|
|
224
|
+
var prevResult = FormulaExec['formula'](prevProps.defaultValue, prevProps.data);
|
|
225
|
+
if (!isEqual(curResult, prevResult) &&
|
|
226
|
+
!isEqual(curResult, model.tmpValue)) {
|
|
227
|
+
// 识别上下文变动、自身数值变动、公式运算结果变动
|
|
228
|
+
model.changeTmpValue(curResult, 'formulaChanged');
|
|
229
|
+
if (model.extraName) {
|
|
230
|
+
var values = model.splitExtraValue(curResult);
|
|
231
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, values[0], model.name, false);
|
|
232
|
+
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, values[1], model.extraName, false);
|
|
204
233
|
}
|
|
205
|
-
else
|
|
206
|
-
|
|
207
|
-
// now 表达式,计算后的值永远相同
|
|
208
|
-
model.changeTmpValue(nowData, 'formulaChanged');
|
|
209
|
-
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, nowData, model.name, false);
|
|
234
|
+
else {
|
|
235
|
+
(_c = props.onChange) === null || _c === void 0 ? void 0 : _c.call(props, curResult, model.name, false);
|
|
210
236
|
}
|
|
211
237
|
}
|
|
212
238
|
}
|
|
213
239
|
else if (model) {
|
|
214
|
-
var valueByName = getVariable(props.data, model.name);
|
|
215
240
|
// value 非公式表达式时,name 值优先,若 defaultValue 主动变动时,则使用 defaultValue
|
|
216
241
|
if (
|
|
217
242
|
// 然后才是查看关联的 name 属性值是否变化
|
|
@@ -219,11 +244,19 @@ function wrapControl(ComposedComponent) {
|
|
|
219
244
|
(!model.emitedValue ||
|
|
220
245
|
isEqual(model.emitedValue, model.tmpValue))) {
|
|
221
246
|
model.changeEmitedValue(undefined);
|
|
222
|
-
var
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
getVariable(
|
|
226
|
-
|
|
247
|
+
var valueByName = model.extraName
|
|
248
|
+
? [
|
|
249
|
+
getVariable(props.data, model.name, false),
|
|
250
|
+
getVariable(props.data, model.extraName, false)
|
|
251
|
+
]
|
|
252
|
+
: getVariable(props.data, model.name, false);
|
|
253
|
+
if (!isEqual(valueByName, model.extraName
|
|
254
|
+
? model.splitExtraValue(model.tmpValue)
|
|
255
|
+
: model.tmpValue) &&
|
|
256
|
+
(!isEqual(model.extraName ? valueByName[0] : valueByName, getVariable(prevProps.data, model.name, false)) ||
|
|
257
|
+
// extraName
|
|
258
|
+
(model.extraName &&
|
|
259
|
+
!isEqual(valueByName[1], getVariable(prevProps.data, model.extraName, false))))) {
|
|
227
260
|
model.changeTmpValue(valueByName, props.formInited && !prevProps.formInited
|
|
228
261
|
? 'formInited'
|
|
229
262
|
: 'dataChanged');
|
|
@@ -374,7 +407,7 @@ function wrapControl(ComposedComponent) {
|
|
|
374
407
|
}
|
|
375
408
|
if (pipeOut) {
|
|
376
409
|
var oldValue = this.model.value;
|
|
377
|
-
value = pipeOut(value, oldValue, data);
|
|
410
|
+
value = pipeOut.call(this, value, oldValue, data);
|
|
378
411
|
}
|
|
379
412
|
this.model.changeTmpValue(value, 'input');
|
|
380
413
|
if (changeImmediately || conrolChangeImmediately || !formInited) {
|
|
@@ -391,9 +424,15 @@ function wrapControl(ComposedComponent) {
|
|
|
391
424
|
if (!this.model) {
|
|
392
425
|
return;
|
|
393
426
|
}
|
|
427
|
+
var model = this.model;
|
|
394
428
|
var value = this.model.tmpValue;
|
|
395
|
-
var oldValue =
|
|
396
|
-
|
|
429
|
+
var oldValue = model.extraName
|
|
430
|
+
? [
|
|
431
|
+
getVariable(data, model.name, false),
|
|
432
|
+
getVariable(data, model.extraName, false)
|
|
433
|
+
]
|
|
434
|
+
: getVariable(data, model.name, false);
|
|
435
|
+
if (model.extraName ? isEqual(oldValue, value) : oldValue === value) {
|
|
397
436
|
return;
|
|
398
437
|
}
|
|
399
438
|
if (type !== 'input-password') {
|
|
@@ -416,7 +455,14 @@ function wrapControl(ComposedComponent) {
|
|
|
416
455
|
if (!this.model) {
|
|
417
456
|
return;
|
|
418
457
|
}
|
|
419
|
-
|
|
458
|
+
if (model.extraName) {
|
|
459
|
+
var values = model.splitExtraValue(value);
|
|
460
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values[0], name);
|
|
461
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values[1], model.extraName, submitOnChange === true);
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, submitOnChange === true);
|
|
465
|
+
}
|
|
420
466
|
this.checkValidate();
|
|
421
467
|
};
|
|
422
468
|
class_1.prototype.handleBlur = function (e) {
|
|
@@ -430,17 +476,25 @@ function wrapControl(ComposedComponent) {
|
|
|
430
476
|
if (!this.model) {
|
|
431
477
|
return;
|
|
432
478
|
}
|
|
479
|
+
var model = this.model;
|
|
433
480
|
var _a = this.props; _a.formStore; var name = _a.name, pipeOut = _a.$schema.pipeOut, onChange = _a.onChange, oldValue = _a.value, data = _a.data;
|
|
434
481
|
if (pipeOut) {
|
|
435
|
-
value = pipeOut(value, oldValue, data);
|
|
482
|
+
value = pipeOut.call(this, value, oldValue, data);
|
|
483
|
+
}
|
|
484
|
+
if (model.extraName) {
|
|
485
|
+
var values = model.splitExtraValue(value);
|
|
486
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values[0], name, false, true);
|
|
487
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values[1], model.extraName, false, true);
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, false, true);
|
|
436
491
|
}
|
|
437
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, false, true);
|
|
438
492
|
};
|
|
439
493
|
class_1.prototype.getValue = function () {
|
|
440
494
|
var _a = this.props, data = _a.formStore, control = _a.$schema;
|
|
441
495
|
var value = this.model ? this.model.tmpValue : control.value;
|
|
442
496
|
if (control.pipeIn) {
|
|
443
|
-
value = control.pipeIn(value, data);
|
|
497
|
+
value = control.pipeIn.call(this, value, data);
|
|
444
498
|
}
|
|
445
499
|
return value;
|
|
446
500
|
};
|
package/esm/store/app.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
|
|
|
@@ -20,14 +20,14 @@ import 'moment';
|
|
|
20
20
|
import '../utils/debug.js';
|
|
21
21
|
import 'react-dom';
|
|
22
22
|
import '../utils/errors.js';
|
|
23
|
-
import '../utils/tpl.js';
|
|
23
|
+
import { filter } from '../utils/tpl.js';
|
|
24
24
|
import 'classnames';
|
|
25
25
|
import '../utils/filter.js';
|
|
26
26
|
import 'lodash/isObject';
|
|
27
27
|
import 'lodash/isString';
|
|
28
28
|
import 'lodash/isBoolean';
|
|
29
|
-
import 'lodash';
|
|
30
29
|
import '../utils/image.js';
|
|
30
|
+
import 'lodash/isEqual';
|
|
31
31
|
import '../actions/Action.js';
|
|
32
32
|
import 'lodash/debounce';
|
|
33
33
|
import 'lodash/cloneDeep';
|
|
@@ -67,7 +67,11 @@ var AppStore = ServiceStore.named('AppStore')
|
|
|
67
67
|
path: item.path,
|
|
68
68
|
children: item.children,
|
|
69
69
|
className: item.className,
|
|
70
|
-
visible: visible
|
|
70
|
+
visible: visible,
|
|
71
|
+
badge: typeof item.badge === 'string'
|
|
72
|
+
? filter(item.badge, self.data)
|
|
73
|
+
: item.badge,
|
|
74
|
+
badgeClassName: filter(item.badgeClassName, self.data)
|
|
71
75
|
};
|
|
72
76
|
});
|
|
73
77
|
}
|