amis-core 3.6.2 → 6.0.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 (287) hide show
  1. package/esm/Root.js +1 -1
  2. package/esm/RootRenderer.js +1 -1
  3. package/esm/SchemaRenderer.js +1 -1
  4. package/esm/Scoped.js +2 -1
  5. package/esm/StatusScoped.js +1 -1
  6. package/esm/WithRootStore.js +1 -1
  7. package/esm/WithStore.js +1 -1
  8. package/esm/actions/Action.js +31 -27
  9. package/esm/actions/AjaxAction.js +1 -1
  10. package/esm/actions/BreakAction.js +1 -1
  11. package/esm/actions/BroadcastAction.js +1 -1
  12. package/esm/actions/CmptAction.js +65 -26
  13. package/esm/actions/ContinueAction.js +1 -1
  14. package/esm/actions/CopyAction.js +1 -1
  15. package/esm/actions/CustomAction.js +3 -2
  16. package/esm/actions/DialogAction.js +1 -1
  17. package/esm/actions/DrawerAction.js +1 -1
  18. package/esm/actions/EmailAction.js +1 -1
  19. package/esm/actions/LinkAction.js +1 -1
  20. package/esm/actions/LoopAction.js +1 -1
  21. package/esm/actions/PageAction.js +1 -1
  22. package/esm/actions/ParallelAction.js +1 -1
  23. package/esm/actions/StatusAction.js +1 -1
  24. package/esm/actions/SwitchAction.js +1 -1
  25. package/esm/actions/ToastAction.js +1 -1
  26. package/esm/components/CustomStyle.js +1 -1
  27. package/esm/components/ErrorBoundary.js +1 -1
  28. package/esm/components/LazyComponent.js +1 -1
  29. package/esm/components/Overlay.d.ts +2 -1
  30. package/esm/components/Overlay.js +21 -6
  31. package/esm/components/PopOver.js +6 -3
  32. package/esm/env.js +1 -1
  33. package/esm/envOverwrite.js +1 -1
  34. package/esm/factory.js +1 -1
  35. package/esm/index.js +4 -2
  36. package/esm/locale.js +1 -1
  37. package/esm/polyfills.js +1 -1
  38. package/esm/renderers/Form.js +125 -111
  39. package/esm/renderers/Item.js +4 -3
  40. package/esm/renderers/Options.js +163 -49
  41. package/esm/renderers/Placeholder.js +1 -1
  42. package/esm/renderers/builtin.js +1 -1
  43. package/esm/renderers/register.js +1 -1
  44. package/esm/renderers/wrapControl.js +4 -3
  45. package/esm/store/app.d.ts +2 -2
  46. package/esm/store/app.js +3 -2
  47. package/esm/store/combo.d.ts +7 -7
  48. package/esm/store/combo.js +1 -1
  49. package/esm/store/crud.d.ts +3 -2
  50. package/esm/store/crud.js +18 -4
  51. package/esm/store/form.d.ts +3 -3
  52. package/esm/store/form.js +5 -5
  53. package/esm/store/formItem.js +1 -1
  54. package/esm/store/iRenderer.d.ts +1 -1
  55. package/esm/store/iRenderer.js +7 -2
  56. package/esm/store/index.js +1 -1
  57. package/esm/store/list.d.ts +1 -1
  58. package/esm/store/list.js +18 -13
  59. package/esm/store/manager.js +1 -1
  60. package/esm/store/modal.d.ts +2 -2
  61. package/esm/store/modal.js +1 -1
  62. package/esm/store/node.js +1 -1
  63. package/esm/store/pagination.d.ts +2 -1
  64. package/esm/store/pagination.js +3 -2
  65. package/esm/store/root.d.ts +2 -2
  66. package/esm/store/root.js +3 -2
  67. package/esm/store/service.d.ts +2 -2
  68. package/esm/store/service.js +11 -7
  69. package/esm/store/status.js +1 -1
  70. package/esm/store/table.d.ts +7 -7
  71. package/esm/store/table.js +26 -11
  72. package/esm/store/table2.d.ts +14 -3
  73. package/esm/store/table2.js +22 -9
  74. package/esm/theme.js +1 -1
  75. package/esm/types.d.ts +7 -0
  76. package/esm/utils/Animation.js +1 -1
  77. package/esm/utils/ColorScale.js +1 -1
  78. package/esm/utils/DataSchema.js +1 -1
  79. package/esm/utils/DataScope.js +1 -1
  80. package/esm/utils/RootClose.js +1 -1
  81. package/esm/utils/SimpleMap.js +1 -1
  82. package/esm/utils/api.js +1 -1
  83. package/esm/utils/arraySlice.js +1 -1
  84. package/esm/utils/attachmentAdpator.js +1 -1
  85. package/esm/utils/autobind.js +1 -1
  86. package/esm/utils/browser.d.ts +1 -0
  87. package/esm/utils/browser.js +11 -0
  88. package/esm/utils/columnsSplit.js +1 -1
  89. package/esm/utils/concatData.d.ts +8 -0
  90. package/esm/utils/concatData.js +39 -0
  91. package/esm/utils/dataMapping.js +1 -1
  92. package/esm/utils/date.js +1 -1
  93. package/esm/utils/debug.js +1 -1
  94. package/esm/utils/decodeEntity.js +1 -1
  95. package/esm/utils/dom.js +1 -1
  96. package/esm/utils/errors.js +1 -1
  97. package/esm/utils/escapeHtml.js +1 -1
  98. package/esm/utils/filter-schema.js +1 -1
  99. package/esm/utils/filter.js +1 -1
  100. package/esm/utils/formatDuration.js +1 -1
  101. package/esm/utils/formula.js +1 -1
  102. package/esm/utils/getVariable.js +1 -1
  103. package/esm/utils/grammar.js +1 -1
  104. package/esm/utils/handleAction.js +1 -1
  105. package/esm/utils/helper.d.ts +6 -1
  106. package/esm/utils/helper.js +23 -6
  107. package/esm/utils/highlight.js +1 -1
  108. package/esm/utils/icon.js +1 -1
  109. package/esm/utils/image.js +1 -1
  110. package/esm/utils/index.d.ts +2 -0
  111. package/esm/utils/isPureVariable.js +1 -1
  112. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  113. package/esm/utils/keyToPath.js +1 -1
  114. package/esm/utils/makeSorter.js +1 -1
  115. package/esm/utils/math.js +1 -1
  116. package/esm/utils/memoryParse.js +1 -1
  117. package/esm/utils/normalizeLink.js +1 -1
  118. package/esm/utils/normalizeOptions.js +1 -1
  119. package/esm/utils/object.js +1 -1
  120. package/esm/utils/offset.js +1 -1
  121. package/esm/utils/offsetParent.js +1 -1
  122. package/esm/utils/optionValueCompare.js +1 -1
  123. package/esm/utils/position.js +1 -1
  124. package/esm/utils/prettyBytes.js +1 -1
  125. package/esm/utils/renderer-event.js +19 -3
  126. package/esm/utils/replaceText.js +1 -1
  127. package/esm/utils/resize-sensor.js +1 -1
  128. package/esm/utils/resolveCondition.js +1 -1
  129. package/esm/utils/resolveVariable.js +1 -1
  130. package/esm/utils/resolveVariableAndFilter.js +1 -1
  131. package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
  132. package/esm/utils/scrollPosition.js +1 -1
  133. package/esm/utils/string2regExp.js +1 -1
  134. package/esm/utils/stripNumber.js +1 -1
  135. package/esm/utils/style-helper.js +4 -6
  136. package/esm/utils/style.js +1 -1
  137. package/esm/utils/toNumber.js +1 -1
  138. package/esm/utils/tokenize.js +1 -1
  139. package/esm/utils/tpl-builtin.js +1 -1
  140. package/esm/utils/tpl-lodash.js +1 -1
  141. package/esm/utils/tpl.js +1 -1
  142. package/esm/utils/uncontrollable.js +1 -1
  143. package/esm/utils/validations.js +1 -1
  144. package/lib/Root.js +1 -1
  145. package/lib/RootRenderer.js +1 -1
  146. package/lib/SchemaRenderer.js +1 -1
  147. package/lib/Scoped.js +2 -1
  148. package/lib/StatusScoped.js +1 -1
  149. package/lib/WithRootStore.js +1 -1
  150. package/lib/WithStore.js +1 -1
  151. package/lib/actions/Action.js +31 -27
  152. package/lib/actions/AjaxAction.js +1 -1
  153. package/lib/actions/BreakAction.js +1 -1
  154. package/lib/actions/BroadcastAction.js +1 -1
  155. package/lib/actions/CmptAction.js +65 -26
  156. package/lib/actions/ContinueAction.js +1 -1
  157. package/lib/actions/CopyAction.js +1 -1
  158. package/lib/actions/CustomAction.js +3 -2
  159. package/lib/actions/DialogAction.js +1 -1
  160. package/lib/actions/DrawerAction.js +1 -1
  161. package/lib/actions/EmailAction.js +1 -1
  162. package/lib/actions/LinkAction.js +1 -1
  163. package/lib/actions/LoopAction.js +1 -1
  164. package/lib/actions/PageAction.js +1 -1
  165. package/lib/actions/ParallelAction.js +1 -1
  166. package/lib/actions/StatusAction.js +1 -1
  167. package/lib/actions/SwitchAction.js +1 -1
  168. package/lib/actions/ToastAction.js +1 -1
  169. package/lib/components/CustomStyle.js +1 -1
  170. package/lib/components/ErrorBoundary.js +1 -1
  171. package/lib/components/LazyComponent.js +1 -1
  172. package/lib/components/Overlay.d.ts +2 -1
  173. package/lib/components/Overlay.js +21 -5
  174. package/lib/components/PopOver.js +6 -3
  175. package/lib/env.js +1 -1
  176. package/lib/envOverwrite.js +1 -1
  177. package/lib/factory.js +1 -1
  178. package/lib/index.js +6 -2
  179. package/lib/locale.js +1 -1
  180. package/lib/polyfills.js +1 -1
  181. package/lib/renderers/Form.js +125 -111
  182. package/lib/renderers/Item.js +4 -3
  183. package/lib/renderers/Options.js +163 -49
  184. package/lib/renderers/Placeholder.js +1 -1
  185. package/lib/renderers/builtin.js +1 -1
  186. package/lib/renderers/register.js +1 -1
  187. package/lib/renderers/wrapControl.js +4 -3
  188. package/lib/store/app.d.ts +2 -2
  189. package/lib/store/app.js +3 -2
  190. package/lib/store/combo.d.ts +7 -7
  191. package/lib/store/combo.js +1 -1
  192. package/lib/store/crud.d.ts +3 -2
  193. package/lib/store/crud.js +18 -4
  194. package/lib/store/form.d.ts +3 -3
  195. package/lib/store/form.js +5 -5
  196. package/lib/store/formItem.js +1 -1
  197. package/lib/store/iRenderer.d.ts +1 -1
  198. package/lib/store/iRenderer.js +7 -2
  199. package/lib/store/index.js +1 -1
  200. package/lib/store/list.d.ts +1 -1
  201. package/lib/store/list.js +18 -14
  202. package/lib/store/manager.js +1 -1
  203. package/lib/store/modal.d.ts +2 -2
  204. package/lib/store/modal.js +1 -1
  205. package/lib/store/node.js +1 -1
  206. package/lib/store/pagination.d.ts +2 -1
  207. package/lib/store/pagination.js +3 -2
  208. package/lib/store/root.d.ts +2 -2
  209. package/lib/store/root.js +3 -2
  210. package/lib/store/service.d.ts +2 -2
  211. package/lib/store/service.js +11 -7
  212. package/lib/store/status.js +1 -1
  213. package/lib/store/table.d.ts +7 -7
  214. package/lib/store/table.js +26 -12
  215. package/lib/store/table2.d.ts +14 -3
  216. package/lib/store/table2.js +22 -9
  217. package/lib/theme.js +1 -1
  218. package/lib/types.d.ts +7 -0
  219. package/lib/utils/Animation.js +1 -1
  220. package/lib/utils/ColorScale.js +1 -1
  221. package/lib/utils/DataSchema.js +1 -1
  222. package/lib/utils/DataScope.js +1 -1
  223. package/lib/utils/RootClose.js +1 -1
  224. package/lib/utils/SimpleMap.js +1 -1
  225. package/lib/utils/api.js +1 -1
  226. package/lib/utils/arraySlice.js +1 -1
  227. package/lib/utils/attachmentAdpator.js +1 -1
  228. package/lib/utils/autobind.js +1 -1
  229. package/lib/utils/browser.d.ts +1 -0
  230. package/lib/utils/browser.js +15 -0
  231. package/lib/utils/columnsSplit.js +1 -1
  232. package/lib/utils/concatData.d.ts +8 -0
  233. package/lib/utils/concatData.js +43 -0
  234. package/lib/utils/dataMapping.js +1 -1
  235. package/lib/utils/date.js +1 -1
  236. package/lib/utils/debug.js +1 -1
  237. package/lib/utils/decodeEntity.js +1 -1
  238. package/lib/utils/dom.js +1 -1
  239. package/lib/utils/errors.js +1 -1
  240. package/lib/utils/escapeHtml.js +1 -1
  241. package/lib/utils/filter-schema.js +1 -1
  242. package/lib/utils/filter.js +1 -1
  243. package/lib/utils/formatDuration.js +1 -1
  244. package/lib/utils/formula.js +1 -1
  245. package/lib/utils/getVariable.js +1 -1
  246. package/lib/utils/grammar.js +1 -1
  247. package/lib/utils/handleAction.js +1 -1
  248. package/lib/utils/helper.d.ts +6 -1
  249. package/lib/utils/helper.js +23 -6
  250. package/lib/utils/highlight.js +1 -1
  251. package/lib/utils/icon.js +1 -1
  252. package/lib/utils/image.js +1 -1
  253. package/lib/utils/index.d.ts +2 -0
  254. package/lib/utils/isPureVariable.js +1 -1
  255. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  256. package/lib/utils/keyToPath.js +1 -1
  257. package/lib/utils/makeSorter.js +1 -1
  258. package/lib/utils/math.js +1 -1
  259. package/lib/utils/memoryParse.js +1 -1
  260. package/lib/utils/normalizeLink.js +1 -1
  261. package/lib/utils/normalizeOptions.js +1 -1
  262. package/lib/utils/object.js +1 -1
  263. package/lib/utils/offset.js +1 -1
  264. package/lib/utils/offsetParent.js +1 -1
  265. package/lib/utils/optionValueCompare.js +1 -1
  266. package/lib/utils/position.js +1 -1
  267. package/lib/utils/prettyBytes.js +1 -1
  268. package/lib/utils/renderer-event.js +19 -3
  269. package/lib/utils/replaceText.js +1 -1
  270. package/lib/utils/resize-sensor.js +1 -1
  271. package/lib/utils/resolveCondition.js +1 -1
  272. package/lib/utils/resolveVariable.js +1 -1
  273. package/lib/utils/resolveVariableAndFilter.js +1 -1
  274. package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
  275. package/lib/utils/scrollPosition.js +1 -1
  276. package/lib/utils/string2regExp.js +1 -1
  277. package/lib/utils/stripNumber.js +1 -1
  278. package/lib/utils/style-helper.js +4 -6
  279. package/lib/utils/style.js +1 -1
  280. package/lib/utils/toNumber.js +1 -1
  281. package/lib/utils/tokenize.js +1 -1
  282. package/lib/utils/tpl-builtin.js +1 -1
  283. package/lib/utils/tpl-lodash.js +1 -1
  284. package/lib/utils/tpl.js +1 -1
  285. package/lib/utils/uncontrollable.js +1 -1
  286. package/lib/utils/validations.js +1 -1
  287. package/package.json +4 -3
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.2
2
+ * amis-core v6.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -27,6 +27,7 @@ var findIndex = require('lodash/findIndex');
27
27
  var isPlainObject = require('lodash/isPlainObject');
28
28
  var normalizeOptions = require('../utils/normalizeOptions.js');
29
29
  var optionValueCompare = require('../utils/optionValueCompare.js');
30
+ require('../utils/browser.js');
30
31
  require('../utils/ColorScale.js');
31
32
  require('../utils/columnsSplit.js');
32
33
  require('../utils/DataSchema.js');
@@ -160,7 +161,7 @@ function registerOptionsControl(config) {
160
161
  var _this = this;
161
162
  var props = this.props;
162
163
  var formItem = props.formItem;
163
- if (prevProps.options !== props.options && formItem) {
164
+ if (!props.source && prevProps.options !== props.options && formItem) {
164
165
  formItem.setOptions(normalizeOptions.normalizeOptions(props.options || [], undefined, props.valueField), this.changeOptionValue, props.data);
165
166
  this.normalizeValue();
166
167
  }
@@ -194,7 +195,8 @@ function registerOptionsControl(config) {
194
195
  this.toDispose.forEach(function (fn) { return fn(); });
195
196
  this.toDispose = [];
196
197
  };
197
- FormOptionsItem.prototype.dispatchOptionEvent = function (eventName, eventData) {
198
+ // 不推荐使用,缺少组件值
199
+ FormOptionsItem.prototype.oldDispatchOptionEvent = function (eventName, eventData) {
198
200
  if (eventData === void 0) { eventData = ''; }
199
201
  return tslib.__awaiter(this, void 0, void 0, function () {
200
202
  var _a, dispatchEvent, options, rendererEvent$1;
@@ -212,6 +214,23 @@ function registerOptionsControl(config) {
212
214
  });
213
215
  });
214
216
  };
217
+ FormOptionsItem.prototype.dispatchOptionEvent = function (eventName, eventData) {
218
+ if (eventData === void 0) { eventData = ''; }
219
+ return tslib.__awaiter(this, void 0, void 0, function () {
220
+ var _a, dispatchEvent, options, value, rendererEvent$1;
221
+ return tslib.__generator(this, function (_b) {
222
+ switch (_b.label) {
223
+ case 0:
224
+ _a = this.props, dispatchEvent = _a.dispatchEvent, options = _a.options, value = _a.value;
225
+ return [4 /*yield*/, dispatchEvent(eventName, rendererEvent.resolveEventData(this.props, tslib.__assign({ value: value, options: options, items: options }, eventData)))];
226
+ case 1:
227
+ rendererEvent$1 = _b.sent();
228
+ // 返回阻塞标识
229
+ return [2 /*return*/, !!(rendererEvent$1 === null || rendererEvent$1 === void 0 ? void 0 : rendererEvent$1.prevented)];
230
+ }
231
+ });
232
+ });
233
+ };
215
234
  FormOptionsItem.prototype.doAction = function (action, data, throwErrors) {
216
235
  var _a = this.props, resetValue = _a.resetValue, onChange = _a.onChange;
217
236
  var actionType = action === null || action === void 0 ? void 0 : action.actionType;
@@ -297,7 +316,9 @@ function registerOptionsControl(config) {
297
316
  return [2 /*return*/];
298
317
  }
299
318
  newValue = this.toggleValue(option, value);
300
- return [4 /*yield*/, this.dispatchOptionEvent('change', newValue)];
319
+ return [4 /*yield*/, this.dispatchOptionEvent('change', {
320
+ value: newValue
321
+ })];
301
322
  case 1:
302
323
  isPrevented = _b.sent();
303
324
  isPrevented ||
@@ -368,7 +389,9 @@ function registerOptionsControl(config) {
368
389
  ? []
369
390
  : formItem.filteredOptions.concat();
370
391
  newValue = this.formatValueArray(valueArray);
371
- return [4 /*yield*/, this.dispatchOptionEvent('change', newValue)];
392
+ return [4 /*yield*/, this.dispatchOptionEvent('change', {
393
+ value: newValue
394
+ })];
372
395
  case 1:
373
396
  isPrevented = _b.sent();
374
397
  isPrevented || (onChange && onChange(newValue));
@@ -451,7 +474,10 @@ function registerOptionsControl(config) {
451
474
  case 1:
452
475
  json = _b.sent();
453
476
  // 触发事件通知,加载完成
454
- this.dispatchOptionEvent('loadFinished', json);
477
+ // 废弃,不推荐使用
478
+ this.oldDispatchOptionEvent('loadFinished', json);
479
+ // 避免产生breakchange,增加新事件名,用来更正之前的设计问题
480
+ this.dispatchOptionEvent('deferLoadFinished', { result: json });
455
481
  return [2 /*return*/];
456
482
  }
457
483
  });
@@ -533,8 +559,9 @@ function registerOptionsControl(config) {
533
559
  if (idx === void 0) { idx = -1; }
534
560
  if (skipForm === void 0) { skipForm = false; }
535
561
  return tslib.__awaiter(this, void 0, void 0, function () {
536
- var _c, addControls, addDialog, disabled, labelField, onOpenDialog, optionLabel, addApi, source, data, valueField, deferField, model, createBtnLabel, env, __, parent, ctx, result, _d, payload, e_1, isPrevented, options;
562
+ var _c, addControls, addDialog, disabled, labelField, onOpenDialog, optionLabel, addApi, source, data, valueField, deferField, model, createBtnLabel, env, __, parent, ctx, customAddPrevent, result, _d, prevent, payload, e_1, isPrevented, options;
537
563
  var _e;
564
+ var _this = this;
538
565
  return tslib.__generator(this, function (_f) {
539
566
  switch (_f.label) {
540
567
  case 0:
@@ -560,6 +587,7 @@ function registerOptionsControl(config) {
560
587
  : undefined;
561
588
  ctx = object.createObject(data, Array.isArray(idx)
562
589
  ? tslib.__assign({ parent: parent }, value) : value);
590
+ customAddPrevent = false;
563
591
  if (!skipForm) return [3 /*break*/, 1];
564
592
  _d = ctx;
565
593
  return [3 /*break*/, 3];
@@ -577,21 +605,59 @@ function registerOptionsControl(config) {
577
605
  name: 'parent',
578
606
  value: parent
579
607
  }
580
- ], tslib.__read((addControls || [])), false)
608
+ ], tslib.__read((addControls || [])), false),
609
+ onSubmit: function (payload) { return tslib.__awaiter(_this, void 0, void 0, function () {
610
+ var labelKey, valueKey;
611
+ var _a;
612
+ var _b;
613
+ return tslib.__generator(this, function (_c) {
614
+ switch (_c.label) {
615
+ case 0:
616
+ labelKey = labelField || 'label';
617
+ valueKey = valueField || 'value';
618
+ return [4 /*yield*/, this.dispatchOptionEvent('addConfirm', {
619
+ item: (_a = {},
620
+ _a[labelKey] = payload[labelKey],
621
+ _a[valueKey] = (_b = payload[valueKey]) !== null && _b !== void 0 ? _b : payload[labelKey],
622
+ _a)
623
+ })];
624
+ case 1:
625
+ // 派发确认添加事件
626
+ customAddPrevent = _c.sent();
627
+ return [2 /*return*/, !customAddPrevent];
628
+ }
629
+ });
630
+ }); }
581
631
  } }), ctx)];
582
632
  case 2:
583
633
  _d = _f.sent();
584
634
  _f.label = 3;
585
635
  case 3:
586
636
  result = _d;
587
- if (!(skipForm && addApi)) return [3 /*break*/, 7];
588
- _f.label = 4;
637
+ if (!skipForm) return [3 /*break*/, 5];
638
+ return [4 /*yield*/, this.dispatchOptionEvent('addConfirm', {
639
+ item: result
640
+ })];
589
641
  case 4:
590
- _f.trys.push([4, 6, , 7]);
642
+ prevent = _f.sent();
643
+ if (prevent) {
644
+ return [2 /*return*/];
645
+ }
646
+ return [3 /*break*/, 6];
647
+ case 5:
648
+ if (customAddPrevent) {
649
+ return [2 /*return*/];
650
+ }
651
+ _f.label = 6;
652
+ case 6:
653
+ if (!(skipForm && addApi)) return [3 /*break*/, 10];
654
+ _f.label = 7;
655
+ case 7:
656
+ _f.trys.push([7, 9, , 10]);
591
657
  return [4 /*yield*/, env.fetcher(addApi, result, {
592
658
  method: 'post'
593
659
  })];
594
- case 5:
660
+ case 8:
595
661
  payload = _f.sent();
596
662
  if (!payload.ok) {
597
663
  !addApi.silent &&
@@ -601,14 +667,14 @@ function registerOptionsControl(config) {
601
667
  else {
602
668
  result = payload.data || result;
603
669
  }
604
- return [3 /*break*/, 7];
605
- case 6:
670
+ return [3 /*break*/, 10];
671
+ case 9:
606
672
  e_1 = _f.sent();
607
673
  result = null;
608
674
  console.error(e_1);
609
675
  !addApi.silent && env.notify('error', e_1.message);
610
- return [3 /*break*/, 7];
611
- case 7:
676
+ return [3 /*break*/, 10];
677
+ case 10:
612
678
  // 有 result 说明弹框点了确认。否则就是取消了。
613
679
  if (!result) {
614
680
  return [2 /*return*/];
@@ -617,19 +683,19 @@ function registerOptionsControl(config) {
617
683
  if (!result.hasOwnProperty(valueField || 'value')) {
618
684
  result = tslib.__assign(tslib.__assign({}, result), (_e = {}, _e[valueField || 'value'] = result[labelField || 'label'], _e));
619
685
  }
620
- return [4 /*yield*/, this.dispatchOptionEvent('add', tslib.__assign(tslib.__assign({}, result), { idx: idx }))];
621
- case 8:
686
+ return [4 /*yield*/, this.oldDispatchOptionEvent('add', tslib.__assign(tslib.__assign({}, result), { idx: idx }))];
687
+ case 11:
622
688
  isPrevented = _f.sent();
623
689
  if (isPrevented) {
624
690
  return [2 /*return*/];
625
691
  }
626
692
  if (!(((parent === null || parent === void 0 ? void 0 : parent.hasOwnProperty(deferField)) && parent[deferField]) ||
627
- (parent === null || parent === void 0 ? void 0 : parent.defer))) return [3 /*break*/, 10];
693
+ (parent === null || parent === void 0 ? void 0 : parent.defer))) return [3 /*break*/, 13];
628
694
  return [4 /*yield*/, this.deferLoad(parent)];
629
- case 9:
695
+ case 12:
630
696
  _f.sent();
631
- return [3 /*break*/, 11];
632
- case 10:
697
+ return [3 /*break*/, 14];
698
+ case 13:
633
699
  if (source && addApi) {
634
700
  // 如果配置了 source 且配置了 addApi 直接重新拉取接口就够了
635
701
  // 不能不判断 addApi 就刷新,因为有些场景就是临时添加的。
@@ -647,8 +713,8 @@ function registerOptionsControl(config) {
647
713
  }
648
714
  model.setOptions(options, this.changeOptionValue, data);
649
715
  }
650
- _f.label = 11;
651
- case 11: return [2 /*return*/];
716
+ _f.label = 14;
717
+ case 14: return [2 /*return*/];
652
718
  }
653
719
  });
654
720
  });
@@ -658,11 +724,12 @@ function registerOptionsControl(config) {
658
724
  if (origin === void 0) { origin = value; }
659
725
  if (skipForm === void 0) { skipForm = false; }
660
726
  return tslib.__awaiter(this, void 0, void 0, function () {
661
- var _c, editControls, editDialog, disabled, labelField, onOpenDialog, editApi, editInitApi, env, source, data, model, optionLabel, __, result, _d, payload, e_2, isPrevented, indexes;
727
+ var _c, editControls, editDialog, disabled, labelField, valueField, onOpenDialog, editApi, editInitApi, env, source, data, model, optionLabel, __, customEditPrevent, result, _d, prevent, payload, e_2, isPrevented, indexes;
728
+ var _this = this;
662
729
  return tslib.__generator(this, function (_e) {
663
730
  switch (_e.label) {
664
731
  case 0:
665
- _c = this.props, editControls = _c.editControls, editDialog = _c.editDialog, disabled = _c.disabled, labelField = _c.labelField, onOpenDialog = _c.onOpenDialog, editApi = _c.editApi, editInitApi = _c.editInitApi, env = _c.env, source = _c.source, data = _c.data, model = _c.formItem, optionLabel = _c.optionLabel, __ = _c.translate;
732
+ _c = this.props, editControls = _c.editControls, editDialog = _c.editDialog, disabled = _c.disabled, labelField = _c.labelField, valueField = _c.valueField, onOpenDialog = _c.onOpenDialog, editApi = _c.editApi, editInitApi = _c.editInitApi, env = _c.env, source = _c.source, data = _c.data, model = _c.formItem, optionLabel = _c.optionLabel, __ = _c.translate;
666
733
  if (disabled || !model) {
667
734
  return [2 /*return*/];
668
735
  }
@@ -676,6 +743,7 @@ function registerOptionsControl(config) {
676
743
  }
677
744
  ];
678
745
  }
746
+ customEditPrevent = false;
679
747
  if (!skipForm) return [3 /*break*/, 1];
680
748
  _d = value;
681
749
  return [3 /*break*/, 3];
@@ -685,21 +753,59 @@ function registerOptionsControl(config) {
685
753
  type: 'form',
686
754
  initApi: editInitApi,
687
755
  api: editApi,
688
- controls: editControls
756
+ controls: editControls,
757
+ onSubmit: function (payload) { return tslib.__awaiter(_this, void 0, void 0, function () {
758
+ var labelKey, valueKey;
759
+ var _a;
760
+ var _b;
761
+ return tslib.__generator(this, function (_c) {
762
+ switch (_c.label) {
763
+ case 0:
764
+ labelKey = labelField || 'label';
765
+ valueKey = valueField || 'value';
766
+ return [4 /*yield*/, this.dispatchOptionEvent('editConfirm', {
767
+ item: (_a = {},
768
+ _a[labelKey] = payload[labelKey],
769
+ _a[valueKey] = (_b = payload[valueKey]) !== null && _b !== void 0 ? _b : payload[labelKey],
770
+ _a)
771
+ })];
772
+ case 1:
773
+ // 避免产生breakchange,增加新事件名,用来更正之前的设计问题
774
+ customEditPrevent = _c.sent();
775
+ return [2 /*return*/, !customEditPrevent];
776
+ }
777
+ });
778
+ }); }
689
779
  } }), object.createObject(data, value))];
690
780
  case 2:
691
781
  _d = _e.sent();
692
782
  _e.label = 3;
693
783
  case 3:
694
784
  result = _d;
695
- if (!(skipForm && editApi)) return [3 /*break*/, 7];
696
- _e.label = 4;
785
+ if (!skipForm) return [3 /*break*/, 5];
786
+ return [4 /*yield*/, this.dispatchOptionEvent('editConfirm', {
787
+ item: result
788
+ })];
697
789
  case 4:
698
- _e.trys.push([4, 6, , 7]);
790
+ prevent = _e.sent();
791
+ if (prevent) {
792
+ return [2 /*return*/];
793
+ }
794
+ return [3 /*break*/, 6];
795
+ case 5:
796
+ if (customEditPrevent) {
797
+ return [2 /*return*/];
798
+ }
799
+ _e.label = 6;
800
+ case 6:
801
+ if (!(skipForm && editApi)) return [3 /*break*/, 10];
802
+ _e.label = 7;
803
+ case 7:
804
+ _e.trys.push([7, 9, , 10]);
699
805
  return [4 /*yield*/, env.fetcher(editApi, object.createObject(data, result), {
700
806
  method: 'post'
701
807
  })];
702
- case 5:
808
+ case 8:
703
809
  payload = _e.sent();
704
810
  if (!payload.ok) {
705
811
  !editApi.silent &&
@@ -709,20 +815,20 @@ function registerOptionsControl(config) {
709
815
  else {
710
816
  result = payload.data || result;
711
817
  }
712
- return [3 /*break*/, 7];
713
- case 6:
818
+ return [3 /*break*/, 10];
819
+ case 9:
714
820
  e_2 = _e.sent();
715
821
  result = null;
716
822
  console.error(e_2);
717
823
  !editApi.silent && env.notify('error', e_2.message);
718
- return [3 /*break*/, 7];
719
- case 7:
824
+ return [3 /*break*/, 10];
825
+ case 10:
720
826
  // 没有结果,说明取消了。
721
827
  if (!result) {
722
828
  return [2 /*return*/];
723
829
  }
724
- return [4 /*yield*/, this.dispatchOptionEvent('edit', result)];
725
- case 8:
830
+ return [4 /*yield*/, this.oldDispatchOptionEvent('edit', result)];
831
+ case 11:
726
832
  isPrevented = _e.sent();
727
833
  if (isPrevented) {
728
834
  return [2 /*return*/];
@@ -744,7 +850,7 @@ function registerOptionsControl(config) {
744
850
  FormOptionsItem.prototype.handleOptionDelete = function (value) {
745
851
  var _a, _b;
746
852
  return tslib.__awaiter(this, void 0, void 0, function () {
747
- var _c, deleteConfirmText, disabled, data, deleteApi, onDelete, env, model, source, valueField, __, ctx, confirmed, _d, isPrevented, result, options, indexes, e_3;
853
+ var _c, deleteConfirmText, disabled, data, deleteApi, onDelete, env, model, source, valueField, __, ctx, confirmed, _d, isPrevented, delConfirmPrevent, result, options, indexes, e_3;
748
854
  return tslib.__generator(this, function (_e) {
749
855
  switch (_e.label) {
750
856
  case 0:
@@ -766,28 +872,36 @@ function registerOptionsControl(config) {
766
872
  if (!confirmed) {
767
873
  return [2 /*return*/];
768
874
  }
769
- return [4 /*yield*/, this.dispatchOptionEvent('delete', ctx)];
875
+ return [4 /*yield*/, this.oldDispatchOptionEvent('delete', ctx)];
770
876
  case 4:
771
877
  isPrevented = _e.sent();
772
878
  if (isPrevented) {
773
879
  return [2 /*return*/];
774
880
  }
775
- _e.label = 5;
881
+ return [4 /*yield*/, this.dispatchOptionEvent('deleteConfirm', {
882
+ item: value
883
+ })];
776
884
  case 5:
777
- _e.trys.push([5, 8, , 9]);
778
- if (!deleteApi) return [3 /*break*/, 7];
885
+ delConfirmPrevent = _e.sent();
886
+ if (delConfirmPrevent) {
887
+ return [2 /*return*/];
888
+ }
889
+ _e.label = 6;
890
+ case 6:
891
+ _e.trys.push([6, 9, , 10]);
892
+ if (!deleteApi) return [3 /*break*/, 8];
779
893
  return [4 /*yield*/, env.fetcher(deleteApi, ctx, {
780
894
  method: 'delete'
781
895
  })];
782
- case 6:
896
+ case 7:
783
897
  result = _e.sent();
784
898
  if (!result.ok) {
785
899
  !deleteApi.silent &&
786
900
  env.notify('error', (_b = (_a = deleteApi === null || deleteApi === void 0 ? void 0 : deleteApi.messages) === null || _a === void 0 ? void 0 : _a.failed) !== null && _b !== void 0 ? _b : (result.msg || __('deleteFailed')));
787
901
  return [2 /*return*/];
788
902
  }
789
- _e.label = 7;
790
- case 7:
903
+ _e.label = 8;
904
+ case 8:
791
905
  // 由外部代码实现删除逻辑
792
906
  if (onDelete) {
793
907
  onDelete(ctx);
@@ -802,13 +916,13 @@ function registerOptionsControl(config) {
802
916
  model.setOptions(helper.spliceTree(options, indexes, 1), this.changeOptionValue, data);
803
917
  }
804
918
  }
805
- return [3 /*break*/, 9];
806
- case 8:
919
+ return [3 /*break*/, 10];
920
+ case 9:
807
921
  e_3 = _e.sent();
808
922
  console.error(e_3);
809
923
  !deleteApi.silent && env.notify('error', e_3.message);
810
- return [3 /*break*/, 9];
811
- case 9: return [2 /*return*/];
924
+ return [3 /*break*/, 10];
925
+ case 10: return [2 /*return*/];
812
926
  }
813
927
  });
814
928
  });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.2
2
+ * amis-core v6.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.2
2
+ * amis-core v6.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.2
2
+ * amis-core v6.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.2
2
+ * amis-core v6.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -23,12 +23,13 @@ var WithRootStore = require('../WithRootStore.js');
23
23
  var table = require('../store/table.js');
24
24
  var pick = require('lodash/pick');
25
25
  var api = require('../utils/api.js');
26
+ require('../utils/browser.js');
26
27
  require('../utils/ColorScale.js');
27
28
  require('../utils/columnsSplit.js');
29
+ var getVariable = require('../utils/getVariable.js');
30
+ require('lodash/isPlainObject');
28
31
  require('amis-formula');
29
32
  var tokenize = require('../utils/tokenize.js');
30
- require('lodash/isPlainObject');
31
- var getVariable = require('../utils/getVariable.js');
32
33
  require('../utils/DataSchema.js');
33
34
  require('../utils/DataScope.js');
34
35
  require('moment');
@@ -52,7 +52,7 @@ export declare const AppStore: import("mobx-state-tree").IModelType<{
52
52
  setTopStore(value: any): void;
53
53
  initData(data?: object, skipSetPristine?: boolean): void;
54
54
  reset(): void;
55
- updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined): void;
55
+ updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined, concatFields?: string | string[] | undefined): void;
56
56
  changeValue(name: string, value: any, changePristine?: boolean | undefined, force?: boolean | undefined, otherModifier?: ((data: Object) => void) | undefined): void;
57
57
  setCurrentAction(action: object): void;
58
58
  openDialog(ctx: any, additonal?: object | undefined, callback?: ((ret: any) => void) | undefined, scoped?: import("..").IScopedContext | undefined): void;
@@ -69,7 +69,7 @@ export declare const AppStore: import("mobx-state-tree").IModelType<{
69
69
  markBusying: (busying?: boolean) => void;
70
70
  fetchInitData: (api: import("../types").Api, data?: object | undefined, options?: import("../types").fetchOptions | undefined) => Promise<any>;
71
71
  fetchData: (api: import("../types").Api, data?: object | undefined, options?: import("../types").fetchOptions | undefined) => Promise<any>;
72
- reInitData: (data: object | undefined, replace?: boolean) => void;
72
+ reInitData: (data: object | undefined, replace?: boolean, concatFields?: string | string[] | undefined) => void;
73
73
  updateMessage: (msg?: string | undefined, error?: boolean) => void;
74
74
  clearMessage: () => void;
75
75
  setHasRemoteData: () => void;
package/lib/store/app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.2
2
+ * amis-core v6.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -12,11 +12,12 @@ var mobxStateTree = require('mobx-state-tree');
12
12
  var helper = require('../utils/helper.js');
13
13
  var service = require('./service.js');
14
14
  require('../utils/api.js');
15
+ require('../utils/browser.js');
15
16
  require('../utils/ColorScale.js');
16
17
  require('../utils/columnsSplit.js');
18
+ var object = require('../utils/object.js');
17
19
  require('amis-formula');
18
20
  require('lodash/isPlainObject');
19
- var object = require('../utils/object.js');
20
21
  require('../utils/DataSchema.js');
21
22
  require('../utils/DataScope.js');
22
23
  require('moment');
@@ -2106,7 +2106,7 @@ export declare const ComboStore: import("mobx-state-tree").IModelType<{
2106
2106
  setTopStore(value: any): void;
2107
2107
  initData(data?: object, skipSetPristine?: boolean): void;
2108
2108
  reset(): void;
2109
- updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined): void;
2109
+ updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined, concatFields?: string | string[] | undefined): void;
2110
2110
  changeValue(name: string, value: any, changePristine?: boolean | undefined, force?: boolean | undefined, otherModifier?: ((data: Object) => void) | undefined): void;
2111
2111
  setCurrentAction(action: object): void;
2112
2112
  openDialog(ctx: any, additonal?: object | undefined, callback?: ((ret: any) => void) | undefined, scoped?: import("..").IScopedContext | undefined): void;
@@ -2168,7 +2168,7 @@ export declare const ComboStore: import("mobx-state-tree").IModelType<{
2168
2168
  setTopStore(value: any): void;
2169
2169
  initData(data?: object, skipSetPristine?: boolean): void;
2170
2170
  reset(): void;
2171
- updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined): void;
2171
+ updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined, concatFields?: string | string[] | undefined): void;
2172
2172
  changeValue(name: string, value: any, changePristine?: boolean | undefined, force?: boolean | undefined, otherModifier?: ((data: Object) => void) | undefined): void;
2173
2173
  setCurrentAction(action: object): void;
2174
2174
  openDialog(ctx: any, additonal?: object | undefined, callback?: ((ret: any) => void) | undefined, scoped?: import("..").IScopedContext | undefined): void;
@@ -2185,7 +2185,7 @@ export declare const ComboStore: import("mobx-state-tree").IModelType<{
2185
2185
  markBusying: (busying?: boolean) => void;
2186
2186
  fetchInitData: (api: import("..").Api, data?: object | undefined, options?: import("..").fetchOptions | undefined) => Promise<any>;
2187
2187
  fetchData: (api: import("..").Api, data?: object | undefined, options?: import("..").fetchOptions | undefined) => Promise<any>;
2188
- reInitData: (data: object | undefined, replace?: boolean) => void;
2188
+ reInitData: (data: object | undefined, replace?: boolean, concatFields?: string | string[] | undefined) => void;
2189
2189
  updateMessage: (msg?: string | undefined, error?: boolean) => void;
2190
2190
  clearMessage: () => void;
2191
2191
  setHasRemoteData: () => void;
@@ -7316,7 +7316,7 @@ export declare const ComboStore: import("mobx-state-tree").IModelType<{
7316
7316
  readonly persistKey: string;
7317
7317
  } & {
7318
7318
  setInited: (value: boolean) => void;
7319
- setValues: (values: object, tag?: object | undefined, replace?: boolean | undefined) => void;
7319
+ setValues: (values: object, tag?: object | undefined, replace?: boolean | undefined, concatFields?: string | string[] | undefined) => void;
7320
7320
  setValueByName: (name: string, value: any, isPristine?: boolean, force?: boolean) => void;
7321
7321
  trimValues: () => void;
7322
7322
  submit: (fn?: ((values: object) => Promise<any>) | undefined, hooks?: (() => Promise<any>)[] | undefined, failedMessage?: string | undefined, validateErrCb?: (() => void) | undefined, throwErrors?: boolean | undefined) => Promise<any>;
@@ -7402,7 +7402,7 @@ export declare const ComboStore: import("mobx-state-tree").IModelType<{
7402
7402
  setTopStore(value: any): void;
7403
7403
  initData(data?: object, skipSetPristine?: boolean): void;
7404
7404
  reset(): void;
7405
- updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined): void;
7405
+ updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined, concatFields?: string | string[] | undefined): void;
7406
7406
  changeValue(name: string, value: any, changePristine?: boolean | undefined, force?: boolean | undefined, otherModifier?: ((data: Object) => void) | undefined): void;
7407
7407
  setCurrentAction(action: object): void;
7408
7408
  openDialog(ctx: any, additonal?: object | undefined, callback?: ((ret: any) => void) | undefined, scoped?: import("..").IScopedContext | undefined): void;
@@ -7419,7 +7419,7 @@ export declare const ComboStore: import("mobx-state-tree").IModelType<{
7419
7419
  markBusying: (busying?: boolean) => void;
7420
7420
  fetchInitData: (api: import("..").Api, data?: object | undefined, options?: import("..").fetchOptions | undefined) => Promise<any>;
7421
7421
  fetchData: (api: import("..").Api, data?: object | undefined, options?: import("..").fetchOptions | undefined) => Promise<any>;
7422
- reInitData: (data: object | undefined, replace?: boolean) => void;
7422
+ reInitData: (data: object | undefined, replace?: boolean, concatFields?: string | string[] | undefined) => void;
7423
7423
  updateMessage: (msg?: string | undefined, error?: boolean) => void;
7424
7424
  clearMessage: () => void;
7425
7425
  setHasRemoteData: () => void;
@@ -12550,7 +12550,7 @@ export declare const ComboStore: import("mobx-state-tree").IModelType<{
12550
12550
  readonly persistKey: string;
12551
12551
  } & {
12552
12552
  setInited: (value: boolean) => void;
12553
- setValues: (values: object, tag?: object | undefined, replace?: boolean | undefined) => void;
12553
+ setValues: (values: object, tag?: object | undefined, replace?: boolean | undefined, concatFields?: string | string[] | undefined) => void;
12554
12554
  setValueByName: (name: string, value: any, isPristine?: boolean, force?: boolean) => void;
12555
12555
  trimValues: () => void;
12556
12556
  submit: (fn?: ((values: object) => Promise<any>) | undefined, hooks?: (() => Promise<any>)[] | undefined, failedMessage?: string | undefined, validateErrCb?: (() => void) | undefined, throwErrors?: boolean | undefined) => Promise<any>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.2
2
+ * amis-core v6.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -77,7 +77,7 @@ export declare const CRUDStore: import("mobx-state-tree").IModelType<{
77
77
  setTopStore(value: any): void;
78
78
  initData(data?: object, skipSetPristine?: boolean): void;
79
79
  reset(): void;
80
- updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined): void;
80
+ updateData(data?: object, tag?: object | undefined, replace?: boolean | undefined, concatFields?: string | string[] | undefined): void;
81
81
  changeValue(name: string, value: any, changePristine?: boolean | undefined, force?: boolean | undefined, otherModifier?: ((data: Object) => void) | undefined): void;
82
82
  setCurrentAction(action: object): void;
83
83
  openDialog(ctx: any, additonal?: object | undefined, callback?: ((ret: any) => void) | undefined, scoped?: import("..").IScopedContext | undefined): void;
@@ -94,7 +94,7 @@ export declare const CRUDStore: import("mobx-state-tree").IModelType<{
94
94
  markBusying: (busying?: boolean) => void;
95
95
  fetchInitData: (api: Api, data?: object | undefined, options?: fetchOptions | undefined) => Promise<any>;
96
96
  fetchData: (api: Api, data?: object | undefined, options?: fetchOptions | undefined) => Promise<any>;
97
- reInitData: (data: object | undefined, replace?: boolean) => void;
97
+ reInitData: (data: object | undefined, replace?: boolean, concatFields?: string | string[] | undefined) => void;
98
98
  updateMessage: (msg?: string | undefined, error?: boolean) => void;
99
99
  clearMessage: () => void;
100
100
  setHasRemoteData: () => void;
@@ -149,6 +149,7 @@ export declare const CRUDStore: import("mobx-state-tree").IModelType<{
149
149
  }) => Promise<void>;
150
150
  updateColumns: (columns: Array<any>) => void;
151
151
  updateTotal: (total: number) => void;
152
+ resetSelection: () => void;
152
153
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
153
154
  export type ICRUDStore = Instance<typeof CRUDStore>;
154
155
  export {};