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
  import { __extends, __awaiter, __generator, __assign, __read, __rest, __decorate, __metadata, __spreadArray } from 'tslib';
@@ -36,7 +36,6 @@ import 'lodash/isBoolean';
36
36
  import '../utils/image.js';
37
37
  import 'lodash/isEqual';
38
38
  import '../actions/Action.js';
39
- import 'lodash/cloneDeep';
40
39
  import '../utils/resize-sensor.js';
41
40
  import 'react-overlays/useRootClose';
42
41
  import '../utils/SimpleMap.js';
@@ -56,7 +55,7 @@ var getItemLabelClassName = function (props) {
56
55
  var staticLabelClassName = props.staticLabelClassName, labelClassName = props.labelClassName, id = props.id, themeCss = props.themeCss;
57
56
  return props.static && staticLabelClassName
58
57
  ? staticLabelClassName
59
- : cx(labelClassName, setThemeClassName('labelClassName', id, themeCss, 'item'));
58
+ : cx(labelClassName, setThemeClassName(__assign(__assign({}, props), { name: 'labelClassName', id: id, themeCss: themeCss, extra: 'item' })));
60
59
  };
61
60
  var getItemInputClassName = function (props) {
62
61
  var staticInputClassName = props.staticInputClassName, inputClassName = props.inputClassName;
@@ -348,7 +347,7 @@ var FormItemWrap = /** @class */ (function (_super) {
348
347
  typeof controlSize === 'string' &&
349
348
  !!controlSize &&
350
349
  controlSize !== 'full',
351
- _a), model === null || model === void 0 ? void 0 : model.errClassNames, setThemeClassName('wrapperCustomStyle', rest.id, rest.wrapperCustomStyle, 'item'), getItemInputClassName(this.props)) }));
350
+ _a), model === null || model === void 0 ? void 0 : model.errClassNames, setThemeClassName(__assign(__assign({}, this.props), { name: 'wrapperCustomStyle', id: rest.id, themeCss: rest.wrapperCustomStyle, extra: 'item' })), getItemInputClassName(this.props)) }));
352
351
  }
353
352
  return null;
354
353
  };
@@ -371,7 +370,7 @@ var FormItemWrap = /** @class */ (function (_super) {
371
370
  formStore: undefined
372
371
  })
373
372
  : null,
374
- React.createElement(CustomStyle, { config: {
373
+ React.createElement(CustomStyle, __assign({}, this.props, { config: {
375
374
  themeCss: themeCss || css,
376
375
  classNames: [
377
376
  {
@@ -383,7 +382,7 @@ var FormItemWrap = /** @class */ (function (_super) {
383
382
  ],
384
383
  wrapperCustomStyle: wrapperCustomStyle,
385
384
  id: id && id + '-item'
386
- }, env: env })));
385
+ }, env: env }))));
387
386
  };
388
387
  /**
389
388
  * 布局扩充点,可以自己扩充表单项的布局方式
@@ -407,7 +406,7 @@ var FormItemWrap = /** @class */ (function (_super) {
407
406
  },
408
407
  _a["is-error"] = model && !model.valid,
409
408
  _a["is-required"] = required,
410
- _a), model === null || model === void 0 ? void 0 : model.errClassNames, setThemeClassName('wrapperCustomStyle', id, wrapperCustomStyle, 'item')), style: style },
409
+ _a), model === null || model === void 0 ? void 0 : model.errClassNames, setThemeClassName(__assign(__assign({}, props), { name: 'wrapperCustomStyle', id: id, themeCss: wrapperCustomStyle, extra: 'item' }))), style: style },
411
410
  label !== false ? (React.createElement("label", { className: cx("Form-label", (_b = {},
412
411
  _b["Form-itemColumn--".concat(typeof horizontal.leftFixed === 'string'
413
412
  ? horizontal.leftFixed
@@ -460,7 +459,7 @@ var FormItemWrap = /** @class */ (function (_super) {
460
459
  Array.isArray(model.errors) ? (React.createElement("ul", { className: cx("Form-feedback") }, model.errors.map(function (msg, key) { return (React.createElement("li", { key: key }, msg)); }))) : null,
461
460
  renderDescription !== false && description
462
461
  ? render('description', description, {
463
- className: cx("Form-description", descriptionClassName, setThemeClassName('descriptionClassName', id, themeCss, 'item'))
462
+ className: cx("Form-description", descriptionClassName, setThemeClassName(__assign(__assign({}, props), { name: 'descriptionClassName', id: id, themeCss: themeCss, extra: 'item' })))
464
463
  })
465
464
  : null)));
466
465
  },
@@ -472,7 +471,7 @@ var FormItemWrap = /** @class */ (function (_super) {
472
471
  'is-error': model && !model.valid
473
472
  },
474
473
  _a["is-required"] = required,
475
- _a), model === null || model === void 0 ? void 0 : model.errClassNames, setThemeClassName('wrapperCustomStyle', id, wrapperCustomStyle, 'item')), style: style },
474
+ _a), model === null || model === void 0 ? void 0 : model.errClassNames, setThemeClassName(__assign(__assign({}, props), { name: 'wrapperCustomStyle', id: id, themeCss: wrapperCustomStyle, extra: 'item' }))), style: style },
476
475
  label && renderLabel !== false ? (React.createElement("label", { className: cx("Form-label", getItemLabelClassName(props)) },
477
476
  React.createElement("span", null,
478
477
  label ? render('label', label) : null,
@@ -515,7 +514,7 @@ var FormItemWrap = /** @class */ (function (_super) {
515
514
  Array.isArray(model.errors) ? (React.createElement("ul", { className: cx("Form-feedback") }, model.errors.map(function (msg, key) { return (React.createElement("li", { key: key }, msg)); }))) : null,
516
515
  renderDescription !== false && description
517
516
  ? render('description', description, {
518
- className: cx("Form-description", descriptionClassName, setThemeClassName('descriptionClassName', id, themeCss, 'item'))
517
+ className: cx("Form-description", descriptionClassName, setThemeClassName(__assign(__assign({}, props), { name: 'descriptionClassName', id: id, themeCss: themeCss, extra: 'item' })))
519
518
  })
520
519
  : null)) : (React.createElement(React.Fragment, null,
521
520
  renderControl(),
@@ -545,7 +544,7 @@ var FormItemWrap = /** @class */ (function (_super) {
545
544
  Array.isArray(model.errors) ? (React.createElement("ul", { className: cx("Form-feedback") }, model.errors.map(function (msg, key) { return (React.createElement("li", { key: key }, msg)); }))) : null,
546
545
  renderDescription !== false && description
547
546
  ? render('description', description, {
548
- className: cx("Form-description", descriptionClassName, setThemeClassName('descriptionClassName', id, themeCss, 'item'))
547
+ className: cx("Form-description", descriptionClassName, setThemeClassName(__assign(__assign({}, props), { name: 'descriptionClassName', id: id, themeCss: themeCss, extra: 'item' })))
549
548
  })
550
549
  : null))));
551
550
  },
@@ -558,7 +557,7 @@ var FormItemWrap = /** @class */ (function (_super) {
558
557
  'is-error': model && !model.valid
559
558
  },
560
559
  _a["is-required"] = required,
561
- _a), model === null || model === void 0 ? void 0 : model.errClassNames, setThemeClassName('wrapperCustomStyle', id, wrapperCustomStyle, 'item')), style: style },
560
+ _a), model === null || model === void 0 ? void 0 : model.errClassNames, setThemeClassName(__assign(__assign({}, props), { name: 'wrapperCustomStyle', id: id, themeCss: wrapperCustomStyle, extra: 'item' }))), style: style },
562
561
  label && renderLabel !== false ? (React.createElement("label", { className: cx("Form-label", getItemLabelClassName(props)), style: labelWidth != null ? { width: labelWidth } : undefined },
563
562
  React.createElement("span", null,
564
563
  label ? render('label', label) : label,
@@ -601,7 +600,7 @@ var FormItemWrap = /** @class */ (function (_super) {
601
600
  Array.isArray(model.errors) ? (React.createElement("ul", { className: cx("Form-feedback") }, model.errors.map(function (msg, key) { return (React.createElement("li", { key: key }, msg)); }))) : null,
602
601
  renderDescription !== false && description
603
602
  ? render('description', description, {
604
- className: cx("Form-description", descriptionClassName, setThemeClassName('descriptionClassName', id, themeCss, 'item'))
603
+ className: cx("Form-description", descriptionClassName, setThemeClassName(__assign(__assign({}, props), { name: 'descriptionClassName', id: id, themeCss: themeCss, extra: 'item' })))
605
604
  })
606
605
  : null)));
607
606
  },
@@ -614,7 +613,7 @@ var FormItemWrap = /** @class */ (function (_super) {
614
613
  'is-error': model && !model.valid
615
614
  },
616
615
  _a["is-required"] = required,
617
- _a), model === null || model === void 0 ? void 0 : model.errClassNames, setThemeClassName('wrapperCustomStyle', id, wrapperCustomStyle, 'item')), style: style },
616
+ _a), model === null || model === void 0 ? void 0 : model.errClassNames, setThemeClassName(__assign(__assign({}, props), { name: 'wrapperCustomStyle', id: id, themeCss: wrapperCustomStyle, extra: 'item' }))), style: style },
618
617
  React.createElement("div", { className: cx('Form-rowInner') },
619
618
  label && renderLabel !== false ? (React.createElement("label", { className: cx("Form-label", getItemLabelClassName(props)), style: labelWidth != null ? { width: labelWidth } : undefined },
620
619
  React.createElement("span", null,
@@ -656,7 +655,7 @@ var FormItemWrap = /** @class */ (function (_super) {
656
655
  Array.isArray(model.errors) ? (React.createElement("ul", { className: cx('Form-feedback') }, model.errors.map(function (msg, key) { return (React.createElement("li", { key: key }, msg)); }))) : null,
657
656
  description && renderDescription !== false
658
657
  ? render('description', description, {
659
- className: cx("Form-description", descriptionClassName, setThemeClassName('descriptionClassName', id, themeCss, 'item'))
658
+ className: cx("Form-description", descriptionClassName, setThemeClassName(__assign(__assign({}, props), { name: 'descriptionClassName', id: id, themeCss: themeCss, extra: 'item' })))
660
659
  })
661
660
  : null));
662
661
  }
@@ -126,6 +126,11 @@ export interface FormOptionsControl extends FormBaseControl {
126
126
  autoFill?: {
127
127
  [propName: string]: string;
128
128
  };
129
+ /**
130
+ * @default fillIfNotSet
131
+ * 初始化时是否把其他字段同步到表单内部。
132
+ */
133
+ initAutoFill?: boolean | 'fillIfNotSet';
129
134
  }
130
135
  export interface OptionsBasicConfig extends FormItemBasicConfig {
131
136
  autoLoadOptionsFromSource?: boolean;
@@ -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
  import { __extends, __awaiter, __generator, __assign, __spreadArray, __read, __decorate, __metadata } from 'tslib';
@@ -37,12 +37,12 @@ import 'lodash/isBoolean';
37
37
  import '../utils/image.js';
38
38
  import { keyToPath } from '../utils/keyToPath.js';
39
39
  import { resolveEventData } from '../utils/renderer-event.js';
40
- import 'lodash/cloneDeep';
41
40
  import '../utils/resize-sensor.js';
42
41
  import 'react-overlays/useRootClose';
43
42
  import '../utils/SimpleMap.js';
44
43
  import 'lodash/mapValues';
45
44
  import 'lodash/camelCase';
45
+ import 'lodash/cloneDeep';
46
46
  import 'lodash/map';
47
47
  import 'lodash/isEmpty';
48
48
  import 'lodash/kebabCase';
@@ -80,6 +80,7 @@ function registerOptionsControl(config) {
80
80
  _this = _super.call(this, props) || this;
81
81
  _this.toDispose = [];
82
82
  _this.mounted = false;
83
+ _this.initedFilled = false;
83
84
  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;
84
85
  if (formItem) {
85
86
  formItem.setOptions(normalizeOptions(options, undefined, valueField), _this.changeOptionValue, data);
@@ -88,12 +89,20 @@ function registerOptionsControl(config) {
88
89
  return JSON.stringify(formItem.getSelectedOptions(formItem.tmpValue));
89
90
  }, function () {
90
91
  return _this.mounted &&
92
+ _this.initedFilled &&
91
93
  _this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue));
92
94
  }));
93
- if (options &&
94
- formItem.tmpValue &&
95
- formItem.getSelectedOptions(formItem.tmpValue).length) {
96
- _this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue));
95
+ if (formInited || !addHook) {
96
+ _this.initedFilled = true;
97
+ _this.props.initAutoFill !== false &&
98
+ _this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue), _this.props.initAutoFill === 'fillIfNotSet');
99
+ }
100
+ else if (addHook) {
101
+ addHook(function () {
102
+ _this.initedFilled = true;
103
+ _this.props.initAutoFill !== false &&
104
+ _this.syncAutoFill(formItem.getSelectedOptions(formItem.tmpValue), _this.props.initAutoFill === 'fillIfNotSet');
105
+ }, 'init');
97
106
  }
98
107
  // 默认全选。这里会和默认值\回填值逻辑冲突,所以如果有配置source则不执行默认全选
99
108
  if (multiple &&
@@ -225,7 +234,8 @@ function registerOptionsControl(config) {
225
234
  onChange === null || onChange === void 0 ? void 0 : onChange(resetValue !== null && resetValue !== void 0 ? resetValue : '');
226
235
  }
227
236
  };
228
- FormOptionsItem.prototype.syncAutoFill = function (selectedOptions) {
237
+ FormOptionsItem.prototype.syncAutoFill = function (selectedOptions, skipIfExits) {
238
+ if (skipIfExits === void 0) { skipIfExits = false; }
229
239
  var _a = this.props, autoFill = _a.autoFill, multiple = _a.multiple, onBulkChange = _a.onBulkChange, data = _a.data;
230
240
  var formItem = this.props.formItem;
231
241
  // 参照录入|自动填充
@@ -247,11 +257,18 @@ function registerOptionsControl(config) {
247
257
  var result_1 = __assign({}, toSync_1);
248
258
  Object.keys(autoFill).forEach(function (key) {
249
259
  var keys = keyToPath(key);
260
+ var value = getVariable(toSync_1, key);
261
+ if (skipIfExits) {
262
+ var originValue = getVariable(data, key);
263
+ if (typeof originValue !== 'undefined') {
264
+ value = originValue;
265
+ }
266
+ }
267
+ setVariable(result_1, key, value);
250
268
  // 如果左边的 key 是一个路径
251
269
  // 这里不希望直接把原始对象都给覆盖没了
252
270
  // 而是保留原始的对象,只修改指定的属性
253
271
  if (keys.length > 1 && isPlainObject(tmpData_1[keys[0]])) {
254
- var value = getVariable(toSync_1, key);
255
272
  // 存在情况:依次更新同一子路径的多个key,eg: a.b.c1 和 a.b.c2,所以需要同步更新data
256
273
  setVariable(tmpData_1, key, value);
257
274
  result_1[keys[0]] = tmpData_1[keys[0]];
@@ -919,7 +936,7 @@ function registerOptionsControl(config) {
919
936
  : [], 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 && isEffectiveApi(addApi) ? true : creatable, editable: editable || (editable !== false && isEffectiveApi(editApi)), removable: removable || (removable !== false && isEffectiveApi(deleteApi)), onAdd: this.handleOptionAdd, onEdit: this.handleOptionEdit, onDelete: this.handleOptionDelete })));
920
937
  };
921
938
  FormOptionsItem.displayName = "OptionsControl(".concat(config.type, ")");
922
- FormOptionsItem.defaultProps = __assign({ delimiter: ',', labelField: 'label', valueField: 'value', joinValues: true, extractValue: false, multiple: false, placeholder: 'Select.placeholder', resetValue: '', deleteConfirmText: 'deleteConfirm' }, Control.defaultProps);
939
+ FormOptionsItem.defaultProps = __assign({ delimiter: ',', labelField: 'label', valueField: 'value', joinValues: true, extractValue: false, multiple: false, placeholder: 'Select.placeholder', resetValue: '', deleteConfirmText: 'deleteConfirm', initAutoFill: 'fillIfNotSet' }, Control.defaultProps);
923
940
  FormOptionsItem.propsList = Control.propsList
924
941
  ? __spreadArray([], __read(Control.propsList), false) : [];
925
942
  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
  import { __extends } from 'tslib';
@@ -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
  import { Placeholder } from './Placeholder.js';
@@ -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
  import { __assign } from 'tslib';
@@ -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
  import { __extends, __assign, __awaiter, __generator } from 'tslib';
@@ -9,7 +9,7 @@ import debounce from 'lodash/debounce';
9
9
  import isEqual from 'lodash/isEqual';
10
10
  import { ComboStore } from '../store/combo.js';
11
11
  import { guid, promisify, changedEffect } from '../utils/helper.js';
12
- import { isExpression, FormulaExec, replaceExpression, isNeedFormula } from '../utils/formula.js';
12
+ import { isExpression, isNeedFormula, FormulaExec, replaceExpression } from '../utils/formula.js';
13
13
  import { ScopedContext } from '../Scoped.js';
14
14
  import { FormItemStore } from '../store/formItem.js';
15
15
  import { isAlive } from 'mobx-state-tree';
@@ -37,12 +37,12 @@ import '../utils/filter.js';
37
37
  import 'lodash/isObject';
38
38
  import '../utils/image.js';
39
39
  import '../actions/Action.js';
40
- import 'lodash/cloneDeep';
41
40
  import '../utils/resize-sensor.js';
42
41
  import 'react-overlays/useRootClose';
43
42
  import '../utils/SimpleMap.js';
44
43
  import 'lodash/mapValues';
45
44
  import 'lodash/camelCase';
45
+ import 'lodash/cloneDeep';
46
46
  import 'lodash/map';
47
47
  import 'lodash/isEmpty';
48
48
  import 'lodash/kebabCase';
@@ -110,26 +110,7 @@ function wrapControl(ComposedComponent) {
110
110
  model.setIsControlled(true);
111
111
  }
112
112
  else {
113
- var isExp = isExpression(value);
114
- if (isExp) {
115
- model.changeTmpValue(FormulaExec['formula'](value, data), // 对组件默认值进行运算
116
- 'formulaChanged');
117
- }
118
- else {
119
- var initialValue = model.extraName
120
- ? [
121
- store === null || store === void 0 ? void 0 : store.getValueByName(model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData),
122
- store === null || store === void 0 ? void 0 : store.getValueByName(model.extraName, form === null || form === void 0 ? void 0 : form.canAccessSuperData)
123
- ]
124
- : store === null || store === void 0 ? void 0 : store.getValueByName(model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData);
125
- if (model.extraName &&
126
- initialValue.every(function (item) { return item === undefined; })) {
127
- initialValue = undefined;
128
- }
129
- model.changeTmpValue(initialValue !== null && initialValue !== void 0 ? initialValue : replaceExpression(value), typeof initialValue !== 'undefined'
130
- ? 'initialValue'
131
- : 'defaultValue');
132
- }
113
+ _this.setInitialValue(value);
133
114
  }
134
115
  if (onChange &&
135
116
  value !== undefined &&
@@ -167,9 +148,7 @@ function wrapControl(ComposedComponent) {
167
148
  var _this = this;
168
149
  var _a = this.props; _a.store; _a.formStore; var validate = _a.$schema.validate, addHook = _a.addHook;
169
150
  // 提交前先把之前的 lazyEmit 执行一下。
170
- this.hook3 = function () {
171
- _this.lazyEmitChange.flush();
172
- };
151
+ this.hook3 = function () { return _this.lazyEmitChange.flush(); };
173
152
  addHook === null || addHook === void 0 ? void 0 : addHook(this.hook3, 'flush');
174
153
  var formItem = this.model;
175
154
  if (formItem && validate) {
@@ -186,6 +165,7 @@ function wrapControl(ComposedComponent) {
186
165
  }
187
166
  };
188
167
  class_1.prototype.componentDidUpdate = function (prevProps) {
168
+ var _this = this;
189
169
  var _a, _b, _c;
190
170
  var props = this.props;
191
171
  var model = this.model;
@@ -193,6 +173,7 @@ function wrapControl(ComposedComponent) {
193
173
  return;
194
174
  }
195
175
  changedEffect([
176
+ 'name',
196
177
  'id',
197
178
  'validations',
198
179
  'validationErrors',
@@ -219,6 +200,9 @@ function wrapControl(ComposedComponent) {
219
200
  model.config(__assign(__assign({}, changes), {
220
201
  // todo 优化后面两个
221
202
  isValueSchemaExp: isExpression(props.$schema.value), inputGroupControl: props === null || props === void 0 ? void 0 : props.inputGroupControl }));
203
+ if (changes.hasOwnProperty('name')) {
204
+ _this.setInitialValue(_this.props.$schema.value);
205
+ }
222
206
  });
223
207
  if (props.required !== prevProps.required) {
224
208
  model.config({
@@ -294,6 +278,30 @@ function wrapControl(ComposedComponent) {
294
278
  (_g = this.reaction) === null || _g === void 0 ? void 0 : _g.call(this);
295
279
  this.disposeModel();
296
280
  };
281
+ class_1.prototype.setInitialValue = function (value) {
282
+ var model = this.model;
283
+ var _a = this.props, form = _a.formStore, data = _a.data;
284
+ var isExp = isExpression(value);
285
+ if (isExp) {
286
+ model.changeTmpValue(FormulaExec['formula'](value, data), // 对组件默认值进行运算
287
+ 'formulaChanged');
288
+ }
289
+ else {
290
+ var initialValue = model.extraName
291
+ ? [
292
+ getVariable(data, model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData),
293
+ getVariable(data, model.extraName, form === null || form === void 0 ? void 0 : form.canAccessSuperData)
294
+ ]
295
+ : getVariable(data, model.name, form === null || form === void 0 ? void 0 : form.canAccessSuperData);
296
+ if (model.extraName &&
297
+ initialValue.every(function (item) { return item === undefined; })) {
298
+ initialValue = undefined;
299
+ }
300
+ model.changeTmpValue(initialValue !== null && initialValue !== void 0 ? initialValue : replaceExpression(value), typeof initialValue !== 'undefined'
301
+ ? 'initialValue'
302
+ : 'defaultValue');
303
+ }
304
+ };
297
305
  class_1.prototype.disposeModel = function () {
298
306
  var _a;
299
307
  var _b = this.props, form = _b.formStore, formItem = _b.formItem, rootStore = _b.rootStore;
@@ -506,10 +514,10 @@ function wrapControl(ComposedComponent) {
506
514
  }
507
515
  };
508
516
  class_1.prototype.getValue = function () {
509
- var _a = this.props, data = _a.formStore, control = _a.$schema;
517
+ var _a = this.props, formStore = _a.formStore, data = _a.data, control = _a.$schema;
510
518
  var value = this.model ? this.model.tmpValue : control.value;
511
519
  if (control.pipeIn) {
512
- value = callStrFunction.call(this, control.pipeIn, ['value', 'data'], value, data);
520
+ value = callStrFunction.call(this, control.pipeIn, ['value', 'store', 'data'], value, formStore, data);
513
521
  }
514
522
  return value;
515
523
  };
package/esm/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
  import { __assign } from 'tslib';
@@ -30,12 +30,12 @@ import '../utils/image.js';
30
30
  import 'lodash/isEqual';
31
31
  import '../actions/Action.js';
32
32
  import 'lodash/debounce';
33
- import 'lodash/cloneDeep';
34
33
  import '../utils/resize-sensor.js';
35
34
  import 'react-overlays/useRootClose';
36
35
  import '../utils/SimpleMap.js';
37
36
  import 'lodash/mapValues';
38
37
  import 'lodash/camelCase';
38
+ import 'lodash/cloneDeep';
39
39
  import 'lodash/map';
40
40
  import 'lodash/isEmpty';
41
41
  import 'lodash/kebabCase';