amis-core 3.6.3 → 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 (286) 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.js +3 -2
  30. package/esm/components/PopOver.js +3 -2
  31. package/esm/env.js +1 -1
  32. package/esm/envOverwrite.js +1 -1
  33. package/esm/factory.js +1 -1
  34. package/esm/index.js +4 -2
  35. package/esm/locale.js +1 -1
  36. package/esm/polyfills.js +1 -1
  37. package/esm/renderers/Form.js +125 -111
  38. package/esm/renderers/Item.js +4 -3
  39. package/esm/renderers/Options.js +163 -49
  40. package/esm/renderers/Placeholder.js +1 -1
  41. package/esm/renderers/builtin.js +1 -1
  42. package/esm/renderers/register.js +1 -1
  43. package/esm/renderers/wrapControl.js +4 -3
  44. package/esm/store/app.d.ts +2 -2
  45. package/esm/store/app.js +3 -2
  46. package/esm/store/combo.d.ts +7 -7
  47. package/esm/store/combo.js +1 -1
  48. package/esm/store/crud.d.ts +3 -2
  49. package/esm/store/crud.js +18 -4
  50. package/esm/store/form.d.ts +3 -3
  51. package/esm/store/form.js +5 -5
  52. package/esm/store/formItem.js +1 -1
  53. package/esm/store/iRenderer.d.ts +1 -1
  54. package/esm/store/iRenderer.js +7 -2
  55. package/esm/store/index.js +1 -1
  56. package/esm/store/list.d.ts +1 -1
  57. package/esm/store/list.js +18 -13
  58. package/esm/store/manager.js +1 -1
  59. package/esm/store/modal.d.ts +2 -2
  60. package/esm/store/modal.js +1 -1
  61. package/esm/store/node.js +1 -1
  62. package/esm/store/pagination.d.ts +2 -1
  63. package/esm/store/pagination.js +3 -2
  64. package/esm/store/root.d.ts +2 -2
  65. package/esm/store/root.js +3 -2
  66. package/esm/store/service.d.ts +2 -2
  67. package/esm/store/service.js +11 -7
  68. package/esm/store/status.js +1 -1
  69. package/esm/store/table.d.ts +7 -7
  70. package/esm/store/table.js +26 -11
  71. package/esm/store/table2.d.ts +14 -3
  72. package/esm/store/table2.js +22 -9
  73. package/esm/theme.js +1 -1
  74. package/esm/types.d.ts +7 -0
  75. package/esm/utils/Animation.js +1 -1
  76. package/esm/utils/ColorScale.js +1 -1
  77. package/esm/utils/DataSchema.js +1 -1
  78. package/esm/utils/DataScope.js +1 -1
  79. package/esm/utils/RootClose.js +1 -1
  80. package/esm/utils/SimpleMap.js +1 -1
  81. package/esm/utils/api.js +1 -1
  82. package/esm/utils/arraySlice.js +1 -1
  83. package/esm/utils/attachmentAdpator.js +1 -1
  84. package/esm/utils/autobind.js +1 -1
  85. package/esm/utils/browser.d.ts +1 -0
  86. package/esm/utils/browser.js +11 -0
  87. package/esm/utils/columnsSplit.js +1 -1
  88. package/esm/utils/concatData.d.ts +8 -0
  89. package/esm/utils/concatData.js +39 -0
  90. package/esm/utils/dataMapping.js +1 -1
  91. package/esm/utils/date.js +1 -1
  92. package/esm/utils/debug.js +1 -1
  93. package/esm/utils/decodeEntity.js +1 -1
  94. package/esm/utils/dom.js +1 -1
  95. package/esm/utils/errors.js +1 -1
  96. package/esm/utils/escapeHtml.js +1 -1
  97. package/esm/utils/filter-schema.js +1 -1
  98. package/esm/utils/filter.js +1 -1
  99. package/esm/utils/formatDuration.js +1 -1
  100. package/esm/utils/formula.js +1 -1
  101. package/esm/utils/getVariable.js +1 -1
  102. package/esm/utils/grammar.js +1 -1
  103. package/esm/utils/handleAction.js +1 -1
  104. package/esm/utils/helper.d.ts +6 -1
  105. package/esm/utils/helper.js +23 -6
  106. package/esm/utils/highlight.js +1 -1
  107. package/esm/utils/icon.js +1 -1
  108. package/esm/utils/image.js +1 -1
  109. package/esm/utils/index.d.ts +2 -0
  110. package/esm/utils/isPureVariable.js +1 -1
  111. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  112. package/esm/utils/keyToPath.js +1 -1
  113. package/esm/utils/makeSorter.js +1 -1
  114. package/esm/utils/math.js +1 -1
  115. package/esm/utils/memoryParse.js +1 -1
  116. package/esm/utils/normalizeLink.js +1 -1
  117. package/esm/utils/normalizeOptions.js +1 -1
  118. package/esm/utils/object.js +1 -1
  119. package/esm/utils/offset.js +1 -1
  120. package/esm/utils/offsetParent.js +1 -1
  121. package/esm/utils/optionValueCompare.js +1 -1
  122. package/esm/utils/position.js +1 -1
  123. package/esm/utils/prettyBytes.js +1 -1
  124. package/esm/utils/renderer-event.js +19 -3
  125. package/esm/utils/replaceText.js +1 -1
  126. package/esm/utils/resize-sensor.js +1 -1
  127. package/esm/utils/resolveCondition.js +1 -1
  128. package/esm/utils/resolveVariable.js +1 -1
  129. package/esm/utils/resolveVariableAndFilter.js +1 -1
  130. package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
  131. package/esm/utils/scrollPosition.js +1 -1
  132. package/esm/utils/string2regExp.js +1 -1
  133. package/esm/utils/stripNumber.js +1 -1
  134. package/esm/utils/style-helper.js +4 -6
  135. package/esm/utils/style.js +1 -1
  136. package/esm/utils/toNumber.js +1 -1
  137. package/esm/utils/tokenize.js +1 -1
  138. package/esm/utils/tpl-builtin.js +1 -1
  139. package/esm/utils/tpl-lodash.js +1 -1
  140. package/esm/utils/tpl.js +1 -1
  141. package/esm/utils/uncontrollable.js +1 -1
  142. package/esm/utils/validations.js +1 -1
  143. package/lib/Root.js +1 -1
  144. package/lib/RootRenderer.d.ts +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.js +3 -2
  173. package/lib/components/PopOver.js +3 -2
  174. package/lib/env.js +1 -1
  175. package/lib/envOverwrite.js +1 -1
  176. package/lib/factory.js +1 -1
  177. package/lib/index.js +6 -2
  178. package/lib/locale.js +1 -1
  179. package/lib/polyfills.js +1 -1
  180. package/lib/renderers/Form.js +125 -111
  181. package/lib/renderers/Item.js +4 -3
  182. package/lib/renderers/Options.js +163 -49
  183. package/lib/renderers/Placeholder.js +1 -1
  184. package/lib/renderers/builtin.js +1 -1
  185. package/lib/renderers/register.js +1 -1
  186. package/lib/renderers/wrapControl.js +4 -3
  187. package/lib/store/app.d.ts +2 -2
  188. package/lib/store/app.js +3 -2
  189. package/lib/store/combo.d.ts +31 -31
  190. package/lib/store/combo.js +1 -1
  191. package/lib/store/crud.d.ts +3 -2
  192. package/lib/store/crud.js +18 -4
  193. package/lib/store/form.d.ts +13 -13
  194. package/lib/store/form.js +5 -5
  195. package/lib/store/formItem.js +1 -1
  196. package/lib/store/iRenderer.d.ts +1 -1
  197. package/lib/store/iRenderer.js +7 -2
  198. package/lib/store/index.js +1 -1
  199. package/lib/store/list.d.ts +1 -1
  200. package/lib/store/list.js +18 -14
  201. package/lib/store/manager.js +1 -1
  202. package/lib/store/modal.d.ts +2 -2
  203. package/lib/store/modal.js +1 -1
  204. package/lib/store/node.js +1 -1
  205. package/lib/store/pagination.d.ts +2 -1
  206. package/lib/store/pagination.js +3 -2
  207. package/lib/store/root.d.ts +2 -2
  208. package/lib/store/root.js +3 -2
  209. package/lib/store/service.d.ts +2 -2
  210. package/lib/store/service.js +11 -7
  211. package/lib/store/status.js +1 -1
  212. package/lib/store/table.d.ts +27 -27
  213. package/lib/store/table.js +26 -12
  214. package/lib/store/table2.d.ts +14 -3
  215. package/lib/store/table2.js +22 -9
  216. package/lib/theme.js +1 -1
  217. package/lib/types.d.ts +7 -0
  218. package/lib/utils/Animation.js +1 -1
  219. package/lib/utils/ColorScale.js +1 -1
  220. package/lib/utils/DataSchema.js +1 -1
  221. package/lib/utils/DataScope.js +1 -1
  222. package/lib/utils/RootClose.js +1 -1
  223. package/lib/utils/SimpleMap.js +1 -1
  224. package/lib/utils/api.js +1 -1
  225. package/lib/utils/arraySlice.js +1 -1
  226. package/lib/utils/attachmentAdpator.js +1 -1
  227. package/lib/utils/autobind.js +1 -1
  228. package/lib/utils/browser.d.ts +1 -0
  229. package/lib/utils/browser.js +15 -0
  230. package/lib/utils/columnsSplit.js +1 -1
  231. package/lib/utils/concatData.d.ts +8 -0
  232. package/lib/utils/concatData.js +43 -0
  233. package/lib/utils/dataMapping.js +1 -1
  234. package/lib/utils/date.js +1 -1
  235. package/lib/utils/debug.js +1 -1
  236. package/lib/utils/decodeEntity.js +1 -1
  237. package/lib/utils/dom.js +1 -1
  238. package/lib/utils/errors.js +1 -1
  239. package/lib/utils/escapeHtml.js +1 -1
  240. package/lib/utils/filter-schema.js +1 -1
  241. package/lib/utils/filter.js +1 -1
  242. package/lib/utils/formatDuration.js +1 -1
  243. package/lib/utils/formula.js +1 -1
  244. package/lib/utils/getVariable.js +1 -1
  245. package/lib/utils/grammar.js +1 -1
  246. package/lib/utils/handleAction.js +1 -1
  247. package/lib/utils/helper.d.ts +6 -1
  248. package/lib/utils/helper.js +23 -6
  249. package/lib/utils/highlight.js +1 -1
  250. package/lib/utils/icon.js +1 -1
  251. package/lib/utils/image.js +1 -1
  252. package/lib/utils/index.d.ts +2 -0
  253. package/lib/utils/isPureVariable.js +1 -1
  254. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  255. package/lib/utils/keyToPath.js +1 -1
  256. package/lib/utils/makeSorter.js +1 -1
  257. package/lib/utils/math.js +1 -1
  258. package/lib/utils/memoryParse.js +1 -1
  259. package/lib/utils/normalizeLink.js +1 -1
  260. package/lib/utils/normalizeOptions.js +1 -1
  261. package/lib/utils/object.js +1 -1
  262. package/lib/utils/offset.js +1 -1
  263. package/lib/utils/offsetParent.js +1 -1
  264. package/lib/utils/optionValueCompare.js +1 -1
  265. package/lib/utils/position.js +1 -1
  266. package/lib/utils/prettyBytes.js +1 -1
  267. package/lib/utils/renderer-event.js +19 -3
  268. package/lib/utils/replaceText.js +1 -1
  269. package/lib/utils/resize-sensor.js +1 -1
  270. package/lib/utils/resolveCondition.js +1 -1
  271. package/lib/utils/resolveVariable.js +1 -1
  272. package/lib/utils/resolveVariableAndFilter.js +1 -1
  273. package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
  274. package/lib/utils/scrollPosition.js +1 -1
  275. package/lib/utils/string2regExp.js +1 -1
  276. package/lib/utils/stripNumber.js +1 -1
  277. package/lib/utils/style-helper.js +4 -6
  278. package/lib/utils/style.js +1 -1
  279. package/lib/utils/toNumber.js +1 -1
  280. package/lib/utils/tokenize.js +1 -1
  281. package/lib/utils/tpl-builtin.js +1 -1
  282. package/lib/utils/tpl-lodash.js +1 -1
  283. package/lib/utils/tpl.js +1 -1
  284. package/lib/utils/uncontrollable.js +1 -1
  285. package/lib/utils/validations.js +1 -1
  286. package/package.json +4 -3
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.3
2
+ * amis-core v6.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -23,6 +23,7 @@ import findIndex from 'lodash/findIndex';
23
23
  import isPlainObject from 'lodash/isPlainObject';
24
24
  import { normalizeOptions } from '../utils/normalizeOptions.js';
25
25
  import { optionValueCompare } from '../utils/optionValueCompare.js';
26
+ import '../utils/browser.js';
26
27
  import '../utils/ColorScale.js';
27
28
  import 'lodash/chunk';
28
29
  import '../utils/DataSchema.js';
@@ -144,7 +145,7 @@ function registerOptionsControl(config) {
144
145
  var _this = this;
145
146
  var props = this.props;
146
147
  var formItem = props.formItem;
147
- if (prevProps.options !== props.options && formItem) {
148
+ if (!props.source && prevProps.options !== props.options && formItem) {
148
149
  formItem.setOptions(normalizeOptions(props.options || [], undefined, props.valueField), this.changeOptionValue, props.data);
149
150
  this.normalizeValue();
150
151
  }
@@ -178,7 +179,8 @@ function registerOptionsControl(config) {
178
179
  this.toDispose.forEach(function (fn) { return fn(); });
179
180
  this.toDispose = [];
180
181
  };
181
- FormOptionsItem.prototype.dispatchOptionEvent = function (eventName, eventData) {
182
+ // 不推荐使用,缺少组件值
183
+ FormOptionsItem.prototype.oldDispatchOptionEvent = function (eventName, eventData) {
182
184
  if (eventData === void 0) { eventData = ''; }
183
185
  return __awaiter(this, void 0, void 0, function () {
184
186
  var _a, dispatchEvent, options, rendererEvent;
@@ -196,6 +198,23 @@ function registerOptionsControl(config) {
196
198
  });
197
199
  });
198
200
  };
201
+ FormOptionsItem.prototype.dispatchOptionEvent = function (eventName, eventData) {
202
+ if (eventData === void 0) { eventData = ''; }
203
+ return __awaiter(this, void 0, void 0, function () {
204
+ var _a, dispatchEvent, options, value, rendererEvent;
205
+ return __generator(this, function (_b) {
206
+ switch (_b.label) {
207
+ case 0:
208
+ _a = this.props, dispatchEvent = _a.dispatchEvent, options = _a.options, value = _a.value;
209
+ return [4 /*yield*/, dispatchEvent(eventName, resolveEventData(this.props, __assign({ value: value, options: options, items: options }, eventData)))];
210
+ case 1:
211
+ rendererEvent = _b.sent();
212
+ // 返回阻塞标识
213
+ return [2 /*return*/, !!(rendererEvent === null || rendererEvent === void 0 ? void 0 : rendererEvent.prevented)];
214
+ }
215
+ });
216
+ });
217
+ };
199
218
  FormOptionsItem.prototype.doAction = function (action, data, throwErrors) {
200
219
  var _a = this.props, resetValue = _a.resetValue, onChange = _a.onChange;
201
220
  var actionType = action === null || action === void 0 ? void 0 : action.actionType;
@@ -281,7 +300,9 @@ function registerOptionsControl(config) {
281
300
  return [2 /*return*/];
282
301
  }
283
302
  newValue = this.toggleValue(option, value);
284
- return [4 /*yield*/, this.dispatchOptionEvent('change', newValue)];
303
+ return [4 /*yield*/, this.dispatchOptionEvent('change', {
304
+ value: newValue
305
+ })];
285
306
  case 1:
286
307
  isPrevented = _b.sent();
287
308
  isPrevented ||
@@ -352,7 +373,9 @@ function registerOptionsControl(config) {
352
373
  ? []
353
374
  : formItem.filteredOptions.concat();
354
375
  newValue = this.formatValueArray(valueArray);
355
- return [4 /*yield*/, this.dispatchOptionEvent('change', newValue)];
376
+ return [4 /*yield*/, this.dispatchOptionEvent('change', {
377
+ value: newValue
378
+ })];
356
379
  case 1:
357
380
  isPrevented = _b.sent();
358
381
  isPrevented || (onChange && onChange(newValue));
@@ -435,7 +458,10 @@ function registerOptionsControl(config) {
435
458
  case 1:
436
459
  json = _b.sent();
437
460
  // 触发事件通知,加载完成
438
- this.dispatchOptionEvent('loadFinished', json);
461
+ // 废弃,不推荐使用
462
+ this.oldDispatchOptionEvent('loadFinished', json);
463
+ // 避免产生breakchange,增加新事件名,用来更正之前的设计问题
464
+ this.dispatchOptionEvent('deferLoadFinished', { result: json });
439
465
  return [2 /*return*/];
440
466
  }
441
467
  });
@@ -517,8 +543,9 @@ function registerOptionsControl(config) {
517
543
  if (idx === void 0) { idx = -1; }
518
544
  if (skipForm === void 0) { skipForm = false; }
519
545
  return __awaiter(this, void 0, void 0, function () {
520
- 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;
546
+ 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;
521
547
  var _e;
548
+ var _this = this;
522
549
  return __generator(this, function (_f) {
523
550
  switch (_f.label) {
524
551
  case 0:
@@ -544,6 +571,7 @@ function registerOptionsControl(config) {
544
571
  : undefined;
545
572
  ctx = createObject(data, Array.isArray(idx)
546
573
  ? __assign({ parent: parent }, value) : value);
574
+ customAddPrevent = false;
547
575
  if (!skipForm) return [3 /*break*/, 1];
548
576
  _d = ctx;
549
577
  return [3 /*break*/, 3];
@@ -561,21 +589,59 @@ function registerOptionsControl(config) {
561
589
  name: 'parent',
562
590
  value: parent
563
591
  }
564
- ], __read((addControls || [])), false)
592
+ ], __read((addControls || [])), false),
593
+ onSubmit: function (payload) { return __awaiter(_this, void 0, void 0, function () {
594
+ var labelKey, valueKey;
595
+ var _a;
596
+ var _b;
597
+ return __generator(this, function (_c) {
598
+ switch (_c.label) {
599
+ case 0:
600
+ labelKey = labelField || 'label';
601
+ valueKey = valueField || 'value';
602
+ return [4 /*yield*/, this.dispatchOptionEvent('addConfirm', {
603
+ item: (_a = {},
604
+ _a[labelKey] = payload[labelKey],
605
+ _a[valueKey] = (_b = payload[valueKey]) !== null && _b !== void 0 ? _b : payload[labelKey],
606
+ _a)
607
+ })];
608
+ case 1:
609
+ // 派发确认添加事件
610
+ customAddPrevent = _c.sent();
611
+ return [2 /*return*/, !customAddPrevent];
612
+ }
613
+ });
614
+ }); }
565
615
  } }), ctx)];
566
616
  case 2:
567
617
  _d = _f.sent();
568
618
  _f.label = 3;
569
619
  case 3:
570
620
  result = _d;
571
- if (!(skipForm && addApi)) return [3 /*break*/, 7];
572
- _f.label = 4;
621
+ if (!skipForm) return [3 /*break*/, 5];
622
+ return [4 /*yield*/, this.dispatchOptionEvent('addConfirm', {
623
+ item: result
624
+ })];
573
625
  case 4:
574
- _f.trys.push([4, 6, , 7]);
626
+ prevent = _f.sent();
627
+ if (prevent) {
628
+ return [2 /*return*/];
629
+ }
630
+ return [3 /*break*/, 6];
631
+ case 5:
632
+ if (customAddPrevent) {
633
+ return [2 /*return*/];
634
+ }
635
+ _f.label = 6;
636
+ case 6:
637
+ if (!(skipForm && addApi)) return [3 /*break*/, 10];
638
+ _f.label = 7;
639
+ case 7:
640
+ _f.trys.push([7, 9, , 10]);
575
641
  return [4 /*yield*/, env.fetcher(addApi, result, {
576
642
  method: 'post'
577
643
  })];
578
- case 5:
644
+ case 8:
579
645
  payload = _f.sent();
580
646
  if (!payload.ok) {
581
647
  !addApi.silent &&
@@ -585,14 +651,14 @@ function registerOptionsControl(config) {
585
651
  else {
586
652
  result = payload.data || result;
587
653
  }
588
- return [3 /*break*/, 7];
589
- case 6:
654
+ return [3 /*break*/, 10];
655
+ case 9:
590
656
  e_1 = _f.sent();
591
657
  result = null;
592
658
  console.error(e_1);
593
659
  !addApi.silent && env.notify('error', e_1.message);
594
- return [3 /*break*/, 7];
595
- case 7:
660
+ return [3 /*break*/, 10];
661
+ case 10:
596
662
  // 有 result 说明弹框点了确认。否则就是取消了。
597
663
  if (!result) {
598
664
  return [2 /*return*/];
@@ -601,19 +667,19 @@ function registerOptionsControl(config) {
601
667
  if (!result.hasOwnProperty(valueField || 'value')) {
602
668
  result = __assign(__assign({}, result), (_e = {}, _e[valueField || 'value'] = result[labelField || 'label'], _e));
603
669
  }
604
- return [4 /*yield*/, this.dispatchOptionEvent('add', __assign(__assign({}, result), { idx: idx }))];
605
- case 8:
670
+ return [4 /*yield*/, this.oldDispatchOptionEvent('add', __assign(__assign({}, result), { idx: idx }))];
671
+ case 11:
606
672
  isPrevented = _f.sent();
607
673
  if (isPrevented) {
608
674
  return [2 /*return*/];
609
675
  }
610
676
  if (!(((parent === null || parent === void 0 ? void 0 : parent.hasOwnProperty(deferField)) && parent[deferField]) ||
611
- (parent === null || parent === void 0 ? void 0 : parent.defer))) return [3 /*break*/, 10];
677
+ (parent === null || parent === void 0 ? void 0 : parent.defer))) return [3 /*break*/, 13];
612
678
  return [4 /*yield*/, this.deferLoad(parent)];
613
- case 9:
679
+ case 12:
614
680
  _f.sent();
615
- return [3 /*break*/, 11];
616
- case 10:
681
+ return [3 /*break*/, 14];
682
+ case 13:
617
683
  if (source && addApi) {
618
684
  // 如果配置了 source 且配置了 addApi 直接重新拉取接口就够了
619
685
  // 不能不判断 addApi 就刷新,因为有些场景就是临时添加的。
@@ -631,8 +697,8 @@ function registerOptionsControl(config) {
631
697
  }
632
698
  model.setOptions(options, this.changeOptionValue, data);
633
699
  }
634
- _f.label = 11;
635
- case 11: return [2 /*return*/];
700
+ _f.label = 14;
701
+ case 14: return [2 /*return*/];
636
702
  }
637
703
  });
638
704
  });
@@ -642,11 +708,12 @@ function registerOptionsControl(config) {
642
708
  if (origin === void 0) { origin = value; }
643
709
  if (skipForm === void 0) { skipForm = false; }
644
710
  return __awaiter(this, void 0, void 0, function () {
645
- var _c, editControls, editDialog, disabled, labelField, onOpenDialog, editApi, editInitApi, env, source, data, model, optionLabel, __, result, _d, payload, e_2, isPrevented, indexes;
711
+ var _c, editControls, editDialog, disabled, labelField, valueField, onOpenDialog, editApi, editInitApi, env, source, data, model, optionLabel, __, customEditPrevent, result, _d, prevent, payload, e_2, isPrevented, indexes;
712
+ var _this = this;
646
713
  return __generator(this, function (_e) {
647
714
  switch (_e.label) {
648
715
  case 0:
649
- _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;
716
+ _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;
650
717
  if (disabled || !model) {
651
718
  return [2 /*return*/];
652
719
  }
@@ -660,6 +727,7 @@ function registerOptionsControl(config) {
660
727
  }
661
728
  ];
662
729
  }
730
+ customEditPrevent = false;
663
731
  if (!skipForm) return [3 /*break*/, 1];
664
732
  _d = value;
665
733
  return [3 /*break*/, 3];
@@ -669,21 +737,59 @@ function registerOptionsControl(config) {
669
737
  type: 'form',
670
738
  initApi: editInitApi,
671
739
  api: editApi,
672
- controls: editControls
740
+ controls: editControls,
741
+ onSubmit: function (payload) { return __awaiter(_this, void 0, void 0, function () {
742
+ var labelKey, valueKey;
743
+ var _a;
744
+ var _b;
745
+ return __generator(this, function (_c) {
746
+ switch (_c.label) {
747
+ case 0:
748
+ labelKey = labelField || 'label';
749
+ valueKey = valueField || 'value';
750
+ return [4 /*yield*/, this.dispatchOptionEvent('editConfirm', {
751
+ item: (_a = {},
752
+ _a[labelKey] = payload[labelKey],
753
+ _a[valueKey] = (_b = payload[valueKey]) !== null && _b !== void 0 ? _b : payload[labelKey],
754
+ _a)
755
+ })];
756
+ case 1:
757
+ // 避免产生breakchange,增加新事件名,用来更正之前的设计问题
758
+ customEditPrevent = _c.sent();
759
+ return [2 /*return*/, !customEditPrevent];
760
+ }
761
+ });
762
+ }); }
673
763
  } }), createObject(data, value))];
674
764
  case 2:
675
765
  _d = _e.sent();
676
766
  _e.label = 3;
677
767
  case 3:
678
768
  result = _d;
679
- if (!(skipForm && editApi)) return [3 /*break*/, 7];
680
- _e.label = 4;
769
+ if (!skipForm) return [3 /*break*/, 5];
770
+ return [4 /*yield*/, this.dispatchOptionEvent('editConfirm', {
771
+ item: result
772
+ })];
681
773
  case 4:
682
- _e.trys.push([4, 6, , 7]);
774
+ prevent = _e.sent();
775
+ if (prevent) {
776
+ return [2 /*return*/];
777
+ }
778
+ return [3 /*break*/, 6];
779
+ case 5:
780
+ if (customEditPrevent) {
781
+ return [2 /*return*/];
782
+ }
783
+ _e.label = 6;
784
+ case 6:
785
+ if (!(skipForm && editApi)) return [3 /*break*/, 10];
786
+ _e.label = 7;
787
+ case 7:
788
+ _e.trys.push([7, 9, , 10]);
683
789
  return [4 /*yield*/, env.fetcher(editApi, createObject(data, result), {
684
790
  method: 'post'
685
791
  })];
686
- case 5:
792
+ case 8:
687
793
  payload = _e.sent();
688
794
  if (!payload.ok) {
689
795
  !editApi.silent &&
@@ -693,20 +799,20 @@ function registerOptionsControl(config) {
693
799
  else {
694
800
  result = payload.data || result;
695
801
  }
696
- return [3 /*break*/, 7];
697
- case 6:
802
+ return [3 /*break*/, 10];
803
+ case 9:
698
804
  e_2 = _e.sent();
699
805
  result = null;
700
806
  console.error(e_2);
701
807
  !editApi.silent && env.notify('error', e_2.message);
702
- return [3 /*break*/, 7];
703
- case 7:
808
+ return [3 /*break*/, 10];
809
+ case 10:
704
810
  // 没有结果,说明取消了。
705
811
  if (!result) {
706
812
  return [2 /*return*/];
707
813
  }
708
- return [4 /*yield*/, this.dispatchOptionEvent('edit', result)];
709
- case 8:
814
+ return [4 /*yield*/, this.oldDispatchOptionEvent('edit', result)];
815
+ case 11:
710
816
  isPrevented = _e.sent();
711
817
  if (isPrevented) {
712
818
  return [2 /*return*/];
@@ -728,7 +834,7 @@ function registerOptionsControl(config) {
728
834
  FormOptionsItem.prototype.handleOptionDelete = function (value) {
729
835
  var _a, _b;
730
836
  return __awaiter(this, void 0, void 0, function () {
731
- var _c, deleteConfirmText, disabled, data, deleteApi, onDelete, env, model, source, valueField, __, ctx, confirmed, _d, isPrevented, result, options, indexes, e_3;
837
+ var _c, deleteConfirmText, disabled, data, deleteApi, onDelete, env, model, source, valueField, __, ctx, confirmed, _d, isPrevented, delConfirmPrevent, result, options, indexes, e_3;
732
838
  return __generator(this, function (_e) {
733
839
  switch (_e.label) {
734
840
  case 0:
@@ -750,28 +856,36 @@ function registerOptionsControl(config) {
750
856
  if (!confirmed) {
751
857
  return [2 /*return*/];
752
858
  }
753
- return [4 /*yield*/, this.dispatchOptionEvent('delete', ctx)];
859
+ return [4 /*yield*/, this.oldDispatchOptionEvent('delete', ctx)];
754
860
  case 4:
755
861
  isPrevented = _e.sent();
756
862
  if (isPrevented) {
757
863
  return [2 /*return*/];
758
864
  }
759
- _e.label = 5;
865
+ return [4 /*yield*/, this.dispatchOptionEvent('deleteConfirm', {
866
+ item: value
867
+ })];
760
868
  case 5:
761
- _e.trys.push([5, 8, , 9]);
762
- if (!deleteApi) return [3 /*break*/, 7];
869
+ delConfirmPrevent = _e.sent();
870
+ if (delConfirmPrevent) {
871
+ return [2 /*return*/];
872
+ }
873
+ _e.label = 6;
874
+ case 6:
875
+ _e.trys.push([6, 9, , 10]);
876
+ if (!deleteApi) return [3 /*break*/, 8];
763
877
  return [4 /*yield*/, env.fetcher(deleteApi, ctx, {
764
878
  method: 'delete'
765
879
  })];
766
- case 6:
880
+ case 7:
767
881
  result = _e.sent();
768
882
  if (!result.ok) {
769
883
  !deleteApi.silent &&
770
884
  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')));
771
885
  return [2 /*return*/];
772
886
  }
773
- _e.label = 7;
774
- case 7:
887
+ _e.label = 8;
888
+ case 8:
775
889
  // 由外部代码实现删除逻辑
776
890
  if (onDelete) {
777
891
  onDelete(ctx);
@@ -786,13 +900,13 @@ function registerOptionsControl(config) {
786
900
  model.setOptions(spliceTree(options, indexes, 1), this.changeOptionValue, data);
787
901
  }
788
902
  }
789
- return [3 /*break*/, 9];
790
- case 8:
903
+ return [3 /*break*/, 10];
904
+ case 9:
791
905
  e_3 = _e.sent();
792
906
  console.error(e_3);
793
907
  !deleteApi.silent && env.notify('error', e_3.message);
794
- return [3 /*break*/, 9];
795
- case 9: return [2 /*return*/];
908
+ return [3 /*break*/, 10];
909
+ case 10: return [2 /*return*/];
796
910
  }
797
911
  });
798
912
  });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.3
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.3
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.3
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.3
2
+ * amis-core v6.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -19,12 +19,13 @@ import { withRootStore } from '../WithRootStore.js';
19
19
  import { TableStore } from '../store/table.js';
20
20
  import pick from 'lodash/pick';
21
21
  import { callStrFunction } from '../utils/api.js';
22
+ import '../utils/browser.js';
22
23
  import '../utils/ColorScale.js';
23
24
  import 'lodash/chunk';
25
+ import { getVariable } from '../utils/getVariable.js';
26
+ import 'lodash/isPlainObject';
24
27
  import 'amis-formula';
25
28
  import { tokenize } from '../utils/tokenize.js';
26
- import 'lodash/isPlainObject';
27
- import { getVariable } from '../utils/getVariable.js';
28
29
  import '../utils/DataSchema.js';
29
30
  import '../utils/DataScope.js';
30
31
  import '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/esm/store/app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.3
2
+ * amis-core v6.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -8,12 +8,13 @@ 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
10
  import '../utils/api.js';
11
+ import '../utils/browser.js';
11
12
  import '../utils/ColorScale.js';
12
13
  import 'react';
13
14
  import 'lodash/chunk';
15
+ import { createObject } from '../utils/object.js';
14
16
  import 'amis-formula';
15
17
  import 'lodash/isPlainObject';
16
- import { createObject } from '../utils/object.js';
17
18
  import '../utils/DataSchema.js';
18
19
  import '../utils/DataScope.js';
19
20
  import '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.3
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 {};