amis-core 2.8.0 → 3.0.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 (315) hide show
  1. package/esm/Root.d.ts +1 -1
  2. package/esm/Root.js +1 -1
  3. package/esm/RootRenderer.d.ts +1 -1
  4. package/esm/RootRenderer.js +21 -4
  5. package/esm/SchemaRenderer.d.ts +3 -1
  6. package/esm/SchemaRenderer.js +7 -5
  7. package/esm/Scoped.js +30 -2
  8. package/esm/WithRootStore.d.ts +4 -8
  9. package/esm/WithRootStore.js +1 -1
  10. package/esm/WithStore.js +1 -1
  11. package/esm/actions/Action.d.ts +2 -1
  12. package/esm/actions/Action.js +40 -12
  13. package/esm/actions/AjaxAction.js +1 -1
  14. package/esm/actions/BreakAction.js +1 -1
  15. package/esm/actions/BroadcastAction.js +1 -1
  16. package/esm/actions/CmptAction.js +1 -1
  17. package/esm/actions/ContinueAction.js +1 -1
  18. package/esm/actions/CopyAction.js +1 -1
  19. package/esm/actions/CustomAction.js +2 -1
  20. package/esm/actions/DialogAction.d.ts +1 -1
  21. package/esm/actions/DialogAction.js +12 -3
  22. package/esm/actions/DrawerAction.js +1 -1
  23. package/esm/actions/EmailAction.js +1 -1
  24. package/esm/actions/LinkAction.js +1 -1
  25. package/esm/actions/LoopAction.js +1 -1
  26. package/esm/actions/PageAction.js +1 -1
  27. package/esm/actions/ParallelAction.js +1 -1
  28. package/esm/actions/SwitchAction.js +18 -15
  29. package/esm/actions/ToastAction.js +1 -1
  30. package/esm/components/LazyComponent.d.ts +3 -3
  31. package/esm/components/LazyComponent.js +1 -1
  32. package/esm/components/Overlay.d.ts +2 -2
  33. package/esm/components/Overlay.js +2 -1
  34. package/esm/components/PopOver.d.ts +2 -4
  35. package/esm/components/PopOver.js +2 -1
  36. package/esm/env.d.ts +3 -7
  37. package/esm/env.js +1 -1
  38. package/esm/envOverwrite.js +1 -1
  39. package/esm/factory.d.ts +2 -1
  40. package/esm/factory.js +5 -3
  41. package/esm/index.d.ts +9 -5
  42. package/esm/index.js +12 -9
  43. package/esm/locale.d.ts +1 -3
  44. package/esm/locale.js +1 -1
  45. package/esm/renderers/Form.d.ts +1 -1
  46. package/esm/renderers/Form.js +17 -15
  47. package/esm/renderers/Item.d.ts +9 -15
  48. package/esm/renderers/Item.js +11 -7
  49. package/esm/renderers/Options.js +4 -3
  50. package/esm/renderers/Placeholder.js +1 -1
  51. package/esm/renderers/builtin.js +1 -1
  52. package/esm/renderers/register.js +1 -1
  53. package/esm/renderers/wrapControl.d.ts +4 -8
  54. package/esm/renderers/wrapControl.js +21 -30
  55. package/esm/store/app.d.ts +4 -2
  56. package/esm/store/app.js +1 -1
  57. package/esm/store/combo.d.ts +12 -6
  58. package/esm/store/combo.js +1 -1
  59. package/esm/store/crud.d.ts +5 -2
  60. package/esm/store/crud.js +46 -12
  61. package/esm/store/form.d.ts +4 -2
  62. package/esm/store/form.js +1 -1
  63. package/esm/store/formItem.js +6 -5
  64. package/esm/store/iRenderer.d.ts +5 -2
  65. package/esm/store/iRenderer.js +15 -3
  66. package/esm/store/index.js +1 -1
  67. package/esm/store/list.d.ts +4 -2
  68. package/esm/store/list.js +5 -5
  69. package/esm/store/manager.js +1 -1
  70. package/esm/store/modal.d.ts +4 -2
  71. package/esm/store/modal.js +1 -1
  72. package/esm/store/node.js +1 -1
  73. package/esm/store/pagination.d.ts +4 -2
  74. package/esm/store/pagination.js +2 -2
  75. package/esm/store/root.d.ts +4 -2
  76. package/esm/store/root.js +1 -1
  77. package/esm/store/service.d.ts +4 -2
  78. package/esm/store/service.js +1 -1
  79. package/esm/store/table.d.ts +36 -29
  80. package/esm/store/table.js +28 -5
  81. package/esm/store/table2.d.ts +9 -7
  82. package/esm/store/table2.js +23 -19
  83. package/esm/theme.d.ts +2 -4
  84. package/esm/theme.js +1 -1
  85. package/esm/types.d.ts +45 -2
  86. package/esm/utils/Animation.js +1 -1
  87. package/esm/utils/ColorScale.js +1 -1
  88. package/esm/utils/DataSchema.js +1 -1
  89. package/esm/utils/DataScope.js +1 -1
  90. package/esm/utils/RootClose.js +1 -1
  91. package/esm/utils/SimpleMap.js +1 -1
  92. package/esm/utils/api.js +11 -5
  93. package/esm/utils/attachmentAdpator.js +1 -1
  94. package/esm/utils/autobind.js +1 -1
  95. package/esm/utils/columnsSplit.js +1 -1
  96. package/esm/utils/dataMapping.js +1 -1
  97. package/esm/utils/date.js +1 -1
  98. package/esm/utils/debug.d.ts +1 -0
  99. package/esm/utils/debug.js +4 -4
  100. package/esm/utils/decodeEntity.js +1 -1
  101. package/esm/utils/dom.d.ts +2 -0
  102. package/esm/utils/dom.js +47 -10
  103. package/esm/utils/errors.js +1 -1
  104. package/esm/utils/escapeHtml.js +1 -1
  105. package/esm/utils/filter-schema.js +1 -1
  106. package/esm/utils/filter.js +1 -1
  107. package/esm/utils/formatDuration.js +1 -1
  108. package/esm/utils/formula.d.ts +1 -0
  109. package/esm/utils/formula.js +7 -3
  110. package/esm/utils/getVariable.js +1 -1
  111. package/esm/utils/grammar.js +1 -1
  112. package/esm/utils/handleAction.js +1 -1
  113. package/esm/utils/helper.d.ts +7 -0
  114. package/esm/utils/helper.js +28 -3
  115. package/esm/utils/highlight.js +1 -1
  116. package/esm/utils/icon.d.ts +6 -1
  117. package/esm/utils/icon.js +6 -1
  118. package/esm/utils/image.js +1 -1
  119. package/esm/utils/index.d.ts +2 -0
  120. package/esm/utils/isPureVariable.js +1 -1
  121. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  122. package/esm/utils/keyToPath.js +1 -1
  123. package/esm/utils/makeSorter.js +1 -1
  124. package/esm/utils/normalizeLink.js +1 -1
  125. package/esm/utils/normalizeOptions.js +1 -1
  126. package/esm/utils/object.js +1 -1
  127. package/esm/utils/offset.js +1 -1
  128. package/esm/utils/offsetParent.js +1 -1
  129. package/esm/utils/optionValueCompare.js +7 -3
  130. package/esm/utils/position.js +1 -1
  131. package/esm/utils/prettyBytes.js +1 -1
  132. package/esm/utils/renderer-event.js +35 -32
  133. package/esm/utils/replaceText.js +1 -1
  134. package/esm/utils/resize-sensor.js +1 -1
  135. package/esm/utils/resolveCondition.d.ts +6 -0
  136. package/esm/utils/resolveCondition.js +321 -0
  137. package/esm/utils/resolveVariable.js +1 -1
  138. package/esm/utils/resolveVariableAndFilter.js +1 -1
  139. package/esm/utils/resolveVariableAndFilterForAsync.d.ts +6 -0
  140. package/esm/utils/resolveVariableAndFilterForAsync.js +63 -0
  141. package/esm/utils/scrollPosition.js +1 -1
  142. package/esm/utils/string2regExp.js +1 -1
  143. package/esm/utils/stripNumber.js +1 -1
  144. package/esm/utils/style-helper.d.ts +9 -4
  145. package/esm/utils/style-helper.js +81 -16
  146. package/esm/utils/style.js +2 -2
  147. package/esm/utils/toNumber.js +1 -1
  148. package/esm/utils/tokenize.d.ts +1 -0
  149. package/esm/utils/tokenize.js +34 -3
  150. package/esm/utils/tpl-builtin.d.ts +2 -1
  151. package/esm/utils/tpl-builtin.js +18 -3
  152. package/esm/utils/tpl-lodash.js +3 -2
  153. package/esm/utils/tpl.d.ts +9 -0
  154. package/esm/utils/tpl.js +45 -3
  155. package/esm/utils/uncontrollable.js +1 -1
  156. package/esm/utils/validations.d.ts +4 -1
  157. package/esm/utils/validations.js +27 -12
  158. package/lib/Root.d.ts +1 -1
  159. package/lib/Root.js +1 -1
  160. package/lib/RootRenderer.d.ts +1 -1
  161. package/lib/RootRenderer.js +21 -4
  162. package/lib/SchemaRenderer.d.ts +3 -1
  163. package/lib/SchemaRenderer.js +7 -4
  164. package/lib/Scoped.js +30 -2
  165. package/lib/WithRootStore.d.ts +4 -8
  166. package/lib/WithRootStore.js +1 -1
  167. package/lib/WithStore.js +1 -1
  168. package/lib/actions/Action.d.ts +2 -1
  169. package/lib/actions/Action.js +39 -11
  170. package/lib/actions/AjaxAction.js +1 -1
  171. package/lib/actions/BreakAction.js +1 -1
  172. package/lib/actions/BroadcastAction.js +1 -1
  173. package/lib/actions/CmptAction.js +1 -1
  174. package/lib/actions/ContinueAction.js +1 -1
  175. package/lib/actions/CopyAction.js +1 -1
  176. package/lib/actions/CustomAction.js +2 -1
  177. package/lib/actions/DialogAction.d.ts +1 -1
  178. package/lib/actions/DialogAction.js +12 -3
  179. package/lib/actions/DrawerAction.js +1 -1
  180. package/lib/actions/EmailAction.js +1 -1
  181. package/lib/actions/LinkAction.js +1 -1
  182. package/lib/actions/LoopAction.js +1 -1
  183. package/lib/actions/PageAction.js +1 -1
  184. package/lib/actions/ParallelAction.js +1 -1
  185. package/lib/actions/SwitchAction.js +17 -14
  186. package/lib/actions/ToastAction.js +1 -1
  187. package/lib/components/LazyComponent.d.ts +3 -3
  188. package/lib/components/LazyComponent.js +1 -1
  189. package/lib/components/Overlay.d.ts +2 -2
  190. package/lib/components/Overlay.js +2 -1
  191. package/lib/components/PopOver.d.ts +2 -4
  192. package/lib/components/PopOver.js +2 -1
  193. package/lib/env.d.ts +3 -7
  194. package/lib/env.js +1 -1
  195. package/lib/envOverwrite.js +1 -1
  196. package/lib/factory.d.ts +2 -1
  197. package/lib/factory.js +5 -3
  198. package/lib/index.d.ts +9 -5
  199. package/lib/index.js +30 -2
  200. package/lib/locale.d.ts +1 -3
  201. package/lib/locale.js +1 -1
  202. package/lib/renderers/Form.d.ts +1 -1
  203. package/lib/renderers/Form.js +16 -14
  204. package/lib/renderers/Item.d.ts +9 -15
  205. package/lib/renderers/Item.js +11 -7
  206. package/lib/renderers/Options.js +4 -3
  207. package/lib/renderers/Placeholder.js +1 -1
  208. package/lib/renderers/builtin.js +1 -1
  209. package/lib/renderers/register.js +1 -1
  210. package/lib/renderers/wrapControl.d.ts +4 -8
  211. package/lib/renderers/wrapControl.js +20 -28
  212. package/lib/store/app.d.ts +4 -2
  213. package/lib/store/app.js +1 -1
  214. package/lib/store/combo.d.ts +12 -6
  215. package/lib/store/combo.js +1 -1
  216. package/lib/store/crud.d.ts +5 -2
  217. package/lib/store/crud.js +45 -11
  218. package/lib/store/form.d.ts +4 -2
  219. package/lib/store/form.js +1 -1
  220. package/lib/store/formItem.js +6 -5
  221. package/lib/store/iRenderer.d.ts +5 -2
  222. package/lib/store/iRenderer.js +15 -3
  223. package/lib/store/index.js +1 -1
  224. package/lib/store/list.d.ts +4 -2
  225. package/lib/store/list.js +5 -5
  226. package/lib/store/manager.js +1 -1
  227. package/lib/store/modal.d.ts +4 -2
  228. package/lib/store/modal.js +1 -1
  229. package/lib/store/node.js +1 -1
  230. package/lib/store/pagination.d.ts +4 -2
  231. package/lib/store/pagination.js +2 -2
  232. package/lib/store/root.d.ts +4 -2
  233. package/lib/store/root.js +1 -1
  234. package/lib/store/service.d.ts +4 -2
  235. package/lib/store/service.js +1 -1
  236. package/lib/store/table.d.ts +36 -29
  237. package/lib/store/table.js +28 -5
  238. package/lib/store/table2.d.ts +9 -7
  239. package/lib/store/table2.js +23 -19
  240. package/lib/theme.d.ts +2 -4
  241. package/lib/theme.js +1 -1
  242. package/lib/types.d.ts +45 -2
  243. package/lib/utils/Animation.js +1 -1
  244. package/lib/utils/ColorScale.js +1 -1
  245. package/lib/utils/DataSchema.js +1 -1
  246. package/lib/utils/DataScope.js +1 -1
  247. package/lib/utils/RootClose.js +1 -1
  248. package/lib/utils/SimpleMap.js +1 -1
  249. package/lib/utils/api.js +10 -4
  250. package/lib/utils/attachmentAdpator.js +1 -1
  251. package/lib/utils/autobind.js +1 -1
  252. package/lib/utils/columnsSplit.js +1 -1
  253. package/lib/utils/dataMapping.js +1 -1
  254. package/lib/utils/date.js +1 -1
  255. package/lib/utils/debug.d.ts +1 -0
  256. package/lib/utils/debug.js +4 -4
  257. package/lib/utils/decodeEntity.js +1 -1
  258. package/lib/utils/dom.d.ts +2 -0
  259. package/lib/utils/dom.js +48 -9
  260. package/lib/utils/errors.js +1 -1
  261. package/lib/utils/escapeHtml.js +1 -1
  262. package/lib/utils/filter-schema.js +1 -1
  263. package/lib/utils/filter.js +1 -1
  264. package/lib/utils/formatDuration.js +1 -1
  265. package/lib/utils/formula.d.ts +1 -0
  266. package/lib/utils/formula.js +7 -2
  267. package/lib/utils/getVariable.js +1 -1
  268. package/lib/utils/grammar.js +1 -1
  269. package/lib/utils/handleAction.js +1 -1
  270. package/lib/utils/helper.d.ts +7 -0
  271. package/lib/utils/helper.js +29 -2
  272. package/lib/utils/highlight.js +1 -1
  273. package/lib/utils/icon.d.ts +6 -1
  274. package/lib/utils/icon.js +6 -1
  275. package/lib/utils/image.js +1 -1
  276. package/lib/utils/index.d.ts +2 -0
  277. package/lib/utils/isPureVariable.js +1 -1
  278. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  279. package/lib/utils/keyToPath.js +1 -1
  280. package/lib/utils/makeSorter.js +1 -1
  281. package/lib/utils/normalizeLink.js +1 -1
  282. package/lib/utils/normalizeOptions.js +1 -1
  283. package/lib/utils/object.js +1 -1
  284. package/lib/utils/offset.js +1 -1
  285. package/lib/utils/offsetParent.js +1 -1
  286. package/lib/utils/optionValueCompare.js +7 -3
  287. package/lib/utils/position.js +1 -1
  288. package/lib/utils/prettyBytes.js +1 -1
  289. package/lib/utils/renderer-event.js +35 -32
  290. package/lib/utils/replaceText.js +1 -1
  291. package/lib/utils/resize-sensor.js +1 -1
  292. package/lib/utils/resolveCondition.d.ts +6 -0
  293. package/lib/utils/resolveCondition.js +338 -0
  294. package/lib/utils/resolveVariable.js +1 -1
  295. package/lib/utils/resolveVariableAndFilter.js +1 -1
  296. package/lib/utils/resolveVariableAndFilterForAsync.d.ts +6 -0
  297. package/lib/utils/resolveVariableAndFilterForAsync.js +68 -0
  298. package/lib/utils/scrollPosition.js +1 -1
  299. package/lib/utils/string2regExp.js +1 -1
  300. package/lib/utils/stripNumber.js +1 -1
  301. package/lib/utils/style-helper.d.ts +9 -4
  302. package/lib/utils/style-helper.js +86 -15
  303. package/lib/utils/style.js +2 -2
  304. package/lib/utils/toNumber.js +1 -1
  305. package/lib/utils/tokenize.d.ts +1 -0
  306. package/lib/utils/tokenize.js +33 -1
  307. package/lib/utils/tpl-builtin.d.ts +2 -1
  308. package/lib/utils/tpl-builtin.js +17 -2
  309. package/lib/utils/tpl-lodash.js +3 -2
  310. package/lib/utils/tpl.d.ts +9 -0
  311. package/lib/utils/tpl.js +45 -1
  312. package/lib/utils/uncontrollable.js +1 -1
  313. package/lib/utils/validations.d.ts +4 -1
  314. package/lib/utils/validations.js +27 -12
  315. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.8.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -34,7 +34,7 @@ function createRendererEvent(type, context) {
34
34
  // 绑定事件
35
35
  var bindEvent = function (renderer) {
36
36
  var e_1, _a;
37
- var _b, _c;
37
+ var _b, _c, _d;
38
38
  if (!renderer) {
39
39
  return undefined;
40
40
  }
@@ -49,15 +49,16 @@ var bindEvent = function (renderer) {
49
49
  rendererEventListeners = rendererEventListeners.filter(function (item) {
50
50
  return !(item.renderer === listener.renderer && item.type === listener.type);
51
51
  });
52
- rendererEventListeners.push({
53
- renderer: renderer,
54
- type: key,
55
- debounce: listener.debounce || null,
56
- weight: listener.weight || 0,
57
- actions: listener.actions
58
- });
52
+ listener.actions.length &&
53
+ rendererEventListeners.push({
54
+ renderer: renderer,
55
+ type: key,
56
+ debounce: listener.debounce || null,
57
+ weight: listener.weight || 0,
58
+ actions: listener.actions
59
+ });
59
60
  }
60
- if (!listener) {
61
+ if (!listener && ((_d = listeners[key].actions) === null || _d === void 0 ? void 0 : _d.length)) {
61
62
  rendererEventListeners.push({
62
63
  renderer: renderer,
63
64
  type: key,
@@ -69,15 +70,15 @@ var bindEvent = function (renderer) {
69
70
  };
70
71
  try {
71
72
  // 暂存
72
- for (var _d = __values(Object.keys(listeners)), _e = _d.next(); !_e.done; _e = _d.next()) {
73
- var key = _e.value;
73
+ for (var _e = __values(Object.keys(listeners)), _f = _e.next(); !_f.done; _f = _e.next()) {
74
+ var key = _f.value;
74
75
  _loop_1(key);
75
76
  }
76
77
  }
77
78
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
78
79
  finally {
79
80
  try {
80
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
81
+ if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
81
82
  }
82
83
  finally { if (e_1) throw e_1.error; }
83
84
  }
@@ -89,19 +90,20 @@ var bindEvent = function (renderer) {
89
90
  };
90
91
  // 触发事件
91
92
  function dispatchEvent(e, renderer, scoped, data, broadcast) {
92
- var _a, _b, _c, _d, _e, _f;
93
+ var _a, _b, _c, _d, _e, _f, _g, _h;
93
94
  return __awaiter(this, void 0, void 0, function () {
94
95
  var unbindEvent, eventName, eventConfig, rendererEvent, listeners, executedCount, checkExecuted, _loop_2, listeners_1, listeners_1_1, listener, state_1, e_2_1;
95
- var e_2, _g;
96
+ var e_2, _j;
96
97
  var _this = this;
97
- return __generator(this, function (_h) {
98
- switch (_h.label) {
98
+ return __generator(this, function (_k) {
99
+ switch (_k.label) {
99
100
  case 0:
100
101
  unbindEvent = null;
101
102
  eventName = typeof e === 'string' ? e : e.type;
102
103
  (_c = (_b = (_a = renderer === null || renderer === void 0 ? void 0 : renderer.props) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.beforeDispatchEvent) === null || _c === void 0 ? void 0 : _c.call(_b, e, renderer, scoped, data, broadcast);
104
+ broadcast && ((_e = (_d = renderer.props).onBroadcast) === null || _e === void 0 ? void 0 : _e.call(_d, e, broadcast, data));
103
105
  if (!broadcast) {
104
- eventConfig = (_e = (_d = renderer === null || renderer === void 0 ? void 0 : renderer.props) === null || _d === void 0 ? void 0 : _d.onEvent) === null || _e === void 0 ? void 0 : _e[eventName];
106
+ eventConfig = (_g = (_f = renderer === null || renderer === void 0 ? void 0 : renderer.props) === null || _f === void 0 ? void 0 : _f.onEvent) === null || _g === void 0 ? void 0 : _g[eventName];
105
107
  if (!eventConfig) {
106
108
  // 没命中也没关系
107
109
  return [2 /*return*/, Promise.resolve()];
@@ -114,7 +116,7 @@ function dispatchEvent(e, renderer, scoped, data, broadcast) {
114
116
  }
115
117
  rendererEvent = broadcast ||
116
118
  createRendererEvent(eventName, {
117
- env: (_f = renderer === null || renderer === void 0 ? void 0 : renderer.props) === null || _f === void 0 ? void 0 : _f.env,
119
+ env: (_h = renderer === null || renderer === void 0 ? void 0 : renderer.props) === null || _h === void 0 ? void 0 : _h.env,
118
120
  nativeEvent: e,
119
121
  data: data,
120
122
  scoped: scoped
@@ -135,11 +137,11 @@ function dispatchEvent(e, renderer, scoped, data, broadcast) {
135
137
  }
136
138
  };
137
139
  _loop_2 = function (listener) {
138
- var _j, _k, wait, _l, trailing, _m, leading, _o, maxWait, debounced_1;
139
- return __generator(this, function (_p) {
140
- switch (_p.label) {
140
+ var _l, _m, wait, _o, trailing, _p, leading, _q, maxWait, debounced_1;
141
+ return __generator(this, function (_r) {
142
+ switch (_r.label) {
141
143
  case 0:
142
- _j = (listener === null || listener === void 0 ? void 0 : listener.debounce) || {}, _k = _j.wait, wait = _k === void 0 ? 100 : _k, _l = _j.trailing, trailing = _l === void 0 ? true : _l, _m = _j.leading, leading = _m === void 0 ? false : _m, _o = _j.maxWait, maxWait = _o === void 0 ? 10000 : _o;
144
+ _l = (listener === null || listener === void 0 ? void 0 : listener.debounce) || {}, _m = _l.wait, wait = _m === void 0 ? 100 : _m, _o = _l.trailing, trailing = _o === void 0 ? true : _o, _p = _l.leading, leading = _p === void 0 ? false : _p, _q = _l.maxWait, maxWait = _q === void 0 ? 10000 : _q;
143
145
  if (!(listener === null || listener === void 0 ? void 0 : listener.debounce)) return [3 /*break*/, 1];
144
146
  debounced_1 = debounce(function () { return __awaiter(_this, void 0, void 0, function () {
145
147
  return __generator(this, function (_a) {
@@ -168,9 +170,9 @@ function dispatchEvent(e, renderer, scoped, data, broadcast) {
168
170
  return [3 /*break*/, 3];
169
171
  case 1: return [4 /*yield*/, runActions(listener.actions, listener.renderer, rendererEvent)];
170
172
  case 2:
171
- _p.sent();
173
+ _r.sent();
172
174
  checkExecuted();
173
- _p.label = 3;
175
+ _r.label = 3;
174
176
  case 3:
175
177
  // 停止后续监听器执行
176
178
  if (rendererEvent.stoped) {
@@ -180,31 +182,31 @@ function dispatchEvent(e, renderer, scoped, data, broadcast) {
180
182
  }
181
183
  });
182
184
  };
183
- _h.label = 1;
185
+ _k.label = 1;
184
186
  case 1:
185
- _h.trys.push([1, 6, 7, 8]);
187
+ _k.trys.push([1, 6, 7, 8]);
186
188
  listeners_1 = __values(listeners), listeners_1_1 = listeners_1.next();
187
- _h.label = 2;
189
+ _k.label = 2;
188
190
  case 2:
189
191
  if (!!listeners_1_1.done) return [3 /*break*/, 5];
190
192
  listener = listeners_1_1.value;
191
193
  return [5 /*yield**/, _loop_2(listener)];
192
194
  case 3:
193
- state_1 = _h.sent();
195
+ state_1 = _k.sent();
194
196
  if (state_1 === "break")
195
197
  return [3 /*break*/, 5];
196
- _h.label = 4;
198
+ _k.label = 4;
197
199
  case 4:
198
200
  listeners_1_1 = listeners_1.next();
199
201
  return [3 /*break*/, 2];
200
202
  case 5: return [3 /*break*/, 8];
201
203
  case 6:
202
- e_2_1 = _h.sent();
204
+ e_2_1 = _k.sent();
203
205
  e_2 = { error: e_2_1 };
204
206
  return [3 /*break*/, 8];
205
207
  case 7:
206
208
  try {
207
- if (listeners_1_1 && !listeners_1_1.done && (_g = listeners_1.return)) _g.call(listeners_1);
209
+ if (listeners_1_1 && !listeners_1_1.done && (_j = listeners_1.return)) _j.call(listeners_1);
208
210
  }
209
211
  finally { if (e_2) throw e_2.error; }
210
212
  return [7 /*endfinally*/];
@@ -224,6 +226,7 @@ var getRendererEventListeners = function () {
224
226
  */
225
227
  var resolveEventData = function (props, data, valueKey) {
226
228
  var _a, _b;
229
+ if (valueKey === void 0) { valueKey = 'value'; }
227
230
  return createObject(props.data, props.name && valueKey
228
231
  ? __assign(__assign({}, data), (_a = {}, _a[props.name] = data[valueKey], _a.__rendererData = __assign(__assign({}, props.data), (_b = {}, _b[props.name] = data[valueKey], _b)), _a)) : data);
229
232
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.8.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.8.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -0,0 +1,6 @@
1
+ export declare function resolveCondition(conditions: any, data: any, defaultResult?: boolean): Promise<boolean>;
2
+ export declare function registerConditionComputer(op: string, func: (left: any, right: any, fieldType?: string) => boolean, fieldType?: string): void;
3
+ export declare function getConditionComputers(): {
4
+ [op: string]: (left: any, right: any, fieldType?: string | undefined) => boolean;
5
+ };
6
+ export declare function setConditionComputeErrorHandler(fn: (conditions: any, data: any, defaultResult: boolean) => boolean | Promise<boolean>): void;
@@ -0,0 +1,321 @@
1
+ /**
2
+ * amis-core v3.0.0
3
+ * Copyright 2018-2023 fex
4
+ */
5
+
6
+ import { __awaiter, __generator, __read } from 'tslib';
7
+ import get from 'lodash/get';
8
+ import endsWith from 'lodash/endsWith';
9
+ import isEmpty from 'lodash/isEmpty';
10
+ import isEqual from 'lodash/isEqual';
11
+ import startsWith from 'lodash/startsWith';
12
+ import { resolveVariableAndFilterForAsync } from './resolveVariableAndFilterForAsync.js';
13
+ import moment from 'moment';
14
+ import capitalize from 'lodash/capitalize';
15
+
16
+ var conditionResolverMap = {};
17
+ var DEFAULT_RESULT = true;
18
+ var conditionComputeErrorHandler;
19
+ function resolveCondition(conditions, data, defaultResult) {
20
+ if (defaultResult === void 0) { defaultResult = true; }
21
+ return __awaiter(this, void 0, void 0, function () {
22
+ var e_1;
23
+ return __generator(this, function (_a) {
24
+ switch (_a.label) {
25
+ case 0:
26
+ if (!conditions ||
27
+ !conditions.conjunction ||
28
+ !Array.isArray(conditions.children) ||
29
+ !conditions.children.length) {
30
+ return [2 /*return*/, defaultResult];
31
+ }
32
+ _a.label = 1;
33
+ case 1:
34
+ _a.trys.push([1, 3, , 6]);
35
+ return [4 /*yield*/, computeConditions(conditions.children, conditions.conjunction, data)];
36
+ case 2: return [2 /*return*/, _a.sent()];
37
+ case 3:
38
+ e_1 = _a.sent();
39
+ if (!(e_1.name === 'FormulaEvalError')) return [3 /*break*/, 5];
40
+ return [4 /*yield*/, (conditionComputeErrorHandler === null || conditionComputeErrorHandler === void 0 ? void 0 : conditionComputeErrorHandler(conditions.children, conditions.conjunction, data))];
41
+ case 4: return [2 /*return*/, _a.sent()];
42
+ case 5: return [2 /*return*/, defaultResult];
43
+ case 6: return [2 /*return*/];
44
+ }
45
+ });
46
+ });
47
+ }
48
+ function computeConditions(conditions, conjunction, data) {
49
+ if (conjunction === void 0) { conjunction = 'and'; }
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ var computeResult, index, len, item, result, _a;
52
+ return __generator(this, function (_b) {
53
+ switch (_b.label) {
54
+ case 0:
55
+ computeResult = true;
56
+ index = 0, len = conditions.length;
57
+ _b.label = 1;
58
+ case 1:
59
+ if (!(index < len)) return [3 /*break*/, 7];
60
+ item = conditions[index];
61
+ if (!(item.conjunction && Array.isArray(item.children) && item.children.length)) return [3 /*break*/, 3];
62
+ return [4 /*yield*/, computeConditions(item.children, item.conjunction, data)];
63
+ case 2:
64
+ _a = _b.sent();
65
+ return [3 /*break*/, 5];
66
+ case 3: return [4 /*yield*/, computeCondition(item, index, data)];
67
+ case 4:
68
+ _a = _b.sent();
69
+ _b.label = 5;
70
+ case 5:
71
+ result = _a;
72
+ computeResult = !!result;
73
+ if ((result && conjunction === 'or') ||
74
+ (!result && conjunction === 'and')) {
75
+ return [3 /*break*/, 7];
76
+ }
77
+ _b.label = 6;
78
+ case 6:
79
+ index++;
80
+ return [3 /*break*/, 1];
81
+ case 7: return [2 /*return*/, computeResult];
82
+ }
83
+ });
84
+ });
85
+ }
86
+ function computeCondition(rule, index, data) {
87
+ var _a;
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ var leftValue, rightValue, func;
90
+ return __generator(this, function (_b) {
91
+ switch (_b.label) {
92
+ case 0:
93
+ leftValue = get(data, rule.left.field);
94
+ return [4 /*yield*/, resolveVariableAndFilterForAsync(rule.right, data, undefined, undefined, true)];
95
+ case 1:
96
+ rightValue = _b.sent();
97
+ func = (_a = conditionResolverMap["".concat(rule.op, "For").concat(capitalize(rule.left.type))]) !== null && _a !== void 0 ? _a : conditionResolverMap[rule.op];
98
+ return [2 /*return*/, func ? func(leftValue, rightValue, rule.left.type) : DEFAULT_RESULT];
99
+ }
100
+ });
101
+ });
102
+ }
103
+ function startsWithFunc(left, right) {
104
+ if (left === undefined || right === undefined) {
105
+ return DEFAULT_RESULT;
106
+ }
107
+ return startsWith(left, right);
108
+ }
109
+ function endsWithFunc(left, right) {
110
+ if (left === undefined || right === undefined) {
111
+ return DEFAULT_RESULT;
112
+ }
113
+ return endsWith(left, right);
114
+ }
115
+ function equalFunc(left, right) {
116
+ return isEqual(left, right);
117
+ }
118
+ function notEqualFunc(left, right) {
119
+ return !isEqual(left, right);
120
+ }
121
+ function isEmptyFunc(left) {
122
+ if (typeof left === 'string') {
123
+ return !left;
124
+ }
125
+ else if (typeof left === 'number') {
126
+ return left === undefined;
127
+ }
128
+ else if (Array.isArray(left)) {
129
+ return !left.length;
130
+ }
131
+ else if (typeof left === 'object') {
132
+ return isEmpty(left);
133
+ }
134
+ return DEFAULT_RESULT;
135
+ }
136
+ function isNotEmptyFunc(left) {
137
+ if (typeof left === 'string') {
138
+ return !left;
139
+ }
140
+ else if (typeof left === 'number') {
141
+ return left !== undefined;
142
+ }
143
+ else if (Array.isArray(left)) {
144
+ return !!left.length;
145
+ }
146
+ else if (typeof left === 'object') {
147
+ return !isEmpty(left);
148
+ }
149
+ return DEFAULT_RESULT;
150
+ }
151
+ function greaterFunc(left, right) {
152
+ if (left === undefined || right === undefined) {
153
+ return DEFAULT_RESULT;
154
+ }
155
+ return parseFloat(left) > parseFloat(right);
156
+ }
157
+ function normalizeDate(raw) {
158
+ if (typeof raw === 'string' || typeof raw === 'number') {
159
+ var formats = ['', 'YYYY-MM-DD HH:mm:ss', 'X'];
160
+ if (/^\d{10}((\.\d+)*)$/.test(raw.toString())) {
161
+ formats = ['X', 'x', 'YYYY-MM-DD HH:mm:ss', ''];
162
+ }
163
+ else if (/^\d{13}((\.\d+)*)$/.test(raw.toString())) {
164
+ formats = ['x', 'X', 'YYYY-MM-DD HH:mm:ss', ''];
165
+ }
166
+ while (formats.length) {
167
+ var format = formats.shift();
168
+ var date = moment(raw, format);
169
+ if (date.isValid()) {
170
+ return date.toDate();
171
+ }
172
+ }
173
+ }
174
+ return raw;
175
+ }
176
+ function normalizeDateRange(raw) {
177
+ return (Array.isArray(raw) ? raw : raw.split(',')).map(function (item) {
178
+ return normalizeDate(String(item).trim());
179
+ });
180
+ }
181
+ function greaterForDateFunc(left, right) {
182
+ left = normalizeDate(left);
183
+ right = normalizeDate(right);
184
+ return moment(left).isAfter(moment(right), 's');
185
+ }
186
+ function greaterOrEqualForDateFunc(left, right) {
187
+ left = normalizeDate(left);
188
+ right = normalizeDate(right);
189
+ return moment(left).isSameOrAfter(moment(right), 's');
190
+ }
191
+ function greaterOrEqualFunc(left, right) {
192
+ if (left === undefined || right === undefined) {
193
+ return DEFAULT_RESULT;
194
+ }
195
+ return parseFloat(left) >= parseFloat(right);
196
+ }
197
+ function lessFunc(left, right) {
198
+ if (left === undefined || right === undefined) {
199
+ return DEFAULT_RESULT;
200
+ }
201
+ return parseFloat(left) < parseFloat(right);
202
+ }
203
+ function lessForDateFunc(left, right) {
204
+ left = normalizeDate(left);
205
+ right = normalizeDate(right);
206
+ return moment(left).isBefore(moment(right), 's');
207
+ }
208
+ function lessOrEqualForDateFunc(left, right) {
209
+ left = normalizeDate(left);
210
+ right = normalizeDate(right);
211
+ return moment(left).isSameOrBefore(moment(right), 's');
212
+ }
213
+ function lessOrEqualFunc(left, right) {
214
+ if (left === undefined || right === undefined) {
215
+ return DEFAULT_RESULT;
216
+ }
217
+ return parseFloat(left) <= parseFloat(right);
218
+ }
219
+ function likeFunc(left, right) {
220
+ if (left === undefined || right === undefined) {
221
+ return DEFAULT_RESULT;
222
+ }
223
+ return !!~left.indexOf(right);
224
+ }
225
+ function notLikeFunc(left, right) {
226
+ if (left === undefined || right === undefined) {
227
+ return DEFAULT_RESULT;
228
+ }
229
+ return !~left.indexOf(right);
230
+ }
231
+ function betweenFunc(left, right) {
232
+ if (typeof left === 'number' && right !== undefined) {
233
+ var _a = __read(right.sort(), 2), min = _a[0], max = _a[1];
234
+ return left >= parseFloat(min) && left <= parseFloat(max);
235
+ }
236
+ return DEFAULT_RESULT;
237
+ }
238
+ function betweenForDateFunc(left, right) {
239
+ if (right !== undefined) {
240
+ var _a = __read(normalizeDateRange(right), 2), min = _a[0], max = _a[1];
241
+ return moment(normalizeDate(left)).isBetween(min, max, 's', '[]');
242
+ }
243
+ return DEFAULT_RESULT;
244
+ }
245
+ function notBetweenFunc(left, right) {
246
+ if (typeof left === 'number' && right !== undefined) {
247
+ var _a = __read(right.sort(), 2), min = _a[0], max = _a[1];
248
+ return left < parseFloat(min) && left > parseFloat(max);
249
+ }
250
+ return DEFAULT_RESULT;
251
+ }
252
+ function notBetweenForDateFunc(left, right) {
253
+ if (right !== undefined) {
254
+ var _a = __read(normalizeDateRange(right), 2), min = _a[0], max = _a[1];
255
+ return !moment(normalizeDate(left)).isBetween(min, max, 's', '[]');
256
+ }
257
+ return DEFAULT_RESULT;
258
+ }
259
+ function selectAnyInFunc(left, right) {
260
+ if (!Array.isArray(right)) {
261
+ return DEFAULT_RESULT;
262
+ }
263
+ if (Array.isArray(left)) {
264
+ return right.every(function (item) { return left.includes(item); });
265
+ }
266
+ return right.includes(left);
267
+ }
268
+ function selectNotAnyInFunc(left, right) {
269
+ if (!Array.isArray(right)) {
270
+ return DEFAULT_RESULT;
271
+ }
272
+ if (Array.isArray(left)) {
273
+ return !right.every(function (item) { return left.includes(item); });
274
+ }
275
+ return !right.includes(left);
276
+ }
277
+ function registerConditionComputer(op, func, fieldType) {
278
+ conditionResolverMap["".concat(op).concat(fieldType ? 'For' + capitalize(fieldType) : '')] = func;
279
+ }
280
+ function getConditionComputers() {
281
+ return conditionResolverMap;
282
+ }
283
+ function setConditionComputeErrorHandler(fn) {
284
+ conditionComputeErrorHandler = fn;
285
+ }
286
+ registerConditionComputer('greater', greaterFunc);
287
+ registerConditionComputer('greater', greaterForDateFunc, 'date');
288
+ registerConditionComputer('greater', greaterForDateFunc, 'time');
289
+ registerConditionComputer('greater', greaterForDateFunc, 'datetime');
290
+ registerConditionComputer('greater_or_equal', greaterOrEqualFunc);
291
+ registerConditionComputer('greater_or_equal', greaterOrEqualForDateFunc, 'date');
292
+ registerConditionComputer('greater_or_equal', greaterOrEqualForDateFunc, 'time');
293
+ registerConditionComputer('greater_or_equal', greaterOrEqualForDateFunc, 'datetime');
294
+ registerConditionComputer('less', lessFunc);
295
+ registerConditionComputer('less', lessForDateFunc, 'date');
296
+ registerConditionComputer('less', lessForDateFunc, 'time');
297
+ registerConditionComputer('less', lessForDateFunc, 'datetime');
298
+ registerConditionComputer('less_or_equal', lessOrEqualFunc);
299
+ registerConditionComputer('less_or_equal', lessOrEqualForDateFunc, 'date');
300
+ registerConditionComputer('less_or_equal', lessOrEqualForDateFunc, 'time');
301
+ registerConditionComputer('less_or_equal', lessOrEqualForDateFunc, 'datetime');
302
+ registerConditionComputer('is_empty', isEmptyFunc);
303
+ registerConditionComputer('is_not_empty', isNotEmptyFunc);
304
+ registerConditionComputer('between', betweenFunc);
305
+ registerConditionComputer('between', betweenForDateFunc, 'date');
306
+ registerConditionComputer('between', betweenForDateFunc, 'time');
307
+ registerConditionComputer('between', betweenForDateFunc, 'datetime');
308
+ registerConditionComputer('not_between', notBetweenFunc);
309
+ registerConditionComputer('not_between', notBetweenForDateFunc, 'date');
310
+ registerConditionComputer('not_between', notBetweenForDateFunc, 'time');
311
+ registerConditionComputer('not_between', notBetweenForDateFunc, 'datetime');
312
+ registerConditionComputer('equal', equalFunc);
313
+ registerConditionComputer('not_equal', notEqualFunc);
314
+ registerConditionComputer('like', likeFunc);
315
+ registerConditionComputer('not_like', notLikeFunc);
316
+ registerConditionComputer('select_any_in', selectAnyInFunc);
317
+ registerConditionComputer('select_not_any_in', selectNotAnyInFunc);
318
+ registerConditionComputer('starts_with', startsWithFunc);
319
+ registerConditionComputer('ends_with', endsWithFunc);
320
+
321
+ export { getConditionComputers, registerConditionComputer, resolveCondition, setConditionComputeErrorHandler };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.8.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.8.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 设置自定义函数,functions中找不到处理的函数时执行
3
+ * @param fn
4
+ */
5
+ export declare function setFormulaEvalErrorHandler(fn: (path: string, data?: object, ...args: any[]) => any): void;
6
+ export declare const resolveVariableAndFilterForAsync: (path?: string, data?: object, defaultFilter?: string, fallbackValue?: (value: any) => any, skipFormulaEvalErrorHandler?: boolean) => Promise<any>;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * amis-core v3.0.0
3
+ * Copyright 2018-2023 fex
4
+ */
5
+
6
+ import { __awaiter, __generator } from 'tslib';
7
+ import { parse, AsyncEvaluator } from 'amis-formula';
8
+
9
+ var formulaEvalErrorHandler;
10
+ /**
11
+ * 设置自定义函数,functions中找不到处理的函数时执行
12
+ * @param fn
13
+ */
14
+ function setFormulaEvalErrorHandler(fn) {
15
+ formulaEvalErrorHandler = fn;
16
+ }
17
+ var resolveVariableAndFilterForAsync = function (path, data, defaultFilter, fallbackValue, skipFormulaEvalErrorHandler) {
18
+ if (data === void 0) { data = {}; }
19
+ if (defaultFilter === void 0) { defaultFilter = '| html'; }
20
+ if (fallbackValue === void 0) { fallbackValue = function (value) { return value; }; }
21
+ if (skipFormulaEvalErrorHandler === void 0) { skipFormulaEvalErrorHandler = false; }
22
+ return __awaiter(void 0, void 0, void 0, function () {
23
+ var ast, ret, e_1;
24
+ return __generator(this, function (_a) {
25
+ switch (_a.label) {
26
+ case 0:
27
+ if (!path || typeof path !== 'string') {
28
+ return [2 /*return*/, undefined];
29
+ }
30
+ _a.label = 1;
31
+ case 1:
32
+ _a.trys.push([1, 3, , 4]);
33
+ ast = parse(path, {
34
+ evalMode: false,
35
+ allowFilter: true
36
+ });
37
+ return [4 /*yield*/, new AsyncEvaluator(data, {
38
+ defaultFilter: defaultFilter
39
+ }).evalute(ast)];
40
+ case 2:
41
+ ret = _a.sent();
42
+ return [2 /*return*/, ret == null && !~path.indexOf('default') && !~path.indexOf('now')
43
+ ? fallbackValue(ret)
44
+ : ret];
45
+ case 3:
46
+ e_1 = _a.sent();
47
+ console.warn(e_1);
48
+ if (e_1.name === 'FormulaEvalError') {
49
+ if (!skipFormulaEvalErrorHandler) {
50
+ // 无法解析时,执行handler自定义解析逻辑
51
+ return [2 /*return*/, formulaEvalErrorHandler === null || formulaEvalErrorHandler === void 0 ? void 0 : formulaEvalErrorHandler(path, data, defaultFilter, fallbackValue)];
52
+ }
53
+ // 跳过自定义解析逻辑,则直接抛异常
54
+ throw e_1;
55
+ }
56
+ return [2 /*return*/, undefined];
57
+ case 4: return [2 /*return*/];
58
+ }
59
+ });
60
+ });
61
+ };
62
+
63
+ export { resolveVariableAndFilterForAsync, setFormulaEvalErrorHandler };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.8.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.8.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.8.0
2
+ * amis-core v3.0.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,6 @@
1
1
  import { PlainObject } from '../types';
2
2
  export declare const valueMap: PlainObject;
3
+ export declare const inheritValueMap: PlainObject;
3
4
  interface extra {
4
5
  pre?: string;
5
6
  suf?: string;
@@ -7,7 +8,7 @@ interface extra {
7
8
  export declare function findOrCreactStyle(id: string): HTMLElement;
8
9
  export declare function insertStyle(style: string, id: string): void;
9
10
  export declare function addStyle(style: string, id: string): void;
10
- export declare function formatStyle(css: any, classNames: {
11
+ export declare function formatStyle(themeCss: any, classNames: {
11
12
  key: string;
12
13
  value?: string;
13
14
  weights?: {
@@ -16,14 +17,14 @@ export declare function formatStyle(css: any, classNames: {
16
17
  active?: extra;
17
18
  disabled?: extra;
18
19
  };
19
- }[], id?: string): {
20
+ }[], id?: string, defaultData?: any): {
20
21
  value: string;
21
22
  origin: {
22
23
  className: string;
23
24
  content: string;
24
25
  }[];
25
26
  };
26
- export declare function insertCustomStyle(css: any, classNames: {
27
+ export declare function insertCustomStyle(themeCss: any, classNames: {
27
28
  key: string;
28
29
  value?: string;
29
30
  weights?: {
@@ -32,5 +33,9 @@ export declare function insertCustomStyle(css: any, classNames: {
32
33
  active?: extra;
33
34
  disabled?: extra;
34
35
  };
35
- }[], id?: string): void;
36
+ }[], id?: string, defaultData?: any): void;
37
+ /**
38
+ * 根据路径获取默认值
39
+ */
40
+ export declare function getValueByPath(path: string, data: any): any;
36
41
  export {};