amis-core 6.0.0 → 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 (293) hide show
  1. package/esm/Root.js +2 -2
  2. package/esm/RootRenderer.js +4 -3
  3. package/esm/SchemaRenderer.js +5 -2
  4. package/esm/Scoped.d.ts +6 -0
  5. package/esm/Scoped.js +45 -8
  6. package/esm/StatusScoped.js +2 -2
  7. package/esm/WithRootStore.js +2 -2
  8. package/esm/WithStore.js +4 -6
  9. package/esm/actions/Action.js +2 -2
  10. package/esm/actions/AjaxAction.js +2 -2
  11. package/esm/actions/BreakAction.js +2 -2
  12. package/esm/actions/BroadcastAction.js +2 -2
  13. package/esm/actions/CmptAction.js +2 -2
  14. package/esm/actions/ContinueAction.js +2 -2
  15. package/esm/actions/CopyAction.js +2 -2
  16. package/esm/actions/CustomAction.js +3 -3
  17. package/esm/actions/DialogAction.js +2 -2
  18. package/esm/actions/DrawerAction.js +2 -2
  19. package/esm/actions/EmailAction.js +2 -2
  20. package/esm/actions/LinkAction.js +10 -5
  21. package/esm/actions/LoopAction.js +2 -2
  22. package/esm/actions/PageAction.js +2 -2
  23. package/esm/actions/ParallelAction.js +2 -2
  24. package/esm/actions/StatusAction.js +2 -2
  25. package/esm/actions/SwitchAction.js +2 -2
  26. package/esm/actions/ToastAction.js +2 -2
  27. package/esm/components/CustomStyle.d.ts +1 -2
  28. package/esm/components/CustomStyle.js +20 -7
  29. package/esm/components/ErrorBoundary.js +2 -2
  30. package/esm/components/LazyComponent.js +2 -2
  31. package/esm/components/Overlay.js +11 -9
  32. package/esm/components/PopOver.js +7 -5
  33. package/esm/env.d.ts +4 -0
  34. package/esm/env.js +2 -2
  35. package/esm/envOverwrite.js +2 -2
  36. package/esm/factory.js +15 -2
  37. package/esm/index.d.ts +2 -2
  38. package/esm/index.js +13 -8
  39. package/esm/locale.js +2 -2
  40. package/esm/polyfills.js +2 -2
  41. package/esm/renderers/Form.d.ts +4 -3
  42. package/esm/renderers/Form.js +94 -42
  43. package/esm/renderers/Item.d.ts +1 -0
  44. package/esm/renderers/Item.js +15 -16
  45. package/esm/renderers/Options.d.ts +5 -0
  46. package/esm/renderers/Options.js +27 -10
  47. package/esm/renderers/Placeholder.js +2 -2
  48. package/esm/renderers/builtin.js +2 -2
  49. package/esm/renderers/register.js +2 -2
  50. package/esm/renderers/wrapControl.js +37 -29
  51. package/esm/store/app.js +3 -3
  52. package/esm/store/combo.d.ts +48 -24
  53. package/esm/store/combo.js +2 -2
  54. package/esm/store/crud.js +2 -2
  55. package/esm/store/form.d.ts +20 -10
  56. package/esm/store/form.js +2 -2
  57. package/esm/store/formItem.d.ts +2 -1
  58. package/esm/store/formItem.js +4 -3
  59. package/esm/store/iRenderer.js +5 -3
  60. package/esm/store/index.js +2 -2
  61. package/esm/store/list.js +2 -2
  62. package/esm/store/manager.js +2 -2
  63. package/esm/store/modal.js +2 -2
  64. package/esm/store/node.js +2 -2
  65. package/esm/store/pagination.js +2 -2
  66. package/esm/store/root.js +3 -3
  67. package/esm/store/service.js +2 -2
  68. package/esm/store/status.js +2 -2
  69. package/esm/store/table.d.ts +42 -20
  70. package/esm/store/table.js +33 -19
  71. package/esm/store/table2.js +2 -2
  72. package/esm/theme.js +2 -2
  73. package/esm/utils/Animation.js +2 -2
  74. package/esm/utils/ColorScale.js +2 -2
  75. package/esm/utils/DataSchema.js +2 -2
  76. package/esm/utils/DataScope.js +2 -2
  77. package/esm/utils/RootClose.js +2 -2
  78. package/esm/utils/SimpleMap.js +2 -2
  79. package/esm/utils/api.js +2 -2
  80. package/esm/utils/arraySlice.js +2 -2
  81. package/esm/utils/attachmentAdpator.js +2 -2
  82. package/esm/utils/autobind.js +2 -2
  83. package/esm/utils/browser.js +2 -2
  84. package/esm/utils/columnsSplit.js +2 -2
  85. package/esm/utils/concatData.js +2 -2
  86. package/esm/utils/dataMapping.js +2 -2
  87. package/esm/utils/date.js +2 -2
  88. package/esm/utils/debug.js +2 -2
  89. package/esm/utils/decodeEntity.js +2 -2
  90. package/esm/utils/dom.js +2 -2
  91. package/esm/utils/errors.js +2 -2
  92. package/esm/utils/escapeHtml.js +2 -2
  93. package/esm/utils/filter-schema.js +2 -2
  94. package/esm/utils/filter.js +2 -2
  95. package/esm/utils/formatDuration.js +2 -2
  96. package/esm/utils/formula.js +2 -2
  97. package/esm/utils/getVariable.js +2 -2
  98. package/esm/utils/grammar.js +2 -2
  99. package/esm/utils/handleAction.js +2 -2
  100. package/esm/utils/helper.d.ts +8 -1
  101. package/esm/utils/helper.js +28 -10
  102. package/esm/utils/highlight.js +4 -3
  103. package/esm/utils/icon.js +2 -2
  104. package/esm/utils/image.js +2 -2
  105. package/esm/utils/index.d.ts +1 -0
  106. package/esm/utils/isPureVariable.js +2 -2
  107. package/esm/utils/json-schema-2-amis-schema.js +2 -2
  108. package/esm/utils/keyToPath.js +2 -2
  109. package/esm/utils/labelToString.d.ts +1 -0
  110. package/esm/utils/labelToString.js +38 -0
  111. package/esm/utils/makeSorter.js +2 -2
  112. package/esm/utils/math.js +2 -2
  113. package/esm/utils/memoryParse.js +2 -2
  114. package/esm/utils/normalizeLink.js +2 -2
  115. package/esm/utils/normalizeOptions.js +2 -2
  116. package/esm/utils/object.js +2 -2
  117. package/esm/utils/offset.js +2 -2
  118. package/esm/utils/offsetParent.js +2 -2
  119. package/esm/utils/optionValueCompare.js +2 -2
  120. package/esm/utils/position.js +2 -2
  121. package/esm/utils/prettyBytes.js +2 -2
  122. package/esm/utils/renderer-event.js +2 -2
  123. package/esm/utils/replaceText.js +10 -12
  124. package/esm/utils/resize-sensor.js +2 -2
  125. package/esm/utils/resolveCondition.js +2 -2
  126. package/esm/utils/resolveVariable.js +2 -2
  127. package/esm/utils/resolveVariableAndFilter.js +2 -2
  128. package/esm/utils/resolveVariableAndFilterForAsync.js +2 -2
  129. package/esm/utils/scrollPosition.js +2 -2
  130. package/esm/utils/string2regExp.d.ts +1 -1
  131. package/esm/utils/string2regExp.js +5 -4
  132. package/esm/utils/stripNumber.js +2 -2
  133. package/esm/utils/style-helper.d.ts +24 -5
  134. package/esm/utils/style-helper.js +47 -17
  135. package/esm/utils/style.js +2 -2
  136. package/esm/utils/toNumber.js +2 -2
  137. package/esm/utils/tokenize.d.ts +1 -0
  138. package/esm/utils/tokenize.js +11 -4
  139. package/esm/utils/tpl-builtin.js +2 -2
  140. package/esm/utils/tpl-lodash.js +2 -2
  141. package/esm/utils/tpl.js +7 -9
  142. package/esm/utils/uncontrollable.js +2 -2
  143. package/esm/utils/validateId.d.ts +16 -0
  144. package/esm/utils/validateId.js +154 -0
  145. package/esm/utils/validations.js +17 -9
  146. package/lib/Root.js +2 -2
  147. package/lib/RootRenderer.d.ts +1 -1
  148. package/lib/RootRenderer.js +4 -3
  149. package/lib/SchemaRenderer.js +5 -2
  150. package/lib/Scoped.d.ts +6 -0
  151. package/lib/Scoped.js +45 -7
  152. package/lib/StatusScoped.js +2 -2
  153. package/lib/WithRootStore.js +2 -2
  154. package/lib/WithStore.js +4 -6
  155. package/lib/actions/Action.js +2 -2
  156. package/lib/actions/AjaxAction.js +2 -2
  157. package/lib/actions/BreakAction.js +2 -2
  158. package/lib/actions/BroadcastAction.js +2 -2
  159. package/lib/actions/CmptAction.js +2 -2
  160. package/lib/actions/ContinueAction.js +2 -2
  161. package/lib/actions/CopyAction.js +2 -2
  162. package/lib/actions/CustomAction.js +3 -3
  163. package/lib/actions/DialogAction.js +2 -2
  164. package/lib/actions/DrawerAction.js +2 -2
  165. package/lib/actions/EmailAction.js +2 -2
  166. package/lib/actions/LinkAction.js +10 -5
  167. package/lib/actions/LoopAction.js +2 -2
  168. package/lib/actions/PageAction.js +2 -2
  169. package/lib/actions/ParallelAction.js +2 -2
  170. package/lib/actions/StatusAction.js +2 -2
  171. package/lib/actions/SwitchAction.js +2 -2
  172. package/lib/actions/ToastAction.js +2 -2
  173. package/lib/components/CustomStyle.d.ts +1 -2
  174. package/lib/components/CustomStyle.js +20 -7
  175. package/lib/components/ErrorBoundary.js +2 -2
  176. package/lib/components/LazyComponent.js +2 -2
  177. package/lib/components/Overlay.js +10 -8
  178. package/lib/components/PopOver.js +7 -5
  179. package/lib/env.d.ts +4 -0
  180. package/lib/env.js +2 -2
  181. package/lib/envOverwrite.js +2 -2
  182. package/lib/factory.js +15 -2
  183. package/lib/index.d.ts +2 -2
  184. package/lib/index.js +16 -5
  185. package/lib/locale.js +2 -2
  186. package/lib/polyfills.js +2 -2
  187. package/lib/renderers/Form.d.ts +4 -3
  188. package/lib/renderers/Form.js +94 -42
  189. package/lib/renderers/Item.d.ts +1 -0
  190. package/lib/renderers/Item.js +15 -16
  191. package/lib/renderers/Options.d.ts +5 -0
  192. package/lib/renderers/Options.js +27 -10
  193. package/lib/renderers/Placeholder.js +2 -2
  194. package/lib/renderers/builtin.js +2 -2
  195. package/lib/renderers/register.js +2 -2
  196. package/lib/renderers/wrapControl.js +36 -28
  197. package/lib/store/app.js +3 -3
  198. package/lib/store/combo.d.ts +72 -49
  199. package/lib/store/combo.js +2 -2
  200. package/lib/store/crud.js +2 -2
  201. package/lib/store/form.d.ts +30 -21
  202. package/lib/store/form.js +2 -2
  203. package/lib/store/formItem.d.ts +2 -1
  204. package/lib/store/formItem.js +4 -3
  205. package/lib/store/iRenderer.js +5 -3
  206. package/lib/store/index.js +2 -2
  207. package/lib/store/list.js +2 -2
  208. package/lib/store/manager.js +2 -2
  209. package/lib/store/modal.js +2 -2
  210. package/lib/store/node.js +2 -2
  211. package/lib/store/pagination.js +2 -2
  212. package/lib/store/root.js +3 -3
  213. package/lib/store/service.js +2 -2
  214. package/lib/store/status.js +2 -2
  215. package/lib/store/table.d.ts +62 -41
  216. package/lib/store/table.js +33 -19
  217. package/lib/store/table2.js +2 -2
  218. package/lib/theme.js +2 -2
  219. package/lib/utils/Animation.js +2 -2
  220. package/lib/utils/ColorScale.js +2 -2
  221. package/lib/utils/DataSchema.js +2 -2
  222. package/lib/utils/DataScope.js +2 -2
  223. package/lib/utils/RootClose.js +2 -2
  224. package/lib/utils/SimpleMap.js +2 -2
  225. package/lib/utils/api.js +2 -2
  226. package/lib/utils/arraySlice.js +2 -2
  227. package/lib/utils/attachmentAdpator.js +2 -2
  228. package/lib/utils/autobind.js +2 -2
  229. package/lib/utils/browser.js +2 -2
  230. package/lib/utils/columnsSplit.js +2 -2
  231. package/lib/utils/concatData.js +2 -2
  232. package/lib/utils/dataMapping.js +2 -2
  233. package/lib/utils/date.js +2 -2
  234. package/lib/utils/debug.js +2 -2
  235. package/lib/utils/decodeEntity.js +2 -2
  236. package/lib/utils/dom.js +2 -2
  237. package/lib/utils/errors.js +2 -2
  238. package/lib/utils/escapeHtml.js +2 -2
  239. package/lib/utils/filter-schema.js +2 -2
  240. package/lib/utils/filter.js +2 -2
  241. package/lib/utils/formatDuration.js +2 -2
  242. package/lib/utils/formula.js +2 -2
  243. package/lib/utils/getVariable.js +2 -2
  244. package/lib/utils/grammar.js +2 -2
  245. package/lib/utils/handleAction.js +2 -2
  246. package/lib/utils/helper.d.ts +8 -1
  247. package/lib/utils/helper.js +29 -8
  248. package/lib/utils/highlight.js +4 -3
  249. package/lib/utils/icon.js +2 -2
  250. package/lib/utils/image.js +2 -2
  251. package/lib/utils/index.d.ts +1 -0
  252. package/lib/utils/isPureVariable.js +2 -2
  253. package/lib/utils/json-schema-2-amis-schema.js +2 -2
  254. package/lib/utils/keyToPath.js +2 -2
  255. package/lib/utils/labelToString.d.ts +1 -0
  256. package/lib/utils/labelToString.js +46 -0
  257. package/lib/utils/makeSorter.js +2 -2
  258. package/lib/utils/math.js +2 -2
  259. package/lib/utils/memoryParse.js +2 -2
  260. package/lib/utils/normalizeLink.js +2 -2
  261. package/lib/utils/normalizeOptions.js +2 -2
  262. package/lib/utils/object.js +2 -2
  263. package/lib/utils/offset.js +2 -2
  264. package/lib/utils/offsetParent.js +2 -2
  265. package/lib/utils/optionValueCompare.js +2 -2
  266. package/lib/utils/position.js +2 -2
  267. package/lib/utils/prettyBytes.js +2 -2
  268. package/lib/utils/renderer-event.js +2 -2
  269. package/lib/utils/replaceText.js +9 -15
  270. package/lib/utils/resize-sensor.js +2 -2
  271. package/lib/utils/resolveCondition.js +2 -2
  272. package/lib/utils/resolveVariable.js +2 -2
  273. package/lib/utils/resolveVariableAndFilter.js +2 -2
  274. package/lib/utils/resolveVariableAndFilterForAsync.js +2 -2
  275. package/lib/utils/scrollPosition.js +2 -2
  276. package/lib/utils/string2regExp.d.ts +1 -1
  277. package/lib/utils/string2regExp.js +5 -4
  278. package/lib/utils/stripNumber.js +2 -2
  279. package/lib/utils/style-helper.d.ts +24 -5
  280. package/lib/utils/style-helper.js +47 -17
  281. package/lib/utils/style.js +2 -2
  282. package/lib/utils/toNumber.js +2 -2
  283. package/lib/utils/tokenize.d.ts +1 -0
  284. package/lib/utils/tokenize.js +11 -3
  285. package/lib/utils/tpl-builtin.js +2 -2
  286. package/lib/utils/tpl-lodash.js +2 -2
  287. package/lib/utils/tpl.js +6 -8
  288. package/lib/utils/uncontrollable.js +2 -2
  289. package/lib/utils/validateId.d.ts +16 -0
  290. package/lib/utils/validateId.js +160 -0
  291. package/lib/utils/validations.js +17 -9
  292. package/package.json +3 -3
  293. package/LICENSE +0 -201
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v6.0.0
3
- * Copyright 2018-2023 fex
2
+ * amis-core v6.1.0
3
+ * Copyright 2018-2024 fex
4
4
  */
5
5
 
6
6
  'use strict';
@@ -43,13 +43,13 @@ require('../utils/icon.js');
43
43
  require('../utils/image.js');
44
44
  var keyToPath = require('../utils/keyToPath.js');
45
45
  var rendererEvent = require('../utils/renderer-event.js');
46
- require('lodash/cloneDeep');
47
46
  require('../utils/resize-sensor.js');
48
47
  require('react-overlays/useRootClose');
49
48
  require('react-dom');
50
49
  require('../utils/SimpleMap.js');
51
50
  require('lodash/mapValues');
52
51
  require('lodash/camelCase');
52
+ require('lodash/cloneDeep');
53
53
  require('lodash/map');
54
54
  require('lodash/isEmpty');
55
55
  require('lodash/kebabCase');
@@ -96,6 +96,7 @@ function registerOptionsControl(config) {
96
96
  _this = _super.call(this, props) || this;
97
97
  _this.toDispose = [];
98
98
  _this.mounted = false;
99
+ _this.initedFilled = false;
99
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;
100
101
  if (formItem) {
101
102
  formItem.setOptions(normalizeOptions.normalizeOptions(options, undefined, valueField), _this.changeOptionValue, data);
@@ -104,12 +105,20 @@ function registerOptionsControl(config) {
104
105
  return JSON.stringify(formItem.getSelectedOptions(formItem.tmpValue));
105
106
  }, function () {
106
107
  return _this.mounted &&
108
+ _this.initedFilled &&
107
109
  _this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue));
108
110
  }));
109
- if (options &&
110
- formItem.tmpValue &&
111
- formItem.getSelectedOptions(formItem.tmpValue).length) {
112
- _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');
113
122
  }
114
123
  // 默认全选。这里会和默认值\回填值逻辑冲突,所以如果有配置source则不执行默认全选
115
124
  if (multiple &&
@@ -241,7 +250,8 @@ function registerOptionsControl(config) {
241
250
  onChange === null || onChange === void 0 ? void 0 : onChange(resetValue !== null && resetValue !== void 0 ? resetValue : '');
242
251
  }
243
252
  };
244
- FormOptionsItem.prototype.syncAutoFill = function (selectedOptions) {
253
+ FormOptionsItem.prototype.syncAutoFill = function (selectedOptions, skipIfExits) {
254
+ if (skipIfExits === void 0) { skipIfExits = false; }
245
255
  var _a = this.props, autoFill = _a.autoFill, multiple = _a.multiple, onBulkChange = _a.onBulkChange, data = _a.data;
246
256
  var formItem = this.props.formItem;
247
257
  // 参照录入|自动填充
@@ -263,11 +273,18 @@ function registerOptionsControl(config) {
263
273
  var result_1 = tslib.__assign({}, toSync_1);
264
274
  Object.keys(autoFill).forEach(function (key) {
265
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);
266
284
  // 如果左边的 key 是一个路径
267
285
  // 这里不希望直接把原始对象都给覆盖没了
268
286
  // 而是保留原始的对象,只修改指定的属性
269
287
  if (keys.length > 1 && isPlainObject__default["default"](tmpData_1[keys[0]])) {
270
- var value = getVariable.getVariable(toSync_1, key);
271
288
  // 存在情况:依次更新同一子路径的多个key,eg: a.b.c1 和 a.b.c2,所以需要同步更新data
272
289
  object.setVariable(tmpData_1, key, value);
273
290
  result_1[keys[0]] = tmpData_1[keys[0]];
@@ -935,7 +952,7 @@ function registerOptionsControl(config) {
935
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 })));
936
953
  };
937
954
  FormOptionsItem.displayName = "OptionsControl(".concat(config.type, ")");
938
- 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);
939
956
  FormOptionsItem.propsList = Control.propsList
940
957
  ? tslib.__spreadArray([], tslib.__read(Control.propsList), false) : [];
941
958
  FormOptionsItem.ComposedComponent = Control;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v6.0.0
3
- * Copyright 2018-2023 fex
2
+ * amis-core v6.1.0
3
+ * Copyright 2018-2024 fex
4
4
  */
5
5
 
6
6
  'use strict';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v6.0.0
3
- * Copyright 2018-2023 fex
2
+ * amis-core v6.1.0
3
+ * Copyright 2018-2024 fex
4
4
  */
5
5
 
6
6
  'use strict';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v6.0.0
3
- * Copyright 2018-2023 fex
2
+ * amis-core v6.1.0
3
+ * Copyright 2018-2024 fex
4
4
  */
5
5
 
6
6
  'use strict';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v6.0.0
3
- * Copyright 2018-2023 fex
2
+ * amis-core v6.1.0
3
+ * Copyright 2018-2024 fex
4
4
  */
5
5
 
6
6
  'use strict';
@@ -42,13 +42,13 @@ require('../utils/highlight.js');
42
42
  require('../utils/icon.js');
43
43
  require('../utils/image.js');
44
44
  require('../actions/Action.js');
45
- require('lodash/cloneDeep');
46
45
  require('../utils/resize-sensor.js');
47
46
  require('react-overlays/useRootClose');
48
47
  require('react-dom');
49
48
  require('../utils/SimpleMap.js');
50
49
  require('lodash/mapValues');
51
50
  require('lodash/camelCase');
51
+ require('lodash/cloneDeep');
52
52
  require('lodash/isObject');
53
53
  require('lodash/map');
54
54
  require('lodash/isEmpty');
@@ -128,26 +128,7 @@ function wrapControl(ComposedComponent) {
128
128
  model.setIsControlled(true);
129
129
  }
130
130
  else {
131
- var isExp = formula.isExpression(value);
132
- if (isExp) {
133
- model.changeTmpValue(formula.FormulaExec['formula'](value, data), // 对组件默认值进行运算
134
- 'formulaChanged');
135
- }
136
- else {
137
- var initialValue = model.extraName
138
- ? [
139
- store === null || store === void 0 ? void 0 : store.getValueByName(model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData),
140
- store === null || store === void 0 ? void 0 : store.getValueByName(model.extraName, form === null || form === void 0 ? void 0 : form.canAccessSuperData)
141
- ]
142
- : store === null || store === void 0 ? void 0 : store.getValueByName(model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData);
143
- if (model.extraName &&
144
- initialValue.every(function (item) { return item === undefined; })) {
145
- initialValue = undefined;
146
- }
147
- model.changeTmpValue(initialValue !== null && initialValue !== void 0 ? initialValue : formula.replaceExpression(value), typeof initialValue !== 'undefined'
148
- ? 'initialValue'
149
- : 'defaultValue');
150
- }
131
+ _this.setInitialValue(value);
151
132
  }
152
133
  if (onChange &&
153
134
  value !== undefined &&
@@ -185,9 +166,7 @@ function wrapControl(ComposedComponent) {
185
166
  var _this = this;
186
167
  var _a = this.props; _a.store; _a.formStore; var validate = _a.$schema.validate, addHook = _a.addHook;
187
168
  // 提交前先把之前的 lazyEmit 执行一下。
188
- this.hook3 = function () {
189
- _this.lazyEmitChange.flush();
190
- };
169
+ this.hook3 = function () { return _this.lazyEmitChange.flush(); };
191
170
  addHook === null || addHook === void 0 ? void 0 : addHook(this.hook3, 'flush');
192
171
  var formItem = this.model;
193
172
  if (formItem && validate) {
@@ -204,6 +183,7 @@ function wrapControl(ComposedComponent) {
204
183
  }
205
184
  };
206
185
  class_1.prototype.componentDidUpdate = function (prevProps) {
186
+ var _this = this;
207
187
  var _a, _b, _c;
208
188
  var props = this.props;
209
189
  var model = this.model;
@@ -211,6 +191,7 @@ function wrapControl(ComposedComponent) {
211
191
  return;
212
192
  }
213
193
  helper.changedEffect([
194
+ 'name',
214
195
  'id',
215
196
  'validations',
216
197
  'validationErrors',
@@ -237,6 +218,9 @@ function wrapControl(ComposedComponent) {
237
218
  model.config(tslib.__assign(tslib.__assign({}, changes), {
238
219
  // todo 优化后面两个
239
220
  isValueSchemaExp: formula.isExpression(props.$schema.value), inputGroupControl: props === null || props === void 0 ? void 0 : props.inputGroupControl }));
221
+ if (changes.hasOwnProperty('name')) {
222
+ _this.setInitialValue(_this.props.$schema.value);
223
+ }
240
224
  });
241
225
  if (props.required !== prevProps.required) {
242
226
  model.config({
@@ -312,6 +296,30 @@ function wrapControl(ComposedComponent) {
312
296
  (_g = this.reaction) === null || _g === void 0 ? void 0 : _g.call(this);
313
297
  this.disposeModel();
314
298
  };
299
+ class_1.prototype.setInitialValue = function (value) {
300
+ var model = this.model;
301
+ var _a = this.props, form = _a.formStore, data = _a.data;
302
+ var isExp = formula.isExpression(value);
303
+ if (isExp) {
304
+ model.changeTmpValue(formula.FormulaExec['formula'](value, data), // 对组件默认值进行运算
305
+ 'formulaChanged');
306
+ }
307
+ else {
308
+ var initialValue = model.extraName
309
+ ? [
310
+ getVariable.getVariable(data, model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData),
311
+ getVariable.getVariable(data, model.extraName, form === null || form === void 0 ? void 0 : form.canAccessSuperData)
312
+ ]
313
+ : getVariable.getVariable(data, model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData);
314
+ if (model.extraName &&
315
+ initialValue.every(function (item) { return item === undefined; })) {
316
+ initialValue = undefined;
317
+ }
318
+ model.changeTmpValue(initialValue !== null && initialValue !== void 0 ? initialValue : formula.replaceExpression(value), typeof initialValue !== 'undefined'
319
+ ? 'initialValue'
320
+ : 'defaultValue');
321
+ }
322
+ };
315
323
  class_1.prototype.disposeModel = function () {
316
324
  var _a;
317
325
  var _b = this.props, form = _b.formStore, formItem = _b.formItem, rootStore = _b.rootStore;
@@ -524,10 +532,10 @@ function wrapControl(ComposedComponent) {
524
532
  }
525
533
  };
526
534
  class_1.prototype.getValue = function () {
527
- var _a = this.props, data = _a.formStore, control = _a.$schema;
535
+ var _a = this.props, formStore = _a.formStore, data = _a.data, control = _a.$schema;
528
536
  var value = this.model ? this.model.tmpValue : control.value;
529
537
  if (control.pipeIn) {
530
- value = api.callStrFunction.call(this, control.pipeIn, ['value', 'data'], value, data);
538
+ value = api.callStrFunction.call(this, control.pipeIn, ['value', 'store', 'data'], value, formStore, data);
531
539
  }
532
540
  return value;
533
541
  };
package/lib/store/app.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v6.0.0
3
- * Copyright 2018-2023 fex
2
+ * amis-core v6.1.0
3
+ * Copyright 2018-2024 fex
4
4
  */
5
5
 
6
6
  'use strict';
@@ -35,7 +35,6 @@ require('../utils/image.js');
35
35
  require('lodash/isEqual');
36
36
  require('../actions/Action.js');
37
37
  require('lodash/debounce');
38
- require('lodash/cloneDeep');
39
38
  require('../utils/resize-sensor.js');
40
39
  require('react');
41
40
  require('react-overlays/useRootClose');
@@ -43,6 +42,7 @@ require('react-dom');
43
42
  require('../utils/SimpleMap.js');
44
43
  require('lodash/mapValues');
45
44
  require('lodash/camelCase');
45
+ require('lodash/cloneDeep');
46
46
  require('lodash/map');
47
47
  require('lodash/isEmpty');
48
48
  require('lodash/kebabCase');