amis-core 2.6.0 → 2.6.1-alpha.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 (233) hide show
  1. package/esm/Root.js +3 -3
  2. package/esm/RootRenderer.js +2 -2
  3. package/esm/SchemaRenderer.js +2 -2
  4. package/esm/Scoped.d.ts +1 -0
  5. package/esm/Scoped.js +60 -3
  6. package/esm/WithRootStore.js +2 -2
  7. package/esm/WithStore.js +2 -2
  8. package/esm/actions/Action.js +2 -2
  9. package/esm/actions/AjaxAction.js +2 -2
  10. package/esm/actions/BreakAction.js +2 -2
  11. package/esm/actions/BroadcastAction.js +2 -2
  12. package/esm/actions/CmptAction.d.ts +2 -0
  13. package/esm/actions/CmptAction.js +55 -39
  14. package/esm/actions/ContinueAction.js +2 -2
  15. package/esm/actions/CopyAction.js +2 -2
  16. package/esm/actions/CustomAction.js +2 -2
  17. package/esm/actions/DialogAction.js +2 -2
  18. package/esm/actions/DrawerAction.js +2 -2
  19. package/esm/actions/EmailAction.js +2 -2
  20. package/esm/actions/LinkAction.js +2 -2
  21. package/esm/actions/LoopAction.js +2 -2
  22. package/esm/actions/PageAction.js +2 -2
  23. package/esm/actions/ParallelAction.js +2 -2
  24. package/esm/actions/SwitchAction.js +2 -2
  25. package/esm/actions/ToastAction.js +2 -2
  26. package/esm/components/LazyComponent.js +2 -2
  27. package/esm/components/Overlay.js +2 -2
  28. package/esm/components/PopOver.js +2 -2
  29. package/esm/env.d.ts +8 -3
  30. package/esm/env.js +2 -2
  31. package/esm/envOverwrite.js +2 -2
  32. package/esm/factory.js +2 -2
  33. package/esm/index.d.ts +1 -1
  34. package/esm/index.js +10 -3
  35. package/esm/locale.js +2 -2
  36. package/esm/renderers/Form.js +2 -2
  37. package/esm/renderers/Item.js +2 -2
  38. package/esm/renderers/Options.js +2 -2
  39. package/esm/renderers/Placeholder.js +2 -2
  40. package/esm/renderers/builtin.js +2 -2
  41. package/esm/renderers/register.js +2 -2
  42. package/esm/renderers/wrapControl.js +2 -2
  43. package/esm/store/app.js +2 -2
  44. package/esm/store/combo.js +2 -2
  45. package/esm/store/crud.js +2 -2
  46. package/esm/store/form.js +2 -2
  47. package/esm/store/formItem.js +2 -2
  48. package/esm/store/iRenderer.js +2 -2
  49. package/esm/store/index.js +2 -2
  50. package/esm/store/list.js +2 -2
  51. package/esm/store/manager.js +2 -2
  52. package/esm/store/modal.js +2 -2
  53. package/esm/store/node.js +2 -2
  54. package/esm/store/pagination.js +2 -2
  55. package/esm/store/root.js +2 -2
  56. package/esm/store/service.js +2 -2
  57. package/esm/store/table.js +2 -2
  58. package/esm/store/table2.js +2 -2
  59. package/esm/theme.js +2 -2
  60. package/esm/types.d.ts +1 -0
  61. package/esm/utils/Animation.js +2 -2
  62. package/esm/utils/ColorScale.js +2 -2
  63. package/esm/utils/DataSchema.js +2 -2
  64. package/esm/utils/DataScope.js +2 -2
  65. package/esm/utils/RootClose.js +2 -2
  66. package/esm/utils/SimpleMap.js +2 -2
  67. package/esm/utils/api.js +7 -3
  68. package/esm/utils/attachmentAdpator.js +2 -2
  69. package/esm/utils/autobind.js +2 -2
  70. package/esm/utils/columnsSplit.js +2 -2
  71. package/esm/utils/dataMapping.js +2 -2
  72. package/esm/utils/date.js +2 -2
  73. package/esm/utils/debug.js +2 -2
  74. package/esm/utils/decodeEntity.js +2 -2
  75. package/esm/utils/dom.js +2 -2
  76. package/esm/utils/errors.js +2 -2
  77. package/esm/utils/escapeHtml.js +2 -2
  78. package/esm/utils/filter-schema.js +2 -2
  79. package/esm/utils/filter.js +2 -2
  80. package/esm/utils/formatDuration.js +2 -2
  81. package/esm/utils/formula.js +2 -2
  82. package/esm/utils/getVariable.js +2 -2
  83. package/esm/utils/grammar.js +2 -2
  84. package/esm/utils/handleAction.js +2 -2
  85. package/esm/utils/helper.js +2 -2
  86. package/esm/utils/highlight.js +2 -2
  87. package/esm/utils/icon.js +2 -2
  88. package/esm/utils/image.js +2 -2
  89. package/esm/utils/isPureVariable.js +2 -2
  90. package/esm/utils/json-schema-2-amis-schema.js +2 -2
  91. package/esm/utils/keyToPath.js +2 -2
  92. package/esm/utils/makeSorter.js +2 -2
  93. package/esm/utils/normalizeLink.js +2 -2
  94. package/esm/utils/normalizeOptions.js +2 -2
  95. package/esm/utils/object.js +2 -2
  96. package/esm/utils/offset.js +2 -2
  97. package/esm/utils/offsetParent.js +2 -2
  98. package/esm/utils/optionValueCompare.js +2 -2
  99. package/esm/utils/position.js +2 -2
  100. package/esm/utils/prettyBytes.js +2 -2
  101. package/esm/utils/renderer-event.js +2 -2
  102. package/esm/utils/replaceText.js +2 -2
  103. package/esm/utils/resize-sensor.js +2 -2
  104. package/esm/utils/resolveVariable.js +2 -2
  105. package/esm/utils/resolveVariableAndFilter.js +2 -2
  106. package/esm/utils/scrollPosition.js +2 -2
  107. package/esm/utils/string2regExp.js +2 -2
  108. package/esm/utils/stripNumber.js +2 -2
  109. package/esm/utils/style.js +2 -2
  110. package/esm/utils/toNumber.js +2 -2
  111. package/esm/utils/tokenize.js +2 -2
  112. package/esm/utils/tpl-builtin.js +2 -2
  113. package/esm/utils/tpl-lodash.js +2 -2
  114. package/esm/utils/tpl.js +2 -2
  115. package/esm/utils/uncontrollable.js +2 -2
  116. package/esm/utils/validations.js +2 -2
  117. package/lib/Root.js +4 -4
  118. package/lib/RootRenderer.js +2 -2
  119. package/lib/SchemaRenderer.js +2 -2
  120. package/lib/Scoped.d.ts +1 -0
  121. package/lib/Scoped.js +60 -2
  122. package/lib/WithRootStore.js +2 -2
  123. package/lib/WithStore.js +2 -2
  124. package/lib/actions/Action.js +2 -2
  125. package/lib/actions/AjaxAction.js +2 -2
  126. package/lib/actions/BreakAction.js +2 -2
  127. package/lib/actions/BroadcastAction.js +2 -2
  128. package/lib/actions/CmptAction.d.ts +2 -0
  129. package/lib/actions/CmptAction.js +55 -39
  130. package/lib/actions/ContinueAction.js +2 -2
  131. package/lib/actions/CopyAction.js +2 -2
  132. package/lib/actions/CustomAction.js +2 -2
  133. package/lib/actions/DialogAction.js +2 -2
  134. package/lib/actions/DrawerAction.js +2 -2
  135. package/lib/actions/EmailAction.js +2 -2
  136. package/lib/actions/LinkAction.js +2 -2
  137. package/lib/actions/LoopAction.js +2 -2
  138. package/lib/actions/PageAction.js +2 -2
  139. package/lib/actions/ParallelAction.js +2 -2
  140. package/lib/actions/SwitchAction.js +2 -2
  141. package/lib/actions/ToastAction.js +2 -2
  142. package/lib/components/LazyComponent.js +2 -2
  143. package/lib/components/Overlay.js +2 -2
  144. package/lib/components/PopOver.js +2 -2
  145. package/lib/env.d.ts +8 -3
  146. package/lib/env.js +2 -2
  147. package/lib/envOverwrite.js +2 -2
  148. package/lib/factory.js +2 -2
  149. package/lib/index.d.ts +1 -1
  150. package/lib/index.js +10 -3
  151. package/lib/locale.js +2 -2
  152. package/lib/renderers/Form.js +2 -2
  153. package/lib/renderers/Item.js +2 -2
  154. package/lib/renderers/Options.js +2 -2
  155. package/lib/renderers/Placeholder.js +2 -2
  156. package/lib/renderers/builtin.js +2 -2
  157. package/lib/renderers/register.js +2 -2
  158. package/lib/renderers/wrapControl.js +2 -2
  159. package/lib/store/app.js +2 -2
  160. package/lib/store/combo.js +2 -2
  161. package/lib/store/crud.js +2 -2
  162. package/lib/store/form.js +2 -2
  163. package/lib/store/formItem.js +2 -2
  164. package/lib/store/iRenderer.js +2 -2
  165. package/lib/store/index.js +2 -2
  166. package/lib/store/list.js +2 -2
  167. package/lib/store/manager.js +2 -2
  168. package/lib/store/modal.js +2 -2
  169. package/lib/store/node.js +2 -2
  170. package/lib/store/pagination.js +2 -2
  171. package/lib/store/root.js +2 -2
  172. package/lib/store/service.js +2 -2
  173. package/lib/store/table.js +2 -2
  174. package/lib/store/table2.js +2 -2
  175. package/lib/theme.js +2 -2
  176. package/lib/types.d.ts +1 -0
  177. package/lib/utils/Animation.js +2 -2
  178. package/lib/utils/ColorScale.js +2 -2
  179. package/lib/utils/DataSchema.js +2 -2
  180. package/lib/utils/DataScope.js +2 -2
  181. package/lib/utils/RootClose.js +2 -2
  182. package/lib/utils/SimpleMap.js +2 -2
  183. package/lib/utils/api.js +7 -3
  184. package/lib/utils/attachmentAdpator.js +2 -2
  185. package/lib/utils/autobind.js +2 -2
  186. package/lib/utils/columnsSplit.js +2 -2
  187. package/lib/utils/dataMapping.js +2 -2
  188. package/lib/utils/date.js +2 -2
  189. package/lib/utils/debug.js +2 -2
  190. package/lib/utils/decodeEntity.js +2 -2
  191. package/lib/utils/dom.js +2 -2
  192. package/lib/utils/errors.js +2 -2
  193. package/lib/utils/escapeHtml.js +2 -2
  194. package/lib/utils/filter-schema.js +2 -2
  195. package/lib/utils/filter.js +2 -2
  196. package/lib/utils/formatDuration.js +2 -2
  197. package/lib/utils/formula.js +2 -2
  198. package/lib/utils/getVariable.js +2 -2
  199. package/lib/utils/grammar.js +2 -2
  200. package/lib/utils/handleAction.js +2 -2
  201. package/lib/utils/helper.js +2 -2
  202. package/lib/utils/highlight.js +2 -2
  203. package/lib/utils/icon.js +2 -2
  204. package/lib/utils/image.js +2 -2
  205. package/lib/utils/isPureVariable.js +2 -2
  206. package/lib/utils/json-schema-2-amis-schema.js +2 -2
  207. package/lib/utils/keyToPath.js +2 -2
  208. package/lib/utils/makeSorter.js +2 -2
  209. package/lib/utils/normalizeLink.js +2 -2
  210. package/lib/utils/normalizeOptions.js +2 -2
  211. package/lib/utils/object.js +2 -2
  212. package/lib/utils/offset.js +2 -2
  213. package/lib/utils/offsetParent.js +2 -2
  214. package/lib/utils/optionValueCompare.js +2 -2
  215. package/lib/utils/position.js +2 -2
  216. package/lib/utils/prettyBytes.js +2 -2
  217. package/lib/utils/renderer-event.js +2 -2
  218. package/lib/utils/replaceText.js +2 -2
  219. package/lib/utils/resize-sensor.js +2 -2
  220. package/lib/utils/resolveVariable.js +2 -2
  221. package/lib/utils/resolveVariableAndFilter.js +2 -2
  222. package/lib/utils/scrollPosition.js +2 -2
  223. package/lib/utils/string2regExp.js +2 -2
  224. package/lib/utils/stripNumber.js +2 -2
  225. package/lib/utils/style.js +2 -2
  226. package/lib/utils/toNumber.js +2 -2
  227. package/lib/utils/tokenize.js +2 -2
  228. package/lib/utils/tpl-builtin.js +2 -2
  229. package/lib/utils/tpl-lodash.js +2 -2
  230. package/lib/utils/tpl.js +2 -2
  231. package/lib/utils/uncontrollable.js +2 -2
  232. package/lib/utils/validations.js +2 -2
  233. package/package.json +3 -3
package/esm/Root.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends, __rest, __assign, __decorate, __metadata } from 'tslib';
7
- import isPlainObject from 'lodash/isPlainObject';
8
7
  import React from 'react';
8
+ import isPlainObject from 'lodash/isPlainObject';
9
9
  import { LocaleContext } from './locale.js';
10
10
  import { RootRenderer } from './RootRenderer.js';
11
11
  import { SchemaRenderer } from './SchemaRenderer.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends, __assign, __awaiter, __generator, __spreadArray, __rest, __decorate, __metadata } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends, __assign, __awaiter, __generator, __rest, __decorate, __metadata } from 'tslib';
package/esm/Scoped.d.ts CHANGED
@@ -11,6 +11,7 @@ export interface ScopedComponentType extends React.Component<RendererProps> {
11
11
  receive?: (values: RendererData, subPath?: string, replace?: boolean) => void;
12
12
  reload?: (subPath?: string, query?: RendererData | null, ctx?: RendererData) => void;
13
13
  context: any;
14
+ setData?: (value?: any, replace?: boolean, index?: number) => void;
14
15
  }
15
16
  export interface IScopedContext {
16
17
  parent?: AliasIScopedContext;
package/esm/Scoped.js CHANGED
@@ -1,19 +1,21 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __assign, __extends, __rest, __decorate, __metadata } from 'tslib';
7
7
  import React from 'react';
8
8
  import find from 'lodash/find';
9
+ import values from 'lodash/values';
9
10
  import hoistNonReactStatic from 'hoist-non-react-statics';
10
11
  import { registerFunction } from 'amis-formula';
11
12
  import 'moment';
12
13
  import 'lodash/isPlainObject';
13
14
  import { getVariable } from './utils/getVariable.js';
15
+ import { isPureVariable } from './utils/isPureVariable.js';
14
16
  import { dataMapping } from './utils/dataMapping.js';
15
17
  import './utils/filter.js';
16
- import { findTree, qsparse, qsstringify, parseQuery, autobind } from './utils/helper.js';
18
+ import { findTree, eachTree, qsparse, qsstringify, parseQuery, autobind } from './utils/helper.js';
17
19
 
18
20
  /**
19
21
  * @file 用来创建一个域,在这个域里面会把里面的运行时实例注册进来,方便组件之间的通信。
@@ -79,6 +81,61 @@ function createScopedTools(path, parent, env) {
79
81
  });
80
82
  return component;
81
83
  },
84
+ /**
85
+ * 基于绑定的变量名称查找组件
86
+ * 支持形如${xxx}的格式
87
+ *
88
+ * @param session store的session, 默认为全局的
89
+ * @param path 变量路径, 包含命名空间
90
+ */
91
+ getComponentsByRefPath: function (session, path) {
92
+ if (!path || typeof path !== 'string') {
93
+ return [];
94
+ }
95
+ var cmptMaps = {};
96
+ var root = this;
97
+ while (root.parent) {
98
+ root = root.parent;
99
+ }
100
+ eachTree([root], function (item) {
101
+ var _a, _b, _c, _d, _e, _f;
102
+ var scopedCmptList = item.getComponents() || [];
103
+ if (Array.isArray(scopedCmptList)) {
104
+ for (var _i = 0, scopedCmptList_1 = scopedCmptList; _i < scopedCmptList_1.length; _i++) {
105
+ var cmpt = scopedCmptList_1[_i];
106
+ var pathKey = (_b = (_a = cmpt === null || cmpt === void 0 ? void 0 : cmpt.props) === null || _a === void 0 ? void 0 : _a.$path) !== null && _b !== void 0 ? _b : 'unknown';
107
+ var schema = (_d = (_c = cmpt === null || cmpt === void 0 ? void 0 : cmpt.props) === null || _c === void 0 ? void 0 : _c.$schema) !== null && _d !== void 0 ? _d : {};
108
+ var cmptSession = (_f = (_e = cmpt === null || cmpt === void 0 ? void 0 : cmpt.props.env) === null || _e === void 0 ? void 0 : _e.session) !== null && _f !== void 0 ? _f : 'global';
109
+ /** 仅查找当前session的组件 */
110
+ if (cmptMaps[pathKey] || session !== cmptSession) {
111
+ continue;
112
+ }
113
+ /** 非Scoped组件, 查找其所属的父容器 */
114
+ if ((cmpt === null || cmpt === void 0 ? void 0 : cmpt.setData) && typeof cmpt.setData === 'function') {
115
+ cmptMaps[pathKey] = cmpt;
116
+ continue;
117
+ }
118
+ /** 查找Scoped组件中的引用 */
119
+ for (var _g = 0, _h = Object.keys(schema); _g < _h.length; _g++) {
120
+ var key = _h[_g];
121
+ var expression = schema[key];
122
+ if (typeof expression === 'string' &&
123
+ isPureVariable(expression)) {
124
+ /** 考虑到数据映射函数的情况,将宿主变量提取出来 */
125
+ var host = expression
126
+ .substring(2, expression.length - 1)
127
+ .split('|')[0];
128
+ if (host && host === path) {
129
+ cmptMaps[pathKey] = cmpt;
130
+ break;
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
136
+ });
137
+ return values(cmptMaps);
138
+ },
82
139
  getComponents: function () {
83
140
  return components.concat();
84
141
  },
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends, __assign } from 'tslib';
package/esm/WithStore.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends, __assign, __rest, __decorate, __metadata } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator, __assign } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator, __assign } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator } from 'tslib';
@@ -3,6 +3,8 @@ import { RendererAction, ListenerAction, ListenerContext } from './Action';
3
3
  export interface ICmptAction extends ListenerAction {
4
4
  actionType: 'setValue' | 'static' | 'nonstatic' | 'show' | 'visibility' | 'hidden' | 'enabled' | 'disabled' | 'usability' | 'reload';
5
5
  args: {
6
+ /** actionType为setValue时,目标变量的path */
7
+ path?: string;
6
8
  value?: string | {
7
9
  [key: string]: string;
8
10
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator } from 'tslib';
@@ -17,45 +17,61 @@ 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, _j, _k;
20
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
21
21
  return __awaiter(this, void 0, void 0, function () {
22
- var component, dataMergeMode, visibility, usability;
23
- return __generator(this, function (_l) {
24
- component = action.componentId && renderer.props.$schema.id !== action.componentId
25
- ? (_a = event.context.scoped) === null || _a === void 0 ? void 0 : _a.getComponentById(action.componentId)
26
- : renderer;
27
- dataMergeMode = action.dataMergeMode || 'merge';
28
- // 显隐&状态控制
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
32
- : action.actionType === 'show';
33
- return [2 /*return*/, renderer.props.topStore.setVisible(action.componentId, visibility)];
22
+ var component, dataMergeMode, visibility, usability, beforeSetData, path, res;
23
+ return __generator(this, function (_p) {
24
+ switch (_p.label) {
25
+ case 0:
26
+ component = action.componentId && renderer.props.$schema.id !== action.componentId
27
+ ? (_a = event.context.scoped) === null || _a === void 0 ? void 0 : _a.getComponentById(action.componentId)
28
+ : renderer;
29
+ dataMergeMode = action.dataMergeMode || 'merge';
30
+ // 显隐&状态控制
31
+ if (['show', 'hidden', 'visibility'].includes(action.actionType)) {
32
+ visibility = action.actionType === 'visibility'
33
+ ? (_b = action.args) === null || _b === void 0 ? void 0 : _b.value
34
+ : action.actionType === 'show';
35
+ return [2 /*return*/, renderer.props.topStore.setVisible(action.componentId, visibility)];
36
+ }
37
+ else if (['static', 'nonstatic'].includes(action.actionType)) {
38
+ return [2 /*return*/, renderer.props.topStore.setStatic(action.componentId, action.actionType === 'static')];
39
+ }
40
+ else if (['enabled', 'disabled', 'usability'].includes(action.actionType)) {
41
+ usability = action.actionType === 'usability'
42
+ ? !((_c = action.args) === null || _c === void 0 ? void 0 : _c.value)
43
+ : action.actionType === 'disabled';
44
+ return [2 /*return*/, renderer.props.topStore.setDisable(action.componentId, usability)];
45
+ }
46
+ if (!(action.actionType === 'setValue')) return [3 /*break*/, 3];
47
+ 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;
48
+ path = (_f = action.args) === null || _f === void 0 ? void 0 : _f.path;
49
+ if (!(path &&
50
+ typeof path === 'string' &&
51
+ beforeSetData &&
52
+ typeof beforeSetData === 'function')) return [3 /*break*/, 2];
53
+ return [4 /*yield*/, beforeSetData(renderer, action, event)];
54
+ case 1:
55
+ res = _p.sent();
56
+ if (res === false) {
57
+ return [2 /*return*/];
58
+ }
59
+ _p.label = 2;
60
+ case 2:
61
+ if (component === null || component === void 0 ? void 0 : component.setData) {
62
+ return [2 /*return*/, component === null || component === void 0 ? void 0 : component.setData((_g = action.args) === null || _g === void 0 ? void 0 : _g.value, dataMergeMode === 'override', (_h = action.args) === null || _h === void 0 ? void 0 : _h.index)];
63
+ }
64
+ else {
65
+ return [2 /*return*/, (_k = component === null || component === void 0 ? void 0 : (_j = component.props).onChange) === null || _k === void 0 ? void 0 : _k.call(_j, (_l = action.args) === null || _l === void 0 ? void 0 : _l.value)];
66
+ }
67
+ case 3:
68
+ // 刷新
69
+ if (action.actionType === 'reload') {
70
+ return [2 /*return*/, (_m = component === null || component === void 0 ? void 0 : component.reload) === null || _m === void 0 ? void 0 : _m.call(component, undefined, action.data, undefined, undefined, dataMergeMode === 'override', action.args)];
71
+ }
72
+ // 执行组件动作
73
+ return [2 /*return*/, (_o = component === null || component === void 0 ? void 0 : component.doAction) === null || _o === void 0 ? void 0 : _o.call(component, action, action.args)];
34
74
  }
35
- else if (['static', 'nonstatic'].includes(action.actionType)) {
36
- return [2 /*return*/, renderer.props.topStore.setStatic(action.componentId, action.actionType === 'static')];
37
- }
38
- else if (['enabled', 'disabled', 'usability'].includes(action.actionType)) {
39
- usability = action.actionType === 'usability'
40
- ? !((_c = action.args) === null || _c === void 0 ? void 0 : _c.value)
41
- : action.actionType === 'disabled';
42
- return [2 /*return*/, renderer.props.topStore.setDisable(action.componentId, usability)];
43
- }
44
- // 数据更新
45
- if (action.actionType === 'setValue') {
46
- if (component === null || component === void 0 ? void 0 : component.setData) {
47
- 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)];
48
- }
49
- else {
50
- 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)];
51
- }
52
- }
53
- // 刷新
54
- if (action.actionType === 'reload') {
55
- 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)];
56
- }
57
- // 执行组件动作
58
- 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)];
59
75
  });
60
76
  });
61
77
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator, __assign } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator, __assign } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator, __assign } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __awaiter, __generator } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends, __rest, __assign } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends, __rest, __assign, __decorate, __metadata } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends, __rest, __assign } from 'tslib';
package/esm/env.d.ts CHANGED
@@ -6,14 +6,17 @@ import { RendererConfig } from './factory';
6
6
  import { ThemeInstance } from './theme';
7
7
  import { ActionObject, Api, EventTrack, Payload, PlainObject, Schema, ToastConf, ToastLevel } from './types';
8
8
  import hoistNonReactStatic from 'hoist-non-react-statics';
9
- import { IScopedContext } from './Scoped';
10
- import { RendererEvent } from './utils/renderer-event';
9
+ import type { IScopedContext } from './Scoped';
10
+ import type { RendererEvent } from './utils/renderer-event';
11
+ import type { ListenerContext } from './actions/Action';
12
+ import type { ICmptAction } from './actions/CmptAction';
11
13
  export interface wsObject {
12
14
  url: string;
13
15
  responseKey?: string;
14
16
  body?: any;
15
17
  }
16
18
  export interface RendererEnv {
19
+ session?: string;
17
20
  fetcher: (api: Api, data?: any, options?: object) => Promise<Payload>;
18
21
  isCancel: (val: any) => boolean;
19
22
  wsFetcher: (ws: wsObject, onMessage: (data: any) => void, onError: (error: any) => void) => void;
@@ -63,13 +66,15 @@ export interface RendererEnv {
63
66
  [propName: string]: any;
64
67
  };
65
68
  /**
66
- * 文本替换的黑名单,因为属性太多了所以改成黑名单的 fangs
69
+ * 文本替换的黑名单,因为属性太多了所以改成黑名单的 flags
67
70
  */
68
71
  replaceTextIgnoreKeys?: String[];
69
72
  /**
70
73
  * 解析url参数
71
74
  */
72
75
  parseLocation?: (location: any) => Object;
76
+ /** 数据更新前触发的Hook */
77
+ beforeSetData?: (renderer: ListenerContext, action: ICmptAction, event: RendererEvent<any, any>) => Promise<void | boolean>;
73
78
  }
74
79
  export declare const EnvContext: React.Context<void | RendererEnv>;
75
80
  export interface EnvProps {
package/esm/env.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { findObjectsWithKey } from './utils/helper.js';
package/esm/factory.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __assign } from 'tslib';
package/esm/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  /** @license amis v@version
3
2
  *
4
3
  * Copyright Baidu
@@ -6,6 +5,7 @@
6
5
  * This source code is licensed under the Apache license found in the
7
6
  * LICENSE file in the root directory of this source tree.
8
7
  */
8
+ /// <reference types="react" />
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';
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __assign } from 'tslib';
@@ -121,9 +121,16 @@ export { PaginationStore } from './store/pagination.js';
121
121
  export { AppStore } from './store/app.js';
122
122
  export { StoreNode } from './store/node.js';
123
123
 
124
+ /** @license amis v@version
125
+ *
126
+ * Copyright Baidu
127
+ *
128
+ * This source code is licensed under the Apache license found in the
129
+ * LICENSE file in the root directory of this source tree.
130
+ */
124
131
  var classPrefix = getClassPrefix();
125
132
  // @ts-ignore
126
- var version = '2.6.0';
133
+ var version = '2.6.1-alpha.0';
127
134
  function render(schema, props, options, pathPrefix) {
128
135
  if (props === void 0) { props = {}; }
129
136
  if (options === void 0) { options = {}; }
package/esm/locale.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __assign, __extends, __spreadArray } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends, __awaiter, __generator, __assign, __decorate, __metadata } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends, __awaiter, __generator, __assign, __rest, __decorate, __metadata, __spreadArray } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends, __awaiter, __generator, __assign, __spreadArray, __decorate, __metadata } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { __extends } from 'tslib';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { Placeholder } from './Placeholder.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
- * amis-core v2.6.0
3
- * Copyright 2018-2022 fex
2
+ * amis-core v2.6.1-alpha.0
3
+ * Copyright 2018-2023 fex
4
4
  */
5
5
 
6
6
  import { renderersMap, Renderer } from '../factory.js';