amis-core 2.9.0 → 3.1.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 (331) hide show
  1. package/esm/Root.d.ts +89 -4
  2. package/esm/Root.js +15 -4
  3. package/esm/RootRenderer.d.ts +3 -1
  4. package/esm/RootRenderer.js +9 -3
  5. package/esm/SchemaRenderer.d.ts +4 -2
  6. package/esm/SchemaRenderer.js +32 -24
  7. package/esm/Scoped.d.ts +8 -0
  8. package/esm/Scoped.js +20 -5
  9. package/esm/StatusScoped.d.ts +58 -0
  10. package/esm/StatusScoped.js +54 -0
  11. package/esm/WithRootStore.d.ts +2 -2
  12. package/esm/WithRootStore.js +1 -1
  13. package/esm/WithStore.js +6 -2
  14. package/esm/actions/Action.d.ts +1 -0
  15. package/esm/actions/Action.js +19 -5
  16. package/esm/actions/AjaxAction.js +1 -1
  17. package/esm/actions/BreakAction.js +1 -1
  18. package/esm/actions/BroadcastAction.js +1 -1
  19. package/esm/actions/CmptAction.js +8 -7
  20. package/esm/actions/ContinueAction.js +1 -1
  21. package/esm/actions/CopyAction.js +1 -1
  22. package/esm/actions/CustomAction.js +4 -4
  23. package/esm/actions/DialogAction.d.ts +16 -2
  24. package/esm/actions/DialogAction.js +23 -7
  25. package/esm/actions/DrawerAction.js +1 -1
  26. package/esm/actions/EmailAction.js +1 -1
  27. package/esm/actions/LinkAction.js +1 -1
  28. package/esm/actions/LoopAction.js +1 -1
  29. package/esm/actions/PageAction.js +1 -1
  30. package/esm/actions/ParallelAction.js +1 -1
  31. package/esm/actions/SwitchAction.js +1 -1
  32. package/esm/actions/ToastAction.js +1 -1
  33. package/esm/components/CustomStyle.d.ts +13 -0
  34. package/esm/components/CustomStyle.js +18 -0
  35. package/esm/components/LazyComponent.d.ts +1 -1
  36. package/esm/components/LazyComponent.js +1 -1
  37. package/esm/components/Overlay.d.ts +3 -3
  38. package/esm/components/Overlay.js +1 -1
  39. package/esm/components/PopOver.d.ts +2 -2
  40. package/esm/components/PopOver.js +1 -1
  41. package/esm/env.d.ts +10 -2
  42. package/esm/env.js +1 -1
  43. package/esm/envOverwrite.js +1 -5
  44. package/esm/factory.d.ts +5 -3
  45. package/esm/factory.js +3 -3
  46. package/esm/index.d.ts +11 -4
  47. package/esm/index.js +55 -33
  48. package/esm/locale.d.ts +2 -2
  49. package/esm/locale.js +10 -3
  50. package/esm/renderers/Form.d.ts +3 -2
  51. package/esm/renderers/Form.js +216 -180
  52. package/esm/renderers/Item.d.ts +55 -41
  53. package/esm/renderers/Item.js +30 -19
  54. package/esm/renderers/Options.js +11 -4
  55. package/esm/renderers/Placeholder.js +1 -1
  56. package/esm/renderers/builtin.js +1 -1
  57. package/esm/renderers/register.js +1 -1
  58. package/esm/renderers/wrapControl.d.ts +2 -2
  59. package/esm/renderers/wrapControl.js +13 -16
  60. package/esm/store/app.d.ts +1 -0
  61. package/esm/store/app.js +1 -1
  62. package/esm/store/combo.d.ts +3 -0
  63. package/esm/store/combo.js +1 -1
  64. package/esm/store/crud.d.ts +2 -0
  65. package/esm/store/crud.js +31 -9
  66. package/esm/store/form.d.ts +1 -0
  67. package/esm/store/form.js +10 -4
  68. package/esm/store/formItem.js +2 -2
  69. package/esm/store/iRenderer.d.ts +1 -0
  70. package/esm/store/iRenderer.js +54 -13
  71. package/esm/store/index.js +1 -1
  72. package/esm/store/list.d.ts +1 -0
  73. package/esm/store/list.js +7 -3
  74. package/esm/store/manager.js +1 -1
  75. package/esm/store/modal.d.ts +1 -0
  76. package/esm/store/modal.js +1 -1
  77. package/esm/store/node.js +1 -1
  78. package/esm/store/pagination.d.ts +1 -0
  79. package/esm/store/pagination.js +2 -2
  80. package/esm/store/root.d.ts +4 -6
  81. package/esm/store/root.js +53 -24
  82. package/esm/store/service.d.ts +1 -0
  83. package/esm/store/service.js +1 -1
  84. package/esm/store/status.d.ts +12 -0
  85. package/esm/store/status.js +38 -0
  86. package/esm/store/table.d.ts +28 -23
  87. package/esm/store/table.js +26 -5
  88. package/esm/store/table2.d.ts +7 -6
  89. package/esm/store/table2.js +27 -23
  90. package/esm/theme.d.ts +1 -1
  91. package/esm/theme.js +1 -1
  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.d.ts +3 -5
  97. package/esm/utils/DataScope.js +88 -31
  98. package/esm/utils/RootClose.js +1 -1
  99. package/esm/utils/SimpleMap.js +1 -1
  100. package/esm/utils/api.js +14 -5
  101. package/esm/utils/attachmentAdpator.js +2 -2
  102. package/esm/utils/autobind.js +1 -1
  103. package/esm/utils/columnsSplit.js +1 -1
  104. package/esm/utils/dataMapping.js +1 -1
  105. package/esm/utils/date.d.ts +7 -0
  106. package/esm/utils/date.js +34 -2
  107. package/esm/utils/debug.js +4 -4
  108. package/esm/utils/decodeEntity.js +1 -1
  109. package/esm/utils/dom.d.ts +3 -0
  110. package/esm/utils/dom.js +47 -10
  111. package/esm/utils/errors.js +1 -1
  112. package/esm/utils/escapeHtml.js +1 -1
  113. package/esm/utils/filter-schema.js +1 -1
  114. package/esm/utils/filter.js +1 -1
  115. package/esm/utils/formatDuration.js +1 -1
  116. package/esm/utils/formula.js +2 -2
  117. package/esm/utils/getVariable.js +1 -1
  118. package/esm/utils/grammar.js +3 -3
  119. package/esm/utils/handleAction.js +1 -1
  120. package/esm/utils/helper.d.ts +9 -2
  121. package/esm/utils/helper.js +52 -20
  122. package/esm/utils/highlight.js +1 -1
  123. package/esm/utils/icon.d.ts +6 -1
  124. package/esm/utils/icon.js +6 -1
  125. package/esm/utils/image.js +1 -1
  126. package/esm/utils/isPureVariable.js +3 -3
  127. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  128. package/esm/utils/keyToPath.js +1 -1
  129. package/esm/utils/makeSorter.js +1 -1
  130. package/esm/utils/memoryParse.d.ts +17 -0
  131. package/esm/utils/memoryParse.js +26 -0
  132. package/esm/utils/normalizeLink.js +1 -1
  133. package/esm/utils/normalizeOptions.js +4 -2
  134. package/esm/utils/object.d.ts +2 -0
  135. package/esm/utils/object.js +27 -2
  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/renderer-event.js +35 -32
  142. package/esm/utils/replaceText.js +1 -1
  143. package/esm/utils/resize-sensor.js +1 -1
  144. package/esm/utils/resolveCondition.d.ts +1 -0
  145. package/esm/utils/resolveCondition.js +19 -4
  146. package/esm/utils/resolveVariable.js +4 -3
  147. package/esm/utils/resolveVariableAndFilter.js +1 -1
  148. package/esm/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
  149. package/esm/utils/resolveVariableAndFilterForAsync.js +23 -5
  150. package/esm/utils/scrollPosition.js +1 -1
  151. package/esm/utils/string2regExp.js +1 -1
  152. package/esm/utils/stripNumber.js +1 -1
  153. package/esm/utils/style-helper.d.ts +12 -4
  154. package/esm/utils/style-helper.js +96 -19
  155. package/esm/utils/style.js +2 -2
  156. package/esm/utils/toNumber.js +1 -1
  157. package/esm/utils/tokenize.js +1 -1
  158. package/esm/utils/tpl-builtin.d.ts +2 -1
  159. package/esm/utils/tpl-builtin.js +19 -2
  160. package/esm/utils/tpl-lodash.js +3 -2
  161. package/esm/utils/tpl.d.ts +2 -0
  162. package/esm/utils/tpl.js +24 -2
  163. package/esm/utils/uncontrollable.js +1 -1
  164. package/esm/utils/validations.d.ts +4 -1
  165. package/esm/utils/validations.js +27 -12
  166. package/lib/Root.d.ts +89 -4
  167. package/lib/Root.js +15 -4
  168. package/lib/RootRenderer.d.ts +3 -1
  169. package/lib/RootRenderer.js +8 -2
  170. package/lib/SchemaRenderer.d.ts +4 -2
  171. package/lib/SchemaRenderer.js +32 -23
  172. package/lib/Scoped.d.ts +8 -0
  173. package/lib/Scoped.js +20 -4
  174. package/lib/StatusScoped.d.ts +58 -0
  175. package/lib/StatusScoped.js +63 -0
  176. package/lib/WithRootStore.d.ts +2 -2
  177. package/lib/WithRootStore.js +1 -1
  178. package/lib/WithStore.js +6 -2
  179. package/lib/actions/Action.d.ts +1 -0
  180. package/lib/actions/Action.js +19 -5
  181. package/lib/actions/AjaxAction.js +1 -1
  182. package/lib/actions/BreakAction.js +1 -1
  183. package/lib/actions/BroadcastAction.js +1 -1
  184. package/lib/actions/CmptAction.js +8 -7
  185. package/lib/actions/ContinueAction.js +1 -1
  186. package/lib/actions/CopyAction.js +1 -1
  187. package/lib/actions/CustomAction.js +4 -4
  188. package/lib/actions/DialogAction.d.ts +16 -2
  189. package/lib/actions/DialogAction.js +23 -7
  190. package/lib/actions/DrawerAction.js +1 -1
  191. package/lib/actions/EmailAction.js +1 -1
  192. package/lib/actions/LinkAction.js +1 -1
  193. package/lib/actions/LoopAction.js +1 -1
  194. package/lib/actions/PageAction.js +1 -1
  195. package/lib/actions/ParallelAction.js +1 -1
  196. package/lib/actions/SwitchAction.js +1 -1
  197. package/lib/actions/ToastAction.js +1 -1
  198. package/lib/components/CustomStyle.d.ts +13 -0
  199. package/lib/components/CustomStyle.js +22 -0
  200. package/lib/components/LazyComponent.d.ts +1 -1
  201. package/lib/components/LazyComponent.js +1 -1
  202. package/lib/components/Overlay.d.ts +3 -3
  203. package/lib/components/Overlay.js +1 -1
  204. package/lib/components/PopOver.d.ts +2 -2
  205. package/lib/components/PopOver.js +1 -1
  206. package/lib/env.d.ts +10 -2
  207. package/lib/env.js +1 -1
  208. package/lib/envOverwrite.js +1 -5
  209. package/lib/factory.d.ts +5 -3
  210. package/lib/factory.js +3 -3
  211. package/lib/index.d.ts +11 -4
  212. package/lib/index.js +61 -23
  213. package/lib/locale.d.ts +2 -2
  214. package/lib/locale.js +10 -3
  215. package/lib/renderers/Form.d.ts +3 -2
  216. package/lib/renderers/Form.js +215 -179
  217. package/lib/renderers/Item.d.ts +55 -41
  218. package/lib/renderers/Item.js +30 -19
  219. package/lib/renderers/Options.js +11 -4
  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 -2
  224. package/lib/renderers/wrapControl.js +12 -15
  225. package/lib/store/app.d.ts +1 -0
  226. package/lib/store/app.js +1 -1
  227. package/lib/store/combo.d.ts +3 -0
  228. package/lib/store/combo.js +1 -1
  229. package/lib/store/crud.d.ts +2 -0
  230. package/lib/store/crud.js +31 -9
  231. package/lib/store/form.d.ts +1 -0
  232. package/lib/store/form.js +10 -4
  233. package/lib/store/formItem.js +2 -2
  234. package/lib/store/iRenderer.d.ts +1 -0
  235. package/lib/store/iRenderer.js +53 -12
  236. package/lib/store/index.js +1 -1
  237. package/lib/store/list.d.ts +1 -0
  238. package/lib/store/list.js +7 -3
  239. package/lib/store/manager.js +1 -1
  240. package/lib/store/modal.d.ts +1 -0
  241. package/lib/store/modal.js +1 -1
  242. package/lib/store/node.js +1 -1
  243. package/lib/store/pagination.d.ts +1 -0
  244. package/lib/store/pagination.js +2 -2
  245. package/lib/store/root.d.ts +4 -6
  246. package/lib/store/root.js +52 -23
  247. package/lib/store/service.d.ts +1 -0
  248. package/lib/store/service.js +1 -1
  249. package/lib/store/status.d.ts +12 -0
  250. package/lib/store/status.js +42 -0
  251. package/lib/store/table.d.ts +28 -23
  252. package/lib/store/table.js +26 -5
  253. package/lib/store/table2.d.ts +7 -6
  254. package/lib/store/table2.js +27 -23
  255. package/lib/theme.d.ts +1 -1
  256. package/lib/theme.js +1 -1
  257. package/lib/types.d.ts +7 -1
  258. package/lib/utils/Animation.js +1 -1
  259. package/lib/utils/ColorScale.js +1 -1
  260. package/lib/utils/DataSchema.js +1 -1
  261. package/lib/utils/DataScope.d.ts +3 -5
  262. package/lib/utils/DataScope.js +86 -29
  263. package/lib/utils/RootClose.js +1 -1
  264. package/lib/utils/SimpleMap.js +1 -1
  265. package/lib/utils/api.js +13 -4
  266. package/lib/utils/attachmentAdpator.js +2 -2
  267. package/lib/utils/autobind.js +1 -1
  268. package/lib/utils/columnsSplit.js +1 -1
  269. package/lib/utils/dataMapping.js +1 -1
  270. package/lib/utils/date.d.ts +7 -0
  271. package/lib/utils/date.js +34 -1
  272. package/lib/utils/debug.js +4 -4
  273. package/lib/utils/decodeEntity.js +1 -1
  274. package/lib/utils/dom.d.ts +3 -0
  275. package/lib/utils/dom.js +48 -9
  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 +3 -3
  284. package/lib/utils/handleAction.js +1 -1
  285. package/lib/utils/helper.d.ts +9 -2
  286. package/lib/utils/helper.js +53 -19
  287. package/lib/utils/highlight.js +1 -1
  288. package/lib/utils/icon.d.ts +6 -1
  289. package/lib/utils/icon.js +6 -1
  290. package/lib/utils/image.js +1 -1
  291. package/lib/utils/isPureVariable.js +3 -3
  292. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  293. package/lib/utils/keyToPath.js +1 -1
  294. package/lib/utils/makeSorter.js +1 -1
  295. package/lib/utils/memoryParse.d.ts +17 -0
  296. package/lib/utils/memoryParse.js +30 -0
  297. package/lib/utils/normalizeLink.js +1 -1
  298. package/lib/utils/normalizeOptions.js +4 -2
  299. package/lib/utils/object.d.ts +2 -0
  300. package/lib/utils/object.js +28 -1
  301. package/lib/utils/offset.js +1 -1
  302. package/lib/utils/offsetParent.js +1 -1
  303. package/lib/utils/optionValueCompare.js +1 -1
  304. package/lib/utils/position.js +1 -1
  305. package/lib/utils/prettyBytes.js +1 -1
  306. package/lib/utils/renderer-event.js +35 -32
  307. package/lib/utils/replaceText.js +1 -1
  308. package/lib/utils/resize-sensor.js +1 -1
  309. package/lib/utils/resolveCondition.d.ts +1 -0
  310. package/lib/utils/resolveCondition.js +19 -3
  311. package/lib/utils/resolveVariable.js +3 -2
  312. package/lib/utils/resolveVariableAndFilter.js +1 -1
  313. package/lib/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
  314. package/lib/utils/resolveVariableAndFilterForAsync.js +22 -3
  315. package/lib/utils/scrollPosition.js +1 -1
  316. package/lib/utils/string2regExp.js +1 -1
  317. package/lib/utils/stripNumber.js +1 -1
  318. package/lib/utils/style-helper.d.ts +12 -4
  319. package/lib/utils/style-helper.js +101 -18
  320. package/lib/utils/style.js +2 -2
  321. package/lib/utils/toNumber.js +1 -1
  322. package/lib/utils/tokenize.js +1 -1
  323. package/lib/utils/tpl-builtin.d.ts +2 -1
  324. package/lib/utils/tpl-builtin.js +19 -2
  325. package/lib/utils/tpl-lodash.js +3 -2
  326. package/lib/utils/tpl.d.ts +2 -0
  327. package/lib/utils/tpl.js +24 -1
  328. package/lib/utils/uncontrollable.js +1 -1
  329. package/lib/utils/validations.d.ts +4 -1
  330. package/lib/utils/validations.js +27 -12
  331. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -66,6 +66,7 @@ var Form = /** @class */ (function (_super) {
66
66
  _this.reload = _this.reload.bind(_this);
67
67
  _this.silentReload = _this.silentReload.bind(_this);
68
68
  _this.initInterval = _this.initInterval.bind(_this);
69
+ _this.dispatchInited = _this.dispatchInited.bind(_this);
69
70
  _this.blockRouting = _this.blockRouting.bind(_this);
70
71
  _this.beforePageUnload = _this.beforePageUnload.bind(_this);
71
72
  var store = props.store, canAccessSuperData = props.canAccessSuperData, persistData = props.persistData, simpleMode = props.simpleMode;
@@ -148,6 +149,7 @@ var Form = /** @class */ (function (_super) {
148
149
  return helper.until(function () { return store.checkRemote(initAsyncApi, store.data); }, function (ret) { return ret && ret[initFinishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); }, initCheckInterval);
149
150
  }
150
151
  })
152
+ .then(this.dispatchInited)
151
153
  .then(this.initInterval)
152
154
  .then(this.onInit);
153
155
  }
@@ -167,7 +169,9 @@ var Form = /** @class */ (function (_super) {
167
169
  store[store.hasRemoteData ? 'fetchData' : 'fetchInitData'](props.initApi, store.data, {
168
170
  successMessage: fetchSuccess,
169
171
  errorMessage: fetchFailed
170
- }).then(this.initInterval);
172
+ })
173
+ .then(this.dispatchInited)
174
+ .then(this.initInterval);
171
175
  }
172
176
  };
173
177
  Form.prototype.componentWillUnmount = function () {
@@ -182,6 +186,27 @@ var Form = /** @class */ (function (_super) {
182
186
  window.removeEventListener('beforeunload', this.beforePageUnload);
183
187
  (_a = this.unBlockRouting) === null || _a === void 0 ? void 0 : _a.call(this);
184
188
  };
189
+ Form.prototype.dispatchInited = function (value) {
190
+ var _a;
191
+ return tslib.__awaiter(this, void 0, void 0, function () {
192
+ var _b, data, store, dispatchEvent;
193
+ return tslib.__generator(this, function (_c) {
194
+ switch (_c.label) {
195
+ case 0:
196
+ _b = this.props, data = _b.data, store = _b.store, dispatchEvent = _b.dispatchEvent;
197
+ if (store.fetching) {
198
+ return [2 /*return*/];
199
+ }
200
+ // 派发init事件,参数为初始化数据
201
+ 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 })))];
202
+ case 1:
203
+ // 派发init事件,参数为初始化数据
204
+ _c.sent();
205
+ return [2 /*return*/, value];
206
+ }
207
+ });
208
+ });
209
+ };
185
210
  Form.prototype.blockRouting = function () {
186
211
  var store = this.props.store;
187
212
  var _a = this.props, promptPageLeaveMessage = _a.promptPageLeaveMessage, promptPageLeave = _a.promptPageLeave;
@@ -198,11 +223,11 @@ var Form = /** @class */ (function (_super) {
198
223
  };
199
224
  Form.prototype.onInit = function () {
200
225
  return tslib.__awaiter(this, void 0, void 0, function () {
201
- var _a, onInit, store, persistData, submitOnInit, dispatchEvent, data, initedAt, hooks, dispatcher;
226
+ var _a, onInit, store, persistData, submitOnInit, data, initedAt, hooks;
202
227
  return tslib.__generator(this, function (_b) {
203
228
  switch (_b.label) {
204
229
  case 0:
205
- _a = this.props, onInit = _a.onInit, store = _a.store, persistData = _a.persistData, submitOnInit = _a.submitOnInit, dispatchEvent = _a.dispatchEvent;
230
+ _a = this.props, onInit = _a.onInit, store = _a.store, persistData = _a.persistData, submitOnInit = _a.submitOnInit, _a.dispatchEvent;
206
231
  if (!mobxStateTree.isAlive(store)) {
207
232
  return [2 /*return*/];
208
233
  }
@@ -227,12 +252,7 @@ var Form = /** @class */ (function (_super) {
227
252
  store.getLocalPersistData();
228
253
  data = object.cloneObject(store.data);
229
254
  }
230
- return [4 /*yield*/, dispatchEvent('inited', object.createObject(this.props.data, data))];
231
- case 2:
232
- dispatcher = _b.sent();
233
- if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
234
- onInit && onInit(data, this.props);
235
- }
255
+ onInit && onInit(data, this.props);
236
256
  submitOnInit &&
237
257
  this.handleAction(undefined, {
238
258
  type: 'submit'
@@ -267,12 +287,23 @@ var Form = /** @class */ (function (_super) {
267
287
  return helper.until(function () { return store.checkRemote(initAsyncApi, store.data); }, function (ret) { return ret && ret[initFinishedField || 'finished']; }, function (cancel) { return (_this.asyncCancel = cancel); });
268
288
  }
269
289
  })
270
- .then(function (result) {
271
- if (result === null || result === void 0 ? void 0 : result.ok) {
272
- _this.initInterval(result);
273
- store.reset(undefined, false);
274
- }
275
- })
290
+ .then(function (result) { return tslib.__awaiter(_this, void 0, void 0, function () {
291
+ return tslib.__generator(this, function (_a) {
292
+ switch (_a.label) {
293
+ case 0:
294
+ // 派发初始化接口请求完成事件
295
+ return [4 /*yield*/, this.dispatchInited(result)];
296
+ case 1:
297
+ // 派发初始化接口请求完成事件
298
+ _a.sent();
299
+ if (result === null || result === void 0 ? void 0 : result.ok) {
300
+ this.initInterval(result);
301
+ store.reset(undefined, false);
302
+ }
303
+ return [2 /*return*/];
304
+ }
305
+ });
306
+ }); })
276
307
  : store.reset(undefined, false);
277
308
  };
278
309
  Form.prototype.receive = function (values, name, replace) {
@@ -455,14 +486,15 @@ var Form = /** @class */ (function (_super) {
455
486
  };
456
487
  };
457
488
  Form.prototype.handleAction = function (e, action, data, throwErrors, delegate) {
489
+ var _a, _b;
458
490
  if (throwErrors === void 0) { throwErrors = false; }
459
491
  return tslib.__awaiter(this, void 0, void 0, function () {
460
- var _a, store, onSubmit, api$1, asyncApi, finishedField, checkInterval, _b, saveSuccess, saveFailed, resetAfterSubmit, clearAfterSubmit, onAction, onSaved, onReset, onFinished, onFailed, redirect, reload, target, env, onChange, clearPersistDataAfterSubmit, trimValues, dispatchEvent, __, fields, validationRes, dispatcher;
492
+ 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;
461
493
  var _this = this;
462
- return tslib.__generator(this, function (_c) {
463
- switch (_c.label) {
494
+ return tslib.__generator(this, function (_f) {
495
+ switch (_f.label) {
464
496
  case 0:
465
- _a = this.props, store = _a.store, onSubmit = _a.onSubmit, api$1 = _a.api, asyncApi = _a.asyncApi, finishedField = _a.finishedField, checkInterval = _a.checkInterval, _b = _a.messages, saveSuccess = _b.saveSuccess, saveFailed = _b.saveFailed, resetAfterSubmit = _a.resetAfterSubmit, clearAfterSubmit = _a.clearAfterSubmit, onAction = _a.onAction, onSaved = _a.onSaved, onReset = _a.onReset, onFinished = _a.onFinished, onFailed = _a.onFailed, redirect = _a.redirect, reload = _a.reload, target = _a.target, env = _a.env, onChange = _a.onChange, clearPersistDataAfterSubmit = _a.clearPersistDataAfterSubmit, trimValues = _a.trimValues, dispatchEvent = _a.dispatchEvent, __ = _a.translate;
497
+ _c = this.props, store = _c.store, onSubmit = _c.onSubmit, api$1 = _c.api, asyncApi = _c.asyncApi, finishedField = _c.finishedField, checkInterval = _c.checkInterval, _d = _c.messages, saveSuccess = _d.saveSuccess, saveFailed = _d.saveFailed, resetAfterSubmit = _c.resetAfterSubmit, clearAfterSubmit = _c.clearAfterSubmit, onAction = _c.onAction, onSaved = _c.onSaved, onReset = _c.onReset, onFinished = _c.onFinished, onFailed = _c.onFailed, redirect = _c.redirect, reload = _c.reload, target = _c.target, env = _c.env, onChange = _c.onChange, clearPersistDataAfterSubmit = _c.clearPersistDataAfterSubmit, trimValues = _c.trimValues, dispatchEvent = _c.dispatchEvent, __ = _c.translate;
466
498
  // 做动作之前,先把数据同步一下。
467
499
  this.flush();
468
500
  if (trimValues) {
@@ -481,11 +513,11 @@ var Form = /** @class */ (function (_super) {
481
513
  }); });
482
514
  return [4 /*yield*/, store.validateFields(fields)];
483
515
  case 1:
484
- validationRes = _c.sent();
516
+ validationRes = _f.sent();
485
517
  if (!!validationRes) return [3 /*break*/, 3];
486
518
  return [4 /*yield*/, dispatchEvent('validateError', this.props.data)];
487
519
  case 2:
488
- dispatcher = _c.sent();
520
+ dispatcher = _f.sent();
489
521
  if (!(dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented)) {
490
522
  env.notify('error', __('Form.validateFailed'));
491
523
  }
@@ -494,147 +526,158 @@ var Form = /** @class */ (function (_super) {
494
526
  case 3:
495
527
  /** 重置validated状态,保证submit时触发表单中的校验项 */
496
528
  store.clearErrors();
497
- _c.label = 4;
529
+ _f.label = 4;
498
530
  case 4:
499
- if (action.type === 'submit' ||
531
+ if (!(action.type === 'submit' ||
500
532
  action.actionType === 'submit' ||
501
533
  action.actionType === 'confirm' ||
502
534
  action.actionType === 'reset-and-submit' ||
503
- action.actionType === 'clear-and-submit') {
504
- store.setCurrentAction(action);
505
- if (action.actionType === 'reset-and-submit') {
506
- store.reset(this.handleReset(action));
507
- }
508
- else if (action.actionType === 'clear-and-submit') {
509
- store.clear(this.handleReset(action));
510
- }
511
- return [2 /*return*/, this.submit(function (values) {
512
- var _a;
513
- if (onSubmit && onSubmit(values, action) === false) {
514
- return Promise.resolve(false);
515
- }
516
- // 走到这里代表校验成功了
517
- dispatchEvent('validateSucc', _this.props.data);
518
- if (target) {
519
- _this.submitToTarget(tpl.filter(target, values), values);
520
- dispatchEvent('submitSucc', object.createObject(_this.props.data, values));
521
- }
522
- else if (action.actionType === 'reload') {
523
- action.target &&
524
- _this.reloadTarget(tpl.filter(action.target, values), values);
525
- }
526
- else if (action.actionType === 'dialog') {
527
- store.openDialog(data);
528
- }
529
- else if (action.actionType === 'drawer') {
530
- store.openDrawer(data);
531
- }
532
- else if (api.isEffectiveApi(action.api || api$1, values)) {
533
- var finnalAsyncApi_1 = action.asyncApi || asyncApi;
534
- api.isEffectiveApi(finnalAsyncApi_1, store.data) &&
535
- store.updateData((_a = {},
536
- _a[finishedField || 'finished'] = false,
537
- _a));
538
- return store
539
- .saveRemote(action.api || api$1, values, {
540
- successMessage: saveSuccess,
541
- errorMessage: saveFailed,
542
- onSuccess: function (result) { return tslib.__awaiter(_this, void 0, void 0, function () {
543
- var dispatcher, cbResult;
544
- var _this = this;
545
- return tslib.__generator(this, function (_a) {
546
- switch (_a.label) {
547
- case 0: return [4 /*yield*/, dispatchEvent('submitSucc', object.createObject(this.props.data, { result: result }))];
548
- case 1:
549
- dispatcher = _a.sent();
550
- if (!api.isEffectiveApi(finnalAsyncApi_1, store.data) ||
551
- store.data[finishedField || 'finished']) {
552
- return [2 /*return*/, {
553
- cbResult: null,
554
- dispatcher: dispatcher
555
- }];
556
- }
557
- 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);
558
- return [2 /*return*/, {
559
- cbResult: cbResult,
560
- dispatcher: dispatcher
561
- }];
562
- }
563
- });
564
- }); },
565
- onFailed: function (result) { return tslib.__awaiter(_this, void 0, void 0, function () {
566
- var dispatcher;
567
- return tslib.__generator(this, function (_a) {
568
- switch (_a.label) {
569
- case 0: return [4 /*yield*/, dispatchEvent('submitFail', object.createObject(this.props.data, { error: result }))];
570
- case 1:
571
- dispatcher = _a.sent();
535
+ action.actionType === 'clear-and-submit')) return [3 /*break*/, 6];
536
+ _e = this.props, dispatchEvent_1 = _e.dispatchEvent, onEvent = _e.onEvent;
537
+ 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;
538
+ return [4 /*yield*/, dispatchEvent_1('submit', this.props.data)];
539
+ case 5:
540
+ dispatcher = _f.sent();
541
+ if ((dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented) || submitEvent) {
542
+ return [2 /*return*/];
543
+ }
544
+ store.setCurrentAction(action);
545
+ if (action.actionType === 'reset-and-submit') {
546
+ store.reset(this.handleReset(action));
547
+ }
548
+ else if (action.actionType === 'clear-and-submit') {
549
+ store.clear(this.handleReset(action));
550
+ }
551
+ return [2 /*return*/, this.submit(function (values) {
552
+ var _a;
553
+ if (onSubmit && onSubmit(values, action) === false) {
554
+ return Promise.resolve(false);
555
+ }
556
+ // 走到这里代表校验成功了
557
+ dispatchEvent_1('validateSucc', _this.props.data);
558
+ if (target) {
559
+ _this.submitToTarget(Scoped.filterTarget(target, values), values);
560
+ dispatchEvent_1('submitSucc', object.createObject(_this.props.data, values));
561
+ }
562
+ else if (action.actionType === 'reload') {
563
+ action.target &&
564
+ _this.reloadTarget(Scoped.filterTarget(action.target, values), values);
565
+ }
566
+ else if (action.actionType === 'dialog') {
567
+ store.openDialog(data);
568
+ }
569
+ else if (action.actionType === 'drawer') {
570
+ store.openDrawer(data);
571
+ }
572
+ else if (api.isEffectiveApi(action.api || api$1, values)) {
573
+ var finnalAsyncApi_1 = action.asyncApi || asyncApi;
574
+ api.isEffectiveApi(finnalAsyncApi_1, store.data) &&
575
+ store.updateData((_a = {},
576
+ _a[finishedField || 'finished'] = false,
577
+ _a));
578
+ return store
579
+ .saveRemote(action.api || api$1, values, {
580
+ successMessage: saveSuccess,
581
+ errorMessage: saveFailed,
582
+ onSuccess: function (result) { return tslib.__awaiter(_this, void 0, void 0, function () {
583
+ var dispatcher, cbResult;
584
+ var _this = this;
585
+ return tslib.__generator(this, function (_a) {
586
+ switch (_a.label) {
587
+ case 0: return [4 /*yield*/, dispatchEvent_1('submitSucc', object.createObject(this.props.data, { result: result }))];
588
+ case 1:
589
+ dispatcher = _a.sent();
590
+ if (!api.isEffectiveApi(finnalAsyncApi_1, store.data) ||
591
+ store.data[finishedField || 'finished']) {
572
592
  return [2 /*return*/, {
593
+ cbResult: null,
573
594
  dispatcher: dispatcher
574
595
  }];
575
- }
576
- });
577
- }); }
578
- })
579
- .then(function (response) { return tslib.__awaiter(_this, void 0, void 0, function () {
580
- var feedback, confirmed;
596
+ }
597
+ 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) {
598
+ // 派发asyncApiFinished事件
599
+ dispatchEvent_1('asyncApiFinished', store.data);
600
+ });
601
+ return [2 /*return*/, {
602
+ cbResult: cbResult,
603
+ dispatcher: dispatcher
604
+ }];
605
+ }
606
+ });
607
+ }); },
608
+ onFailed: function (result) { return tslib.__awaiter(_this, void 0, void 0, function () {
609
+ var dispatcher;
581
610
  return tslib.__generator(this, function (_a) {
582
611
  switch (_a.label) {
583
- case 0:
584
- onSaved && onSaved(values, response);
585
- feedback = action.feedback || this.props.feedback;
586
- if (!(feedback && helper.isVisible(feedback, store.data))) return [3 /*break*/, 2];
587
- return [4 /*yield*/, this.openFeedback(feedback, store.data)];
612
+ case 0: return [4 /*yield*/, dispatchEvent_1('submitFail', object.createObject(this.props.data, { error: result }))];
588
613
  case 1:
589
- confirmed = _a.sent();
590
- // 如果 feedback 配置了,取消就跳过原有逻辑。
591
- if (feedback.skipRestOnCancel && !confirmed) {
592
- throw new helper.SkipOperation();
593
- }
594
- else if (feedback.skipRestOnConfirm && confirmed) {
595
- throw new helper.SkipOperation();
596
- }
597
- _a.label = 2;
598
- case 2: return [2 /*return*/];
614
+ dispatcher = _a.sent();
615
+ return [2 /*return*/, {
616
+ dispatcher: dispatcher
617
+ }];
599
618
  }
600
619
  });
601
- }); });
602
- }
603
- else {
604
- // type为submit,但是没有配api以及target时,只派发事件
605
- dispatchEvent('submitSucc', object.createObject(_this.props.data, values));
606
- }
607
- return Promise.resolve(null);
608
- })
609
- .then(function (values) {
610
- // 有可能 onSubmit return false 了,那么后面的就不应该再执行了。
611
- if (values === false) {
612
- return store.data;
613
- }
614
- if (onFinished && onFinished(values, action) === false) {
615
- return values;
616
- }
617
- resetAfterSubmit && store.reset(_this.handleReset(action));
618
- clearAfterSubmit && store.clear(_this.handleReset(action));
619
- clearPersistDataAfterSubmit && store.clearLocalPersistData();
620
- if (action.redirect || redirect) {
621
- var finalRedirect = tpl.filter(action.redirect || redirect, store.data);
622
- finalRedirect && env.jumpTo(finalRedirect, action);
623
- }
624
- else if (action.reload || reload) {
625
- _this.reloadTarget(tpl.filter(action.reload || reload, store.data), store.data);
626
- }
627
- action.close && _this.closeTarget(action.close);
620
+ }); }
621
+ })
622
+ .then(function (response) { return tslib.__awaiter(_this, void 0, void 0, function () {
623
+ var feedback, confirmed;
624
+ return tslib.__generator(this, function (_a) {
625
+ switch (_a.label) {
626
+ case 0:
627
+ onSaved && onSaved(values, response);
628
+ feedback = action.feedback || this.props.feedback;
629
+ if (!(feedback && helper.isVisible(feedback, store.data))) return [3 /*break*/, 2];
630
+ return [4 /*yield*/, this.openFeedback(feedback, store.data)];
631
+ case 1:
632
+ confirmed = _a.sent();
633
+ // 如果 feedback 配置了,取消就跳过原有逻辑。
634
+ if (feedback.skipRestOnCancel && !confirmed) {
635
+ throw new helper.SkipOperation();
636
+ }
637
+ else if (feedback.skipRestOnConfirm && confirmed) {
638
+ throw new helper.SkipOperation();
639
+ }
640
+ _a.label = 2;
641
+ case 2: return [2 /*return*/];
642
+ }
643
+ });
644
+ }); });
645
+ }
646
+ else {
647
+ // type为submit,但是没有配api以及target时,只派发事件
648
+ dispatchEvent_1('submitSucc', object.createObject(_this.props.data, values));
649
+ }
650
+ return Promise.resolve(null);
651
+ })
652
+ .then(function (values) {
653
+ // 有可能 onSubmit return false 了,那么后面的就不应该再执行了。
654
+ if (values === false) {
655
+ return store.data;
656
+ }
657
+ if (onFinished && onFinished(values, action) === false) {
628
658
  return values;
629
- })
630
- .catch(function (reason) {
631
- onFailed && onFailed(reason, store.errors);
632
- if (throwErrors) {
633
- throw reason;
634
- }
635
- })];
636
- }
637
- else if (action.type === 'reset' || action.actionType === 'reset') {
659
+ }
660
+ resetAfterSubmit && store.reset(_this.handleReset(action));
661
+ clearAfterSubmit && store.clear(_this.handleReset(action));
662
+ clearPersistDataAfterSubmit && store.clearLocalPersistData();
663
+ if (action.redirect || redirect) {
664
+ var finalRedirect = tpl.filter(action.redirect || redirect, store.data);
665
+ finalRedirect && env.jumpTo(finalRedirect, action);
666
+ }
667
+ else if (action.reload || reload) {
668
+ _this.reloadTarget(Scoped.filterTarget(action.reload || reload, store.data), store.data);
669
+ }
670
+ action.close && _this.closeTarget(action.close);
671
+ return values;
672
+ })
673
+ .catch(function (reason) {
674
+ onFailed && onFailed(reason, store.errors);
675
+ if (throwErrors) {
676
+ throw reason;
677
+ }
678
+ })];
679
+ case 6:
680
+ if (action.type === 'reset' || action.actionType === 'reset') {
638
681
  store.setCurrentAction(action);
639
682
  store.reset(onReset);
640
683
  }
@@ -687,7 +730,7 @@ var Form = /** @class */ (function (_super) {
687
730
  redirect = action.redirect && tpl.filter(action.redirect, store.data);
688
731
  redirect && env.jumpTo(redirect, action);
689
732
  action.reload &&
690
- this.reloadTarget(tpl.filter(action.reload, store.data), store.data);
733
+ this.reloadTarget(Scoped.filterTarget(action.reload, store.data), store.data);
691
734
  action.close && this.closeTarget(action.close);
692
735
  return [2 /*return*/];
693
736
  }
@@ -703,18 +746,19 @@ var Form = /** @class */ (function (_super) {
703
746
  else if (action.actionType === 'reload') {
704
747
  store.setCurrentAction(action);
705
748
  if (action.target) {
706
- this.reloadTarget(tpl.filter(action.target, data), data);
749
+ this.reloadTarget(Scoped.filterTarget(action.target, data), data);
707
750
  }
708
751
  else {
709
752
  this.receive(data);
710
753
  }
711
- // action.target && this.reloadTarget(action.target, data);
754
+ // action.target && this.reloadTarget(filterTarget(action.target, data), data);
712
755
  }
713
756
  else if (onAction) {
714
757
  // 不识别的丢给上层去处理。
715
758
  return [2 /*return*/, onAction(e, action, data, throwErrors, delegate || this.context)];
716
759
  }
717
- return [2 /*return*/];
760
+ _f.label = 7;
761
+ case 7: return [2 /*return*/];
718
762
  }
719
763
  });
720
764
  });
@@ -1062,33 +1106,25 @@ var FormRenderer = /** @class */ (function (_super) {
1062
1106
  return this.handleAction(undefined, action, data, throwErrors);
1063
1107
  };
1064
1108
  FormRenderer.prototype.handleAction = function (e, action, ctx, throwErrors, delegate) {
1065
- var _a, _b;
1066
1109
  if (throwErrors === void 0) { throwErrors = false; }
1067
1110
  return tslib.__awaiter(this, void 0, void 0, function () {
1068
- var _c, dispatchEvent, onEvent, submitEvent, dispatcher, scoped_1;
1069
- return tslib.__generator(this, function (_d) {
1070
- switch (_d.label) {
1071
- case 0:
1072
- _c = this.props, dispatchEvent = _c.dispatchEvent, onEvent = _c.onEvent;
1073
- 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;
1074
- return [4 /*yield*/, dispatchEvent('submit', this.props.data)];
1075
- case 1:
1076
- dispatcher = _d.sent();
1077
- if ((dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.prevented) || submitEvent) {
1078
- return [2 /*return*/];
1079
- }
1080
- if (action.target && action.actionType !== 'reload') {
1081
- scoped_1 = this.context;
1082
- return [2 /*return*/, Promise.all(action.target.split(',').map(function (name) {
1083
- var target = scoped_1.getComponentByName(name);
1084
- return (target &&
1085
- target.doAction &&
1086
- target.doAction(tslib.__assign(tslib.__assign({}, action), { target: undefined }), ctx, throwErrors));
1087
- }))];
1088
- }
1089
- else {
1090
- return [2 /*return*/, _super.prototype.handleAction.call(this, e, action, ctx, throwErrors, delegate)];
1091
- }
1111
+ var scoped_1;
1112
+ return tslib.__generator(this, function (_a) {
1113
+ // 禁用了不要做任何动作。@先注释掉,会引起其他问题
1114
+ // if (this.props.disabled) {
1115
+ // return;
1116
+ // }
1117
+ if (action.target && action.actionType !== 'reload') {
1118
+ scoped_1 = this.context;
1119
+ return [2 /*return*/, Promise.all(action.target.split(',').map(function (name) {
1120
+ var target = scoped_1.getComponentByName(name);
1121
+ return (target &&
1122
+ target.doAction &&
1123
+ target.doAction(tslib.__assign(tslib.__assign({}, action), { target: undefined }), ctx, throwErrors));
1124
+ }))];
1125
+ }
1126
+ else {
1127
+ return [2 /*return*/, _super.prototype.handleAction.call(this, e, action, ctx, throwErrors, delegate)];
1092
1128
  }
1093
1129
  });
1094
1130
  });