amis-core 6.2.2 → 6.4.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 +28 -10
- package/esm/SchemaRenderer.js +17 -7
- package/esm/Scoped.d.ts +2 -1
- package/esm/Scoped.js +30 -14
- package/esm/StatusScoped.js +4 -2
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +28 -17
- package/esm/actions/Action.js +5 -3
- package/esm/actions/AjaxAction.js +29 -19
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.js +3 -3
- 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.d.ts +8 -0
- package/esm/actions/DialogAction.js +116 -40
- package/esm/actions/DrawerAction.d.ts +5 -0
- package/esm/actions/DrawerAction.js +74 -11
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/EventAction.d.ts +20 -0
- package/esm/actions/EventAction.js +102 -0
- 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/PrintAction.d.ts +2 -2
- package/esm/actions/PrintAction.js +6 -6
- package/esm/actions/StatusAction.js +1 -1
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +1 -1
- package/esm/actions/WaitAction.d.ts +18 -0
- package/esm/actions/WaitAction.js +41 -0
- package/esm/actions/index.d.ts +2 -0
- package/esm/components/CustomStyle.js +1 -4
- package/esm/components/ErrorBoundary.js +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.d.ts +3 -0
- package/esm/components/Overlay.js +7 -4
- package/esm/components/PopOver.js +2 -2
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.d.ts +3 -0
- package/esm/factory.js +1 -1
- package/esm/index.js +6 -4
- package/esm/locale.js +4 -2
- package/esm/polyfills.js +1 -1
- package/esm/renderers/Form.d.ts +6 -4
- package/esm/renderers/Form.js +134 -66
- package/esm/renderers/Item.d.ts +123 -79
- package/esm/renderers/Item.js +159 -60
- package/esm/renderers/Options.d.ts +0 -11
- package/esm/renderers/Options.js +20 -84
- 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 -1
- package/esm/renderers/wrapControl.js +34 -28
- package/esm/store/app.d.ts +5 -5
- package/esm/store/app.js +1 -1
- package/esm/store/combo.d.ts +255 -63
- package/esm/store/combo.js +1 -1
- package/esm/store/crud.d.ts +5 -5
- package/esm/store/crud.js +12 -6
- package/esm/store/form.d.ts +105 -25
- package/esm/store/form.js +33 -15
- package/esm/store/formItem.d.ts +6 -2
- package/esm/store/formItem.js +68 -5
- package/esm/store/iRenderer.d.ts +5 -5
- package/esm/store/iRenderer.js +28 -12
- package/esm/store/index.js +1 -1
- package/esm/store/list.d.ts +18 -5
- package/esm/store/list.js +14 -1
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.d.ts +5 -5
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.d.ts +5 -5
- package/esm/store/pagination.js +1 -1
- package/esm/store/root.d.ts +5 -5
- package/esm/store/root.js +1 -1
- package/esm/store/service.d.ts +5 -5
- package/esm/store/service.js +2 -2
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +244 -55
- package/esm/store/table.js +27 -9
- package/esm/store/table2.d.ts +5 -5
- package/esm/store/table2.js +1 -1
- package/esm/theme.js +4 -2
- package/esm/types.d.ts +7 -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.js +1 -1
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.js +1 -1
- package/esm/utils/arraySlice.js +1 -1
- package/esm/utils/attachmentAdpator.js +1 -1
- package/esm/utils/autobind.js +1 -1
- package/esm/utils/browser.js +1 -1
- package/esm/utils/columnsSplit.js +1 -1
- package/esm/utils/concatData.js +1 -1
- package/esm/utils/dataMapping.js +1 -1
- package/esm/utils/date.js +1 -1
- package/esm/utils/debug.js +1 -1
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.d.ts +2 -2
- package/esm/utils/dom.js +72 -13
- 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 +2 -2
- 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 +12 -6
- package/esm/utils/helper.js +41 -18
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.js +1 -1
- package/esm/utils/image.js +1 -1
- 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/labelToString.js +1 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/math.js +1 -1
- 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.js +1 -1
- 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/printElement.js +1 -1
- package/esm/utils/renderer-event.d.ts +13 -0
- package/esm/utils/renderer-event.js +111 -2
- 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.d.ts +1 -1
- package/esm/utils/stripNumber.js +4 -3
- package/esm/utils/style-helper.d.ts +21 -2
- package/esm/utils/style-helper.js +55 -10
- 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 +4 -4
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validateId.js +5 -2
- package/esm/utils/validations.js +1 -1
- package/lib/Root.js +1 -1
- package/lib/RootRenderer.d.ts +2 -2
- package/lib/RootRenderer.js +28 -10
- package/lib/SchemaRenderer.js +16 -6
- package/lib/Scoped.d.ts +2 -1
- package/lib/Scoped.js +30 -14
- package/lib/StatusScoped.js +4 -2
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +28 -17
- package/lib/actions/Action.js +5 -3
- package/lib/actions/AjaxAction.js +29 -19
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.js +3 -3
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +1 -1
- package/lib/actions/DialogAction.d.ts +8 -0
- package/lib/actions/DialogAction.js +119 -40
- package/lib/actions/DrawerAction.d.ts +5 -0
- package/lib/actions/DrawerAction.js +77 -11
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/EventAction.d.ts +20 -0
- package/lib/actions/EventAction.js +109 -0
- 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/PrintAction.d.ts +2 -2
- package/lib/actions/PrintAction.js +6 -6
- package/lib/actions/StatusAction.js +1 -1
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +1 -1
- package/lib/actions/WaitAction.d.ts +18 -0
- package/lib/actions/WaitAction.js +45 -0
- package/lib/actions/index.d.ts +2 -0
- package/lib/components/CustomStyle.js +1 -4
- package/lib/components/ErrorBoundary.js +1 -1
- package/lib/components/LazyComponent.js +1 -1
- package/lib/components/Overlay.d.ts +3 -0
- package/lib/components/Overlay.js +7 -4
- package/lib/components/PopOver.js +1 -1
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.d.ts +3 -0
- package/lib/factory.js +1 -1
- package/lib/index.js +6 -4
- package/lib/locale.js +4 -2
- package/lib/polyfills.js +1 -1
- package/lib/renderers/Form.d.ts +6 -4
- package/lib/renderers/Form.js +135 -65
- package/lib/renderers/Item.d.ts +123 -79
- package/lib/renderers/Item.js +158 -58
- package/lib/renderers/Options.d.ts +0 -11
- package/lib/renderers/Options.js +19 -84
- 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 -1
- package/lib/renderers/wrapControl.js +34 -28
- package/lib/store/app.d.ts +5 -5
- package/lib/store/app.js +1 -1
- package/lib/store/combo.d.ts +279 -88
- package/lib/store/combo.js +1 -1
- package/lib/store/crud.d.ts +5 -5
- package/lib/store/crud.js +12 -6
- package/lib/store/form.d.ts +115 -36
- package/lib/store/form.js +33 -15
- package/lib/store/formItem.d.ts +6 -2
- package/lib/store/formItem.js +67 -4
- package/lib/store/iRenderer.d.ts +5 -5
- package/lib/store/iRenderer.js +27 -11
- package/lib/store/index.js +1 -1
- package/lib/store/list.d.ts +18 -5
- package/lib/store/list.js +14 -1
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.d.ts +5 -5
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.d.ts +5 -5
- package/lib/store/pagination.js +1 -1
- package/lib/store/root.d.ts +5 -5
- package/lib/store/root.js +1 -1
- package/lib/store/service.d.ts +5 -5
- package/lib/store/service.js +2 -2
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +264 -76
- package/lib/store/table.js +27 -9
- package/lib/store/table2.d.ts +5 -5
- package/lib/store/table2.js +1 -1
- package/lib/theme.js +4 -2
- package/lib/types.d.ts +7 -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.js +1 -1
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.js +1 -1
- package/lib/utils/arraySlice.js +1 -1
- package/lib/utils/attachmentAdpator.js +1 -1
- package/lib/utils/autobind.js +1 -1
- package/lib/utils/browser.js +1 -1
- package/lib/utils/columnsSplit.js +1 -1
- package/lib/utils/concatData.js +1 -1
- package/lib/utils/dataMapping.js +1 -1
- package/lib/utils/date.js +1 -1
- package/lib/utils/debug.js +1 -1
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.d.ts +2 -2
- package/lib/utils/dom.js +72 -13
- 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 +2 -2
- 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 +12 -6
- package/lib/utils/helper.js +41 -20
- package/lib/utils/highlight.js +1 -1
- package/lib/utils/icon.js +1 -1
- package/lib/utils/image.js +1 -1
- 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/labelToString.js +1 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/math.js +1 -1
- 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.js +1 -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/printElement.js +1 -1
- package/lib/utils/renderer-event.d.ts +13 -0
- package/lib/utils/renderer-event.js +111 -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 +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.d.ts +1 -1
- package/lib/utils/stripNumber.js +4 -3
- package/lib/utils/style-helper.d.ts +21 -2
- package/lib/utils/style-helper.js +55 -10
- 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 +4 -4
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validateId.js +9 -2
- package/lib/utils/validations.js +1 -1
- package/package.json +5 -3
package/lib/renderers/Item.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.
|
|
2
|
+
* amis-core v6.4.0
|
|
3
3
|
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -11,6 +11,7 @@ var tslib = require('tslib');
|
|
|
11
11
|
var React = require('react');
|
|
12
12
|
var hoistNonReactStatic = require('hoist-non-react-statics');
|
|
13
13
|
var mobx = require('mobx');
|
|
14
|
+
var mobxStateTree = require('mobx-state-tree');
|
|
14
15
|
var factory = require('../factory.js');
|
|
15
16
|
var helper = require('../utils/helper.js');
|
|
16
17
|
var mobxReact = require('mobx-react');
|
|
@@ -33,7 +34,7 @@ require('../utils/debug.js');
|
|
|
33
34
|
require('../utils/dom.js');
|
|
34
35
|
require('../utils/errors.js');
|
|
35
36
|
require('../utils/tpl.js');
|
|
36
|
-
require('lodash/isPlainObject');
|
|
37
|
+
var isPlainObject = require('lodash/isPlainObject');
|
|
37
38
|
require('../utils/filter.js');
|
|
38
39
|
require('lodash/isObject');
|
|
39
40
|
require('lodash/isString');
|
|
@@ -41,6 +42,7 @@ require('lodash/isBoolean');
|
|
|
41
42
|
require('../utils/highlight.js');
|
|
42
43
|
require('../utils/icon.js');
|
|
43
44
|
require('../utils/image.js');
|
|
45
|
+
var keyToPath = require('../utils/keyToPath.js');
|
|
44
46
|
require('lodash/isEqual');
|
|
45
47
|
require('../actions/Action.js');
|
|
46
48
|
require('../utils/resize-sensor.js');
|
|
@@ -63,6 +65,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
63
65
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
64
66
|
var hoistNonReactStatic__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonReactStatic);
|
|
65
67
|
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
68
|
+
var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject);
|
|
66
69
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
67
70
|
|
|
68
71
|
var __react_jsx__ = require('react');
|
|
@@ -84,46 +87,72 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
84
87
|
tslib.__extends(FormItemWrap, _super);
|
|
85
88
|
function FormItemWrap(props) {
|
|
86
89
|
var _this = _super.call(this, props) || this;
|
|
87
|
-
_this.
|
|
88
|
-
_this.
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
_this.mounted = false;
|
|
91
|
+
_this.initedOptionFilled = false;
|
|
92
|
+
_this.initedApiFilled = false;
|
|
93
|
+
_this.toDispose = [];
|
|
94
|
+
_this.syncApiAutoFill = debounce__default["default"](function (term, forceLoad, skipIfExits) {
|
|
95
|
+
if (skipIfExits === void 0) { skipIfExits = false; }
|
|
96
|
+
return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
97
|
+
var _a, autoFill, onBulkChange, formItem, data_1, itemName, ctx, result, e_1;
|
|
91
98
|
var _b;
|
|
92
99
|
var _c, _d;
|
|
93
100
|
return tslib.__generator(this, function (_e) {
|
|
94
101
|
switch (_e.label) {
|
|
95
102
|
case 0:
|
|
96
|
-
|
|
103
|
+
_e.trys.push([0, 4, , 5]);
|
|
104
|
+
_a = this.props, autoFill = _a.autoFill, onBulkChange = _a.onBulkChange, formItem = _a.formItem, data_1 = _a.data;
|
|
97
105
|
// 参照录入
|
|
98
|
-
if (!
|
|
106
|
+
if (!onBulkChange ||
|
|
107
|
+
!formItem ||
|
|
108
|
+
!autoFill ||
|
|
109
|
+
(autoFill && !(autoFill === null || autoFill === void 0 ? void 0 : autoFill.hasOwnProperty('api')))) {
|
|
110
|
+
return [2 /*return*/];
|
|
111
|
+
}
|
|
112
|
+
else if (skipIfExits &&
|
|
113
|
+
(!autoFill.fillMapping ||
|
|
114
|
+
Object.keys(autoFill.fillMapping).some(function (key) { return typeof getVariable.getVariable(data_1, key) !== 'undefined'; }))) {
|
|
115
|
+
// 只要目标填充值有一个有值,就初始不自动填充
|
|
99
116
|
return [2 /*return*/];
|
|
100
117
|
}
|
|
101
118
|
if (!(autoFill === null || autoFill === void 0 ? void 0 : autoFill.showSuggestion)) return [3 /*break*/, 1];
|
|
102
119
|
this.handleAutoFill('change');
|
|
103
120
|
return [3 /*break*/, 3];
|
|
104
121
|
case 1:
|
|
105
|
-
itemName = formItem
|
|
106
|
-
ctx = object.createObject(
|
|
122
|
+
itemName = formItem.name;
|
|
123
|
+
ctx = object.createObject(data_1, (_b = {},
|
|
107
124
|
_b[itemName || ''] = term,
|
|
125
|
+
_b.__term = term,
|
|
108
126
|
_b));
|
|
109
|
-
if (!(
|
|
110
|
-
api.isEffectiveApi(autoFill.api, ctx) &&
|
|
111
|
-
|
|
112
|
-
reload)) return [3 /*break*/, 3];
|
|
113
|
-
return [4 /*yield*/, (formItem === null || formItem === void 0 ? void 0 : formItem.loadAutoUpdateData(autoFill.api, ctx, !!((_c = autoFill.api) === null || _c === void 0 ? void 0 : _c.silent)))];
|
|
127
|
+
if (!(forceLoad ||
|
|
128
|
+
(api.isEffectiveApi(autoFill.api, ctx) && this.lastSearchTerm !== term))) return [3 /*break*/, 3];
|
|
129
|
+
return [4 /*yield*/, formItem.loadAutoUpdateData(autoFill.api, ctx, !!((_c = autoFill.api) === null || _c === void 0 ? void 0 : _c.silent))];
|
|
114
130
|
case 2:
|
|
115
131
|
result = _e.sent();
|
|
116
132
|
this.lastSearchTerm =
|
|
117
133
|
(_d = (result && getVariable.getVariable(result, itemName))) !== null && _d !== void 0 ? _d : term;
|
|
134
|
+
// 如果没有返回不应该处理
|
|
135
|
+
if (!result) {
|
|
136
|
+
return [2 /*return*/];
|
|
137
|
+
}
|
|
118
138
|
if (autoFill === null || autoFill === void 0 ? void 0 : autoFill.fillMapping) {
|
|
119
139
|
result = dataMapping.dataMapping(autoFill.fillMapping, result);
|
|
120
140
|
}
|
|
121
|
-
|
|
141
|
+
if (result) {
|
|
142
|
+
// 不能把自己给清了吧
|
|
143
|
+
object.setVariable(result, itemName, getVariable.getVariable(result, itemName) || formItem.tmpValue);
|
|
144
|
+
onBulkChange === null || onBulkChange === void 0 ? void 0 : onBulkChange(result);
|
|
145
|
+
}
|
|
122
146
|
_e.label = 3;
|
|
123
|
-
case 3: return [
|
|
147
|
+
case 3: return [3 /*break*/, 5];
|
|
148
|
+
case 4:
|
|
149
|
+
e_1 = _e.sent();
|
|
150
|
+
console.error(e_1);
|
|
151
|
+
return [3 /*break*/, 5];
|
|
152
|
+
case 5: return [2 /*return*/];
|
|
124
153
|
}
|
|
125
154
|
});
|
|
126
|
-
});
|
|
155
|
+
});
|
|
127
156
|
}, 250, {
|
|
128
157
|
trailing: true,
|
|
129
158
|
leading: false
|
|
@@ -131,30 +160,57 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
131
160
|
_this.state = {
|
|
132
161
|
isOpened: false
|
|
133
162
|
};
|
|
134
|
-
var model = props.formItem;
|
|
135
|
-
if (model) {
|
|
136
|
-
|
|
137
|
-
_this.reaction.push(mobx.reaction(function () { return model === null || model === void 0 ? void 0 : model.filteredOptions; }, function () { return _this.forceUpdate(); }));
|
|
138
|
-
_this.reaction.push(mobx.reaction(function () { return JSON.stringify(model.tmpValue); }, function () { return _this.syncAutoFill(model.tmpValue); }));
|
|
163
|
+
var model = props.formItem, formInited = props.formInited, addHook = props.addHook, initAutoFill = props.initAutoFill;
|
|
164
|
+
if (!model) {
|
|
165
|
+
return _this;
|
|
139
166
|
}
|
|
167
|
+
_this.toDispose.push(mobx.reaction(function () {
|
|
168
|
+
return "".concat(model.errors.join('')).concat(model.isFocused).concat(model.dialogOpen).concat(JSON.stringify(model.filteredOptions));
|
|
169
|
+
}, function () { return _this.forceUpdate(); }));
|
|
170
|
+
var onInit = function () {
|
|
171
|
+
var _a;
|
|
172
|
+
_this.initedOptionFilled = true;
|
|
173
|
+
initAutoFill !== false &&
|
|
174
|
+
mobxStateTree.isAlive(model) &&
|
|
175
|
+
_this.syncOptionAutoFill(model.getSelectedOptions(model.tmpValue), initAutoFill === 'fillIfNotSet');
|
|
176
|
+
_this.initedApiFilled = true;
|
|
177
|
+
initAutoFill !== false &&
|
|
178
|
+
mobxStateTree.isAlive(model) &&
|
|
179
|
+
_this.syncApiAutoFill((_a = model.tmpValue) !== null && _a !== void 0 ? _a : '', false, initAutoFill === 'fillIfNotSet');
|
|
180
|
+
_this.toDispose.push(mobx.reaction(function () { return JSON.stringify(model.tmpValue); }, function () {
|
|
181
|
+
return _this.mounted &&
|
|
182
|
+
_this.initedApiFilled &&
|
|
183
|
+
_this.syncApiAutoFill(model.tmpValue);
|
|
184
|
+
}));
|
|
185
|
+
_this.toDispose.push(mobx.reaction(function () { return JSON.stringify(model.getSelectedOptions(model.tmpValue)); }, function () {
|
|
186
|
+
return _this.mounted &&
|
|
187
|
+
_this.initedOptionFilled &&
|
|
188
|
+
_this.syncOptionAutoFill(model.getSelectedOptions(model.tmpValue));
|
|
189
|
+
}));
|
|
190
|
+
};
|
|
191
|
+
_this.toDispose.push(formInited || !addHook
|
|
192
|
+
? model.addInitHook(onInit, 999)
|
|
193
|
+
: addHook(onInit, 'init', 'post'));
|
|
140
194
|
return _this;
|
|
141
195
|
}
|
|
196
|
+
FormItemWrap.prototype.componentDidMount = function () {
|
|
197
|
+
this.mounted = true;
|
|
198
|
+
this.target = ReactDOM.findDOMNode(this);
|
|
199
|
+
};
|
|
142
200
|
FormItemWrap.prototype.componentDidUpdate = function (prevProps) {
|
|
143
201
|
var _a, _b, _c;
|
|
144
202
|
var props = this.props;
|
|
145
203
|
var model = props.formItem;
|
|
146
204
|
if (api.isEffectiveApi((_a = props.autoFill) === null || _a === void 0 ? void 0 : _a.api, props.data) &&
|
|
147
205
|
api.isApiOutdated((_b = prevProps.autoFill) === null || _b === void 0 ? void 0 : _b.api, (_c = props.autoFill) === null || _c === void 0 ? void 0 : _c.api, prevProps.data, props.data)) {
|
|
148
|
-
this.
|
|
206
|
+
this.syncApiAutoFill(model === null || model === void 0 ? void 0 : model.tmpValue, true);
|
|
149
207
|
}
|
|
150
208
|
};
|
|
151
|
-
FormItemWrap.prototype.componentDidMount = function () {
|
|
152
|
-
this.target = ReactDOM.findDOMNode(this);
|
|
153
|
-
};
|
|
154
209
|
FormItemWrap.prototype.componentWillUnmount = function () {
|
|
155
|
-
this.
|
|
156
|
-
this.
|
|
157
|
-
this.
|
|
210
|
+
this.syncApiAutoFill.cancel();
|
|
211
|
+
this.mounted = false;
|
|
212
|
+
this.toDispose.forEach(function (fn) { return fn(); });
|
|
213
|
+
this.toDispose = [];
|
|
158
214
|
};
|
|
159
215
|
FormItemWrap.prototype.handleFocus = function (e) {
|
|
160
216
|
var _a = this.props, model = _a.formItem, autoFill = _a.autoFill;
|
|
@@ -185,7 +241,7 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
185
241
|
// 参照录入 dialog | drawer
|
|
186
242
|
trigger === type &&
|
|
187
243
|
(mode === 'dialog' || mode === 'drawer')) {
|
|
188
|
-
formItem === null || formItem === void 0 ? void 0 : formItem.openDialog(this.
|
|
244
|
+
formItem === null || formItem === void 0 ? void 0 : formItem.openDialog(this.buildAutoFillSchema(), data, function (confirmed, result) {
|
|
189
245
|
if (!(result === null || result === void 0 ? void 0 : result.selectedItems)) {
|
|
190
246
|
return;
|
|
191
247
|
}
|
|
@@ -206,7 +262,50 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
206
262
|
}
|
|
207
263
|
onBulkChange === null || onBulkChange === void 0 ? void 0 : onBulkChange(responseData);
|
|
208
264
|
};
|
|
209
|
-
FormItemWrap.prototype.
|
|
265
|
+
FormItemWrap.prototype.syncOptionAutoFill = function (selectedOptions, skipIfExits) {
|
|
266
|
+
if (skipIfExits === void 0) { skipIfExits = false; }
|
|
267
|
+
var _a = this.props, autoFill = _a.autoFill, multiple = _a.multiple, onBulkChange = _a.onBulkChange, data = _a.data;
|
|
268
|
+
var formItem = this.props.formItem;
|
|
269
|
+
// 参照录入|自动填充
|
|
270
|
+
if (autoFill === null || autoFill === void 0 ? void 0 : autoFill.hasOwnProperty('api')) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (onBulkChange &&
|
|
274
|
+
autoFill &&
|
|
275
|
+
!helper.isEmpty(autoFill) &&
|
|
276
|
+
formItem.filteredOptions.length) {
|
|
277
|
+
var toSync_1 = dataMapping.dataMapping(autoFill, multiple
|
|
278
|
+
? {
|
|
279
|
+
items: selectedOptions.map(function (item) {
|
|
280
|
+
return object.createObject(tslib.__assign(tslib.__assign({}, data), { ancestors: helper.getTreeAncestors(formItem.filteredOptions, item, true) }), item);
|
|
281
|
+
})
|
|
282
|
+
}
|
|
283
|
+
: object.createObject(tslib.__assign(tslib.__assign({}, data), { ancestors: helper.getTreeAncestors(formItem.filteredOptions, selectedOptions[0], true) }), selectedOptions[0]));
|
|
284
|
+
var tmpData_1 = tslib.__assign({}, data);
|
|
285
|
+
var result_1 = tslib.__assign({}, toSync_1);
|
|
286
|
+
Object.keys(autoFill).forEach(function (key) {
|
|
287
|
+
var keys = keyToPath.keyToPath(key);
|
|
288
|
+
var value = getVariable.getVariable(toSync_1, key);
|
|
289
|
+
if (skipIfExits) {
|
|
290
|
+
var originValue = getVariable.getVariable(data, key);
|
|
291
|
+
if (typeof originValue !== 'undefined') {
|
|
292
|
+
value = originValue;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
object.setVariable(result_1, key, value);
|
|
296
|
+
// 如果左边的 key 是一个路径
|
|
297
|
+
// 这里不希望直接把原始对象都给覆盖没了
|
|
298
|
+
// 而是保留原始的对象,只修改指定的属性
|
|
299
|
+
if (keys.length > 1 && isPlainObject__default["default"](tmpData_1[keys[0]])) {
|
|
300
|
+
// 存在情况:依次更新同一子路径的多个key,eg: a.b.c1 和 a.b.c2,所以需要同步更新data
|
|
301
|
+
object.setVariable(tmpData_1, key, value);
|
|
302
|
+
result_1[keys[0]] = tmpData_1[keys[0]];
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
onBulkChange(result_1);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
FormItemWrap.prototype.buildAutoFillSchema = function () {
|
|
210
309
|
var _this = this;
|
|
211
310
|
var _a = this.props, render = _a.render, autoFill = _a.autoFill, ns = _a.classPrefix, cx = _a.classnames, __ = _a.translate;
|
|
212
311
|
if (!autoFill || (autoFill && !(autoFill === null || autoFill === void 0 ? void 0 : autoFill.hasOwnProperty('api')))) {
|
|
@@ -266,29 +365,9 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
266
365
|
}
|
|
267
366
|
]
|
|
268
367
|
};
|
|
269
|
-
var schema = {
|
|
270
|
-
type: mode,
|
|
271
|
-
className: 'auto-fill-dialog',
|
|
272
|
-
title: __('FormItem.autoFillSuggest'),
|
|
273
|
-
size: size,
|
|
274
|
-
body: form,
|
|
275
|
-
actions: [
|
|
276
|
-
{
|
|
277
|
-
type: 'button',
|
|
278
|
-
actionType: 'cancel',
|
|
279
|
-
label: __('cancel')
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
type: 'submit',
|
|
283
|
-
actionType: 'submit',
|
|
284
|
-
level: 'primary',
|
|
285
|
-
label: __('confirm')
|
|
286
|
-
}
|
|
287
|
-
]
|
|
288
|
-
};
|
|
289
368
|
if (mode === 'popOver') {
|
|
290
369
|
return (_J$X_(Overlay["default"], { container: popOverContainer || this.target, target: function () { return _this.target; }, placement: position || 'left-bottom-left-top', show: true },
|
|
291
|
-
_J$X_(PopOver["default"], { classPrefix: ns, className: cx("".concat(ns, "
|
|
370
|
+
_J$X_(PopOver["default"], { classPrefix: ns, className: cx("".concat(ns, "Autofill-popOver"), popOverClassName), style: {
|
|
292
371
|
minWidth: this.target ? this.target.offsetWidth : undefined
|
|
293
372
|
}, offset: offset, onHide: this.handleClose, overlay: true }, render('popOver-auto-fill-form', form, {
|
|
294
373
|
onAction: this.handleAction,
|
|
@@ -296,7 +375,26 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
296
375
|
}))));
|
|
297
376
|
}
|
|
298
377
|
else {
|
|
299
|
-
return
|
|
378
|
+
return {
|
|
379
|
+
type: mode,
|
|
380
|
+
className: 'auto-fill-dialog',
|
|
381
|
+
title: __('FormItem.autoFillSuggest'),
|
|
382
|
+
size: size,
|
|
383
|
+
body: tslib.__assign(tslib.__assign({}, form), { wrapWithPanel: false }),
|
|
384
|
+
actions: [
|
|
385
|
+
{
|
|
386
|
+
type: 'button',
|
|
387
|
+
actionType: 'cancel',
|
|
388
|
+
label: __('cancel')
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
type: 'submit',
|
|
392
|
+
actionType: 'submit',
|
|
393
|
+
level: 'primary',
|
|
394
|
+
label: __('confirm')
|
|
395
|
+
}
|
|
396
|
+
]
|
|
397
|
+
};
|
|
300
398
|
}
|
|
301
399
|
};
|
|
302
400
|
// 参照录入popOver提交
|
|
@@ -327,7 +425,9 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
327
425
|
return [2 /*return*/];
|
|
328
426
|
}
|
|
329
427
|
return [2 /*return*/, new Promise(function (resolve) {
|
|
330
|
-
return model.openDialog(schema, data, function (
|
|
428
|
+
return model.openDialog(schema, data, function (confirmed, value) {
|
|
429
|
+
return resolve(confirmed ? value : false);
|
|
430
|
+
});
|
|
331
431
|
})];
|
|
332
432
|
});
|
|
333
433
|
});
|
|
@@ -338,7 +438,7 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
338
438
|
if (!model) {
|
|
339
439
|
return;
|
|
340
440
|
}
|
|
341
|
-
model.closeDialog(values);
|
|
441
|
+
model.closeDialog(true, values);
|
|
342
442
|
};
|
|
343
443
|
FormItemWrap.prototype.handleDialogClose = function (confirmed) {
|
|
344
444
|
if (confirmed === void 0) { confirmed = false; }
|
|
@@ -875,11 +975,11 @@ function asFormItem(config) {
|
|
|
875
975
|
!!controlSize &&
|
|
876
976
|
controlSize !== 'full',
|
|
877
977
|
_a), model === null || model === void 0 ? void 0 : model.errClassNames, getItemInputClassName(this.props)) })),
|
|
878
|
-
isOpened ? this.
|
|
978
|
+
isOpened ? this.buildAutoFillSchema() : null));
|
|
879
979
|
};
|
|
880
980
|
return class_1;
|
|
881
981
|
}(FormItemWrap)),
|
|
882
|
-
_a.defaultProps = tslib.__assign({ className: '', renderLabel: config.renderLabel, renderDescription: config.renderDescription, sizeMutable: config.sizeMutable, wrap: config.wrap, showErrorMsg: config.showErrorMsg }, Control.defaultProps),
|
|
982
|
+
_a.defaultProps = tslib.__assign({ initAutoFill: 'fillIfNotSet', className: '', renderLabel: config.renderLabel, renderDescription: config.renderDescription, sizeMutable: config.sizeMutable, wrap: config.wrap, showErrorMsg: config.showErrorMsg }, Control.defaultProps),
|
|
883
983
|
_a.propsList = tslib.__spreadArray([
|
|
884
984
|
'value',
|
|
885
985
|
'defaultValue',
|
|
@@ -120,17 +120,6 @@ export interface FormOptionsControl extends FormBaseControl {
|
|
|
120
120
|
* 选项删除提示文字。
|
|
121
121
|
*/
|
|
122
122
|
deleteConfirmText?: string;
|
|
123
|
-
/**
|
|
124
|
-
* 自动填充,当选项被选择的时候,将选项中的其他值同步设置到表单内。
|
|
125
|
-
*/
|
|
126
|
-
autoFill?: {
|
|
127
|
-
[propName: string]: string;
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* @default fillIfNotSet
|
|
131
|
-
* 初始化时是否把其他字段同步到表单内部。
|
|
132
|
-
*/
|
|
133
|
-
initAutoFill?: boolean | 'fillIfNotSet';
|
|
134
123
|
}
|
|
135
124
|
export interface OptionsBasicConfig extends FormItemBasicConfig {
|
|
136
125
|
autoLoadOptionsFromSource?: boolean;
|
package/lib/renderers/Options.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.
|
|
2
|
+
* amis-core v6.4.0
|
|
3
3
|
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -18,13 +18,11 @@ require('amis-formula');
|
|
|
18
18
|
require('moment');
|
|
19
19
|
var object = require('../utils/object.js');
|
|
20
20
|
var isPureVariable = require('../utils/isPureVariable.js');
|
|
21
|
-
var getVariable = require('../utils/getVariable.js');
|
|
22
21
|
var resolveVariableAndFilter = require('../utils/resolveVariableAndFilter.js');
|
|
23
|
-
|
|
22
|
+
require('lodash/isPlainObject');
|
|
24
23
|
require('../utils/filter.js');
|
|
25
24
|
var tpl = require('../utils/tpl.js');
|
|
26
25
|
var findIndex = require('lodash/findIndex');
|
|
27
|
-
var isPlainObject = require('lodash/isPlainObject');
|
|
28
26
|
var normalizeOptions = require('../utils/normalizeOptions.js');
|
|
29
27
|
var optionValueCompare = require('../utils/optionValueCompare.js');
|
|
30
28
|
require('../utils/browser.js');
|
|
@@ -41,7 +39,6 @@ require('lodash/isBoolean');
|
|
|
41
39
|
require('../utils/highlight.js');
|
|
42
40
|
require('../utils/icon.js');
|
|
43
41
|
require('../utils/image.js');
|
|
44
|
-
var keyToPath = require('../utils/keyToPath.js');
|
|
45
42
|
var rendererEvent = require('../utils/renderer-event.js');
|
|
46
43
|
require('../utils/resize-sensor.js');
|
|
47
44
|
require('react-overlays/useRootClose');
|
|
@@ -63,7 +60,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
63
60
|
|
|
64
61
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
65
62
|
var findIndex__default = /*#__PURE__*/_interopDefaultLegacy(findIndex);
|
|
66
|
-
var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject);
|
|
67
63
|
|
|
68
64
|
var __react_jsx__ = require('react');
|
|
69
65
|
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
|
|
@@ -96,40 +92,21 @@ function registerOptionsControl(config) {
|
|
|
96
92
|
_this = _super.call(this, props) || this;
|
|
97
93
|
_this.toDispose = [];
|
|
98
94
|
_this.mounted = false;
|
|
99
|
-
_this.initedFilled = false;
|
|
100
95
|
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;
|
|
101
|
-
if (formItem) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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');
|
|
122
|
-
}
|
|
123
|
-
// 默认全选。这里会和默认值\回填值逻辑冲突,所以如果有配置source则不执行默认全选
|
|
124
|
-
if (multiple &&
|
|
125
|
-
defaultCheckAll &&
|
|
126
|
-
((_a = formItem.filteredOptions) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
127
|
-
!source) {
|
|
128
|
-
_this.defaultCheckAll();
|
|
129
|
-
}
|
|
96
|
+
if (!formItem) {
|
|
97
|
+
return _this;
|
|
98
|
+
}
|
|
99
|
+
formItem.setOptions(normalizeOptions.normalizeOptions(options, undefined, valueField), _this.changeOptionValue, data);
|
|
100
|
+
_this.toDispose.push(mobx.reaction(function () { return JSON.stringify([formItem.loading, formItem.filteredOptions]); }, function () { return _this.mounted && _this.forceUpdate(); }));
|
|
101
|
+
// 默认全选。这里会和默认值\回填值逻辑冲突,所以如果有配置source则不执行默认全选
|
|
102
|
+
if (multiple &&
|
|
103
|
+
defaultCheckAll &&
|
|
104
|
+
((_a = formItem.filteredOptions) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
105
|
+
!source) {
|
|
106
|
+
_this.defaultCheckAll();
|
|
130
107
|
}
|
|
131
108
|
var loadOptions = initFetch !== false;
|
|
132
|
-
if (
|
|
109
|
+
if (joinValues === false && defaultValue) {
|
|
133
110
|
var selectedOptions = extractValue
|
|
134
111
|
? formItem
|
|
135
112
|
.getSelectedOptions(value)
|
|
@@ -141,9 +118,9 @@ function registerOptionsControl(config) {
|
|
|
141
118
|
}
|
|
142
119
|
loadOptions &&
|
|
143
120
|
config.autoLoadOptionsFromSource !== false &&
|
|
144
|
-
(formInited || !addHook
|
|
145
|
-
? _this.reload
|
|
146
|
-
: addHook
|
|
121
|
+
_this.toDispose.push(formInited || !addHook
|
|
122
|
+
? formItem.addInitHook(_this.reload)
|
|
123
|
+
: addHook(_this.initOptions, 'init'));
|
|
147
124
|
return _this;
|
|
148
125
|
}
|
|
149
126
|
FormOptionsItem.prototype.componentDidMount = function () {
|
|
@@ -201,6 +178,7 @@ function registerOptionsControl(config) {
|
|
|
201
178
|
FormOptionsItem.prototype.componentWillUnmount = function () {
|
|
202
179
|
var _a, _b;
|
|
203
180
|
(_b = (_a = this.props).removeHook) === null || _b === void 0 ? void 0 : _b.call(_a, this.reload, 'init');
|
|
181
|
+
this.mounted = false;
|
|
204
182
|
this.toDispose.forEach(function (fn) { return fn(); });
|
|
205
183
|
this.toDispose = [];
|
|
206
184
|
};
|
|
@@ -250,49 +228,6 @@ function registerOptionsControl(config) {
|
|
|
250
228
|
onChange === null || onChange === void 0 ? void 0 : onChange(resetValue !== null && resetValue !== void 0 ? resetValue : '');
|
|
251
229
|
}
|
|
252
230
|
};
|
|
253
|
-
FormOptionsItem.prototype.syncAutoFill = function (selectedOptions, skipIfExits) {
|
|
254
|
-
if (skipIfExits === void 0) { skipIfExits = false; }
|
|
255
|
-
var _a = this.props, autoFill = _a.autoFill, multiple = _a.multiple, onBulkChange = _a.onBulkChange, data = _a.data;
|
|
256
|
-
var formItem = this.props.formItem;
|
|
257
|
-
// 参照录入|自动填充
|
|
258
|
-
if (autoFill === null || autoFill === void 0 ? void 0 : autoFill.hasOwnProperty('api')) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
if (onBulkChange &&
|
|
262
|
-
autoFill &&
|
|
263
|
-
!helper.isEmpty(autoFill) &&
|
|
264
|
-
formItem.filteredOptions.length) {
|
|
265
|
-
var toSync_1 = dataMapping.dataMapping(autoFill, multiple
|
|
266
|
-
? {
|
|
267
|
-
items: selectedOptions.map(function (item) {
|
|
268
|
-
return object.createObject(tslib.__assign(tslib.__assign({}, data), { ancestors: helper.getTreeAncestors(formItem.filteredOptions, item, true) }), item);
|
|
269
|
-
})
|
|
270
|
-
}
|
|
271
|
-
: object.createObject(tslib.__assign(tslib.__assign({}, data), { ancestors: helper.getTreeAncestors(formItem.filteredOptions, selectedOptions[0], true) }), selectedOptions[0]));
|
|
272
|
-
var tmpData_1 = tslib.__assign({}, data);
|
|
273
|
-
var result_1 = tslib.__assign({}, toSync_1);
|
|
274
|
-
Object.keys(autoFill).forEach(function (key) {
|
|
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);
|
|
284
|
-
// 如果左边的 key 是一个路径
|
|
285
|
-
// 这里不希望直接把原始对象都给覆盖没了
|
|
286
|
-
// 而是保留原始的对象,只修改指定的属性
|
|
287
|
-
if (keys.length > 1 && isPlainObject__default["default"](tmpData_1[keys[0]])) {
|
|
288
|
-
// 存在情况:依次更新同一子路径的多个key,eg: a.b.c1 和 a.b.c2,所以需要同步更新data
|
|
289
|
-
object.setVariable(tmpData_1, key, value);
|
|
290
|
-
result_1[keys[0]] = tmpData_1[keys[0]];
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
onBulkChange(result_1);
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
231
|
// 当前值,跟设置预期的值格式不一致时自动转换。
|
|
297
232
|
FormOptionsItem.prototype.normalizeValue = function () {
|
|
298
233
|
var _a = this.props, joinValues = _a.joinValues, extractValue = _a.extractValue, value = _a.value, multiple = _a.multiple, formItem = _a.formItem, valueField = _a.valueField; _a.enableNodePath; _a.pathSeparator; var onChange = _a.onChange;
|
|
@@ -952,7 +887,7 @@ function registerOptionsControl(config) {
|
|
|
952
887
|
: [], 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 })));
|
|
953
888
|
};
|
|
954
889
|
FormOptionsItem.displayName = "OptionsControl(".concat(config.type, ")");
|
|
955
|
-
FormOptionsItem.defaultProps = tslib.__assign({ delimiter: ',', labelField: 'label', valueField: 'value', joinValues: true, extractValue: false, multiple: false, placeholder: 'Select.placeholder', resetValue: '', deleteConfirmText: 'deleteConfirm'
|
|
890
|
+
FormOptionsItem.defaultProps = tslib.__assign({ delimiter: ',', labelField: 'label', valueField: 'value', joinValues: true, extractValue: false, multiple: false, placeholder: 'Select.placeholder', resetValue: '', deleteConfirmText: 'deleteConfirm' }, Control.defaultProps);
|
|
956
891
|
FormOptionsItem.propsList = Control.propsList
|
|
957
892
|
? tslib.__spreadArray([], tslib.__read(Control.propsList), false) : [];
|
|
958
893
|
FormOptionsItem.ComposedComponent = Control;
|
package/lib/renderers/builtin.js
CHANGED
|
@@ -32,7 +32,7 @@ export interface ControlOutterProps extends RendererProps {
|
|
|
32
32
|
submitOnChange?: boolean;
|
|
33
33
|
validate?: (value: any, values: any, name: string) => any;
|
|
34
34
|
formItem?: IFormItemStore;
|
|
35
|
-
addHook?: (fn: () => any, type?: 'validate' | 'init' | 'flush') => void;
|
|
35
|
+
addHook?: (fn: () => any, type?: 'validate' | 'init' | 'flush') => () => void;
|
|
36
36
|
removeHook?: (fn: () => any, type?: 'validate' | 'init' | 'flush') => void;
|
|
37
37
|
$schema: {
|
|
38
38
|
pipeIn?: (value: any, data: any) => any;
|
|
@@ -42,6 +42,7 @@ export interface ControlOutterProps extends RendererProps {
|
|
|
42
42
|
store?: IIRendererStore;
|
|
43
43
|
onChange?: (value: any, name: string, submit?: boolean, changePristine?: boolean) => void;
|
|
44
44
|
formItemDispatchEvent: (type: string, data: any) => void;
|
|
45
|
+
formItemRef?: (control: any) => void;
|
|
45
46
|
}
|
|
46
47
|
export interface ControlProps {
|
|
47
48
|
onBulkChange?: (values: Object) => void;
|