amis-core 6.3.0 → 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.
Files changed (282) hide show
  1. package/esm/Root.js +1 -1
  2. package/esm/RootRenderer.js +1 -1
  3. package/esm/SchemaRenderer.js +3 -2
  4. package/esm/Scoped.d.ts +1 -0
  5. package/esm/Scoped.js +28 -14
  6. package/esm/StatusScoped.js +1 -1
  7. package/esm/WithRootStore.js +1 -1
  8. package/esm/WithStore.js +1 -1
  9. package/esm/actions/Action.js +4 -2
  10. package/esm/actions/AjaxAction.js +29 -19
  11. package/esm/actions/BreakAction.js +1 -1
  12. package/esm/actions/BroadcastAction.js +1 -1
  13. package/esm/actions/CmptAction.js +2 -2
  14. package/esm/actions/ContinueAction.js +1 -1
  15. package/esm/actions/CopyAction.js +1 -1
  16. package/esm/actions/CustomAction.js +1 -1
  17. package/esm/actions/DialogAction.js +30 -14
  18. package/esm/actions/DrawerAction.js +15 -7
  19. package/esm/actions/EmailAction.js +1 -1
  20. package/esm/actions/EventAction.js +1 -1
  21. package/esm/actions/LinkAction.js +1 -1
  22. package/esm/actions/LoopAction.js +1 -1
  23. package/esm/actions/PageAction.js +1 -1
  24. package/esm/actions/ParallelAction.js +1 -1
  25. package/esm/actions/PrintAction.d.ts +2 -2
  26. package/esm/actions/PrintAction.js +6 -6
  27. package/esm/actions/StatusAction.js +1 -1
  28. package/esm/actions/SwitchAction.js +1 -1
  29. package/esm/actions/ToastAction.js +1 -1
  30. package/esm/actions/WaitAction.js +1 -1
  31. package/esm/components/CustomStyle.js +1 -4
  32. package/esm/components/ErrorBoundary.js +1 -1
  33. package/esm/components/LazyComponent.js +1 -1
  34. package/esm/components/Overlay.js +1 -1
  35. package/esm/components/PopOver.js +1 -1
  36. package/esm/env.js +1 -1
  37. package/esm/envOverwrite.js +1 -1
  38. package/esm/factory.d.ts +1 -0
  39. package/esm/factory.js +1 -1
  40. package/esm/index.js +2 -2
  41. package/esm/locale.js +1 -1
  42. package/esm/polyfills.js +1 -1
  43. package/esm/renderers/Form.d.ts +3 -2
  44. package/esm/renderers/Form.js +55 -44
  45. package/esm/renderers/Item.js +1 -1
  46. package/esm/renderers/Options.js +1 -1
  47. package/esm/renderers/Placeholder.js +1 -1
  48. package/esm/renderers/builtin.js +1 -1
  49. package/esm/renderers/register.js +1 -1
  50. package/esm/renderers/wrapControl.js +31 -27
  51. package/esm/store/app.js +1 -1
  52. package/esm/store/combo.js +1 -1
  53. package/esm/store/crud.js +12 -6
  54. package/esm/store/form.js +1 -1
  55. package/esm/store/formItem.js +1 -1
  56. package/esm/store/iRenderer.js +6 -3
  57. package/esm/store/index.js +1 -1
  58. package/esm/store/list.d.ts +13 -0
  59. package/esm/store/list.js +14 -1
  60. package/esm/store/manager.js +1 -1
  61. package/esm/store/modal.js +1 -1
  62. package/esm/store/node.js +1 -1
  63. package/esm/store/pagination.js +1 -1
  64. package/esm/store/root.js +1 -1
  65. package/esm/store/service.js +1 -1
  66. package/esm/store/status.js +1 -1
  67. package/esm/store/table.d.ts +1 -0
  68. package/esm/store/table.js +5 -1
  69. package/esm/store/table2.js +1 -1
  70. package/esm/theme.js +1 -1
  71. package/esm/types.d.ts +1 -1
  72. package/esm/utils/Animation.js +1 -1
  73. package/esm/utils/ColorScale.js +1 -1
  74. package/esm/utils/DataSchema.js +1 -1
  75. package/esm/utils/DataScope.js +1 -1
  76. package/esm/utils/RootClose.js +1 -1
  77. package/esm/utils/SimpleMap.js +1 -1
  78. package/esm/utils/api.js +1 -1
  79. package/esm/utils/arraySlice.js +1 -1
  80. package/esm/utils/attachmentAdpator.js +1 -1
  81. package/esm/utils/autobind.js +1 -1
  82. package/esm/utils/browser.js +1 -1
  83. package/esm/utils/columnsSplit.js +1 -1
  84. package/esm/utils/concatData.js +1 -1
  85. package/esm/utils/dataMapping.js +1 -1
  86. package/esm/utils/date.js +1 -1
  87. package/esm/utils/debug.js +1 -1
  88. package/esm/utils/decodeEntity.js +1 -1
  89. package/esm/utils/dom.js +3 -3
  90. package/esm/utils/errors.js +1 -1
  91. package/esm/utils/escapeHtml.js +1 -1
  92. package/esm/utils/filter-schema.js +1 -1
  93. package/esm/utils/filter.js +1 -1
  94. package/esm/utils/formatDuration.js +1 -1
  95. package/esm/utils/formula.js +1 -1
  96. package/esm/utils/getVariable.js +1 -1
  97. package/esm/utils/grammar.js +1 -1
  98. package/esm/utils/handleAction.js +1 -1
  99. package/esm/utils/helper.js +3 -3
  100. package/esm/utils/highlight.js +1 -1
  101. package/esm/utils/icon.js +1 -1
  102. package/esm/utils/image.js +1 -1
  103. package/esm/utils/isPureVariable.js +1 -1
  104. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  105. package/esm/utils/keyToPath.js +1 -1
  106. package/esm/utils/labelToString.js +1 -1
  107. package/esm/utils/makeSorter.js +1 -1
  108. package/esm/utils/math.js +1 -1
  109. package/esm/utils/memoryParse.js +1 -1
  110. package/esm/utils/normalizeLink.js +1 -1
  111. package/esm/utils/normalizeOptions.js +1 -1
  112. package/esm/utils/object.js +1 -1
  113. package/esm/utils/offset.js +1 -1
  114. package/esm/utils/offsetParent.js +1 -1
  115. package/esm/utils/optionValueCompare.js +1 -1
  116. package/esm/utils/position.js +1 -1
  117. package/esm/utils/prettyBytes.js +1 -1
  118. package/esm/utils/printElement.js +1 -1
  119. package/esm/utils/renderer-event.d.ts +2 -0
  120. package/esm/utils/renderer-event.js +13 -1
  121. package/esm/utils/replaceText.js +1 -1
  122. package/esm/utils/resize-sensor.js +1 -1
  123. package/esm/utils/resolveCondition.js +1 -1
  124. package/esm/utils/resolveVariable.js +1 -1
  125. package/esm/utils/resolveVariableAndFilter.js +1 -1
  126. package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
  127. package/esm/utils/scrollPosition.js +1 -1
  128. package/esm/utils/string2regExp.js +1 -1
  129. package/esm/utils/stripNumber.js +1 -1
  130. package/esm/utils/style-helper.js +1 -1
  131. package/esm/utils/style.js +1 -1
  132. package/esm/utils/toNumber.js +1 -1
  133. package/esm/utils/tokenize.js +1 -1
  134. package/esm/utils/tpl-builtin.js +1 -1
  135. package/esm/utils/tpl-lodash.js +1 -1
  136. package/esm/utils/tpl.js +4 -4
  137. package/esm/utils/uncontrollable.js +1 -1
  138. package/esm/utils/validateId.js +1 -1
  139. package/esm/utils/validations.js +1 -1
  140. package/lib/Root.js +1 -1
  141. package/lib/RootRenderer.d.ts +1 -1
  142. package/lib/RootRenderer.js +1 -1
  143. package/lib/SchemaRenderer.js +3 -2
  144. package/lib/Scoped.d.ts +1 -0
  145. package/lib/Scoped.js +28 -14
  146. package/lib/StatusScoped.js +1 -1
  147. package/lib/WithRootStore.js +1 -1
  148. package/lib/WithStore.js +1 -1
  149. package/lib/actions/Action.js +4 -2
  150. package/lib/actions/AjaxAction.js +29 -19
  151. package/lib/actions/BreakAction.js +1 -1
  152. package/lib/actions/BroadcastAction.js +1 -1
  153. package/lib/actions/CmptAction.js +2 -2
  154. package/lib/actions/ContinueAction.js +1 -1
  155. package/lib/actions/CopyAction.js +1 -1
  156. package/lib/actions/CustomAction.js +1 -1
  157. package/lib/actions/DialogAction.js +30 -14
  158. package/lib/actions/DrawerAction.js +15 -7
  159. package/lib/actions/EmailAction.js +1 -1
  160. package/lib/actions/EventAction.js +1 -1
  161. package/lib/actions/LinkAction.js +1 -1
  162. package/lib/actions/LoopAction.js +1 -1
  163. package/lib/actions/PageAction.js +1 -1
  164. package/lib/actions/ParallelAction.js +1 -1
  165. package/lib/actions/PrintAction.d.ts +2 -2
  166. package/lib/actions/PrintAction.js +6 -6
  167. package/lib/actions/StatusAction.js +1 -1
  168. package/lib/actions/SwitchAction.js +1 -1
  169. package/lib/actions/ToastAction.js +1 -1
  170. package/lib/actions/WaitAction.js +1 -1
  171. package/lib/components/CustomStyle.js +1 -4
  172. package/lib/components/ErrorBoundary.js +1 -1
  173. package/lib/components/LazyComponent.js +1 -1
  174. package/lib/components/Overlay.js +1 -1
  175. package/lib/components/PopOver.js +1 -1
  176. package/lib/env.js +1 -1
  177. package/lib/envOverwrite.js +1 -1
  178. package/lib/factory.d.ts +1 -0
  179. package/lib/factory.js +1 -1
  180. package/lib/index.js +2 -2
  181. package/lib/locale.js +1 -1
  182. package/lib/polyfills.js +1 -1
  183. package/lib/renderers/Form.d.ts +3 -2
  184. package/lib/renderers/Form.js +55 -44
  185. package/lib/renderers/Item.js +1 -1
  186. package/lib/renderers/Options.js +1 -1
  187. package/lib/renderers/Placeholder.js +1 -1
  188. package/lib/renderers/builtin.js +1 -1
  189. package/lib/renderers/register.js +1 -1
  190. package/lib/renderers/wrapControl.js +31 -27
  191. package/lib/store/app.js +1 -1
  192. package/lib/store/combo.d.ts +24 -25
  193. package/lib/store/combo.js +1 -1
  194. package/lib/store/crud.js +12 -6
  195. package/lib/store/form.d.ts +10 -11
  196. package/lib/store/form.js +1 -1
  197. package/lib/store/formItem.js +1 -1
  198. package/lib/store/iRenderer.js +5 -2
  199. package/lib/store/index.js +1 -1
  200. package/lib/store/list.d.ts +13 -0
  201. package/lib/store/list.js +14 -1
  202. package/lib/store/manager.js +1 -1
  203. package/lib/store/modal.js +1 -1
  204. package/lib/store/node.js +1 -1
  205. package/lib/store/pagination.js +1 -1
  206. package/lib/store/root.js +1 -1
  207. package/lib/store/service.js +1 -1
  208. package/lib/store/status.js +1 -1
  209. package/lib/store/table.d.ts +21 -21
  210. package/lib/store/table.js +5 -1
  211. package/lib/store/table2.js +1 -1
  212. package/lib/theme.js +1 -1
  213. package/lib/types.d.ts +1 -1
  214. package/lib/utils/Animation.js +1 -1
  215. package/lib/utils/ColorScale.js +1 -1
  216. package/lib/utils/DataSchema.js +1 -1
  217. package/lib/utils/DataScope.js +1 -1
  218. package/lib/utils/RootClose.js +1 -1
  219. package/lib/utils/SimpleMap.js +1 -1
  220. package/lib/utils/api.js +1 -1
  221. package/lib/utils/arraySlice.js +1 -1
  222. package/lib/utils/attachmentAdpator.js +1 -1
  223. package/lib/utils/autobind.js +1 -1
  224. package/lib/utils/browser.js +1 -1
  225. package/lib/utils/columnsSplit.js +1 -1
  226. package/lib/utils/concatData.js +1 -1
  227. package/lib/utils/dataMapping.js +1 -1
  228. package/lib/utils/date.js +1 -1
  229. package/lib/utils/debug.js +1 -1
  230. package/lib/utils/decodeEntity.js +1 -1
  231. package/lib/utils/dom.js +3 -3
  232. package/lib/utils/errors.js +1 -1
  233. package/lib/utils/escapeHtml.js +1 -1
  234. package/lib/utils/filter-schema.js +1 -1
  235. package/lib/utils/filter.js +1 -1
  236. package/lib/utils/formatDuration.js +1 -1
  237. package/lib/utils/formula.js +1 -1
  238. package/lib/utils/getVariable.js +1 -1
  239. package/lib/utils/grammar.js +1 -1
  240. package/lib/utils/handleAction.js +1 -1
  241. package/lib/utils/helper.js +3 -4
  242. package/lib/utils/highlight.js +1 -1
  243. package/lib/utils/icon.js +1 -1
  244. package/lib/utils/image.js +1 -1
  245. package/lib/utils/isPureVariable.js +1 -1
  246. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  247. package/lib/utils/keyToPath.js +1 -1
  248. package/lib/utils/labelToString.js +1 -1
  249. package/lib/utils/makeSorter.js +1 -1
  250. package/lib/utils/math.js +1 -1
  251. package/lib/utils/memoryParse.js +1 -1
  252. package/lib/utils/normalizeLink.js +1 -1
  253. package/lib/utils/normalizeOptions.js +1 -1
  254. package/lib/utils/object.js +1 -1
  255. package/lib/utils/offset.js +1 -1
  256. package/lib/utils/offsetParent.js +1 -1
  257. package/lib/utils/optionValueCompare.js +1 -1
  258. package/lib/utils/position.js +1 -1
  259. package/lib/utils/prettyBytes.js +1 -1
  260. package/lib/utils/printElement.js +1 -1
  261. package/lib/utils/renderer-event.d.ts +2 -0
  262. package/lib/utils/renderer-event.js +13 -1
  263. package/lib/utils/replaceText.js +1 -1
  264. package/lib/utils/resize-sensor.js +1 -1
  265. package/lib/utils/resolveCondition.js +1 -1
  266. package/lib/utils/resolveVariable.js +1 -1
  267. package/lib/utils/resolveVariableAndFilter.js +1 -1
  268. package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
  269. package/lib/utils/scrollPosition.js +1 -1
  270. package/lib/utils/string2regExp.js +1 -1
  271. package/lib/utils/stripNumber.js +1 -1
  272. package/lib/utils/style-helper.js +1 -1
  273. package/lib/utils/style.js +1 -1
  274. package/lib/utils/toNumber.js +1 -1
  275. package/lib/utils/tokenize.js +1 -1
  276. package/lib/utils/tpl-builtin.js +1 -1
  277. package/lib/utils/tpl-lodash.js +1 -1
  278. package/lib/utils/tpl.js +4 -4
  279. package/lib/utils/uncontrollable.js +1 -1
  280. package/lib/utils/validateId.js +1 -1
  281. package/lib/utils/validations.js +1 -1
  282. package/package.json +2 -2
package/esm/polyfills.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -355,9 +355,10 @@ export default class Form extends React.Component<FormProps, object> {
355
355
  addHook(fn: () => any, type?: 'validate' | 'init' | 'flush', enforce?: 'prev' | 'post'): () => void;
356
356
  removeHook(fn: () => any, type?: string): void;
357
357
  handleChange(value: any, name: string, submit: boolean, changePristine?: boolean): void;
358
- formItemDispatchEvent(type: string, data: any): any;
358
+ formItemDispatchEvent(type: string, data: any): Promise<import("../utils").RendererEvent<any, any>>;
359
359
  emittedData: any;
360
- emitChange(submit: boolean, skipIfNothingChanges?: boolean): Promise<void>;
360
+ emitting: boolean;
361
+ emitChange(submit: boolean, emitedFromWatch?: boolean): Promise<void>;
361
362
  handleBulkChange(values: Object, submit: boolean): void;
362
363
  handleFormSubmit(e: React.UIEvent<any>): any;
363
364
  handleReset(action: any): (data: any) => void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -68,6 +68,7 @@ var Form = /** @class */ (function (_super) {
68
68
  // 如果开启了 lazyChange,需要一个 flush 方法把队列中值应用上。
69
69
  _this.flushing = false;
70
70
  _this.emittedData = null;
71
+ _this.emitting = false;
71
72
  _this.onInit = _this.onInit.bind(_this);
72
73
  _this.handleAction = _this.handleAction.bind(_this);
73
74
  _this.handleQuery = _this.handleQuery.bind(_this);
@@ -184,7 +185,6 @@ var Form = /** @class */ (function (_super) {
184
185
  return until(function () { return store.checkRemote(initAsyncApi, store.data); }, function (ret) { return ret && ret[initFinishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); }, initCheckInterval);
185
186
  }
186
187
  })
187
- .then(this.dispatchInited)
188
188
  .then(this.initInterval)
189
189
  .then(this.onInit);
190
190
  }
@@ -205,8 +205,8 @@ var Form = /** @class */ (function (_super) {
205
205
  successMessage: fetchSuccess,
206
206
  errorMessage: fetchFailed
207
207
  })
208
- .then(this.dispatchInited)
209
- .then(this.initInterval);
208
+ .then(this.initInterval)
209
+ .then(this.dispatchInited);
210
210
  }
211
211
  };
212
212
  Form.prototype.componentWillUnmount = function () {
@@ -236,20 +236,18 @@ var Form = /** @class */ (function (_super) {
236
236
  Form.prototype.dispatchInited = function (value) {
237
237
  var _a;
238
238
  return __awaiter(this, void 0, void 0, function () {
239
- var _b, data, store, dispatchEvent;
239
+ var _b, data, store, dispatchEvent, result;
240
240
  return __generator(this, function (_c) {
241
241
  switch (_c.label) {
242
242
  case 0:
243
243
  _b = this.props, data = _b.data, store = _b.store, dispatchEvent = _b.dispatchEvent;
244
- if (store.fetching) {
244
+ if (!isAlive(store) || store.fetching) {
245
245
  return [2 /*return*/, value];
246
246
  }
247
- // 派发init事件,参数为初始化数据
248
247
  return [4 /*yield*/, dispatchEvent('inited', createObject(data, __assign(__assign({}, value === null || value === void 0 ? void 0 : value.data), { responseData: (_a = value === null || value === void 0 ? void 0 : value.data) !== null && _a !== void 0 ? _a : {}, responseStatus: store.error ? 1 : 0, responseMsg: store.msg })))];
249
248
  case 1:
250
- // 派发init事件,参数为初始化数据
251
- _c.sent();
252
- return [2 /*return*/, value];
249
+ result = _c.sent();
250
+ return [2 /*return*/, result];
253
251
  }
254
252
  });
255
253
  });
@@ -270,7 +268,7 @@ var Form = /** @class */ (function (_super) {
270
268
  };
271
269
  Form.prototype.onInit = function () {
272
270
  return __awaiter(this, void 0, void 0, function () {
273
- var _a, onInit, store, persistData, submitOnInit, data, initedAt, hooks, groupedHooks;
271
+ var _a, onInit, store, persistData, submitOnInit, data, initedAt, hooks, groupedHooks, dispatch;
274
272
  return __generator(this, function (_b) {
275
273
  switch (_b.label) {
276
274
  case 0:
@@ -315,6 +313,13 @@ var Form = /** @class */ (function (_super) {
315
313
  data = cloneObject(store.data);
316
314
  }
317
315
  onInit && onInit(data, this.props);
316
+ return [4 /*yield*/, this.dispatchInited({ data: data })];
317
+ case 4:
318
+ dispatch = _b.sent();
319
+ if (dispatch === null || dispatch === void 0 ? void 0 : dispatch.prevented) {
320
+ return [2 /*return*/];
321
+ }
322
+ // submitOnInit
318
323
  submitOnInit &&
319
324
  this.handleAction(undefined, {
320
325
  type: 'submit'
@@ -340,7 +345,8 @@ var Form = /** @class */ (function (_super) {
340
345
  store.updateData((_c = {},
341
346
  _c[initFinishedField || 'finished'] = false,
342
347
  _c));
343
- if (!isEffectiveApi(initApi, store.data)) return [3 /*break*/, 3];
348
+ result = undefined;
349
+ if (!isEffectiveApi(initApi, store.data)) return [3 /*break*/, 2];
344
350
  return [4 /*yield*/, store.fetchInitData(initApi, store.data, {
345
351
  successMessage: fetchSuccess,
346
352
  errorMessage: fetchFailed,
@@ -356,20 +362,18 @@ var Form = /** @class */ (function (_super) {
356
362
  })];
357
363
  case 1:
358
364
  result = _d.sent();
359
- // 派发初始化接口请求完成事件
360
- return [4 /*yield*/, this.dispatchInited(result)];
361
- case 2:
362
- // 派发初始化接口请求完成事件
363
- _d.sent();
364
365
  if (result === null || result === void 0 ? void 0 : result.ok) {
365
366
  this.initInterval(result);
366
367
  store.reset(undefined, false);
367
368
  }
368
- return [3 /*break*/, 4];
369
- case 3:
369
+ return [3 /*break*/, 3];
370
+ case 2:
370
371
  store.reset(undefined, false);
371
- _d.label = 4;
372
- case 4: return [2 /*return*/];
372
+ _d.label = 3;
373
+ case 3:
374
+ // 派发初始化接口请求完成事件
375
+ this.dispatchInited(result);
376
+ return [2 /*return*/];
373
377
  }
374
378
  });
375
379
  });
@@ -471,7 +475,7 @@ var Form = /** @class */ (function (_super) {
471
475
  return __generator(this, function (_a) {
472
476
  switch (_a.label) {
473
477
  case 0:
474
- _a.trys.push([0, , 3, 4]);
478
+ _a.trys.push([0, , 4, 5]);
475
479
  if (this.flushing) {
476
480
  return [2 /*return*/];
477
481
  }
@@ -480,14 +484,16 @@ var Form = /** @class */ (function (_super) {
480
484
  return [4 /*yield*/, Promise.all(hooks.map(function (fn) { return fn(); }))];
481
485
  case 1:
482
486
  _a.sent();
487
+ if (!!this.emitting) return [3 /*break*/, 3];
483
488
  return [4 /*yield*/, this.lazyEmitChange.flush()];
484
489
  case 2:
485
490
  _a.sent();
486
- return [3 /*break*/, 4];
487
- case 3:
491
+ _a.label = 3;
492
+ case 3: return [3 /*break*/, 5];
493
+ case 4:
488
494
  this.flushing = false;
489
495
  return [7 /*endfinally*/];
490
- case 4: return [2 /*return*/];
496
+ case 5: return [2 /*return*/];
491
497
  }
492
498
  });
493
499
  });
@@ -541,32 +547,34 @@ var Form = /** @class */ (function (_super) {
541
547
  var dispatchEvent = this.props.dispatchEvent;
542
548
  return dispatchEvent(type, data);
543
549
  };
544
- Form.prototype.emitChange = function (submit, skipIfNothingChanges) {
545
- if (skipIfNothingChanges === void 0) { skipIfNothingChanges = false; }
550
+ Form.prototype.emitChange = function (submit, emitedFromWatch) {
551
+ if (emitedFromWatch === void 0) { emitedFromWatch = false; }
546
552
  return __awaiter(this, void 0, void 0, function () {
547
- var _a, onChange, store, submitOnChange, dispatchEvent, data, diff, changeProps, dispatcher;
553
+ var _a, onChange, store, submitOnChange, dispatchEvent_1, data, diff, changeProps, dispatcher;
548
554
  return __generator(this, function (_b) {
549
555
  switch (_b.label) {
550
556
  case 0:
551
- _a = this.props, onChange = _a.onChange, store = _a.store, submitOnChange = _a.submitOnChange, dispatchEvent = _a.dispatchEvent, data = _a.data;
557
+ _b.trys.push([0, , 4, 5]);
558
+ this.emitting = true;
559
+ _a = this.props, onChange = _a.onChange, store = _a.store, submitOnChange = _a.submitOnChange, dispatchEvent_1 = _a.dispatchEvent, data = _a.data;
552
560
  if (!isAlive(store)) {
553
561
  return [2 /*return*/];
554
562
  }
555
563
  diff = difference(store.data, store.pristine);
556
- if (skipIfNothingChanges &&
564
+ if (emitedFromWatch &&
557
565
  (!Object.keys(diff).length || isEqual(store.data, this.emittedData))) {
558
566
  return [2 /*return*/];
559
567
  }
560
568
  this.emittedData = store.data;
561
569
  changeProps = [store.data, diff, this.props];
562
- return [4 /*yield*/, dispatchEvent('change', createObject(data, store.data))];
570
+ return [4 /*yield*/, dispatchEvent_1('change', createObject(data, store.data))];
563
571
  case 1:
564
572
  dispatcher = _b.sent();
565
573
  if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
566
574
  onChange && onChange.apply(null, changeProps);
567
575
  }
568
576
  store.clearRestError();
569
- if (!(submit || (submitOnChange && store.inited))) return [3 /*break*/, 3];
577
+ if (!(!emitedFromWatch && (submit || (submitOnChange && store.inited)))) return [3 /*break*/, 3];
570
578
  return [4 /*yield*/, this.handleAction(undefined, {
571
579
  type: 'submit',
572
580
  // 如果这里不跳过,会相互依赖死循环,flush 会 让 emiteChange 立即执行
@@ -576,7 +584,11 @@ var Form = /** @class */ (function (_super) {
576
584
  case 2:
577
585
  _b.sent();
578
586
  _b.label = 3;
579
- case 3: return [2 /*return*/];
587
+ case 3: return [3 /*break*/, 5];
588
+ case 4:
589
+ this.emitting = false;
590
+ return [7 /*endfinally*/];
591
+ case 5: return [2 /*return*/];
580
592
  }
581
593
  });
582
594
  });
@@ -621,7 +633,7 @@ var Form = /** @class */ (function (_super) {
621
633
  var _a, _b;
622
634
  if (throwErrors === void 0) { throwErrors = false; }
623
635
  return __awaiter(this, void 0, void 0, function () {
624
- var _c, store, onSubmit, api, asyncApi, finishedField, checkInterval, _d, saveSuccess, saveFailed, resetAfterSubmit, clearAfterSubmit, onAction, onSaved, onReset, onFinished, onFailed, redirect, reload, target, env, onChange, clearPersistDataAfterSubmit, trimValues, dispatchEvent, __, fields, validationRes, dispatcher, _e, dispatchEvent_1, onEvent, submitEvent, dispatcher, successMsg, failMsg;
636
+ var _c, store, onSubmit, api, asyncApi, finishedField, checkInterval, _d, saveSuccess, saveFailed, resetAfterSubmit, clearAfterSubmit, onAction, onSaved, onReset, onFinished, onFailed, redirect, reload, target, env, onChange, clearPersistDataAfterSubmit, trimValues, dispatchEvent, __, fields, validationRes, dispatcher, _e, dispatchEvent_2, onEvent, submitEvent, dispatcher, successMsg, failMsg;
625
637
  var _this = this;
626
638
  return __generator(this, function (_f) {
627
639
  switch (_f.label) {
@@ -669,9 +681,9 @@ var Form = /** @class */ (function (_super) {
669
681
  action.actionType === 'confirm' ||
670
682
  action.actionType === 'reset-and-submit' ||
671
683
  action.actionType === 'clear-and-submit')) return [3 /*break*/, 8];
672
- _e = this.props, dispatchEvent_1 = _e.dispatchEvent, onEvent = _e.onEvent;
684
+ _e = this.props, dispatchEvent_2 = _e.dispatchEvent, onEvent = _e.onEvent;
673
685
  submitEvent = (_b = (_a = onEvent === null || onEvent === void 0 ? void 0 : onEvent.submit) === null || _a === void 0 ? void 0 : _a.actions) === null || _b === void 0 ? void 0 : _b.length;
674
- return [4 /*yield*/, dispatchEvent_1('submit', this.props.data)];
686
+ return [4 /*yield*/, dispatchEvent_2('submit', this.props.data)];
675
687
  case 7:
676
688
  dispatcher = _f.sent();
677
689
  if ((dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented) || submitEvent) {
@@ -701,12 +713,12 @@ var Form = /** @class */ (function (_super) {
701
713
  _b.label = 2;
702
714
  case 2:
703
715
  // 走到这里代表校验成功了
704
- dispatchEvent_1('validateSucc', this.props.data);
716
+ dispatchEvent_2('validateSucc', this.props.data);
705
717
  if (target) {
706
718
  this.submitToTarget(filterTarget(target, values), values);
707
719
  /** 可能配置页面跳转事件,页面路由变化导致persistKey不一致,无法清除持久化数据,所以提交成功事件之前先清理一下 */
708
720
  clearPersistDataAfterSubmit && store.clearLocalPersistData();
709
- dispatchEvent_1('submitSucc', createObject(this.props.data, values));
721
+ dispatchEvent_2('submitSucc', createObject(this.props.data, values));
710
722
  }
711
723
  else if (action.actionType === 'reload') {
712
724
  action.target &&
@@ -757,7 +769,7 @@ var Form = /** @class */ (function (_super) {
757
769
  switch (_a.label) {
758
770
  case 0:
759
771
  clearPersistDataAfterSubmit && store.clearLocalPersistData();
760
- return [4 /*yield*/, dispatchEvent_1('submitSucc', createObject(this.props.data, { result: result }))];
772
+ return [4 /*yield*/, dispatchEvent_2('submitSucc', createObject(this.props.data, { result: result }))];
761
773
  case 1:
762
774
  dispatcher = _a.sent();
763
775
  if (!isEffectiveApi(finnalAsyncApi_1, store.data) ||
@@ -769,7 +781,7 @@ var Form = /** @class */ (function (_super) {
769
781
  }
770
782
  cbResult = until(function () { return store.checkRemote(finnalAsyncApi_1, store.data); }, function (ret) { return ret && ret[finishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); }, checkInterval).then(function (value) {
771
783
  // 派发asyncApiFinished事件
772
- dispatchEvent_1('asyncApiFinished', store.data);
784
+ dispatchEvent_2('asyncApiFinished', store.data);
773
785
  });
774
786
  return [2 /*return*/, {
775
787
  cbResult: cbResult,
@@ -782,7 +794,7 @@ var Form = /** @class */ (function (_super) {
782
794
  var dispatcher;
783
795
  return __generator(this, function (_a) {
784
796
  switch (_a.label) {
785
- case 0: return [4 /*yield*/, dispatchEvent_1('submitFail', createObject(this.props.data, { error: result }))];
797
+ case 0: return [4 /*yield*/, dispatchEvent_2('submitFail', createObject(this.props.data, { error: result }))];
786
798
  case 1:
787
799
  dispatcher = _a.sent();
788
800
  return [2 /*return*/, {
@@ -822,7 +834,7 @@ var Form = /** @class */ (function (_super) {
822
834
  else {
823
835
  clearPersistDataAfterSubmit && store.clearLocalPersistData();
824
836
  // type为submit,但是没有配api以及target时,只派发事件
825
- dispatchEvent_1('submitSucc', createObject(this.props.data, values));
837
+ dispatchEvent_2('submitSucc', createObject(this.props.data, values));
826
838
  }
827
839
  return [2 /*return*/, Promise.resolve(null)];
828
840
  }
@@ -1454,8 +1466,7 @@ var FormRenderer = /** @class */ (function (_super) {
1454
1466
  onChange(store.data, difference(store.data, store.pristine), this.props);
1455
1467
  };
1456
1468
  FormRenderer.prototype.getData = function () {
1457
- var store = this.props.store;
1458
- return store.data;
1469
+ return this.getValues();
1459
1470
  };
1460
1471
  FormRenderer.contextType = ScopedContext;
1461
1472
  FormRenderer = __decorate([
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -283,25 +283,27 @@ function wrapControl(ComposedComponent) {
283
283
  var model = this.model;
284
284
  var _a = this.props, form = _a.formStore, data = _a.data, canAccessSuperData = _a.canAccessSuperData;
285
285
  var isExp = isExpression(value);
286
- if (isExp) {
287
- model.changeTmpValue(FormulaExec['formula'](value, data), // 对组件默认值进行运算
288
- 'formulaChanged');
289
- }
290
- else {
291
- var initialValue = model.extraName
292
- ? [
293
- getVariable(data, model.name, canAccessSuperData !== null && canAccessSuperData !== void 0 ? canAccessSuperData : form === null || form === void 0 ? void 0 : form.canAccessSuperData),
294
- getVariable(data, model.extraName, canAccessSuperData !== null && canAccessSuperData !== void 0 ? canAccessSuperData : form === null || form === void 0 ? void 0 : form.canAccessSuperData)
295
- ]
296
- : getVariable(data, model.name, canAccessSuperData !== null && canAccessSuperData !== void 0 ? canAccessSuperData : form === null || form === void 0 ? void 0 : form.canAccessSuperData);
297
- if (model.extraName &&
298
- initialValue.every(function (item) { return item === undefined; })) {
299
- initialValue = undefined;
300
- }
301
- model.changeTmpValue(initialValue !== null && initialValue !== void 0 ? initialValue : replaceExpression(value), typeof initialValue !== 'undefined'
302
- ? 'initialValue'
286
+ var initialValue = model.extraName
287
+ ? [
288
+ getVariable(data, model.name, canAccessSuperData !== null && canAccessSuperData !== void 0 ? canAccessSuperData : form === null || form === void 0 ? void 0 : form.canAccessSuperData),
289
+ getVariable(data, model.extraName, canAccessSuperData !== null && canAccessSuperData !== void 0 ? canAccessSuperData : form === null || form === void 0 ? void 0 : form.canAccessSuperData)
290
+ ]
291
+ : getVariable(data, model.name, canAccessSuperData !== null && canAccessSuperData !== void 0 ? canAccessSuperData : form === null || form === void 0 ? void 0 : form.canAccessSuperData);
292
+ if (model.extraName &&
293
+ initialValue.every(function (item) { return item === undefined; })) {
294
+ initialValue = undefined;
295
+ }
296
+ if (typeof initialValue === 'undefined') {
297
+ value = isExp
298
+ ? FormulaExec['formula'](value, data)
299
+ : replaceExpression(value);
300
+ }
301
+ model.changeTmpValue(initialValue !== null && initialValue !== void 0 ? initialValue : value, // 对组件默认值进行运算
302
+ typeof initialValue !== 'undefined'
303
+ ? 'initialValue'
304
+ : isExp
305
+ ? 'formulaChanged'
303
306
  : 'defaultValue');
304
- }
305
307
  };
306
308
  class_1.prototype.disposeModel = function () {
307
309
  var _a;
@@ -378,14 +380,15 @@ function wrapControl(ComposedComponent) {
378
380
  }
379
381
  };
380
382
  class_1.prototype.validate = function () {
383
+ var _a, _b;
381
384
  return __awaiter(this, void 0, void 0, function () {
382
- var _a, form, data, formItemDispatchEvent, result, combo, group, validPromises, valid;
383
- return __generator(this, function (_b) {
384
- switch (_b.label) {
385
+ var _c, form, data, formItemDispatchEvent, result, combo, group, validPromises, valid;
386
+ return __generator(this, function (_d) {
387
+ switch (_d.label) {
385
388
  case 0:
386
389
  if (!this.model)
387
390
  return [2 /*return*/];
388
- _a = this.props, form = _a.formStore, data = _a.data, formItemDispatchEvent = _a.formItemDispatchEvent;
391
+ _c = this.props, form = _c.formStore, data = _c.data, formItemDispatchEvent = _c.formItemDispatchEvent;
389
392
  if (!(this.model.unique &&
390
393
  (form === null || form === void 0 ? void 0 : form.parentStore) &&
391
394
  form.parentStore.storeType === ComboStore.name)) return [3 /*break*/, 2];
@@ -396,15 +399,16 @@ function wrapControl(ComposedComponent) {
396
399
  });
397
400
  return [4 /*yield*/, Promise.all(validPromises)];
398
401
  case 1:
399
- result = _b.sent();
402
+ result = _d.sent();
400
403
  return [3 /*break*/, 4];
401
404
  case 2: return [4 /*yield*/, this.model.validate(data)];
402
405
  case 3:
403
- result = [_b.sent()];
404
- _b.label = 4;
406
+ result = [_d.sent()];
407
+ _d.label = 4;
405
408
  case 4:
406
409
  valid = !result.some(function (item) { return item === false; });
407
- formItemDispatchEvent === null || formItemDispatchEvent === void 0 ? void 0 : formItemDispatchEvent(valid ? 'formItemValidateSucc' : 'formItemValidateError', data);
410
+ (_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里的一定是最新的数据
411
+ );
408
412
  return [2 /*return*/, valid];
409
413
  }
410
414
  });
package/esm/store/app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
package/esm/store/crud.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -23,9 +23,10 @@ import { TableStore } from './table.js';
23
23
 
24
24
  var ServerError = /** @class */ (function (_super) {
25
25
  __extends(ServerError, _super);
26
- function ServerError() {
27
- var _this = _super !== null && _super.apply(this, arguments) || this;
26
+ function ServerError(msg, response) {
27
+ var _this = _super.call(this, msg) || this;
28
28
  _this.type = 'ServerError';
29
+ _this.response = response;
29
30
  return _this;
30
31
  }
31
32
  return ServerError;
@@ -396,7 +397,7 @@ var CRUDStore = ServiceStore.named('CRUDStore')
396
397
  timeout: json.msgTimeout
397
398
  }
398
399
  : undefined);
399
- throw new ServerError(self.msg);
400
+ throw new ServerError(self.msg, json);
400
401
  }
401
402
  else {
402
403
  self.updateMessage((_h = (_g = (_f = (_e = api === null || api === void 0 ? void 0 : api.messages) === null || _e === void 0 ? void 0 : _e.success) !== null && _f !== void 0 ? _f : json.msg) !== null && _g !== void 0 ? _g : options.successMessage) !== null && _h !== void 0 ? _h : json.defaultMsg);
@@ -408,13 +409,18 @@ var CRUDStore = ServiceStore.named('CRUDStore')
408
409
  }
409
410
  : undefined);
410
411
  }
411
- return [2 /*return*/, json.data];
412
+ // 补一个空对象是为了区别于被取消的请求
413
+ // 请求被取消时会返回 undefined
414
+ return [2 /*return*/, json.data || {}];
412
415
  case 2:
413
416
  e_3 = _j.sent();
414
- self.markSaving(false);
415
417
  if (!isAlive(self) || self.disposed) {
416
418
  return [2 /*return*/];
417
419
  }
420
+ self.markSaving(false);
421
+ if (getEnv(self).isCancel(e_3)) {
422
+ return [2 /*return*/];
423
+ }
418
424
  !(api === null || api === void 0 ? void 0 : api.silent) &&
419
425
  e_3.type !== 'ServerError' &&
420
426
  getEnv(self).notify('error', e_3.message);
package/esm/store/form.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -8,7 +8,7 @@ import { types } from 'mobx-state-tree';
8
8
  import '../utils/helper.js';
9
9
  import 'amis-formula';
10
10
  import 'moment';
11
- import { createObject, extendObject, cloneObject, setVariable, deleteVariable, extractObjectChain, createObjectFromChain } from '../utils/object.js';
11
+ import { injectObjectChain, createObject, extendObject, cloneObject, setVariable, deleteVariable, extractObjectChain, createObjectFromChain } from '../utils/object.js';
12
12
  import { getVariable } from '../utils/getVariable.js';
13
13
  import { dataMapping } from '../utils/dataMapping.js';
14
14
  import '../utils/filter.js';
@@ -84,6 +84,9 @@ var iRendererStore = StoreNode.named('iRendererStore')
84
84
  if (data === void 0) { data = {}; }
85
85
  if (skipSetPristine === void 0) { skipSetPristine = false; }
86
86
  self.initedAt = Date.now();
87
+ if (self.data.__tag) {
88
+ data = injectObjectChain(data, self.data.__tag);
89
+ }
87
90
  !skipSetPristine && (self.pristine = data);
88
91
  self.data = data;
89
92
  },
@@ -98,7 +101,7 @@ var iRendererStore = StoreNode.named('iRendererStore')
98
101
  var prev = self.data;
99
102
  var newData;
100
103
  if (tag) {
101
- var proto = createObject(self.data.__super || null, tag);
104
+ var proto = createObject(self.data.__super || null, __assign(__assign({}, tag), { __tag: tag }));
102
105
  newData = createObject(proto, __assign(__assign({}, (replace ? {} : self.data)), data));
103
106
  }
104
107
  else {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.3.0
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5