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
 
@@ -42,7 +42,7 @@ function createRendererEvent(type, context) {
42
42
  // 绑定事件
43
43
  var bindEvent = function (renderer) {
44
44
  var e_1, _a;
45
- var _b, _c;
45
+ var _b, _c, _d;
46
46
  if (!renderer) {
47
47
  return undefined;
48
48
  }
@@ -57,15 +57,16 @@ var bindEvent = function (renderer) {
57
57
  rendererEventListeners = rendererEventListeners.filter(function (item) {
58
58
  return !(item.renderer === listener.renderer && item.type === listener.type);
59
59
  });
60
- rendererEventListeners.push({
61
- renderer: renderer,
62
- type: key,
63
- debounce: listener.debounce || null,
64
- weight: listener.weight || 0,
65
- actions: listener.actions
66
- });
60
+ listener.actions.length &&
61
+ rendererEventListeners.push({
62
+ renderer: renderer,
63
+ type: key,
64
+ debounce: listener.debounce || null,
65
+ weight: listener.weight || 0,
66
+ actions: listener.actions
67
+ });
67
68
  }
68
- if (!listener) {
69
+ if (!listener && ((_d = listeners[key].actions) === null || _d === void 0 ? void 0 : _d.length)) {
69
70
  rendererEventListeners.push({
70
71
  renderer: renderer,
71
72
  type: key,
@@ -77,15 +78,15 @@ var bindEvent = function (renderer) {
77
78
  };
78
79
  try {
79
80
  // 暂存
80
- for (var _d = tslib.__values(Object.keys(listeners)), _e = _d.next(); !_e.done; _e = _d.next()) {
81
- var key = _e.value;
81
+ for (var _e = tslib.__values(Object.keys(listeners)), _f = _e.next(); !_f.done; _f = _e.next()) {
82
+ var key = _f.value;
82
83
  _loop_1(key);
83
84
  }
84
85
  }
85
86
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
86
87
  finally {
87
88
  try {
88
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
89
+ if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
89
90
  }
90
91
  finally { if (e_1) throw e_1.error; }
91
92
  }
@@ -97,19 +98,20 @@ var bindEvent = function (renderer) {
97
98
  };
98
99
  // 触发事件
99
100
  function dispatchEvent(e, renderer, scoped, data, broadcast) {
100
- var _a, _b, _c, _d, _e, _f;
101
+ var _a, _b, _c, _d, _e, _f, _g, _h;
101
102
  return tslib.__awaiter(this, void 0, void 0, function () {
102
103
  var unbindEvent, eventName, eventConfig, rendererEvent, listeners, executedCount, checkExecuted, _loop_2, listeners_1, listeners_1_1, listener, state_1, e_2_1;
103
- var e_2, _g;
104
+ var e_2, _j;
104
105
  var _this = this;
105
- return tslib.__generator(this, function (_h) {
106
- switch (_h.label) {
106
+ return tslib.__generator(this, function (_k) {
107
+ switch (_k.label) {
107
108
  case 0:
108
109
  unbindEvent = null;
109
110
  eventName = typeof e === 'string' ? e : e.type;
110
111
  (_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);
112
+ broadcast && ((_e = (_d = renderer.props).onBroadcast) === null || _e === void 0 ? void 0 : _e.call(_d, e, broadcast, data));
111
113
  if (!broadcast) {
112
- 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];
114
+ 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];
113
115
  if (!eventConfig) {
114
116
  // 没命中也没关系
115
117
  return [2 /*return*/, Promise.resolve()];
@@ -122,7 +124,7 @@ function dispatchEvent(e, renderer, scoped, data, broadcast) {
122
124
  }
123
125
  rendererEvent = broadcast ||
124
126
  createRendererEvent(eventName, {
125
- env: (_f = renderer === null || renderer === void 0 ? void 0 : renderer.props) === null || _f === void 0 ? void 0 : _f.env,
127
+ env: (_h = renderer === null || renderer === void 0 ? void 0 : renderer.props) === null || _h === void 0 ? void 0 : _h.env,
126
128
  nativeEvent: e,
127
129
  data: data,
128
130
  scoped: scoped
@@ -143,11 +145,11 @@ function dispatchEvent(e, renderer, scoped, data, broadcast) {
143
145
  }
144
146
  };
145
147
  _loop_2 = function (listener) {
146
- var _j, _k, wait, _l, trailing, _m, leading, _o, maxWait, debounced_1;
147
- return tslib.__generator(this, function (_p) {
148
- switch (_p.label) {
148
+ var _l, _m, wait, _o, trailing, _p, leading, _q, maxWait, debounced_1;
149
+ return tslib.__generator(this, function (_r) {
150
+ switch (_r.label) {
149
151
  case 0:
150
- _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;
152
+ _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;
151
153
  if (!(listener === null || listener === void 0 ? void 0 : listener.debounce)) return [3 /*break*/, 1];
152
154
  debounced_1 = debounce__default["default"](function () { return tslib.__awaiter(_this, void 0, void 0, function () {
153
155
  return tslib.__generator(this, function (_a) {
@@ -176,9 +178,9 @@ function dispatchEvent(e, renderer, scoped, data, broadcast) {
176
178
  return [3 /*break*/, 3];
177
179
  case 1: return [4 /*yield*/, Action.runActions(listener.actions, listener.renderer, rendererEvent)];
178
180
  case 2:
179
- _p.sent();
181
+ _r.sent();
180
182
  checkExecuted();
181
- _p.label = 3;
183
+ _r.label = 3;
182
184
  case 3:
183
185
  // 停止后续监听器执行
184
186
  if (rendererEvent.stoped) {
@@ -188,31 +190,31 @@ function dispatchEvent(e, renderer, scoped, data, broadcast) {
188
190
  }
189
191
  });
190
192
  };
191
- _h.label = 1;
193
+ _k.label = 1;
192
194
  case 1:
193
- _h.trys.push([1, 6, 7, 8]);
195
+ _k.trys.push([1, 6, 7, 8]);
194
196
  listeners_1 = tslib.__values(listeners), listeners_1_1 = listeners_1.next();
195
- _h.label = 2;
197
+ _k.label = 2;
196
198
  case 2:
197
199
  if (!!listeners_1_1.done) return [3 /*break*/, 5];
198
200
  listener = listeners_1_1.value;
199
201
  return [5 /*yield**/, _loop_2(listener)];
200
202
  case 3:
201
- state_1 = _h.sent();
203
+ state_1 = _k.sent();
202
204
  if (state_1 === "break")
203
205
  return [3 /*break*/, 5];
204
- _h.label = 4;
206
+ _k.label = 4;
205
207
  case 4:
206
208
  listeners_1_1 = listeners_1.next();
207
209
  return [3 /*break*/, 2];
208
210
  case 5: return [3 /*break*/, 8];
209
211
  case 6:
210
- e_2_1 = _h.sent();
212
+ e_2_1 = _k.sent();
211
213
  e_2 = { error: e_2_1 };
212
214
  return [3 /*break*/, 8];
213
215
  case 7:
214
216
  try {
215
- if (listeners_1_1 && !listeners_1_1.done && (_g = listeners_1.return)) _g.call(listeners_1);
217
+ if (listeners_1_1 && !listeners_1_1.done && (_j = listeners_1.return)) _j.call(listeners_1);
216
218
  }
217
219
  finally { if (e_2) throw e_2.error; }
218
220
  return [7 /*endfinally*/];
@@ -232,6 +234,7 @@ var getRendererEventListeners = function () {
232
234
  */
233
235
  var resolveEventData = function (props, data, valueKey) {
234
236
  var _a, _b;
237
+ if (valueKey === void 0) { valueKey = 'value'; }
235
238
  return object.createObject(props.data, props.name && valueKey
236
239
  ? tslib.__assign(tslib.__assign({}, data), (_a = {}, _a[props.name] = data[valueKey], _a.__rendererData = tslib.__assign(tslib.__assign({}, props.data), (_b = {}, _b[props.name] = data[valueKey], _b)), _a)) : data);
237
240
  };
@@ -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,338 @@
1
+ /**
2
+ * amis-core v3.0.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 get = require('lodash/get');
12
+ var endsWith = require('lodash/endsWith');
13
+ var isEmpty = require('lodash/isEmpty');
14
+ var isEqual = require('lodash/isEqual');
15
+ var startsWith = require('lodash/startsWith');
16
+ var resolveVariableAndFilterForAsync = require('./resolveVariableAndFilterForAsync.js');
17
+ var moment = require('moment');
18
+ var capitalize = require('lodash/capitalize');
19
+
20
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
+
22
+ var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
23
+ var endsWith__default = /*#__PURE__*/_interopDefaultLegacy(endsWith);
24
+ var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
25
+ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
26
+ var startsWith__default = /*#__PURE__*/_interopDefaultLegacy(startsWith);
27
+ var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
28
+ var capitalize__default = /*#__PURE__*/_interopDefaultLegacy(capitalize);
29
+
30
+ var conditionResolverMap = {};
31
+ var DEFAULT_RESULT = true;
32
+ var conditionComputeErrorHandler;
33
+ function resolveCondition(conditions, data, defaultResult) {
34
+ if (defaultResult === void 0) { defaultResult = true; }
35
+ return tslib.__awaiter(this, void 0, void 0, function () {
36
+ var e_1;
37
+ return tslib.__generator(this, function (_a) {
38
+ switch (_a.label) {
39
+ case 0:
40
+ if (!conditions ||
41
+ !conditions.conjunction ||
42
+ !Array.isArray(conditions.children) ||
43
+ !conditions.children.length) {
44
+ return [2 /*return*/, defaultResult];
45
+ }
46
+ _a.label = 1;
47
+ case 1:
48
+ _a.trys.push([1, 3, , 6]);
49
+ return [4 /*yield*/, computeConditions(conditions.children, conditions.conjunction, data)];
50
+ case 2: return [2 /*return*/, _a.sent()];
51
+ case 3:
52
+ e_1 = _a.sent();
53
+ if (!(e_1.name === 'FormulaEvalError')) return [3 /*break*/, 5];
54
+ return [4 /*yield*/, (conditionComputeErrorHandler === null || conditionComputeErrorHandler === void 0 ? void 0 : conditionComputeErrorHandler(conditions.children, conditions.conjunction, data))];
55
+ case 4: return [2 /*return*/, _a.sent()];
56
+ case 5: return [2 /*return*/, defaultResult];
57
+ case 6: return [2 /*return*/];
58
+ }
59
+ });
60
+ });
61
+ }
62
+ function computeConditions(conditions, conjunction, data) {
63
+ if (conjunction === void 0) { conjunction = 'and'; }
64
+ return tslib.__awaiter(this, void 0, void 0, function () {
65
+ var computeResult, index, len, item, result, _a;
66
+ return tslib.__generator(this, function (_b) {
67
+ switch (_b.label) {
68
+ case 0:
69
+ computeResult = true;
70
+ index = 0, len = conditions.length;
71
+ _b.label = 1;
72
+ case 1:
73
+ if (!(index < len)) return [3 /*break*/, 7];
74
+ item = conditions[index];
75
+ if (!(item.conjunction && Array.isArray(item.children) && item.children.length)) return [3 /*break*/, 3];
76
+ return [4 /*yield*/, computeConditions(item.children, item.conjunction, data)];
77
+ case 2:
78
+ _a = _b.sent();
79
+ return [3 /*break*/, 5];
80
+ case 3: return [4 /*yield*/, computeCondition(item, index, data)];
81
+ case 4:
82
+ _a = _b.sent();
83
+ _b.label = 5;
84
+ case 5:
85
+ result = _a;
86
+ computeResult = !!result;
87
+ if ((result && conjunction === 'or') ||
88
+ (!result && conjunction === 'and')) {
89
+ return [3 /*break*/, 7];
90
+ }
91
+ _b.label = 6;
92
+ case 6:
93
+ index++;
94
+ return [3 /*break*/, 1];
95
+ case 7: return [2 /*return*/, computeResult];
96
+ }
97
+ });
98
+ });
99
+ }
100
+ function computeCondition(rule, index, data) {
101
+ var _a;
102
+ return tslib.__awaiter(this, void 0, void 0, function () {
103
+ var leftValue, rightValue, func;
104
+ return tslib.__generator(this, function (_b) {
105
+ switch (_b.label) {
106
+ case 0:
107
+ leftValue = get__default["default"](data, rule.left.field);
108
+ return [4 /*yield*/, resolveVariableAndFilterForAsync.resolveVariableAndFilterForAsync(rule.right, data, undefined, undefined, true)];
109
+ case 1:
110
+ rightValue = _b.sent();
111
+ func = (_a = conditionResolverMap["".concat(rule.op, "For").concat(capitalize__default["default"](rule.left.type))]) !== null && _a !== void 0 ? _a : conditionResolverMap[rule.op];
112
+ return [2 /*return*/, func ? func(leftValue, rightValue, rule.left.type) : DEFAULT_RESULT];
113
+ }
114
+ });
115
+ });
116
+ }
117
+ function startsWithFunc(left, right) {
118
+ if (left === undefined || right === undefined) {
119
+ return DEFAULT_RESULT;
120
+ }
121
+ return startsWith__default["default"](left, right);
122
+ }
123
+ function endsWithFunc(left, right) {
124
+ if (left === undefined || right === undefined) {
125
+ return DEFAULT_RESULT;
126
+ }
127
+ return endsWith__default["default"](left, right);
128
+ }
129
+ function equalFunc(left, right) {
130
+ return isEqual__default["default"](left, right);
131
+ }
132
+ function notEqualFunc(left, right) {
133
+ return !isEqual__default["default"](left, right);
134
+ }
135
+ function isEmptyFunc(left) {
136
+ if (typeof left === 'string') {
137
+ return !left;
138
+ }
139
+ else if (typeof left === 'number') {
140
+ return left === undefined;
141
+ }
142
+ else if (Array.isArray(left)) {
143
+ return !left.length;
144
+ }
145
+ else if (typeof left === 'object') {
146
+ return isEmpty__default["default"](left);
147
+ }
148
+ return DEFAULT_RESULT;
149
+ }
150
+ function isNotEmptyFunc(left) {
151
+ if (typeof left === 'string') {
152
+ return !left;
153
+ }
154
+ else if (typeof left === 'number') {
155
+ return left !== undefined;
156
+ }
157
+ else if (Array.isArray(left)) {
158
+ return !!left.length;
159
+ }
160
+ else if (typeof left === 'object') {
161
+ return !isEmpty__default["default"](left);
162
+ }
163
+ return DEFAULT_RESULT;
164
+ }
165
+ function greaterFunc(left, right) {
166
+ if (left === undefined || right === undefined) {
167
+ return DEFAULT_RESULT;
168
+ }
169
+ return parseFloat(left) > parseFloat(right);
170
+ }
171
+ function normalizeDate(raw) {
172
+ if (typeof raw === 'string' || typeof raw === 'number') {
173
+ var formats = ['', 'YYYY-MM-DD HH:mm:ss', 'X'];
174
+ if (/^\d{10}((\.\d+)*)$/.test(raw.toString())) {
175
+ formats = ['X', 'x', 'YYYY-MM-DD HH:mm:ss', ''];
176
+ }
177
+ else if (/^\d{13}((\.\d+)*)$/.test(raw.toString())) {
178
+ formats = ['x', 'X', 'YYYY-MM-DD HH:mm:ss', ''];
179
+ }
180
+ while (formats.length) {
181
+ var format = formats.shift();
182
+ var date = moment__default["default"](raw, format);
183
+ if (date.isValid()) {
184
+ return date.toDate();
185
+ }
186
+ }
187
+ }
188
+ return raw;
189
+ }
190
+ function normalizeDateRange(raw) {
191
+ return (Array.isArray(raw) ? raw : raw.split(',')).map(function (item) {
192
+ return normalizeDate(String(item).trim());
193
+ });
194
+ }
195
+ function greaterForDateFunc(left, right) {
196
+ left = normalizeDate(left);
197
+ right = normalizeDate(right);
198
+ return moment__default["default"](left).isAfter(moment__default["default"](right), 's');
199
+ }
200
+ function greaterOrEqualForDateFunc(left, right) {
201
+ left = normalizeDate(left);
202
+ right = normalizeDate(right);
203
+ return moment__default["default"](left).isSameOrAfter(moment__default["default"](right), 's');
204
+ }
205
+ function greaterOrEqualFunc(left, right) {
206
+ if (left === undefined || right === undefined) {
207
+ return DEFAULT_RESULT;
208
+ }
209
+ return parseFloat(left) >= parseFloat(right);
210
+ }
211
+ function lessFunc(left, right) {
212
+ if (left === undefined || right === undefined) {
213
+ return DEFAULT_RESULT;
214
+ }
215
+ return parseFloat(left) < parseFloat(right);
216
+ }
217
+ function lessForDateFunc(left, right) {
218
+ left = normalizeDate(left);
219
+ right = normalizeDate(right);
220
+ return moment__default["default"](left).isBefore(moment__default["default"](right), 's');
221
+ }
222
+ function lessOrEqualForDateFunc(left, right) {
223
+ left = normalizeDate(left);
224
+ right = normalizeDate(right);
225
+ return moment__default["default"](left).isSameOrBefore(moment__default["default"](right), 's');
226
+ }
227
+ function lessOrEqualFunc(left, right) {
228
+ if (left === undefined || right === undefined) {
229
+ return DEFAULT_RESULT;
230
+ }
231
+ return parseFloat(left) <= parseFloat(right);
232
+ }
233
+ function likeFunc(left, right) {
234
+ if (left === undefined || right === undefined) {
235
+ return DEFAULT_RESULT;
236
+ }
237
+ return !!~left.indexOf(right);
238
+ }
239
+ function notLikeFunc(left, right) {
240
+ if (left === undefined || right === undefined) {
241
+ return DEFAULT_RESULT;
242
+ }
243
+ return !~left.indexOf(right);
244
+ }
245
+ function betweenFunc(left, right) {
246
+ if (typeof left === 'number' && right !== undefined) {
247
+ var _a = tslib.__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 betweenForDateFunc(left, right) {
253
+ if (right !== undefined) {
254
+ var _a = tslib.__read(normalizeDateRange(right), 2), min = _a[0], max = _a[1];
255
+ return moment__default["default"](normalizeDate(left)).isBetween(min, max, 's', '[]');
256
+ }
257
+ return DEFAULT_RESULT;
258
+ }
259
+ function notBetweenFunc(left, right) {
260
+ if (typeof left === 'number' && right !== undefined) {
261
+ var _a = tslib.__read(right.sort(), 2), min = _a[0], max = _a[1];
262
+ return left < parseFloat(min) && left > parseFloat(max);
263
+ }
264
+ return DEFAULT_RESULT;
265
+ }
266
+ function notBetweenForDateFunc(left, right) {
267
+ if (right !== undefined) {
268
+ var _a = tslib.__read(normalizeDateRange(right), 2), min = _a[0], max = _a[1];
269
+ return !moment__default["default"](normalizeDate(left)).isBetween(min, max, 's', '[]');
270
+ }
271
+ return DEFAULT_RESULT;
272
+ }
273
+ function selectAnyInFunc(left, right) {
274
+ if (!Array.isArray(right)) {
275
+ return DEFAULT_RESULT;
276
+ }
277
+ if (Array.isArray(left)) {
278
+ return right.every(function (item) { return left.includes(item); });
279
+ }
280
+ return right.includes(left);
281
+ }
282
+ function selectNotAnyInFunc(left, right) {
283
+ if (!Array.isArray(right)) {
284
+ return DEFAULT_RESULT;
285
+ }
286
+ if (Array.isArray(left)) {
287
+ return !right.every(function (item) { return left.includes(item); });
288
+ }
289
+ return !right.includes(left);
290
+ }
291
+ function registerConditionComputer(op, func, fieldType) {
292
+ conditionResolverMap["".concat(op).concat(fieldType ? 'For' + capitalize__default["default"](fieldType) : '')] = func;
293
+ }
294
+ function getConditionComputers() {
295
+ return conditionResolverMap;
296
+ }
297
+ function setConditionComputeErrorHandler(fn) {
298
+ conditionComputeErrorHandler = fn;
299
+ }
300
+ registerConditionComputer('greater', greaterFunc);
301
+ registerConditionComputer('greater', greaterForDateFunc, 'date');
302
+ registerConditionComputer('greater', greaterForDateFunc, 'time');
303
+ registerConditionComputer('greater', greaterForDateFunc, 'datetime');
304
+ registerConditionComputer('greater_or_equal', greaterOrEqualFunc);
305
+ registerConditionComputer('greater_or_equal', greaterOrEqualForDateFunc, 'date');
306
+ registerConditionComputer('greater_or_equal', greaterOrEqualForDateFunc, 'time');
307
+ registerConditionComputer('greater_or_equal', greaterOrEqualForDateFunc, 'datetime');
308
+ registerConditionComputer('less', lessFunc);
309
+ registerConditionComputer('less', lessForDateFunc, 'date');
310
+ registerConditionComputer('less', lessForDateFunc, 'time');
311
+ registerConditionComputer('less', lessForDateFunc, 'datetime');
312
+ registerConditionComputer('less_or_equal', lessOrEqualFunc);
313
+ registerConditionComputer('less_or_equal', lessOrEqualForDateFunc, 'date');
314
+ registerConditionComputer('less_or_equal', lessOrEqualForDateFunc, 'time');
315
+ registerConditionComputer('less_or_equal', lessOrEqualForDateFunc, 'datetime');
316
+ registerConditionComputer('is_empty', isEmptyFunc);
317
+ registerConditionComputer('is_not_empty', isNotEmptyFunc);
318
+ registerConditionComputer('between', betweenFunc);
319
+ registerConditionComputer('between', betweenForDateFunc, 'date');
320
+ registerConditionComputer('between', betweenForDateFunc, 'time');
321
+ registerConditionComputer('between', betweenForDateFunc, 'datetime');
322
+ registerConditionComputer('not_between', notBetweenFunc);
323
+ registerConditionComputer('not_between', notBetweenForDateFunc, 'date');
324
+ registerConditionComputer('not_between', notBetweenForDateFunc, 'time');
325
+ registerConditionComputer('not_between', notBetweenForDateFunc, 'datetime');
326
+ registerConditionComputer('equal', equalFunc);
327
+ registerConditionComputer('not_equal', notEqualFunc);
328
+ registerConditionComputer('like', likeFunc);
329
+ registerConditionComputer('not_like', notLikeFunc);
330
+ registerConditionComputer('select_any_in', selectAnyInFunc);
331
+ registerConditionComputer('select_not_any_in', selectNotAnyInFunc);
332
+ registerConditionComputer('starts_with', startsWithFunc);
333
+ registerConditionComputer('ends_with', endsWithFunc);
334
+
335
+ exports.getConditionComputers = getConditionComputers;
336
+ exports.registerConditionComputer = registerConditionComputer;
337
+ exports.resolveCondition = resolveCondition;
338
+ exports.setConditionComputeErrorHandler = 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,68 @@
1
+ /**
2
+ * amis-core v3.0.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 amisFormula = require('amis-formula');
12
+
13
+ var formulaEvalErrorHandler;
14
+ /**
15
+ * 设置自定义函数,functions中找不到处理的函数时执行
16
+ * @param fn
17
+ */
18
+ function setFormulaEvalErrorHandler(fn) {
19
+ formulaEvalErrorHandler = fn;
20
+ }
21
+ var resolveVariableAndFilterForAsync = function (path, data, defaultFilter, fallbackValue, skipFormulaEvalErrorHandler) {
22
+ if (data === void 0) { data = {}; }
23
+ if (defaultFilter === void 0) { defaultFilter = '| html'; }
24
+ if (fallbackValue === void 0) { fallbackValue = function (value) { return value; }; }
25
+ if (skipFormulaEvalErrorHandler === void 0) { skipFormulaEvalErrorHandler = false; }
26
+ return tslib.__awaiter(void 0, void 0, void 0, function () {
27
+ var ast, ret, e_1;
28
+ return tslib.__generator(this, function (_a) {
29
+ switch (_a.label) {
30
+ case 0:
31
+ if (!path || typeof path !== 'string') {
32
+ return [2 /*return*/, undefined];
33
+ }
34
+ _a.label = 1;
35
+ case 1:
36
+ _a.trys.push([1, 3, , 4]);
37
+ ast = amisFormula.parse(path, {
38
+ evalMode: false,
39
+ allowFilter: true
40
+ });
41
+ return [4 /*yield*/, new amisFormula.AsyncEvaluator(data, {
42
+ defaultFilter: defaultFilter
43
+ }).evalute(ast)];
44
+ case 2:
45
+ ret = _a.sent();
46
+ return [2 /*return*/, ret == null && !~path.indexOf('default') && !~path.indexOf('now')
47
+ ? fallbackValue(ret)
48
+ : ret];
49
+ case 3:
50
+ e_1 = _a.sent();
51
+ console.warn(e_1);
52
+ if (e_1.name === 'FormulaEvalError') {
53
+ if (!skipFormulaEvalErrorHandler) {
54
+ // 无法解析时,执行handler自定义解析逻辑
55
+ return [2 /*return*/, formulaEvalErrorHandler === null || formulaEvalErrorHandler === void 0 ? void 0 : formulaEvalErrorHandler(path, data, defaultFilter, fallbackValue)];
56
+ }
57
+ // 跳过自定义解析逻辑,则直接抛异常
58
+ throw e_1;
59
+ }
60
+ return [2 /*return*/, undefined];
61
+ case 4: return [2 /*return*/];
62
+ }
63
+ });
64
+ });
65
+ };
66
+
67
+ exports.resolveVariableAndFilterForAsync = resolveVariableAndFilterForAsync;
68
+ exports.setFormulaEvalErrorHandler = 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