amis-core 6.13.0-beta.2 → 6.13.0-beta.21
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.js +15 -7
- package/esm/SchemaRenderer.js +11 -6
- package/esm/Scoped.js +1 -1
- package/esm/StatusScoped.js +1 -1
- package/esm/StyleManager.js +1 -1
- package/esm/WithRootStore.js +1 -1
- package/esm/WithStore.js +1 -1
- package/esm/actions/Action.js +60 -15
- package/esm/actions/AjaxAction.js +2 -2
- package/esm/actions/BreakAction.js +1 -1
- package/esm/actions/BroadcastAction.js +1 -1
- package/esm/actions/CmptAction.js +48 -43
- package/esm/actions/ContinueAction.js +1 -1
- package/esm/actions/CopyAction.js +1 -1
- package/esm/actions/CustomAction.js +7 -7
- package/esm/actions/DialogAction.js +8 -8
- package/esm/actions/DrawerAction.js +8 -8
- package/esm/actions/EmailAction.js +1 -1
- package/esm/actions/EventAction.js +9 -9
- 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.js +1 -1
- 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.js +1 -1
- package/esm/components/Animations.js +7 -7
- package/esm/components/CustomStyle.js +1 -1
- package/esm/components/ErrorBoundary.js +1 -1
- package/esm/components/LazyComponent.js +1 -1
- package/esm/components/Overlay.js +7 -7
- package/esm/components/PopOver.js +9 -7
- package/esm/env.js +1 -1
- package/esm/envOverwrite.js +1 -1
- package/esm/factory.js +1 -1
- package/esm/globalVar.js +1 -1
- package/esm/globalVarClientHandler.js +1 -1
- package/esm/globalVarDefaultValueHandler.js +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.js +8 -8
- package/esm/locale.js +1 -1
- package/esm/polyfills.js +1 -1
- package/esm/renderers/Form.d.ts +5 -1
- package/esm/renderers/Form.js +72 -24
- package/esm/renderers/Item.js +1 -1
- package/esm/renderers/Options.js +1 -1
- 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 +0 -1
- package/esm/renderers/wrapControl.js +30 -14
- package/esm/store/app.d.ts +2 -0
- package/esm/store/app.js +8 -8
- package/esm/store/combo.d.ts +132 -0
- package/esm/store/combo.js +24 -2
- package/esm/store/crud.d.ts +3 -0
- package/esm/store/crud.js +6 -2
- package/esm/store/form.d.ts +52 -0
- package/esm/store/form.js +3 -3
- package/esm/store/formItem.d.ts +1 -0
- package/esm/store/formItem.js +4 -2
- package/esm/store/iRenderer.d.ts +2 -0
- package/esm/store/iRenderer.js +9 -3
- package/esm/store/index.js +1 -1
- package/esm/store/list.d.ts +2 -0
- package/esm/store/list.js +1 -1
- package/esm/store/manager.js +1 -1
- package/esm/store/modal.d.ts +4 -0
- package/esm/store/modal.js +7 -2
- package/esm/store/node.js +1 -1
- package/esm/store/pagination.d.ts +2 -0
- package/esm/store/pagination.js +1 -1
- package/esm/store/root.d.ts +8 -2
- package/esm/store/root.js +142 -72
- package/esm/store/service.d.ts +2 -0
- package/esm/store/service.js +8 -8
- package/esm/store/status.js +1 -1
- package/esm/store/table.d.ts +146 -92
- package/esm/store/table.js +36 -19
- package/esm/store/table2.d.ts +2 -0
- package/esm/store/table2.js +4 -3
- package/esm/theme.js +1 -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/animations.js +1 -1
- package/esm/utils/api.js +8 -3
- 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 +6 -9
- package/esm/utils/debug.js +1 -1
- package/esm/utils/decodeEntity.js +1 -1
- package/esm/utils/dom.js +6 -3
- package/esm/utils/errors.js +2 -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/getPageId.js +1 -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.js +3 -3
- package/esm/utils/highlight.js +1 -1
- package/esm/utils/icon.js +1 -1
- package/esm/utils/image.js +1 -1
- package/esm/utils/index.d.ts +1 -1
- package/esm/utils/index.js +9 -9
- 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 +1 -1
- package/esm/utils/loopTooMuch.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 +6 -2
- 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.d.ts +3 -1
- package/esm/utils/resize-sensor.js +63 -29
- package/esm/utils/resolveCondition.js +2 -2
- package/esm/utils/resolveVariable.js +1 -1
- package/esm/utils/resolveVariableAndFilter.js +4 -3
- 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.d.ts +12 -1
- package/esm/utils/style-helper.js +30 -18
- package/esm/utils/style.d.ts +13 -0
- package/esm/utils/style.js +44 -4
- package/esm/utils/toNumber.js +1 -1
- package/esm/utils/tokenize.js +1 -1
- package/esm/utils/tpl-builtin.d.ts +1 -0
- package/esm/utils/tpl-builtin.js +7 -3
- package/esm/utils/tpl-lodash.js +1 -1
- package/esm/utils/tpl.js +6 -2
- package/esm/utils/uncontrollable.js +1 -1
- package/esm/utils/validateId.js +1 -1
- package/esm/utils/validations.js +2 -2
- package/esm/utils/visitedCache.js +1 -1
- package/lib/Root.js +1 -1
- package/lib/RootRenderer.d.ts +1 -1
- package/lib/RootRenderer.js +15 -7
- package/lib/SchemaRenderer.js +10 -5
- package/lib/Scoped.js +1 -1
- package/lib/StatusScoped.js +1 -1
- package/lib/StyleManager.js +1 -1
- package/lib/WithRootStore.js +1 -1
- package/lib/WithStore.js +1 -1
- package/lib/actions/Action.js +62 -14
- package/lib/actions/AjaxAction.js +2 -2
- package/lib/actions/BreakAction.js +1 -1
- package/lib/actions/BroadcastAction.js +1 -1
- package/lib/actions/CmptAction.js +48 -43
- package/lib/actions/ContinueAction.js +1 -1
- package/lib/actions/CopyAction.js +1 -1
- package/lib/actions/CustomAction.js +7 -7
- package/lib/actions/DialogAction.js +8 -8
- package/lib/actions/DrawerAction.js +8 -8
- package/lib/actions/EmailAction.js +1 -1
- package/lib/actions/EventAction.js +9 -9
- 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.js +1 -1
- 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.js +1 -1
- package/lib/components/Animations.js +7 -7
- package/lib/components/CustomStyle.js +1 -1
- package/lib/components/ErrorBoundary.js +1 -1
- package/lib/components/LazyComponent.js +1 -1
- package/lib/components/Overlay.js +7 -7
- package/lib/components/PopOver.js +9 -7
- package/lib/env.js +1 -1
- package/lib/envOverwrite.js +1 -1
- package/lib/factory.js +1 -1
- package/lib/globalVar.js +1 -1
- package/lib/globalVarClientHandler.js +1 -1
- package/lib/globalVarDefaultValueHandler.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +12 -6
- package/lib/locale.js +1 -1
- package/lib/polyfills.js +1 -1
- package/lib/renderers/Form.d.ts +5 -1
- package/lib/renderers/Form.js +71 -23
- package/lib/renderers/Item.js +1 -1
- package/lib/renderers/Options.js +1 -1
- 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 +0 -1
- package/lib/renderers/wrapControl.js +30 -14
- package/lib/store/app.d.ts +2 -0
- package/lib/store/app.js +8 -8
- package/lib/store/combo.d.ts +156 -25
- package/lib/store/combo.js +24 -2
- package/lib/store/crud.d.ts +3 -0
- package/lib/store/crud.js +6 -2
- package/lib/store/form.d.ts +62 -11
- package/lib/store/form.js +3 -3
- package/lib/store/formItem.d.ts +1 -0
- package/lib/store/formItem.js +4 -2
- package/lib/store/iRenderer.d.ts +2 -0
- package/lib/store/iRenderer.js +9 -3
- package/lib/store/index.js +1 -1
- package/lib/store/list.d.ts +2 -0
- package/lib/store/list.js +1 -1
- package/lib/store/manager.js +1 -1
- package/lib/store/modal.d.ts +4 -0
- package/lib/store/modal.js +7 -2
- package/lib/store/node.js +1 -1
- package/lib/store/pagination.d.ts +2 -0
- package/lib/store/pagination.js +1 -1
- package/lib/store/root.d.ts +8 -3
- package/lib/store/root.js +140 -70
- package/lib/store/service.d.ts +2 -0
- package/lib/store/service.js +8 -8
- package/lib/store/status.js +1 -1
- package/lib/store/table.d.ts +166 -113
- package/lib/store/table.js +36 -19
- package/lib/store/table2.d.ts +2 -0
- package/lib/store/table2.js +4 -3
- package/lib/theme.js +1 -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/animations.js +1 -1
- package/lib/utils/api.js +8 -3
- 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 +6 -9
- package/lib/utils/debug.js +1 -1
- package/lib/utils/decodeEntity.js +1 -1
- package/lib/utils/dom.js +6 -3
- package/lib/utils/errors.js +2 -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/getPageId.js +1 -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.js +3 -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/index.d.ts +1 -1
- package/lib/utils/index.js +22 -20
- 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 +1 -1
- package/lib/utils/loopTooMuch.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 +6 -2
- 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.d.ts +3 -1
- package/lib/utils/resize-sensor.js +64 -28
- package/lib/utils/resolveCondition.js +2 -2
- package/lib/utils/resolveVariable.js +1 -1
- package/lib/utils/resolveVariableAndFilter.js +3 -2
- 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.d.ts +12 -1
- package/lib/utils/style-helper.js +30 -17
- package/lib/utils/style.d.ts +13 -0
- package/lib/utils/style.js +45 -3
- package/lib/utils/toNumber.js +1 -1
- package/lib/utils/tokenize.js +1 -1
- package/lib/utils/tpl-builtin.d.ts +1 -0
- package/lib/utils/tpl-builtin.js +7 -2
- package/lib/utils/tpl-lodash.js +1 -1
- package/lib/utils/tpl.js +6 -2
- package/lib/utils/uncontrollable.js +1 -1
- package/lib/utils/validateId.js +1 -1
- package/lib/utils/validations.js +2 -2
- package/lib/utils/visitedCache.js +1 -1
- package/package.json +5 -3
package/lib/renderers/Form.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.13.0-beta.
|
|
2
|
+
* amis-core v6.13.0-beta.21
|
|
3
3
|
* Copyright 2018-2025 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -56,6 +56,12 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
56
56
|
trailing: true,
|
|
57
57
|
leading: false
|
|
58
58
|
});
|
|
59
|
+
// 当有多次调用时,只需要跳一个
|
|
60
|
+
_this.lazyJumpToErrorComponent = debounce__default["default"](_this.jumpToErrorComponent.bind(_this), 250, {
|
|
61
|
+
trailing: false,
|
|
62
|
+
leading: true
|
|
63
|
+
});
|
|
64
|
+
_this.formRef = React__default["default"].createRef();
|
|
59
65
|
// 如果开启了 lazyChange,需要一个 flush 方法把队列中值应用上。
|
|
60
66
|
_this.flushing = false;
|
|
61
67
|
_this.emittedData = null;
|
|
@@ -82,7 +88,7 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
82
88
|
_this.dispatchInited = _this.dispatchInited.bind(_this);
|
|
83
89
|
_this.blockRouting = _this.blockRouting.bind(_this);
|
|
84
90
|
_this.beforePageUnload = _this.beforePageUnload.bind(_this);
|
|
85
|
-
_this.
|
|
91
|
+
_this.dispatchEvent = _this.dispatchEvent.bind(_this);
|
|
86
92
|
_this.flush = _this.flush.bind(_this);
|
|
87
93
|
var store = props.store, canAccessSuperData = props.canAccessSuperData, persistData = props.persistData, simpleMode = props.simpleMode, formLazyChange = props.formLazyChange;
|
|
88
94
|
store.setCanAccessSuperData(canAccessSuperData !== false);
|
|
@@ -180,6 +186,11 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
180
186
|
}
|
|
181
187
|
})
|
|
182
188
|
.then(this.initInterval)
|
|
189
|
+
.then(function () {
|
|
190
|
+
return _this.props.dispatchEvent('initApiFinished', object.injectObjectChain(store.data, {
|
|
191
|
+
__trigger: 'init'
|
|
192
|
+
}));
|
|
193
|
+
})
|
|
183
194
|
.then(this.onInit);
|
|
184
195
|
}
|
|
185
196
|
else {
|
|
@@ -209,6 +220,7 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
209
220
|
clearTimeout(this.timer);
|
|
210
221
|
// this.lazyHandleChange.flush();
|
|
211
222
|
this.lazyEmitChange.cancel();
|
|
223
|
+
this.lazyJumpToErrorComponent.cancel();
|
|
212
224
|
this.asyncCancel && this.asyncCancel();
|
|
213
225
|
this.toDispose.forEach(function (fn) { return fn(); });
|
|
214
226
|
this.toDispose = [];
|
|
@@ -263,6 +275,7 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
263
275
|
Form.prototype.onInit = function () {
|
|
264
276
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
265
277
|
var _a, onInit, store, persistData, submitOnInit, dispatchEvent, data, initedAt, hooks, groupedHooks, dispatch;
|
|
278
|
+
var _this = this;
|
|
266
279
|
return tslib.__generator(this, function (_b) {
|
|
267
280
|
switch (_b.label) {
|
|
268
281
|
case 0:
|
|
@@ -273,6 +286,13 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
273
286
|
data = object.cloneObject(store.data);
|
|
274
287
|
initedAt = store.initedAt;
|
|
275
288
|
store.setInited(true);
|
|
289
|
+
// 等待 formInited 属性下发成功
|
|
290
|
+
// 因为 hooks 里面可以能有读取 props 的操作
|
|
291
|
+
return [4 /*yield*/, new Promise(function (resolve) { return _this.forceUpdate(resolve); })];
|
|
292
|
+
case 1:
|
|
293
|
+
// 等待 formInited 属性下发成功
|
|
294
|
+
// 因为 hooks 里面可以能有读取 props 的操作
|
|
295
|
+
_b.sent();
|
|
276
296
|
hooks = this.hooks['init'] || [];
|
|
277
297
|
groupedHooks = groupBy__default["default"](hooks, function (item) {
|
|
278
298
|
return item.__enforce === 'prev'
|
|
@@ -282,15 +302,15 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
282
302
|
: 'normal';
|
|
283
303
|
});
|
|
284
304
|
return [4 /*yield*/, Promise.all((groupedHooks.prev || []).map(function (hook) { return hook(data); }))];
|
|
285
|
-
case
|
|
305
|
+
case 2:
|
|
286
306
|
_b.sent();
|
|
287
307
|
// 有可能在前面的步骤中删除了钩子,所以需要重新验证一下
|
|
288
308
|
return [4 /*yield*/, Promise.all((groupedHooks.normal || []).map(function (hook) { return hooks.includes(hook) && hook(data); }))];
|
|
289
|
-
case
|
|
309
|
+
case 3:
|
|
290
310
|
// 有可能在前面的步骤中删除了钩子,所以需要重新验证一下
|
|
291
311
|
_b.sent();
|
|
292
312
|
return [4 /*yield*/, Promise.all((groupedHooks.post || []).map(function (hook) { return hooks.includes(hook) && hook(data); }))];
|
|
293
|
-
case
|
|
313
|
+
case 4:
|
|
294
314
|
_b.sent();
|
|
295
315
|
if (!mobxStateTree.isAlive(store)) {
|
|
296
316
|
return [2 /*return*/];
|
|
@@ -308,7 +328,7 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
308
328
|
}
|
|
309
329
|
onInit && onInit(data, this.props);
|
|
310
330
|
return [4 /*yield*/, this.dispatchInited({ data: data })];
|
|
311
|
-
case
|
|
331
|
+
case 5:
|
|
312
332
|
dispatch = _b.sent();
|
|
313
333
|
if (dispatch === null || dispatch === void 0 ? void 0 : dispatch.prevented) {
|
|
314
334
|
return [2 /*return*/];
|
|
@@ -340,7 +360,7 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
340
360
|
_c[initFinishedField || 'finished'] = false,
|
|
341
361
|
_c));
|
|
342
362
|
result = undefined;
|
|
343
|
-
if (!api.isEffectiveApi(initApi, store.data)) return [3 /*break*/,
|
|
363
|
+
if (!api.isEffectiveApi(initApi, store.data)) return [3 /*break*/, 4];
|
|
344
364
|
return [4 /*yield*/, store.fetchInitData(initApi, store.data, {
|
|
345
365
|
successMessage: fetchSuccess,
|
|
346
366
|
errorMessage: fetchFailed,
|
|
@@ -356,15 +376,20 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
356
376
|
})];
|
|
357
377
|
case 1:
|
|
358
378
|
result = _d.sent();
|
|
359
|
-
if (result === null || result === void 0 ? void 0 : result.ok)
|
|
360
|
-
|
|
361
|
-
store.reset(undefined, false);
|
|
362
|
-
}
|
|
363
|
-
return [3 /*break*/, 3];
|
|
364
|
-
case 2:
|
|
379
|
+
if (!(result === null || result === void 0 ? void 0 : result.ok)) return [3 /*break*/, 3];
|
|
380
|
+
this.initInterval(result);
|
|
365
381
|
store.reset(undefined, false);
|
|
382
|
+
return [4 /*yield*/, this.props.dispatchEvent('initApiFinished', object.injectObjectChain(store.data, {
|
|
383
|
+
__trigger: 'reload'
|
|
384
|
+
}))];
|
|
385
|
+
case 2:
|
|
386
|
+
_d.sent();
|
|
366
387
|
_d.label = 3;
|
|
367
|
-
case 3:
|
|
388
|
+
case 3: return [3 /*break*/, 5];
|
|
389
|
+
case 4:
|
|
390
|
+
store.reset(undefined, false);
|
|
391
|
+
_d.label = 5;
|
|
392
|
+
case 5:
|
|
368
393
|
// 派发初始化接口请求完成事件
|
|
369
394
|
this.dispatchInited(result);
|
|
370
395
|
return [2 /*return*/, store.data];
|
|
@@ -566,9 +591,34 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
566
591
|
store.setLocalPersistData(persistDataKeys);
|
|
567
592
|
}
|
|
568
593
|
};
|
|
569
|
-
Form.prototype.
|
|
570
|
-
var
|
|
571
|
-
|
|
594
|
+
Form.prototype.jumpToErrorComponent = function (renderer) {
|
|
595
|
+
var _a, _b;
|
|
596
|
+
// 当表单校验错误是,优先调用组件的 focus
|
|
597
|
+
// 如果没有 focus 方法,则滚动到错误信息的位置
|
|
598
|
+
if (typeof (renderer === null || renderer === void 0 ? void 0 : renderer.focus) === 'function') {
|
|
599
|
+
renderer.focus();
|
|
600
|
+
}
|
|
601
|
+
else {
|
|
602
|
+
(_b = (_a = this.formRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(".".concat(this.props.classPrefix, "Form-feedback"))) === null || _b === void 0 ? void 0 : _b.scrollIntoView({
|
|
603
|
+
behavior: 'smooth',
|
|
604
|
+
block: 'center'
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
Form.prototype.dispatchEvent = function (e, data, renderer, // for didmount
|
|
609
|
+
scoped) {
|
|
610
|
+
// 把这两个事件转到 form 组件上,让 form 组件来处理
|
|
611
|
+
if ((e === 'formItemValidateSucc' || e === 'formItemValidateError') &&
|
|
612
|
+
(renderer === null || renderer === void 0 ? void 0 : renderer.props.type) !== 'form') {
|
|
613
|
+
if (e === 'formItemValidateError') {
|
|
614
|
+
this.lazyJumpToErrorComponent(renderer);
|
|
615
|
+
}
|
|
616
|
+
// 如果事件是 formItemValidateSucc 或者 formItemValidateError 转成当前组件触发的,
|
|
617
|
+
// 所以 onEvent 是配置在 form 层的而不是表单项层
|
|
618
|
+
renderer = undefined;
|
|
619
|
+
scoped = undefined;
|
|
620
|
+
}
|
|
621
|
+
return this.props.dispatchEvent(e, data, renderer, scoped);
|
|
572
622
|
};
|
|
573
623
|
Form.prototype.emitChange = function (submit, emitedFromWatch) {
|
|
574
624
|
if (emitedFromWatch === void 0) { emitedFromWatch = false; }
|
|
@@ -1245,7 +1295,7 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
1245
1295
|
addHook: this.addHook,
|
|
1246
1296
|
removeHook: this.removeHook,
|
|
1247
1297
|
renderFormItems: this.renderFormItems,
|
|
1248
|
-
|
|
1298
|
+
dispatchEvent: this.dispatchEvent,
|
|
1249
1299
|
formPristine: form.pristine,
|
|
1250
1300
|
onFlushForm: this.flush
|
|
1251
1301
|
// value: (control as any)?.name
|
|
@@ -1268,7 +1318,7 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
1268
1318
|
var padDom = helper.repeatCount(columnCount && Array.isArray(body)
|
|
1269
1319
|
? (columnCount - (body.length % columnCount)) % columnCount
|
|
1270
1320
|
: 0, function (index) { return (_J$X_("div", { className: cx("Form-item Form-item--".concat(mode, " is-placeholder")), key: index })); });
|
|
1271
|
-
return (_J$X_(WrapperComponent, { className: cx("Form", "Form--".concat(mode || 'normal'), columnCount ? "Form--column Form--column-".concat(columnCount) : null, staticClassName && isStatic ? staticClassName : className, isStatic ? 'Form--isStatic' : null, styleHelper.setThemeClassName(tslib.__assign(tslib.__assign({}, this.props), { name: [
|
|
1321
|
+
return (_J$X_(WrapperComponent, { ref: this.formRef, className: cx("Form", "Form--".concat(mode || 'normal'), columnCount ? "Form--column Form--column-".concat(columnCount) : null, staticClassName && isStatic ? staticClassName : className, isStatic ? 'Form--isStatic' : null, styleHelper.setThemeClassName(tslib.__assign(tslib.__assign({}, this.props), { name: [
|
|
1272
1322
|
'formControlClassName',
|
|
1273
1323
|
'itemClassName',
|
|
1274
1324
|
'staticClassName',
|
|
@@ -1289,16 +1339,14 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
1289
1339
|
}),
|
|
1290
1340
|
padDom,
|
|
1291
1341
|
restError && restError.length ? (_J$X_("ul", { className: cx('Form-restError', 'Form-feedback') }, restError.map(function (item, idx) { return (_J$X_("li", { key: idx }, item)); }))) : null,
|
|
1292
|
-
render('modal', tslib.__assign(tslib.__assign({},
|
|
1293
|
-
store.action.dialog)), { type: 'dialog' }), {
|
|
1342
|
+
render('modal', tslib.__assign(tslib.__assign({}, store.dialogSchema), { type: 'dialog' }), {
|
|
1294
1343
|
key: 'dialog',
|
|
1295
1344
|
data: store.dialogData,
|
|
1296
1345
|
onConfirm: this.handleDialogConfirm,
|
|
1297
1346
|
onClose: this.handleDialogClose,
|
|
1298
1347
|
show: store.dialogOpen
|
|
1299
1348
|
}),
|
|
1300
|
-
render('modal', tslib.__assign(tslib.__assign({},
|
|
1301
|
-
store.action.drawer)), { type: 'drawer' }), {
|
|
1349
|
+
render('modal', tslib.__assign(tslib.__assign({}, store.drawerSchema), { type: 'drawer' }), {
|
|
1302
1350
|
key: 'drawer',
|
|
1303
1351
|
data: store.drawerData,
|
|
1304
1352
|
onConfirm: this.handleDrawerConfirm,
|
package/lib/renderers/Item.js
CHANGED
package/lib/renderers/Options.js
CHANGED
package/lib/renderers/builtin.js
CHANGED
|
@@ -42,7 +42,6 @@ export interface ControlOutterProps extends RendererProps {
|
|
|
42
42
|
};
|
|
43
43
|
store?: IIRendererStore;
|
|
44
44
|
onChange?: (value: any, name: string, submit?: boolean, changePristine?: boolean, changeReason?: DataChangeReason) => void;
|
|
45
|
-
formItemDispatchEvent: (type: string, data: any) => void;
|
|
46
45
|
formItemRef?: (control: any) => void;
|
|
47
46
|
}
|
|
48
47
|
export interface ControlProps {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.13.0-beta.
|
|
2
|
+
* amis-core v6.13.0-beta.21
|
|
3
3
|
* Copyright 2018-2025 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -23,8 +23,10 @@ var hoistNonReactStatic = require('hoist-non-react-statics');
|
|
|
23
23
|
var WithRootStore = require('../WithRootStore.js');
|
|
24
24
|
var table = require('../store/table.js');
|
|
25
25
|
var pick = require('lodash/pick');
|
|
26
|
+
var mobx = require('mobx');
|
|
26
27
|
require('../utils/index.js');
|
|
27
28
|
var tokenize = require('../utils/tokenize.js');
|
|
29
|
+
var object = require('../utils/object.js');
|
|
28
30
|
var getVariable = require('../utils/getVariable.js');
|
|
29
31
|
var api = require('../utils/api.js');
|
|
30
32
|
|
|
@@ -74,6 +76,7 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
74
76
|
if (!name) {
|
|
75
77
|
return _this;
|
|
76
78
|
}
|
|
79
|
+
var valueIsExp = formula.isExpression(value);
|
|
77
80
|
var propValue = _this.props.value;
|
|
78
81
|
var model = rootStore.addStore({
|
|
79
82
|
id: helper.guid(),
|
|
@@ -90,8 +93,7 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
90
93
|
? tslib.__assign(tslib.__assign({}, validations$1), validations.str2rules(config.validations)) : validations$1;
|
|
91
94
|
// @issue 打算干掉这个
|
|
92
95
|
formItem$1 === null || formItem$1 === void 0 ? void 0 : formItem$1.addSubFormItem(model);
|
|
93
|
-
model.config(tslib.__assign(tslib.__assign({}, pick__default["default"](tslib.__assign(tslib.__assign({}, ComposedComponent.defaultProps), _this.props.$schema), ['multiple'])), { id: id, type: type, required: props.required || required, unique: unique, value: value, isValueSchemaExp:
|
|
94
|
-
value.replace(/\s/g, '') !== "${".concat(name, "}"), rules: rules, messages: validationErrors, delimiter: delimiter, valueField: valueField, labelField: labelField, joinValues: joinValues, extractValue: extractValue, selectFirst: selectFirst, autoFill: autoFill, clearValueOnHidden: clearValueOnHidden, validateApi: validateApi, minLength: minLength, maxLength: maxLength, validateOnChange: validateOnChange, label: label, inputGroupControl: inputGroupControl, extraName: extraName, pagination: pagination }));
|
|
96
|
+
model.config(tslib.__assign(tslib.__assign({}, pick__default["default"](tslib.__assign(tslib.__assign({}, ComposedComponent.defaultProps), _this.props.$schema), ['multiple'])), { id: id, type: type, required: props.required || required, unique: unique, value: value, isValueSchemaExp: valueIsExp && value.replace(/\s/g, '') !== "${".concat(name, "}"), rules: rules, messages: validationErrors, delimiter: delimiter, valueField: valueField, labelField: labelField, joinValues: joinValues, extractValue: extractValue, selectFirst: selectFirst, autoFill: autoFill, clearValueOnHidden: clearValueOnHidden, validateApi: validateApi, minLength: minLength, maxLength: maxLength, validateOnChange: validateOnChange, label: label, inputGroupControl: inputGroupControl, extraName: extraName, pagination: pagination }));
|
|
95
97
|
// issue 这个逻辑应该在 combo 里面自己实现。
|
|
96
98
|
if (_this.model.unique &&
|
|
97
99
|
((_b = form === null || form === void 0 ? void 0 : form.parentStore) === null || _b === void 0 ? void 0 : _b.storeType) === combo.ComboStore.name) {
|
|
@@ -108,7 +110,13 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
108
110
|
}
|
|
109
111
|
if (onChange &&
|
|
110
112
|
value !== undefined &&
|
|
111
|
-
model.tmpValue !== undefined
|
|
113
|
+
model.tmpValue !== undefined &&
|
|
114
|
+
// 要么是默认值起作用了
|
|
115
|
+
// 要么是表达式起作用了
|
|
116
|
+
// 只有这两种情况才会触发 onChange
|
|
117
|
+
// 比如以下 case 就不应该触发
|
|
118
|
+
// 关联到上下文数据了,同时设置了默认值,因为是上下文数据优先,这个时候就不应该触发 onChange,因为没变化
|
|
119
|
+
(value === model.tmpValue || valueIsExp)) {
|
|
112
120
|
// 组件默认值支持表达式需要: 避免初始化时上下文中丢失组件默认值
|
|
113
121
|
if (model.extraName) {
|
|
114
122
|
var values = model.splitExtraValue(model.tmpValue);
|
|
@@ -136,6 +144,17 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
136
144
|
onChange(model.tmpValue, model.name, false, true);
|
|
137
145
|
}
|
|
138
146
|
}
|
|
147
|
+
_this.reaction = mobx.reaction(function () { return model.validatedAt; }, function (validatedAt) {
|
|
148
|
+
var _a, _b, _c, _d;
|
|
149
|
+
(_b = (_a = _this.props).dispatchEvent) === null || _b === void 0 ? void 0 : _b.call(_a, model.valid
|
|
150
|
+
? 'formItemValidateSucc'
|
|
151
|
+
: 'formItemValidateError', object.injectObjectChain((_d = (_c = _this.props.formStore) === null || _c === void 0 ? void 0 : _c.data) !== null && _d !== void 0 ? _d : _this.props.data, {
|
|
152
|
+
__errors: model.errors,
|
|
153
|
+
__formName: model.name,
|
|
154
|
+
__formValue: model.tmpValue,
|
|
155
|
+
__formControl: _this.control
|
|
156
|
+
}));
|
|
157
|
+
});
|
|
139
158
|
return _this;
|
|
140
159
|
}
|
|
141
160
|
class_1.prototype.componentDidMount = function () {
|
|
@@ -390,15 +409,14 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
390
409
|
}
|
|
391
410
|
};
|
|
392
411
|
class_1.prototype.validate = function () {
|
|
393
|
-
var _a, _b;
|
|
394
412
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
395
|
-
var
|
|
396
|
-
return tslib.__generator(this, function (
|
|
397
|
-
switch (
|
|
413
|
+
var _a, form, data, dispatchEvent, result, combo$1, group, validPromises, valid;
|
|
414
|
+
return tslib.__generator(this, function (_b) {
|
|
415
|
+
switch (_b.label) {
|
|
398
416
|
case 0:
|
|
399
417
|
if (!this.model)
|
|
400
418
|
return [2 /*return*/];
|
|
401
|
-
|
|
419
|
+
_a = this.props, form = _a.formStore, data = _a.data, dispatchEvent = _a.dispatchEvent;
|
|
402
420
|
if (!(this.model.unique &&
|
|
403
421
|
(form === null || form === void 0 ? void 0 : form.parentStore) &&
|
|
404
422
|
form.parentStore.storeType === combo.ComboStore.name)) return [3 /*break*/, 2];
|
|
@@ -409,16 +427,14 @@ var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;
|
|
|
409
427
|
});
|
|
410
428
|
return [4 /*yield*/, Promise.all(validPromises)];
|
|
411
429
|
case 1:
|
|
412
|
-
result =
|
|
430
|
+
result = _b.sent();
|
|
413
431
|
return [3 /*break*/, 4];
|
|
414
432
|
case 2: return [4 /*yield*/, this.model.validate(data)];
|
|
415
433
|
case 3:
|
|
416
|
-
result = [
|
|
417
|
-
|
|
434
|
+
result = [_b.sent()];
|
|
435
|
+
_b.label = 4;
|
|
418
436
|
case 4:
|
|
419
437
|
valid = !result.some(function (item) { return item === false; });
|
|
420
|
-
(_a = (formItemDispatchEvent !== null && formItemDispatchEvent !== void 0 ? formItemDispatchEvent : this.props.dispatchEvent)) === null || _a === void 0 ? void 0 : _a(valid ? 'formItemValidateSucc' : 'formItemValidateError', (_b = form === null || form === void 0 ? void 0 : form.data) !== null && _b !== void 0 ? _b : this.props.data // form里的一定是最新的数据
|
|
421
|
-
);
|
|
422
438
|
return [2 /*return*/, valid];
|
|
423
439
|
}
|
|
424
440
|
});
|
package/lib/store/app.d.ts
CHANGED
|
@@ -17,8 +17,10 @@ export declare const AppStore: import("mobx-state-tree").IModelType<{
|
|
|
17
17
|
pristineRaw: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
18
18
|
upStreamData: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
19
19
|
action: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
20
|
+
dialogSchema: import("mobx-state-tree").IType<any, any, any>;
|
|
20
21
|
dialogOpen: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
21
22
|
dialogData: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
23
|
+
drawerSchema: import("mobx-state-tree").IType<any, any, any>;
|
|
22
24
|
drawerOpen: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
23
25
|
drawerData: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
|
|
24
26
|
} & {
|
package/lib/store/app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-core v6.13.0-beta.
|
|
2
|
+
* amis-core v6.13.0-beta.21
|
|
3
3
|
* Copyright 2018-2025 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -11,27 +11,27 @@ var tslib = require('tslib');
|
|
|
11
11
|
var mobxStateTree = require('mobx-state-tree');
|
|
12
12
|
var helper = require('../utils/helper.js');
|
|
13
13
|
var service = require('./service.js');
|
|
14
|
+
require('amis-formula');
|
|
15
|
+
require('moment');
|
|
16
|
+
var object = require('../utils/object.js');
|
|
17
|
+
require('../utils/memoryParse.js');
|
|
18
|
+
require('@rc-component/mini-decimal');
|
|
19
|
+
require('lodash/isPlainObject');
|
|
20
|
+
require('../utils/filter.js');
|
|
14
21
|
require('../utils/api.js');
|
|
15
22
|
require('file-saver');
|
|
16
23
|
require('../utils/browser.js');
|
|
17
24
|
require('../utils/ColorScale.js');
|
|
18
25
|
require('../utils/columnsSplit.js');
|
|
19
|
-
var object = require('../utils/object.js');
|
|
20
|
-
require('../utils/memoryParse.js');
|
|
21
|
-
require('amis-formula');
|
|
22
|
-
require('lodash/isPlainObject');
|
|
23
26
|
require('../utils/DataSchema.js');
|
|
24
27
|
require('../utils/DataScope.js');
|
|
25
|
-
require('moment');
|
|
26
28
|
require('../utils/debug.js');
|
|
27
29
|
require('../utils/dom.js');
|
|
28
30
|
require('../utils/errors.js');
|
|
29
31
|
var tpl = require('../utils/tpl.js');
|
|
30
|
-
require('../utils/filter.js');
|
|
31
32
|
require('lodash/isObject');
|
|
32
33
|
require('lodash/isString');
|
|
33
34
|
require('lodash/isBoolean');
|
|
34
|
-
require('@rc-component/mini-decimal');
|
|
35
35
|
require('../utils/highlight.js');
|
|
36
36
|
require('../utils/icon.js');
|
|
37
37
|
require('../utils/image.js');
|