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
 
@@ -9,7 +9,7 @@ import { Renderer } from '../factory.js';
9
9
  import { FormStore } from '../store/form.js';
10
10
  import { evalExpression, filter } from '../utils/tpl.js';
11
11
  import { getExprProperties } from '../utils/filter-schema.js';
12
- import { promisify, isEmpty, until, noop, difference, isVisible, repeatCount, buildTestId, qsparse, isObjectShallowModified, SkipOperation } from '../utils/helper.js';
12
+ import { promisify, isEmpty, until, noop, difference, isVisible, repeatCount, qsparse, isObjectShallowModified, SkipOperation } from '../utils/helper.js';
13
13
  import debounce from 'lodash/debounce';
14
14
  import flatten from 'lodash/flatten';
15
15
  import find from 'lodash/find';
@@ -35,7 +35,7 @@ import 'lodash/isString';
35
35
  import 'lodash/isBoolean';
36
36
  import '../utils/image.js';
37
37
  import 'lodash/isPlainObject';
38
- import 'lodash/isEqual';
38
+ import isEqual from 'lodash/isEqual';
39
39
  import '../actions/Action.js';
40
40
  import '../utils/resize-sensor.js';
41
41
  import 'react-overlays/useRootClose';
@@ -52,6 +52,7 @@ import '../utils/validations.js';
52
52
  import '../utils/resolveCondition.js';
53
53
  import { reaction } from 'mobx';
54
54
  import '../utils/Animation.js';
55
+ import groupBy from 'lodash/groupBy';
55
56
 
56
57
  var Form = /** @class */ (function (_super) {
57
58
  __extends(Form, _super);
@@ -66,6 +67,8 @@ var Form = /** @class */ (function (_super) {
66
67
  });
67
68
  // 如果开启了 lazyChange,需要一个 flush 方法把队列中值应用上。
68
69
  _this.flushing = false;
70
+ _this.emittedData = null;
71
+ _this.emitting = false;
69
72
  _this.onInit = _this.onInit.bind(_this);
70
73
  _this.handleAction = _this.handleAction.bind(_this);
71
74
  _this.handleQuery = _this.handleQuery.bind(_this);
@@ -182,7 +185,6 @@ var Form = /** @class */ (function (_super) {
182
185
  return until(function () { return store.checkRemote(initAsyncApi, store.data); }, function (ret) { return ret && ret[initFinishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); }, initCheckInterval);
183
186
  }
184
187
  })
185
- .then(this.dispatchInited)
186
188
  .then(this.initInterval)
187
189
  .then(this.onInit);
188
190
  }
@@ -203,8 +205,8 @@ var Form = /** @class */ (function (_super) {
203
205
  successMessage: fetchSuccess,
204
206
  errorMessage: fetchFailed
205
207
  })
206
- .then(this.dispatchInited)
207
- .then(this.initInterval);
208
+ .then(this.initInterval)
209
+ .then(this.dispatchInited);
208
210
  }
209
211
  };
210
212
  Form.prototype.componentWillUnmount = function () {
@@ -234,20 +236,18 @@ var Form = /** @class */ (function (_super) {
234
236
  Form.prototype.dispatchInited = function (value) {
235
237
  var _a;
236
238
  return __awaiter(this, void 0, void 0, function () {
237
- var _b, data, store, dispatchEvent;
239
+ var _b, data, store, dispatchEvent, result;
238
240
  return __generator(this, function (_c) {
239
241
  switch (_c.label) {
240
242
  case 0:
241
243
  _b = this.props, data = _b.data, store = _b.store, dispatchEvent = _b.dispatchEvent;
242
- if (store.fetching) {
244
+ if (!isAlive(store) || store.fetching) {
243
245
  return [2 /*return*/, value];
244
246
  }
245
- // 派发init事件,参数为初始化数据
246
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 })))];
247
248
  case 1:
248
- // 派发init事件,参数为初始化数据
249
- _c.sent();
250
- return [2 /*return*/, value];
249
+ result = _c.sent();
250
+ return [2 /*return*/, result];
251
251
  }
252
252
  });
253
253
  });
@@ -268,7 +268,7 @@ var Form = /** @class */ (function (_super) {
268
268
  };
269
269
  Form.prototype.onInit = function () {
270
270
  return __awaiter(this, void 0, void 0, function () {
271
- var _a, onInit, store, persistData, submitOnInit, data, initedAt, hooks;
271
+ var _a, onInit, store, persistData, submitOnInit, data, initedAt, hooks, groupedHooks, dispatch;
272
272
  return __generator(this, function (_b) {
273
273
  switch (_b.label) {
274
274
  case 0:
@@ -280,8 +280,23 @@ var Form = /** @class */ (function (_super) {
280
280
  initedAt = store.initedAt;
281
281
  store.setInited(true);
282
282
  hooks = this.hooks['init'] || [];
283
- return [4 /*yield*/, Promise.all(hooks.map(function (hook) { return hook(data); }))];
283
+ groupedHooks = groupBy(hooks, function (item) {
284
+ return item.__enforce === 'prev'
285
+ ? 'prev'
286
+ : item.__enforce === 'post'
287
+ ? 'post'
288
+ : 'normal';
289
+ });
290
+ return [4 /*yield*/, Promise.all((groupedHooks.prev || []).map(function (hook) { return hook(data); }))];
284
291
  case 1:
292
+ _b.sent();
293
+ // 有可能在前面的步骤中删除了钩子,所以需要重新验证一下
294
+ return [4 /*yield*/, Promise.all((groupedHooks.normal || []).map(function (hook) { return hooks.includes(hook) && hook(data); }))];
295
+ case 2:
296
+ // 有可能在前面的步骤中删除了钩子,所以需要重新验证一下
297
+ _b.sent();
298
+ return [4 /*yield*/, Promise.all((groupedHooks.post || []).map(function (hook) { return hooks.includes(hook) && hook(data); }))];
299
+ case 3:
285
300
  _b.sent();
286
301
  if (!isAlive(store)) {
287
302
  return [2 /*return*/];
@@ -298,6 +313,13 @@ var Form = /** @class */ (function (_super) {
298
313
  data = cloneObject(store.data);
299
314
  }
300
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
301
323
  submitOnInit &&
302
324
  this.handleAction(undefined, {
303
325
  type: 'submit'
@@ -323,7 +345,8 @@ var Form = /** @class */ (function (_super) {
323
345
  store.updateData((_c = {},
324
346
  _c[initFinishedField || 'finished'] = false,
325
347
  _c));
326
- if (!isEffectiveApi(initApi, store.data)) return [3 /*break*/, 3];
348
+ result = undefined;
349
+ if (!isEffectiveApi(initApi, store.data)) return [3 /*break*/, 2];
327
350
  return [4 /*yield*/, store.fetchInitData(initApi, store.data, {
328
351
  successMessage: fetchSuccess,
329
352
  errorMessage: fetchFailed,
@@ -339,20 +362,18 @@ var Form = /** @class */ (function (_super) {
339
362
  })];
340
363
  case 1:
341
364
  result = _d.sent();
342
- // 派发初始化接口请求完成事件
343
- return [4 /*yield*/, this.dispatchInited(result)];
344
- case 2:
345
- // 派发初始化接口请求完成事件
346
- _d.sent();
347
365
  if (result === null || result === void 0 ? void 0 : result.ok) {
348
366
  this.initInterval(result);
349
367
  store.reset(undefined, false);
350
368
  }
351
- return [3 /*break*/, 4];
352
- case 3:
369
+ return [3 /*break*/, 3];
370
+ case 2:
353
371
  store.reset(undefined, false);
354
- _d.label = 4;
355
- case 4: return [2 /*return*/];
372
+ _d.label = 3;
373
+ case 3:
374
+ // 派发初始化接口请求完成事件
375
+ this.dispatchInited(result);
376
+ return [2 /*return*/];
356
377
  }
357
378
  });
358
379
  });
@@ -454,7 +475,7 @@ var Form = /** @class */ (function (_super) {
454
475
  return __generator(this, function (_a) {
455
476
  switch (_a.label) {
456
477
  case 0:
457
- _a.trys.push([0, , 3, 4]);
478
+ _a.trys.push([0, , 4, 5]);
458
479
  if (this.flushing) {
459
480
  return [2 /*return*/];
460
481
  }
@@ -463,14 +484,16 @@ var Form = /** @class */ (function (_super) {
463
484
  return [4 /*yield*/, Promise.all(hooks.map(function (fn) { return fn(); }))];
464
485
  case 1:
465
486
  _a.sent();
487
+ if (!!this.emitting) return [3 /*break*/, 3];
466
488
  return [4 /*yield*/, this.lazyEmitChange.flush()];
467
489
  case 2:
468
490
  _a.sent();
469
- return [3 /*break*/, 4];
470
- case 3:
491
+ _a.label = 3;
492
+ case 3: return [3 /*break*/, 5];
493
+ case 4:
471
494
  this.flushing = false;
472
495
  return [7 /*endfinally*/];
473
- case 4: return [2 /*return*/];
496
+ case 5: return [2 /*return*/];
474
497
  }
475
498
  });
476
499
  });
@@ -479,11 +502,13 @@ var Form = /** @class */ (function (_super) {
479
502
  var _a = this.props, store = _a.store, onReset = _a.onReset;
480
503
  store.reset(onReset);
481
504
  };
482
- Form.prototype.addHook = function (fn, type) {
505
+ Form.prototype.addHook = function (fn, type, enforce) {
483
506
  var _this = this;
484
507
  if (type === void 0) { type = 'validate'; }
485
508
  this.hooks[type] = this.hooks[type] || [];
486
- this.hooks[type].push(type === 'flush' ? fn : promisify(fn));
509
+ var hook = type === 'flush' ? fn : promisify(fn);
510
+ hook.__enforce = enforce;
511
+ this.hooks[type].push(hook);
487
512
  return function () {
488
513
  _this.removeHook(fn, type);
489
514
  fn = noop;
@@ -522,30 +547,34 @@ var Form = /** @class */ (function (_super) {
522
547
  var dispatchEvent = this.props.dispatchEvent;
523
548
  return dispatchEvent(type, data);
524
549
  };
525
- Form.prototype.emitChange = function (submit, skipIfNothingChanges) {
526
- if (skipIfNothingChanges === void 0) { skipIfNothingChanges = false; }
550
+ Form.prototype.emitChange = function (submit, emitedFromWatch) {
551
+ if (emitedFromWatch === void 0) { emitedFromWatch = false; }
527
552
  return __awaiter(this, void 0, void 0, function () {
528
- var _a, onChange, store, submitOnChange, dispatchEvent, data, diff, changeProps, dispatcher;
553
+ var _a, onChange, store, submitOnChange, dispatchEvent_1, data, diff, changeProps, dispatcher;
529
554
  return __generator(this, function (_b) {
530
555
  switch (_b.label) {
531
556
  case 0:
532
- _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;
533
560
  if (!isAlive(store)) {
534
561
  return [2 /*return*/];
535
562
  }
536
563
  diff = difference(store.data, store.pristine);
537
- if (skipIfNothingChanges && !Object.keys(diff).length) {
564
+ if (emitedFromWatch &&
565
+ (!Object.keys(diff).length || isEqual(store.data, this.emittedData))) {
538
566
  return [2 /*return*/];
539
567
  }
568
+ this.emittedData = store.data;
540
569
  changeProps = [store.data, diff, this.props];
541
- return [4 /*yield*/, dispatchEvent('change', createObject(data, store.data))];
570
+ return [4 /*yield*/, dispatchEvent_1('change', createObject(data, store.data))];
542
571
  case 1:
543
572
  dispatcher = _b.sent();
544
573
  if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
545
574
  onChange && onChange.apply(null, changeProps);
546
575
  }
547
576
  store.clearRestError();
548
- if (!(submit || (submitOnChange && store.inited))) return [3 /*break*/, 3];
577
+ if (!(!emitedFromWatch && (submit || (submitOnChange && store.inited)))) return [3 /*break*/, 3];
549
578
  return [4 /*yield*/, this.handleAction(undefined, {
550
579
  type: 'submit',
551
580
  // 如果这里不跳过,会相互依赖死循环,flush 会 让 emiteChange 立即执行
@@ -555,7 +584,11 @@ var Form = /** @class */ (function (_super) {
555
584
  case 2:
556
585
  _b.sent();
557
586
  _b.label = 3;
558
- 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*/];
559
592
  }
560
593
  });
561
594
  });
@@ -600,7 +633,7 @@ var Form = /** @class */ (function (_super) {
600
633
  var _a, _b;
601
634
  if (throwErrors === void 0) { throwErrors = false; }
602
635
  return __awaiter(this, void 0, void 0, function () {
603
- 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;
604
637
  var _this = this;
605
638
  return __generator(this, function (_f) {
606
639
  switch (_f.label) {
@@ -648,15 +681,15 @@ var Form = /** @class */ (function (_super) {
648
681
  action.actionType === 'confirm' ||
649
682
  action.actionType === 'reset-and-submit' ||
650
683
  action.actionType === 'clear-and-submit')) return [3 /*break*/, 8];
651
- _e = this.props, dispatchEvent_1 = _e.dispatchEvent, onEvent = _e.onEvent;
684
+ _e = this.props, dispatchEvent_2 = _e.dispatchEvent, onEvent = _e.onEvent;
652
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;
653
- return [4 /*yield*/, dispatchEvent_1('submit', this.props.data)];
686
+ return [4 /*yield*/, dispatchEvent_2('submit', this.props.data)];
654
687
  case 7:
655
688
  dispatcher = _f.sent();
656
689
  if ((dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented) || submitEvent) {
657
690
  return [2 /*return*/];
658
691
  }
659
- store.setCurrentAction(action);
692
+ store.setCurrentAction(action, this.props.resolveDefinitions);
660
693
  if (action.actionType === 'reset-and-submit') {
661
694
  store.reset(this.handleReset(action));
662
695
  }
@@ -680,22 +713,40 @@ var Form = /** @class */ (function (_super) {
680
713
  _b.label = 2;
681
714
  case 2:
682
715
  // 走到这里代表校验成功了
683
- dispatchEvent_1('validateSucc', this.props.data);
716
+ dispatchEvent_2('validateSucc', this.props.data);
684
717
  if (target) {
685
718
  this.submitToTarget(filterTarget(target, values), values);
686
719
  /** 可能配置页面跳转事件,页面路由变化导致persistKey不一致,无法清除持久化数据,所以提交成功事件之前先清理一下 */
687
720
  clearPersistDataAfterSubmit && store.clearLocalPersistData();
688
- dispatchEvent_1('submitSucc', createObject(this.props.data, values));
721
+ dispatchEvent_2('submitSucc', createObject(this.props.data, values));
689
722
  }
690
723
  else if (action.actionType === 'reload') {
691
724
  action.target &&
692
725
  this.reloadTarget(filterTarget(action.target, values), values);
693
726
  }
694
727
  else if (action.actionType === 'dialog') {
695
- store.openDialog(data, undefined, action.callback, delegate || this.context);
728
+ return [2 /*return*/, new Promise(function (resolve) {
729
+ store.openDialog(data, undefined, function (confirmed, value) {
730
+ var _a;
731
+ (_a = action.callback) === null || _a === void 0 ? void 0 : _a.call(action, confirmed, value);
732
+ resolve({
733
+ confirmed: confirmed,
734
+ value: value
735
+ });
736
+ }, delegate || _this.context);
737
+ })];
696
738
  }
697
739
  else if (action.actionType === 'drawer') {
698
- store.openDrawer(data);
740
+ return [2 /*return*/, new Promise(function (resolve) {
741
+ store.openDrawer(data, undefined, function (confirmed, value) {
742
+ var _a;
743
+ (_a = action.callback) === null || _a === void 0 ? void 0 : _a.call(action, confirmed, value);
744
+ resolve({
745
+ confirmed: confirmed,
746
+ value: value
747
+ });
748
+ });
749
+ })];
699
750
  }
700
751
  else if (isEffectiveApi(action.api || api, values)) {
701
752
  finnalAsyncApi_1 = action.asyncApi || asyncApi;
@@ -718,7 +769,7 @@ var Form = /** @class */ (function (_super) {
718
769
  switch (_a.label) {
719
770
  case 0:
720
771
  clearPersistDataAfterSubmit && store.clearLocalPersistData();
721
- 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 }))];
722
773
  case 1:
723
774
  dispatcher = _a.sent();
724
775
  if (!isEffectiveApi(finnalAsyncApi_1, store.data) ||
@@ -730,7 +781,7 @@ var Form = /** @class */ (function (_super) {
730
781
  }
731
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) {
732
783
  // 派发asyncApiFinished事件
733
- dispatchEvent_1('asyncApiFinished', store.data);
784
+ dispatchEvent_2('asyncApiFinished', store.data);
734
785
  });
735
786
  return [2 /*return*/, {
736
787
  cbResult: cbResult,
@@ -743,7 +794,7 @@ var Form = /** @class */ (function (_super) {
743
794
  var dispatcher;
744
795
  return __generator(this, function (_a) {
745
796
  switch (_a.label) {
746
- 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 }))];
747
798
  case 1:
748
799
  dispatcher = _a.sent();
749
800
  return [2 /*return*/, {
@@ -783,7 +834,7 @@ var Form = /** @class */ (function (_super) {
783
834
  else {
784
835
  clearPersistDataAfterSubmit && store.clearLocalPersistData();
785
836
  // type为submit,但是没有配api以及target时,只派发事件
786
- dispatchEvent_1('submitSucc', createObject(this.props.data, values));
837
+ dispatchEvent_2('submitSucc', createObject(this.props.data, values));
787
838
  }
788
839
  return [2 /*return*/, Promise.resolve(null)];
789
840
  }
@@ -818,27 +869,45 @@ var Form = /** @class */ (function (_super) {
818
869
  })];
819
870
  case 8:
820
871
  if (action.type === 'reset' || action.actionType === 'reset') {
821
- store.setCurrentAction(action);
872
+ store.setCurrentAction(action, this.props.resolveDefinitions);
822
873
  store.reset(onReset);
823
874
  }
824
875
  else if (action.actionType === 'clear') {
825
- store.setCurrentAction(action);
876
+ store.setCurrentAction(action, this.props.resolveDefinitions);
826
877
  store.clear(onReset);
827
878
  }
828
879
  else if (action.actionType === 'validate') {
829
- store.setCurrentAction(action);
880
+ store.setCurrentAction(action, this.props.resolveDefinitions);
830
881
  return [2 /*return*/, this.validate(true, throwErrors, true, true)];
831
882
  }
832
883
  else if (action.actionType === 'dialog') {
833
- store.setCurrentAction(action);
834
- store.openDialog(data, undefined, action.callback, delegate || this.context);
884
+ store.setCurrentAction(action, this.props.resolveDefinitions);
885
+ return [2 /*return*/, new Promise(function (resolve) {
886
+ store.openDialog(data, undefined, function (confirmed, value) {
887
+ var _a;
888
+ (_a = action.callback) === null || _a === void 0 ? void 0 : _a.call(action, confirmed, value);
889
+ resolve({
890
+ confirmed: confirmed,
891
+ value: value
892
+ });
893
+ }, delegate || _this.context);
894
+ })];
835
895
  }
836
896
  else if (action.actionType === 'drawer') {
837
- store.setCurrentAction(action);
838
- store.openDrawer(data);
897
+ store.setCurrentAction(action, this.props.resolveDefinitions);
898
+ return [2 /*return*/, new Promise(function (resolve) {
899
+ store.openDrawer(data, undefined, function (confirmed, value) {
900
+ var _a;
901
+ (_a = action.callback) === null || _a === void 0 ? void 0 : _a.call(action, confirmed, value);
902
+ resolve({
903
+ confirmed: confirmed,
904
+ value: value
905
+ });
906
+ });
907
+ })];
839
908
  }
840
909
  else if (action.actionType === 'ajax') {
841
- store.setCurrentAction(action);
910
+ store.setCurrentAction(action, this.props.resolveDefinitions);
842
911
  if (!isEffectiveApi(action.api)) {
843
912
  return [2 /*return*/, env.alert(__("\u5F53 actionType \u4E3A ajax \u65F6\uFF0C\u8BF7\u8BBE\u7F6E api \u5C5E\u6027"))];
844
913
  }
@@ -890,7 +959,7 @@ var Form = /** @class */ (function (_super) {
890
959
  })];
891
960
  }
892
961
  else if (action.actionType === 'reload') {
893
- store.setCurrentAction(action);
962
+ store.setCurrentAction(action, this.props.resolveDefinitions);
894
963
  if (action.target) {
895
964
  this.reloadTarget(filterTarget(action.target, data), data);
896
965
  }
@@ -935,7 +1004,7 @@ var Form = /** @class */ (function (_super) {
935
1004
  targets[0].props.type === 'form') {
936
1005
  this.handleBulkChange(values[0], false);
937
1006
  }
938
- store.closeDialog(true);
1007
+ store.closeDialog(true, values);
939
1008
  };
940
1009
  Form.prototype.handleDialogClose = function (confirmed) {
941
1010
  if (confirmed === void 0) { confirmed = false; }
@@ -952,7 +1021,7 @@ var Form = /** @class */ (function (_super) {
952
1021
  onChange &&
953
1022
  onChange(store.data, difference(store.data, store.pristine), this.props);
954
1023
  }
955
- store.closeDrawer(true);
1024
+ store.closeDrawer(true, values);
956
1025
  };
957
1026
  Form.prototype.handleDrawerClose = function () {
958
1027
  var store = this.props.store;
@@ -975,7 +1044,7 @@ var Form = /** @class */ (function (_super) {
975
1044
  type: 'button',
976
1045
  actionType: 'dialog',
977
1046
  dialog: dialog
978
- });
1047
+ }, _this.props.resolveDefinitions);
979
1048
  store.openDialog(ctx, undefined, function (confirmed) {
980
1049
  resolve(confirmed);
981
1050
  }, _this.context);
@@ -1116,14 +1185,14 @@ var Form = /** @class */ (function (_super) {
1116
1185
  return render("".concat(region ? "".concat(region, "/") : '').concat(key), subSchema, subProps);
1117
1186
  };
1118
1187
  Form.prototype.renderBody = function () {
1119
- 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;
1188
+ 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;
1120
1189
  var restError = store.restError;
1121
1190
  var WrapperComponent = this.props.wrapperComponent ||
1122
1191
  (/(?:\/|^)form\//.test($path) ? 'div' : 'form');
1123
1192
  var padDom = repeatCount(columnCount && Array.isArray(body)
1124
1193
  ? (columnCount - (body.length % columnCount)) % columnCount
1125
1194
  : 0, function (index) { return (React.createElement("div", { className: cx("Form-item Form-item--".concat(mode, " is-placeholder")), key: index })); });
1126
- return (React.createElement(WrapperComponent, __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 }, buildTestId(testid)),
1195
+ return (React.createElement(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 },
1127
1196
  React.createElement("input", { type: "submit", style: { display: 'none' } }),
1128
1197
  debug
1129
1198
  ? render('form-debug-json', __assign({ type: 'json', value: store.data, ellipsisThreshold: 120, className: cx('Form--debug') }, debugConfig))
@@ -1397,8 +1466,7 @@ var FormRenderer = /** @class */ (function (_super) {
1397
1466
  onChange(store.data, difference(store.data, store.pristine), this.props);
1398
1467
  };
1399
1468
  FormRenderer.prototype.getData = function () {
1400
- var store = this.props.store;
1401
- return store.data;
1469
+ return this.getValues();
1402
1470
  };
1403
1471
  FormRenderer.contextType = ScopedContext;
1404
1472
  FormRenderer = __decorate([