amis-core 3.1.1 → 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 +6 -2
- package/esm/Scoped.d.ts +4 -1
- package/esm/Scoped.js +9 -5
- package/esm/StatusScoped.js +1 -1
- package/esm/WithRootStore.d.ts +4 -24
- package/esm/WithRootStore.js +12 -4
- package/esm/WithStore.js +23 -16
- package/esm/actions/Action.d.ts +1 -0
- package/esm/actions/Action.js +70 -45
- 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 +47 -32
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +3 -2
- package/esm/actions/DialogAction.d.ts +2 -0
- package/esm/actions/DialogAction.js +39 -23
- 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 +3 -2
- package/esm/components/PopOver.js +3 -2
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.js +2 -2
- package/esm/index.d.ts +3 -1
- package/esm/index.js +16 -14
- package/esm/locale.js +1 -1
- package/esm/polyfills.d.ts +3 -0
- package/esm/polyfills.js +18 -0
- package/esm/renderers/Form.d.ts +7 -7
- package/esm/renderers/Form.js +182 -128
- package/esm/renderers/Item.d.ts +82 -77
- package/esm/renderers/Item.js +90 -74
- 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.d.ts +4 -24
- package/esm/renderers/wrapControl.js +140 -88
- package/esm/store/app.js +42 -4
- package/esm/store/combo.d.ts +564 -1892
- package/esm/store/combo.js +9 -2
- package/esm/store/crud.d.ts +4 -2
- package/esm/store/crud.js +17 -4
- package/esm/store/form.d.ts +182 -882
- package/esm/store/form.js +83 -81
- package/esm/store/formItem.d.ts +6 -2
- package/esm/store/formItem.js +19 -3
- package/esm/store/iRenderer.js +3 -2
- package/esm/store/index.js +1 -1
- package/esm/store/list.d.ts +1 -0
- package/esm/store/list.js +8 -2
- 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 +3 -2
- package/esm/store/service.js +17 -12
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +604 -2020
- package/esm/store/table.js +86 -56
- 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 +22 -5
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.d.ts +3 -2
- package/esm/utils/DataSchema.js +27 -7
- package/esm/utils/DataScope.d.ts +10 -3
- package/esm/utils/DataScope.js +50 -12
- 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 +152 -112
- package/esm/utils/arraySlice.d.ts +1 -0
- package/esm/utils/arraySlice.js +76 -0
- 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 +29 -19
- 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 +4 -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 +19 -2
- package/esm/utils/helper.js +69 -10
- 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 +2 -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 +18 -9
- 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 +13 -6
- package/lib/Scoped.d.ts +4 -1
- package/lib/Scoped.js +19 -13
- package/lib/StatusScoped.js +5 -2
- package/lib/WithRootStore.d.ts +4 -24
- package/lib/WithRootStore.js +15 -4
- package/lib/WithStore.js +27 -17
- package/lib/actions/Action.d.ts +1 -0
- package/lib/actions/Action.js +70 -45
- 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 +47 -32
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +9 -5
- package/lib/actions/DialogAction.d.ts +2 -0
- package/lib/actions/DialogAction.js +39 -23
- 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 +15 -14
- package/lib/components/PopOver.js +12 -10
- package/lib/env.js +4 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.js +11 -9
- package/lib/index.d.ts +3 -1
- package/lib/index.js +26 -19
- package/lib/locale.js +6 -3
- package/lib/polyfills.d.ts +3 -0
- package/lib/polyfills.js +20 -0
- package/lib/renderers/Form.d.ts +7 -7
- package/lib/renderers/Form.js +194 -135
- package/lib/renderers/Item.d.ts +82 -77
- package/lib/renderers/Item.js +126 -104
- 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.d.ts +4 -24
- package/lib/renderers/wrapControl.js +143 -88
- package/lib/store/app.js +44 -3
- package/lib/store/combo.d.ts +564 -1892
- package/lib/store/combo.js +9 -2
- package/lib/store/crud.d.ts +4 -2
- package/lib/store/crud.js +17 -4
- package/lib/store/form.d.ts +182 -882
- package/lib/store/form.js +81 -79
- package/lib/store/formItem.d.ts +6 -2
- package/lib/store/formItem.js +19 -3
- package/lib/store/iRenderer.js +9 -5
- package/lib/store/index.js +1 -1
- package/lib/store/list.d.ts +1 -0
- package/lib/store/list.js +8 -2
- 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 +9 -5
- package/lib/store/service.js +17 -12
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +604 -2020
- package/lib/store/table.js +85 -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 +22 -5
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.d.ts +3 -2
- package/lib/utils/DataSchema.js +27 -7
- package/lib/utils/DataScope.d.ts +10 -3
- package/lib/utils/DataScope.js +50 -11
- 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 +151 -111
- package/lib/utils/arraySlice.d.ts +1 -0
- package/lib/utils/arraySlice.js +80 -0
- 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 +29 -19
- 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 +10 -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 +19 -2
- package/lib/utils/helper.js +70 -9
- 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 +2 -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 +18 -9
- 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 +9 -4
|
@@ -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
|
|
|
@@ -32,20 +32,23 @@ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
|
32
32
|
var hoistNonReactStatic__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonReactStatic);
|
|
33
33
|
var pick__default = /*#__PURE__*/_interopDefaultLegacy(pick);
|
|
34
34
|
|
|
35
|
+
var __react_jsx__ = require('react');
|
|
36
|
+
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
|
|
37
|
+
(__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
35
38
|
function wrapControl(ComposedComponent) {
|
|
36
39
|
var _a;
|
|
37
40
|
var result = hoistNonReactStatic__default["default"](WithRootStore.withRootStore(mobxReact.observer((_a = /** @class */ (function (_super) {
|
|
38
41
|
tslib.__extends(class_1, _super);
|
|
39
42
|
function class_1(props) {
|
|
40
43
|
var _this = this;
|
|
41
|
-
var _a
|
|
44
|
+
var _a;
|
|
42
45
|
_this = _super.call(this, props) || this;
|
|
43
46
|
_this.value = undefined;
|
|
44
47
|
_this.lazyEmitChange = debounce__default["default"](_this.emitChange.bind(_this), 250, {
|
|
45
48
|
trailing: true,
|
|
46
49
|
leading: false
|
|
47
50
|
});
|
|
48
|
-
var
|
|
51
|
+
var _b = _this.props, form = _b.formStore, formItem$1 = _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;
|
|
49
52
|
_this.getValue = _this.getValue.bind(_this);
|
|
50
53
|
_this.setValue = _this.setValue.bind(_this);
|
|
51
54
|
_this.handleChange = _this.handleChange.bind(_this);
|
|
@@ -76,7 +79,7 @@ function wrapControl(ComposedComponent) {
|
|
|
76
79
|
_this.model = model;
|
|
77
80
|
// @issue 打算干掉这个
|
|
78
81
|
formItem$1 === null || formItem$1 === void 0 ? void 0 : formItem$1.addSubFormItem(model);
|
|
79
|
-
model.config(tslib.__assign(tslib.__assign({}, pick__default["default"](tslib.__assign(tslib.__assign({}, ComposedComponent.defaultProps), _this.props.$schema), ['multiple'])), { id: id, type: type, required: required, unique: unique, value: value, isValueSchemaExp: formula.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 }));
|
|
82
|
+
model.config(tslib.__assign(tslib.__assign({}, pick__default["default"](tslib.__assign(tslib.__assign({}, ComposedComponent.defaultProps), _this.props.$schema), ['multiple'])), { id: id, type: type, required: required, unique: unique, value: value, isValueSchemaExp: formula.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 }));
|
|
80
83
|
// issue 这个逻辑应该在 combo 里面自己实现。
|
|
81
84
|
if (_this.model.unique &&
|
|
82
85
|
((_a = form === null || form === void 0 ? void 0 : form.parentStore) === null || _a === void 0 ? void 0 : _a.storeType) === combo.ComboStore.name) {
|
|
@@ -85,21 +88,42 @@ function wrapControl(ComposedComponent) {
|
|
|
85
88
|
}
|
|
86
89
|
if (propValue !== undefined && propValue !== null) {
|
|
87
90
|
// 同步 value: 优先使用 props 中的 value
|
|
88
|
-
model.changeTmpValue(propValue);
|
|
91
|
+
model.changeTmpValue(propValue, 'controlled');
|
|
89
92
|
}
|
|
90
93
|
else {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
var isExp = formula.isExpression(value);
|
|
95
|
+
if (isExp) {
|
|
96
|
+
model.changeTmpValue(formula.FormulaExec['formula'](value, data), // 对组件默认值进行运算
|
|
97
|
+
'formulaChanged');
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
var initialValue = model.extraName
|
|
101
|
+
? [
|
|
102
|
+
store === null || store === void 0 ? void 0 : store.getValueByName(model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData),
|
|
103
|
+
store === null || store === void 0 ? void 0 : store.getValueByName(model.extraName, form === null || form === void 0 ? void 0 : form.canAccessSuperData)
|
|
104
|
+
]
|
|
105
|
+
: store === null || store === void 0 ? void 0 : store.getValueByName(model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData);
|
|
106
|
+
if (model.extraName &&
|
|
107
|
+
initialValue.every(function (item) { return item === undefined; })) {
|
|
108
|
+
initialValue = undefined;
|
|
109
|
+
}
|
|
110
|
+
model.changeTmpValue(initialValue !== null && initialValue !== void 0 ? initialValue : formula.replaceExpression(value), typeof initialValue !== 'undefined'
|
|
111
|
+
? 'initialValue'
|
|
112
|
+
: 'defaultValue');
|
|
113
|
+
}
|
|
97
114
|
}
|
|
98
115
|
if (onChange &&
|
|
99
116
|
value !== undefined &&
|
|
100
117
|
model.tmpValue !== undefined) {
|
|
101
118
|
// 组件默认值支持表达式需要: 避免初始化时上下文中丢失组件默认值
|
|
102
|
-
|
|
119
|
+
if (model.extraName) {
|
|
120
|
+
var values = model.splitExtraValue(model.tmpValue);
|
|
121
|
+
onChange(values[0], model.name, false, true);
|
|
122
|
+
onChange(values[1], model.extraName, false, true);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
onChange(model.tmpValue, model.name, false, true);
|
|
126
|
+
}
|
|
103
127
|
}
|
|
104
128
|
else if (onChange &&
|
|
105
129
|
typeof propValue === 'undefined' &&
|
|
@@ -109,7 +133,14 @@ function wrapControl(ComposedComponent) {
|
|
|
109
133
|
// 对应 issue 为 https://github.com/baidu/amis/issues/2674
|
|
110
134
|
(store === null || store === void 0 ? void 0 : store.storeType) !== table.TableStore.name) {
|
|
111
135
|
// 如果没有初始值,通过 onChange 设置过去
|
|
112
|
-
|
|
136
|
+
if (model.extraName) {
|
|
137
|
+
var values = model.splitExtraValue(model.tmpValue);
|
|
138
|
+
onChange(values[0], model.name, false, true);
|
|
139
|
+
onChange(values[1], model.extraName, false, true);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
onChange(model.tmpValue, model.name, false, true);
|
|
143
|
+
}
|
|
113
144
|
}
|
|
114
145
|
return _this;
|
|
115
146
|
}
|
|
@@ -136,7 +167,7 @@ function wrapControl(ComposedComponent) {
|
|
|
136
167
|
}
|
|
137
168
|
};
|
|
138
169
|
class_1.prototype.componentDidUpdate = function (prevProps) {
|
|
139
|
-
var _a, _b;
|
|
170
|
+
var _a, _b, _c;
|
|
140
171
|
var props = this.props;
|
|
141
172
|
props.formStore;
|
|
142
173
|
var model = this.model;
|
|
@@ -161,7 +192,8 @@ function wrapControl(ComposedComponent) {
|
|
|
161
192
|
'validateApi',
|
|
162
193
|
'minLength',
|
|
163
194
|
'maxLength',
|
|
164
|
-
'label'
|
|
195
|
+
'label',
|
|
196
|
+
'extraName'
|
|
165
197
|
], prevProps.$schema, props.$schema)) {
|
|
166
198
|
model.config({
|
|
167
199
|
required: props.$schema.required,
|
|
@@ -184,7 +216,8 @@ function wrapControl(ComposedComponent) {
|
|
|
184
216
|
minLength: props.$schema.minLength,
|
|
185
217
|
maxLength: props.$schema.maxLength,
|
|
186
218
|
label: props.$schema.label,
|
|
187
|
-
inputGroupControl: props === null || props === void 0 ? void 0 : props.inputGroupControl
|
|
219
|
+
inputGroupControl: props === null || props === void 0 ? void 0 : props.inputGroupControl,
|
|
220
|
+
extraName: props.$schema.extraName
|
|
188
221
|
});
|
|
189
222
|
}
|
|
190
223
|
// 此处需要同时考虑 defaultValue 和 value
|
|
@@ -193,60 +226,56 @@ function wrapControl(ComposedComponent) {
|
|
|
193
226
|
if (!isEqual__default["default"](props.value, prevProps.value) &&
|
|
194
227
|
!isEqual__default["default"](props.value, model.tmpValue)) {
|
|
195
228
|
// 外部直接传入的 value 无需执行运算器
|
|
196
|
-
model.changeTmpValue(props.value);
|
|
229
|
+
model.changeTmpValue(props.value, 'controlled');
|
|
197
230
|
}
|
|
198
231
|
}
|
|
199
232
|
else if (model &&
|
|
200
233
|
typeof props.defaultValue !== 'undefined' &&
|
|
201
|
-
formula.isExpression(props.defaultValue)
|
|
202
|
-
|
|
203
|
-
// 渲染器中的 defaultValue 优先(备注: SchemaRenderer中会将 value 改成 defaultValue)
|
|
204
|
-
if (!isEqual__default["default"](props.defaultValue, prevProps.defaultValue) ||
|
|
234
|
+
formula.isExpression(props.defaultValue) &&
|
|
235
|
+
(!isEqual__default["default"](props.defaultValue, prevProps.defaultValue) ||
|
|
205
236
|
(props.data !== prevProps.data &&
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
237
|
+
formula.isNeedFormula(props.defaultValue, props.data, prevProps.data)))) {
|
|
238
|
+
var curResult = formula.FormulaExec['formula'](props.defaultValue, props.data);
|
|
239
|
+
var prevResult = formula.FormulaExec['formula'](prevProps.defaultValue, prevProps.data);
|
|
240
|
+
if (!isEqual__default["default"](curResult, prevResult) &&
|
|
241
|
+
!isEqual__default["default"](curResult, model.tmpValue)) {
|
|
242
|
+
// 识别上下文变动、自身数值变动、公式运算结果变动
|
|
243
|
+
model.changeTmpValue(curResult, 'formulaChanged');
|
|
244
|
+
if (model.extraName) {
|
|
245
|
+
var values = model.splitExtraValue(curResult);
|
|
246
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, values[0], model.name, false);
|
|
247
|
+
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, values[1], model.extraName, false);
|
|
215
248
|
}
|
|
216
|
-
else
|
|
217
|
-
|
|
218
|
-
// now 表达式,计算后的值永远相同
|
|
219
|
-
model.changeTmpValue(nowData);
|
|
220
|
-
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, nowData, model.name, false);
|
|
249
|
+
else {
|
|
250
|
+
(_c = props.onChange) === null || _c === void 0 ? void 0 : _c.call(props, curResult, model.name, false);
|
|
221
251
|
}
|
|
222
252
|
}
|
|
223
253
|
}
|
|
224
254
|
else if (model) {
|
|
225
|
-
|
|
226
|
-
if (
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
props.onChange(curValue, model.name, false);
|
|
255
|
+
// value 非公式表达式时,name 值优先,若 defaultValue 主动变动时,则使用 defaultValue
|
|
256
|
+
if (
|
|
257
|
+
// 然后才是查看关联的 name 属性值是否变化
|
|
258
|
+
props.data !== prevProps.data &&
|
|
259
|
+
(!model.emitedValue ||
|
|
260
|
+
isEqual__default["default"](model.emitedValue, model.tmpValue))) {
|
|
261
|
+
model.changeEmitedValue(undefined);
|
|
262
|
+
var valueByName = model.extraName
|
|
263
|
+
? [
|
|
264
|
+
getVariable.getVariable(props.data, model.name, false),
|
|
265
|
+
getVariable.getVariable(props.data, model.extraName, false)
|
|
266
|
+
]
|
|
267
|
+
: getVariable.getVariable(props.data, model.name, false);
|
|
268
|
+
if (!isEqual__default["default"](valueByName, model.extraName
|
|
269
|
+
? model.splitExtraValue(model.tmpValue)
|
|
270
|
+
: model.tmpValue) &&
|
|
271
|
+
(!isEqual__default["default"](model.extraName ? valueByName[0] : valueByName, getVariable.getVariable(prevProps.data, model.name, false)) ||
|
|
272
|
+
// extraName
|
|
273
|
+
(model.extraName &&
|
|
274
|
+
!isEqual__default["default"](valueByName[1], getVariable.getVariable(prevProps.data, model.extraName, false))))) {
|
|
275
|
+
model.changeTmpValue(valueByName, props.formInited && !prevProps.formInited
|
|
276
|
+
? 'formInited'
|
|
277
|
+
: 'dataChanged');
|
|
278
|
+
this.checkValidate();
|
|
250
279
|
}
|
|
251
280
|
}
|
|
252
281
|
}
|
|
@@ -317,14 +346,33 @@ function wrapControl(ComposedComponent) {
|
|
|
317
346
|
scoped.unRegisterComponent(originRef);
|
|
318
347
|
}
|
|
319
348
|
};
|
|
349
|
+
class_1.prototype.checkValidate = function () {
|
|
350
|
+
var _a;
|
|
351
|
+
if (!this.model)
|
|
352
|
+
return; // 如果 model 为 undefined 则直接返回
|
|
353
|
+
var validated = this.model.validated;
|
|
354
|
+
var _b = this.props, formSubmited = _b.formSubmited, validateOnChange = _b.validateOnChange;
|
|
355
|
+
if (
|
|
356
|
+
// 如果配置了 minLength 或者 maxLength 就切成及时验证
|
|
357
|
+
// this.model.rules.minLength ||
|
|
358
|
+
// this.model.rules.maxLength ||
|
|
359
|
+
validateOnChange === true ||
|
|
360
|
+
(validateOnChange !== false && (formSubmited || validated))) {
|
|
361
|
+
this.validate();
|
|
362
|
+
}
|
|
363
|
+
else if (validateOnChange === false) {
|
|
364
|
+
(_a = this.model) === null || _a === void 0 ? void 0 : _a.reset();
|
|
365
|
+
}
|
|
366
|
+
};
|
|
320
367
|
class_1.prototype.validate = function () {
|
|
321
368
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
322
|
-
var _a, form, data, formItemDispatchEvent, result, combo$1, group, validPromises
|
|
369
|
+
var _a, form, data, formItemDispatchEvent, result, combo$1, group, validPromises;
|
|
323
370
|
return tslib.__generator(this, function (_b) {
|
|
324
371
|
switch (_b.label) {
|
|
325
372
|
case 0:
|
|
373
|
+
if (!this.model)
|
|
374
|
+
return [2 /*return*/];
|
|
326
375
|
_a = this.props, form = _a.formStore, data = _a.data, formItemDispatchEvent = _a.formItemDispatchEvent;
|
|
327
|
-
if (!this.model) return [3 /*break*/, 4];
|
|
328
376
|
if (!(this.model.unique &&
|
|
329
377
|
(form === null || form === void 0 ? void 0 : form.parentStore) &&
|
|
330
378
|
form.parentStore.storeType === combo.ComboStore.name)) return [3 /*break*/, 2];
|
|
@@ -337,12 +385,9 @@ function wrapControl(ComposedComponent) {
|
|
|
337
385
|
case 1:
|
|
338
386
|
result = _b.sent();
|
|
339
387
|
return [3 /*break*/, 4];
|
|
340
|
-
case 2:
|
|
341
|
-
validPromises = form === null || form === void 0 ? void 0 : form.getItemsByName(this.model.name).map(function (item) { return item.validate(data); });
|
|
342
|
-
if (!(validPromises && validPromises.length)) return [3 /*break*/, 4];
|
|
343
|
-
return [4 /*yield*/, Promise.all(validPromises)];
|
|
388
|
+
case 2: return [4 /*yield*/, this.model.validate(data)];
|
|
344
389
|
case 3:
|
|
345
|
-
result = _b.sent();
|
|
390
|
+
result = [_b.sent()];
|
|
346
391
|
_b.label = 4;
|
|
347
392
|
case 4:
|
|
348
393
|
if (result && result.length) {
|
|
@@ -377,9 +422,9 @@ function wrapControl(ComposedComponent) {
|
|
|
377
422
|
}
|
|
378
423
|
if (pipeOut) {
|
|
379
424
|
var oldValue = this.model.value;
|
|
380
|
-
value = pipeOut(value, oldValue, data);
|
|
425
|
+
value = pipeOut.call(this, value, oldValue, data);
|
|
381
426
|
}
|
|
382
|
-
this.model.changeTmpValue(value);
|
|
427
|
+
this.model.changeTmpValue(value, 'input');
|
|
383
428
|
if (changeImmediately || conrolChangeImmediately || !formInited) {
|
|
384
429
|
this.emitChange(submitOnChange);
|
|
385
430
|
}
|
|
@@ -389,15 +434,20 @@ function wrapControl(ComposedComponent) {
|
|
|
389
434
|
}
|
|
390
435
|
};
|
|
391
436
|
class_1.prototype.emitChange = function (submitOnChange) {
|
|
392
|
-
var _a;
|
|
393
437
|
if (submitOnChange === void 0) { submitOnChange = this.props.$schema.submitOnChange; }
|
|
394
|
-
var
|
|
438
|
+
var _a = this.props, form = _a.formStore, onChange = _a.onChange, _b = _a.$schema, name = _b.name, id = _b.id, label = _b.label, type = _b.type, onFormItemChange = _b.onChange; _b.maxLength; _b.minLength; var data = _a.data, env = _a.env; _a.validateOnChange; _a.formSubmited;
|
|
395
439
|
if (!this.model) {
|
|
396
440
|
return;
|
|
397
441
|
}
|
|
442
|
+
var model = this.model;
|
|
398
443
|
var value = this.model.tmpValue;
|
|
399
|
-
var oldValue =
|
|
400
|
-
|
|
444
|
+
var oldValue = model.extraName
|
|
445
|
+
? [
|
|
446
|
+
getVariable.getVariable(data, model.name, false),
|
|
447
|
+
getVariable.getVariable(data, model.extraName, false)
|
|
448
|
+
]
|
|
449
|
+
: getVariable.getVariable(data, model.name, false);
|
|
450
|
+
if (model.extraName ? isEqual__default["default"](oldValue, value) : oldValue === value) {
|
|
401
451
|
return;
|
|
402
452
|
}
|
|
403
453
|
if (type !== 'input-password') {
|
|
@@ -420,19 +470,15 @@ function wrapControl(ComposedComponent) {
|
|
|
420
470
|
if (!this.model) {
|
|
421
471
|
return;
|
|
422
472
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
// this.model.rules.minLength ||
|
|
428
|
-
// this.model.rules.maxLength ||
|
|
429
|
-
validateOnChange === true ||
|
|
430
|
-
(validateOnChange !== false && (formSubmited || validated))) {
|
|
431
|
-
this.validate();
|
|
473
|
+
if (model.extraName) {
|
|
474
|
+
var values = model.splitExtraValue(value);
|
|
475
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values[0], name);
|
|
476
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values[1], model.extraName, submitOnChange === true);
|
|
432
477
|
}
|
|
433
|
-
else
|
|
434
|
-
|
|
478
|
+
else {
|
|
479
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, submitOnChange === true);
|
|
435
480
|
}
|
|
481
|
+
this.checkValidate();
|
|
436
482
|
};
|
|
437
483
|
class_1.prototype.handleBlur = function (e) {
|
|
438
484
|
var _a = this.props, onBlur = _a.onBlur, validateOnBlur = _a.$schema.validateOnBlur;
|
|
@@ -445,17 +491,25 @@ function wrapControl(ComposedComponent) {
|
|
|
445
491
|
if (!this.model) {
|
|
446
492
|
return;
|
|
447
493
|
}
|
|
494
|
+
var model = this.model;
|
|
448
495
|
var _a = this.props; _a.formStore; var name = _a.name, pipeOut = _a.$schema.pipeOut, onChange = _a.onChange, oldValue = _a.value, data = _a.data;
|
|
449
496
|
if (pipeOut) {
|
|
450
|
-
value = pipeOut(value, oldValue, data);
|
|
497
|
+
value = pipeOut.call(this, value, oldValue, data);
|
|
498
|
+
}
|
|
499
|
+
if (model.extraName) {
|
|
500
|
+
var values = model.splitExtraValue(value);
|
|
501
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values[0], name, false, true);
|
|
502
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(values[1], model.extraName, false, true);
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, false, true);
|
|
451
506
|
}
|
|
452
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(value, name, false, true);
|
|
453
507
|
};
|
|
454
508
|
class_1.prototype.getValue = function () {
|
|
455
509
|
var _a = this.props, data = _a.formStore, control = _a.$schema;
|
|
456
510
|
var value = this.model ? this.model.tmpValue : control.value;
|
|
457
511
|
if (control.pipeIn) {
|
|
458
|
-
value = control.pipeIn(value, data);
|
|
512
|
+
value = control.pipeIn.call(this, value, data);
|
|
459
513
|
}
|
|
460
514
|
return value;
|
|
461
515
|
};
|
|
@@ -489,6 +543,7 @@ function wrapControl(ComposedComponent) {
|
|
|
489
543
|
ref: this.controlRef,
|
|
490
544
|
data: data || (store === null || store === void 0 ? void 0 : store.data),
|
|
491
545
|
value: value,
|
|
546
|
+
changeMotivation: model === null || model === void 0 ? void 0 : model.changeMotivation,
|
|
492
547
|
defaultValue: control.value,
|
|
493
548
|
formItemValue: value,
|
|
494
549
|
onChange: this.handleChange,
|
|
@@ -500,7 +555,7 @@ function wrapControl(ComposedComponent) {
|
|
|
500
555
|
// !没了这个, tree 里的 options 渲染会出问题
|
|
501
556
|
_filteredOptions: (_a = this.model) === null || _a === void 0 ? void 0 : _a.filteredOptions
|
|
502
557
|
};
|
|
503
|
-
return (
|
|
558
|
+
return (_J$X_(ComposedComponent, tslib.__assign({}, this.props, injectedProps)));
|
|
504
559
|
};
|
|
505
560
|
return class_1;
|
|
506
561
|
}(React__default["default"].Component)),
|
package/lib/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
|
|
|
@@ -11,7 +11,44 @@ var tslib = require('tslib');
|
|
|
11
11
|
var mobxStateTree = require('mobx-state-tree');
|
|
12
12
|
var helper = require('../utils/helper.js');
|
|
13
13
|
var service = require('./service.js');
|
|
14
|
+
require('../utils/api.js');
|
|
15
|
+
require('../utils/ColorScale.js');
|
|
16
|
+
require('../utils/columnsSplit.js');
|
|
17
|
+
require('amis-formula');
|
|
18
|
+
require('lodash/isPlainObject');
|
|
14
19
|
var object = require('../utils/object.js');
|
|
20
|
+
require('../utils/DataSchema.js');
|
|
21
|
+
require('../utils/DataScope.js');
|
|
22
|
+
require('moment');
|
|
23
|
+
require('../utils/debug.js');
|
|
24
|
+
require('../utils/dom.js');
|
|
25
|
+
require('../utils/errors.js');
|
|
26
|
+
var tpl = require('../utils/tpl.js');
|
|
27
|
+
require('classnames');
|
|
28
|
+
require('../utils/filter.js');
|
|
29
|
+
require('lodash/isObject');
|
|
30
|
+
require('lodash/isString');
|
|
31
|
+
require('lodash/isBoolean');
|
|
32
|
+
require('../utils/highlight.js');
|
|
33
|
+
require('../utils/icon.js');
|
|
34
|
+
require('../utils/image.js');
|
|
35
|
+
require('lodash/isEqual');
|
|
36
|
+
require('../actions/Action.js');
|
|
37
|
+
require('lodash/debounce');
|
|
38
|
+
require('lodash/cloneDeep');
|
|
39
|
+
require('../utils/resize-sensor.js');
|
|
40
|
+
require('react');
|
|
41
|
+
require('react-overlays/useRootClose');
|
|
42
|
+
require('react-dom');
|
|
43
|
+
require('../utils/SimpleMap.js');
|
|
44
|
+
require('lodash/mapValues');
|
|
45
|
+
require('lodash/camelCase');
|
|
46
|
+
require('uncontrollable');
|
|
47
|
+
require('hoist-non-react-statics');
|
|
48
|
+
require('../utils/validations.js');
|
|
49
|
+
require('../utils/resolveCondition.js');
|
|
50
|
+
require('mobx');
|
|
51
|
+
require('../utils/Animation.js');
|
|
15
52
|
|
|
16
53
|
var AppStore = service.ServiceStore.named('AppStore')
|
|
17
54
|
.props({
|
|
@@ -24,7 +61,7 @@ var AppStore = service.ServiceStore.named('AppStore')
|
|
|
24
61
|
get navigations() {
|
|
25
62
|
if (Array.isArray(self.pages)) {
|
|
26
63
|
return helper.mapTree(self.pages, function (item) {
|
|
27
|
-
var visible = item.
|
|
64
|
+
var visible = helper.isVisible(item, self.data);
|
|
28
65
|
if (visible !== false &&
|
|
29
66
|
item.path &&
|
|
30
67
|
!~item.path.indexOf('http') &&
|
|
@@ -37,7 +74,11 @@ var AppStore = service.ServiceStore.named('AppStore')
|
|
|
37
74
|
path: item.path,
|
|
38
75
|
children: item.children,
|
|
39
76
|
className: item.className,
|
|
40
|
-
visible: visible
|
|
77
|
+
visible: visible,
|
|
78
|
+
badge: typeof item.badge === 'string'
|
|
79
|
+
? tpl.filter(item.badge, self.data)
|
|
80
|
+
: item.badge,
|
|
81
|
+
badgeClassName: tpl.filter(item.badgeClassName, self.data)
|
|
41
82
|
};
|
|
42
83
|
});
|
|
43
84
|
}
|