amis-core 6.7.0 → 6.9.0-beta.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 +24 -2
- package/esm/SchemaRenderer.d.ts +0 -1
- package/esm/SchemaRenderer.js +44 -20
- package/esm/Scoped.d.ts +1 -1
- package/esm/Scoped.js +2 -1
- package/esm/StatusScoped.js +1 -1
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +14 -14
- package/esm/actions/Action.js +2 -1
- package/esm/actions/AjaxAction.js +1 -1
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.js +57 -50
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +2 -1
- package/esm/actions/DialogAction.js +3 -1
- package/esm/actions/DrawerAction.js +2 -1
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/EventAction.js +2 -1
- package/esm/actions/LinkAction.js +1 -1
- package/esm/actions/LoopAction.js +2 -1
- package/esm/actions/PageAction.js +1 -1
- package/esm/actions/ParallelAction.js +1 -1
- package/esm/actions/PrintAction.js +1 -1
- package/esm/actions/StatusAction.js +1 -1
- package/esm/actions/SwitchAction.js +1 -1
- package/esm/actions/ToastAction.js +3 -3
- package/esm/actions/WaitAction.js +1 -1
- package/esm/components/CustomStyle.js +1 -1
- package/esm/components/ErrorBoundary.js +1 -1
- package/esm/components/LazyComponent.d.ts +40 -2
- package/esm/components/LazyComponent.js +13 -7
- package/esm/components/Overlay.js +2 -1
- package/esm/components/PopOver.d.ts +1 -1
- package/esm/components/PopOver.js +2 -1
- package/esm/env.d.ts +0 -4
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.d.ts +19 -2
- package/esm/factory.js +205 -45
- package/esm/index.d.ts +4 -4
- package/esm/index.js +9 -5
- package/esm/locale.d.ts +1 -1
- package/esm/locale.js +14 -2
- package/esm/polyfills.js +1 -1
- package/esm/renderers/Form.d.ts +5 -5
- package/esm/renderers/Form.js +68 -29
- package/esm/renderers/Item.d.ts +109 -18
- package/esm/renderers/Item.js +164 -126
- package/esm/renderers/Options.d.ts +3 -3
- package/esm/renderers/Options.js +43 -19
- 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 +3 -3
- package/esm/renderers/wrapControl.js +25 -10
- package/esm/store/app.d.ts +3 -3
- package/esm/store/app.js +2 -1
- package/esm/store/combo.d.ts +425 -15
- package/esm/store/combo.js +1 -1
- package/esm/store/crud.d.ts +3 -3
- package/esm/store/crud.js +2 -1
- package/esm/store/form.d.ts +178 -7
- package/esm/store/form.js +29 -6
- package/esm/store/formItem.d.ts +5 -0
- package/esm/store/formItem.js +32 -10
- package/esm/store/iRenderer.d.ts +4 -3
- package/esm/store/iRenderer.js +29 -4
- package/esm/store/index.d.ts +1 -0
- package/esm/store/index.js +3 -2
- package/esm/store/list.d.ts +3 -3
- package/esm/store/list.js +1 -1
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.d.ts +3 -3
- package/esm/store/modal.js +1 -1
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.d.ts +3 -3
- package/esm/store/pagination.js +2 -1
- package/esm/store/root.d.ts +5 -3
- package/esm/store/root.js +46 -21
- package/esm/store/service.d.ts +3 -3
- package/esm/store/service.js +11 -4
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +396 -36
- package/esm/store/table.js +84 -54
- package/esm/store/table2.d.ts +3 -3
- package/esm/store/table2.js +1 -1
- package/esm/theme.d.ts +1 -1
- package/esm/theme.js +13 -2
- package/esm/types.d.ts +19 -2
- package/esm/utils/Animation.js +1 -1
- package/esm/utils/ColorScale.js +1 -1
- package/esm/utils/DataSchema.js +1 -1
- package/esm/utils/DataScope.js +1 -1
- package/esm/utils/RootClose.js +1 -1
- package/esm/utils/SimpleMap.js +1 -1
- package/esm/utils/api.d.ts +21 -1
- package/esm/utils/api.js +138 -41
- 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 +17 -3
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.js +1 -1
- package/esm/utils/errors.js +1 -1
- package/esm/utils/escapeHtml.js +1 -1
- package/esm/utils/filter-schema.js +1 -1
- package/esm/utils/filter.js +1 -1
- package/esm/utils/formatDuration.js +1 -1
- package/esm/utils/formula.js +2 -1
- 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 +4 -1
- package/esm/utils/helper.js +20 -4
- 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 +2 -2
- package/esm/utils/json-schema-2-amis-schema.js +1 -1
- package/esm/utils/keyToPath.js +1 -1
- package/esm/utils/labelToString.js +4 -1
- package/esm/utils/makeSorter.js +1 -1
- package/esm/utils/math.js +1 -1
- package/esm/utils/memoryParse.d.ts +2 -1
- package/esm/utils/memoryParse.js +10 -6
- package/esm/utils/normalizeLink.js +1 -1
- package/esm/utils/normalizeOptions.js +1 -1
- package/esm/utils/object.d.ts +2 -4
- 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.js +1 -1
- package/esm/utils/replaceText.js +1 -1
- package/esm/utils/resize-sensor.js +30 -1
- package/esm/utils/resolveCondition.js +2 -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 +2 -1
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.js +2 -1
- package/esm/utils/tpl-lodash.js +2 -1
- package/esm/utils/tpl.js +1 -1
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validateId.js +1 -1
- package/esm/utils/validations.js +2 -1
- package/esm/utils/visitedCache.d.ts +46 -0
- package/esm/utils/visitedCache.js +124 -0
- package/lib/Root.js +1 -1
- package/lib/RootRenderer.js +23 -1
- package/lib/SchemaRenderer.d.ts +0 -1
- package/lib/SchemaRenderer.js +42 -18
- package/lib/Scoped.d.ts +1 -1
- package/lib/Scoped.js +2 -1
- package/lib/StatusScoped.js +1 -1
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +14 -14
- package/lib/actions/Action.js +2 -1
- package/lib/actions/AjaxAction.js +1 -1
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.js +56 -49
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +2 -1
- package/lib/actions/DialogAction.js +3 -1
- package/lib/actions/DrawerAction.js +2 -1
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/EventAction.js +2 -1
- package/lib/actions/LinkAction.js +1 -1
- package/lib/actions/LoopAction.js +2 -1
- package/lib/actions/PageAction.js +1 -1
- package/lib/actions/ParallelAction.js +1 -1
- package/lib/actions/PrintAction.js +1 -1
- package/lib/actions/StatusAction.js +1 -1
- package/lib/actions/SwitchAction.js +1 -1
- package/lib/actions/ToastAction.js +2 -2
- package/lib/actions/WaitAction.js +1 -1
- package/lib/components/CustomStyle.js +1 -1
- package/lib/components/ErrorBoundary.js +1 -1
- package/lib/components/LazyComponent.d.ts +40 -2
- package/lib/components/LazyComponent.js +14 -7
- package/lib/components/Overlay.js +2 -1
- package/lib/components/PopOver.d.ts +1 -1
- package/lib/components/PopOver.js +2 -1
- package/lib/env.d.ts +0 -4
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.d.ts +19 -2
- package/lib/factory.js +211 -44
- package/lib/index.d.ts +4 -4
- package/lib/index.js +16 -2
- package/lib/locale.d.ts +1 -1
- package/lib/locale.js +14 -2
- package/lib/polyfills.js +1 -1
- package/lib/renderers/Form.d.ts +5 -5
- package/lib/renderers/Form.js +65 -26
- package/lib/renderers/Item.d.ts +110 -19
- package/lib/renderers/Item.js +163 -125
- package/lib/renderers/Options.d.ts +3 -3
- package/lib/renderers/Options.js +43 -19
- 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 +3 -3
- package/lib/renderers/wrapControl.js +25 -10
- package/lib/store/app.d.ts +3 -3
- package/lib/store/app.js +2 -1
- package/lib/store/combo.d.ts +449 -40
- package/lib/store/combo.js +1 -1
- package/lib/store/crud.d.ts +3 -3
- package/lib/store/crud.js +3 -2
- package/lib/store/form.d.ts +188 -18
- package/lib/store/form.js +29 -6
- package/lib/store/formItem.d.ts +5 -0
- package/lib/store/formItem.js +32 -10
- package/lib/store/iRenderer.d.ts +4 -3
- package/lib/store/iRenderer.js +29 -4
- package/lib/store/index.d.ts +1 -0
- package/lib/store/index.js +3 -1
- package/lib/store/list.d.ts +3 -3
- package/lib/store/list.js +1 -1
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.d.ts +3 -3
- package/lib/store/modal.js +1 -1
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.d.ts +3 -3
- package/lib/store/pagination.js +2 -1
- package/lib/store/root.d.ts +5 -3
- package/lib/store/root.js +44 -19
- package/lib/store/service.d.ts +3 -3
- package/lib/store/service.js +11 -4
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +416 -57
- package/lib/store/table.js +84 -54
- package/lib/store/table2.d.ts +3 -3
- package/lib/store/table2.js +1 -1
- package/lib/theme.d.ts +1 -1
- package/lib/theme.js +13 -2
- package/lib/types.d.ts +19 -2
- package/lib/utils/Animation.js +1 -1
- package/lib/utils/ColorScale.js +1 -1
- package/lib/utils/DataSchema.js +1 -1
- package/lib/utils/DataScope.js +1 -1
- package/lib/utils/RootClose.js +1 -1
- package/lib/utils/SimpleMap.js +1 -1
- package/lib/utils/api.d.ts +21 -1
- package/lib/utils/api.js +141 -40
- 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 +18 -4
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.js +1 -1
- 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 -1
- 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 +4 -1
- package/lib/utils/helper.js +19 -3
- 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 +2 -2
- package/lib/utils/json-schema-2-amis-schema.js +1 -1
- package/lib/utils/keyToPath.js +1 -1
- package/lib/utils/labelToString.js +4 -1
- package/lib/utils/makeSorter.js +1 -1
- package/lib/utils/math.js +1 -1
- package/lib/utils/memoryParse.d.ts +2 -1
- package/lib/utils/memoryParse.js +10 -6
- package/lib/utils/normalizeLink.js +1 -1
- package/lib/utils/normalizeOptions.js +1 -1
- package/lib/utils/object.d.ts +2 -4
- 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.js +1 -1
- package/lib/utils/replaceText.js +1 -1
- package/lib/utils/resize-sensor.js +30 -1
- package/lib/utils/resolveCondition.js +2 -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 +2 -1
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.js +2 -1
- package/lib/utils/tpl-lodash.js +2 -1
- package/lib/utils/tpl.js +1 -1
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validateId.js +1 -1
- package/lib/utils/validations.js +2 -1
- package/lib/utils/visitedCache.d.ts +46 -0
- package/lib/utils/visitedCache.js +128 -0
- package/package.json +2 -2
package/esm/renderers/Form.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.
|
|
2
|
+
* amis-core v6.9.0-beta.0
|
|
3
3
|
* Copyright 2018-2024 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { __extends, __awaiter, __generator, __assign, __decorate, __metadata } from 'tslib';
|
|
6
|
+
import { __extends, __awaiter, __generator, __assign, __values, __decorate, __metadata } from 'tslib';
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { Renderer } from '../factory.js';
|
|
9
9
|
import { FormStore } from '../store/form.js';
|
|
@@ -17,11 +17,12 @@ import { filterTarget, ScopedContext } from '../Scoped.js';
|
|
|
17
17
|
import 'amis-formula';
|
|
18
18
|
import 'moment';
|
|
19
19
|
import { isObject, createObject, cloneObject, injectObjectChain } from '../utils/object.js';
|
|
20
|
+
import '../utils/memoryParse.js';
|
|
20
21
|
import '@rc-component/mini-decimal';
|
|
21
22
|
import { dataMapping } from '../utils/dataMapping.js';
|
|
22
23
|
import '../utils/filter.js';
|
|
23
24
|
import { isEffectiveApi, isApiOutdated } from '../utils/api.js';
|
|
24
|
-
import
|
|
25
|
+
import themedLazyComponent from '../components/LazyComponent.js';
|
|
25
26
|
import { isAlive } from 'mobx-state-tree';
|
|
26
27
|
import '../utils/browser.js';
|
|
27
28
|
import '../utils/ColorScale.js';
|
|
@@ -91,7 +92,8 @@ var Form = /** @class */ (function (_super) {
|
|
|
91
92
|
_this.blockRouting = _this.blockRouting.bind(_this);
|
|
92
93
|
_this.beforePageUnload = _this.beforePageUnload.bind(_this);
|
|
93
94
|
_this.formItemDispatchEvent = _this.formItemDispatchEvent.bind(_this);
|
|
94
|
-
|
|
95
|
+
_this.flush = _this.flush.bind(_this);
|
|
96
|
+
var store = props.store, canAccessSuperData = props.canAccessSuperData, persistData = props.persistData, simpleMode = props.simpleMode, formLazyChange = props.formLazyChange;
|
|
95
97
|
store.setCanAccessSuperData(canAccessSuperData !== false);
|
|
96
98
|
store.setPersistData(persistData);
|
|
97
99
|
if (simpleMode) {
|
|
@@ -111,7 +113,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
111
113
|
// https://github.com/baidu/amis/issues/8773
|
|
112
114
|
_this.toDispose.push(reaction(function () { return store.initedAt; }, function () {
|
|
113
115
|
store.inited &&
|
|
114
|
-
_this.lazyEmitChange(!!_this.props.submitOnChange, true);
|
|
116
|
+
(formLazyChange === false ? _this.emitChange : _this.lazyEmitChange)(!!_this.props.submitOnChange, true);
|
|
115
117
|
}));
|
|
116
118
|
return _this;
|
|
117
119
|
}
|
|
@@ -176,7 +178,9 @@ var Form = /** @class */ (function (_super) {
|
|
|
176
178
|
successMessage: fetchSuccess,
|
|
177
179
|
errorMessage: fetchFailed,
|
|
178
180
|
onSuccess: function (json, data) {
|
|
179
|
-
store.setValues(data
|
|
181
|
+
store.setValues(data, undefined, undefined, undefined, {
|
|
182
|
+
type: 'api'
|
|
183
|
+
});
|
|
180
184
|
if (!isEffectiveApi(initAsyncApi, store.data) ||
|
|
181
185
|
store.data[initFinishedField || 'finished']) {
|
|
182
186
|
return;
|
|
@@ -372,7 +376,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
372
376
|
case 3:
|
|
373
377
|
// 派发初始化接口请求完成事件
|
|
374
378
|
this.dispatchInited(result);
|
|
375
|
-
return [2 /*return
|
|
379
|
+
return [2 /*return*/, store.data];
|
|
376
380
|
}
|
|
377
381
|
});
|
|
378
382
|
});
|
|
@@ -383,7 +387,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
383
387
|
return this.reload();
|
|
384
388
|
};
|
|
385
389
|
Form.prototype.silentReload = function (target, query) {
|
|
386
|
-
this.reload(target, query, undefined, true);
|
|
390
|
+
return this.reload(target, query, undefined, true);
|
|
387
391
|
};
|
|
388
392
|
Form.prototype.initInterval = function (value) {
|
|
389
393
|
var _a = this.props, interval = _a.interval, silentPolling = _a.silentPolling, stopAutoRefreshWhen = _a.stopAutoRefreshWhen, data = _a.data;
|
|
@@ -443,7 +447,9 @@ var Form = /** @class */ (function (_super) {
|
|
|
443
447
|
Form.prototype.setValues = function (value, replace) {
|
|
444
448
|
var store = this.props.store;
|
|
445
449
|
this.flush();
|
|
446
|
-
store.setValues(value, undefined, replace
|
|
450
|
+
store.setValues(value, undefined, replace, undefined, {
|
|
451
|
+
type: 'action'
|
|
452
|
+
});
|
|
447
453
|
};
|
|
448
454
|
Form.prototype.submit = function (fn, throwErrors, skipFlush) {
|
|
449
455
|
if (throwErrors === void 0) { throwErrors = false; }
|
|
@@ -470,29 +476,54 @@ var Form = /** @class */ (function (_super) {
|
|
|
470
476
|
};
|
|
471
477
|
Form.prototype.flush = function () {
|
|
472
478
|
return __awaiter(this, void 0, void 0, function () {
|
|
473
|
-
var hooks;
|
|
474
|
-
|
|
475
|
-
|
|
479
|
+
var hooks, hooks_1, hooks_1_1, hook, e_1_1;
|
|
480
|
+
var e_1, _a;
|
|
481
|
+
return __generator(this, function (_b) {
|
|
482
|
+
switch (_b.label) {
|
|
476
483
|
case 0:
|
|
477
|
-
|
|
484
|
+
_b.trys.push([0, , 11, 12]);
|
|
478
485
|
if (this.flushing) {
|
|
479
486
|
return [2 /*return*/];
|
|
480
487
|
}
|
|
481
488
|
this.flushing = true;
|
|
482
489
|
hooks = this.hooks['flush'] || [];
|
|
483
|
-
|
|
490
|
+
_b.label = 1;
|
|
484
491
|
case 1:
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
492
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
493
|
+
hooks_1 = __values(hooks), hooks_1_1 = hooks_1.next();
|
|
494
|
+
_b.label = 2;
|
|
488
495
|
case 2:
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
496
|
+
if (!!hooks_1_1.done) return [3 /*break*/, 5];
|
|
497
|
+
hook = hooks_1_1.value;
|
|
498
|
+
return [4 /*yield*/, hook()];
|
|
499
|
+
case 3:
|
|
500
|
+
_b.sent();
|
|
501
|
+
_b.label = 4;
|
|
492
502
|
case 4:
|
|
503
|
+
hooks_1_1 = hooks_1.next();
|
|
504
|
+
return [3 /*break*/, 2];
|
|
505
|
+
case 5: return [3 /*break*/, 8];
|
|
506
|
+
case 6:
|
|
507
|
+
e_1_1 = _b.sent();
|
|
508
|
+
e_1 = { error: e_1_1 };
|
|
509
|
+
return [3 /*break*/, 8];
|
|
510
|
+
case 7:
|
|
511
|
+
try {
|
|
512
|
+
if (hooks_1_1 && !hooks_1_1.done && (_a = hooks_1.return)) _a.call(hooks_1);
|
|
513
|
+
}
|
|
514
|
+
finally { if (e_1) throw e_1.error; }
|
|
515
|
+
return [7 /*endfinally*/];
|
|
516
|
+
case 8:
|
|
517
|
+
if (!!this.emitting) return [3 /*break*/, 10];
|
|
518
|
+
return [4 /*yield*/, this.lazyEmitChange.flush()];
|
|
519
|
+
case 9:
|
|
520
|
+
_b.sent();
|
|
521
|
+
_b.label = 10;
|
|
522
|
+
case 10: return [3 /*break*/, 12];
|
|
523
|
+
case 11:
|
|
493
524
|
this.flushing = false;
|
|
494
525
|
return [7 /*endfinally*/];
|
|
495
|
-
case
|
|
526
|
+
case 12: return [2 /*return*/];
|
|
496
527
|
}
|
|
497
528
|
});
|
|
498
529
|
});
|
|
@@ -528,13 +559,15 @@ var Form = /** @class */ (function (_super) {
|
|
|
528
559
|
}
|
|
529
560
|
}
|
|
530
561
|
};
|
|
531
|
-
Form.prototype.handleChange = function (value, name, submit, changePristine) {
|
|
562
|
+
Form.prototype.handleChange = function (value, name, submit, changePristine, changeReason) {
|
|
532
563
|
if (changePristine === void 0) { changePristine = false; }
|
|
533
564
|
var _a = this.props, store = _a.store, formLazyChange = _a.formLazyChange, persistDataKeys = _a.persistDataKeys;
|
|
534
565
|
if (typeof name !== 'string') {
|
|
535
566
|
return;
|
|
536
567
|
}
|
|
537
|
-
store.changeValue(name, value, changePristine
|
|
568
|
+
store.changeValue(name, value, changePristine, undefined, undefined, changeReason || {
|
|
569
|
+
type: 'input'
|
|
570
|
+
});
|
|
538
571
|
if (!changePristine || typeof value !== 'undefined') {
|
|
539
572
|
(formLazyChange === false ? this.emitChange : this.lazyEmitChange)(submit);
|
|
540
573
|
}
|
|
@@ -572,7 +605,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
572
605
|
if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
|
|
573
606
|
onChange && onChange.apply(null, changeProps);
|
|
574
607
|
}
|
|
575
|
-
store.clearRestError();
|
|
608
|
+
isAlive(store) && store.clearRestError();
|
|
576
609
|
if (!(!emitedFromWatch && (submit || (submitOnChange && store.inited)))) return [3 /*break*/, 3];
|
|
577
610
|
return [4 /*yield*/, this.handleAction(undefined, {
|
|
578
611
|
type: 'submit',
|
|
@@ -592,9 +625,11 @@ var Form = /** @class */ (function (_super) {
|
|
|
592
625
|
});
|
|
593
626
|
});
|
|
594
627
|
};
|
|
595
|
-
Form.prototype.handleBulkChange = function (values, submit) {
|
|
628
|
+
Form.prototype.handleBulkChange = function (values, submit, changeReason) {
|
|
596
629
|
var _a = this.props; _a.onChange; var store = _a.store, formLazyChange = _a.formLazyChange;
|
|
597
|
-
store.setValues(values
|
|
630
|
+
store.setValues(values, undefined, undefined, undefined, changeReason || {
|
|
631
|
+
type: 'input'
|
|
632
|
+
});
|
|
598
633
|
// store.updateData(values);
|
|
599
634
|
// store.items.forEach(formItem => {
|
|
600
635
|
// const updatedValue = getVariable(values, formItem.name, false);
|
|
@@ -644,6 +679,9 @@ var Form = /** @class */ (function (_super) {
|
|
|
644
679
|
_f.sent();
|
|
645
680
|
_f.label = 2;
|
|
646
681
|
case 2:
|
|
682
|
+
if (!isAlive(store)) {
|
|
683
|
+
return [2 /*return*/];
|
|
684
|
+
}
|
|
647
685
|
if (trimValues) {
|
|
648
686
|
store.trimValues();
|
|
649
687
|
}
|
|
@@ -844,7 +882,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
844
882
|
if (values === false) {
|
|
845
883
|
return store.data;
|
|
846
884
|
}
|
|
847
|
-
if (onFinished && onFinished(values, action) === false) {
|
|
885
|
+
if (onFinished && onFinished(values, action, store) === false) {
|
|
848
886
|
return values;
|
|
849
887
|
}
|
|
850
888
|
resetAfterSubmit && store.reset(_this.handleReset(action));
|
|
@@ -1203,7 +1241,8 @@ var Form = /** @class */ (function (_super) {
|
|
|
1203
1241
|
removeHook: this.removeHook,
|
|
1204
1242
|
renderFormItems: this.renderFormItems,
|
|
1205
1243
|
formItemDispatchEvent: this.formItemDispatchEvent,
|
|
1206
|
-
formPristine: form.pristine
|
|
1244
|
+
formPristine: form.pristine,
|
|
1245
|
+
onFlushForm: this.flush
|
|
1207
1246
|
// value: (control as any)?.name
|
|
1208
1247
|
// ? getVariable(form.data, (control as any)?.name, canAccessSuperData)
|
|
1209
1248
|
// : (control as any)?.value,
|
|
@@ -1357,7 +1396,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
1357
1396
|
});
|
|
1358
1397
|
}
|
|
1359
1398
|
if (lazyLoad) {
|
|
1360
|
-
body = React.createElement(
|
|
1399
|
+
body = React.createElement(themedLazyComponent, null, body);
|
|
1361
1400
|
}
|
|
1362
1401
|
return body;
|
|
1363
1402
|
};
|
package/esm/renderers/Item.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
|
4
4
|
import { IFormItemStore, IFormStore } from '../store/form';
|
|
5
5
|
import { RendererProps, TestFunc, RendererConfig } from '../factory';
|
|
6
6
|
import { FormHorizontal, FormSchemaBase } from './Form';
|
|
7
|
-
import { ActionObject, BaseApiObject, BaseSchemaWithoutType, ClassName, Schema } from '../types';
|
|
7
|
+
import { ActionObject, BaseApiObject, BaseSchemaWithoutType, ClassName, DataChangeReason, Schema } from '../types';
|
|
8
|
+
import { IScopedContext } from '../Scoped';
|
|
8
9
|
export type LabelAlign = 'right' | 'left' | 'top' | 'inherit';
|
|
9
10
|
export interface FormBaseControl extends BaseSchemaWithoutType {
|
|
10
11
|
/**
|
|
@@ -303,6 +304,10 @@ export interface FormBaseControl extends BaseSchemaWithoutType {
|
|
|
303
304
|
* 是否为参照录入模式,参照录入会展示候选值供用户选择,而不是直接填充。
|
|
304
305
|
*/
|
|
305
306
|
showSuggestion?: boolean;
|
|
307
|
+
/**
|
|
308
|
+
* 参照录入时,默认选中的值
|
|
309
|
+
*/
|
|
310
|
+
defaultSelection?: any;
|
|
306
311
|
/**
|
|
307
312
|
* 自动填充 api
|
|
308
313
|
*/
|
|
@@ -321,7 +326,7 @@ export interface FormBaseControl extends BaseSchemaWithoutType {
|
|
|
321
326
|
/**
|
|
322
327
|
* 触发条件,默认为 change
|
|
323
328
|
*/
|
|
324
|
-
trigger?: 'change' | '
|
|
329
|
+
trigger?: 'change' | 'focus' | 'blur';
|
|
325
330
|
/**
|
|
326
331
|
* 弹窗方式,当为参照录入时用可以配置
|
|
327
332
|
*/
|
|
@@ -359,6 +364,10 @@ export interface FormItemBasicConfig extends Partial<RendererConfig> {
|
|
|
359
364
|
storeType?: string;
|
|
360
365
|
validations?: string;
|
|
361
366
|
strictMode?: boolean;
|
|
367
|
+
/**
|
|
368
|
+
* 是否是瘦子
|
|
369
|
+
*/
|
|
370
|
+
thin?: boolean;
|
|
362
371
|
/**
|
|
363
372
|
* schema变化使视图更新的属性白名单
|
|
364
373
|
*/
|
|
@@ -394,7 +403,7 @@ export interface FormItemProps extends RendererProps {
|
|
|
394
403
|
onChange: (value: any, submitOnChange?: boolean, changeImmediately?: boolean) => void;
|
|
395
404
|
onBulkChange?: (values: {
|
|
396
405
|
[propName: string]: any;
|
|
397
|
-
}, submitOnChange?: boolean) => void;
|
|
406
|
+
}, submitOnChange?: boolean, changeReason?: DataChangeReason) => void;
|
|
398
407
|
addHook: (fn: Function, mode?: 'validate' | 'init' | 'flush', enforce?: 'prev' | 'post') => () => void;
|
|
399
408
|
removeHook: (fn: Function, mode?: 'validate' | 'init' | 'flush') => void;
|
|
400
409
|
renderFormItems: (schema: Partial<FormSchemaBase>, region: string, props: any) => JSX.Element;
|
|
@@ -444,7 +453,76 @@ export declare class FormItemWrap extends React.Component<FormItemProps> {
|
|
|
444
453
|
updateAutoFillData(context: any): void;
|
|
445
454
|
syncApiAutoFill: import("lodash").DebouncedFunc<(term: any, forceLoad?: boolean, skipIfExits?: any) => Promise<void>>;
|
|
446
455
|
syncOptionAutoFill(selectedOptions: Array<any>, skipIfExits?: boolean): void;
|
|
447
|
-
|
|
456
|
+
/**
|
|
457
|
+
* 应用映射函数,根据给定的映射关系,更新数据对象
|
|
458
|
+
*
|
|
459
|
+
* @param mapping 映射关系,类型为任意类型
|
|
460
|
+
* @param ctx 上下文对象,类型为任意类型
|
|
461
|
+
* @param skipIfExits 是否跳过已存在的属性,默认为 false
|
|
462
|
+
*/
|
|
463
|
+
applyMapping(mapping: any, ctx: any, skipIfExits?: boolean): void;
|
|
464
|
+
buildAutoFillSchema(): {
|
|
465
|
+
popOverContainer: any;
|
|
466
|
+
popOverClassName: any;
|
|
467
|
+
placement: any;
|
|
468
|
+
offset: any;
|
|
469
|
+
body: {
|
|
470
|
+
type: string;
|
|
471
|
+
title: string;
|
|
472
|
+
className: string;
|
|
473
|
+
body: {
|
|
474
|
+
type: string;
|
|
475
|
+
embed: boolean;
|
|
476
|
+
joinValues: boolean;
|
|
477
|
+
strictMode: boolean;
|
|
478
|
+
label: boolean;
|
|
479
|
+
labelField: any;
|
|
480
|
+
valueField: any;
|
|
481
|
+
multiple: any;
|
|
482
|
+
name: string;
|
|
483
|
+
value: any;
|
|
484
|
+
options: never[];
|
|
485
|
+
required: boolean;
|
|
486
|
+
source: any;
|
|
487
|
+
pickerSchema: {
|
|
488
|
+
type: string;
|
|
489
|
+
bodyClassName: string;
|
|
490
|
+
affixHeader: boolean;
|
|
491
|
+
alwaysShowPagination: boolean;
|
|
492
|
+
keepItemSelectionOnPageChange: boolean;
|
|
493
|
+
headerToolbar: never[];
|
|
494
|
+
footerToolbar: ({
|
|
495
|
+
type: string;
|
|
496
|
+
align: string;
|
|
497
|
+
className?: undefined;
|
|
498
|
+
} | {
|
|
499
|
+
type: string;
|
|
500
|
+
align: string;
|
|
501
|
+
className: string;
|
|
502
|
+
})[];
|
|
503
|
+
multiple: any;
|
|
504
|
+
filter: any;
|
|
505
|
+
columns: any;
|
|
506
|
+
};
|
|
507
|
+
}[];
|
|
508
|
+
actions: ({
|
|
509
|
+
type: string;
|
|
510
|
+
actionType: string;
|
|
511
|
+
label: any;
|
|
512
|
+
level?: undefined;
|
|
513
|
+
} | {
|
|
514
|
+
type: string;
|
|
515
|
+
actionType: string;
|
|
516
|
+
level: string;
|
|
517
|
+
label: any;
|
|
518
|
+
})[];
|
|
519
|
+
};
|
|
520
|
+
type?: undefined;
|
|
521
|
+
className?: undefined;
|
|
522
|
+
title?: undefined;
|
|
523
|
+
size?: undefined;
|
|
524
|
+
actions?: undefined;
|
|
525
|
+
} | {
|
|
448
526
|
type: any;
|
|
449
527
|
className: string;
|
|
450
528
|
title: any;
|
|
@@ -458,16 +536,19 @@ export declare class FormItemWrap extends React.Component<FormItemProps> {
|
|
|
458
536
|
type: string;
|
|
459
537
|
embed: boolean;
|
|
460
538
|
joinValues: boolean;
|
|
539
|
+
strictMode: boolean;
|
|
461
540
|
label: boolean;
|
|
462
541
|
labelField: any;
|
|
463
542
|
valueField: any;
|
|
464
543
|
multiple: any;
|
|
465
544
|
name: string;
|
|
545
|
+
value: any;
|
|
466
546
|
options: never[];
|
|
467
547
|
required: boolean;
|
|
468
548
|
source: any;
|
|
469
549
|
pickerSchema: {
|
|
470
550
|
type: string;
|
|
551
|
+
bodyClassName: string;
|
|
471
552
|
affixHeader: boolean;
|
|
472
553
|
alwaysShowPagination: boolean;
|
|
473
554
|
keepItemSelectionOnPageChange: boolean;
|
|
@@ -485,7 +566,7 @@ export declare class FormItemWrap extends React.Component<FormItemProps> {
|
|
|
485
566
|
filter: any;
|
|
486
567
|
columns: any;
|
|
487
568
|
};
|
|
488
|
-
};
|
|
569
|
+
}[];
|
|
489
570
|
actions: ({
|
|
490
571
|
type: string;
|
|
491
572
|
actionType: string;
|
|
@@ -509,10 +590,14 @@ export declare class FormItemWrap extends React.Component<FormItemProps> {
|
|
|
509
590
|
level: string;
|
|
510
591
|
label: any;
|
|
511
592
|
})[];
|
|
593
|
+
popOverContainer?: undefined;
|
|
594
|
+
popOverClassName?: undefined;
|
|
595
|
+
placement?: undefined;
|
|
596
|
+
offset?: undefined;
|
|
512
597
|
} | undefined;
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
598
|
+
handlePopOverConfirm(values: any): void;
|
|
599
|
+
handlePopOverAction(e: React.UIEvent<any>, action: ActionObject, data: object, throwErrors?: boolean, delegate?: IScopedContext): any;
|
|
600
|
+
closePopOver(): void;
|
|
516
601
|
handleOpenDialog(schema: Schema, data: any): Promise<unknown>;
|
|
517
602
|
handleDialogConfirm([values]: Array<any>): void;
|
|
518
603
|
handleDialogClose(confirmed?: boolean): void;
|
|
@@ -559,9 +644,7 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
559
644
|
} & import("mobx-state-tree/dist/internal").NonEmptyObject & {
|
|
560
645
|
readonly fetcher: any;
|
|
561
646
|
readonly notify: any;
|
|
562
|
-
readonly isCancel: (value: any) => boolean;
|
|
563
|
-
* 当修改完的时候是否提交表单。
|
|
564
|
-
*/
|
|
647
|
+
readonly isCancel: (value: any) => boolean;
|
|
565
648
|
readonly __: import("..").TranslateFn<any>;
|
|
566
649
|
getStoreById(id: string): {
|
|
567
650
|
id: string;
|
|
@@ -642,7 +725,10 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
642
725
|
} & {
|
|
643
726
|
addStore(store: {
|
|
644
727
|
[propName: string]: any;
|
|
645
|
-
storeType: string;
|
|
728
|
+
storeType: string; /**
|
|
729
|
+
* 不设置时,当表单提交过后表单项每次修改都会触发重新验证,
|
|
730
|
+
* 如果设置了,则由此配置项来决定要不要每次修改都触发验证。
|
|
731
|
+
*/
|
|
646
732
|
id: string;
|
|
647
733
|
path: string;
|
|
648
734
|
parentId?: string | undefined;
|
|
@@ -719,15 +805,15 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
719
805
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
720
806
|
addChildId: (id: string) => void;
|
|
721
807
|
removeChildId: (id: string) => void;
|
|
722
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>): void;
|
|
808
|
+
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>): void; /**
|
|
809
|
+
* 配置 input className
|
|
810
|
+
*/
|
|
723
811
|
} & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
|
|
724
812
|
storeType: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
725
813
|
}, {
|
|
726
814
|
readonly fetcher: any;
|
|
727
815
|
readonly notify: any;
|
|
728
|
-
readonly isCancel: (value: any) => boolean;
|
|
729
|
-
* 当修改完的时候是否提交表单。
|
|
730
|
-
*/
|
|
816
|
+
readonly isCancel: (value: any) => boolean;
|
|
731
817
|
readonly __: import("..").TranslateFn<any>;
|
|
732
818
|
getStoreById(id: string): {
|
|
733
819
|
id: string;
|
|
@@ -808,7 +894,10 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
808
894
|
} & {
|
|
809
895
|
addStore(store: {
|
|
810
896
|
[propName: string]: any;
|
|
811
|
-
storeType: string;
|
|
897
|
+
storeType: string; /**
|
|
898
|
+
* 不设置时,当表单提交过后表单项每次修改都会触发重新验证,
|
|
899
|
+
* 如果设置了,则由此配置项来决定要不要每次修改都触发验证。
|
|
900
|
+
*/
|
|
812
901
|
id: string;
|
|
813
902
|
path: string;
|
|
814
903
|
parentId?: string | undefined;
|
|
@@ -885,7 +974,9 @@ export declare function asFormItem(config: Omit<FormItemConfig, 'component'>): (
|
|
|
885
974
|
dispose: (callback?: (() => void) | undefined) => void;
|
|
886
975
|
addChildId: (id: string) => void;
|
|
887
976
|
removeChildId: (id: string) => void;
|
|
888
|
-
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>): void;
|
|
977
|
+
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>): void; /**
|
|
978
|
+
* 配置 input className
|
|
979
|
+
*/
|
|
889
980
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>;
|
|
890
981
|
ComposedComponent: React.ComponentType<any>;
|
|
891
982
|
} & hoistNonReactStatic.NonReactStatics<any, {}> & {
|