amis-core 6.2.2 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/esm/Root.js +1 -1
  2. package/esm/RootRenderer.d.ts +1 -1
  3. package/esm/RootRenderer.js +28 -10
  4. package/esm/SchemaRenderer.js +17 -7
  5. package/esm/Scoped.d.ts +2 -1
  6. package/esm/Scoped.js +30 -14
  7. package/esm/StatusScoped.js +4 -2
  8. package/esm/WithRootStore.js +1 -1
  9. package/esm/WithStore.js +28 -17
  10. package/esm/actions/Action.js +5 -3
  11. package/esm/actions/AjaxAction.js +29 -19
  12. package/esm/actions/BreakAction.js +1 -1
  13. package/esm/actions/BroadcastAction.js +1 -1
  14. package/esm/actions/CmptAction.js +3 -3
  15. package/esm/actions/ContinueAction.js +1 -1
  16. package/esm/actions/CopyAction.js +1 -1
  17. package/esm/actions/CustomAction.js +2 -2
  18. package/esm/actions/DialogAction.d.ts +8 -0
  19. package/esm/actions/DialogAction.js +116 -40
  20. package/esm/actions/DrawerAction.d.ts +5 -0
  21. package/esm/actions/DrawerAction.js +74 -11
  22. package/esm/actions/EmailAction.js +1 -1
  23. package/esm/actions/EventAction.d.ts +20 -0
  24. package/esm/actions/EventAction.js +102 -0
  25. package/esm/actions/LinkAction.js +1 -1
  26. package/esm/actions/LoopAction.js +1 -1
  27. package/esm/actions/PageAction.js +1 -1
  28. package/esm/actions/ParallelAction.js +1 -1
  29. package/esm/actions/PrintAction.d.ts +2 -2
  30. package/esm/actions/PrintAction.js +6 -6
  31. package/esm/actions/StatusAction.js +1 -1
  32. package/esm/actions/SwitchAction.js +1 -1
  33. package/esm/actions/ToastAction.js +1 -1
  34. package/esm/actions/WaitAction.d.ts +18 -0
  35. package/esm/actions/WaitAction.js +41 -0
  36. package/esm/actions/index.d.ts +2 -0
  37. package/esm/components/CustomStyle.js +1 -4
  38. package/esm/components/ErrorBoundary.js +1 -1
  39. package/esm/components/LazyComponent.js +1 -1
  40. package/esm/components/Overlay.d.ts +3 -0
  41. package/esm/components/Overlay.js +7 -4
  42. package/esm/components/PopOver.js +2 -2
  43. package/esm/env.js +1 -1
  44. package/esm/envOverwrite.js +1 -1
  45. package/esm/factory.d.ts +3 -0
  46. package/esm/factory.js +1 -1
  47. package/esm/index.js +6 -4
  48. package/esm/locale.js +4 -2
  49. package/esm/polyfills.js +1 -1
  50. package/esm/renderers/Form.d.ts +6 -4
  51. package/esm/renderers/Form.js +134 -66
  52. package/esm/renderers/Item.d.ts +123 -79
  53. package/esm/renderers/Item.js +159 -60
  54. package/esm/renderers/Options.d.ts +0 -11
  55. package/esm/renderers/Options.js +20 -84
  56. package/esm/renderers/Placeholder.js +1 -1
  57. package/esm/renderers/builtin.js +1 -1
  58. package/esm/renderers/register.js +1 -1
  59. package/esm/renderers/wrapControl.d.ts +2 -1
  60. package/esm/renderers/wrapControl.js +34 -28
  61. package/esm/store/app.d.ts +5 -5
  62. package/esm/store/app.js +1 -1
  63. package/esm/store/combo.d.ts +255 -63
  64. package/esm/store/combo.js +1 -1
  65. package/esm/store/crud.d.ts +5 -5
  66. package/esm/store/crud.js +12 -6
  67. package/esm/store/form.d.ts +105 -25
  68. package/esm/store/form.js +33 -15
  69. package/esm/store/formItem.d.ts +6 -2
  70. package/esm/store/formItem.js +68 -5
  71. package/esm/store/iRenderer.d.ts +5 -5
  72. package/esm/store/iRenderer.js +28 -12
  73. package/esm/store/index.js +1 -1
  74. package/esm/store/list.d.ts +18 -5
  75. package/esm/store/list.js +14 -1
  76. package/esm/store/manager.js +1 -1
  77. package/esm/store/modal.d.ts +5 -5
  78. package/esm/store/modal.js +1 -1
  79. package/esm/store/node.js +1 -1
  80. package/esm/store/pagination.d.ts +5 -5
  81. package/esm/store/pagination.js +1 -1
  82. package/esm/store/root.d.ts +5 -5
  83. package/esm/store/root.js +1 -1
  84. package/esm/store/service.d.ts +5 -5
  85. package/esm/store/service.js +2 -2
  86. package/esm/store/status.js +1 -1
  87. package/esm/store/table.d.ts +244 -55
  88. package/esm/store/table.js +27 -9
  89. package/esm/store/table2.d.ts +5 -5
  90. package/esm/store/table2.js +1 -1
  91. package/esm/theme.js +4 -2
  92. package/esm/types.d.ts +7 -1
  93. package/esm/utils/Animation.js +1 -1
  94. package/esm/utils/ColorScale.js +1 -1
  95. package/esm/utils/DataSchema.js +1 -1
  96. package/esm/utils/DataScope.js +1 -1
  97. package/esm/utils/RootClose.js +1 -1
  98. package/esm/utils/SimpleMap.js +1 -1
  99. package/esm/utils/api.js +1 -1
  100. package/esm/utils/arraySlice.js +1 -1
  101. package/esm/utils/attachmentAdpator.js +1 -1
  102. package/esm/utils/autobind.js +1 -1
  103. package/esm/utils/browser.js +1 -1
  104. package/esm/utils/columnsSplit.js +1 -1
  105. package/esm/utils/concatData.js +1 -1
  106. package/esm/utils/dataMapping.js +1 -1
  107. package/esm/utils/date.js +1 -1
  108. package/esm/utils/debug.js +1 -1
  109. package/esm/utils/decodeEntity.js +1 -1
  110. package/esm/utils/dom.d.ts +2 -2
  111. package/esm/utils/dom.js +72 -13
  112. package/esm/utils/errors.js +1 -1
  113. package/esm/utils/escapeHtml.js +1 -1
  114. package/esm/utils/filter-schema.js +1 -1
  115. package/esm/utils/filter.js +1 -1
  116. package/esm/utils/formatDuration.js +1 -1
  117. package/esm/utils/formula.js +2 -2
  118. package/esm/utils/getVariable.js +1 -1
  119. package/esm/utils/grammar.js +1 -1
  120. package/esm/utils/handleAction.js +1 -1
  121. package/esm/utils/helper.d.ts +12 -6
  122. package/esm/utils/helper.js +41 -18
  123. package/esm/utils/highlight.js +1 -1
  124. package/esm/utils/icon.js +1 -1
  125. package/esm/utils/image.js +1 -1
  126. package/esm/utils/isPureVariable.js +1 -1
  127. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  128. package/esm/utils/keyToPath.js +1 -1
  129. package/esm/utils/labelToString.js +1 -1
  130. package/esm/utils/makeSorter.js +1 -1
  131. package/esm/utils/math.js +1 -1
  132. package/esm/utils/memoryParse.js +1 -1
  133. package/esm/utils/normalizeLink.js +1 -1
  134. package/esm/utils/normalizeOptions.js +1 -1
  135. package/esm/utils/object.js +1 -1
  136. package/esm/utils/offset.js +1 -1
  137. package/esm/utils/offsetParent.js +1 -1
  138. package/esm/utils/optionValueCompare.js +1 -1
  139. package/esm/utils/position.js +1 -1
  140. package/esm/utils/prettyBytes.js +1 -1
  141. package/esm/utils/printElement.js +1 -1
  142. package/esm/utils/renderer-event.d.ts +13 -0
  143. package/esm/utils/renderer-event.js +111 -2
  144. package/esm/utils/replaceText.js +1 -1
  145. package/esm/utils/resize-sensor.js +1 -1
  146. package/esm/utils/resolveCondition.js +1 -1
  147. package/esm/utils/resolveVariable.js +1 -1
  148. package/esm/utils/resolveVariableAndFilter.js +1 -1
  149. package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
  150. package/esm/utils/scrollPosition.js +1 -1
  151. package/esm/utils/string2regExp.js +1 -1
  152. package/esm/utils/stripNumber.d.ts +1 -1
  153. package/esm/utils/stripNumber.js +4 -3
  154. package/esm/utils/style-helper.d.ts +21 -2
  155. package/esm/utils/style-helper.js +55 -10
  156. package/esm/utils/style.js +1 -1
  157. package/esm/utils/toNumber.js +1 -1
  158. package/esm/utils/tokenize.js +1 -1
  159. package/esm/utils/tpl-builtin.js +1 -1
  160. package/esm/utils/tpl-lodash.js +1 -1
  161. package/esm/utils/tpl.js +4 -4
  162. package/esm/utils/uncontrollable.js +1 -1
  163. package/esm/utils/validateId.js +5 -2
  164. package/esm/utils/validations.js +1 -1
  165. package/lib/Root.js +1 -1
  166. package/lib/RootRenderer.d.ts +2 -2
  167. package/lib/RootRenderer.js +28 -10
  168. package/lib/SchemaRenderer.js +16 -6
  169. package/lib/Scoped.d.ts +2 -1
  170. package/lib/Scoped.js +30 -14
  171. package/lib/StatusScoped.js +4 -2
  172. package/lib/WithRootStore.js +1 -1
  173. package/lib/WithStore.js +28 -17
  174. package/lib/actions/Action.js +5 -3
  175. package/lib/actions/AjaxAction.js +29 -19
  176. package/lib/actions/BreakAction.js +1 -1
  177. package/lib/actions/BroadcastAction.js +1 -1
  178. package/lib/actions/CmptAction.js +3 -3
  179. package/lib/actions/ContinueAction.js +1 -1
  180. package/lib/actions/CopyAction.js +1 -1
  181. package/lib/actions/CustomAction.js +1 -1
  182. package/lib/actions/DialogAction.d.ts +8 -0
  183. package/lib/actions/DialogAction.js +119 -40
  184. package/lib/actions/DrawerAction.d.ts +5 -0
  185. package/lib/actions/DrawerAction.js +77 -11
  186. package/lib/actions/EmailAction.js +1 -1
  187. package/lib/actions/EventAction.d.ts +20 -0
  188. package/lib/actions/EventAction.js +109 -0
  189. package/lib/actions/LinkAction.js +1 -1
  190. package/lib/actions/LoopAction.js +1 -1
  191. package/lib/actions/PageAction.js +1 -1
  192. package/lib/actions/ParallelAction.js +1 -1
  193. package/lib/actions/PrintAction.d.ts +2 -2
  194. package/lib/actions/PrintAction.js +6 -6
  195. package/lib/actions/StatusAction.js +1 -1
  196. package/lib/actions/SwitchAction.js +1 -1
  197. package/lib/actions/ToastAction.js +1 -1
  198. package/lib/actions/WaitAction.d.ts +18 -0
  199. package/lib/actions/WaitAction.js +45 -0
  200. package/lib/actions/index.d.ts +2 -0
  201. package/lib/components/CustomStyle.js +1 -4
  202. package/lib/components/ErrorBoundary.js +1 -1
  203. package/lib/components/LazyComponent.js +1 -1
  204. package/lib/components/Overlay.d.ts +3 -0
  205. package/lib/components/Overlay.js +7 -4
  206. package/lib/components/PopOver.js +1 -1
  207. package/lib/env.js +1 -1
  208. package/lib/envOverwrite.js +1 -1
  209. package/lib/factory.d.ts +3 -0
  210. package/lib/factory.js +1 -1
  211. package/lib/index.js +6 -4
  212. package/lib/locale.js +4 -2
  213. package/lib/polyfills.js +1 -1
  214. package/lib/renderers/Form.d.ts +6 -4
  215. package/lib/renderers/Form.js +135 -65
  216. package/lib/renderers/Item.d.ts +123 -79
  217. package/lib/renderers/Item.js +158 -58
  218. package/lib/renderers/Options.d.ts +0 -11
  219. package/lib/renderers/Options.js +19 -84
  220. package/lib/renderers/Placeholder.js +1 -1
  221. package/lib/renderers/builtin.js +1 -1
  222. package/lib/renderers/register.js +1 -1
  223. package/lib/renderers/wrapControl.d.ts +2 -1
  224. package/lib/renderers/wrapControl.js +34 -28
  225. package/lib/store/app.d.ts +5 -5
  226. package/lib/store/app.js +1 -1
  227. package/lib/store/combo.d.ts +279 -88
  228. package/lib/store/combo.js +1 -1
  229. package/lib/store/crud.d.ts +5 -5
  230. package/lib/store/crud.js +12 -6
  231. package/lib/store/form.d.ts +115 -36
  232. package/lib/store/form.js +33 -15
  233. package/lib/store/formItem.d.ts +6 -2
  234. package/lib/store/formItem.js +67 -4
  235. package/lib/store/iRenderer.d.ts +5 -5
  236. package/lib/store/iRenderer.js +27 -11
  237. package/lib/store/index.js +1 -1
  238. package/lib/store/list.d.ts +18 -5
  239. package/lib/store/list.js +14 -1
  240. package/lib/store/manager.js +1 -1
  241. package/lib/store/modal.d.ts +5 -5
  242. package/lib/store/modal.js +1 -1
  243. package/lib/store/node.js +1 -1
  244. package/lib/store/pagination.d.ts +5 -5
  245. package/lib/store/pagination.js +1 -1
  246. package/lib/store/root.d.ts +5 -5
  247. package/lib/store/root.js +1 -1
  248. package/lib/store/service.d.ts +5 -5
  249. package/lib/store/service.js +2 -2
  250. package/lib/store/status.js +1 -1
  251. package/lib/store/table.d.ts +264 -76
  252. package/lib/store/table.js +27 -9
  253. package/lib/store/table2.d.ts +5 -5
  254. package/lib/store/table2.js +1 -1
  255. package/lib/theme.js +4 -2
  256. package/lib/types.d.ts +7 -1
  257. package/lib/utils/Animation.js +1 -1
  258. package/lib/utils/ColorScale.js +1 -1
  259. package/lib/utils/DataSchema.js +1 -1
  260. package/lib/utils/DataScope.js +1 -1
  261. package/lib/utils/RootClose.js +1 -1
  262. package/lib/utils/SimpleMap.js +1 -1
  263. package/lib/utils/api.js +1 -1
  264. package/lib/utils/arraySlice.js +1 -1
  265. package/lib/utils/attachmentAdpator.js +1 -1
  266. package/lib/utils/autobind.js +1 -1
  267. package/lib/utils/browser.js +1 -1
  268. package/lib/utils/columnsSplit.js +1 -1
  269. package/lib/utils/concatData.js +1 -1
  270. package/lib/utils/dataMapping.js +1 -1
  271. package/lib/utils/date.js +1 -1
  272. package/lib/utils/debug.js +1 -1
  273. package/lib/utils/decodeEntity.js +1 -1
  274. package/lib/utils/dom.d.ts +2 -2
  275. package/lib/utils/dom.js +72 -13
  276. package/lib/utils/errors.js +1 -1
  277. package/lib/utils/escapeHtml.js +1 -1
  278. package/lib/utils/filter-schema.js +1 -1
  279. package/lib/utils/filter.js +1 -1
  280. package/lib/utils/formatDuration.js +1 -1
  281. package/lib/utils/formula.js +2 -2
  282. package/lib/utils/getVariable.js +1 -1
  283. package/lib/utils/grammar.js +1 -1
  284. package/lib/utils/handleAction.js +1 -1
  285. package/lib/utils/helper.d.ts +12 -6
  286. package/lib/utils/helper.js +41 -20
  287. package/lib/utils/highlight.js +1 -1
  288. package/lib/utils/icon.js +1 -1
  289. package/lib/utils/image.js +1 -1
  290. package/lib/utils/isPureVariable.js +1 -1
  291. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  292. package/lib/utils/keyToPath.js +1 -1
  293. package/lib/utils/labelToString.js +1 -1
  294. package/lib/utils/makeSorter.js +1 -1
  295. package/lib/utils/math.js +1 -1
  296. package/lib/utils/memoryParse.js +1 -1
  297. package/lib/utils/normalizeLink.js +1 -1
  298. package/lib/utils/normalizeOptions.js +1 -1
  299. package/lib/utils/object.js +1 -1
  300. package/lib/utils/offset.js +1 -1
  301. package/lib/utils/offsetParent.js +1 -1
  302. package/lib/utils/optionValueCompare.js +1 -1
  303. package/lib/utils/position.js +1 -1
  304. package/lib/utils/prettyBytes.js +1 -1
  305. package/lib/utils/printElement.js +1 -1
  306. package/lib/utils/renderer-event.d.ts +13 -0
  307. package/lib/utils/renderer-event.js +111 -1
  308. package/lib/utils/replaceText.js +1 -1
  309. package/lib/utils/resize-sensor.js +1 -1
  310. package/lib/utils/resolveCondition.js +1 -1
  311. package/lib/utils/resolveVariable.js +1 -1
  312. package/lib/utils/resolveVariableAndFilter.js +1 -1
  313. package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
  314. package/lib/utils/scrollPosition.js +1 -1
  315. package/lib/utils/string2regExp.js +1 -1
  316. package/lib/utils/stripNumber.d.ts +1 -1
  317. package/lib/utils/stripNumber.js +4 -3
  318. package/lib/utils/style-helper.d.ts +21 -2
  319. package/lib/utils/style-helper.js +55 -10
  320. package/lib/utils/style.js +1 -1
  321. package/lib/utils/toNumber.js +1 -1
  322. package/lib/utils/tokenize.js +1 -1
  323. package/lib/utils/tpl-builtin.js +1 -1
  324. package/lib/utils/tpl-lodash.js +1 -1
  325. package/lib/utils/tpl.js +4 -4
  326. package/lib/utils/uncontrollable.js +1 -1
  327. package/lib/utils/validateId.js +9 -2
  328. package/lib/utils/validations.js +1 -1
  329. package/package.json +5 -3
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.2.2
2
+ * amis-core v6.4.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -41,7 +41,7 @@ require('../utils/highlight.js');
41
41
  require('../utils/icon.js');
42
42
  require('../utils/image.js');
43
43
  require('lodash/isPlainObject');
44
- require('lodash/isEqual');
44
+ var isEqual = require('lodash/isEqual');
45
45
  require('../actions/Action.js');
46
46
  require('../utils/resize-sensor.js');
47
47
  require('react-overlays/useRootClose');
@@ -59,6 +59,7 @@ require('../utils/validations.js');
59
59
  require('../utils/resolveCondition.js');
60
60
  var mobx = require('mobx');
61
61
  require('../utils/Animation.js');
62
+ var groupBy = require('lodash/groupBy');
62
63
 
63
64
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
64
65
 
@@ -66,6 +67,8 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
66
67
  var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
67
68
  var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
68
69
  var find__default = /*#__PURE__*/_interopDefaultLegacy(find);
70
+ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
71
+ var groupBy__default = /*#__PURE__*/_interopDefaultLegacy(groupBy);
69
72
 
70
73
  var __react_jsx__ = require('react');
71
74
  var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
@@ -83,6 +86,8 @@ var Form = /** @class */ (function (_super) {
83
86
  });
84
87
  // 如果开启了 lazyChange,需要一个 flush 方法把队列中值应用上。
85
88
  _this.flushing = false;
89
+ _this.emittedData = null;
90
+ _this.emitting = false;
86
91
  _this.onInit = _this.onInit.bind(_this);
87
92
  _this.handleAction = _this.handleAction.bind(_this);
88
93
  _this.handleQuery = _this.handleQuery.bind(_this);
@@ -199,7 +204,6 @@ var Form = /** @class */ (function (_super) {
199
204
  return helper.until(function () { return store.checkRemote(initAsyncApi, store.data); }, function (ret) { return ret && ret[initFinishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); }, initCheckInterval);
200
205
  }
201
206
  })
202
- .then(this.dispatchInited)
203
207
  .then(this.initInterval)
204
208
  .then(this.onInit);
205
209
  }
@@ -220,8 +224,8 @@ var Form = /** @class */ (function (_super) {
220
224
  successMessage: fetchSuccess,
221
225
  errorMessage: fetchFailed
222
226
  })
223
- .then(this.dispatchInited)
224
- .then(this.initInterval);
227
+ .then(this.initInterval)
228
+ .then(this.dispatchInited);
225
229
  }
226
230
  };
227
231
  Form.prototype.componentWillUnmount = function () {
@@ -251,20 +255,18 @@ var Form = /** @class */ (function (_super) {
251
255
  Form.prototype.dispatchInited = function (value) {
252
256
  var _a;
253
257
  return tslib.__awaiter(this, void 0, void 0, function () {
254
- var _b, data, store, dispatchEvent;
258
+ var _b, data, store, dispatchEvent, result;
255
259
  return tslib.__generator(this, function (_c) {
256
260
  switch (_c.label) {
257
261
  case 0:
258
262
  _b = this.props, data = _b.data, store = _b.store, dispatchEvent = _b.dispatchEvent;
259
- if (store.fetching) {
263
+ if (!mobxStateTree.isAlive(store) || store.fetching) {
260
264
  return [2 /*return*/, value];
261
265
  }
262
- // 派发init事件,参数为初始化数据
263
266
  return [4 /*yield*/, dispatchEvent('inited', object.createObject(data, tslib.__assign(tslib.__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 })))];
264
267
  case 1:
265
- // 派发init事件,参数为初始化数据
266
- _c.sent();
267
- return [2 /*return*/, value];
268
+ result = _c.sent();
269
+ return [2 /*return*/, result];
268
270
  }
269
271
  });
270
272
  });
@@ -285,7 +287,7 @@ var Form = /** @class */ (function (_super) {
285
287
  };
286
288
  Form.prototype.onInit = function () {
287
289
  return tslib.__awaiter(this, void 0, void 0, function () {
288
- var _a, onInit, store, persistData, submitOnInit, data, initedAt, hooks;
290
+ var _a, onInit, store, persistData, submitOnInit, data, initedAt, hooks, groupedHooks, dispatch;
289
291
  return tslib.__generator(this, function (_b) {
290
292
  switch (_b.label) {
291
293
  case 0:
@@ -297,8 +299,23 @@ var Form = /** @class */ (function (_super) {
297
299
  initedAt = store.initedAt;
298
300
  store.setInited(true);
299
301
  hooks = this.hooks['init'] || [];
300
- return [4 /*yield*/, Promise.all(hooks.map(function (hook) { return hook(data); }))];
302
+ groupedHooks = groupBy__default["default"](hooks, function (item) {
303
+ return item.__enforce === 'prev'
304
+ ? 'prev'
305
+ : item.__enforce === 'post'
306
+ ? 'post'
307
+ : 'normal';
308
+ });
309
+ return [4 /*yield*/, Promise.all((groupedHooks.prev || []).map(function (hook) { return hook(data); }))];
301
310
  case 1:
311
+ _b.sent();
312
+ // 有可能在前面的步骤中删除了钩子,所以需要重新验证一下
313
+ return [4 /*yield*/, Promise.all((groupedHooks.normal || []).map(function (hook) { return hooks.includes(hook) && hook(data); }))];
314
+ case 2:
315
+ // 有可能在前面的步骤中删除了钩子,所以需要重新验证一下
316
+ _b.sent();
317
+ return [4 /*yield*/, Promise.all((groupedHooks.post || []).map(function (hook) { return hooks.includes(hook) && hook(data); }))];
318
+ case 3:
302
319
  _b.sent();
303
320
  if (!mobxStateTree.isAlive(store)) {
304
321
  return [2 /*return*/];
@@ -315,6 +332,13 @@ var Form = /** @class */ (function (_super) {
315
332
  data = object.cloneObject(store.data);
316
333
  }
317
334
  onInit && onInit(data, this.props);
335
+ return [4 /*yield*/, this.dispatchInited({ data: data })];
336
+ case 4:
337
+ dispatch = _b.sent();
338
+ if (dispatch === null || dispatch === void 0 ? void 0 : dispatch.prevented) {
339
+ return [2 /*return*/];
340
+ }
341
+ // submitOnInit
318
342
  submitOnInit &&
319
343
  this.handleAction(undefined, {
320
344
  type: 'submit'
@@ -340,7 +364,8 @@ var Form = /** @class */ (function (_super) {
340
364
  store.updateData((_c = {},
341
365
  _c[initFinishedField || 'finished'] = false,
342
366
  _c));
343
- if (!api.isEffectiveApi(initApi, store.data)) return [3 /*break*/, 3];
367
+ result = undefined;
368
+ if (!api.isEffectiveApi(initApi, store.data)) return [3 /*break*/, 2];
344
369
  return [4 /*yield*/, store.fetchInitData(initApi, store.data, {
345
370
  successMessage: fetchSuccess,
346
371
  errorMessage: fetchFailed,
@@ -356,20 +381,18 @@ var Form = /** @class */ (function (_super) {
356
381
  })];
357
382
  case 1:
358
383
  result = _d.sent();
359
- // 派发初始化接口请求完成事件
360
- return [4 /*yield*/, this.dispatchInited(result)];
361
- case 2:
362
- // 派发初始化接口请求完成事件
363
- _d.sent();
364
384
  if (result === null || result === void 0 ? void 0 : result.ok) {
365
385
  this.initInterval(result);
366
386
  store.reset(undefined, false);
367
387
  }
368
- return [3 /*break*/, 4];
369
- case 3:
388
+ return [3 /*break*/, 3];
389
+ case 2:
370
390
  store.reset(undefined, false);
371
- _d.label = 4;
372
- case 4: return [2 /*return*/];
391
+ _d.label = 3;
392
+ case 3:
393
+ // 派发初始化接口请求完成事件
394
+ this.dispatchInited(result);
395
+ return [2 /*return*/];
373
396
  }
374
397
  });
375
398
  });
@@ -471,7 +494,7 @@ var Form = /** @class */ (function (_super) {
471
494
  return tslib.__generator(this, function (_a) {
472
495
  switch (_a.label) {
473
496
  case 0:
474
- _a.trys.push([0, , 3, 4]);
497
+ _a.trys.push([0, , 4, 5]);
475
498
  if (this.flushing) {
476
499
  return [2 /*return*/];
477
500
  }
@@ -480,14 +503,16 @@ var Form = /** @class */ (function (_super) {
480
503
  return [4 /*yield*/, Promise.all(hooks.map(function (fn) { return fn(); }))];
481
504
  case 1:
482
505
  _a.sent();
506
+ if (!!this.emitting) return [3 /*break*/, 3];
483
507
  return [4 /*yield*/, this.lazyEmitChange.flush()];
484
508
  case 2:
485
509
  _a.sent();
486
- return [3 /*break*/, 4];
487
- case 3:
510
+ _a.label = 3;
511
+ case 3: return [3 /*break*/, 5];
512
+ case 4:
488
513
  this.flushing = false;
489
514
  return [7 /*endfinally*/];
490
- case 4: return [2 /*return*/];
515
+ case 5: return [2 /*return*/];
491
516
  }
492
517
  });
493
518
  });
@@ -496,11 +521,13 @@ var Form = /** @class */ (function (_super) {
496
521
  var _a = this.props, store = _a.store, onReset = _a.onReset;
497
522
  store.reset(onReset);
498
523
  };
499
- Form.prototype.addHook = function (fn, type) {
524
+ Form.prototype.addHook = function (fn, type, enforce) {
500
525
  var _this = this;
501
526
  if (type === void 0) { type = 'validate'; }
502
527
  this.hooks[type] = this.hooks[type] || [];
503
- this.hooks[type].push(type === 'flush' ? fn : helper.promisify(fn));
528
+ var hook = type === 'flush' ? fn : helper.promisify(fn);
529
+ hook.__enforce = enforce;
530
+ this.hooks[type].push(hook);
504
531
  return function () {
505
532
  _this.removeHook(fn, type);
506
533
  fn = helper.noop;
@@ -539,30 +566,34 @@ var Form = /** @class */ (function (_super) {
539
566
  var dispatchEvent = this.props.dispatchEvent;
540
567
  return dispatchEvent(type, data);
541
568
  };
542
- Form.prototype.emitChange = function (submit, skipIfNothingChanges) {
543
- if (skipIfNothingChanges === void 0) { skipIfNothingChanges = false; }
569
+ Form.prototype.emitChange = function (submit, emitedFromWatch) {
570
+ if (emitedFromWatch === void 0) { emitedFromWatch = false; }
544
571
  return tslib.__awaiter(this, void 0, void 0, function () {
545
- var _a, onChange, store, submitOnChange, dispatchEvent, data, diff, changeProps, dispatcher;
572
+ var _a, onChange, store, submitOnChange, dispatchEvent_1, data, diff, changeProps, dispatcher;
546
573
  return tslib.__generator(this, function (_b) {
547
574
  switch (_b.label) {
548
575
  case 0:
549
- _a = this.props, onChange = _a.onChange, store = _a.store, submitOnChange = _a.submitOnChange, dispatchEvent = _a.dispatchEvent, data = _a.data;
576
+ _b.trys.push([0, , 4, 5]);
577
+ this.emitting = true;
578
+ _a = this.props, onChange = _a.onChange, store = _a.store, submitOnChange = _a.submitOnChange, dispatchEvent_1 = _a.dispatchEvent, data = _a.data;
550
579
  if (!mobxStateTree.isAlive(store)) {
551
580
  return [2 /*return*/];
552
581
  }
553
582
  diff = helper.difference(store.data, store.pristine);
554
- if (skipIfNothingChanges && !Object.keys(diff).length) {
583
+ if (emitedFromWatch &&
584
+ (!Object.keys(diff).length || isEqual__default["default"](store.data, this.emittedData))) {
555
585
  return [2 /*return*/];
556
586
  }
587
+ this.emittedData = store.data;
557
588
  changeProps = [store.data, diff, this.props];
558
- return [4 /*yield*/, dispatchEvent('change', object.createObject(data, store.data))];
589
+ return [4 /*yield*/, dispatchEvent_1('change', object.createObject(data, store.data))];
559
590
  case 1:
560
591
  dispatcher = _b.sent();
561
592
  if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
562
593
  onChange && onChange.apply(null, changeProps);
563
594
  }
564
595
  store.clearRestError();
565
- if (!(submit || (submitOnChange && store.inited))) return [3 /*break*/, 3];
596
+ if (!(!emitedFromWatch && (submit || (submitOnChange && store.inited)))) return [3 /*break*/, 3];
566
597
  return [4 /*yield*/, this.handleAction(undefined, {
567
598
  type: 'submit',
568
599
  // 如果这里不跳过,会相互依赖死循环,flush 会 让 emiteChange 立即执行
@@ -572,7 +603,11 @@ var Form = /** @class */ (function (_super) {
572
603
  case 2:
573
604
  _b.sent();
574
605
  _b.label = 3;
575
- case 3: return [2 /*return*/];
606
+ case 3: return [3 /*break*/, 5];
607
+ case 4:
608
+ this.emitting = false;
609
+ return [7 /*endfinally*/];
610
+ case 5: return [2 /*return*/];
576
611
  }
577
612
  });
578
613
  });
@@ -617,7 +652,7 @@ var Form = /** @class */ (function (_super) {
617
652
  var _a, _b;
618
653
  if (throwErrors === void 0) { throwErrors = false; }
619
654
  return tslib.__awaiter(this, void 0, void 0, function () {
620
- var _c, store, onSubmit, api$1, 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;
655
+ var _c, store, onSubmit, api$1, 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;
621
656
  var _this = this;
622
657
  return tslib.__generator(this, function (_f) {
623
658
  switch (_f.label) {
@@ -665,15 +700,15 @@ var Form = /** @class */ (function (_super) {
665
700
  action.actionType === 'confirm' ||
666
701
  action.actionType === 'reset-and-submit' ||
667
702
  action.actionType === 'clear-and-submit')) return [3 /*break*/, 8];
668
- _e = this.props, dispatchEvent_1 = _e.dispatchEvent, onEvent = _e.onEvent;
703
+ _e = this.props, dispatchEvent_2 = _e.dispatchEvent, onEvent = _e.onEvent;
669
704
  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;
670
- return [4 /*yield*/, dispatchEvent_1('submit', this.props.data)];
705
+ return [4 /*yield*/, dispatchEvent_2('submit', this.props.data)];
671
706
  case 7:
672
707
  dispatcher = _f.sent();
673
708
  if ((dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented) || submitEvent) {
674
709
  return [2 /*return*/];
675
710
  }
676
- store.setCurrentAction(action);
711
+ store.setCurrentAction(action, this.props.resolveDefinitions);
677
712
  if (action.actionType === 'reset-and-submit') {
678
713
  store.reset(this.handleReset(action));
679
714
  }
@@ -697,22 +732,40 @@ var Form = /** @class */ (function (_super) {
697
732
  _b.label = 2;
698
733
  case 2:
699
734
  // 走到这里代表校验成功了
700
- dispatchEvent_1('validateSucc', this.props.data);
735
+ dispatchEvent_2('validateSucc', this.props.data);
701
736
  if (target) {
702
737
  this.submitToTarget(Scoped.filterTarget(target, values), values);
703
738
  /** 可能配置页面跳转事件,页面路由变化导致persistKey不一致,无法清除持久化数据,所以提交成功事件之前先清理一下 */
704
739
  clearPersistDataAfterSubmit && store.clearLocalPersistData();
705
- dispatchEvent_1('submitSucc', object.createObject(this.props.data, values));
740
+ dispatchEvent_2('submitSucc', object.createObject(this.props.data, values));
706
741
  }
707
742
  else if (action.actionType === 'reload') {
708
743
  action.target &&
709
744
  this.reloadTarget(Scoped.filterTarget(action.target, values), values);
710
745
  }
711
746
  else if (action.actionType === 'dialog') {
712
- store.openDialog(data, undefined, action.callback, delegate || this.context);
747
+ return [2 /*return*/, new Promise(function (resolve) {
748
+ store.openDialog(data, undefined, function (confirmed, value) {
749
+ var _a;
750
+ (_a = action.callback) === null || _a === void 0 ? void 0 : _a.call(action, confirmed, value);
751
+ resolve({
752
+ confirmed: confirmed,
753
+ value: value
754
+ });
755
+ }, delegate || _this.context);
756
+ })];
713
757
  }
714
758
  else if (action.actionType === 'drawer') {
715
- store.openDrawer(data);
759
+ return [2 /*return*/, new Promise(function (resolve) {
760
+ store.openDrawer(data, undefined, function (confirmed, value) {
761
+ var _a;
762
+ (_a = action.callback) === null || _a === void 0 ? void 0 : _a.call(action, confirmed, value);
763
+ resolve({
764
+ confirmed: confirmed,
765
+ value: value
766
+ });
767
+ });
768
+ })];
716
769
  }
717
770
  else if (api.isEffectiveApi(action.api || api$1, values)) {
718
771
  finnalAsyncApi_1 = action.asyncApi || asyncApi;
@@ -735,7 +788,7 @@ var Form = /** @class */ (function (_super) {
735
788
  switch (_a.label) {
736
789
  case 0:
737
790
  clearPersistDataAfterSubmit && store.clearLocalPersistData();
738
- return [4 /*yield*/, dispatchEvent_1('submitSucc', object.createObject(this.props.data, { result: result }))];
791
+ return [4 /*yield*/, dispatchEvent_2('submitSucc', object.createObject(this.props.data, { result: result }))];
739
792
  case 1:
740
793
  dispatcher = _a.sent();
741
794
  if (!api.isEffectiveApi(finnalAsyncApi_1, store.data) ||
@@ -747,7 +800,7 @@ var Form = /** @class */ (function (_super) {
747
800
  }
748
801
  cbResult = helper.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) {
749
802
  // 派发asyncApiFinished事件
750
- dispatchEvent_1('asyncApiFinished', store.data);
803
+ dispatchEvent_2('asyncApiFinished', store.data);
751
804
  });
752
805
  return [2 /*return*/, {
753
806
  cbResult: cbResult,
@@ -760,7 +813,7 @@ var Form = /** @class */ (function (_super) {
760
813
  var dispatcher;
761
814
  return tslib.__generator(this, function (_a) {
762
815
  switch (_a.label) {
763
- case 0: return [4 /*yield*/, dispatchEvent_1('submitFail', object.createObject(this.props.data, { error: result }))];
816
+ case 0: return [4 /*yield*/, dispatchEvent_2('submitFail', object.createObject(this.props.data, { error: result }))];
764
817
  case 1:
765
818
  dispatcher = _a.sent();
766
819
  return [2 /*return*/, {
@@ -800,7 +853,7 @@ var Form = /** @class */ (function (_super) {
800
853
  else {
801
854
  clearPersistDataAfterSubmit && store.clearLocalPersistData();
802
855
  // type为submit,但是没有配api以及target时,只派发事件
803
- dispatchEvent_1('submitSucc', object.createObject(this.props.data, values));
856
+ dispatchEvent_2('submitSucc', object.createObject(this.props.data, values));
804
857
  }
805
858
  return [2 /*return*/, Promise.resolve(null)];
806
859
  }
@@ -835,27 +888,45 @@ var Form = /** @class */ (function (_super) {
835
888
  })];
836
889
  case 8:
837
890
  if (action.type === 'reset' || action.actionType === 'reset') {
838
- store.setCurrentAction(action);
891
+ store.setCurrentAction(action, this.props.resolveDefinitions);
839
892
  store.reset(onReset);
840
893
  }
841
894
  else if (action.actionType === 'clear') {
842
- store.setCurrentAction(action);
895
+ store.setCurrentAction(action, this.props.resolveDefinitions);
843
896
  store.clear(onReset);
844
897
  }
845
898
  else if (action.actionType === 'validate') {
846
- store.setCurrentAction(action);
899
+ store.setCurrentAction(action, this.props.resolveDefinitions);
847
900
  return [2 /*return*/, this.validate(true, throwErrors, true, true)];
848
901
  }
849
902
  else if (action.actionType === 'dialog') {
850
- store.setCurrentAction(action);
851
- store.openDialog(data, undefined, action.callback, delegate || this.context);
903
+ store.setCurrentAction(action, this.props.resolveDefinitions);
904
+ return [2 /*return*/, new Promise(function (resolve) {
905
+ store.openDialog(data, undefined, function (confirmed, value) {
906
+ var _a;
907
+ (_a = action.callback) === null || _a === void 0 ? void 0 : _a.call(action, confirmed, value);
908
+ resolve({
909
+ confirmed: confirmed,
910
+ value: value
911
+ });
912
+ }, delegate || _this.context);
913
+ })];
852
914
  }
853
915
  else if (action.actionType === 'drawer') {
854
- store.setCurrentAction(action);
855
- store.openDrawer(data);
916
+ store.setCurrentAction(action, this.props.resolveDefinitions);
917
+ return [2 /*return*/, new Promise(function (resolve) {
918
+ store.openDrawer(data, undefined, function (confirmed, value) {
919
+ var _a;
920
+ (_a = action.callback) === null || _a === void 0 ? void 0 : _a.call(action, confirmed, value);
921
+ resolve({
922
+ confirmed: confirmed,
923
+ value: value
924
+ });
925
+ });
926
+ })];
856
927
  }
857
928
  else if (action.actionType === 'ajax') {
858
- store.setCurrentAction(action);
929
+ store.setCurrentAction(action, this.props.resolveDefinitions);
859
930
  if (!api.isEffectiveApi(action.api)) {
860
931
  return [2 /*return*/, env.alert(__("\u5F53 actionType \u4E3A ajax \u65F6\uFF0C\u8BF7\u8BBE\u7F6E api \u5C5E\u6027"))];
861
932
  }
@@ -907,7 +978,7 @@ var Form = /** @class */ (function (_super) {
907
978
  })];
908
979
  }
909
980
  else if (action.actionType === 'reload') {
910
- store.setCurrentAction(action);
981
+ store.setCurrentAction(action, this.props.resolveDefinitions);
911
982
  if (action.target) {
912
983
  this.reloadTarget(Scoped.filterTarget(action.target, data), data);
913
984
  }
@@ -952,7 +1023,7 @@ var Form = /** @class */ (function (_super) {
952
1023
  targets[0].props.type === 'form') {
953
1024
  this.handleBulkChange(values[0], false);
954
1025
  }
955
- store.closeDialog(true);
1026
+ store.closeDialog(true, values);
956
1027
  };
957
1028
  Form.prototype.handleDialogClose = function (confirmed) {
958
1029
  if (confirmed === void 0) { confirmed = false; }
@@ -969,7 +1040,7 @@ var Form = /** @class */ (function (_super) {
969
1040
  onChange &&
970
1041
  onChange(store.data, helper.difference(store.data, store.pristine), this.props);
971
1042
  }
972
- store.closeDrawer(true);
1043
+ store.closeDrawer(true, values);
973
1044
  };
974
1045
  Form.prototype.handleDrawerClose = function () {
975
1046
  var store = this.props.store;
@@ -992,7 +1063,7 @@ var Form = /** @class */ (function (_super) {
992
1063
  type: 'button',
993
1064
  actionType: 'dialog',
994
1065
  dialog: dialog
995
- });
1066
+ }, _this.props.resolveDefinitions);
996
1067
  store.openDialog(ctx, undefined, function (confirmed) {
997
1068
  resolve(confirmed);
998
1069
  }, _this.context);
@@ -1133,14 +1204,14 @@ var Form = /** @class */ (function (_super) {
1133
1204
  return render("".concat(region ? "".concat(region, "/") : '').concat(key), subSchema, subProps);
1134
1205
  };
1135
1206
  Form.prototype.renderBody = function () {
1136
- var _a = this.props, body = _a.body, mode = _a.mode, className = _a.className, cx = _a.classnames, debug = _a.debug, debugConfig = _a.debugConfig, $path = _a.$path, store = _a.store, columnCount = _a.columnCount, render = _a.render, staticClassName = _a.staticClassName, _b = _a.static, isStatic = _b === void 0 ? false : _b, loadingConfig = _a.loadingConfig, testid = _a.testid;
1207
+ var _a = this.props, body = _a.body, mode = _a.mode, className = _a.className, cx = _a.classnames, debug = _a.debug, debugConfig = _a.debugConfig, $path = _a.$path, store = _a.store, columnCount = _a.columnCount, render = _a.render, staticClassName = _a.staticClassName, _b = _a.static, isStatic = _b === void 0 ? false : _b, loadingConfig = _a.loadingConfig; _a.testid;
1137
1208
  var restError = store.restError;
1138
1209
  var WrapperComponent = this.props.wrapperComponent ||
1139
1210
  (/(?:\/|^)form\//.test($path) ? 'div' : 'form');
1140
1211
  var padDom = helper.repeatCount(columnCount && Array.isArray(body)
1141
1212
  ? (columnCount - (body.length % columnCount)) % columnCount
1142
1213
  : 0, function (index) { return (_J$X_("div", { className: cx("Form-item Form-item--".concat(mode, " is-placeholder")), key: index })); });
1143
- return (_J$X_(WrapperComponent, tslib.__assign({ className: cx("Form", "Form--".concat(mode || 'normal'), columnCount ? "Form--column Form--column-".concat(columnCount) : null, staticClassName && isStatic ? staticClassName : className, isStatic ? 'Form--isStatic' : null), onSubmit: this.handleFormSubmit, noValidate: true }, helper.buildTestId(testid)),
1214
+ 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), onSubmit: this.handleFormSubmit, noValidate: true },
1144
1215
  _J$X_("input", { type: "submit", style: { display: 'none' } }),
1145
1216
  debug
1146
1217
  ? render('form-debug-json', tslib.__assign({ type: 'json', value: store.data, ellipsisThreshold: 120, className: cx('Form--debug') }, debugConfig))
@@ -1414,8 +1485,7 @@ var FormRenderer = /** @class */ (function (_super) {
1414
1485
  onChange(store.data, helper.difference(store.data, store.pristine), this.props);
1415
1486
  };
1416
1487
  FormRenderer.prototype.getData = function () {
1417
- var store = this.props.store;
1418
- return store.data;
1488
+ return this.getValues();
1419
1489
  };
1420
1490
  FormRenderer.contextType = Scoped.ScopedContext;
1421
1491
  FormRenderer = tslib.__decorate([