amis-core 6.13.0-beta.2 → 6.13.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/esm/Root.js +1 -1
  2. package/esm/RootRenderer.js +15 -7
  3. package/esm/SchemaRenderer.js +11 -6
  4. package/esm/Scoped.js +1 -1
  5. package/esm/StatusScoped.js +1 -1
  6. package/esm/StyleManager.js +1 -1
  7. package/esm/WithRootStore.js +1 -1
  8. package/esm/WithStore.js +1 -1
  9. package/esm/actions/Action.js +60 -15
  10. package/esm/actions/AjaxAction.js +2 -2
  11. package/esm/actions/BreakAction.js +1 -1
  12. package/esm/actions/BroadcastAction.js +1 -1
  13. package/esm/actions/CmptAction.js +48 -43
  14. package/esm/actions/ContinueAction.js +1 -1
  15. package/esm/actions/CopyAction.js +1 -1
  16. package/esm/actions/CustomAction.js +7 -7
  17. package/esm/actions/DialogAction.js +8 -8
  18. package/esm/actions/DrawerAction.js +8 -8
  19. package/esm/actions/EmailAction.js +1 -1
  20. package/esm/actions/EventAction.js +9 -9
  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.js +1 -1
  26. package/esm/actions/StatusAction.js +1 -1
  27. package/esm/actions/SwitchAction.js +1 -1
  28. package/esm/actions/ToastAction.js +1 -1
  29. package/esm/actions/WaitAction.js +1 -1
  30. package/esm/components/Animations.js +7 -7
  31. package/esm/components/CustomStyle.js +1 -1
  32. package/esm/components/ErrorBoundary.js +1 -1
  33. package/esm/components/LazyComponent.js +1 -1
  34. package/esm/components/Overlay.js +7 -7
  35. package/esm/components/PopOver.js +9 -7
  36. package/esm/env.js +1 -1
  37. package/esm/envOverwrite.js +1 -1
  38. package/esm/factory.js +1 -1
  39. package/esm/globalVar.js +1 -1
  40. package/esm/globalVarClientHandler.js +1 -1
  41. package/esm/globalVarDefaultValueHandler.js +1 -1
  42. package/esm/index.d.ts +2 -2
  43. package/esm/index.js +8 -8
  44. package/esm/locale.js +1 -1
  45. package/esm/polyfills.js +1 -1
  46. package/esm/renderers/Form.d.ts +5 -1
  47. package/esm/renderers/Form.js +72 -24
  48. package/esm/renderers/Item.js +1 -1
  49. package/esm/renderers/Options.js +1 -1
  50. package/esm/renderers/Placeholder.js +1 -1
  51. package/esm/renderers/builtin.js +1 -1
  52. package/esm/renderers/register.js +1 -1
  53. package/esm/renderers/wrapControl.d.ts +0 -1
  54. package/esm/renderers/wrapControl.js +30 -14
  55. package/esm/store/app.d.ts +2 -0
  56. package/esm/store/app.js +8 -8
  57. package/esm/store/combo.d.ts +132 -0
  58. package/esm/store/combo.js +24 -2
  59. package/esm/store/crud.d.ts +3 -0
  60. package/esm/store/crud.js +6 -2
  61. package/esm/store/form.d.ts +52 -0
  62. package/esm/store/form.js +3 -3
  63. package/esm/store/formItem.d.ts +1 -0
  64. package/esm/store/formItem.js +4 -2
  65. package/esm/store/iRenderer.d.ts +2 -0
  66. package/esm/store/iRenderer.js +9 -3
  67. package/esm/store/index.js +1 -1
  68. package/esm/store/list.d.ts +2 -0
  69. package/esm/store/list.js +1 -1
  70. package/esm/store/manager.js +1 -1
  71. package/esm/store/modal.d.ts +4 -0
  72. package/esm/store/modal.js +7 -2
  73. package/esm/store/node.js +1 -1
  74. package/esm/store/pagination.d.ts +2 -0
  75. package/esm/store/pagination.js +1 -1
  76. package/esm/store/root.d.ts +8 -2
  77. package/esm/store/root.js +142 -72
  78. package/esm/store/service.d.ts +2 -0
  79. package/esm/store/service.js +8 -8
  80. package/esm/store/status.js +1 -1
  81. package/esm/store/table.d.ts +146 -92
  82. package/esm/store/table.js +36 -19
  83. package/esm/store/table2.d.ts +2 -0
  84. package/esm/store/table2.js +4 -3
  85. package/esm/theme.js +1 -1
  86. package/esm/utils/Animation.js +1 -1
  87. package/esm/utils/ColorScale.js +1 -1
  88. package/esm/utils/DataSchema.js +1 -1
  89. package/esm/utils/DataScope.js +1 -1
  90. package/esm/utils/RootClose.js +1 -1
  91. package/esm/utils/SimpleMap.js +1 -1
  92. package/esm/utils/animations.js +1 -1
  93. package/esm/utils/api.js +8 -3
  94. package/esm/utils/arraySlice.js +1 -1
  95. package/esm/utils/attachmentAdpator.js +1 -1
  96. package/esm/utils/autobind.js +1 -1
  97. package/esm/utils/browser.js +1 -1
  98. package/esm/utils/columnsSplit.js +1 -1
  99. package/esm/utils/concatData.js +1 -1
  100. package/esm/utils/dataMapping.js +1 -1
  101. package/esm/utils/date.js +6 -9
  102. package/esm/utils/debug.js +1 -1
  103. package/esm/utils/decodeEntity.js +1 -1
  104. package/esm/utils/dom.js +6 -3
  105. package/esm/utils/errors.js +2 -1
  106. package/esm/utils/escapeHtml.js +1 -1
  107. package/esm/utils/filter-schema.js +1 -1
  108. package/esm/utils/filter.js +1 -1
  109. package/esm/utils/formatDuration.js +1 -1
  110. package/esm/utils/formula.js +2 -2
  111. package/esm/utils/getPageId.js +1 -1
  112. package/esm/utils/getVariable.js +1 -1
  113. package/esm/utils/grammar.js +1 -1
  114. package/esm/utils/handleAction.js +1 -1
  115. package/esm/utils/helper.js +3 -3
  116. package/esm/utils/highlight.js +1 -1
  117. package/esm/utils/icon.js +1 -1
  118. package/esm/utils/image.js +1 -1
  119. package/esm/utils/index.d.ts +1 -1
  120. package/esm/utils/index.js +9 -9
  121. package/esm/utils/isPureVariable.js +2 -2
  122. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  123. package/esm/utils/keyToPath.js +1 -1
  124. package/esm/utils/labelToString.js +1 -1
  125. package/esm/utils/loopTooMuch.js +1 -1
  126. package/esm/utils/makeSorter.js +1 -1
  127. package/esm/utils/math.js +1 -1
  128. package/esm/utils/memoryParse.js +1 -1
  129. package/esm/utils/normalizeLink.js +1 -1
  130. package/esm/utils/normalizeOptions.js +6 -2
  131. package/esm/utils/object.js +1 -1
  132. package/esm/utils/offset.js +1 -1
  133. package/esm/utils/offsetParent.js +1 -1
  134. package/esm/utils/optionValueCompare.js +1 -1
  135. package/esm/utils/position.js +1 -1
  136. package/esm/utils/prettyBytes.js +1 -1
  137. package/esm/utils/printElement.js +1 -1
  138. package/esm/utils/renderer-event.js +1 -1
  139. package/esm/utils/replaceText.js +1 -1
  140. package/esm/utils/resize-sensor.d.ts +3 -1
  141. package/esm/utils/resize-sensor.js +63 -29
  142. package/esm/utils/resolveCondition.js +2 -2
  143. package/esm/utils/resolveVariable.js +1 -1
  144. package/esm/utils/resolveVariableAndFilter.js +4 -3
  145. package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
  146. package/esm/utils/scrollPosition.js +1 -1
  147. package/esm/utils/string2regExp.js +1 -1
  148. package/esm/utils/stripNumber.js +1 -1
  149. package/esm/utils/style-helper.d.ts +12 -1
  150. package/esm/utils/style-helper.js +30 -18
  151. package/esm/utils/style.d.ts +13 -0
  152. package/esm/utils/style.js +44 -4
  153. package/esm/utils/toNumber.js +1 -1
  154. package/esm/utils/tokenize.js +1 -1
  155. package/esm/utils/tpl-builtin.d.ts +1 -0
  156. package/esm/utils/tpl-builtin.js +7 -3
  157. package/esm/utils/tpl-lodash.js +1 -1
  158. package/esm/utils/tpl.js +6 -2
  159. package/esm/utils/uncontrollable.js +1 -1
  160. package/esm/utils/validateId.js +1 -1
  161. package/esm/utils/validations.js +2 -2
  162. package/esm/utils/visitedCache.js +1 -1
  163. package/lib/Root.js +1 -1
  164. package/lib/RootRenderer.d.ts +1 -1
  165. package/lib/RootRenderer.js +15 -7
  166. package/lib/SchemaRenderer.js +10 -5
  167. package/lib/Scoped.js +1 -1
  168. package/lib/StatusScoped.js +1 -1
  169. package/lib/StyleManager.js +1 -1
  170. package/lib/WithRootStore.js +1 -1
  171. package/lib/WithStore.js +1 -1
  172. package/lib/actions/Action.js +62 -14
  173. package/lib/actions/AjaxAction.js +2 -2
  174. package/lib/actions/BreakAction.js +1 -1
  175. package/lib/actions/BroadcastAction.js +1 -1
  176. package/lib/actions/CmptAction.js +48 -43
  177. package/lib/actions/ContinueAction.js +1 -1
  178. package/lib/actions/CopyAction.js +1 -1
  179. package/lib/actions/CustomAction.js +7 -7
  180. package/lib/actions/DialogAction.js +8 -8
  181. package/lib/actions/DrawerAction.js +8 -8
  182. package/lib/actions/EmailAction.js +1 -1
  183. package/lib/actions/EventAction.js +9 -9
  184. package/lib/actions/LinkAction.js +1 -1
  185. package/lib/actions/LoopAction.js +1 -1
  186. package/lib/actions/PageAction.js +1 -1
  187. package/lib/actions/ParallelAction.js +1 -1
  188. package/lib/actions/PrintAction.js +1 -1
  189. package/lib/actions/StatusAction.js +1 -1
  190. package/lib/actions/SwitchAction.js +1 -1
  191. package/lib/actions/ToastAction.js +1 -1
  192. package/lib/actions/WaitAction.js +1 -1
  193. package/lib/components/Animations.js +7 -7
  194. package/lib/components/CustomStyle.js +1 -1
  195. package/lib/components/ErrorBoundary.js +1 -1
  196. package/lib/components/LazyComponent.js +1 -1
  197. package/lib/components/Overlay.js +7 -7
  198. package/lib/components/PopOver.js +9 -7
  199. package/lib/env.js +1 -1
  200. package/lib/envOverwrite.js +1 -1
  201. package/lib/factory.js +1 -1
  202. package/lib/globalVar.js +1 -1
  203. package/lib/globalVarClientHandler.js +1 -1
  204. package/lib/globalVarDefaultValueHandler.js +1 -1
  205. package/lib/index.d.ts +2 -2
  206. package/lib/index.js +12 -6
  207. package/lib/locale.js +1 -1
  208. package/lib/polyfills.js +1 -1
  209. package/lib/renderers/Form.d.ts +5 -1
  210. package/lib/renderers/Form.js +71 -23
  211. package/lib/renderers/Item.js +1 -1
  212. package/lib/renderers/Options.js +1 -1
  213. package/lib/renderers/Placeholder.js +1 -1
  214. package/lib/renderers/builtin.js +1 -1
  215. package/lib/renderers/register.js +1 -1
  216. package/lib/renderers/wrapControl.d.ts +0 -1
  217. package/lib/renderers/wrapControl.js +30 -14
  218. package/lib/store/app.d.ts +2 -0
  219. package/lib/store/app.js +8 -8
  220. package/lib/store/combo.d.ts +156 -25
  221. package/lib/store/combo.js +24 -2
  222. package/lib/store/crud.d.ts +3 -0
  223. package/lib/store/crud.js +6 -2
  224. package/lib/store/form.d.ts +62 -11
  225. package/lib/store/form.js +3 -3
  226. package/lib/store/formItem.d.ts +1 -0
  227. package/lib/store/formItem.js +4 -2
  228. package/lib/store/iRenderer.d.ts +2 -0
  229. package/lib/store/iRenderer.js +9 -3
  230. package/lib/store/index.js +1 -1
  231. package/lib/store/list.d.ts +2 -0
  232. package/lib/store/list.js +1 -1
  233. package/lib/store/manager.js +1 -1
  234. package/lib/store/modal.d.ts +4 -0
  235. package/lib/store/modal.js +7 -2
  236. package/lib/store/node.js +1 -1
  237. package/lib/store/pagination.d.ts +2 -0
  238. package/lib/store/pagination.js +1 -1
  239. package/lib/store/root.d.ts +8 -3
  240. package/lib/store/root.js +140 -70
  241. package/lib/store/service.d.ts +2 -0
  242. package/lib/store/service.js +8 -8
  243. package/lib/store/status.js +1 -1
  244. package/lib/store/table.d.ts +166 -113
  245. package/lib/store/table.js +36 -19
  246. package/lib/store/table2.d.ts +2 -0
  247. package/lib/store/table2.js +4 -3
  248. package/lib/theme.js +1 -1
  249. package/lib/utils/Animation.js +1 -1
  250. package/lib/utils/ColorScale.js +1 -1
  251. package/lib/utils/DataSchema.js +1 -1
  252. package/lib/utils/DataScope.js +1 -1
  253. package/lib/utils/RootClose.js +1 -1
  254. package/lib/utils/SimpleMap.js +1 -1
  255. package/lib/utils/animations.js +1 -1
  256. package/lib/utils/api.js +8 -3
  257. package/lib/utils/arraySlice.js +1 -1
  258. package/lib/utils/attachmentAdpator.js +1 -1
  259. package/lib/utils/autobind.js +1 -1
  260. package/lib/utils/browser.js +1 -1
  261. package/lib/utils/columnsSplit.js +1 -1
  262. package/lib/utils/concatData.js +1 -1
  263. package/lib/utils/dataMapping.js +1 -1
  264. package/lib/utils/date.js +6 -9
  265. package/lib/utils/debug.js +1 -1
  266. package/lib/utils/decodeEntity.js +1 -1
  267. package/lib/utils/dom.js +6 -3
  268. package/lib/utils/errors.js +2 -1
  269. package/lib/utils/escapeHtml.js +1 -1
  270. package/lib/utils/filter-schema.js +1 -1
  271. package/lib/utils/filter.js +1 -1
  272. package/lib/utils/formatDuration.js +1 -1
  273. package/lib/utils/formula.js +2 -2
  274. package/lib/utils/getPageId.js +1 -1
  275. package/lib/utils/getVariable.js +1 -1
  276. package/lib/utils/grammar.js +1 -1
  277. package/lib/utils/handleAction.js +1 -1
  278. package/lib/utils/helper.js +3 -3
  279. package/lib/utils/highlight.js +1 -1
  280. package/lib/utils/icon.js +1 -1
  281. package/lib/utils/image.js +1 -1
  282. package/lib/utils/index.d.ts +1 -1
  283. package/lib/utils/index.js +22 -20
  284. package/lib/utils/isPureVariable.js +2 -2
  285. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  286. package/lib/utils/keyToPath.js +1 -1
  287. package/lib/utils/labelToString.js +1 -1
  288. package/lib/utils/loopTooMuch.js +1 -1
  289. package/lib/utils/makeSorter.js +1 -1
  290. package/lib/utils/math.js +1 -1
  291. package/lib/utils/memoryParse.js +1 -1
  292. package/lib/utils/normalizeLink.js +1 -1
  293. package/lib/utils/normalizeOptions.js +6 -2
  294. package/lib/utils/object.js +1 -1
  295. package/lib/utils/offset.js +1 -1
  296. package/lib/utils/offsetParent.js +1 -1
  297. package/lib/utils/optionValueCompare.js +1 -1
  298. package/lib/utils/position.js +1 -1
  299. package/lib/utils/prettyBytes.js +1 -1
  300. package/lib/utils/printElement.js +1 -1
  301. package/lib/utils/renderer-event.js +1 -1
  302. package/lib/utils/replaceText.js +1 -1
  303. package/lib/utils/resize-sensor.d.ts +3 -1
  304. package/lib/utils/resize-sensor.js +64 -28
  305. package/lib/utils/resolveCondition.js +2 -2
  306. package/lib/utils/resolveVariable.js +1 -1
  307. package/lib/utils/resolveVariableAndFilter.js +3 -2
  308. package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
  309. package/lib/utils/scrollPosition.js +1 -1
  310. package/lib/utils/string2regExp.js +1 -1
  311. package/lib/utils/stripNumber.js +1 -1
  312. package/lib/utils/style-helper.d.ts +12 -1
  313. package/lib/utils/style-helper.js +30 -17
  314. package/lib/utils/style.d.ts +13 -0
  315. package/lib/utils/style.js +45 -3
  316. package/lib/utils/toNumber.js +1 -1
  317. package/lib/utils/tokenize.js +1 -1
  318. package/lib/utils/tpl-builtin.d.ts +1 -0
  319. package/lib/utils/tpl-builtin.js +7 -2
  320. package/lib/utils/tpl-lodash.js +1 -1
  321. package/lib/utils/tpl.js +6 -2
  322. package/lib/utils/uncontrollable.js +1 -1
  323. package/lib/utils/validateId.js +1 -1
  324. package/lib/utils/validations.js +2 -2
  325. package/lib/utils/visitedCache.js +1 -1
  326. package/package.json +5 -3
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.13.0-beta.2
2
+ * amis-core v6.13.0-beta.21
3
3
  * Copyright 2018-2025 fex
4
4
  */
5
5
 
@@ -23,7 +23,7 @@ import { reaction } from 'mobx';
23
23
  import groupBy from 'lodash/groupBy';
24
24
  import isEqual from 'lodash/isEqual';
25
25
  import CustomStyle from '../components/CustomStyle.js';
26
- import { isObject, createObject, cloneObject, injectObjectChain } from '../utils/object.js';
26
+ import { isObject, injectObjectChain, createObject, cloneObject } from '../utils/object.js';
27
27
  import { setThemeClassName } from '../utils/style-helper.js';
28
28
  import { dataMapping } from '../utils/dataMapping.js';
29
29
 
@@ -38,6 +38,12 @@ var Form = /** @class */ (function (_super) {
38
38
  trailing: true,
39
39
  leading: false
40
40
  });
41
+ // 当有多次调用时,只需要跳一个
42
+ _this.lazyJumpToErrorComponent = debounce(_this.jumpToErrorComponent.bind(_this), 250, {
43
+ trailing: false,
44
+ leading: true
45
+ });
46
+ _this.formRef = React.createRef();
41
47
  // 如果开启了 lazyChange,需要一个 flush 方法把队列中值应用上。
42
48
  _this.flushing = false;
43
49
  _this.emittedData = null;
@@ -64,7 +70,7 @@ var Form = /** @class */ (function (_super) {
64
70
  _this.dispatchInited = _this.dispatchInited.bind(_this);
65
71
  _this.blockRouting = _this.blockRouting.bind(_this);
66
72
  _this.beforePageUnload = _this.beforePageUnload.bind(_this);
67
- _this.formItemDispatchEvent = _this.formItemDispatchEvent.bind(_this);
73
+ _this.dispatchEvent = _this.dispatchEvent.bind(_this);
68
74
  _this.flush = _this.flush.bind(_this);
69
75
  var store = props.store, canAccessSuperData = props.canAccessSuperData, persistData = props.persistData, simpleMode = props.simpleMode, formLazyChange = props.formLazyChange;
70
76
  store.setCanAccessSuperData(canAccessSuperData !== false);
@@ -162,6 +168,11 @@ var Form = /** @class */ (function (_super) {
162
168
  }
163
169
  })
164
170
  .then(this.initInterval)
171
+ .then(function () {
172
+ return _this.props.dispatchEvent('initApiFinished', injectObjectChain(store.data, {
173
+ __trigger: 'init'
174
+ }));
175
+ })
165
176
  .then(this.onInit);
166
177
  }
167
178
  else {
@@ -191,6 +202,7 @@ var Form = /** @class */ (function (_super) {
191
202
  clearTimeout(this.timer);
192
203
  // this.lazyHandleChange.flush();
193
204
  this.lazyEmitChange.cancel();
205
+ this.lazyJumpToErrorComponent.cancel();
194
206
  this.asyncCancel && this.asyncCancel();
195
207
  this.toDispose.forEach(function (fn) { return fn(); });
196
208
  this.toDispose = [];
@@ -245,6 +257,7 @@ var Form = /** @class */ (function (_super) {
245
257
  Form.prototype.onInit = function () {
246
258
  return __awaiter(this, void 0, void 0, function () {
247
259
  var _a, onInit, store, persistData, submitOnInit, dispatchEvent, data, initedAt, hooks, groupedHooks, dispatch;
260
+ var _this = this;
248
261
  return __generator(this, function (_b) {
249
262
  switch (_b.label) {
250
263
  case 0:
@@ -255,6 +268,13 @@ var Form = /** @class */ (function (_super) {
255
268
  data = cloneObject(store.data);
256
269
  initedAt = store.initedAt;
257
270
  store.setInited(true);
271
+ // 等待 formInited 属性下发成功
272
+ // 因为 hooks 里面可以能有读取 props 的操作
273
+ return [4 /*yield*/, new Promise(function (resolve) { return _this.forceUpdate(resolve); })];
274
+ case 1:
275
+ // 等待 formInited 属性下发成功
276
+ // 因为 hooks 里面可以能有读取 props 的操作
277
+ _b.sent();
258
278
  hooks = this.hooks['init'] || [];
259
279
  groupedHooks = groupBy(hooks, function (item) {
260
280
  return item.__enforce === 'prev'
@@ -264,15 +284,15 @@ var Form = /** @class */ (function (_super) {
264
284
  : 'normal';
265
285
  });
266
286
  return [4 /*yield*/, Promise.all((groupedHooks.prev || []).map(function (hook) { return hook(data); }))];
267
- case 1:
287
+ case 2:
268
288
  _b.sent();
269
289
  // 有可能在前面的步骤中删除了钩子,所以需要重新验证一下
270
290
  return [4 /*yield*/, Promise.all((groupedHooks.normal || []).map(function (hook) { return hooks.includes(hook) && hook(data); }))];
271
- case 2:
291
+ case 3:
272
292
  // 有可能在前面的步骤中删除了钩子,所以需要重新验证一下
273
293
  _b.sent();
274
294
  return [4 /*yield*/, Promise.all((groupedHooks.post || []).map(function (hook) { return hooks.includes(hook) && hook(data); }))];
275
- case 3:
295
+ case 4:
276
296
  _b.sent();
277
297
  if (!isAlive(store)) {
278
298
  return [2 /*return*/];
@@ -290,7 +310,7 @@ var Form = /** @class */ (function (_super) {
290
310
  }
291
311
  onInit && onInit(data, this.props);
292
312
  return [4 /*yield*/, this.dispatchInited({ data: data })];
293
- case 4:
313
+ case 5:
294
314
  dispatch = _b.sent();
295
315
  if (dispatch === null || dispatch === void 0 ? void 0 : dispatch.prevented) {
296
316
  return [2 /*return*/];
@@ -322,7 +342,7 @@ var Form = /** @class */ (function (_super) {
322
342
  _c[initFinishedField || 'finished'] = false,
323
343
  _c));
324
344
  result = undefined;
325
- if (!isEffectiveApi(initApi, store.data)) return [3 /*break*/, 2];
345
+ if (!isEffectiveApi(initApi, store.data)) return [3 /*break*/, 4];
326
346
  return [4 /*yield*/, store.fetchInitData(initApi, store.data, {
327
347
  successMessage: fetchSuccess,
328
348
  errorMessage: fetchFailed,
@@ -338,15 +358,20 @@ var Form = /** @class */ (function (_super) {
338
358
  })];
339
359
  case 1:
340
360
  result = _d.sent();
341
- if (result === null || result === void 0 ? void 0 : result.ok) {
342
- this.initInterval(result);
343
- store.reset(undefined, false);
344
- }
345
- return [3 /*break*/, 3];
346
- case 2:
361
+ if (!(result === null || result === void 0 ? void 0 : result.ok)) return [3 /*break*/, 3];
362
+ this.initInterval(result);
347
363
  store.reset(undefined, false);
364
+ return [4 /*yield*/, this.props.dispatchEvent('initApiFinished', injectObjectChain(store.data, {
365
+ __trigger: 'reload'
366
+ }))];
367
+ case 2:
368
+ _d.sent();
348
369
  _d.label = 3;
349
- case 3:
370
+ case 3: return [3 /*break*/, 5];
371
+ case 4:
372
+ store.reset(undefined, false);
373
+ _d.label = 5;
374
+ case 5:
350
375
  // 派发初始化接口请求完成事件
351
376
  this.dispatchInited(result);
352
377
  return [2 /*return*/, store.data];
@@ -548,9 +573,34 @@ var Form = /** @class */ (function (_super) {
548
573
  store.setLocalPersistData(persistDataKeys);
549
574
  }
550
575
  };
551
- Form.prototype.formItemDispatchEvent = function (type, data) {
552
- var dispatchEvent = this.props.dispatchEvent;
553
- return dispatchEvent(type, data);
576
+ Form.prototype.jumpToErrorComponent = function (renderer) {
577
+ var _a, _b;
578
+ // 当表单校验错误是,优先调用组件的 focus
579
+ // 如果没有 focus 方法,则滚动到错误信息的位置
580
+ if (typeof (renderer === null || renderer === void 0 ? void 0 : renderer.focus) === 'function') {
581
+ renderer.focus();
582
+ }
583
+ else {
584
+ (_b = (_a = this.formRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(".".concat(this.props.classPrefix, "Form-feedback"))) === null || _b === void 0 ? void 0 : _b.scrollIntoView({
585
+ behavior: 'smooth',
586
+ block: 'center'
587
+ });
588
+ }
589
+ };
590
+ Form.prototype.dispatchEvent = function (e, data, renderer, // for didmount
591
+ scoped) {
592
+ // 把这两个事件转到 form 组件上,让 form 组件来处理
593
+ if ((e === 'formItemValidateSucc' || e === 'formItemValidateError') &&
594
+ (renderer === null || renderer === void 0 ? void 0 : renderer.props.type) !== 'form') {
595
+ if (e === 'formItemValidateError') {
596
+ this.lazyJumpToErrorComponent(renderer);
597
+ }
598
+ // 如果事件是 formItemValidateSucc 或者 formItemValidateError 转成当前组件触发的,
599
+ // 所以 onEvent 是配置在 form 层的而不是表单项层
600
+ renderer = undefined;
601
+ scoped = undefined;
602
+ }
603
+ return this.props.dispatchEvent(e, data, renderer, scoped);
554
604
  };
555
605
  Form.prototype.emitChange = function (submit, emitedFromWatch) {
556
606
  if (emitedFromWatch === void 0) { emitedFromWatch = false; }
@@ -1227,7 +1277,7 @@ var Form = /** @class */ (function (_super) {
1227
1277
  addHook: this.addHook,
1228
1278
  removeHook: this.removeHook,
1229
1279
  renderFormItems: this.renderFormItems,
1230
- formItemDispatchEvent: this.formItemDispatchEvent,
1280
+ dispatchEvent: this.dispatchEvent,
1231
1281
  formPristine: form.pristine,
1232
1282
  onFlushForm: this.flush
1233
1283
  // value: (control as any)?.name
@@ -1250,7 +1300,7 @@ var Form = /** @class */ (function (_super) {
1250
1300
  var padDom = repeatCount(columnCount && Array.isArray(body)
1251
1301
  ? (columnCount - (body.length % columnCount)) % columnCount
1252
1302
  : 0, function (index) { return (React.createElement("div", { className: cx("Form-item Form-item--".concat(mode, " is-placeholder")), key: index })); });
1253
- 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, setThemeClassName(__assign(__assign({}, this.props), { name: [
1303
+ return (React.createElement(WrapperComponent, { ref: this.formRef, className: cx("Form", "Form--".concat(mode || 'normal'), columnCount ? "Form--column Form--column-".concat(columnCount) : null, staticClassName && isStatic ? staticClassName : className, isStatic ? 'Form--isStatic' : null, setThemeClassName(__assign(__assign({}, this.props), { name: [
1254
1304
  'formControlClassName',
1255
1305
  'itemClassName',
1256
1306
  'staticClassName',
@@ -1271,16 +1321,14 @@ var Form = /** @class */ (function (_super) {
1271
1321
  }),
1272
1322
  padDom,
1273
1323
  restError && restError.length ? (React.createElement("ul", { className: cx('Form-restError', 'Form-feedback') }, restError.map(function (item, idx) { return (React.createElement("li", { key: idx }, item)); }))) : null,
1274
- render('modal', __assign(__assign({}, (store.action &&
1275
- store.action.dialog)), { type: 'dialog' }), {
1324
+ render('modal', __assign(__assign({}, store.dialogSchema), { type: 'dialog' }), {
1276
1325
  key: 'dialog',
1277
1326
  data: store.dialogData,
1278
1327
  onConfirm: this.handleDialogConfirm,
1279
1328
  onClose: this.handleDialogClose,
1280
1329
  show: store.dialogOpen
1281
1330
  }),
1282
- render('modal', __assign(__assign({}, (store.action &&
1283
- store.action.drawer)), { type: 'drawer' }), {
1331
+ render('modal', __assign(__assign({}, store.drawerSchema), { type: 'drawer' }), {
1284
1332
  key: 'drawer',
1285
1333
  data: store.drawerData,
1286
1334
  onConfirm: this.handleDrawerConfirm,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.13.0-beta.2
2
+ * amis-core v6.13.0-beta.21
3
3
  * Copyright 2018-2025 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.13.0-beta.2
2
+ * amis-core v6.13.0-beta.21
3
3
  * Copyright 2018-2025 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.13.0-beta.2
2
+ * amis-core v6.13.0-beta.21
3
3
  * Copyright 2018-2025 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.13.0-beta.2
2
+ * amis-core v6.13.0-beta.21
3
3
  * Copyright 2018-2025 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.13.0-beta.2
2
+ * amis-core v6.13.0-beta.21
3
3
  * Copyright 2018-2025 fex
4
4
  */
5
5
 
@@ -42,7 +42,6 @@ export interface ControlOutterProps extends RendererProps {
42
42
  };
43
43
  store?: IIRendererStore;
44
44
  onChange?: (value: any, name: string, submit?: boolean, changePristine?: boolean, changeReason?: DataChangeReason) => void;
45
- formItemDispatchEvent: (type: string, data: any) => void;
46
45
  formItemRef?: (control: any) => void;
47
46
  }
48
47
  export interface ControlProps {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.13.0-beta.2
2
+ * amis-core v6.13.0-beta.21
3
3
  * Copyright 2018-2025 fex
4
4
  */
5
5
 
@@ -19,8 +19,10 @@ import hoistNonReactStatic from 'hoist-non-react-statics';
19
19
  import { withRootStore } from '../WithRootStore.js';
20
20
  import { TableStore } from '../store/table.js';
21
21
  import pick from 'lodash/pick';
22
+ import { reaction } from 'mobx';
22
23
  import '../utils/index.js';
23
24
  import { tokenize } from '../utils/tokenize.js';
25
+ import { injectObjectChain } from '../utils/object.js';
24
26
  import { getVariable } from '../utils/getVariable.js';
25
27
  import { callStrFunction } from '../utils/api.js';
26
28
 
@@ -57,6 +59,7 @@ function wrapControl(config, ComposedComponent) {
57
59
  if (!name) {
58
60
  return _this;
59
61
  }
62
+ var valueIsExp = isExpression(value);
60
63
  var propValue = _this.props.value;
61
64
  var model = rootStore.addStore({
62
65
  id: guid(),
@@ -73,8 +76,7 @@ function wrapControl(config, ComposedComponent) {
73
76
  ? __assign(__assign({}, validations), str2rules(config.validations)) : validations;
74
77
  // @issue 打算干掉这个
75
78
  formItem === null || formItem === void 0 ? void 0 : formItem.addSubFormItem(model);
76
- model.config(__assign(__assign({}, pick(__assign(__assign({}, ComposedComponent.defaultProps), _this.props.$schema), ['multiple'])), { id: id, type: type, required: props.required || required, unique: unique, value: value, isValueSchemaExp: isExpression(value) &&
77
- value.replace(/\s/g, '') !== "${".concat(name, "}"), rules: rules, messages: validationErrors, delimiter: delimiter, valueField: valueField, labelField: labelField, joinValues: joinValues, extractValue: extractValue, selectFirst: selectFirst, autoFill: autoFill, clearValueOnHidden: clearValueOnHidden, validateApi: validateApi, minLength: minLength, maxLength: maxLength, validateOnChange: validateOnChange, label: label, inputGroupControl: inputGroupControl, extraName: extraName, pagination: pagination }));
79
+ model.config(__assign(__assign({}, pick(__assign(__assign({}, ComposedComponent.defaultProps), _this.props.$schema), ['multiple'])), { id: id, type: type, required: props.required || required, unique: unique, value: value, isValueSchemaExp: valueIsExp && value.replace(/\s/g, '') !== "${".concat(name, "}"), rules: rules, messages: validationErrors, delimiter: delimiter, valueField: valueField, labelField: labelField, joinValues: joinValues, extractValue: extractValue, selectFirst: selectFirst, autoFill: autoFill, clearValueOnHidden: clearValueOnHidden, validateApi: validateApi, minLength: minLength, maxLength: maxLength, validateOnChange: validateOnChange, label: label, inputGroupControl: inputGroupControl, extraName: extraName, pagination: pagination }));
78
80
  // issue 这个逻辑应该在 combo 里面自己实现。
79
81
  if (_this.model.unique &&
80
82
  ((_b = form === null || form === void 0 ? void 0 : form.parentStore) === null || _b === void 0 ? void 0 : _b.storeType) === ComboStore.name) {
@@ -91,7 +93,13 @@ function wrapControl(config, ComposedComponent) {
91
93
  }
92
94
  if (onChange &&
93
95
  value !== undefined &&
94
- model.tmpValue !== undefined) {
96
+ model.tmpValue !== undefined &&
97
+ // 要么是默认值起作用了
98
+ // 要么是表达式起作用了
99
+ // 只有这两种情况才会触发 onChange
100
+ // 比如以下 case 就不应该触发
101
+ // 关联到上下文数据了,同时设置了默认值,因为是上下文数据优先,这个时候就不应该触发 onChange,因为没变化
102
+ (value === model.tmpValue || valueIsExp)) {
95
103
  // 组件默认值支持表达式需要: 避免初始化时上下文中丢失组件默认值
96
104
  if (model.extraName) {
97
105
  var values = model.splitExtraValue(model.tmpValue);
@@ -119,6 +127,17 @@ function wrapControl(config, ComposedComponent) {
119
127
  onChange(model.tmpValue, model.name, false, true);
120
128
  }
121
129
  }
130
+ _this.reaction = reaction(function () { return model.validatedAt; }, function (validatedAt) {
131
+ var _a, _b, _c, _d;
132
+ (_b = (_a = _this.props).dispatchEvent) === null || _b === void 0 ? void 0 : _b.call(_a, model.valid
133
+ ? 'formItemValidateSucc'
134
+ : 'formItemValidateError', injectObjectChain((_d = (_c = _this.props.formStore) === null || _c === void 0 ? void 0 : _c.data) !== null && _d !== void 0 ? _d : _this.props.data, {
135
+ __errors: model.errors,
136
+ __formName: model.name,
137
+ __formValue: model.tmpValue,
138
+ __formControl: _this.control
139
+ }));
140
+ });
122
141
  return _this;
123
142
  }
124
143
  class_1.prototype.componentDidMount = function () {
@@ -373,15 +392,14 @@ function wrapControl(config, ComposedComponent) {
373
392
  }
374
393
  };
375
394
  class_1.prototype.validate = function () {
376
- var _a, _b;
377
395
  return __awaiter(this, void 0, void 0, function () {
378
- var _c, form, data, formItemDispatchEvent, result, combo, group, validPromises, valid;
379
- return __generator(this, function (_d) {
380
- switch (_d.label) {
396
+ var _a, form, data, dispatchEvent, result, combo, group, validPromises, valid;
397
+ return __generator(this, function (_b) {
398
+ switch (_b.label) {
381
399
  case 0:
382
400
  if (!this.model)
383
401
  return [2 /*return*/];
384
- _c = this.props, form = _c.formStore, data = _c.data, formItemDispatchEvent = _c.formItemDispatchEvent;
402
+ _a = this.props, form = _a.formStore, data = _a.data, dispatchEvent = _a.dispatchEvent;
385
403
  if (!(this.model.unique &&
386
404
  (form === null || form === void 0 ? void 0 : form.parentStore) &&
387
405
  form.parentStore.storeType === ComboStore.name)) return [3 /*break*/, 2];
@@ -392,16 +410,14 @@ function wrapControl(config, ComposedComponent) {
392
410
  });
393
411
  return [4 /*yield*/, Promise.all(validPromises)];
394
412
  case 1:
395
- result = _d.sent();
413
+ result = _b.sent();
396
414
  return [3 /*break*/, 4];
397
415
  case 2: return [4 /*yield*/, this.model.validate(data)];
398
416
  case 3:
399
- result = [_d.sent()];
400
- _d.label = 4;
417
+ result = [_b.sent()];
418
+ _b.label = 4;
401
419
  case 4:
402
420
  valid = !result.some(function (item) { return item === false; });
403
- (_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里的一定是最新的数据
404
- );
405
421
  return [2 /*return*/, valid];
406
422
  }
407
423
  });
@@ -17,8 +17,10 @@ export declare const AppStore: import("mobx-state-tree").IModelType<{
17
17
  pristineRaw: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
18
18
  upStreamData: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
19
19
  action: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
20
+ dialogSchema: import("mobx-state-tree").IType<any, any, any>;
20
21
  dialogOpen: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
21
22
  dialogData: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
23
+ drawerSchema: import("mobx-state-tree").IType<any, any, any>;
22
24
  drawerOpen: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
23
25
  drawerData: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
24
26
  } & {
package/esm/store/app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v6.13.0-beta.2
2
+ * amis-core v6.13.0-beta.21
3
3
  * Copyright 2018-2025 fex
4
4
  */
5
5
 
@@ -7,28 +7,28 @@ import { __assign } from 'tslib';
7
7
  import { types } from 'mobx-state-tree';
8
8
  import { mapTree, findTree, isVisible, guid, replaceUrlParams } from '../utils/helper.js';
9
9
  import { ServiceStore } from './service.js';
10
+ import 'amis-formula';
11
+ import 'moment';
12
+ import { createObject } from '../utils/object.js';
13
+ import '../utils/memoryParse.js';
14
+ import '@rc-component/mini-decimal';
15
+ import 'lodash/isPlainObject';
16
+ import '../utils/filter.js';
10
17
  import '../utils/api.js';
11
18
  import 'file-saver';
12
19
  import '../utils/browser.js';
13
20
  import '../utils/ColorScale.js';
14
21
  import 'react';
15
22
  import 'lodash/chunk';
16
- import { createObject } from '../utils/object.js';
17
- import '../utils/memoryParse.js';
18
- import 'amis-formula';
19
- import 'lodash/isPlainObject';
20
23
  import '../utils/DataSchema.js';
21
24
  import '../utils/DataScope.js';
22
- import 'moment';
23
25
  import '../utils/debug.js';
24
26
  import 'react-dom';
25
27
  import '../utils/errors.js';
26
28
  import { filter } from '../utils/tpl.js';
27
- import '../utils/filter.js';
28
29
  import 'lodash/isObject';
29
30
  import 'lodash/isString';
30
31
  import 'lodash/isBoolean';
31
- import '@rc-component/mini-decimal';
32
32
  import '../utils/image.js';
33
33
  import 'lodash/isEqual';
34
34
  import '../actions/Action.js';