amis-core 2.9.0 → 3.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 (331) hide show
  1. package/esm/Root.d.ts +89 -4
  2. package/esm/Root.js +15 -4
  3. package/esm/RootRenderer.d.ts +3 -1
  4. package/esm/RootRenderer.js +9 -3
  5. package/esm/SchemaRenderer.d.ts +4 -2
  6. package/esm/SchemaRenderer.js +32 -24
  7. package/esm/Scoped.d.ts +8 -0
  8. package/esm/Scoped.js +20 -5
  9. package/esm/StatusScoped.d.ts +58 -0
  10. package/esm/StatusScoped.js +54 -0
  11. package/esm/WithRootStore.d.ts +2 -2
  12. package/esm/WithRootStore.js +1 -1
  13. package/esm/WithStore.js +6 -2
  14. package/esm/actions/Action.d.ts +1 -0
  15. package/esm/actions/Action.js +19 -5
  16. package/esm/actions/AjaxAction.js +1 -1
  17. package/esm/actions/BreakAction.js +1 -1
  18. package/esm/actions/BroadcastAction.js +1 -1
  19. package/esm/actions/CmptAction.js +8 -7
  20. package/esm/actions/ContinueAction.js +1 -1
  21. package/esm/actions/CopyAction.js +1 -1
  22. package/esm/actions/CustomAction.js +4 -4
  23. package/esm/actions/DialogAction.d.ts +16 -2
  24. package/esm/actions/DialogAction.js +23 -7
  25. package/esm/actions/DrawerAction.js +1 -1
  26. package/esm/actions/EmailAction.js +1 -1
  27. package/esm/actions/LinkAction.js +1 -1
  28. package/esm/actions/LoopAction.js +1 -1
  29. package/esm/actions/PageAction.js +1 -1
  30. package/esm/actions/ParallelAction.js +1 -1
  31. package/esm/actions/SwitchAction.js +1 -1
  32. package/esm/actions/ToastAction.js +1 -1
  33. package/esm/components/CustomStyle.d.ts +13 -0
  34. package/esm/components/CustomStyle.js +18 -0
  35. package/esm/components/LazyComponent.d.ts +1 -1
  36. package/esm/components/LazyComponent.js +1 -1
  37. package/esm/components/Overlay.d.ts +3 -3
  38. package/esm/components/Overlay.js +1 -1
  39. package/esm/components/PopOver.d.ts +2 -2
  40. package/esm/components/PopOver.js +1 -1
  41. package/esm/env.d.ts +10 -2
  42. package/esm/env.js +1 -1
  43. package/esm/envOverwrite.js +1 -5
  44. package/esm/factory.d.ts +5 -3
  45. package/esm/factory.js +3 -3
  46. package/esm/index.d.ts +11 -4
  47. package/esm/index.js +55 -33
  48. package/esm/locale.d.ts +2 -2
  49. package/esm/locale.js +10 -3
  50. package/esm/renderers/Form.d.ts +3 -2
  51. package/esm/renderers/Form.js +216 -180
  52. package/esm/renderers/Item.d.ts +55 -41
  53. package/esm/renderers/Item.js +30 -19
  54. package/esm/renderers/Options.js +11 -4
  55. package/esm/renderers/Placeholder.js +1 -1
  56. package/esm/renderers/builtin.js +1 -1
  57. package/esm/renderers/register.js +1 -1
  58. package/esm/renderers/wrapControl.d.ts +2 -2
  59. package/esm/renderers/wrapControl.js +13 -16
  60. package/esm/store/app.d.ts +1 -0
  61. package/esm/store/app.js +1 -1
  62. package/esm/store/combo.d.ts +3 -0
  63. package/esm/store/combo.js +1 -1
  64. package/esm/store/crud.d.ts +2 -0
  65. package/esm/store/crud.js +31 -9
  66. package/esm/store/form.d.ts +1 -0
  67. package/esm/store/form.js +10 -4
  68. package/esm/store/formItem.js +2 -2
  69. package/esm/store/iRenderer.d.ts +1 -0
  70. package/esm/store/iRenderer.js +54 -13
  71. package/esm/store/index.js +1 -1
  72. package/esm/store/list.d.ts +1 -0
  73. package/esm/store/list.js +7 -3
  74. package/esm/store/manager.js +1 -1
  75. package/esm/store/modal.d.ts +1 -0
  76. package/esm/store/modal.js +1 -1
  77. package/esm/store/node.js +1 -1
  78. package/esm/store/pagination.d.ts +1 -0
  79. package/esm/store/pagination.js +2 -2
  80. package/esm/store/root.d.ts +4 -6
  81. package/esm/store/root.js +53 -24
  82. package/esm/store/service.d.ts +1 -0
  83. package/esm/store/service.js +1 -1
  84. package/esm/store/status.d.ts +12 -0
  85. package/esm/store/status.js +38 -0
  86. package/esm/store/table.d.ts +28 -23
  87. package/esm/store/table.js +26 -5
  88. package/esm/store/table2.d.ts +7 -6
  89. package/esm/store/table2.js +27 -23
  90. package/esm/theme.d.ts +1 -1
  91. package/esm/theme.js +1 -1
  92. package/esm/types.d.ts +7 -1
  93. package/esm/utils/Animation.js +1 -1
  94. package/esm/utils/ColorScale.js +1 -1
  95. package/esm/utils/DataSchema.js +1 -1
  96. package/esm/utils/DataScope.d.ts +3 -5
  97. package/esm/utils/DataScope.js +88 -31
  98. package/esm/utils/RootClose.js +1 -1
  99. package/esm/utils/SimpleMap.js +1 -1
  100. package/esm/utils/api.js +14 -5
  101. package/esm/utils/attachmentAdpator.js +2 -2
  102. package/esm/utils/autobind.js +1 -1
  103. package/esm/utils/columnsSplit.js +1 -1
  104. package/esm/utils/dataMapping.js +1 -1
  105. package/esm/utils/date.d.ts +7 -0
  106. package/esm/utils/date.js +34 -2
  107. package/esm/utils/debug.js +4 -4
  108. package/esm/utils/decodeEntity.js +1 -1
  109. package/esm/utils/dom.d.ts +3 -0
  110. package/esm/utils/dom.js +47 -10
  111. package/esm/utils/errors.js +1 -1
  112. package/esm/utils/escapeHtml.js +1 -1
  113. package/esm/utils/filter-schema.js +1 -1
  114. package/esm/utils/filter.js +1 -1
  115. package/esm/utils/formatDuration.js +1 -1
  116. package/esm/utils/formula.js +2 -2
  117. package/esm/utils/getVariable.js +1 -1
  118. package/esm/utils/grammar.js +3 -3
  119. package/esm/utils/handleAction.js +1 -1
  120. package/esm/utils/helper.d.ts +9 -2
  121. package/esm/utils/helper.js +52 -20
  122. package/esm/utils/highlight.js +1 -1
  123. package/esm/utils/icon.d.ts +6 -1
  124. package/esm/utils/icon.js +6 -1
  125. package/esm/utils/image.js +1 -1
  126. package/esm/utils/isPureVariable.js +3 -3
  127. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  128. package/esm/utils/keyToPath.js +1 -1
  129. package/esm/utils/makeSorter.js +1 -1
  130. package/esm/utils/memoryParse.d.ts +17 -0
  131. package/esm/utils/memoryParse.js +26 -0
  132. package/esm/utils/normalizeLink.js +1 -1
  133. package/esm/utils/normalizeOptions.js +4 -2
  134. package/esm/utils/object.d.ts +2 -0
  135. package/esm/utils/object.js +27 -2
  136. package/esm/utils/offset.js +1 -1
  137. package/esm/utils/offsetParent.js +1 -1
  138. package/esm/utils/optionValueCompare.js +1 -1
  139. package/esm/utils/position.js +1 -1
  140. package/esm/utils/prettyBytes.js +1 -1
  141. package/esm/utils/renderer-event.js +35 -32
  142. package/esm/utils/replaceText.js +1 -1
  143. package/esm/utils/resize-sensor.js +1 -1
  144. package/esm/utils/resolveCondition.d.ts +1 -0
  145. package/esm/utils/resolveCondition.js +19 -4
  146. package/esm/utils/resolveVariable.js +4 -3
  147. package/esm/utils/resolveVariableAndFilter.js +1 -1
  148. package/esm/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
  149. package/esm/utils/resolveVariableAndFilterForAsync.js +23 -5
  150. package/esm/utils/scrollPosition.js +1 -1
  151. package/esm/utils/string2regExp.js +1 -1
  152. package/esm/utils/stripNumber.js +1 -1
  153. package/esm/utils/style-helper.d.ts +12 -4
  154. package/esm/utils/style-helper.js +96 -19
  155. package/esm/utils/style.js +2 -2
  156. package/esm/utils/toNumber.js +1 -1
  157. package/esm/utils/tokenize.js +1 -1
  158. package/esm/utils/tpl-builtin.d.ts +2 -1
  159. package/esm/utils/tpl-builtin.js +19 -2
  160. package/esm/utils/tpl-lodash.js +3 -2
  161. package/esm/utils/tpl.d.ts +2 -0
  162. package/esm/utils/tpl.js +24 -2
  163. package/esm/utils/uncontrollable.js +1 -1
  164. package/esm/utils/validations.d.ts +4 -1
  165. package/esm/utils/validations.js +27 -12
  166. package/lib/Root.d.ts +89 -4
  167. package/lib/Root.js +15 -4
  168. package/lib/RootRenderer.d.ts +3 -1
  169. package/lib/RootRenderer.js +8 -2
  170. package/lib/SchemaRenderer.d.ts +4 -2
  171. package/lib/SchemaRenderer.js +32 -23
  172. package/lib/Scoped.d.ts +8 -0
  173. package/lib/Scoped.js +20 -4
  174. package/lib/StatusScoped.d.ts +58 -0
  175. package/lib/StatusScoped.js +63 -0
  176. package/lib/WithRootStore.d.ts +2 -2
  177. package/lib/WithRootStore.js +1 -1
  178. package/lib/WithStore.js +6 -2
  179. package/lib/actions/Action.d.ts +1 -0
  180. package/lib/actions/Action.js +19 -5
  181. package/lib/actions/AjaxAction.js +1 -1
  182. package/lib/actions/BreakAction.js +1 -1
  183. package/lib/actions/BroadcastAction.js +1 -1
  184. package/lib/actions/CmptAction.js +8 -7
  185. package/lib/actions/ContinueAction.js +1 -1
  186. package/lib/actions/CopyAction.js +1 -1
  187. package/lib/actions/CustomAction.js +4 -4
  188. package/lib/actions/DialogAction.d.ts +16 -2
  189. package/lib/actions/DialogAction.js +23 -7
  190. package/lib/actions/DrawerAction.js +1 -1
  191. package/lib/actions/EmailAction.js +1 -1
  192. package/lib/actions/LinkAction.js +1 -1
  193. package/lib/actions/LoopAction.js +1 -1
  194. package/lib/actions/PageAction.js +1 -1
  195. package/lib/actions/ParallelAction.js +1 -1
  196. package/lib/actions/SwitchAction.js +1 -1
  197. package/lib/actions/ToastAction.js +1 -1
  198. package/lib/components/CustomStyle.d.ts +13 -0
  199. package/lib/components/CustomStyle.js +22 -0
  200. package/lib/components/LazyComponent.d.ts +1 -1
  201. package/lib/components/LazyComponent.js +1 -1
  202. package/lib/components/Overlay.d.ts +3 -3
  203. package/lib/components/Overlay.js +1 -1
  204. package/lib/components/PopOver.d.ts +2 -2
  205. package/lib/components/PopOver.js +1 -1
  206. package/lib/env.d.ts +10 -2
  207. package/lib/env.js +1 -1
  208. package/lib/envOverwrite.js +1 -5
  209. package/lib/factory.d.ts +5 -3
  210. package/lib/factory.js +3 -3
  211. package/lib/index.d.ts +11 -4
  212. package/lib/index.js +61 -23
  213. package/lib/locale.d.ts +2 -2
  214. package/lib/locale.js +10 -3
  215. package/lib/renderers/Form.d.ts +3 -2
  216. package/lib/renderers/Form.js +215 -179
  217. package/lib/renderers/Item.d.ts +55 -41
  218. package/lib/renderers/Item.js +30 -19
  219. package/lib/renderers/Options.js +11 -4
  220. package/lib/renderers/Placeholder.js +1 -1
  221. package/lib/renderers/builtin.js +1 -1
  222. package/lib/renderers/register.js +1 -1
  223. package/lib/renderers/wrapControl.d.ts +2 -2
  224. package/lib/renderers/wrapControl.js +12 -15
  225. package/lib/store/app.d.ts +1 -0
  226. package/lib/store/app.js +1 -1
  227. package/lib/store/combo.d.ts +3 -0
  228. package/lib/store/combo.js +1 -1
  229. package/lib/store/crud.d.ts +2 -0
  230. package/lib/store/crud.js +31 -9
  231. package/lib/store/form.d.ts +1 -0
  232. package/lib/store/form.js +10 -4
  233. package/lib/store/formItem.js +2 -2
  234. package/lib/store/iRenderer.d.ts +1 -0
  235. package/lib/store/iRenderer.js +53 -12
  236. package/lib/store/index.js +1 -1
  237. package/lib/store/list.d.ts +1 -0
  238. package/lib/store/list.js +7 -3
  239. package/lib/store/manager.js +1 -1
  240. package/lib/store/modal.d.ts +1 -0
  241. package/lib/store/modal.js +1 -1
  242. package/lib/store/node.js +1 -1
  243. package/lib/store/pagination.d.ts +1 -0
  244. package/lib/store/pagination.js +2 -2
  245. package/lib/store/root.d.ts +4 -6
  246. package/lib/store/root.js +52 -23
  247. package/lib/store/service.d.ts +1 -0
  248. package/lib/store/service.js +1 -1
  249. package/lib/store/status.d.ts +12 -0
  250. package/lib/store/status.js +42 -0
  251. package/lib/store/table.d.ts +28 -23
  252. package/lib/store/table.js +26 -5
  253. package/lib/store/table2.d.ts +7 -6
  254. package/lib/store/table2.js +27 -23
  255. package/lib/theme.d.ts +1 -1
  256. package/lib/theme.js +1 -1
  257. package/lib/types.d.ts +7 -1
  258. package/lib/utils/Animation.js +1 -1
  259. package/lib/utils/ColorScale.js +1 -1
  260. package/lib/utils/DataSchema.js +1 -1
  261. package/lib/utils/DataScope.d.ts +3 -5
  262. package/lib/utils/DataScope.js +86 -29
  263. package/lib/utils/RootClose.js +1 -1
  264. package/lib/utils/SimpleMap.js +1 -1
  265. package/lib/utils/api.js +13 -4
  266. package/lib/utils/attachmentAdpator.js +2 -2
  267. package/lib/utils/autobind.js +1 -1
  268. package/lib/utils/columnsSplit.js +1 -1
  269. package/lib/utils/dataMapping.js +1 -1
  270. package/lib/utils/date.d.ts +7 -0
  271. package/lib/utils/date.js +34 -1
  272. package/lib/utils/debug.js +4 -4
  273. package/lib/utils/decodeEntity.js +1 -1
  274. package/lib/utils/dom.d.ts +3 -0
  275. package/lib/utils/dom.js +48 -9
  276. package/lib/utils/errors.js +1 -1
  277. package/lib/utils/escapeHtml.js +1 -1
  278. package/lib/utils/filter-schema.js +1 -1
  279. package/lib/utils/filter.js +1 -1
  280. package/lib/utils/formatDuration.js +1 -1
  281. package/lib/utils/formula.js +2 -2
  282. package/lib/utils/getVariable.js +1 -1
  283. package/lib/utils/grammar.js +3 -3
  284. package/lib/utils/handleAction.js +1 -1
  285. package/lib/utils/helper.d.ts +9 -2
  286. package/lib/utils/helper.js +53 -19
  287. package/lib/utils/highlight.js +1 -1
  288. package/lib/utils/icon.d.ts +6 -1
  289. package/lib/utils/icon.js +6 -1
  290. package/lib/utils/image.js +1 -1
  291. package/lib/utils/isPureVariable.js +3 -3
  292. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  293. package/lib/utils/keyToPath.js +1 -1
  294. package/lib/utils/makeSorter.js +1 -1
  295. package/lib/utils/memoryParse.d.ts +17 -0
  296. package/lib/utils/memoryParse.js +30 -0
  297. package/lib/utils/normalizeLink.js +1 -1
  298. package/lib/utils/normalizeOptions.js +4 -2
  299. package/lib/utils/object.d.ts +2 -0
  300. package/lib/utils/object.js +28 -1
  301. package/lib/utils/offset.js +1 -1
  302. package/lib/utils/offsetParent.js +1 -1
  303. package/lib/utils/optionValueCompare.js +1 -1
  304. package/lib/utils/position.js +1 -1
  305. package/lib/utils/prettyBytes.js +1 -1
  306. package/lib/utils/renderer-event.js +35 -32
  307. package/lib/utils/replaceText.js +1 -1
  308. package/lib/utils/resize-sensor.js +1 -1
  309. package/lib/utils/resolveCondition.d.ts +1 -0
  310. package/lib/utils/resolveCondition.js +19 -3
  311. package/lib/utils/resolveVariable.js +3 -2
  312. package/lib/utils/resolveVariableAndFilter.js +1 -1
  313. package/lib/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
  314. package/lib/utils/resolveVariableAndFilterForAsync.js +22 -3
  315. package/lib/utils/scrollPosition.js +1 -1
  316. package/lib/utils/string2regExp.js +1 -1
  317. package/lib/utils/stripNumber.js +1 -1
  318. package/lib/utils/style-helper.d.ts +12 -4
  319. package/lib/utils/style-helper.js +101 -18
  320. package/lib/utils/style.js +2 -2
  321. package/lib/utils/toNumber.js +1 -1
  322. package/lib/utils/tokenize.js +1 -1
  323. package/lib/utils/tpl-builtin.d.ts +2 -1
  324. package/lib/utils/tpl-builtin.js +19 -2
  325. package/lib/utils/tpl-lodash.js +3 -2
  326. package/lib/utils/tpl.d.ts +2 -0
  327. package/lib/utils/tpl.js +24 -1
  328. package/lib/utils/uncontrollable.js +1 -1
  329. package/lib/utils/validations.d.ts +4 -1
  330. package/lib/utils/validations.js +27 -12
  331. package/package.json +3 -3
@@ -0,0 +1,63 @@
1
+ /**
2
+ * amis-core v3.1.0
3
+ * Copyright 2018-2023 fex
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ Object.defineProperty(exports, '__esModule', { value: true });
9
+
10
+ var tslib = require('tslib');
11
+ var React = require('react');
12
+ var hoistNonReactStatic = require('hoist-non-react-statics');
13
+ var status = require('./store/status.js');
14
+ var mobxStateTree = require('mobx-state-tree');
15
+
16
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
+
18
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
19
+ var hoistNonReactStatic__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonReactStatic);
20
+
21
+ function StatusScoped(ComposedComponent) {
22
+ var _a;
23
+ var result = hoistNonReactStatic__default["default"]((_a = /** @class */ (function (_super) {
24
+ tslib.__extends(class_1, _super);
25
+ function class_1(props) {
26
+ var _this = _super.call(this, props) || this;
27
+ _this.childRef = _this.childRef.bind(_this);
28
+ _this.getWrappedInstance = _this.getWrappedInstance.bind(_this);
29
+ _this.store = status.StatusStore.create({});
30
+ return _this;
31
+ }
32
+ class_1.prototype.childRef = function (ref) {
33
+ while (ref && ref.getWrappedInstance) {
34
+ ref = ref.getWrappedInstance();
35
+ }
36
+ this.ref = ref;
37
+ };
38
+ class_1.prototype.getWrappedInstance = function () {
39
+ return this.ref;
40
+ };
41
+ class_1.prototype.componentWillUnmount = function () {
42
+ this.store && mobxStateTree.destroy(this.store);
43
+ delete this.store;
44
+ };
45
+ class_1.prototype.render = function () {
46
+ var _a;
47
+ var injectedProps = {
48
+ statusStore: this.store
49
+ };
50
+ var refConfig = ((_a = ComposedComponent.prototype) === null || _a === void 0 ? void 0 : _a.isReactComponent)
51
+ ? { ref: this.childRef }
52
+ : { forwardedRef: this.childRef };
53
+ return (React__default["default"].createElement(ComposedComponent, tslib.__assign({}, this.props, injectedProps, refConfig)));
54
+ };
55
+ return class_1;
56
+ }(React__default["default"].Component)),
57
+ _a.displayName = "StatusScoped(".concat(ComposedComponent.displayName || ComposedComponent.name, ")"),
58
+ _a.ComposedComponent = ComposedComponent,
59
+ _a), ComposedComponent);
60
+ return result;
61
+ }
62
+
63
+ exports.StatusScoped = StatusScoped;
@@ -334,7 +334,7 @@ export declare function withRootStore<T extends React.ComponentType<React.Compon
334
334
  rootStore: IRendererStore;
335
335
  }>>(ComposedComponent: T): {
336
336
  new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">> | Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>): {
337
- render(): JSX.Element;
337
+ render(): React.JSX.Element;
338
338
  context: unknown;
339
339
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
340
340
  forceUpdate(callback?: (() => void) | undefined): void;
@@ -357,7 +357,7 @@ export declare function withRootStore<T extends React.ComponentType<React.Compon
357
357
  UNSAFE_componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>, nextState: Readonly<{}>, nextContext: any): void;
358
358
  };
359
359
  new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>, context: any): {
360
- render(): JSX.Element;
360
+ render(): React.JSX.Element;
361
361
  context: unknown;
362
362
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "rootStore">>>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
363
363
  forceUpdate(callback?: (() => void) | undefined): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
package/lib/WithStore.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -42,6 +42,7 @@ function HocStoreFactory(renderer) {
42
42
  storeType: renderer.storeType,
43
43
  parentId: _this.props.store ? _this.props.store.id : ''
44
44
  });
45
+ store.setTopStore(props.topStore);
45
46
  _this.store = store;
46
47
  var extendsData = typeof renderer.extendsData === 'function'
47
48
  ? renderer.extendsData(props)
@@ -157,7 +158,10 @@ function HocStoreFactory(renderer) {
157
158
  var rootStore = this.context;
158
159
  var store = this.store;
159
160
  (_a = this.unReaction) === null || _a === void 0 ? void 0 : _a.call(this);
160
- mobxStateTree.isAlive(store) && rootStore.removeStore(store);
161
+ if (mobxStateTree.isAlive(store)) {
162
+ store.setTopStore(null);
163
+ rootStore.removeStore(store);
164
+ }
161
165
  // @ts-ignore
162
166
  delete this.store;
163
167
  };
@@ -16,6 +16,7 @@ export interface ListenerAction {
16
16
  actionType: string;
17
17
  description?: string;
18
18
  componentId?: string;
19
+ componentName?: string;
19
20
  args?: Record<string, any>;
20
21
  data?: Record<string, any> | null;
21
22
  dataMergeMode?: 'merge' | 'override';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -95,6 +95,9 @@ var getOmitActionProp = function (type) {
95
95
  case 'drawer':
96
96
  omitList = ['drawer'];
97
97
  break;
98
+ case 'confirmDialog':
99
+ omitList = ['confirmDialog'];
100
+ break;
98
101
  case 'reload':
99
102
  omitList = ['resetPage'];
100
103
  break;
@@ -120,7 +123,8 @@ var runActions = function (actions, renderer, event) { return tslib.__awaiter(vo
120
123
  actionConfig = actions_1_1.value;
121
124
  actionInstrance = getActionByType(actionConfig.actionType);
122
125
  // 如果存在指定组件ID,说明是组件专有动作
123
- if (!actionInstrance && actionConfig.componentId) {
126
+ if (!actionInstrance &&
127
+ (actionConfig.componentId || actionConfig.componentName)) {
124
128
  actionInstrance = getActionByType('component');
125
129
  }
126
130
  else if (actionConfig.actionType === 'url' ||
@@ -162,7 +166,7 @@ var runActions = function (actions, renderer, event) { return tslib.__awaiter(vo
162
166
  }); };
163
167
  // 执行动作,与原有动作处理打通
164
168
  var runAction = function (actionInstrance, actionConfig, renderer, event) { return tslib.__awaiter(void 0, void 0, void 0, function () {
165
- var additional, mergeData, expression, isStop, preventDefault, stopPropagation, args, afterMappingData, actionData, data, stoped, actionResult;
169
+ var additional, mergeData, expression, isStop, preventDefault, stopPropagation, key, args, afterMappingData, actionData, data, stoped, actionResult;
166
170
  var _a, _b, _c;
167
171
  return tslib.__generator(this, function (_d) {
168
172
  switch (_d.label) {
@@ -205,8 +209,18 @@ var runAction = function (actionInstrance, actionConfig, renderer, event) { retu
205
209
  stopPropagation = _d.sent();
206
210
  _d.label = 6;
207
211
  case 6:
212
+ key = {
213
+ componentId: dataMapping.dataMapping(actionConfig.componentId, mergeData),
214
+ componentName: dataMapping.dataMapping(actionConfig.componentName, mergeData)
215
+ };
208
216
  args = dataMapping.dataMapping(actionConfig.args, mergeData, function (key) {
209
- return ['adaptor', 'responseAdaptor', 'requestAdaptor', 'responseData'].includes(key);
217
+ return [
218
+ 'adaptor',
219
+ 'responseAdaptor',
220
+ 'requestAdaptor',
221
+ 'responseData',
222
+ 'condition'
223
+ ].includes(key);
210
224
  });
211
225
  afterMappingData = dataMapping.dataMapping(actionConfig.data, mergeData);
212
226
  actionData = args && Object.keys(args).length
@@ -220,7 +234,7 @@ var runAction = function (actionInstrance, actionConfig, renderer, event) { retu
220
234
  (_b = console.group) === null || _b === void 0 ? void 0 : _b.call(console, "run action ".concat(actionConfig.actionType));
221
235
  console.debug("[".concat(actionConfig.actionType, "] action args, data"), args, data);
222
236
  stoped = false;
223
- return [4 /*yield*/, actionInstrance.run(tslib.__assign(tslib.__assign({}, actionConfig), { args: args, data: data }), renderer, event, mergeData)];
237
+ return [4 /*yield*/, actionInstrance.run(tslib.__assign(tslib.__assign(tslib.__assign({}, actionConfig), { args: args, data: data }), key), renderer, event, mergeData)];
224
238
  case 7:
225
239
  actionResult = _d.sent();
226
240
  // 二次确认弹窗如果取消,则终止后续动作
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -23,12 +23,13 @@ var CmptAction = /** @class */ (function () {
23
23
  CmptAction.prototype.run = function (action, renderer, event) {
24
24
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
25
25
  return tslib.__awaiter(this, void 0, void 0, function () {
26
- var component, dataMergeMode, visibility, usability, beforeSetData, path, res;
26
+ var key, component, dataMergeMode, visibility, usability, beforeSetData, path, res;
27
27
  return tslib.__generator(this, function (_p) {
28
28
  switch (_p.label) {
29
29
  case 0:
30
- component = action.componentId && renderer.props.$schema.id !== action.componentId
31
- ? (_a = event.context.scoped) === null || _a === void 0 ? void 0 : _a.getComponentById(action.componentId)
30
+ key = action.componentId || action.componentName;
31
+ component = key && renderer.props.$schema[action.componentId ? 'id' : 'name'] !== key
32
+ ? (_a = event.context.scoped) === null || _a === void 0 ? void 0 : _a[action.componentId ? 'getComponentById' : 'getComponentByName'](key)
32
33
  : renderer;
33
34
  dataMergeMode = action.dataMergeMode || 'merge';
34
35
  // 显隐&状态控制
@@ -36,16 +37,16 @@ var CmptAction = /** @class */ (function () {
36
37
  visibility = action.actionType === 'visibility'
37
38
  ? (_b = action.args) === null || _b === void 0 ? void 0 : _b.value
38
39
  : action.actionType === 'show';
39
- return [2 /*return*/, renderer.props.topStore.setVisible(action.componentId, visibility)];
40
+ return [2 /*return*/, renderer.props.statusStore.setVisible(key, visibility)];
40
41
  }
41
42
  else if (['static', 'nonstatic'].includes(action.actionType)) {
42
- return [2 /*return*/, renderer.props.topStore.setStatic(action.componentId, action.actionType === 'static')];
43
+ return [2 /*return*/, renderer.props.statusStore.setStatic(key, action.actionType === 'static')];
43
44
  }
44
45
  else if (['enabled', 'disabled', 'usability'].includes(action.actionType)) {
45
46
  usability = action.actionType === 'usability'
46
47
  ? !((_c = action.args) === null || _c === void 0 ? void 0 : _c.value)
47
48
  : action.actionType === 'disabled';
48
- return [2 /*return*/, renderer.props.topStore.setDisable(action.componentId, usability)];
49
+ return [2 /*return*/, renderer.props.statusStore.setDisable(key, usability)];
49
50
  }
50
51
  if (!(action.actionType === 'setValue')) return [3 /*break*/, 3];
51
52
  beforeSetData = (_e = (_d = renderer === null || renderer === void 0 ? void 0 : renderer.props) === null || _d === void 0 ? void 0 : _d.env) === null || _e === void 0 ? void 0 : _e.beforeSetData;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
10
  var tslib = require('tslib');
11
- require('../utils/api.js');
11
+ var api = require('../utils/api.js');
12
12
  require('../utils/ColorScale.js');
13
13
  require('react');
14
14
  require('lodash/chunk');
@@ -21,7 +21,7 @@ require('../utils/debug.js');
21
21
  require('react-dom');
22
22
  require('../utils/errors.js');
23
23
  require('../utils/tpl.js');
24
- var helper = require('../utils/helper.js');
24
+ require('../utils/helper.js');
25
25
  require('classnames');
26
26
  require('../utils/filter.js');
27
27
  require('lodash/isObject');
@@ -62,7 +62,7 @@ var CustomAction = /** @class */ (function () {
62
62
  case 0:
63
63
  scriptFunc = (_b = (_a = action.args) === null || _a === void 0 ? void 0 : _a.script) !== null && _b !== void 0 ? _b : action.script;
64
64
  if (typeof scriptFunc === 'string') {
65
- scriptFunc = helper.promisify(new Function('context', 'doAction', 'event', scriptFunc));
65
+ scriptFunc = api.str2AsyncFunction(scriptFunc, 'context', 'doAction', 'event');
66
66
  }
67
67
  return [4 /*yield*/, (scriptFunc === null || scriptFunc === void 0 ? void 0 : scriptFunc.call(null, renderer, function (action) { return Action.runActions(action, renderer, event); }, event, action))];
68
68
  case 1:
@@ -1,4 +1,4 @@
1
- import { SchemaNode } from '../types';
1
+ import { Schema, SchemaNode } from '../types';
2
2
  import { RendererEvent } from '../utils/renderer-event';
3
3
  import { RendererAction, ListenerAction, ListenerContext } from './Action';
4
4
  export interface IAlertAction extends ListenerAction {
@@ -23,6 +23,20 @@ export interface IDialogAction extends ListenerAction {
23
23
  };
24
24
  dialog?: SchemaNode;
25
25
  }
26
+ export interface IConfirmDialogAction extends ListenerAction {
27
+ actionType: 'confirmDialog';
28
+ args: {
29
+ msg: string;
30
+ title: string;
31
+ body?: Schema;
32
+ closeOnEsc?: boolean;
33
+ size?: '' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
34
+ confirmText?: string;
35
+ cancelText?: string;
36
+ confirmBtnLevel?: string;
37
+ cancelBtnLevel?: string;
38
+ };
39
+ }
26
40
  /**
27
41
  * 打开弹窗动作
28
42
  *
@@ -56,5 +70,5 @@ export declare class AlertAction implements RendererAction {
56
70
  * confirm确认提示动作
57
71
  */
58
72
  export declare class ConfirmAction implements RendererAction {
59
- run(action: IConfirmAction, renderer: ListenerContext, event: RendererEvent<any>): Promise<any>;
73
+ run(action: IConfirmDialogAction, renderer: ListenerContext, event: RendererEvent<any>): Promise<any>;
60
74
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -9,6 +9,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
10
  var tslib = require('tslib');
11
11
  var Action = require('./Action.js');
12
+ var index = require('../index.js');
12
13
 
13
14
  /**
14
15
  * 打开弹窗动作
@@ -24,6 +25,10 @@ var DialogAction = /** @class */ (function () {
24
25
  var _a, _b, _c;
25
26
  return tslib.__awaiter(this, void 0, void 0, function () {
26
27
  return tslib.__generator(this, function (_d) {
28
+ // 防止editor preview模式下执行
29
+ if (action.$$id !== undefined) {
30
+ return [2 /*return*/];
31
+ }
27
32
  (_b = (_a = renderer.props).onAction) === null || _b === void 0 ? void 0 : _b.call(_a, event, {
28
33
  actionType: 'dialog',
29
34
  dialog: ((_c = action.args) === null || _c === void 0 ? void 0 : _c.dialog) || action.dialog,
@@ -87,14 +92,25 @@ var ConfirmAction = /** @class */ (function () {
87
92
  function ConfirmAction() {
88
93
  }
89
94
  ConfirmAction.prototype.run = function (action, renderer, event) {
90
- var _a, _b, _c, _d;
95
+ var _a, _b, _c;
91
96
  return tslib.__awaiter(this, void 0, void 0, function () {
92
- var confirmed;
93
- return tslib.__generator(this, function (_e) {
94
- switch (_e.label) {
95
- case 0: return [4 /*yield*/, ((_b = (_a = event.context.env).confirm) === null || _b === void 0 ? void 0 : _b.call(_a, (_c = action.args) === null || _c === void 0 ? void 0 : _c.msg, (_d = action.args) === null || _d === void 0 ? void 0 : _d.title))];
97
+ var content, confirmed;
98
+ return tslib.__generator(this, function (_d) {
99
+ switch (_d.label) {
100
+ case 0:
101
+ content = ((_a = action.args) === null || _a === void 0 ? void 0 : _a.body)
102
+ ? index.render(action.args.body)
103
+ : action.args.msg;
104
+ return [4 /*yield*/, ((_c = (_b = event.context.env).confirm) === null || _c === void 0 ? void 0 : _c.call(_b, content, action.args.title, {
105
+ closeOnEsc: action.args.closeOnEsc,
106
+ size: action.args.size,
107
+ confirmText: action.args.confirmText,
108
+ cancelText: action.args.cancelText,
109
+ confirmBtnLevel: action.args.confirmBtnLevel,
110
+ cancelBtnLevel: action.args.cancelBtnLevel
111
+ }))];
96
112
  case 1:
97
- confirmed = _e.sent();
113
+ confirmed = _d.sent();
98
114
  return [2 /*return*/, confirmed];
99
115
  }
100
116
  });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -0,0 +1,13 @@
1
+ import type { RendererEnv } from '../env';
2
+ import type { CustomStyleClassName } from '../utils/style-helper';
3
+ interface CustomStyleProps {
4
+ config: {
5
+ themeCss: any;
6
+ classNames: CustomStyleClassName[];
7
+ id?: string;
8
+ defaultData?: any;
9
+ };
10
+ env: RendererEnv;
11
+ }
12
+ export default function (props: CustomStyleProps): null;
13
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * amis-core v3.1.0
3
+ * Copyright 2018-2023 fex
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ Object.defineProperty(exports, '__esModule', { value: true });
9
+
10
+ var React = require('react');
11
+ var styleHelper = require('../utils/style-helper.js');
12
+
13
+ function CustomStyle (props) {
14
+ var _a = props.config, themeCss = _a.themeCss, classNames = _a.classNames, id = _a.id, defaultData = _a.defaultData;
15
+ React.useEffect(function () {
16
+ var _a;
17
+ styleHelper.insertCustomStyle(themeCss, classNames, id, defaultData, (_a = props.env) === null || _a === void 0 ? void 0 : _a.customStyleClassPrefix);
18
+ }, [props.config.themeCss]);
19
+ return null;
20
+ }
21
+
22
+ exports["default"] = CustomStyle;
@@ -19,7 +19,7 @@ export interface LazyComponentState {
19
19
  }
20
20
  export default class LazyComponent extends React.Component<LazyComponentProps, LazyComponentState> {
21
21
  static defaultProps: {
22
- placeholder: JSX.Element;
22
+ placeholder: React.JSX.Element;
23
23
  unMountOnHidden: boolean;
24
24
  partialVisibility: boolean;
25
25
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -13,9 +13,9 @@ interface OverlayProps {
13
13
  shouldUpdatePosition?: boolean;
14
14
  rootClose?: boolean;
15
15
  onHide?(props: any, ...args: any[]): any;
16
- container?: HTMLElement | (() => HTMLElement | null | undefined);
16
+ container?: HTMLElement | React.ReactNode | (() => HTMLElement | React.ReactNode | null | undefined);
17
17
  containerSelector?: string;
18
- target?: React.ReactNode | Function;
18
+ target?: React.ReactNode | HTMLElement | Function;
19
19
  watchTargetSizeChange?: boolean;
20
20
  offset?: [number, number];
21
21
  onEnter?(node: HTMLElement): any;
@@ -39,6 +39,6 @@ export default class Overlay extends React.Component<OverlayProps, OverlayState>
39
39
  componentDidUpdate(prevProps: OverlayProps): void;
40
40
  onHiddenListener(node: HTMLElement): void;
41
41
  getContainerSelector(): Element | null;
42
- render(): JSX.Element | null;
42
+ render(): React.JSX.Element | null;
43
43
  }
44
44
  export {};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -50,14 +50,14 @@ export declare class PopOver extends React.PureComponent<PopOverPorps, PopOverSt
50
50
  componentDidUpdate(): void;
51
51
  componentWillUnmount(): void;
52
52
  mayUpdateOffset(): void;
53
- render(): JSX.Element;
53
+ render(): React.JSX.Element;
54
54
  }
55
55
  declare const _default: {
56
56
  new (props: Omit<PopOverPorps, keyof import("../theme").ThemeProps> & import("../theme").ThemeOutterProps): {
57
57
  ref: any;
58
58
  childRef(ref: any): void;
59
59
  getWrappedInstance(): any;
60
- render(): JSX.Element;
60
+ render(): React.JSX.Element;
61
61
  context: unknown;
62
62
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<Omit<PopOverPorps, keyof import("../theme").ThemeProps> & import("../theme").ThemeOutterProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
63
63
  forceUpdate(callback?: (() => void) | undefined): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
package/lib/env.d.ts CHANGED
@@ -40,6 +40,14 @@ export interface RendererEnv {
40
40
  */
41
41
  watchRouteChange?: (fn: () => void) => () => void;
42
42
  tracker: (eventTrack: EventTrack, props?: PlainObject) => void;
43
+ /**
44
+ * 捕获amis执行中的错误信息
45
+ */
46
+ errorCatcher?: (error: any, errorInfo: any) => void;
47
+ /**
48
+ * 自定义样式前缀
49
+ */
50
+ customStyleClassPrefix?: string;
43
51
  rendererResolver?: (path: string, schema: Schema, props: any) => null | RendererConfig;
44
52
  copy?: (contents: string, format?: any) => void;
45
53
  getModalContainer?: () => HTMLElement;
@@ -86,7 +94,7 @@ export declare function withRendererEnv<T extends React.ComponentType<React.Comp
86
94
  }) | Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
87
95
  env?: RendererEnv | undefined;
88
96
  }>): {
89
- render(): JSX.Element;
97
+ render(): React.JSX.Element;
90
98
  context: unknown;
91
99
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
92
100
  env?: RendererEnv | undefined;
@@ -129,7 +137,7 @@ export declare function withRendererEnv<T extends React.ComponentType<React.Comp
129
137
  new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
130
138
  env?: RendererEnv | undefined;
131
139
  }, context: any): {
132
- render(): JSX.Element;
140
+ render(): React.JSX.Element;
133
141
  context: unknown;
134
142
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "env">> & {
135
143
  env?: RendererEnv | undefined;
package/lib/env.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -20,10 +20,6 @@ var isMobile = ((_b = (_a = window).matchMedia) === null || _b === void 0 ? void
20
20
  // 这里不能用 addSchemaFilter 是因为还需要更深层的替换,比如 select 里的 options
21
21
  var envOverwrite = function (schema, locale) {
22
22
  var e_1, _a, e_2, _b;
23
- if (schema.mobile && isMobile) {
24
- Object.assign(schema, schema.mobile);
25
- delete schema.mobile;
26
- }
27
23
  if (locale) {
28
24
  var schemaNodes = helper.findObjectsWithKey(schema, locale);
29
25
  try {