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/esm/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
|
|
|
@@ -7,8 +7,9 @@ import { __extends, __awaiter, __generator, __assign, __read, __rest, __decorate
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
9
9
|
import { reaction } from 'mobx';
|
|
10
|
+
import { isAlive } from 'mobx-state-tree';
|
|
10
11
|
import { registerRenderer, renderersMap } from '../factory.js';
|
|
11
|
-
import { ucFirst, getWidthRate, autobind, anyChanged } from '../utils/helper.js';
|
|
12
|
+
import { isEmpty, getTreeAncestors, ucFirst, getWidthRate, autobind, anyChanged } from '../utils/helper.js';
|
|
12
13
|
import { observer } from 'mobx-react';
|
|
13
14
|
import { HocStoreFactory } from '../WithStore.js';
|
|
14
15
|
import { wrapControl } from './wrapControl.js';
|
|
@@ -19,7 +20,7 @@ import '../utils/browser.js';
|
|
|
19
20
|
import '../utils/ColorScale.js';
|
|
20
21
|
import 'lodash/chunk';
|
|
21
22
|
import { getVariable } from '../utils/getVariable.js';
|
|
22
|
-
import { createObject } from '../utils/object.js';
|
|
23
|
+
import { setVariable, createObject } from '../utils/object.js';
|
|
23
24
|
import { dataMapping } from '../utils/dataMapping.js';
|
|
24
25
|
import '../utils/DataSchema.js';
|
|
25
26
|
import '../utils/DataScope.js';
|
|
@@ -28,12 +29,13 @@ import 'amis-formula';
|
|
|
28
29
|
import '../utils/debug.js';
|
|
29
30
|
import '../utils/errors.js';
|
|
30
31
|
import '../utils/tpl.js';
|
|
31
|
-
import 'lodash/isPlainObject';
|
|
32
|
+
import isPlainObject from 'lodash/isPlainObject';
|
|
32
33
|
import '../utils/filter.js';
|
|
33
34
|
import 'lodash/isObject';
|
|
34
35
|
import 'lodash/isString';
|
|
35
36
|
import 'lodash/isBoolean';
|
|
36
37
|
import '../utils/image.js';
|
|
38
|
+
import { keyToPath } from '../utils/keyToPath.js';
|
|
37
39
|
import 'lodash/isEqual';
|
|
38
40
|
import '../actions/Action.js';
|
|
39
41
|
import '../utils/resize-sensor.js';
|
|
@@ -67,46 +69,72 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
67
69
|
__extends(FormItemWrap, _super);
|
|
68
70
|
function FormItemWrap(props) {
|
|
69
71
|
var _this = _super.call(this, props) || this;
|
|
70
|
-
_this.
|
|
71
|
-
_this.
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
_this.mounted = false;
|
|
73
|
+
_this.initedOptionFilled = false;
|
|
74
|
+
_this.initedApiFilled = false;
|
|
75
|
+
_this.toDispose = [];
|
|
76
|
+
_this.syncApiAutoFill = debounce(function (term, forceLoad, skipIfExits) {
|
|
77
|
+
if (skipIfExits === void 0) { skipIfExits = false; }
|
|
78
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
79
|
+
var _a, autoFill, onBulkChange, formItem, data_1, itemName, ctx, result, e_1;
|
|
74
80
|
var _b;
|
|
75
81
|
var _c, _d;
|
|
76
82
|
return __generator(this, function (_e) {
|
|
77
83
|
switch (_e.label) {
|
|
78
84
|
case 0:
|
|
79
|
-
|
|
85
|
+
_e.trys.push([0, 4, , 5]);
|
|
86
|
+
_a = this.props, autoFill = _a.autoFill, onBulkChange = _a.onBulkChange, formItem = _a.formItem, data_1 = _a.data;
|
|
80
87
|
// 参照录入
|
|
81
|
-
if (!
|
|
88
|
+
if (!onBulkChange ||
|
|
89
|
+
!formItem ||
|
|
90
|
+
!autoFill ||
|
|
91
|
+
(autoFill && !(autoFill === null || autoFill === void 0 ? void 0 : autoFill.hasOwnProperty('api')))) {
|
|
92
|
+
return [2 /*return*/];
|
|
93
|
+
}
|
|
94
|
+
else if (skipIfExits &&
|
|
95
|
+
(!autoFill.fillMapping ||
|
|
96
|
+
Object.keys(autoFill.fillMapping).some(function (key) { return typeof getVariable(data_1, key) !== 'undefined'; }))) {
|
|
97
|
+
// 只要目标填充值有一个有值,就初始不自动填充
|
|
82
98
|
return [2 /*return*/];
|
|
83
99
|
}
|
|
84
100
|
if (!(autoFill === null || autoFill === void 0 ? void 0 : autoFill.showSuggestion)) return [3 /*break*/, 1];
|
|
85
101
|
this.handleAutoFill('change');
|
|
86
102
|
return [3 /*break*/, 3];
|
|
87
103
|
case 1:
|
|
88
|
-
itemName = formItem
|
|
89
|
-
ctx = createObject(
|
|
104
|
+
itemName = formItem.name;
|
|
105
|
+
ctx = createObject(data_1, (_b = {},
|
|
90
106
|
_b[itemName || ''] = term,
|
|
107
|
+
_b.__term = term,
|
|
91
108
|
_b));
|
|
92
|
-
if (!(
|
|
93
|
-
isEffectiveApi(autoFill.api, ctx) &&
|
|
94
|
-
|
|
95
|
-
reload)) return [3 /*break*/, 3];
|
|
96
|
-
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)))];
|
|
109
|
+
if (!(forceLoad ||
|
|
110
|
+
(isEffectiveApi(autoFill.api, ctx) && this.lastSearchTerm !== term))) return [3 /*break*/, 3];
|
|
111
|
+
return [4 /*yield*/, formItem.loadAutoUpdateData(autoFill.api, ctx, !!((_c = autoFill.api) === null || _c === void 0 ? void 0 : _c.silent))];
|
|
97
112
|
case 2:
|
|
98
113
|
result = _e.sent();
|
|
99
114
|
this.lastSearchTerm =
|
|
100
115
|
(_d = (result && getVariable(result, itemName))) !== null && _d !== void 0 ? _d : term;
|
|
116
|
+
// 如果没有返回不应该处理
|
|
117
|
+
if (!result) {
|
|
118
|
+
return [2 /*return*/];
|
|
119
|
+
}
|
|
101
120
|
if (autoFill === null || autoFill === void 0 ? void 0 : autoFill.fillMapping) {
|
|
102
121
|
result = dataMapping(autoFill.fillMapping, result);
|
|
103
122
|
}
|
|
104
|
-
|
|
123
|
+
if (result) {
|
|
124
|
+
// 不能把自己给清了吧
|
|
125
|
+
setVariable(result, itemName, getVariable(result, itemName) || formItem.tmpValue);
|
|
126
|
+
onBulkChange === null || onBulkChange === void 0 ? void 0 : onBulkChange(result);
|
|
127
|
+
}
|
|
105
128
|
_e.label = 3;
|
|
106
|
-
case 3: return [
|
|
129
|
+
case 3: return [3 /*break*/, 5];
|
|
130
|
+
case 4:
|
|
131
|
+
e_1 = _e.sent();
|
|
132
|
+
console.error(e_1);
|
|
133
|
+
return [3 /*break*/, 5];
|
|
134
|
+
case 5: return [2 /*return*/];
|
|
107
135
|
}
|
|
108
136
|
});
|
|
109
|
-
});
|
|
137
|
+
});
|
|
110
138
|
}, 250, {
|
|
111
139
|
trailing: true,
|
|
112
140
|
leading: false
|
|
@@ -114,30 +142,57 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
114
142
|
_this.state = {
|
|
115
143
|
isOpened: false
|
|
116
144
|
};
|
|
117
|
-
var model = props.formItem;
|
|
118
|
-
if (model) {
|
|
119
|
-
|
|
120
|
-
_this.reaction.push(reaction(function () { return model === null || model === void 0 ? void 0 : model.filteredOptions; }, function () { return _this.forceUpdate(); }));
|
|
121
|
-
_this.reaction.push(reaction(function () { return JSON.stringify(model.tmpValue); }, function () { return _this.syncAutoFill(model.tmpValue); }));
|
|
145
|
+
var model = props.formItem, formInited = props.formInited, addHook = props.addHook, initAutoFill = props.initAutoFill;
|
|
146
|
+
if (!model) {
|
|
147
|
+
return _this;
|
|
122
148
|
}
|
|
149
|
+
_this.toDispose.push(reaction(function () {
|
|
150
|
+
return "".concat(model.errors.join('')).concat(model.isFocused).concat(model.dialogOpen).concat(JSON.stringify(model.filteredOptions));
|
|
151
|
+
}, function () { return _this.forceUpdate(); }));
|
|
152
|
+
var onInit = function () {
|
|
153
|
+
var _a;
|
|
154
|
+
_this.initedOptionFilled = true;
|
|
155
|
+
initAutoFill !== false &&
|
|
156
|
+
isAlive(model) &&
|
|
157
|
+
_this.syncOptionAutoFill(model.getSelectedOptions(model.tmpValue), initAutoFill === 'fillIfNotSet');
|
|
158
|
+
_this.initedApiFilled = true;
|
|
159
|
+
initAutoFill !== false &&
|
|
160
|
+
isAlive(model) &&
|
|
161
|
+
_this.syncApiAutoFill((_a = model.tmpValue) !== null && _a !== void 0 ? _a : '', false, initAutoFill === 'fillIfNotSet');
|
|
162
|
+
_this.toDispose.push(reaction(function () { return JSON.stringify(model.tmpValue); }, function () {
|
|
163
|
+
return _this.mounted &&
|
|
164
|
+
_this.initedApiFilled &&
|
|
165
|
+
_this.syncApiAutoFill(model.tmpValue);
|
|
166
|
+
}));
|
|
167
|
+
_this.toDispose.push(reaction(function () { return JSON.stringify(model.getSelectedOptions(model.tmpValue)); }, function () {
|
|
168
|
+
return _this.mounted &&
|
|
169
|
+
_this.initedOptionFilled &&
|
|
170
|
+
_this.syncOptionAutoFill(model.getSelectedOptions(model.tmpValue));
|
|
171
|
+
}));
|
|
172
|
+
};
|
|
173
|
+
_this.toDispose.push(formInited || !addHook
|
|
174
|
+
? model.addInitHook(onInit, 999)
|
|
175
|
+
: addHook(onInit, 'init', 'post'));
|
|
123
176
|
return _this;
|
|
124
177
|
}
|
|
178
|
+
FormItemWrap.prototype.componentDidMount = function () {
|
|
179
|
+
this.mounted = true;
|
|
180
|
+
this.target = findDOMNode(this);
|
|
181
|
+
};
|
|
125
182
|
FormItemWrap.prototype.componentDidUpdate = function (prevProps) {
|
|
126
183
|
var _a, _b, _c;
|
|
127
184
|
var props = this.props;
|
|
128
185
|
var model = props.formItem;
|
|
129
186
|
if (isEffectiveApi((_a = props.autoFill) === null || _a === void 0 ? void 0 : _a.api, props.data) &&
|
|
130
187
|
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)) {
|
|
131
|
-
this.
|
|
188
|
+
this.syncApiAutoFill(model === null || model === void 0 ? void 0 : model.tmpValue, true);
|
|
132
189
|
}
|
|
133
190
|
};
|
|
134
|
-
FormItemWrap.prototype.componentDidMount = function () {
|
|
135
|
-
this.target = findDOMNode(this);
|
|
136
|
-
};
|
|
137
191
|
FormItemWrap.prototype.componentWillUnmount = function () {
|
|
138
|
-
this.
|
|
139
|
-
this.
|
|
140
|
-
this.
|
|
192
|
+
this.syncApiAutoFill.cancel();
|
|
193
|
+
this.mounted = false;
|
|
194
|
+
this.toDispose.forEach(function (fn) { return fn(); });
|
|
195
|
+
this.toDispose = [];
|
|
141
196
|
};
|
|
142
197
|
FormItemWrap.prototype.handleFocus = function (e) {
|
|
143
198
|
var _a = this.props, model = _a.formItem, autoFill = _a.autoFill;
|
|
@@ -168,7 +223,7 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
168
223
|
// 参照录入 dialog | drawer
|
|
169
224
|
trigger === type &&
|
|
170
225
|
(mode === 'dialog' || mode === 'drawer')) {
|
|
171
|
-
formItem === null || formItem === void 0 ? void 0 : formItem.openDialog(this.
|
|
226
|
+
formItem === null || formItem === void 0 ? void 0 : formItem.openDialog(this.buildAutoFillSchema(), data, function (confirmed, result) {
|
|
172
227
|
if (!(result === null || result === void 0 ? void 0 : result.selectedItems)) {
|
|
173
228
|
return;
|
|
174
229
|
}
|
|
@@ -189,7 +244,50 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
189
244
|
}
|
|
190
245
|
onBulkChange === null || onBulkChange === void 0 ? void 0 : onBulkChange(responseData);
|
|
191
246
|
};
|
|
192
|
-
FormItemWrap.prototype.
|
|
247
|
+
FormItemWrap.prototype.syncOptionAutoFill = function (selectedOptions, skipIfExits) {
|
|
248
|
+
if (skipIfExits === void 0) { skipIfExits = false; }
|
|
249
|
+
var _a = this.props, autoFill = _a.autoFill, multiple = _a.multiple, onBulkChange = _a.onBulkChange, data = _a.data;
|
|
250
|
+
var formItem = this.props.formItem;
|
|
251
|
+
// 参照录入|自动填充
|
|
252
|
+
if (autoFill === null || autoFill === void 0 ? void 0 : autoFill.hasOwnProperty('api')) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (onBulkChange &&
|
|
256
|
+
autoFill &&
|
|
257
|
+
!isEmpty(autoFill) &&
|
|
258
|
+
formItem.filteredOptions.length) {
|
|
259
|
+
var toSync_1 = dataMapping(autoFill, multiple
|
|
260
|
+
? {
|
|
261
|
+
items: selectedOptions.map(function (item) {
|
|
262
|
+
return createObject(__assign(__assign({}, data), { ancestors: getTreeAncestors(formItem.filteredOptions, item, true) }), item);
|
|
263
|
+
})
|
|
264
|
+
}
|
|
265
|
+
: createObject(__assign(__assign({}, data), { ancestors: getTreeAncestors(formItem.filteredOptions, selectedOptions[0], true) }), selectedOptions[0]));
|
|
266
|
+
var tmpData_1 = __assign({}, data);
|
|
267
|
+
var result_1 = __assign({}, toSync_1);
|
|
268
|
+
Object.keys(autoFill).forEach(function (key) {
|
|
269
|
+
var keys = keyToPath(key);
|
|
270
|
+
var value = getVariable(toSync_1, key);
|
|
271
|
+
if (skipIfExits) {
|
|
272
|
+
var originValue = getVariable(data, key);
|
|
273
|
+
if (typeof originValue !== 'undefined') {
|
|
274
|
+
value = originValue;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
setVariable(result_1, key, value);
|
|
278
|
+
// 如果左边的 key 是一个路径
|
|
279
|
+
// 这里不希望直接把原始对象都给覆盖没了
|
|
280
|
+
// 而是保留原始的对象,只修改指定的属性
|
|
281
|
+
if (keys.length > 1 && isPlainObject(tmpData_1[keys[0]])) {
|
|
282
|
+
// 存在情况:依次更新同一子路径的多个key,eg: a.b.c1 和 a.b.c2,所以需要同步更新data
|
|
283
|
+
setVariable(tmpData_1, key, value);
|
|
284
|
+
result_1[keys[0]] = tmpData_1[keys[0]];
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
onBulkChange(result_1);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
FormItemWrap.prototype.buildAutoFillSchema = function () {
|
|
193
291
|
var _this = this;
|
|
194
292
|
var _a = this.props, render = _a.render, autoFill = _a.autoFill, ns = _a.classPrefix, cx = _a.classnames, __ = _a.translate;
|
|
195
293
|
if (!autoFill || (autoFill && !(autoFill === null || autoFill === void 0 ? void 0 : autoFill.hasOwnProperty('api')))) {
|
|
@@ -249,29 +347,9 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
249
347
|
}
|
|
250
348
|
]
|
|
251
349
|
};
|
|
252
|
-
var schema = {
|
|
253
|
-
type: mode,
|
|
254
|
-
className: 'auto-fill-dialog',
|
|
255
|
-
title: __('FormItem.autoFillSuggest'),
|
|
256
|
-
size: size,
|
|
257
|
-
body: form,
|
|
258
|
-
actions: [
|
|
259
|
-
{
|
|
260
|
-
type: 'button',
|
|
261
|
-
actionType: 'cancel',
|
|
262
|
-
label: __('cancel')
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
type: 'submit',
|
|
266
|
-
actionType: 'submit',
|
|
267
|
-
level: 'primary',
|
|
268
|
-
label: __('confirm')
|
|
269
|
-
}
|
|
270
|
-
]
|
|
271
|
-
};
|
|
272
350
|
if (mode === 'popOver') {
|
|
273
351
|
return (React.createElement(Overlay, { container: popOverContainer || this.target, target: function () { return _this.target; }, placement: position || 'left-bottom-left-top', show: true },
|
|
274
|
-
React.createElement(PopOver, { classPrefix: ns, className: cx("".concat(ns, "
|
|
352
|
+
React.createElement(PopOver, { classPrefix: ns, className: cx("".concat(ns, "Autofill-popOver"), popOverClassName), style: {
|
|
275
353
|
minWidth: this.target ? this.target.offsetWidth : undefined
|
|
276
354
|
}, offset: offset, onHide: this.handleClose, overlay: true }, render('popOver-auto-fill-form', form, {
|
|
277
355
|
onAction: this.handleAction,
|
|
@@ -279,7 +357,26 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
279
357
|
}))));
|
|
280
358
|
}
|
|
281
359
|
else {
|
|
282
|
-
return
|
|
360
|
+
return {
|
|
361
|
+
type: mode,
|
|
362
|
+
className: 'auto-fill-dialog',
|
|
363
|
+
title: __('FormItem.autoFillSuggest'),
|
|
364
|
+
size: size,
|
|
365
|
+
body: __assign(__assign({}, form), { wrapWithPanel: false }),
|
|
366
|
+
actions: [
|
|
367
|
+
{
|
|
368
|
+
type: 'button',
|
|
369
|
+
actionType: 'cancel',
|
|
370
|
+
label: __('cancel')
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
type: 'submit',
|
|
374
|
+
actionType: 'submit',
|
|
375
|
+
level: 'primary',
|
|
376
|
+
label: __('confirm')
|
|
377
|
+
}
|
|
378
|
+
]
|
|
379
|
+
};
|
|
283
380
|
}
|
|
284
381
|
};
|
|
285
382
|
// 参照录入popOver提交
|
|
@@ -310,7 +407,9 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
310
407
|
return [2 /*return*/];
|
|
311
408
|
}
|
|
312
409
|
return [2 /*return*/, new Promise(function (resolve) {
|
|
313
|
-
return model.openDialog(schema, data, function (
|
|
410
|
+
return model.openDialog(schema, data, function (confirmed, value) {
|
|
411
|
+
return resolve(confirmed ? value : false);
|
|
412
|
+
});
|
|
314
413
|
})];
|
|
315
414
|
});
|
|
316
415
|
});
|
|
@@ -321,7 +420,7 @@ var FormItemWrap = /** @class */ (function (_super) {
|
|
|
321
420
|
if (!model) {
|
|
322
421
|
return;
|
|
323
422
|
}
|
|
324
|
-
model.closeDialog(values);
|
|
423
|
+
model.closeDialog(true, values);
|
|
325
424
|
};
|
|
326
425
|
FormItemWrap.prototype.handleDialogClose = function (confirmed) {
|
|
327
426
|
if (confirmed === void 0) { confirmed = false; }
|
|
@@ -858,11 +957,11 @@ function asFormItem(config) {
|
|
|
858
957
|
!!controlSize &&
|
|
859
958
|
controlSize !== 'full',
|
|
860
959
|
_a), model === null || model === void 0 ? void 0 : model.errClassNames, getItemInputClassName(this.props)) })),
|
|
861
|
-
isOpened ? this.
|
|
960
|
+
isOpened ? this.buildAutoFillSchema() : null));
|
|
862
961
|
};
|
|
863
962
|
return class_1;
|
|
864
963
|
}(FormItemWrap)),
|
|
865
|
-
_a.defaultProps = __assign({ className: '', renderLabel: config.renderLabel, renderDescription: config.renderDescription, sizeMutable: config.sizeMutable, wrap: config.wrap, showErrorMsg: config.showErrorMsg }, Control.defaultProps),
|
|
964
|
+
_a.defaultProps = __assign({ initAutoFill: 'fillIfNotSet', className: '', renderLabel: config.renderLabel, renderDescription: config.renderDescription, sizeMutable: config.sizeMutable, wrap: config.wrap, showErrorMsg: config.showErrorMsg }, Control.defaultProps),
|
|
866
965
|
_a.propsList = __spreadArray([
|
|
867
966
|
'value',
|
|
868
967
|
'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/esm/renderers/Options.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.
|
|
2
|
+
* amis-core v6.4.0
|
|
3
3
|
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { __extends, __awaiter, __generator, __assign, __spreadArray, __read, __decorate, __metadata } from 'tslib';
|
|
7
7
|
import { isEffectiveApi, isApiOutdated } from '../utils/api.js';
|
|
8
8
|
import { isAlive } from 'mobx-state-tree';
|
|
9
|
-
import { anyChanged,
|
|
9
|
+
import { anyChanged, getTreeDepth, flattenTree, spliceTree, getTree, findTreeIndex, normalizeNodePath, autobind } from '../utils/helper.js';
|
|
10
10
|
import { reaction } from 'mobx';
|
|
11
11
|
import { registerFormItem, detectProps as detectProps$1 } from './Item.js';
|
|
12
12
|
import React from 'react';
|
|
@@ -14,13 +14,11 @@ import 'amis-formula';
|
|
|
14
14
|
import 'moment';
|
|
15
15
|
import { createObject, setVariable } from '../utils/object.js';
|
|
16
16
|
import { isPureVariable } from '../utils/isPureVariable.js';
|
|
17
|
-
import { getVariable } from '../utils/getVariable.js';
|
|
18
17
|
import { resolveVariableAndFilter } from '../utils/resolveVariableAndFilter.js';
|
|
19
|
-
import
|
|
18
|
+
import 'lodash/isPlainObject';
|
|
20
19
|
import '../utils/filter.js';
|
|
21
20
|
import { filter } from '../utils/tpl.js';
|
|
22
21
|
import findIndex from 'lodash/findIndex';
|
|
23
|
-
import isPlainObject from 'lodash/isPlainObject';
|
|
24
22
|
import { normalizeOptions } from '../utils/normalizeOptions.js';
|
|
25
23
|
import { optionValueCompare } from '../utils/optionValueCompare.js';
|
|
26
24
|
import '../utils/browser.js';
|
|
@@ -35,7 +33,6 @@ import 'lodash/isObject';
|
|
|
35
33
|
import 'lodash/isString';
|
|
36
34
|
import 'lodash/isBoolean';
|
|
37
35
|
import '../utils/image.js';
|
|
38
|
-
import { keyToPath } from '../utils/keyToPath.js';
|
|
39
36
|
import { resolveEventData } from '../utils/renderer-event.js';
|
|
40
37
|
import '../utils/resize-sensor.js';
|
|
41
38
|
import 'react-overlays/useRootClose';
|
|
@@ -80,40 +77,21 @@ function registerOptionsControl(config) {
|
|
|
80
77
|
_this = _super.call(this, props) || this;
|
|
81
78
|
_this.toDispose = [];
|
|
82
79
|
_this.mounted = false;
|
|
83
|
-
_this.initedFilled = false;
|
|
84
80
|
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;
|
|
85
|
-
if (formItem) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
_this.initedFilled = true;
|
|
97
|
-
_this.props.initAutoFill !== false &&
|
|
98
|
-
_this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue), _this.props.initAutoFill === 'fillIfNotSet');
|
|
99
|
-
}
|
|
100
|
-
else if (addHook) {
|
|
101
|
-
addHook(function () {
|
|
102
|
-
_this.initedFilled = true;
|
|
103
|
-
_this.props.initAutoFill !== false &&
|
|
104
|
-
_this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue), _this.props.initAutoFill === 'fillIfNotSet');
|
|
105
|
-
}, 'init');
|
|
106
|
-
}
|
|
107
|
-
// 默认全选。这里会和默认值\回填值逻辑冲突,所以如果有配置source则不执行默认全选
|
|
108
|
-
if (multiple &&
|
|
109
|
-
defaultCheckAll &&
|
|
110
|
-
((_a = formItem.filteredOptions) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
111
|
-
!source) {
|
|
112
|
-
_this.defaultCheckAll();
|
|
113
|
-
}
|
|
81
|
+
if (!formItem) {
|
|
82
|
+
return _this;
|
|
83
|
+
}
|
|
84
|
+
formItem.setOptions(normalizeOptions(options, undefined, valueField), _this.changeOptionValue, data);
|
|
85
|
+
_this.toDispose.push(reaction(function () { return JSON.stringify([formItem.loading, formItem.filteredOptions]); }, function () { return _this.mounted && _this.forceUpdate(); }));
|
|
86
|
+
// 默认全选。这里会和默认值\回填值逻辑冲突,所以如果有配置source则不执行默认全选
|
|
87
|
+
if (multiple &&
|
|
88
|
+
defaultCheckAll &&
|
|
89
|
+
((_a = formItem.filteredOptions) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
90
|
+
!source) {
|
|
91
|
+
_this.defaultCheckAll();
|
|
114
92
|
}
|
|
115
93
|
var loadOptions = initFetch !== false;
|
|
116
|
-
if (
|
|
94
|
+
if (joinValues === false && defaultValue) {
|
|
117
95
|
var selectedOptions = extractValue
|
|
118
96
|
? formItem
|
|
119
97
|
.getSelectedOptions(value)
|
|
@@ -125,9 +103,9 @@ function registerOptionsControl(config) {
|
|
|
125
103
|
}
|
|
126
104
|
loadOptions &&
|
|
127
105
|
config.autoLoadOptionsFromSource !== false &&
|
|
128
|
-
(formInited || !addHook
|
|
129
|
-
? _this.reload
|
|
130
|
-
: addHook
|
|
106
|
+
_this.toDispose.push(formInited || !addHook
|
|
107
|
+
? formItem.addInitHook(_this.reload)
|
|
108
|
+
: addHook(_this.initOptions, 'init'));
|
|
131
109
|
return _this;
|
|
132
110
|
}
|
|
133
111
|
FormOptionsItem.prototype.componentDidMount = function () {
|
|
@@ -185,6 +163,7 @@ function registerOptionsControl(config) {
|
|
|
185
163
|
FormOptionsItem.prototype.componentWillUnmount = function () {
|
|
186
164
|
var _a, _b;
|
|
187
165
|
(_b = (_a = this.props).removeHook) === null || _b === void 0 ? void 0 : _b.call(_a, this.reload, 'init');
|
|
166
|
+
this.mounted = false;
|
|
188
167
|
this.toDispose.forEach(function (fn) { return fn(); });
|
|
189
168
|
this.toDispose = [];
|
|
190
169
|
};
|
|
@@ -234,49 +213,6 @@ function registerOptionsControl(config) {
|
|
|
234
213
|
onChange === null || onChange === void 0 ? void 0 : onChange(resetValue !== null && resetValue !== void 0 ? resetValue : '');
|
|
235
214
|
}
|
|
236
215
|
};
|
|
237
|
-
FormOptionsItem.prototype.syncAutoFill = function (selectedOptions, skipIfExits) {
|
|
238
|
-
if (skipIfExits === void 0) { skipIfExits = false; }
|
|
239
|
-
var _a = this.props, autoFill = _a.autoFill, multiple = _a.multiple, onBulkChange = _a.onBulkChange, data = _a.data;
|
|
240
|
-
var formItem = this.props.formItem;
|
|
241
|
-
// 参照录入|自动填充
|
|
242
|
-
if (autoFill === null || autoFill === void 0 ? void 0 : autoFill.hasOwnProperty('api')) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
if (onBulkChange &&
|
|
246
|
-
autoFill &&
|
|
247
|
-
!isEmpty(autoFill) &&
|
|
248
|
-
formItem.filteredOptions.length) {
|
|
249
|
-
var toSync_1 = dataMapping(autoFill, multiple
|
|
250
|
-
? {
|
|
251
|
-
items: selectedOptions.map(function (item) {
|
|
252
|
-
return createObject(__assign(__assign({}, data), { ancestors: getTreeAncestors(formItem.filteredOptions, item, true) }), item);
|
|
253
|
-
})
|
|
254
|
-
}
|
|
255
|
-
: createObject(__assign(__assign({}, data), { ancestors: getTreeAncestors(formItem.filteredOptions, selectedOptions[0], true) }), selectedOptions[0]));
|
|
256
|
-
var tmpData_1 = __assign({}, data);
|
|
257
|
-
var result_1 = __assign({}, toSync_1);
|
|
258
|
-
Object.keys(autoFill).forEach(function (key) {
|
|
259
|
-
var keys = keyToPath(key);
|
|
260
|
-
var value = getVariable(toSync_1, key);
|
|
261
|
-
if (skipIfExits) {
|
|
262
|
-
var originValue = getVariable(data, key);
|
|
263
|
-
if (typeof originValue !== 'undefined') {
|
|
264
|
-
value = originValue;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
setVariable(result_1, key, value);
|
|
268
|
-
// 如果左边的 key 是一个路径
|
|
269
|
-
// 这里不希望直接把原始对象都给覆盖没了
|
|
270
|
-
// 而是保留原始的对象,只修改指定的属性
|
|
271
|
-
if (keys.length > 1 && isPlainObject(tmpData_1[keys[0]])) {
|
|
272
|
-
// 存在情况:依次更新同一子路径的多个key,eg: a.b.c1 和 a.b.c2,所以需要同步更新data
|
|
273
|
-
setVariable(tmpData_1, key, value);
|
|
274
|
-
result_1[keys[0]] = tmpData_1[keys[0]];
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
onBulkChange(result_1);
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
216
|
// 当前值,跟设置预期的值格式不一致时自动转换。
|
|
281
217
|
FormOptionsItem.prototype.normalizeValue = function () {
|
|
282
218
|
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;
|
|
@@ -936,7 +872,7 @@ function registerOptionsControl(config) {
|
|
|
936
872
|
: [], 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 && isEffectiveApi(addApi) ? true : creatable, editable: editable || (editable !== false && isEffectiveApi(editApi)), removable: removable || (removable !== false && isEffectiveApi(deleteApi)), onAdd: this.handleOptionAdd, onEdit: this.handleOptionEdit, onDelete: this.handleOptionDelete })));
|
|
937
873
|
};
|
|
938
874
|
FormOptionsItem.displayName = "OptionsControl(".concat(config.type, ")");
|
|
939
|
-
FormOptionsItem.defaultProps = __assign({ delimiter: ',', labelField: 'label', valueField: 'value', joinValues: true, extractValue: false, multiple: false, placeholder: 'Select.placeholder', resetValue: '', deleteConfirmText: 'deleteConfirm'
|
|
875
|
+
FormOptionsItem.defaultProps = __assign({ delimiter: ',', labelField: 'label', valueField: 'value', joinValues: true, extractValue: false, multiple: false, placeholder: 'Select.placeholder', resetValue: '', deleteConfirmText: 'deleteConfirm' }, Control.defaultProps);
|
|
940
876
|
FormOptionsItem.propsList = Control.propsList
|
|
941
877
|
? __spreadArray([], __read(Control.propsList), false) : [];
|
|
942
878
|
FormOptionsItem.ComposedComponent = Control;
|
package/esm/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;
|