amis-core 3.6.4 → 6.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 (316) hide show
  1. package/esm/Root.js +1 -1
  2. package/esm/RootRenderer.js +3 -2
  3. package/esm/SchemaRenderer.js +4 -1
  4. package/esm/Scoped.d.ts +6 -0
  5. package/esm/Scoped.js +45 -7
  6. package/esm/StatusScoped.js +1 -1
  7. package/esm/WithRootStore.js +1 -1
  8. package/esm/WithStore.js +3 -5
  9. package/esm/actions/Action.js +31 -27
  10. package/esm/actions/AjaxAction.js +1 -1
  11. package/esm/actions/BreakAction.js +1 -1
  12. package/esm/actions/BroadcastAction.js +1 -1
  13. package/esm/actions/CmptAction.js +65 -26
  14. package/esm/actions/ContinueAction.js +1 -1
  15. package/esm/actions/CopyAction.js +1 -1
  16. package/esm/actions/CustomAction.js +4 -3
  17. package/esm/actions/DialogAction.js +1 -1
  18. package/esm/actions/DrawerAction.js +1 -1
  19. package/esm/actions/EmailAction.js +1 -1
  20. package/esm/actions/LinkAction.js +9 -4
  21. package/esm/actions/LoopAction.js +1 -1
  22. package/esm/actions/PageAction.js +1 -1
  23. package/esm/actions/ParallelAction.js +1 -1
  24. package/esm/actions/StatusAction.js +1 -1
  25. package/esm/actions/SwitchAction.js +1 -1
  26. package/esm/actions/ToastAction.js +1 -1
  27. package/esm/components/CustomStyle.d.ts +1 -2
  28. package/esm/components/CustomStyle.js +19 -6
  29. package/esm/components/ErrorBoundary.js +1 -1
  30. package/esm/components/LazyComponent.js +1 -1
  31. package/esm/components/Overlay.js +12 -9
  32. package/esm/components/PopOver.js +8 -5
  33. package/esm/env.d.ts +4 -0
  34. package/esm/env.js +1 -1
  35. package/esm/envOverwrite.js +1 -1
  36. package/esm/factory.js +14 -1
  37. package/esm/index.d.ts +2 -2
  38. package/esm/index.js +14 -7
  39. package/esm/locale.js +1 -1
  40. package/esm/polyfills.js +1 -1
  41. package/esm/renderers/Form.d.ts +4 -3
  42. package/esm/renderers/Form.js +216 -150
  43. package/esm/renderers/Item.d.ts +1 -0
  44. package/esm/renderers/Item.js +17 -17
  45. package/esm/renderers/Options.d.ts +5 -0
  46. package/esm/renderers/Options.js +188 -57
  47. package/esm/renderers/Placeholder.js +1 -1
  48. package/esm/renderers/builtin.js +1 -1
  49. package/esm/renderers/register.js +1 -1
  50. package/esm/renderers/wrapControl.js +39 -30
  51. package/esm/store/app.d.ts +2 -2
  52. package/esm/store/app.js +4 -3
  53. package/esm/store/combo.d.ts +79 -55
  54. package/esm/store/combo.js +1 -1
  55. package/esm/store/crud.d.ts +3 -2
  56. package/esm/store/crud.js +18 -4
  57. package/esm/store/form.d.ts +33 -23
  58. package/esm/store/form.js +5 -5
  59. package/esm/store/formItem.d.ts +2 -1
  60. package/esm/store/formItem.js +3 -2
  61. package/esm/store/iRenderer.d.ts +1 -1
  62. package/esm/store/iRenderer.js +10 -3
  63. package/esm/store/index.js +1 -1
  64. package/esm/store/list.d.ts +1 -1
  65. package/esm/store/list.js +18 -13
  66. package/esm/store/manager.js +1 -1
  67. package/esm/store/modal.d.ts +2 -2
  68. package/esm/store/modal.js +1 -1
  69. package/esm/store/node.js +1 -1
  70. package/esm/store/pagination.d.ts +2 -1
  71. package/esm/store/pagination.js +3 -2
  72. package/esm/store/root.d.ts +2 -2
  73. package/esm/store/root.js +4 -3
  74. package/esm/store/service.d.ts +2 -2
  75. package/esm/store/service.js +11 -7
  76. package/esm/store/status.js +1 -1
  77. package/esm/store/table.d.ts +69 -47
  78. package/esm/store/table.js +54 -25
  79. package/esm/store/table2.d.ts +14 -3
  80. package/esm/store/table2.js +22 -9
  81. package/esm/theme.js +1 -1
  82. package/esm/types.d.ts +7 -0
  83. package/esm/utils/Animation.js +1 -1
  84. package/esm/utils/ColorScale.js +1 -1
  85. package/esm/utils/DataSchema.js +1 -1
  86. package/esm/utils/DataScope.js +1 -1
  87. package/esm/utils/RootClose.js +1 -1
  88. package/esm/utils/SimpleMap.js +1 -1
  89. package/esm/utils/api.js +1 -1
  90. package/esm/utils/arraySlice.js +1 -1
  91. package/esm/utils/attachmentAdpator.js +1 -1
  92. package/esm/utils/autobind.js +1 -1
  93. package/esm/utils/browser.d.ts +1 -0
  94. package/esm/utils/browser.js +11 -0
  95. package/esm/utils/columnsSplit.js +1 -1
  96. package/esm/utils/concatData.d.ts +8 -0
  97. package/esm/utils/concatData.js +39 -0
  98. package/esm/utils/dataMapping.js +1 -1
  99. package/esm/utils/date.js +1 -1
  100. package/esm/utils/debug.js +1 -1
  101. package/esm/utils/decodeEntity.js +1 -1
  102. package/esm/utils/dom.js +1 -1
  103. package/esm/utils/errors.js +1 -1
  104. package/esm/utils/escapeHtml.js +1 -1
  105. package/esm/utils/filter-schema.js +1 -1
  106. package/esm/utils/filter.js +1 -1
  107. package/esm/utils/formatDuration.js +1 -1
  108. package/esm/utils/formula.js +1 -1
  109. package/esm/utils/getVariable.js +1 -1
  110. package/esm/utils/grammar.js +1 -1
  111. package/esm/utils/handleAction.js +1 -1
  112. package/esm/utils/helper.d.ts +14 -2
  113. package/esm/utils/helper.js +49 -14
  114. package/esm/utils/highlight.js +3 -2
  115. package/esm/utils/icon.js +1 -1
  116. package/esm/utils/image.js +1 -1
  117. package/esm/utils/index.d.ts +3 -0
  118. package/esm/utils/isPureVariable.js +1 -1
  119. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  120. package/esm/utils/keyToPath.js +1 -1
  121. package/esm/utils/labelToString.d.ts +1 -0
  122. package/esm/utils/labelToString.js +38 -0
  123. package/esm/utils/makeSorter.js +1 -1
  124. package/esm/utils/math.js +1 -1
  125. package/esm/utils/memoryParse.js +1 -1
  126. package/esm/utils/normalizeLink.js +1 -1
  127. package/esm/utils/normalizeOptions.js +1 -1
  128. package/esm/utils/object.js +1 -1
  129. package/esm/utils/offset.js +1 -1
  130. package/esm/utils/offsetParent.js +1 -1
  131. package/esm/utils/optionValueCompare.js +1 -1
  132. package/esm/utils/position.js +1 -1
  133. package/esm/utils/prettyBytes.js +1 -1
  134. package/esm/utils/renderer-event.js +19 -3
  135. package/esm/utils/replaceText.js +9 -11
  136. package/esm/utils/resize-sensor.js +1 -1
  137. package/esm/utils/resolveCondition.js +1 -1
  138. package/esm/utils/resolveVariable.js +1 -1
  139. package/esm/utils/resolveVariableAndFilter.js +1 -1
  140. package/esm/utils/resolveVariableAndFilterForAsync.js +1 -1
  141. package/esm/utils/scrollPosition.js +1 -1
  142. package/esm/utils/string2regExp.d.ts +1 -1
  143. package/esm/utils/string2regExp.js +4 -3
  144. package/esm/utils/stripNumber.js +1 -1
  145. package/esm/utils/style-helper.d.ts +24 -5
  146. package/esm/utils/style-helper.js +49 -21
  147. package/esm/utils/style.js +1 -1
  148. package/esm/utils/toNumber.js +1 -1
  149. package/esm/utils/tokenize.d.ts +1 -0
  150. package/esm/utils/tokenize.js +10 -3
  151. package/esm/utils/tpl-builtin.js +1 -1
  152. package/esm/utils/tpl-lodash.js +1 -1
  153. package/esm/utils/tpl.js +6 -8
  154. package/esm/utils/uncontrollable.js +1 -1
  155. package/esm/utils/validateId.d.ts +16 -0
  156. package/esm/utils/validateId.js +154 -0
  157. package/esm/utils/validations.js +16 -8
  158. package/lib/Root.js +1 -1
  159. package/lib/RootRenderer.js +3 -2
  160. package/lib/SchemaRenderer.js +4 -1
  161. package/lib/Scoped.d.ts +6 -0
  162. package/lib/Scoped.js +45 -6
  163. package/lib/StatusScoped.js +1 -1
  164. package/lib/WithRootStore.js +1 -1
  165. package/lib/WithStore.js +3 -5
  166. package/lib/actions/Action.js +31 -27
  167. package/lib/actions/AjaxAction.js +1 -1
  168. package/lib/actions/BreakAction.js +1 -1
  169. package/lib/actions/BroadcastAction.js +1 -1
  170. package/lib/actions/CmptAction.js +65 -26
  171. package/lib/actions/ContinueAction.js +1 -1
  172. package/lib/actions/CopyAction.js +1 -1
  173. package/lib/actions/CustomAction.js +4 -3
  174. package/lib/actions/DialogAction.js +1 -1
  175. package/lib/actions/DrawerAction.js +1 -1
  176. package/lib/actions/EmailAction.js +1 -1
  177. package/lib/actions/LinkAction.js +9 -4
  178. package/lib/actions/LoopAction.js +1 -1
  179. package/lib/actions/PageAction.js +1 -1
  180. package/lib/actions/ParallelAction.js +1 -1
  181. package/lib/actions/StatusAction.js +1 -1
  182. package/lib/actions/SwitchAction.js +1 -1
  183. package/lib/actions/ToastAction.js +1 -1
  184. package/lib/components/CustomStyle.d.ts +1 -2
  185. package/lib/components/CustomStyle.js +19 -6
  186. package/lib/components/ErrorBoundary.js +1 -1
  187. package/lib/components/LazyComponent.js +1 -1
  188. package/lib/components/Overlay.js +11 -8
  189. package/lib/components/PopOver.js +8 -5
  190. package/lib/env.d.ts +4 -0
  191. package/lib/env.js +1 -1
  192. package/lib/envOverwrite.js +1 -1
  193. package/lib/factory.js +14 -1
  194. package/lib/index.d.ts +2 -2
  195. package/lib/index.js +19 -4
  196. package/lib/locale.js +1 -1
  197. package/lib/polyfills.js +1 -1
  198. package/lib/renderers/Form.d.ts +4 -3
  199. package/lib/renderers/Form.js +216 -150
  200. package/lib/renderers/Item.d.ts +1 -0
  201. package/lib/renderers/Item.js +17 -17
  202. package/lib/renderers/Options.d.ts +5 -0
  203. package/lib/renderers/Options.js +188 -57
  204. package/lib/renderers/Placeholder.js +1 -1
  205. package/lib/renderers/builtin.js +1 -1
  206. package/lib/renderers/register.js +1 -1
  207. package/lib/renderers/wrapControl.js +38 -29
  208. package/lib/store/app.d.ts +2 -2
  209. package/lib/store/app.js +4 -3
  210. package/lib/store/combo.d.ts +55 -31
  211. package/lib/store/combo.js +1 -1
  212. package/lib/store/crud.d.ts +3 -2
  213. package/lib/store/crud.js +18 -4
  214. package/lib/store/form.d.ts +23 -13
  215. package/lib/store/form.js +5 -5
  216. package/lib/store/formItem.d.ts +2 -1
  217. package/lib/store/formItem.js +3 -2
  218. package/lib/store/iRenderer.d.ts +1 -1
  219. package/lib/store/iRenderer.js +10 -3
  220. package/lib/store/index.js +1 -1
  221. package/lib/store/list.d.ts +1 -1
  222. package/lib/store/list.js +18 -14
  223. package/lib/store/manager.js +1 -1
  224. package/lib/store/modal.d.ts +2 -2
  225. package/lib/store/modal.js +1 -1
  226. package/lib/store/node.js +1 -1
  227. package/lib/store/pagination.d.ts +2 -1
  228. package/lib/store/pagination.js +3 -2
  229. package/lib/store/root.d.ts +2 -2
  230. package/lib/store/root.js +4 -3
  231. package/lib/store/service.d.ts +2 -2
  232. package/lib/store/service.js +11 -7
  233. package/lib/store/status.js +1 -1
  234. package/lib/store/table.d.ts +49 -27
  235. package/lib/store/table.js +54 -26
  236. package/lib/store/table2.d.ts +14 -3
  237. package/lib/store/table2.js +22 -9
  238. package/lib/theme.js +1 -1
  239. package/lib/types.d.ts +7 -0
  240. package/lib/utils/Animation.js +1 -1
  241. package/lib/utils/ColorScale.js +1 -1
  242. package/lib/utils/DataSchema.js +1 -1
  243. package/lib/utils/DataScope.js +1 -1
  244. package/lib/utils/RootClose.js +1 -1
  245. package/lib/utils/SimpleMap.js +1 -1
  246. package/lib/utils/api.js +1 -1
  247. package/lib/utils/arraySlice.js +1 -1
  248. package/lib/utils/attachmentAdpator.js +1 -1
  249. package/lib/utils/autobind.js +1 -1
  250. package/lib/utils/browser.d.ts +1 -0
  251. package/lib/utils/browser.js +15 -0
  252. package/lib/utils/columnsSplit.js +1 -1
  253. package/lib/utils/concatData.d.ts +8 -0
  254. package/lib/utils/concatData.js +43 -0
  255. package/lib/utils/dataMapping.js +1 -1
  256. package/lib/utils/date.js +1 -1
  257. package/lib/utils/debug.js +1 -1
  258. package/lib/utils/decodeEntity.js +1 -1
  259. package/lib/utils/dom.js +1 -1
  260. package/lib/utils/errors.js +1 -1
  261. package/lib/utils/escapeHtml.js +1 -1
  262. package/lib/utils/filter-schema.js +1 -1
  263. package/lib/utils/filter.js +1 -1
  264. package/lib/utils/formatDuration.js +1 -1
  265. package/lib/utils/formula.js +1 -1
  266. package/lib/utils/getVariable.js +1 -1
  267. package/lib/utils/grammar.js +1 -1
  268. package/lib/utils/handleAction.js +1 -1
  269. package/lib/utils/helper.d.ts +14 -2
  270. package/lib/utils/helper.js +50 -12
  271. package/lib/utils/highlight.js +3 -2
  272. package/lib/utils/icon.js +1 -1
  273. package/lib/utils/image.js +1 -1
  274. package/lib/utils/index.d.ts +3 -0
  275. package/lib/utils/isPureVariable.js +1 -1
  276. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  277. package/lib/utils/keyToPath.js +1 -1
  278. package/lib/utils/labelToString.d.ts +1 -0
  279. package/lib/utils/labelToString.js +46 -0
  280. package/lib/utils/makeSorter.js +1 -1
  281. package/lib/utils/math.js +1 -1
  282. package/lib/utils/memoryParse.js +1 -1
  283. package/lib/utils/normalizeLink.js +1 -1
  284. package/lib/utils/normalizeOptions.js +1 -1
  285. package/lib/utils/object.js +1 -1
  286. package/lib/utils/offset.js +1 -1
  287. package/lib/utils/offsetParent.js +1 -1
  288. package/lib/utils/optionValueCompare.js +1 -1
  289. package/lib/utils/position.js +1 -1
  290. package/lib/utils/prettyBytes.js +1 -1
  291. package/lib/utils/renderer-event.js +19 -3
  292. package/lib/utils/replaceText.js +8 -14
  293. package/lib/utils/resize-sensor.js +1 -1
  294. package/lib/utils/resolveCondition.js +1 -1
  295. package/lib/utils/resolveVariable.js +1 -1
  296. package/lib/utils/resolveVariableAndFilter.js +1 -1
  297. package/lib/utils/resolveVariableAndFilterForAsync.js +1 -1
  298. package/lib/utils/scrollPosition.js +1 -1
  299. package/lib/utils/string2regExp.d.ts +1 -1
  300. package/lib/utils/string2regExp.js +4 -3
  301. package/lib/utils/stripNumber.js +1 -1
  302. package/lib/utils/style-helper.d.ts +24 -5
  303. package/lib/utils/style-helper.js +49 -21
  304. package/lib/utils/style.js +1 -1
  305. package/lib/utils/toNumber.js +1 -1
  306. package/lib/utils/tokenize.d.ts +1 -0
  307. package/lib/utils/tokenize.js +10 -2
  308. package/lib/utils/tpl-builtin.js +1 -1
  309. package/lib/utils/tpl-lodash.js +1 -1
  310. package/lib/utils/tpl.js +5 -7
  311. package/lib/utils/uncontrollable.js +1 -1
  312. package/lib/utils/validateId.d.ts +16 -0
  313. package/lib/utils/validateId.js +160 -0
  314. package/lib/utils/validations.js +16 -8
  315. package/package.json +4 -3
  316. package/LICENSE +0 -201
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.4
2
+ * amis-core v6.1.0
3
3
  * Copyright 2018-2024 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');
@@ -42,13 +43,13 @@ require('../utils/icon.js');
42
43
  require('../utils/image.js');
43
44
  var keyToPath = require('../utils/keyToPath.js');
44
45
  var rendererEvent = require('../utils/renderer-event.js');
45
- require('lodash/cloneDeep');
46
46
  require('../utils/resize-sensor.js');
47
47
  require('react-overlays/useRootClose');
48
48
  require('react-dom');
49
49
  require('../utils/SimpleMap.js');
50
50
  require('lodash/mapValues');
51
51
  require('lodash/camelCase');
52
+ require('lodash/cloneDeep');
52
53
  require('lodash/map');
53
54
  require('lodash/isEmpty');
54
55
  require('lodash/kebabCase');
@@ -95,6 +96,7 @@ function registerOptionsControl(config) {
95
96
  _this = _super.call(this, props) || this;
96
97
  _this.toDispose = [];
97
98
  _this.mounted = false;
99
+ _this.initedFilled = false;
98
100
  var initFetch = props.initFetch, formItem = props.formItem, source = props.source, data = props.data, setPrinstineValue = props.setPrinstineValue, defaultValue = props.defaultValue, multiple = props.multiple, joinValues = props.joinValues, extractValue = props.extractValue, addHook = props.addHook, formInited = props.formInited, valueField = props.valueField, options = props.options, value = props.value, defaultCheckAll = props.defaultCheckAll;
99
101
  if (formItem) {
100
102
  formItem.setOptions(normalizeOptions.normalizeOptions(options, undefined, valueField), _this.changeOptionValue, data);
@@ -103,12 +105,20 @@ function registerOptionsControl(config) {
103
105
  return JSON.stringify(formItem.getSelectedOptions(formItem.tmpValue));
104
106
  }, function () {
105
107
  return _this.mounted &&
108
+ _this.initedFilled &&
106
109
  _this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue));
107
110
  }));
108
- if (options &&
109
- formItem.tmpValue &&
110
- formItem.getSelectedOptions(formItem.tmpValue).length) {
111
- _this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue));
111
+ if (formInited || !addHook) {
112
+ _this.initedFilled = true;
113
+ _this.props.initAutoFill !== false &&
114
+ _this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue), _this.props.initAutoFill === 'fillIfNotSet');
115
+ }
116
+ else if (addHook) {
117
+ addHook(function () {
118
+ _this.initedFilled = true;
119
+ _this.props.initAutoFill !== false &&
120
+ _this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue), _this.props.initAutoFill === 'fillIfNotSet');
121
+ }, 'init');
112
122
  }
113
123
  // 默认全选。这里会和默认值\回填值逻辑冲突,所以如果有配置source则不执行默认全选
114
124
  if (multiple &&
@@ -160,7 +170,7 @@ function registerOptionsControl(config) {
160
170
  var _this = this;
161
171
  var props = this.props;
162
172
  var formItem = props.formItem;
163
- if (prevProps.options !== props.options && formItem) {
173
+ if (!props.source && prevProps.options !== props.options && formItem) {
164
174
  formItem.setOptions(normalizeOptions.normalizeOptions(props.options || [], undefined, props.valueField), this.changeOptionValue, props.data);
165
175
  this.normalizeValue();
166
176
  }
@@ -194,7 +204,8 @@ function registerOptionsControl(config) {
194
204
  this.toDispose.forEach(function (fn) { return fn(); });
195
205
  this.toDispose = [];
196
206
  };
197
- FormOptionsItem.prototype.dispatchOptionEvent = function (eventName, eventData) {
207
+ // 不推荐使用,缺少组件值
208
+ FormOptionsItem.prototype.oldDispatchOptionEvent = function (eventName, eventData) {
198
209
  if (eventData === void 0) { eventData = ''; }
199
210
  return tslib.__awaiter(this, void 0, void 0, function () {
200
211
  var _a, dispatchEvent, options, rendererEvent$1;
@@ -212,6 +223,23 @@ function registerOptionsControl(config) {
212
223
  });
213
224
  });
214
225
  };
226
+ FormOptionsItem.prototype.dispatchOptionEvent = function (eventName, eventData) {
227
+ if (eventData === void 0) { eventData = ''; }
228
+ return tslib.__awaiter(this, void 0, void 0, function () {
229
+ var _a, dispatchEvent, options, value, rendererEvent$1;
230
+ return tslib.__generator(this, function (_b) {
231
+ switch (_b.label) {
232
+ case 0:
233
+ _a = this.props, dispatchEvent = _a.dispatchEvent, options = _a.options, value = _a.value;
234
+ return [4 /*yield*/, dispatchEvent(eventName, rendererEvent.resolveEventData(this.props, tslib.__assign({ value: value, options: options, items: options }, eventData)))];
235
+ case 1:
236
+ rendererEvent$1 = _b.sent();
237
+ // 返回阻塞标识
238
+ return [2 /*return*/, !!(rendererEvent$1 === null || rendererEvent$1 === void 0 ? void 0 : rendererEvent$1.prevented)];
239
+ }
240
+ });
241
+ });
242
+ };
215
243
  FormOptionsItem.prototype.doAction = function (action, data, throwErrors) {
216
244
  var _a = this.props, resetValue = _a.resetValue, onChange = _a.onChange;
217
245
  var actionType = action === null || action === void 0 ? void 0 : action.actionType;
@@ -222,7 +250,8 @@ function registerOptionsControl(config) {
222
250
  onChange === null || onChange === void 0 ? void 0 : onChange(resetValue !== null && resetValue !== void 0 ? resetValue : '');
223
251
  }
224
252
  };
225
- FormOptionsItem.prototype.syncAutoFill = function (selectedOptions) {
253
+ FormOptionsItem.prototype.syncAutoFill = function (selectedOptions, skipIfExits) {
254
+ if (skipIfExits === void 0) { skipIfExits = false; }
226
255
  var _a = this.props, autoFill = _a.autoFill, multiple = _a.multiple, onBulkChange = _a.onBulkChange, data = _a.data;
227
256
  var formItem = this.props.formItem;
228
257
  // 参照录入|自动填充
@@ -244,11 +273,18 @@ function registerOptionsControl(config) {
244
273
  var result_1 = tslib.__assign({}, toSync_1);
245
274
  Object.keys(autoFill).forEach(function (key) {
246
275
  var keys = keyToPath.keyToPath(key);
276
+ var value = getVariable.getVariable(toSync_1, key);
277
+ if (skipIfExits) {
278
+ var originValue = getVariable.getVariable(data, key);
279
+ if (typeof originValue !== 'undefined') {
280
+ value = originValue;
281
+ }
282
+ }
283
+ object.setVariable(result_1, key, value);
247
284
  // 如果左边的 key 是一个路径
248
285
  // 这里不希望直接把原始对象都给覆盖没了
249
286
  // 而是保留原始的对象,只修改指定的属性
250
287
  if (keys.length > 1 && isPlainObject__default["default"](tmpData_1[keys[0]])) {
251
- var value = getVariable.getVariable(toSync_1, key);
252
288
  // 存在情况:依次更新同一子路径的多个key,eg: a.b.c1 和 a.b.c2,所以需要同步更新data
253
289
  object.setVariable(tmpData_1, key, value);
254
290
  result_1[keys[0]] = tmpData_1[keys[0]];
@@ -297,7 +333,9 @@ function registerOptionsControl(config) {
297
333
  return [2 /*return*/];
298
334
  }
299
335
  newValue = this.toggleValue(option, value);
300
- return [4 /*yield*/, this.dispatchOptionEvent('change', newValue)];
336
+ return [4 /*yield*/, this.dispatchOptionEvent('change', {
337
+ value: newValue
338
+ })];
301
339
  case 1:
302
340
  isPrevented = _b.sent();
303
341
  isPrevented ||
@@ -368,7 +406,9 @@ function registerOptionsControl(config) {
368
406
  ? []
369
407
  : formItem.filteredOptions.concat();
370
408
  newValue = this.formatValueArray(valueArray);
371
- return [4 /*yield*/, this.dispatchOptionEvent('change', newValue)];
409
+ return [4 /*yield*/, this.dispatchOptionEvent('change', {
410
+ value: newValue
411
+ })];
372
412
  case 1:
373
413
  isPrevented = _b.sent();
374
414
  isPrevented || (onChange && onChange(newValue));
@@ -451,7 +491,10 @@ function registerOptionsControl(config) {
451
491
  case 1:
452
492
  json = _b.sent();
453
493
  // 触发事件通知,加载完成
454
- this.dispatchOptionEvent('loadFinished', json);
494
+ // 废弃,不推荐使用
495
+ this.oldDispatchOptionEvent('loadFinished', json);
496
+ // 避免产生breakchange,增加新事件名,用来更正之前的设计问题
497
+ this.dispatchOptionEvent('deferLoadFinished', { result: json });
455
498
  return [2 /*return*/];
456
499
  }
457
500
  });
@@ -533,8 +576,9 @@ function registerOptionsControl(config) {
533
576
  if (idx === void 0) { idx = -1; }
534
577
  if (skipForm === void 0) { skipForm = false; }
535
578
  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;
579
+ 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
580
  var _e;
581
+ var _this = this;
538
582
  return tslib.__generator(this, function (_f) {
539
583
  switch (_f.label) {
540
584
  case 0:
@@ -560,6 +604,7 @@ function registerOptionsControl(config) {
560
604
  : undefined;
561
605
  ctx = object.createObject(data, Array.isArray(idx)
562
606
  ? tslib.__assign({ parent: parent }, value) : value);
607
+ customAddPrevent = false;
563
608
  if (!skipForm) return [3 /*break*/, 1];
564
609
  _d = ctx;
565
610
  return [3 /*break*/, 3];
@@ -577,21 +622,59 @@ function registerOptionsControl(config) {
577
622
  name: 'parent',
578
623
  value: parent
579
624
  }
580
- ], tslib.__read((addControls || [])), false)
625
+ ], tslib.__read((addControls || [])), false),
626
+ onSubmit: function (payload) { return tslib.__awaiter(_this, void 0, void 0, function () {
627
+ var labelKey, valueKey;
628
+ var _a;
629
+ var _b;
630
+ return tslib.__generator(this, function (_c) {
631
+ switch (_c.label) {
632
+ case 0:
633
+ labelKey = labelField || 'label';
634
+ valueKey = valueField || 'value';
635
+ return [4 /*yield*/, this.dispatchOptionEvent('addConfirm', {
636
+ item: (_a = {},
637
+ _a[labelKey] = payload[labelKey],
638
+ _a[valueKey] = (_b = payload[valueKey]) !== null && _b !== void 0 ? _b : payload[labelKey],
639
+ _a)
640
+ })];
641
+ case 1:
642
+ // 派发确认添加事件
643
+ customAddPrevent = _c.sent();
644
+ return [2 /*return*/, !customAddPrevent];
645
+ }
646
+ });
647
+ }); }
581
648
  } }), ctx)];
582
649
  case 2:
583
650
  _d = _f.sent();
584
651
  _f.label = 3;
585
652
  case 3:
586
653
  result = _d;
587
- if (!(skipForm && addApi)) return [3 /*break*/, 7];
588
- _f.label = 4;
654
+ if (!skipForm) return [3 /*break*/, 5];
655
+ return [4 /*yield*/, this.dispatchOptionEvent('addConfirm', {
656
+ item: result
657
+ })];
589
658
  case 4:
590
- _f.trys.push([4, 6, , 7]);
659
+ prevent = _f.sent();
660
+ if (prevent) {
661
+ return [2 /*return*/];
662
+ }
663
+ return [3 /*break*/, 6];
664
+ case 5:
665
+ if (customAddPrevent) {
666
+ return [2 /*return*/];
667
+ }
668
+ _f.label = 6;
669
+ case 6:
670
+ if (!(skipForm && addApi)) return [3 /*break*/, 10];
671
+ _f.label = 7;
672
+ case 7:
673
+ _f.trys.push([7, 9, , 10]);
591
674
  return [4 /*yield*/, env.fetcher(addApi, result, {
592
675
  method: 'post'
593
676
  })];
594
- case 5:
677
+ case 8:
595
678
  payload = _f.sent();
596
679
  if (!payload.ok) {
597
680
  !addApi.silent &&
@@ -601,14 +684,14 @@ function registerOptionsControl(config) {
601
684
  else {
602
685
  result = payload.data || result;
603
686
  }
604
- return [3 /*break*/, 7];
605
- case 6:
687
+ return [3 /*break*/, 10];
688
+ case 9:
606
689
  e_1 = _f.sent();
607
690
  result = null;
608
691
  console.error(e_1);
609
692
  !addApi.silent && env.notify('error', e_1.message);
610
- return [3 /*break*/, 7];
611
- case 7:
693
+ return [3 /*break*/, 10];
694
+ case 10:
612
695
  // 有 result 说明弹框点了确认。否则就是取消了。
613
696
  if (!result) {
614
697
  return [2 /*return*/];
@@ -617,19 +700,19 @@ function registerOptionsControl(config) {
617
700
  if (!result.hasOwnProperty(valueField || 'value')) {
618
701
  result = tslib.__assign(tslib.__assign({}, result), (_e = {}, _e[valueField || 'value'] = result[labelField || 'label'], _e));
619
702
  }
620
- return [4 /*yield*/, this.dispatchOptionEvent('add', tslib.__assign(tslib.__assign({}, result), { idx: idx }))];
621
- case 8:
703
+ return [4 /*yield*/, this.oldDispatchOptionEvent('add', tslib.__assign(tslib.__assign({}, result), { idx: idx }))];
704
+ case 11:
622
705
  isPrevented = _f.sent();
623
706
  if (isPrevented) {
624
707
  return [2 /*return*/];
625
708
  }
626
709
  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];
710
+ (parent === null || parent === void 0 ? void 0 : parent.defer))) return [3 /*break*/, 13];
628
711
  return [4 /*yield*/, this.deferLoad(parent)];
629
- case 9:
712
+ case 12:
630
713
  _f.sent();
631
- return [3 /*break*/, 11];
632
- case 10:
714
+ return [3 /*break*/, 14];
715
+ case 13:
633
716
  if (source && addApi) {
634
717
  // 如果配置了 source 且配置了 addApi 直接重新拉取接口就够了
635
718
  // 不能不判断 addApi 就刷新,因为有些场景就是临时添加的。
@@ -647,8 +730,8 @@ function registerOptionsControl(config) {
647
730
  }
648
731
  model.setOptions(options, this.changeOptionValue, data);
649
732
  }
650
- _f.label = 11;
651
- case 11: return [2 /*return*/];
733
+ _f.label = 14;
734
+ case 14: return [2 /*return*/];
652
735
  }
653
736
  });
654
737
  });
@@ -658,11 +741,12 @@ function registerOptionsControl(config) {
658
741
  if (origin === void 0) { origin = value; }
659
742
  if (skipForm === void 0) { skipForm = false; }
660
743
  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;
744
+ var _c, editControls, editDialog, disabled, labelField, valueField, onOpenDialog, editApi, editInitApi, env, source, data, model, optionLabel, __, customEditPrevent, result, _d, prevent, payload, e_2, isPrevented, indexes;
745
+ var _this = this;
662
746
  return tslib.__generator(this, function (_e) {
663
747
  switch (_e.label) {
664
748
  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;
749
+ _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
750
  if (disabled || !model) {
667
751
  return [2 /*return*/];
668
752
  }
@@ -676,6 +760,7 @@ function registerOptionsControl(config) {
676
760
  }
677
761
  ];
678
762
  }
763
+ customEditPrevent = false;
679
764
  if (!skipForm) return [3 /*break*/, 1];
680
765
  _d = value;
681
766
  return [3 /*break*/, 3];
@@ -685,21 +770,59 @@ function registerOptionsControl(config) {
685
770
  type: 'form',
686
771
  initApi: editInitApi,
687
772
  api: editApi,
688
- controls: editControls
773
+ controls: editControls,
774
+ onSubmit: function (payload) { return tslib.__awaiter(_this, void 0, void 0, function () {
775
+ var labelKey, valueKey;
776
+ var _a;
777
+ var _b;
778
+ return tslib.__generator(this, function (_c) {
779
+ switch (_c.label) {
780
+ case 0:
781
+ labelKey = labelField || 'label';
782
+ valueKey = valueField || 'value';
783
+ return [4 /*yield*/, this.dispatchOptionEvent('editConfirm', {
784
+ item: (_a = {},
785
+ _a[labelKey] = payload[labelKey],
786
+ _a[valueKey] = (_b = payload[valueKey]) !== null && _b !== void 0 ? _b : payload[labelKey],
787
+ _a)
788
+ })];
789
+ case 1:
790
+ // 避免产生breakchange,增加新事件名,用来更正之前的设计问题
791
+ customEditPrevent = _c.sent();
792
+ return [2 /*return*/, !customEditPrevent];
793
+ }
794
+ });
795
+ }); }
689
796
  } }), object.createObject(data, value))];
690
797
  case 2:
691
798
  _d = _e.sent();
692
799
  _e.label = 3;
693
800
  case 3:
694
801
  result = _d;
695
- if (!(skipForm && editApi)) return [3 /*break*/, 7];
696
- _e.label = 4;
802
+ if (!skipForm) return [3 /*break*/, 5];
803
+ return [4 /*yield*/, this.dispatchOptionEvent('editConfirm', {
804
+ item: result
805
+ })];
697
806
  case 4:
698
- _e.trys.push([4, 6, , 7]);
807
+ prevent = _e.sent();
808
+ if (prevent) {
809
+ return [2 /*return*/];
810
+ }
811
+ return [3 /*break*/, 6];
812
+ case 5:
813
+ if (customEditPrevent) {
814
+ return [2 /*return*/];
815
+ }
816
+ _e.label = 6;
817
+ case 6:
818
+ if (!(skipForm && editApi)) return [3 /*break*/, 10];
819
+ _e.label = 7;
820
+ case 7:
821
+ _e.trys.push([7, 9, , 10]);
699
822
  return [4 /*yield*/, env.fetcher(editApi, object.createObject(data, result), {
700
823
  method: 'post'
701
824
  })];
702
- case 5:
825
+ case 8:
703
826
  payload = _e.sent();
704
827
  if (!payload.ok) {
705
828
  !editApi.silent &&
@@ -709,20 +832,20 @@ function registerOptionsControl(config) {
709
832
  else {
710
833
  result = payload.data || result;
711
834
  }
712
- return [3 /*break*/, 7];
713
- case 6:
835
+ return [3 /*break*/, 10];
836
+ case 9:
714
837
  e_2 = _e.sent();
715
838
  result = null;
716
839
  console.error(e_2);
717
840
  !editApi.silent && env.notify('error', e_2.message);
718
- return [3 /*break*/, 7];
719
- case 7:
841
+ return [3 /*break*/, 10];
842
+ case 10:
720
843
  // 没有结果,说明取消了。
721
844
  if (!result) {
722
845
  return [2 /*return*/];
723
846
  }
724
- return [4 /*yield*/, this.dispatchOptionEvent('edit', result)];
725
- case 8:
847
+ return [4 /*yield*/, this.oldDispatchOptionEvent('edit', result)];
848
+ case 11:
726
849
  isPrevented = _e.sent();
727
850
  if (isPrevented) {
728
851
  return [2 /*return*/];
@@ -744,7 +867,7 @@ function registerOptionsControl(config) {
744
867
  FormOptionsItem.prototype.handleOptionDelete = function (value) {
745
868
  var _a, _b;
746
869
  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;
870
+ var _c, deleteConfirmText, disabled, data, deleteApi, onDelete, env, model, source, valueField, __, ctx, confirmed, _d, isPrevented, delConfirmPrevent, result, options, indexes, e_3;
748
871
  return tslib.__generator(this, function (_e) {
749
872
  switch (_e.label) {
750
873
  case 0:
@@ -766,28 +889,36 @@ function registerOptionsControl(config) {
766
889
  if (!confirmed) {
767
890
  return [2 /*return*/];
768
891
  }
769
- return [4 /*yield*/, this.dispatchOptionEvent('delete', ctx)];
892
+ return [4 /*yield*/, this.oldDispatchOptionEvent('delete', ctx)];
770
893
  case 4:
771
894
  isPrevented = _e.sent();
772
895
  if (isPrevented) {
773
896
  return [2 /*return*/];
774
897
  }
775
- _e.label = 5;
898
+ return [4 /*yield*/, this.dispatchOptionEvent('deleteConfirm', {
899
+ item: value
900
+ })];
776
901
  case 5:
777
- _e.trys.push([5, 8, , 9]);
778
- if (!deleteApi) return [3 /*break*/, 7];
902
+ delConfirmPrevent = _e.sent();
903
+ if (delConfirmPrevent) {
904
+ return [2 /*return*/];
905
+ }
906
+ _e.label = 6;
907
+ case 6:
908
+ _e.trys.push([6, 9, , 10]);
909
+ if (!deleteApi) return [3 /*break*/, 8];
779
910
  return [4 /*yield*/, env.fetcher(deleteApi, ctx, {
780
911
  method: 'delete'
781
912
  })];
782
- case 6:
913
+ case 7:
783
914
  result = _e.sent();
784
915
  if (!result.ok) {
785
916
  !deleteApi.silent &&
786
917
  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
918
  return [2 /*return*/];
788
919
  }
789
- _e.label = 7;
790
- case 7:
920
+ _e.label = 8;
921
+ case 8:
791
922
  // 由外部代码实现删除逻辑
792
923
  if (onDelete) {
793
924
  onDelete(ctx);
@@ -802,13 +933,13 @@ function registerOptionsControl(config) {
802
933
  model.setOptions(helper.spliceTree(options, indexes, 1), this.changeOptionValue, data);
803
934
  }
804
935
  }
805
- return [3 /*break*/, 9];
806
- case 8:
936
+ return [3 /*break*/, 10];
937
+ case 9:
807
938
  e_3 = _e.sent();
808
939
  console.error(e_3);
809
940
  !deleteApi.silent && env.notify('error', e_3.message);
810
- return [3 /*break*/, 9];
811
- case 9: return [2 /*return*/];
941
+ return [3 /*break*/, 10];
942
+ case 10: return [2 /*return*/];
812
943
  }
813
944
  });
814
945
  });
@@ -821,7 +952,7 @@ function registerOptionsControl(config) {
821
952
  : [], nodePath: nodePathArray, loading: formItem ? formItem.loading : false, setLoading: this.setLoading, setOptions: this.setOptions, syncOptions: this.syncOptions, reloadOptions: this.reload, deferLoad: this.deferLoad, leftDeferLoad: this.leftDeferLoad, expandTreeOptions: this.expandTreeOptions, creatable: creatable !== false && api.isEffectiveApi(addApi) ? true : creatable, editable: editable || (editable !== false && api.isEffectiveApi(editApi)), removable: removable || (removable !== false && api.isEffectiveApi(deleteApi)), onAdd: this.handleOptionAdd, onEdit: this.handleOptionEdit, onDelete: this.handleOptionDelete })));
822
953
  };
823
954
  FormOptionsItem.displayName = "OptionsControl(".concat(config.type, ")");
824
- FormOptionsItem.defaultProps = tslib.__assign({ delimiter: ',', labelField: 'label', valueField: 'value', joinValues: true, extractValue: false, multiple: false, placeholder: 'Select.placeholder', resetValue: '', deleteConfirmText: 'deleteConfirm' }, Control.defaultProps);
955
+ FormOptionsItem.defaultProps = tslib.__assign({ delimiter: ',', labelField: 'label', valueField: 'value', joinValues: true, extractValue: false, multiple: false, placeholder: 'Select.placeholder', resetValue: '', deleteConfirmText: 'deleteConfirm', initAutoFill: 'fillIfNotSet' }, Control.defaultProps);
825
956
  FormOptionsItem.propsList = Control.propsList
826
957
  ? tslib.__spreadArray([], tslib.__read(Control.propsList), false) : [];
827
958
  FormOptionsItem.ComposedComponent = Control;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.4
2
+ * amis-core v6.1.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.4
2
+ * amis-core v6.1.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.6.4
2
+ * amis-core v6.1.0
3
3
  * Copyright 2018-2024 fex
4
4
  */
5
5