amis-core 6.0.0 → 6.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.js +2 -2
- package/esm/RootRenderer.js +4 -3
- package/esm/SchemaRenderer.js +5 -2
- package/esm/Scoped.d.ts +6 -0
- package/esm/Scoped.js +45 -8
- package/esm/StatusScoped.js +2 -2
- package/esm/WithRootStore.js +2 -2
- package/esm/WithStore.js +4 -6
- 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.js +2 -2
- package/esm/actions/ContinueAction.js +2 -2
- package/esm/actions/CopyAction.js +2 -2
- package/esm/actions/CustomAction.js +3 -3
- 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 +10 -5
- package/esm/actions/LoopAction.js +2 -2
- package/esm/actions/PageAction.js +2 -2
- package/esm/actions/ParallelAction.js +2 -2
- package/esm/actions/StatusAction.js +2 -2
- package/esm/actions/SwitchAction.js +2 -2
- package/esm/actions/ToastAction.js +2 -2
- package/esm/components/CustomStyle.d.ts +1 -2
- package/esm/components/CustomStyle.js +20 -7
- package/esm/components/ErrorBoundary.js +2 -2
- package/esm/components/LazyComponent.js +2 -2
- package/esm/components/Overlay.js +11 -9
- package/esm/components/PopOver.js +7 -5
- package/esm/env.d.ts +4 -0
- package/esm/env.js +2 -2
- package/esm/envOverwrite.js +2 -2
- package/esm/factory.js +15 -2
- package/esm/index.d.ts +2 -2
- package/esm/index.js +13 -8
- package/esm/locale.js +2 -2
- package/esm/polyfills.js +2 -2
- package/esm/renderers/Form.d.ts +4 -3
- package/esm/renderers/Form.js +94 -42
- package/esm/renderers/Item.d.ts +1 -0
- package/esm/renderers/Item.js +15 -16
- package/esm/renderers/Options.d.ts +5 -0
- package/esm/renderers/Options.js +27 -10
- 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 +37 -29
- package/esm/store/app.js +3 -3
- package/esm/store/combo.d.ts +48 -24
- package/esm/store/combo.js +2 -2
- package/esm/store/crud.js +2 -2
- package/esm/store/form.d.ts +20 -10
- package/esm/store/form.js +2 -2
- package/esm/store/formItem.d.ts +2 -1
- package/esm/store/formItem.js +4 -3
- package/esm/store/iRenderer.js +5 -3
- 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 +3 -3
- package/esm/store/service.js +2 -2
- package/esm/store/status.js +2 -2
- package/esm/store/table.d.ts +42 -20
- package/esm/store/table.js +33 -19
- package/esm/store/table2.js +2 -2
- package/esm/theme.js +2 -2
- 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 +2 -2
- package/esm/utils/arraySlice.js +2 -2
- package/esm/utils/attachmentAdpator.js +2 -2
- package/esm/utils/autobind.js +2 -2
- package/esm/utils/browser.js +2 -2
- package/esm/utils/columnsSplit.js +2 -2
- package/esm/utils/concatData.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.d.ts +8 -1
- package/esm/utils/helper.js +28 -10
- package/esm/utils/highlight.js +4 -3
- package/esm/utils/icon.js +2 -2
- package/esm/utils/image.js +2 -2
- package/esm/utils/index.d.ts +1 -0
- 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/labelToString.d.ts +1 -0
- package/esm/utils/labelToString.js +38 -0
- package/esm/utils/makeSorter.js +2 -2
- package/esm/utils/math.js +2 -2
- package/esm/utils/memoryParse.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 +10 -12
- package/esm/utils/resize-sensor.js +2 -2
- package/esm/utils/resolveCondition.js +2 -2
- package/esm/utils/resolveVariable.js +2 -2
- package/esm/utils/resolveVariableAndFilter.js +2 -2
- package/esm/utils/resolveVariableAndFilterForAsync.js +2 -2
- package/esm/utils/scrollPosition.js +2 -2
- package/esm/utils/string2regExp.d.ts +1 -1
- package/esm/utils/string2regExp.js +5 -4
- package/esm/utils/stripNumber.js +2 -2
- package/esm/utils/style-helper.d.ts +24 -5
- package/esm/utils/style-helper.js +47 -17
- package/esm/utils/style.js +2 -2
- package/esm/utils/toNumber.js +2 -2
- package/esm/utils/tokenize.d.ts +1 -0
- package/esm/utils/tokenize.js +11 -4
- package/esm/utils/tpl-builtin.js +2 -2
- package/esm/utils/tpl-lodash.js +2 -2
- package/esm/utils/tpl.js +7 -9
- package/esm/utils/uncontrollable.js +2 -2
- package/esm/utils/validateId.d.ts +16 -0
- package/esm/utils/validateId.js +154 -0
- package/esm/utils/validations.js +17 -9
- package/lib/Root.js +2 -2
- package/lib/RootRenderer.d.ts +1 -1
- package/lib/RootRenderer.js +4 -3
- package/lib/SchemaRenderer.js +5 -2
- package/lib/Scoped.d.ts +6 -0
- package/lib/Scoped.js +45 -7
- package/lib/StatusScoped.js +2 -2
- package/lib/WithRootStore.js +2 -2
- package/lib/WithStore.js +4 -6
- 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.js +2 -2
- package/lib/actions/ContinueAction.js +2 -2
- package/lib/actions/CopyAction.js +2 -2
- package/lib/actions/CustomAction.js +3 -3
- 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 +10 -5
- package/lib/actions/LoopAction.js +2 -2
- package/lib/actions/PageAction.js +2 -2
- package/lib/actions/ParallelAction.js +2 -2
- package/lib/actions/StatusAction.js +2 -2
- package/lib/actions/SwitchAction.js +2 -2
- package/lib/actions/ToastAction.js +2 -2
- package/lib/components/CustomStyle.d.ts +1 -2
- package/lib/components/CustomStyle.js +20 -7
- package/lib/components/ErrorBoundary.js +2 -2
- package/lib/components/LazyComponent.js +2 -2
- package/lib/components/Overlay.js +10 -8
- package/lib/components/PopOver.js +7 -5
- package/lib/env.d.ts +4 -0
- package/lib/env.js +2 -2
- package/lib/envOverwrite.js +2 -2
- package/lib/factory.js +15 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.js +16 -5
- package/lib/locale.js +2 -2
- package/lib/polyfills.js +2 -2
- package/lib/renderers/Form.d.ts +4 -3
- package/lib/renderers/Form.js +94 -42
- package/lib/renderers/Item.d.ts +1 -0
- package/lib/renderers/Item.js +15 -16
- package/lib/renderers/Options.d.ts +5 -0
- package/lib/renderers/Options.js +27 -10
- 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 +36 -28
- package/lib/store/app.js +3 -3
- package/lib/store/combo.d.ts +72 -49
- package/lib/store/combo.js +2 -2
- package/lib/store/crud.js +2 -2
- package/lib/store/form.d.ts +30 -21
- package/lib/store/form.js +2 -2
- package/lib/store/formItem.d.ts +2 -1
- package/lib/store/formItem.js +4 -3
- package/lib/store/iRenderer.js +5 -3
- 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 +3 -3
- package/lib/store/service.js +2 -2
- package/lib/store/status.js +2 -2
- package/lib/store/table.d.ts +62 -41
- package/lib/store/table.js +33 -19
- package/lib/store/table2.js +2 -2
- package/lib/theme.js +2 -2
- 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 +2 -2
- package/lib/utils/arraySlice.js +2 -2
- package/lib/utils/attachmentAdpator.js +2 -2
- package/lib/utils/autobind.js +2 -2
- package/lib/utils/browser.js +2 -2
- package/lib/utils/columnsSplit.js +2 -2
- package/lib/utils/concatData.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.d.ts +8 -1
- package/lib/utils/helper.js +29 -8
- package/lib/utils/highlight.js +4 -3
- package/lib/utils/icon.js +2 -2
- package/lib/utils/image.js +2 -2
- package/lib/utils/index.d.ts +1 -0
- 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/labelToString.d.ts +1 -0
- package/lib/utils/labelToString.js +46 -0
- package/lib/utils/makeSorter.js +2 -2
- package/lib/utils/math.js +2 -2
- package/lib/utils/memoryParse.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 +9 -15
- package/lib/utils/resize-sensor.js +2 -2
- package/lib/utils/resolveCondition.js +2 -2
- package/lib/utils/resolveVariable.js +2 -2
- package/lib/utils/resolveVariableAndFilter.js +2 -2
- package/lib/utils/resolveVariableAndFilterForAsync.js +2 -2
- package/lib/utils/scrollPosition.js +2 -2
- package/lib/utils/string2regExp.d.ts +1 -1
- package/lib/utils/string2regExp.js +5 -4
- package/lib/utils/stripNumber.js +2 -2
- package/lib/utils/style-helper.d.ts +24 -5
- package/lib/utils/style-helper.js +47 -17
- package/lib/utils/style.js +2 -2
- package/lib/utils/toNumber.js +2 -2
- package/lib/utils/tokenize.d.ts +1 -0
- package/lib/utils/tokenize.js +11 -3
- package/lib/utils/tpl-builtin.js +2 -2
- package/lib/utils/tpl-lodash.js +2 -2
- package/lib/utils/tpl.js +6 -8
- package/lib/utils/uncontrollable.js +2 -2
- package/lib/utils/validateId.d.ts +16 -0
- package/lib/utils/validateId.js +160 -0
- package/lib/utils/validations.js +17 -9
- package/package.json +3 -3
- package/LICENSE +0 -201
package/lib/renderers/Options.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.
|
|
3
|
-
* Copyright 2018-
|
|
2
|
+
* amis-core v6.1.0
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
'use strict';
|
|
@@ -43,13 +43,13 @@ require('../utils/icon.js');
|
|
|
43
43
|
require('../utils/image.js');
|
|
44
44
|
var keyToPath = require('../utils/keyToPath.js');
|
|
45
45
|
var rendererEvent = require('../utils/renderer-event.js');
|
|
46
|
-
require('lodash/cloneDeep');
|
|
47
46
|
require('../utils/resize-sensor.js');
|
|
48
47
|
require('react-overlays/useRootClose');
|
|
49
48
|
require('react-dom');
|
|
50
49
|
require('../utils/SimpleMap.js');
|
|
51
50
|
require('lodash/mapValues');
|
|
52
51
|
require('lodash/camelCase');
|
|
52
|
+
require('lodash/cloneDeep');
|
|
53
53
|
require('lodash/map');
|
|
54
54
|
require('lodash/isEmpty');
|
|
55
55
|
require('lodash/kebabCase');
|
|
@@ -96,6 +96,7 @@ function registerOptionsControl(config) {
|
|
|
96
96
|
_this = _super.call(this, props) || this;
|
|
97
97
|
_this.toDispose = [];
|
|
98
98
|
_this.mounted = false;
|
|
99
|
+
_this.initedFilled = false;
|
|
99
100
|
var initFetch = props.initFetch, formItem = props.formItem, source = props.source, data = props.data, setPrinstineValue = props.setPrinstineValue, defaultValue = props.defaultValue, multiple = props.multiple, joinValues = props.joinValues, extractValue = props.extractValue, addHook = props.addHook, formInited = props.formInited, valueField = props.valueField, options = props.options, value = props.value, defaultCheckAll = props.defaultCheckAll;
|
|
100
101
|
if (formItem) {
|
|
101
102
|
formItem.setOptions(normalizeOptions.normalizeOptions(options, undefined, valueField), _this.changeOptionValue, data);
|
|
@@ -104,12 +105,20 @@ function registerOptionsControl(config) {
|
|
|
104
105
|
return JSON.stringify(formItem.getSelectedOptions(formItem.tmpValue));
|
|
105
106
|
}, function () {
|
|
106
107
|
return _this.mounted &&
|
|
108
|
+
_this.initedFilled &&
|
|
107
109
|
_this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue));
|
|
108
110
|
}));
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
if (formInited || !addHook) {
|
|
112
|
+
_this.initedFilled = true;
|
|
113
|
+
_this.props.initAutoFill !== false &&
|
|
114
|
+
_this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue), _this.props.initAutoFill === 'fillIfNotSet');
|
|
115
|
+
}
|
|
116
|
+
else if (addHook) {
|
|
117
|
+
addHook(function () {
|
|
118
|
+
_this.initedFilled = true;
|
|
119
|
+
_this.props.initAutoFill !== false &&
|
|
120
|
+
_this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue), _this.props.initAutoFill === 'fillIfNotSet');
|
|
121
|
+
}, 'init');
|
|
113
122
|
}
|
|
114
123
|
// 默认全选。这里会和默认值\回填值逻辑冲突,所以如果有配置source则不执行默认全选
|
|
115
124
|
if (multiple &&
|
|
@@ -241,7 +250,8 @@ function registerOptionsControl(config) {
|
|
|
241
250
|
onChange === null || onChange === void 0 ? void 0 : onChange(resetValue !== null && resetValue !== void 0 ? resetValue : '');
|
|
242
251
|
}
|
|
243
252
|
};
|
|
244
|
-
FormOptionsItem.prototype.syncAutoFill = function (selectedOptions) {
|
|
253
|
+
FormOptionsItem.prototype.syncAutoFill = function (selectedOptions, skipIfExits) {
|
|
254
|
+
if (skipIfExits === void 0) { skipIfExits = false; }
|
|
245
255
|
var _a = this.props, autoFill = _a.autoFill, multiple = _a.multiple, onBulkChange = _a.onBulkChange, data = _a.data;
|
|
246
256
|
var formItem = this.props.formItem;
|
|
247
257
|
// 参照录入|自动填充
|
|
@@ -263,11 +273,18 @@ function registerOptionsControl(config) {
|
|
|
263
273
|
var result_1 = tslib.__assign({}, toSync_1);
|
|
264
274
|
Object.keys(autoFill).forEach(function (key) {
|
|
265
275
|
var keys = keyToPath.keyToPath(key);
|
|
276
|
+
var value = getVariable.getVariable(toSync_1, key);
|
|
277
|
+
if (skipIfExits) {
|
|
278
|
+
var originValue = getVariable.getVariable(data, key);
|
|
279
|
+
if (typeof originValue !== 'undefined') {
|
|
280
|
+
value = originValue;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
object.setVariable(result_1, key, value);
|
|
266
284
|
// 如果左边的 key 是一个路径
|
|
267
285
|
// 这里不希望直接把原始对象都给覆盖没了
|
|
268
286
|
// 而是保留原始的对象,只修改指定的属性
|
|
269
287
|
if (keys.length > 1 && isPlainObject__default["default"](tmpData_1[keys[0]])) {
|
|
270
|
-
var value = getVariable.getVariable(toSync_1, key);
|
|
271
288
|
// 存在情况:依次更新同一子路径的多个key,eg: a.b.c1 和 a.b.c2,所以需要同步更新data
|
|
272
289
|
object.setVariable(tmpData_1, key, value);
|
|
273
290
|
result_1[keys[0]] = tmpData_1[keys[0]];
|
|
@@ -935,7 +952,7 @@ function registerOptionsControl(config) {
|
|
|
935
952
|
: [], nodePath: nodePathArray, loading: formItem ? formItem.loading : false, setLoading: this.setLoading, setOptions: this.setOptions, syncOptions: this.syncOptions, reloadOptions: this.reload, deferLoad: this.deferLoad, leftDeferLoad: this.leftDeferLoad, expandTreeOptions: this.expandTreeOptions, creatable: creatable !== false && api.isEffectiveApi(addApi) ? true : creatable, editable: editable || (editable !== false && api.isEffectiveApi(editApi)), removable: removable || (removable !== false && api.isEffectiveApi(deleteApi)), onAdd: this.handleOptionAdd, onEdit: this.handleOptionEdit, onDelete: this.handleOptionDelete })));
|
|
936
953
|
};
|
|
937
954
|
FormOptionsItem.displayName = "OptionsControl(".concat(config.type, ")");
|
|
938
|
-
FormOptionsItem.defaultProps = tslib.__assign({ delimiter: ',', labelField: 'label', valueField: 'value', joinValues: true, extractValue: false, multiple: false, placeholder: 'Select.placeholder', resetValue: '', deleteConfirmText: 'deleteConfirm' }, Control.defaultProps);
|
|
955
|
+
FormOptionsItem.defaultProps = tslib.__assign({ delimiter: ',', labelField: 'label', valueField: 'value', joinValues: true, extractValue: false, multiple: false, placeholder: 'Select.placeholder', resetValue: '', deleteConfirmText: 'deleteConfirm', initAutoFill: 'fillIfNotSet' }, Control.defaultProps);
|
|
939
956
|
FormOptionsItem.propsList = Control.propsList
|
|
940
957
|
? tslib.__spreadArray([], tslib.__read(Control.propsList), false) : [];
|
|
941
958
|
FormOptionsItem.ComposedComponent = Control;
|
package/lib/renderers/builtin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.
|
|
3
|
-
* Copyright 2018-
|
|
2
|
+
* amis-core v6.1.0
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
'use strict';
|
|
@@ -42,13 +42,13 @@ require('../utils/highlight.js');
|
|
|
42
42
|
require('../utils/icon.js');
|
|
43
43
|
require('../utils/image.js');
|
|
44
44
|
require('../actions/Action.js');
|
|
45
|
-
require('lodash/cloneDeep');
|
|
46
45
|
require('../utils/resize-sensor.js');
|
|
47
46
|
require('react-overlays/useRootClose');
|
|
48
47
|
require('react-dom');
|
|
49
48
|
require('../utils/SimpleMap.js');
|
|
50
49
|
require('lodash/mapValues');
|
|
51
50
|
require('lodash/camelCase');
|
|
51
|
+
require('lodash/cloneDeep');
|
|
52
52
|
require('lodash/isObject');
|
|
53
53
|
require('lodash/map');
|
|
54
54
|
require('lodash/isEmpty');
|
|
@@ -128,26 +128,7 @@ function wrapControl(ComposedComponent) {
|
|
|
128
128
|
model.setIsControlled(true);
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
|
-
|
|
132
|
-
if (isExp) {
|
|
133
|
-
model.changeTmpValue(formula.FormulaExec['formula'](value, data), // 对组件默认值进行运算
|
|
134
|
-
'formulaChanged');
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
var initialValue = model.extraName
|
|
138
|
-
? [
|
|
139
|
-
store === null || store === void 0 ? void 0 : store.getValueByName(model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData),
|
|
140
|
-
store === null || store === void 0 ? void 0 : store.getValueByName(model.extraName, form === null || form === void 0 ? void 0 : form.canAccessSuperData)
|
|
141
|
-
]
|
|
142
|
-
: store === null || store === void 0 ? void 0 : store.getValueByName(model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData);
|
|
143
|
-
if (model.extraName &&
|
|
144
|
-
initialValue.every(function (item) { return item === undefined; })) {
|
|
145
|
-
initialValue = undefined;
|
|
146
|
-
}
|
|
147
|
-
model.changeTmpValue(initialValue !== null && initialValue !== void 0 ? initialValue : formula.replaceExpression(value), typeof initialValue !== 'undefined'
|
|
148
|
-
? 'initialValue'
|
|
149
|
-
: 'defaultValue');
|
|
150
|
-
}
|
|
131
|
+
_this.setInitialValue(value);
|
|
151
132
|
}
|
|
152
133
|
if (onChange &&
|
|
153
134
|
value !== undefined &&
|
|
@@ -185,9 +166,7 @@ function wrapControl(ComposedComponent) {
|
|
|
185
166
|
var _this = this;
|
|
186
167
|
var _a = this.props; _a.store; _a.formStore; var validate = _a.$schema.validate, addHook = _a.addHook;
|
|
187
168
|
// 提交前先把之前的 lazyEmit 执行一下。
|
|
188
|
-
this.hook3 = function () {
|
|
189
|
-
_this.lazyEmitChange.flush();
|
|
190
|
-
};
|
|
169
|
+
this.hook3 = function () { return _this.lazyEmitChange.flush(); };
|
|
191
170
|
addHook === null || addHook === void 0 ? void 0 : addHook(this.hook3, 'flush');
|
|
192
171
|
var formItem = this.model;
|
|
193
172
|
if (formItem && validate) {
|
|
@@ -204,6 +183,7 @@ function wrapControl(ComposedComponent) {
|
|
|
204
183
|
}
|
|
205
184
|
};
|
|
206
185
|
class_1.prototype.componentDidUpdate = function (prevProps) {
|
|
186
|
+
var _this = this;
|
|
207
187
|
var _a, _b, _c;
|
|
208
188
|
var props = this.props;
|
|
209
189
|
var model = this.model;
|
|
@@ -211,6 +191,7 @@ function wrapControl(ComposedComponent) {
|
|
|
211
191
|
return;
|
|
212
192
|
}
|
|
213
193
|
helper.changedEffect([
|
|
194
|
+
'name',
|
|
214
195
|
'id',
|
|
215
196
|
'validations',
|
|
216
197
|
'validationErrors',
|
|
@@ -237,6 +218,9 @@ function wrapControl(ComposedComponent) {
|
|
|
237
218
|
model.config(tslib.__assign(tslib.__assign({}, changes), {
|
|
238
219
|
// todo 优化后面两个
|
|
239
220
|
isValueSchemaExp: formula.isExpression(props.$schema.value), inputGroupControl: props === null || props === void 0 ? void 0 : props.inputGroupControl }));
|
|
221
|
+
if (changes.hasOwnProperty('name')) {
|
|
222
|
+
_this.setInitialValue(_this.props.$schema.value);
|
|
223
|
+
}
|
|
240
224
|
});
|
|
241
225
|
if (props.required !== prevProps.required) {
|
|
242
226
|
model.config({
|
|
@@ -312,6 +296,30 @@ function wrapControl(ComposedComponent) {
|
|
|
312
296
|
(_g = this.reaction) === null || _g === void 0 ? void 0 : _g.call(this);
|
|
313
297
|
this.disposeModel();
|
|
314
298
|
};
|
|
299
|
+
class_1.prototype.setInitialValue = function (value) {
|
|
300
|
+
var model = this.model;
|
|
301
|
+
var _a = this.props, form = _a.formStore, data = _a.data;
|
|
302
|
+
var isExp = formula.isExpression(value);
|
|
303
|
+
if (isExp) {
|
|
304
|
+
model.changeTmpValue(formula.FormulaExec['formula'](value, data), // 对组件默认值进行运算
|
|
305
|
+
'formulaChanged');
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
var initialValue = model.extraName
|
|
309
|
+
? [
|
|
310
|
+
getVariable.getVariable(data, model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData),
|
|
311
|
+
getVariable.getVariable(data, model.extraName, form === null || form === void 0 ? void 0 : form.canAccessSuperData)
|
|
312
|
+
]
|
|
313
|
+
: getVariable.getVariable(data, model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData);
|
|
314
|
+
if (model.extraName &&
|
|
315
|
+
initialValue.every(function (item) { return item === undefined; })) {
|
|
316
|
+
initialValue = undefined;
|
|
317
|
+
}
|
|
318
|
+
model.changeTmpValue(initialValue !== null && initialValue !== void 0 ? initialValue : formula.replaceExpression(value), typeof initialValue !== 'undefined'
|
|
319
|
+
? 'initialValue'
|
|
320
|
+
: 'defaultValue');
|
|
321
|
+
}
|
|
322
|
+
};
|
|
315
323
|
class_1.prototype.disposeModel = function () {
|
|
316
324
|
var _a;
|
|
317
325
|
var _b = this.props, form = _b.formStore, formItem = _b.formItem, rootStore = _b.rootStore;
|
|
@@ -524,10 +532,10 @@ function wrapControl(ComposedComponent) {
|
|
|
524
532
|
}
|
|
525
533
|
};
|
|
526
534
|
class_1.prototype.getValue = function () {
|
|
527
|
-
var _a = this.props,
|
|
535
|
+
var _a = this.props, formStore = _a.formStore, data = _a.data, control = _a.$schema;
|
|
528
536
|
var value = this.model ? this.model.tmpValue : control.value;
|
|
529
537
|
if (control.pipeIn) {
|
|
530
|
-
value = api.callStrFunction.call(this, control.pipeIn, ['value', 'data'], value, data);
|
|
538
|
+
value = api.callStrFunction.call(this, control.pipeIn, ['value', 'store', 'data'], value, formStore, data);
|
|
531
539
|
}
|
|
532
540
|
return value;
|
|
533
541
|
};
|
package/lib/store/app.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.
|
|
3
|
-
* Copyright 2018-
|
|
2
|
+
* amis-core v6.1.0
|
|
3
|
+
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
'use strict';
|
|
@@ -35,7 +35,6 @@ require('../utils/image.js');
|
|
|
35
35
|
require('lodash/isEqual');
|
|
36
36
|
require('../actions/Action.js');
|
|
37
37
|
require('lodash/debounce');
|
|
38
|
-
require('lodash/cloneDeep');
|
|
39
38
|
require('../utils/resize-sensor.js');
|
|
40
39
|
require('react');
|
|
41
40
|
require('react-overlays/useRootClose');
|
|
@@ -43,6 +42,7 @@ require('react-dom');
|
|
|
43
42
|
require('../utils/SimpleMap.js');
|
|
44
43
|
require('lodash/mapValues');
|
|
45
44
|
require('lodash/camelCase');
|
|
45
|
+
require('lodash/cloneDeep');
|
|
46
46
|
require('lodash/map');
|
|
47
47
|
require('lodash/isEmpty');
|
|
48
48
|
require('lodash/kebabCase');
|