amis-core 3.0.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 (323) 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 +3 -2
  6. package/esm/SchemaRenderer.js +26 -20
  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 +12 -4
  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 +19 -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 +1 -1
  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 +3 -2
  45. package/esm/factory.js +1 -1
  46. package/esm/index.d.ts +4 -2
  47. package/esm/index.js +49 -28
  48. package/esm/locale.d.ts +2 -2
  49. package/esm/locale.js +10 -3
  50. package/esm/renderers/Form.d.ts +2 -1
  51. package/esm/renderers/Form.js +216 -180
  52. package/esm/renderers/Item.d.ts +55 -41
  53. package/esm/renderers/Item.js +24 -16
  54. package/esm/renderers/Options.js +9 -2
  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 +12 -4
  66. package/esm/store/form.d.ts +1 -0
  67. package/esm/store/form.js +10 -4
  68. package/esm/store/formItem.js +1 -1
  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 +1 -1
  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 +4 -0
  87. package/esm/store/table.js +10 -2
  88. package/esm/store/table2.d.ts +2 -1
  89. package/esm/store/table2.js +6 -6
  90. package/esm/theme.d.ts +1 -1
  91. package/esm/theme.js +1 -1
  92. package/esm/types.d.ts +1 -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 +6 -4
  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 +1 -1
  108. package/esm/utils/decodeEntity.js +1 -1
  109. package/esm/utils/dom.d.ts +2 -1
  110. package/esm/utils/dom.js +1 -1
  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 +1 -1
  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 +2 -2
  121. package/esm/utils/helper.js +25 -18
  122. package/esm/utils/highlight.js +1 -1
  123. package/esm/utils/icon.d.ts +1 -1
  124. package/esm/utils/icon.js +1 -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 +1 -1
  142. package/esm/utils/replaceText.js +1 -1
  143. package/esm/utils/resize-sensor.js +1 -1
  144. package/esm/utils/resolveCondition.js +1 -1
  145. package/esm/utils/resolveVariable.js +4 -3
  146. package/esm/utils/resolveVariableAndFilter.js +1 -1
  147. package/esm/utils/resolveVariableAndFilterForAsync.js +5 -4
  148. package/esm/utils/scrollPosition.js +1 -1
  149. package/esm/utils/string2regExp.js +1 -1
  150. package/esm/utils/stripNumber.js +1 -1
  151. package/esm/utils/style-helper.d.ts +5 -2
  152. package/esm/utils/style-helper.js +18 -6
  153. package/esm/utils/style.js +1 -1
  154. package/esm/utils/toNumber.js +1 -1
  155. package/esm/utils/tokenize.d.ts +0 -1
  156. package/esm/utils/tokenize.js +3 -34
  157. package/esm/utils/tpl-builtin.js +5 -3
  158. package/esm/utils/tpl-lodash.js +1 -1
  159. package/esm/utils/tpl.js +1 -1
  160. package/esm/utils/uncontrollable.js +1 -1
  161. package/esm/utils/validations.js +1 -1
  162. package/lib/Root.d.ts +89 -4
  163. package/lib/Root.js +15 -4
  164. package/lib/RootRenderer.d.ts +3 -1
  165. package/lib/RootRenderer.js +8 -2
  166. package/lib/SchemaRenderer.d.ts +3 -2
  167. package/lib/SchemaRenderer.js +26 -20
  168. package/lib/Scoped.d.ts +8 -0
  169. package/lib/Scoped.js +20 -4
  170. package/lib/StatusScoped.d.ts +58 -0
  171. package/lib/StatusScoped.js +63 -0
  172. package/lib/WithRootStore.d.ts +2 -2
  173. package/lib/WithRootStore.js +1 -1
  174. package/lib/WithStore.js +6 -2
  175. package/lib/actions/Action.d.ts +1 -0
  176. package/lib/actions/Action.js +12 -4
  177. package/lib/actions/AjaxAction.js +1 -1
  178. package/lib/actions/BreakAction.js +1 -1
  179. package/lib/actions/BroadcastAction.js +1 -1
  180. package/lib/actions/CmptAction.js +8 -7
  181. package/lib/actions/ContinueAction.js +1 -1
  182. package/lib/actions/CopyAction.js +1 -1
  183. package/lib/actions/CustomAction.js +4 -4
  184. package/lib/actions/DialogAction.d.ts +16 -2
  185. package/lib/actions/DialogAction.js +19 -7
  186. package/lib/actions/DrawerAction.js +1 -1
  187. package/lib/actions/EmailAction.js +1 -1
  188. package/lib/actions/LinkAction.js +1 -1
  189. package/lib/actions/LoopAction.js +1 -1
  190. package/lib/actions/PageAction.js +1 -1
  191. package/lib/actions/ParallelAction.js +1 -1
  192. package/lib/actions/SwitchAction.js +1 -1
  193. package/lib/actions/ToastAction.js +1 -1
  194. package/lib/components/CustomStyle.d.ts +13 -0
  195. package/lib/components/CustomStyle.js +22 -0
  196. package/lib/components/LazyComponent.d.ts +1 -1
  197. package/lib/components/LazyComponent.js +1 -1
  198. package/lib/components/Overlay.d.ts +1 -1
  199. package/lib/components/Overlay.js +1 -1
  200. package/lib/components/PopOver.d.ts +2 -2
  201. package/lib/components/PopOver.js +1 -1
  202. package/lib/env.d.ts +10 -2
  203. package/lib/env.js +1 -1
  204. package/lib/envOverwrite.js +1 -5
  205. package/lib/factory.d.ts +3 -2
  206. package/lib/factory.js +1 -1
  207. package/lib/index.d.ts +4 -2
  208. package/lib/index.js +50 -24
  209. package/lib/locale.d.ts +2 -2
  210. package/lib/locale.js +10 -3
  211. package/lib/renderers/Form.d.ts +2 -1
  212. package/lib/renderers/Form.js +215 -179
  213. package/lib/renderers/Item.d.ts +55 -41
  214. package/lib/renderers/Item.js +24 -16
  215. package/lib/renderers/Options.js +9 -2
  216. package/lib/renderers/Placeholder.js +1 -1
  217. package/lib/renderers/builtin.js +1 -1
  218. package/lib/renderers/register.js +1 -1
  219. package/lib/renderers/wrapControl.d.ts +2 -2
  220. package/lib/renderers/wrapControl.js +12 -15
  221. package/lib/store/app.d.ts +1 -0
  222. package/lib/store/app.js +1 -1
  223. package/lib/store/combo.d.ts +3 -0
  224. package/lib/store/combo.js +1 -1
  225. package/lib/store/crud.d.ts +2 -0
  226. package/lib/store/crud.js +12 -4
  227. package/lib/store/form.d.ts +1 -0
  228. package/lib/store/form.js +10 -4
  229. package/lib/store/formItem.js +1 -1
  230. package/lib/store/iRenderer.d.ts +1 -0
  231. package/lib/store/iRenderer.js +53 -12
  232. package/lib/store/index.js +1 -1
  233. package/lib/store/list.d.ts +1 -0
  234. package/lib/store/list.js +7 -3
  235. package/lib/store/manager.js +1 -1
  236. package/lib/store/modal.d.ts +1 -0
  237. package/lib/store/modal.js +1 -1
  238. package/lib/store/node.js +1 -1
  239. package/lib/store/pagination.d.ts +1 -0
  240. package/lib/store/pagination.js +1 -1
  241. package/lib/store/root.d.ts +4 -6
  242. package/lib/store/root.js +52 -23
  243. package/lib/store/service.d.ts +1 -0
  244. package/lib/store/service.js +1 -1
  245. package/lib/store/status.d.ts +12 -0
  246. package/lib/store/status.js +42 -0
  247. package/lib/store/table.d.ts +4 -0
  248. package/lib/store/table.js +10 -2
  249. package/lib/store/table2.d.ts +2 -1
  250. package/lib/store/table2.js +6 -6
  251. package/lib/theme.d.ts +1 -1
  252. package/lib/theme.js +1 -1
  253. package/lib/types.d.ts +1 -1
  254. package/lib/utils/Animation.js +1 -1
  255. package/lib/utils/ColorScale.js +1 -1
  256. package/lib/utils/DataSchema.js +1 -1
  257. package/lib/utils/DataScope.d.ts +3 -5
  258. package/lib/utils/DataScope.js +86 -29
  259. package/lib/utils/RootClose.js +1 -1
  260. package/lib/utils/SimpleMap.js +1 -1
  261. package/lib/utils/api.js +5 -3
  262. package/lib/utils/attachmentAdpator.js +2 -2
  263. package/lib/utils/autobind.js +1 -1
  264. package/lib/utils/columnsSplit.js +1 -1
  265. package/lib/utils/dataMapping.js +1 -1
  266. package/lib/utils/date.d.ts +7 -0
  267. package/lib/utils/date.js +34 -1
  268. package/lib/utils/debug.js +1 -1
  269. package/lib/utils/decodeEntity.js +1 -1
  270. package/lib/utils/dom.d.ts +2 -1
  271. package/lib/utils/dom.js +1 -1
  272. package/lib/utils/errors.js +1 -1
  273. package/lib/utils/escapeHtml.js +1 -1
  274. package/lib/utils/filter-schema.js +1 -1
  275. package/lib/utils/filter.js +1 -1
  276. package/lib/utils/formatDuration.js +1 -1
  277. package/lib/utils/formula.js +1 -1
  278. package/lib/utils/getVariable.js +1 -1
  279. package/lib/utils/grammar.js +3 -3
  280. package/lib/utils/handleAction.js +1 -1
  281. package/lib/utils/helper.d.ts +2 -2
  282. package/lib/utils/helper.js +25 -18
  283. package/lib/utils/highlight.js +1 -1
  284. package/lib/utils/icon.d.ts +1 -1
  285. package/lib/utils/icon.js +1 -1
  286. package/lib/utils/image.js +1 -1
  287. package/lib/utils/isPureVariable.js +3 -3
  288. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  289. package/lib/utils/keyToPath.js +1 -1
  290. package/lib/utils/makeSorter.js +1 -1
  291. package/lib/utils/memoryParse.d.ts +17 -0
  292. package/lib/utils/memoryParse.js +30 -0
  293. package/lib/utils/normalizeLink.js +1 -1
  294. package/lib/utils/normalizeOptions.js +4 -2
  295. package/lib/utils/object.d.ts +2 -0
  296. package/lib/utils/object.js +28 -1
  297. package/lib/utils/offset.js +1 -1
  298. package/lib/utils/offsetParent.js +1 -1
  299. package/lib/utils/optionValueCompare.js +1 -1
  300. package/lib/utils/position.js +1 -1
  301. package/lib/utils/prettyBytes.js +1 -1
  302. package/lib/utils/renderer-event.js +1 -1
  303. package/lib/utils/replaceText.js +1 -1
  304. package/lib/utils/resize-sensor.js +1 -1
  305. package/lib/utils/resolveCondition.js +1 -1
  306. package/lib/utils/resolveVariable.js +3 -2
  307. package/lib/utils/resolveVariableAndFilter.js +1 -1
  308. package/lib/utils/resolveVariableAndFilterForAsync.js +4 -3
  309. package/lib/utils/scrollPosition.js +1 -1
  310. package/lib/utils/string2regExp.js +1 -1
  311. package/lib/utils/stripNumber.js +1 -1
  312. package/lib/utils/style-helper.d.ts +5 -2
  313. package/lib/utils/style-helper.js +18 -6
  314. package/lib/utils/style.js +1 -1
  315. package/lib/utils/toNumber.js +1 -1
  316. package/lib/utils/tokenize.d.ts +0 -1
  317. package/lib/utils/tokenize.js +1 -33
  318. package/lib/utils/tpl-builtin.js +4 -2
  319. package/lib/utils/tpl-lodash.js +1 -1
  320. package/lib/utils/tpl.js +1 -1
  321. package/lib/utils/uncontrollable.js +1 -1
  322. package/lib/utils/validations.js +1 -1
  323. package/package.json +3 -3
package/lib/Root.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.0.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -17,6 +17,7 @@ var Scoped = require('./Scoped.js');
17
17
  var theme = require('./theme.js');
18
18
  var helper = require('./utils/helper.js');
19
19
  var WithRootStore = require('./WithRootStore.js');
20
+ var StatusScoped = require('./StatusScoped.js');
20
21
 
21
22
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
23
 
@@ -40,7 +41,7 @@ var Root = /** @class */ (function (_super) {
40
41
  return definitions && definitions[name];
41
42
  };
42
43
  Root.prototype.render = function () {
43
- var _a = this.props, schema = _a.schema, rootStore = _a.rootStore, env = _a.env, pathPrefix = _a.pathPrefix, location = _a.location, data = _a.data, locale$1 = _a.locale, translate = _a.translate, rest = tslib.__rest(_a, ["schema", "rootStore", "env", "pathPrefix", "location", "data", "locale", "translate"]);
44
+ var _a = this.props, schema = _a.schema, rootStore = _a.rootStore, env = _a.env, pathPrefix = _a.pathPrefix, location = _a.location, data = _a.data, context = _a.context, locale$1 = _a.locale, translate = _a.translate, rest = tslib.__rest(_a, ["schema", "rootStore", "env", "pathPrefix", "location", "data", "context", "locale", "translate"]);
44
45
  var theme$1 = env.theme;
45
46
  var themeName = this.props.theme || 'cxd';
46
47
  if (themeName === 'default') {
@@ -52,7 +53,7 @@ var Root = /** @class */ (function (_super) {
52
53
  return tslib.__assign(tslib.__assign({}, props), { children: wrapper(props) });
53
54
  }, tslib.__assign(tslib.__assign({ pathPrefix: pathPrefix || '', schema: isPlainObject__default["default"](schema)
54
55
  ? tslib.__assign({ type: 'page' }, schema) : schema }, rest), { render: renderChild, rootStore: rootStore, resolveDefinitions: this.resolveDefinitions, location: location, data: data, env: env, classnames: theme$1.classnames, classPrefix: theme$1.classPrefix, locale: locale$1, translate: translate, children: (React__default["default"].createElement(RootRenderer.RootRenderer, tslib.__assign({ pathPrefix: pathPrefix || '', schema: isPlainObject__default["default"](schema)
55
- ? tslib.__assign({ type: 'page' }, schema) : schema }, rest, { render: renderChild, rootStore: rootStore, resolveDefinitions: this.resolveDefinitions, location: location, data: data, env: env, classnames: theme$1.classnames, classPrefix: theme$1.classPrefix, locale: locale$1, translate: translate }))) })).children))));
56
+ ? tslib.__assign({ type: 'page' }, schema) : schema }, rest, { render: renderChild, rootStore: rootStore, resolveDefinitions: this.resolveDefinitions, location: location, data: data, context: context, env: env, classnames: theme$1.classnames, classPrefix: theme$1.classPrefix, locale: locale$1, translate: translate }))) })).children))));
56
57
  };
57
58
  tslib.__decorate([
58
59
  helper.autobind,
@@ -62,6 +63,7 @@ var Root = /** @class */ (function (_super) {
62
63
  ], Root.prototype, "resolveDefinitions", null);
63
64
  return Root;
64
65
  }(React__default["default"].Component));
66
+ var StatusScopedSchemaRenderer = StatusScoped.StatusScoped(SchemaRenderer.SchemaRenderer);
65
67
  function renderChildren(prefix, node, props) {
66
68
  if (Array.isArray(node)) {
67
69
  var elemKey = props.key || props.propKey || props.id || '';
@@ -91,9 +93,18 @@ function renderChild(prefix, node, props) {
91
93
  delete props.propsTransform;
92
94
  props = transform(props);
93
95
  }
96
+ if (['dialog', 'drawer'].includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
97
+ !(schema === null || schema === void 0 ? void 0 : schema.component) &&
98
+ !(schema === null || schema === void 0 ? void 0 : schema.children)) {
99
+ // 因为状态判断实在 SchemaRenderer 里面判断的
100
+ // 找渲染器也是在那,所以没办法在之前根据渲染器信息来包裹个组件下发 statusStore
101
+ // 所以这里先根据 type 来处理一下
102
+ // 等后续把状态处理再抽一层,可以把此处放到 SchemaRenderer 里面去
103
+ return (React__default["default"].createElement(StatusScopedSchemaRenderer, tslib.__assign({ render: renderChild }, props, { schema: schema, propKey: schema.key, "$path": "".concat(prefix ? "".concat(prefix, "/") : '').concat((schema && schema.type) || '') })));
104
+ }
94
105
  return (React__default["default"].createElement(SchemaRenderer.SchemaRenderer, tslib.__assign({ render: renderChild }, props, { schema: schema, propKey: schema.key, "$path": "".concat(prefix ? "".concat(prefix, "/") : '').concat((schema && schema.type) || '') })));
95
106
  }
96
- var ScopedRootRenderer = Scoped.HocScoped(Root);
107
+ var ScopedRootRenderer = StatusScoped.StatusScoped(Scoped.HocScoped(Root));
97
108
 
98
109
  exports.Root = Root;
99
110
  exports.addRootWrapper = addRootWrapper;
@@ -5,6 +5,8 @@ import { IRootStore } from './store/root';
5
5
  import { ActionObject } from './types';
6
6
  export interface RootRendererProps extends RootProps {
7
7
  location?: any;
8
+ data?: Record<string, any>;
9
+ context?: Record<string, any>;
8
10
  render: (region: string, schema: any, props: any) => React.ReactNode;
9
11
  }
10
12
  export declare class RootRenderer extends React.Component<RootRendererProps> {
@@ -23,5 +25,5 @@ export declare class RootRenderer extends React.Component<RootRendererProps> {
23
25
  handleDrawerClose(): void;
24
26
  openFeedback(dialog: any, ctx: any): Promise<unknown>;
25
27
  reloadTarget(scoped: IScopedContext, target: string, data?: any): void;
26
- render(): string | number | boolean | JSX.Element | React.ReactFragment | null | undefined;
28
+ render(): string | number | boolean | React.JSX.Element | React.ReactFragment | null | undefined;
27
29
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.0.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -39,6 +39,7 @@ var RootRenderer = /** @class */ (function (_super) {
39
39
  storeType: root.RootStore.name,
40
40
  parentId: ''
41
41
  });
42
+ _this.store.setContext(props.context);
42
43
  _this.store.initData(props.data);
43
44
  _this.store.updateLocation(props.location, (_a = _this.props.env) === null || _a === void 0 ? void 0 : _a.parseLocation);
44
45
  helper.bulkBindFunctions(_this, [
@@ -62,8 +63,13 @@ var RootRenderer = /** @class */ (function (_super) {
62
63
  if (props.location !== prevProps.location) {
63
64
  this.store.updateLocation(props.location);
64
65
  }
66
+ if (props.context !== prevProps.context) {
67
+ this.store.setContext(props.context);
68
+ }
65
69
  };
66
70
  RootRenderer.prototype.componentDidCatch = function (error, errorInfo) {
71
+ var _a, _b;
72
+ (_b = (_a = this.props.env) === null || _a === void 0 ? void 0 : _a.errorCatcher) === null || _b === void 0 ? void 0 : _b.call(_a, error, errorInfo);
67
73
  this.store.setRuntimeError(error, errorInfo);
68
74
  };
69
75
  RootRenderer.prototype.componentWillUnmount = function () {
@@ -160,7 +166,7 @@ var RootRenderer = /** @class */ (function (_super) {
160
166
  redirect = action.redirect && tpl.filter(action.redirect, store.data);
161
167
  redirect && env.jumpTo(redirect, action);
162
168
  action.reload &&
163
- this.reloadTarget(delegate || this.context, tpl.filter(action.reload, ctx), store.data);
169
+ this.reloadTarget(delegate || this.context, Scoped.filterTarget(action.reload, ctx), store.data);
164
170
  return [2 /*return*/];
165
171
  }
166
172
  });
@@ -3,7 +3,8 @@ import { RendererConfig, RendererEnv, RendererProps } from './factory';
3
3
  import { IScopedContext } from './Scoped';
4
4
  import { Schema, SchemaNode } from './types';
5
5
  import { RendererEvent } from './utils/renderer-event';
6
- interface SchemaRendererProps extends Partial<RendererProps> {
6
+ import { StatusScopedProps } from './StatusScoped';
7
+ interface SchemaRendererProps extends Partial<Omit<RendererProps, 'statusStore'>>, StatusScopedProps {
7
8
  schema: Schema;
8
9
  $path: string;
9
10
  env: RendererEnv;
@@ -32,7 +33,7 @@ export declare class SchemaRenderer extends React.Component<SchemaRendererProps,
32
33
  renderChild(region: string, node?: SchemaNode, subProps?: {
33
34
  data?: object;
34
35
  [propName: string]: any;
35
- }): JSX.Element;
36
+ }): any;
36
37
  reRender(): void;
37
38
  render(): JSX.Element | null;
38
39
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.0.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -28,6 +28,7 @@ require('lodash/isPlainObject');
28
28
  var resolveVariableAndFilter = require('./utils/resolveVariableAndFilter.js');
29
29
  require('./utils/filter.js');
30
30
  var style = require('./utils/style.js');
31
+ var tpl = require('./utils/tpl.js');
31
32
 
32
33
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
33
34
 
@@ -76,9 +77,12 @@ var SchemaRenderer = /** @class */ (function (_super) {
76
77
  _this.reRender = _this.reRender.bind(_this);
77
78
  _this.resolveRenderer(_this.props);
78
79
  _this.dispatchEvent = _this.dispatchEvent.bind(_this);
79
- // 监听topStore更新
80
+ // 监听statusStore更新
80
81
  _this.reaction = mobx.reaction(function () {
81
- return "".concat(props.topStore.visibleState[props.schema.id || props.$path]).concat(props.topStore.disableState[props.schema.id || props.$path]).concat(props.topStore.staticState[props.schema.id || props.$path]);
82
+ var _a, _b, _c;
83
+ var id = tpl.filter(props.schema.id, props.data);
84
+ var name = tpl.filter(props.schema.name, props.data);
85
+ return "".concat((_a = props.statusStore.visibleState[id]) !== null && _a !== void 0 ? _a : props.statusStore.visibleState[name]).concat((_b = props.statusStore.disableState[id]) !== null && _b !== void 0 ? _b : props.statusStore.disableState[name]).concat((_c = props.statusStore.staticState[id]) !== null && _c !== void 0 ? _c : props.statusStore.staticState[name]);
82
86
  }, function () { return _this.forceUpdate(); });
83
87
  return _this;
84
88
  }
@@ -195,12 +199,12 @@ var SchemaRenderer = /** @class */ (function (_super) {
195
199
  SchemaRenderer.prototype.render = function () {
196
200
  var e_1, _a;
197
201
  var _this = this;
198
- var _b, _c, _d;
199
- var _e = this.props; _e.$path; var __ = _e.schema, rootStore = _e.rootStore, topStore = _e.topStore, render = _e.render, rest = tslib.__rest(_e, ["$path", "schema", "rootStore", "topStore", "render"]);
202
+ var _b, _c, _d, _e, _f, _g;
203
+ var _h = this.props; _h.$path; var __ = _h.schema, rootStore = _h.rootStore, statusStore = _h.statusStore, render = _h.render, rest = tslib.__rest(_h, ["$path", "schema", "rootStore", "statusStore", "render"]);
200
204
  if (__ == null) {
201
205
  return null;
202
206
  }
203
- var _f = this.resolveRenderer(this.props), $path = _f.path, schema = _f.schema;
207
+ var _j = this.resolveRenderer(this.props), $path = _j.path, schema = _j.schema;
204
208
  var theme = this.props.env.theme;
205
209
  if (Array.isArray(schema)) {
206
210
  return render($path, schema, rest);
@@ -211,14 +215,16 @@ var SchemaRenderer = /** @class */ (function (_super) {
211
215
  ? filterSchema.getExprProperties(schema, detectData, undefined, rest)
212
216
  : {};
213
217
  // 控制显隐
214
- var visible = mobxStateTree.isAlive(topStore)
215
- ? topStore.visibleState[schema.id || $path]
218
+ var id = tpl.filter(schema.id, rest.data);
219
+ var name = tpl.filter(schema.name, rest.data);
220
+ var visible = mobxStateTree.isAlive(statusStore)
221
+ ? (_b = statusStore.visibleState[id]) !== null && _b !== void 0 ? _b : statusStore.visibleState[name]
216
222
  : undefined;
217
- var disable = mobxStateTree.isAlive(topStore)
218
- ? topStore.disableState[schema.id || $path]
223
+ var disable = mobxStateTree.isAlive(statusStore)
224
+ ? (_c = statusStore.disableState[id]) !== null && _c !== void 0 ? _c : statusStore.disableState[name]
219
225
  : undefined;
220
- var isStatic = mobxStateTree.isAlive(topStore)
221
- ? topStore.staticState[schema.id || $path]
226
+ var isStatic = mobxStateTree.isAlive(statusStore)
227
+ ? (_d = statusStore.staticState[id]) !== null && _d !== void 0 ? _d : statusStore.staticState[name]
222
228
  : undefined;
223
229
  if (visible === false ||
224
230
  (visible !== true &&
@@ -236,7 +242,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
236
242
  ? null
237
243
  : React__default["default"].isValidElement(schema.children)
238
244
  ? schema.children
239
- : schema.children(tslib.__assign(tslib.__assign(tslib.__assign({}, rest), exprProps), { $path: $path, $schema: schema, render: this.renderChild, forwardedRef: this.refFn, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent }));
245
+ : schema.children(tslib.__assign(tslib.__assign(tslib.__assign({}, rest), exprProps), { $path: $path, $schema: schema, render: this.renderChild, forwardedRef: this.refFn, rootStore: rootStore, statusStore: statusStore, dispatchEvent: this.dispatchEvent }));
240
246
  }
241
247
  else if (typeof schema.component === 'function') {
242
248
  var isSFC = !(schema.component.prototype instanceof React__default["default"].Component);
@@ -246,7 +252,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
246
252
  ? null
247
253
  : React__default["default"].createElement(schema.component, tslib.__assign(tslib.__assign(tslib.__assign(tslib.__assign({}, rest), restSchema_1), exprProps), {
248
254
  // value: defaultValue, // 备注: 此处并没有将value传递给渲染器
249
- defaultData: defaultData_1, defaultValue: defaultValue_1, defaultActiveKey: defaultActiveKey_1, propKey: propKey_1, $path: $path, $schema: schema, ref: isSFC ? undefined : this.refFn, forwardedRef: isSFC ? this.refFn : undefined, render: this.renderChild, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent }));
255
+ defaultData: defaultData_1, defaultValue: defaultValue_1, defaultActiveKey: defaultActiveKey_1, propKey: propKey_1, $path: $path, $schema: schema, ref: isSFC ? undefined : this.refFn, forwardedRef: isSFC ? this.refFn : undefined, render: this.renderChild, rootStore: rootStore, statusStore: statusStore, dispatchEvent: this.dispatchEvent }));
250
256
  }
251
257
  else if (Object.keys(schema).length === 0) {
252
258
  return null;
@@ -269,7 +275,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
269
275
  return [2 /*return*/, function () { return factory.loadRenderer(schema, $path); }];
270
276
  }
271
277
  });
272
- }); }, "$path": $path, "$schema": schema, retry: this.reRender, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent })));
278
+ }); }, "$path": $path, "$schema": schema, retry: this.reRender, rootStore: rootStore, statusStore: statusStore, dispatchEvent: this.dispatchEvent })));
273
279
  }
274
280
  var renderer = this.renderer;
275
281
  schema = factory.filterSchema(schema, renderer, rest);
@@ -296,11 +302,11 @@ var SchemaRenderer = /** @class */ (function (_super) {
296
302
  // schema.style是readonly属性
297
303
  schema = tslib.__assign(tslib.__assign({}, schema), { style: style.buildStyle(schema.style, detectData) });
298
304
  }
299
- var isClassComponent = (_b = Component.prototype) === null || _b === void 0 ? void 0 : _b.isReactComponent;
305
+ var isClassComponent = (_e = Component.prototype) === null || _e === void 0 ? void 0 : _e.isReactComponent;
300
306
  var $schema = tslib.__assign(tslib.__assign({}, schema), exprProps);
301
307
  var props = tslib.__assign(tslib.__assign(tslib.__assign(tslib.__assign(tslib.__assign({}, theme.getRendererConfig(renderer.name)), restSchema), helper.chainEvents(rest, restSchema)), exprProps), {
302
308
  // value: defaultValue, // 备注: 此处并没有将value传递给渲染器
303
- defaultData: (_c = restSchema.defaultData) !== null && _c !== void 0 ? _c : defaultData, defaultValue: (_d = restSchema.defaultValue) !== null && _d !== void 0 ? _d : defaultValue, defaultActiveKey: defaultActiveKey, propKey: propKey, $path: $path, $schema: $schema, ref: this.refFn, render: this.renderChild, rootStore: rootStore, topStore: topStore, dispatchEvent: this.dispatchEvent });
309
+ defaultData: (_f = restSchema.defaultData) !== null && _f !== void 0 ? _f : defaultData, defaultValue: (_g = restSchema.defaultValue) !== null && _g !== void 0 ? _g : defaultValue, defaultActiveKey: defaultActiveKey, propKey: propKey, $path: $path, $schema: $schema, ref: this.refFn, render: this.renderChild, rootStore: rootStore, statusStore: statusStore, dispatchEvent: this.dispatchEvent });
304
310
  if (disable !== undefined) {
305
311
  props.disabled = disable;
306
312
  }
@@ -310,8 +316,8 @@ var SchemaRenderer = /** @class */ (function (_super) {
310
316
  // 自动解析变量模式,主要是方便直接引入第三方组件库,无需为了支持变量封装一层
311
317
  if (renderer.autoVar) {
312
318
  try {
313
- for (var _g = tslib.__values(Object.keys($schema)), _h = _g.next(); !_h.done; _h = _g.next()) {
314
- var key = _h.value;
319
+ for (var _k = tslib.__values(Object.keys($schema)), _l = _k.next(); !_l.done; _l = _k.next()) {
320
+ var key = _l.value;
315
321
  if (typeof props[key] === 'string') {
316
322
  props[key] = resolveVariableAndFilter.resolveVariableAndFilter(props[key], props.data, '| raw');
317
323
  }
@@ -320,7 +326,7 @@ var SchemaRenderer = /** @class */ (function (_super) {
320
326
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
321
327
  finally {
322
328
  try {
323
- if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
329
+ if (_l && !_l.done && (_a = _k.return)) _a.call(_k);
324
330
  }
325
331
  finally { if (e_1) throw e_1.error; }
326
332
  }
package/lib/Scoped.d.ts CHANGED
@@ -5,6 +5,14 @@
5
5
  import React from 'react';
6
6
  import { RendererEnv, RendererProps } from './factory';
7
7
  import { RendererData, ActionObject } from './types';
8
+ /**
9
+ * target 里面可能包含 ?xxx=xxx,这种情况下,需要把 ?xxx=xxx 保留下来,然后对前面的部分进行 filter
10
+ * 因为后面会对 query 部分做不一样的处理。会保留原始的值。而不是会转成字符串。
11
+ * @param target
12
+ * @param data
13
+ * @returns
14
+ */
15
+ export declare function filterTarget(target: string, data: Record<string, any>): string;
8
16
  export interface ScopedComponentType extends React.Component<RendererProps> {
9
17
  focus?: () => void;
10
18
  doAction?: (action: ActionObject, data: RendererData, throwErrors?: boolean) => void;
package/lib/Scoped.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.0.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -59,7 +59,22 @@ var hoistNonReactStatic__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonRe
59
59
  * @file 用来创建一个域,在这个域里面会把里面的运行时实例注册进来,方便组件之间的通信。
60
60
  * @author fex
61
61
  */
62
- var ScopedContext = React__default["default"].createContext(createScopedTools(''));
62
+ /**
63
+ * target 里面可能包含 ?xxx=xxx,这种情况下,需要把 ?xxx=xxx 保留下来,然后对前面的部分进行 filter
64
+ * 因为后面会对 query 部分做不一样的处理。会保留原始的值。而不是会转成字符串。
65
+ * @param target
66
+ * @param data
67
+ * @returns
68
+ */
69
+ function filterTarget(target, data) {
70
+ var idx = target.indexOf('?');
71
+ if (~idx) {
72
+ return tpl.filter(target.slice(0, idx), data) + target.slice(idx);
73
+ }
74
+ return tpl.filter(target, data, '| raw');
75
+ }
76
+ var rootScopedContext = createScopedTools('');
77
+ var ScopedContext = React__default["default"].createContext(rootScopedContext);
63
78
  function createScopedTools(path, parent, env) {
64
79
  var components = [];
65
80
  var self = {
@@ -104,14 +119,14 @@ function createScopedTools(path, parent, env) {
104
119
  getComponentById: function (id) {
105
120
  var root = this;
106
121
  // 找到顶端scoped
107
- while (root.parent) {
122
+ while (root.parent && root.parent !== rootScopedContext) {
108
123
  root = root.parent;
109
124
  }
110
125
  // 向下查找
111
126
  var component = undefined;
112
127
  helper.findTree([root], function (item) {
113
128
  return item.getComponents().find(function (cmpt) {
114
- if (cmpt.props.id === id) {
129
+ if (tpl.filter(cmpt.props.id, cmpt.props.data) === id) {
115
130
  component = cmpt;
116
131
  return true;
117
132
  }
@@ -377,3 +392,4 @@ function HocScoped(ComposedComponent) {
377
392
  exports.HocScoped = HocScoped;
378
393
  exports.ScopedContext = ScopedContext;
379
394
  exports["default"] = HocScoped;
395
+ exports.filterTarget = filterTarget;
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import hoistNonReactStatic from 'hoist-non-react-statics';
3
+ import { IStatusStore } from './store/status';
4
+ export interface StatusScopedProps {
5
+ statusStore: IStatusStore;
6
+ }
7
+ export declare function StatusScoped<T extends React.ComponentType<React.ComponentProps<T> & StatusScopedProps>>(ComposedComponent: T): {
8
+ new (props: JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}): {
9
+ store?: ({
10
+ visibleState: any;
11
+ disableState: any;
12
+ staticState: any;
13
+ } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
14
+ setVisible(key: string, value?: boolean | undefined): void;
15
+ setDisable(key: string, value?: boolean | undefined): void;
16
+ setStatic(key: string, value?: boolean | undefined): void;
17
+ resetAll(): void;
18
+ } & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
19
+ visibleState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
20
+ disableState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
21
+ staticState: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IType<any, any, any>, [undefined]>;
22
+ }, {
23
+ setVisible(key: string, value?: boolean | undefined): void;
24
+ setDisable(key: string, value?: boolean | undefined): void;
25
+ setStatic(key: string, value?: boolean | undefined): void;
26
+ resetAll(): void;
27
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>) | undefined;
28
+ ref: any;
29
+ childRef(ref: any): void;
30
+ getWrappedInstance(): any;
31
+ componentWillUnmount(): void;
32
+ render(): React.JSX.Element;
33
+ context: unknown;
34
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
35
+ forceUpdate(callback?: (() => void) | undefined): void;
36
+ readonly props: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>;
37
+ state: Readonly<{}>;
38
+ refs: {
39
+ [key: string]: React.ReactInstance;
40
+ };
41
+ componentDidMount?(): void;
42
+ shouldComponentUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextState: Readonly<{}>, nextContext: any): boolean;
43
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
44
+ getSnapshotBeforeUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, prevState: Readonly<{}>): any;
45
+ componentDidUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, prevState: Readonly<{}>, snapshot?: any): void;
46
+ componentWillMount?(): void;
47
+ UNSAFE_componentWillMount?(): void;
48
+ componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextContext: any): void;
49
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextContext: any): void;
50
+ componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextState: Readonly<{}>, nextContext: any): void;
51
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<T, Omit<React.ComponentProps<T>, "statusStore">> & {}>, nextState: Readonly<{}>, nextContext: any): void;
52
+ };
53
+ displayName: string;
54
+ ComposedComponent: React.ComponentType<T>;
55
+ contextType?: React.Context<any> | undefined;
56
+ } & hoistNonReactStatic.NonReactStatics<T, {}> & {
57
+ ComposedComponent: T;
58
+ };
@@ -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 v3.0.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 v3.0.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 v3.0.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,6 +209,10 @@ 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
217
  return [
210
218
  'adaptor',
@@ -226,7 +234,7 @@ var runAction = function (actionInstrance, actionConfig, renderer, event) { retu
226
234
  (_b = console.group) === null || _b === void 0 ? void 0 : _b.call(console, "run action ".concat(actionConfig.actionType));
227
235
  console.debug("[".concat(actionConfig.actionType, "] action args, data"), args, data);
228
236
  stoped = false;
229
- 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)];
230
238
  case 7:
231
239
  actionResult = _d.sent();
232
240
  // 二次确认弹窗如果取消,则终止后续动作
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v3.0.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 v3.0.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 v3.0.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5