amis-core 2.5.1 → 2.5.2

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 (233) hide show
  1. package/esm/Root.js +1 -1
  2. package/esm/RootRenderer.js +1 -1
  3. package/esm/SchemaRenderer.js +1 -1
  4. package/esm/Scoped.js +1 -1
  5. package/esm/WithRootStore.js +1 -1
  6. package/esm/WithStore.js +1 -1
  7. package/esm/actions/Action.js +1 -1
  8. package/esm/actions/AjaxAction.js +1 -1
  9. package/esm/actions/BreakAction.js +1 -1
  10. package/esm/actions/BroadcastAction.js +1 -1
  11. package/esm/actions/CmptAction.d.ts +1 -1
  12. package/esm/actions/CmptAction.js +16 -12
  13. package/esm/actions/ContinueAction.js +1 -1
  14. package/esm/actions/CopyAction.js +1 -1
  15. package/esm/actions/CustomAction.js +2 -1
  16. package/esm/actions/DialogAction.js +1 -1
  17. package/esm/actions/DrawerAction.js +1 -1
  18. package/esm/actions/EmailAction.js +1 -1
  19. package/esm/actions/LinkAction.js +1 -1
  20. package/esm/actions/LoopAction.js +1 -1
  21. package/esm/actions/PageAction.js +1 -1
  22. package/esm/actions/ParallelAction.js +1 -1
  23. package/esm/actions/SwitchAction.js +1 -1
  24. package/esm/actions/ToastAction.js +1 -1
  25. package/esm/components/LazyComponent.js +1 -1
  26. package/esm/components/Overlay.js +2 -1
  27. package/esm/components/PopOver.js +2 -1
  28. package/esm/env.js +1 -1
  29. package/esm/envOverwrite.js +1 -1
  30. package/esm/factory.js +1 -1
  31. package/esm/index.d.ts +1 -0
  32. package/esm/index.js +3 -2
  33. package/esm/locale.js +7 -3
  34. package/esm/renderers/Form.js +3 -3
  35. package/esm/renderers/Item.js +9 -5
  36. package/esm/renderers/Options.js +1 -1
  37. package/esm/renderers/Placeholder.js +1 -1
  38. package/esm/renderers/builtin.js +1 -1
  39. package/esm/renderers/register.d.ts +6 -0
  40. package/esm/renderers/register.js +78 -0
  41. package/esm/renderers/wrapControl.js +3 -3
  42. package/esm/store/app.js +1 -1
  43. package/esm/store/combo.js +1 -1
  44. package/esm/store/crud.js +1 -1
  45. package/esm/store/form.js +3 -3
  46. package/esm/store/formItem.js +1 -1
  47. package/esm/store/iRenderer.js +1 -1
  48. package/esm/store/index.js +1 -1
  49. package/esm/store/list.js +1 -1
  50. package/esm/store/manager.js +1 -1
  51. package/esm/store/modal.js +1 -1
  52. package/esm/store/node.js +1 -1
  53. package/esm/store/pagination.js +1 -1
  54. package/esm/store/root.js +1 -1
  55. package/esm/store/service.js +1 -1
  56. package/esm/store/table.js +1 -1
  57. package/esm/store/table2.js +1 -1
  58. package/esm/theme.js +1 -1
  59. package/esm/types.d.ts +2 -0
  60. package/esm/utils/Animation.js +1 -1
  61. package/esm/utils/ColorScale.js +1 -1
  62. package/esm/utils/DataSchema.js +1 -1
  63. package/esm/utils/DataScope.js +1 -1
  64. package/esm/utils/RootClose.js +1 -1
  65. package/esm/utils/SimpleMap.js +1 -1
  66. package/esm/utils/api.js +1 -1
  67. package/esm/utils/attachmentAdpator.js +1 -1
  68. package/esm/utils/autobind.js +1 -1
  69. package/esm/utils/columnsSplit.js +1 -1
  70. package/esm/utils/dataMapping.js +1 -1
  71. package/esm/utils/date.js +1 -1
  72. package/esm/utils/debug.js +1 -1
  73. package/esm/utils/decodeEntity.js +1 -1
  74. package/esm/utils/dom.js +1 -1
  75. package/esm/utils/errors.js +1 -1
  76. package/esm/utils/escapeHtml.js +1 -1
  77. package/esm/utils/filter-schema.js +1 -1
  78. package/esm/utils/filter.js +1 -1
  79. package/esm/utils/formatDuration.js +1 -1
  80. package/esm/utils/formula.js +1 -1
  81. package/esm/utils/getVariable.js +1 -1
  82. package/esm/utils/grammar.js +1 -1
  83. package/esm/utils/handleAction.js +1 -1
  84. package/esm/utils/helper.js +1 -1
  85. package/esm/utils/highlight.js +1 -1
  86. package/esm/utils/icon.js +1 -1
  87. package/esm/utils/image.js +1 -1
  88. package/esm/utils/isPureVariable.js +1 -1
  89. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  90. package/esm/utils/keyToPath.js +1 -1
  91. package/esm/utils/makeSorter.js +1 -1
  92. package/esm/utils/normalizeLink.js +1 -1
  93. package/esm/utils/normalizeOptions.js +1 -1
  94. package/esm/utils/object.js +1 -1
  95. package/esm/utils/offset.js +1 -1
  96. package/esm/utils/offsetParent.js +1 -1
  97. package/esm/utils/optionValueCompare.js +1 -1
  98. package/esm/utils/position.js +1 -1
  99. package/esm/utils/prettyBytes.js +1 -1
  100. package/esm/utils/renderer-event.d.ts +11 -0
  101. package/esm/utils/renderer-event.js +78 -13
  102. package/esm/utils/replaceText.js +1 -1
  103. package/esm/utils/resize-sensor.js +1 -1
  104. package/esm/utils/resolveVariable.js +1 -1
  105. package/esm/utils/resolveVariableAndFilter.js +1 -1
  106. package/esm/utils/scrollPosition.js +1 -1
  107. package/esm/utils/string2regExp.js +1 -1
  108. package/esm/utils/stripNumber.js +1 -1
  109. package/esm/utils/style.js +1 -1
  110. package/esm/utils/toNumber.js +1 -1
  111. package/esm/utils/tokenize.js +1 -1
  112. package/esm/utils/tpl-builtin.js +1 -1
  113. package/esm/utils/tpl-lodash.js +1 -1
  114. package/esm/utils/tpl.js +1 -1
  115. package/esm/utils/uncontrollable.js +1 -1
  116. package/esm/utils/validations.js +1 -1
  117. package/lib/Root.js +1 -1
  118. package/lib/RootRenderer.js +1 -1
  119. package/lib/SchemaRenderer.js +1 -1
  120. package/lib/Scoped.js +1 -1
  121. package/lib/WithRootStore.js +1 -1
  122. package/lib/WithStore.js +1 -1
  123. package/lib/actions/Action.js +1 -1
  124. package/lib/actions/AjaxAction.js +1 -1
  125. package/lib/actions/BreakAction.js +1 -1
  126. package/lib/actions/BroadcastAction.js +1 -1
  127. package/lib/actions/CmptAction.d.ts +1 -1
  128. package/lib/actions/CmptAction.js +16 -12
  129. package/lib/actions/ContinueAction.js +1 -1
  130. package/lib/actions/CopyAction.js +1 -1
  131. package/lib/actions/CustomAction.js +2 -1
  132. package/lib/actions/DialogAction.js +1 -1
  133. package/lib/actions/DrawerAction.js +1 -1
  134. package/lib/actions/EmailAction.js +1 -1
  135. package/lib/actions/LinkAction.js +1 -1
  136. package/lib/actions/LoopAction.js +1 -1
  137. package/lib/actions/PageAction.js +1 -1
  138. package/lib/actions/ParallelAction.js +1 -1
  139. package/lib/actions/SwitchAction.js +1 -1
  140. package/lib/actions/ToastAction.js +1 -1
  141. package/lib/components/LazyComponent.js +1 -1
  142. package/lib/components/Overlay.js +2 -1
  143. package/lib/components/PopOver.js +2 -1
  144. package/lib/env.js +1 -1
  145. package/lib/envOverwrite.js +1 -1
  146. package/lib/factory.js +1 -1
  147. package/lib/index.d.ts +1 -0
  148. package/lib/index.js +3 -2
  149. package/lib/locale.js +7 -3
  150. package/lib/renderers/Form.js +4 -4
  151. package/lib/renderers/Item.js +10 -6
  152. package/lib/renderers/Options.js +1 -1
  153. package/lib/renderers/Placeholder.js +1 -1
  154. package/lib/renderers/builtin.js +1 -1
  155. package/lib/renderers/register.d.ts +6 -0
  156. package/lib/renderers/register.js +82 -0
  157. package/lib/renderers/wrapControl.js +4 -4
  158. package/lib/store/app.js +1 -1
  159. package/lib/store/combo.js +1 -1
  160. package/lib/store/crud.js +1 -1
  161. package/lib/store/form.js +4 -4
  162. package/lib/store/formItem.js +1 -1
  163. package/lib/store/iRenderer.js +1 -1
  164. package/lib/store/index.js +1 -1
  165. package/lib/store/list.js +1 -1
  166. package/lib/store/manager.js +1 -1
  167. package/lib/store/modal.js +1 -1
  168. package/lib/store/node.js +1 -1
  169. package/lib/store/pagination.js +1 -1
  170. package/lib/store/root.js +1 -1
  171. package/lib/store/service.js +1 -1
  172. package/lib/store/table.js +1 -1
  173. package/lib/store/table2.js +1 -1
  174. package/lib/theme.js +1 -1
  175. package/lib/types.d.ts +2 -0
  176. package/lib/utils/Animation.js +1 -1
  177. package/lib/utils/ColorScale.js +1 -1
  178. package/lib/utils/DataSchema.js +1 -1
  179. package/lib/utils/DataScope.js +1 -1
  180. package/lib/utils/RootClose.js +1 -1
  181. package/lib/utils/SimpleMap.js +1 -1
  182. package/lib/utils/api.js +1 -1
  183. package/lib/utils/attachmentAdpator.js +1 -1
  184. package/lib/utils/autobind.js +1 -1
  185. package/lib/utils/columnsSplit.js +1 -1
  186. package/lib/utils/dataMapping.js +1 -1
  187. package/lib/utils/date.js +1 -1
  188. package/lib/utils/debug.js +1 -1
  189. package/lib/utils/decodeEntity.js +1 -1
  190. package/lib/utils/dom.js +1 -1
  191. package/lib/utils/errors.js +1 -1
  192. package/lib/utils/escapeHtml.js +1 -1
  193. package/lib/utils/filter-schema.js +1 -1
  194. package/lib/utils/filter.js +1 -1
  195. package/lib/utils/formatDuration.js +1 -1
  196. package/lib/utils/formula.js +1 -1
  197. package/lib/utils/getVariable.js +1 -1
  198. package/lib/utils/grammar.js +1 -1
  199. package/lib/utils/handleAction.js +1 -1
  200. package/lib/utils/helper.js +1 -1
  201. package/lib/utils/highlight.js +1 -1
  202. package/lib/utils/icon.js +1 -1
  203. package/lib/utils/image.js +1 -1
  204. package/lib/utils/isPureVariable.js +1 -1
  205. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  206. package/lib/utils/keyToPath.js +1 -1
  207. package/lib/utils/makeSorter.js +1 -1
  208. package/lib/utils/normalizeLink.js +1 -1
  209. package/lib/utils/normalizeOptions.js +1 -1
  210. package/lib/utils/object.js +1 -1
  211. package/lib/utils/offset.js +1 -1
  212. package/lib/utils/offsetParent.js +1 -1
  213. package/lib/utils/optionValueCompare.js +1 -1
  214. package/lib/utils/position.js +1 -1
  215. package/lib/utils/prettyBytes.js +1 -1
  216. package/lib/utils/renderer-event.d.ts +11 -0
  217. package/lib/utils/renderer-event.js +82 -13
  218. package/lib/utils/replaceText.js +1 -1
  219. package/lib/utils/resize-sensor.js +1 -1
  220. package/lib/utils/resolveVariable.js +1 -1
  221. package/lib/utils/resolveVariableAndFilter.js +1 -1
  222. package/lib/utils/scrollPosition.js +1 -1
  223. package/lib/utils/string2regExp.js +1 -1
  224. package/lib/utils/stripNumber.js +1 -1
  225. package/lib/utils/style.js +1 -1
  226. package/lib/utils/toNumber.js +1 -1
  227. package/lib/utils/tokenize.js +1 -1
  228. package/lib/utils/tpl-builtin.js +1 -1
  229. package/lib/utils/tpl-lodash.js +1 -1
  230. package/lib/utils/tpl.js +1 -1
  231. package/lib/utils/uncontrollable.js +1 -1
  232. package/lib/utils/validations.js +1 -1
  233. package/package.json +3 -3
package/esm/Root.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
package/esm/Scoped.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
package/esm/WithStore.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,7 +1,7 @@
1
1
  import { RendererEvent } from '../utils/renderer-event';
2
2
  import { RendererAction, ListenerAction, ListenerContext } from './Action';
3
3
  export interface ICmptAction extends ListenerAction {
4
- actionType: 'setValue' | 'static' | 'nonstatic' | 'show' | 'hidden' | 'enabled' | 'disabled' | 'reload';
4
+ actionType: 'setValue' | 'static' | 'nonstatic' | 'show' | 'visibility' | 'hidden' | 'enabled' | 'disabled' | 'usability' | 'reload';
5
5
  args: {
6
6
  value?: string | {
7
7
  [key: string]: string;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -17,39 +17,43 @@ var CmptAction = /** @class */ (function () {
17
17
  function CmptAction() {
18
18
  }
19
19
  CmptAction.prototype.run = function (action, renderer, event) {
20
- var _a, _b, _c, _d, _e, _f, _g, _h;
20
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
21
21
  return __awaiter(this, void 0, void 0, function () {
22
- var component, dataMergeMode;
23
- return __generator(this, function (_j) {
22
+ var component, dataMergeMode, visibility, usability;
23
+ return __generator(this, function (_l) {
24
24
  component = action.componentId && renderer.props.$schema.id !== action.componentId
25
25
  ? (_a = event.context.scoped) === null || _a === void 0 ? void 0 : _a.getComponentById(action.componentId)
26
26
  : renderer;
27
27
  dataMergeMode = action.dataMergeMode || 'merge';
28
28
  // 显隐&状态控制
29
- if (['show', 'hidden'].includes(action.actionType)) {
30
- return [2 /*return*/, renderer.props.topStore.setVisible(action.componentId, action.actionType === 'show')];
29
+ if (['show', 'hidden', 'visibility'].includes(action.actionType)) {
30
+ visibility = action.actionType === 'visibility'
31
+ ? (_b = action.args) === null || _b === void 0 ? void 0 : _b.value : action.actionType === 'show';
32
+ return [2 /*return*/, renderer.props.topStore.setVisible(action.componentId, visibility)];
31
33
  }
32
34
  else if (['static', 'nonstatic'].includes(action.actionType)) {
33
35
  return [2 /*return*/, renderer.props.topStore.setStatic(action.componentId, action.actionType === 'static')];
34
36
  }
35
- else if (['enabled', 'disabled'].includes(action.actionType)) {
36
- return [2 /*return*/, renderer.props.topStore.setDisable(action.componentId, action.actionType === 'disabled')];
37
+ else if (['enabled', 'disabled', 'usability'].includes(action.actionType)) {
38
+ usability = action.actionType === 'usability'
39
+ ? !((_c = action.args) === null || _c === void 0 ? void 0 : _c.value) : action.actionType === 'disabled';
40
+ return [2 /*return*/, renderer.props.topStore.setDisable(action.componentId, usability)];
37
41
  }
38
42
  // 数据更新
39
43
  if (action.actionType === 'setValue') {
40
44
  if (component === null || component === void 0 ? void 0 : component.setData) {
41
- return [2 /*return*/, component === null || component === void 0 ? void 0 : component.setData((_b = action.args) === null || _b === void 0 ? void 0 : _b.value, dataMergeMode === 'override', (_c = action.args) === null || _c === void 0 ? void 0 : _c.index)];
45
+ return [2 /*return*/, component === null || component === void 0 ? void 0 : component.setData((_d = action.args) === null || _d === void 0 ? void 0 : _d.value, dataMergeMode === 'override', (_e = action.args) === null || _e === void 0 ? void 0 : _e.index)];
42
46
  }
43
47
  else {
44
- return [2 /*return*/, (_e = component === null || component === void 0 ? void 0 : (_d = component.props).onChange) === null || _e === void 0 ? void 0 : _e.call(_d, (_f = action.args) === null || _f === void 0 ? void 0 : _f.value)];
48
+ return [2 /*return*/, (_g = component === null || component === void 0 ? void 0 : (_f = component.props).onChange) === null || _g === void 0 ? void 0 : _g.call(_f, (_h = action.args) === null || _h === void 0 ? void 0 : _h.value)];
45
49
  }
46
50
  }
47
51
  // 刷新
48
52
  if (action.actionType === 'reload') {
49
- return [2 /*return*/, (_g = component === null || component === void 0 ? void 0 : component.reload) === null || _g === void 0 ? void 0 : _g.call(component, undefined, action.data, undefined, undefined, dataMergeMode === 'override', action.args)];
53
+ return [2 /*return*/, (_j = component === null || component === void 0 ? void 0 : component.reload) === null || _j === void 0 ? void 0 : _j.call(component, undefined, action.data, undefined, undefined, dataMergeMode === 'override', action.args)];
50
54
  }
51
55
  // 执行组件动作
52
- return [2 /*return*/, (_h = component === null || component === void 0 ? void 0 : component.doAction) === null || _h === void 0 ? void 0 : _h.call(component, action, action.args)];
56
+ return [2 /*return*/, (_k = component === null || component === void 0 ? void 0 : component.doAction) === null || _k === void 0 ? void 0 : _k.call(component, action, action.args)];
53
57
  });
54
58
  });
55
59
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -26,6 +26,7 @@ import 'lodash/isBoolean';
26
26
  import 'lodash';
27
27
  import '../utils/image.js';
28
28
  import { registerAction, runActions } from './Action.js';
29
+ import 'lodash/debounce';
29
30
  import '../utils/resize-sensor.js';
30
31
  import 'react-overlays/useRootClose';
31
32
  import '../utils/SimpleMap.js';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -28,6 +28,7 @@ import 'lodash/isBoolean';
28
28
  import 'lodash';
29
29
  import '../utils/image.js';
30
30
  import '../actions/Action.js';
31
+ import 'lodash/debounce';
31
32
  import { getComputedStyle, resizeSensor } from '../utils/resize-sensor.js';
32
33
  import { RootClose } from '../utils/RootClose.js';
33
34
  import '../utils/SimpleMap.js';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -27,6 +27,7 @@ import 'lodash/isBoolean';
27
27
  import 'lodash';
28
28
  import '../utils/image.js';
29
29
  import '../actions/Action.js';
30
+ import 'lodash/debounce';
30
31
  import '../utils/resize-sensor.js';
31
32
  import 'react-overlays/useRootClose';
32
33
  import '../utils/SimpleMap.js';
package/esm/env.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
package/esm/factory.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
package/esm/index.d.ts CHANGED
@@ -9,6 +9,7 @@
9
9
  import { Renderer, getRendererByName, getRenderers, registerRenderer, unRegisterRenderer, resolveRenderer, filterSchema, clearStoresCache, updateEnv, addSchemaFilter, extendDefaultEnv } from './factory';
10
10
  import type { RenderOptions, RendererConfig, RendererProps } from './factory';
11
11
  import './renderers/builtin';
12
+ import './renderers/register';
12
13
  export * from './utils/index';
13
14
  export * from './types';
14
15
  export * from './store';
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -7,6 +7,7 @@ import { __assign } from 'tslib';
7
7
  import { stores, defaultOptions } from './factory.js';
8
8
  export { Renderer, addSchemaFilter, clearStoresCache, extendDefaultEnv, filterSchema, getRendererByName, getRenderers, registerRenderer, resolveRenderer, unRegisterRenderer, updateEnv } from './factory.js';
9
9
  import './renderers/builtin.js';
10
+ import './renderers/register.js';
10
11
  import { wrapFetcher } from './utils/api.js';
11
12
  export { buildApi, clearApiCache, getApiCache, isApiOutdated, isApiOutdatedWithData, isEffectiveApi, isSameApi, isValidApi, jsFetcher, jsonpFetcher, normalizeApi, normalizeApiResponseData, responseAdaptor, setApiCache, str2AsyncFunction, str2function, wrapAdaptor, wrapFetcher } from './utils/api.js';
12
13
  export { attachmentAdpator } from './utils/attachmentAdpator.js';
@@ -122,7 +123,7 @@ export { StoreNode } from './store/node.js';
122
123
 
123
124
  var classPrefix = getClassPrefix();
124
125
  // @ts-ignore
125
- var version = '2.5.1';
126
+ var version = '2.5.2';
126
127
  function render(schema, props, options, pathPrefix) {
127
128
  if (props === void 0) { props = {}; }
128
129
  if (options === void 0) { options = {}; }
package/esm/locale.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -35,6 +35,7 @@ function makeTranslator(locale) {
35
35
  return fns[locale];
36
36
  }
37
37
  var fn = function (str) {
38
+ var _a, _b, _c;
38
39
  var args = [];
39
40
  for (var _i = 1; _i < arguments.length; _i++) {
40
41
  args[_i - 1] = arguments[_i];
@@ -42,8 +43,11 @@ function makeTranslator(locale) {
42
43
  if (!str || typeof str !== 'string') {
43
44
  return str;
44
45
  }
45
- var dict = locales[locale] || locales[defaultLocale] || locales['zh-CN'];
46
- return format.apply(void 0, __spreadArray([(dict === null || dict === void 0 ? void 0 : dict[str]) || str], args, false));
46
+ var value = ((_a = locales[locale]) === null || _a === void 0 ? void 0 : _a[str]) ||
47
+ ((_b = locales[defaultLocale]) === null || _b === void 0 ? void 0 : _b[str]) ||
48
+ ((_c = locales['zh-CN']) === null || _c === void 0 ? void 0 : _c[str]) ||
49
+ str;
50
+ return format.apply(void 0, __spreadArray([value], args, false));
47
51
  };
48
52
  locale && (fns[locale] = fn);
49
53
  return fn;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -11,7 +11,7 @@ import { FormStore } from '../store/form.js';
11
11
  import { evalExpression, filter } from '../utils/tpl.js';
12
12
  import { getExprProperties } from '../utils/filter-schema.js';
13
13
  import { promisify, isEmpty, until, noop, isVisible, SkipOperation, difference, repeatCount, qsparse, isObjectShallowModified } from '../utils/helper.js';
14
- import debouce from 'lodash/debounce';
14
+ import debounce from 'lodash/debounce';
15
15
  import flatten from 'lodash/flatten';
16
16
  import find from 'lodash/find';
17
17
  import { ScopedContext } from '../Scoped.js';
@@ -31,7 +31,7 @@ var Form = /** @class */ (function (_super) {
31
31
  var _this = _super.call(this, props) || this;
32
32
  _this.hooks = {};
33
33
  _this.shouldLoadInitApi = false;
34
- _this.lazyEmitChange = debouce(_this.emitChange.bind(_this), 250, {
34
+ _this.lazyEmitChange = debounce(_this.emitChange.bind(_this), 250, {
35
35
  trailing: true,
36
36
  leading: false
37
37
  });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -13,7 +13,7 @@ import { observer } from 'mobx-react';
13
13
  import { filter } from '../utils/tpl.js';
14
14
  import { HocStoreFactory } from '../WithStore.js';
15
15
  import { wrapControl } from './wrapControl.js';
16
- import debouce from 'lodash/debounce';
16
+ import debounce from 'lodash/debounce';
17
17
  import { isEffectiveApi, isApiOutdated } from '../utils/api.js';
18
18
  import { findDOMNode } from 'react-dom';
19
19
  import '../utils/ColorScale.js';
@@ -64,7 +64,7 @@ var FormItemWrap = /** @class */ (function (_super) {
64
64
  function FormItemWrap(props) {
65
65
  var _this = _super.call(this, props) || this;
66
66
  _this.reaction = [];
67
- _this.syncAutoFill = debouce(function (term, reload) {
67
+ _this.syncAutoFill = debounce(function (term, reload) {
68
68
  (function (term, reload) { return __awaiter(_this, void 0, void 0, function () {
69
69
  var _a, autoFill, onBulkChange, formItem, data, itemName, ctx, result;
70
70
  var _b;
@@ -323,7 +323,9 @@ var FormItemWrap = /** @class */ (function (_super) {
323
323
  };
324
324
  FormItemWrap.prototype.renderControl = function () {
325
325
  var _a;
326
- var _b = this.props, model = _b.formItem, cx = _b.classnames; _b.children; var type = _b.type, renderControl = _b.renderControl; _b.formItemConfig; var sizeMutable = _b.sizeMutable, size = _b.size, defaultSize = _b.defaultSize, useMobileUI = _b.useMobileUI, rest = __rest(_b, ["formItem", "classnames", "children", "type", "renderControl", "formItemConfig", "sizeMutable", "size", "defaultSize", "useMobileUI"]);
326
+ var _b = this.props;
327
+ // 这里解构,不可轻易删除,避免被rest传到子组件
328
+ _b.inputClassName; var model = _b.formItem, cx = _b.classnames; _b.children; var type = _b.type, renderControl = _b.renderControl; _b.formItemConfig; var sizeMutable = _b.sizeMutable, size = _b.size, defaultSize = _b.defaultSize, useMobileUI = _b.useMobileUI, rest = __rest(_b, ["inputClassName", "formItem", "classnames", "children", "type", "renderControl", "formItemConfig", "sizeMutable", "size", "defaultSize", "useMobileUI"]);
327
329
  var mobileUI = useMobileUI && isMobile();
328
330
  if (renderControl) {
329
331
  var controlSize = size || defaultSize;
@@ -807,7 +809,9 @@ function asFormItem(config) {
807
809
  };
808
810
  class_1.prototype.renderControl = function () {
809
811
  var _a;
810
- var _b = this.props, model = _b.formItem, cx = _b.classnames; _b.children; var type = _b.type, size = _b.size, defaultSize = _b.defaultSize, useMobileUI = _b.useMobileUI, rest = __rest(_b, ["formItem", "classnames", "children", "type", "size", "defaultSize", "useMobileUI"]);
812
+ var _b = this.props;
813
+ // 这里解构,不可轻易删除,避免被rest传到子组件
814
+ _b.inputClassName; var model = _b.formItem, cx = _b.classnames; _b.children; var type = _b.type, size = _b.size, defaultSize = _b.defaultSize, useMobileUI = _b.useMobileUI, rest = __rest(_b, ["inputClassName", "formItem", "classnames", "children", "type", "size", "defaultSize", "useMobileUI"]);
811
815
  var controlSize = size || defaultSize;
812
816
  var mobileUI = useMobileUI && isMobile();
813
817
  //@ts-ignore
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 提供两种特殊的注册渲染器的方式
3
+ * 1、自动加载预先注册的自定义渲染器:自动加载并注册 window.AmisCustomRenderers 中的渲染器
4
+ * 2、通过 postMessage 告知 amis 注册一个新的渲染器:间接注册渲染器,无需直接依赖 amis。
5
+ */
6
+ export declare function autoPreRegisterAmisCustomRenderers(): void;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * amis-core v2.5.2
3
+ * Copyright 2018-2022 fex
4
+ */
5
+
6
+ import { renderersMap, Renderer } from '../factory.js';
7
+ import { OptionsControl } from './Options.js';
8
+ import { FormItem } from './Item.js';
9
+
10
+ /**
11
+ * 提供两种特殊的注册渲染器的方式
12
+ * 1、自动加载预先注册的自定义渲染器:自动加载并注册 window.AmisCustomRenderers 中的渲染器
13
+ * 2、通过 postMessage 告知 amis 注册一个新的渲染器:间接注册渲染器,无需直接依赖 amis。
14
+ */
15
+ // 自动加载预先注册的自定义渲染器
16
+ function autoPreRegisterAmisCustomRenderers() {
17
+ if (window.AmisCustomRenderers) {
18
+ Object.keys(window.AmisCustomRenderers).forEach(function (rendererType) {
19
+ if (renderersMap[rendererType]) {
20
+ console.warn("[amis-core]\uFF1A\u9884\u6CE8\u518C\u6E32\u67D3\u5668\u5931\u8D25\uFF0C\u5F53\u524D\u5DF2\u5B58\u5728\u91CD\u540D\u6E32\u67D3\u5668\uFF08".concat(rendererType, "\uFF09\u3002"));
21
+ }
22
+ else {
23
+ var curAmisRenderer = window.AmisCustomRenderers[rendererType];
24
+ if (curAmisRenderer) {
25
+ registerAmisRendererByUsage(rendererType, curAmisRenderer);
26
+ }
27
+ }
28
+ });
29
+ }
30
+ }
31
+ // 自动加载并注册 window.AmisCustomRenderers 中的渲染器
32
+ autoPreRegisterAmisCustomRenderers();
33
+ // postMessage 渲染器动态注册机制
34
+ window.addEventListener('message', function (event) {
35
+ var _a, _b, _c;
36
+ if (!event.data) {
37
+ return;
38
+ }
39
+ if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'amis-renderer-register-event' &&
40
+ ((_b = event.data) === null || _b === void 0 ? void 0 : _b.amisRenderer) &&
41
+ event.data.amisRenderer.type) {
42
+ var curAmisRenderer = (_c = event.data) === null || _c === void 0 ? void 0 : _c.amisRenderer;
43
+ var curUsage = (curAmisRenderer === null || curAmisRenderer === void 0 ? void 0 : curAmisRenderer.usage) || 'renderer';
44
+ if (renderersMap[curAmisRenderer.type]) {
45
+ console.warn("[amis-core]\uFF1A\u52A8\u6001\u6CE8\u518C\u6E32\u67D3\u5668\u5931\u8D25\uFF0C\u5F53\u524D\u5DF2\u5B58\u5728\u91CD\u540D\u6E32\u67D3\u5668\uFF08".concat(curAmisRenderer.type, "\uFF09\u3002"));
46
+ }
47
+ else {
48
+ console.info('[amis-core]响应动态注册渲染器事件:', curAmisRenderer.type);
49
+ registerAmisRendererByUsage(curUsage, curAmisRenderer);
50
+ }
51
+ }
52
+ }, false);
53
+ // 根据类型(usage)进行注册 amis渲染器
54
+ function registerAmisRendererByUsage(curUsage, curAmisRenderer) {
55
+ // 当前支持注册的渲染器类型
56
+ var registerMap = {
57
+ renderer: Renderer,
58
+ formitem: FormItem,
59
+ options: OptionsControl,
60
+ };
61
+ var curAmisRendererComponent = curAmisRenderer.component;
62
+ if (!curAmisRendererComponent &&
63
+ window.AmisCustomRenderers &&
64
+ window.AmisCustomRenderers[curAmisRenderer.type] &&
65
+ window.AmisCustomRenderers[curAmisRenderer.type].component) {
66
+ curAmisRendererComponent = window.AmisCustomRenderers[curAmisRenderer.type].component;
67
+ }
68
+ if (curAmisRendererComponent &&
69
+ ['renderer', 'formitem', 'options'].includes(curUsage) &&
70
+ registerMap[curUsage]) {
71
+ registerMap[curUsage]({
72
+ type: curAmisRenderer.type,
73
+ weight: curAmisRenderer.weight || 0,
74
+ })(curAmisRendererComponent);
75
+ }
76
+ }
77
+
78
+ export { autoPreRegisterAmisCustomRenderers };
@@ -1,11 +1,11 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
6
6
  import { __extends, __awaiter, __generator, __assign } from 'tslib';
7
7
  import React from 'react';
8
- import debouce from 'lodash/debounce';
8
+ 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, anyChanged } from '../utils/helper.js';
@@ -28,7 +28,7 @@ function wrapControl(ComposedComponent) {
28
28
  var _a, _b;
29
29
  _this = _super.call(this, props) || this;
30
30
  _this.value = undefined;
31
- _this.lazyEmitChange = debouce(_this.emitChange.bind(_this), 250, {
31
+ _this.lazyEmitChange = debounce(_this.emitChange.bind(_this), 250, {
32
32
  trailing: true,
33
33
  leading: false
34
34
  });
package/esm/store/app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
package/esm/store/crud.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
package/esm/store/form.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
- * amis-core v2.5.1
2
+ * amis-core v2.5.2
3
3
  * Copyright 2018-2022 fex
4
4
  */
5
5
 
6
6
  import { __generator, __assign } from 'tslib';
7
7
  import { types, flow, isAlive, getEnv } from 'mobx-state-tree';
8
- import debouce from 'lodash/debounce';
8
+ import debounce from 'lodash/debounce';
9
9
  import toPairs from 'lodash/toPairs';
10
10
  import pick from 'lodash/pick';
11
11
  import { ServiceStore } from './service.js';
@@ -217,7 +217,7 @@ var FormStore = ServiceStore.named('FormStore')
217
217
  });
218
218
  self.updateData(data);
219
219
  }
220
- var syncOptions = debouce(function () { return self.items.forEach(function (item) { return item.syncOptions(undefined, self.data); }); }, 250, {
220
+ var syncOptions = debounce(function () { return self.items.forEach(function (item) { return item.syncOptions(undefined, self.data); }); }, 250, {
221
221
  trailing: true,
222
222
  leading: false
223
223
  });