amis-core 2.9.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/esm/Root.d.ts +89 -4
  2. package/esm/Root.js +15 -4
  3. package/esm/RootRenderer.d.ts +3 -1
  4. package/esm/RootRenderer.js +9 -3
  5. package/esm/SchemaRenderer.d.ts +4 -2
  6. package/esm/SchemaRenderer.js +32 -24
  7. package/esm/Scoped.d.ts +8 -0
  8. package/esm/Scoped.js +20 -5
  9. package/esm/StatusScoped.d.ts +58 -0
  10. package/esm/StatusScoped.js +54 -0
  11. package/esm/WithRootStore.d.ts +2 -2
  12. package/esm/WithRootStore.js +1 -1
  13. package/esm/WithStore.js +6 -2
  14. package/esm/actions/Action.d.ts +1 -0
  15. package/esm/actions/Action.js +19 -5
  16. package/esm/actions/AjaxAction.js +1 -1
  17. package/esm/actions/BreakAction.js +1 -1
  18. package/esm/actions/BroadcastAction.js +1 -1
  19. package/esm/actions/CmptAction.js +8 -7
  20. package/esm/actions/ContinueAction.js +1 -1
  21. package/esm/actions/CopyAction.js +1 -1
  22. package/esm/actions/CustomAction.js +4 -4
  23. package/esm/actions/DialogAction.d.ts +16 -2
  24. package/esm/actions/DialogAction.js +23 -7
  25. package/esm/actions/DrawerAction.js +1 -1
  26. package/esm/actions/EmailAction.js +1 -1
  27. package/esm/actions/LinkAction.js +1 -1
  28. package/esm/actions/LoopAction.js +1 -1
  29. package/esm/actions/PageAction.js +1 -1
  30. package/esm/actions/ParallelAction.js +1 -1
  31. package/esm/actions/SwitchAction.js +1 -1
  32. package/esm/actions/ToastAction.js +1 -1
  33. package/esm/components/CustomStyle.d.ts +13 -0
  34. package/esm/components/CustomStyle.js +18 -0
  35. package/esm/components/LazyComponent.d.ts +1 -1
  36. package/esm/components/LazyComponent.js +1 -1
  37. package/esm/components/Overlay.d.ts +3 -3
  38. package/esm/components/Overlay.js +1 -1
  39. package/esm/components/PopOver.d.ts +2 -2
  40. package/esm/components/PopOver.js +1 -1
  41. package/esm/env.d.ts +10 -2
  42. package/esm/env.js +1 -1
  43. package/esm/envOverwrite.js +1 -5
  44. package/esm/factory.d.ts +5 -3
  45. package/esm/factory.js +3 -3
  46. package/esm/index.d.ts +11 -4
  47. package/esm/index.js +55 -33
  48. package/esm/locale.d.ts +2 -2
  49. package/esm/locale.js +10 -3
  50. package/esm/renderers/Form.d.ts +3 -2
  51. package/esm/renderers/Form.js +216 -180
  52. package/esm/renderers/Item.d.ts +55 -41
  53. package/esm/renderers/Item.js +30 -19
  54. package/esm/renderers/Options.js +11 -4
  55. package/esm/renderers/Placeholder.js +1 -1
  56. package/esm/renderers/builtin.js +1 -1
  57. package/esm/renderers/register.js +1 -1
  58. package/esm/renderers/wrapControl.d.ts +2 -2
  59. package/esm/renderers/wrapControl.js +13 -16
  60. package/esm/store/app.d.ts +1 -0
  61. package/esm/store/app.js +1 -1
  62. package/esm/store/combo.d.ts +3 -0
  63. package/esm/store/combo.js +1 -1
  64. package/esm/store/crud.d.ts +2 -0
  65. package/esm/store/crud.js +31 -9
  66. package/esm/store/form.d.ts +1 -0
  67. package/esm/store/form.js +10 -4
  68. package/esm/store/formItem.js +2 -2
  69. package/esm/store/iRenderer.d.ts +1 -0
  70. package/esm/store/iRenderer.js +54 -13
  71. package/esm/store/index.js +1 -1
  72. package/esm/store/list.d.ts +1 -0
  73. package/esm/store/list.js +7 -3
  74. package/esm/store/manager.js +1 -1
  75. package/esm/store/modal.d.ts +1 -0
  76. package/esm/store/modal.js +1 -1
  77. package/esm/store/node.js +1 -1
  78. package/esm/store/pagination.d.ts +1 -0
  79. package/esm/store/pagination.js +2 -2
  80. package/esm/store/root.d.ts +4 -6
  81. package/esm/store/root.js +53 -24
  82. package/esm/store/service.d.ts +1 -0
  83. package/esm/store/service.js +1 -1
  84. package/esm/store/status.d.ts +12 -0
  85. package/esm/store/status.js +38 -0
  86. package/esm/store/table.d.ts +28 -23
  87. package/esm/store/table.js +26 -5
  88. package/esm/store/table2.d.ts +7 -6
  89. package/esm/store/table2.js +27 -23
  90. package/esm/theme.d.ts +1 -1
  91. package/esm/theme.js +1 -1
  92. package/esm/types.d.ts +7 -1
  93. package/esm/utils/Animation.js +1 -1
  94. package/esm/utils/ColorScale.js +1 -1
  95. package/esm/utils/DataSchema.js +1 -1
  96. package/esm/utils/DataScope.d.ts +3 -5
  97. package/esm/utils/DataScope.js +88 -31
  98. package/esm/utils/RootClose.js +1 -1
  99. package/esm/utils/SimpleMap.js +1 -1
  100. package/esm/utils/api.js +14 -5
  101. package/esm/utils/attachmentAdpator.js +2 -2
  102. package/esm/utils/autobind.js +1 -1
  103. package/esm/utils/columnsSplit.js +1 -1
  104. package/esm/utils/dataMapping.js +1 -1
  105. package/esm/utils/date.d.ts +7 -0
  106. package/esm/utils/date.js +34 -2
  107. package/esm/utils/debug.js +4 -4
  108. package/esm/utils/decodeEntity.js +1 -1
  109. package/esm/utils/dom.d.ts +3 -0
  110. package/esm/utils/dom.js +47 -10
  111. package/esm/utils/errors.js +1 -1
  112. package/esm/utils/escapeHtml.js +1 -1
  113. package/esm/utils/filter-schema.js +1 -1
  114. package/esm/utils/filter.js +1 -1
  115. package/esm/utils/formatDuration.js +1 -1
  116. package/esm/utils/formula.js +2 -2
  117. package/esm/utils/getVariable.js +1 -1
  118. package/esm/utils/grammar.js +3 -3
  119. package/esm/utils/handleAction.js +1 -1
  120. package/esm/utils/helper.d.ts +9 -2
  121. package/esm/utils/helper.js +52 -20
  122. package/esm/utils/highlight.js +1 -1
  123. package/esm/utils/icon.d.ts +6 -1
  124. package/esm/utils/icon.js +6 -1
  125. package/esm/utils/image.js +1 -1
  126. package/esm/utils/isPureVariable.js +3 -3
  127. package/esm/utils/json-schema-2-amis-schema.js +1 -1
  128. package/esm/utils/keyToPath.js +1 -1
  129. package/esm/utils/makeSorter.js +1 -1
  130. package/esm/utils/memoryParse.d.ts +17 -0
  131. package/esm/utils/memoryParse.js +26 -0
  132. package/esm/utils/normalizeLink.js +1 -1
  133. package/esm/utils/normalizeOptions.js +4 -2
  134. package/esm/utils/object.d.ts +2 -0
  135. package/esm/utils/object.js +27 -2
  136. package/esm/utils/offset.js +1 -1
  137. package/esm/utils/offsetParent.js +1 -1
  138. package/esm/utils/optionValueCompare.js +1 -1
  139. package/esm/utils/position.js +1 -1
  140. package/esm/utils/prettyBytes.js +1 -1
  141. package/esm/utils/renderer-event.js +35 -32
  142. package/esm/utils/replaceText.js +1 -1
  143. package/esm/utils/resize-sensor.js +1 -1
  144. package/esm/utils/resolveCondition.d.ts +1 -0
  145. package/esm/utils/resolveCondition.js +19 -4
  146. package/esm/utils/resolveVariable.js +4 -3
  147. package/esm/utils/resolveVariableAndFilter.js +1 -1
  148. package/esm/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
  149. package/esm/utils/resolveVariableAndFilterForAsync.js +23 -5
  150. package/esm/utils/scrollPosition.js +1 -1
  151. package/esm/utils/string2regExp.js +1 -1
  152. package/esm/utils/stripNumber.js +1 -1
  153. package/esm/utils/style-helper.d.ts +12 -4
  154. package/esm/utils/style-helper.js +96 -19
  155. package/esm/utils/style.js +2 -2
  156. package/esm/utils/toNumber.js +1 -1
  157. package/esm/utils/tokenize.js +1 -1
  158. package/esm/utils/tpl-builtin.d.ts +2 -1
  159. package/esm/utils/tpl-builtin.js +19 -2
  160. package/esm/utils/tpl-lodash.js +3 -2
  161. package/esm/utils/tpl.d.ts +2 -0
  162. package/esm/utils/tpl.js +24 -2
  163. package/esm/utils/uncontrollable.js +1 -1
  164. package/esm/utils/validations.d.ts +4 -1
  165. package/esm/utils/validations.js +27 -12
  166. package/lib/Root.d.ts +89 -4
  167. package/lib/Root.js +15 -4
  168. package/lib/RootRenderer.d.ts +3 -1
  169. package/lib/RootRenderer.js +8 -2
  170. package/lib/SchemaRenderer.d.ts +4 -2
  171. package/lib/SchemaRenderer.js +32 -23
  172. package/lib/Scoped.d.ts +8 -0
  173. package/lib/Scoped.js +20 -4
  174. package/lib/StatusScoped.d.ts +58 -0
  175. package/lib/StatusScoped.js +63 -0
  176. package/lib/WithRootStore.d.ts +2 -2
  177. package/lib/WithRootStore.js +1 -1
  178. package/lib/WithStore.js +6 -2
  179. package/lib/actions/Action.d.ts +1 -0
  180. package/lib/actions/Action.js +19 -5
  181. package/lib/actions/AjaxAction.js +1 -1
  182. package/lib/actions/BreakAction.js +1 -1
  183. package/lib/actions/BroadcastAction.js +1 -1
  184. package/lib/actions/CmptAction.js +8 -7
  185. package/lib/actions/ContinueAction.js +1 -1
  186. package/lib/actions/CopyAction.js +1 -1
  187. package/lib/actions/CustomAction.js +4 -4
  188. package/lib/actions/DialogAction.d.ts +16 -2
  189. package/lib/actions/DialogAction.js +23 -7
  190. package/lib/actions/DrawerAction.js +1 -1
  191. package/lib/actions/EmailAction.js +1 -1
  192. package/lib/actions/LinkAction.js +1 -1
  193. package/lib/actions/LoopAction.js +1 -1
  194. package/lib/actions/PageAction.js +1 -1
  195. package/lib/actions/ParallelAction.js +1 -1
  196. package/lib/actions/SwitchAction.js +1 -1
  197. package/lib/actions/ToastAction.js +1 -1
  198. package/lib/components/CustomStyle.d.ts +13 -0
  199. package/lib/components/CustomStyle.js +22 -0
  200. package/lib/components/LazyComponent.d.ts +1 -1
  201. package/lib/components/LazyComponent.js +1 -1
  202. package/lib/components/Overlay.d.ts +3 -3
  203. package/lib/components/Overlay.js +1 -1
  204. package/lib/components/PopOver.d.ts +2 -2
  205. package/lib/components/PopOver.js +1 -1
  206. package/lib/env.d.ts +10 -2
  207. package/lib/env.js +1 -1
  208. package/lib/envOverwrite.js +1 -5
  209. package/lib/factory.d.ts +5 -3
  210. package/lib/factory.js +3 -3
  211. package/lib/index.d.ts +11 -4
  212. package/lib/index.js +61 -23
  213. package/lib/locale.d.ts +2 -2
  214. package/lib/locale.js +10 -3
  215. package/lib/renderers/Form.d.ts +3 -2
  216. package/lib/renderers/Form.js +215 -179
  217. package/lib/renderers/Item.d.ts +55 -41
  218. package/lib/renderers/Item.js +30 -19
  219. package/lib/renderers/Options.js +11 -4
  220. package/lib/renderers/Placeholder.js +1 -1
  221. package/lib/renderers/builtin.js +1 -1
  222. package/lib/renderers/register.js +1 -1
  223. package/lib/renderers/wrapControl.d.ts +2 -2
  224. package/lib/renderers/wrapControl.js +12 -15
  225. package/lib/store/app.d.ts +1 -0
  226. package/lib/store/app.js +1 -1
  227. package/lib/store/combo.d.ts +3 -0
  228. package/lib/store/combo.js +1 -1
  229. package/lib/store/crud.d.ts +2 -0
  230. package/lib/store/crud.js +31 -9
  231. package/lib/store/form.d.ts +1 -0
  232. package/lib/store/form.js +10 -4
  233. package/lib/store/formItem.js +2 -2
  234. package/lib/store/iRenderer.d.ts +1 -0
  235. package/lib/store/iRenderer.js +53 -12
  236. package/lib/store/index.js +1 -1
  237. package/lib/store/list.d.ts +1 -0
  238. package/lib/store/list.js +7 -3
  239. package/lib/store/manager.js +1 -1
  240. package/lib/store/modal.d.ts +1 -0
  241. package/lib/store/modal.js +1 -1
  242. package/lib/store/node.js +1 -1
  243. package/lib/store/pagination.d.ts +1 -0
  244. package/lib/store/pagination.js +2 -2
  245. package/lib/store/root.d.ts +4 -6
  246. package/lib/store/root.js +52 -23
  247. package/lib/store/service.d.ts +1 -0
  248. package/lib/store/service.js +1 -1
  249. package/lib/store/status.d.ts +12 -0
  250. package/lib/store/status.js +42 -0
  251. package/lib/store/table.d.ts +28 -23
  252. package/lib/store/table.js +26 -5
  253. package/lib/store/table2.d.ts +7 -6
  254. package/lib/store/table2.js +27 -23
  255. package/lib/theme.d.ts +1 -1
  256. package/lib/theme.js +1 -1
  257. package/lib/types.d.ts +7 -1
  258. package/lib/utils/Animation.js +1 -1
  259. package/lib/utils/ColorScale.js +1 -1
  260. package/lib/utils/DataSchema.js +1 -1
  261. package/lib/utils/DataScope.d.ts +3 -5
  262. package/lib/utils/DataScope.js +86 -29
  263. package/lib/utils/RootClose.js +1 -1
  264. package/lib/utils/SimpleMap.js +1 -1
  265. package/lib/utils/api.js +13 -4
  266. package/lib/utils/attachmentAdpator.js +2 -2
  267. package/lib/utils/autobind.js +1 -1
  268. package/lib/utils/columnsSplit.js +1 -1
  269. package/lib/utils/dataMapping.js +1 -1
  270. package/lib/utils/date.d.ts +7 -0
  271. package/lib/utils/date.js +34 -1
  272. package/lib/utils/debug.js +4 -4
  273. package/lib/utils/decodeEntity.js +1 -1
  274. package/lib/utils/dom.d.ts +3 -0
  275. package/lib/utils/dom.js +48 -9
  276. package/lib/utils/errors.js +1 -1
  277. package/lib/utils/escapeHtml.js +1 -1
  278. package/lib/utils/filter-schema.js +1 -1
  279. package/lib/utils/filter.js +1 -1
  280. package/lib/utils/formatDuration.js +1 -1
  281. package/lib/utils/formula.js +2 -2
  282. package/lib/utils/getVariable.js +1 -1
  283. package/lib/utils/grammar.js +3 -3
  284. package/lib/utils/handleAction.js +1 -1
  285. package/lib/utils/helper.d.ts +9 -2
  286. package/lib/utils/helper.js +53 -19
  287. package/lib/utils/highlight.js +1 -1
  288. package/lib/utils/icon.d.ts +6 -1
  289. package/lib/utils/icon.js +6 -1
  290. package/lib/utils/image.js +1 -1
  291. package/lib/utils/isPureVariable.js +3 -3
  292. package/lib/utils/json-schema-2-amis-schema.js +1 -1
  293. package/lib/utils/keyToPath.js +1 -1
  294. package/lib/utils/makeSorter.js +1 -1
  295. package/lib/utils/memoryParse.d.ts +17 -0
  296. package/lib/utils/memoryParse.js +30 -0
  297. package/lib/utils/normalizeLink.js +1 -1
  298. package/lib/utils/normalizeOptions.js +4 -2
  299. package/lib/utils/object.d.ts +2 -0
  300. package/lib/utils/object.js +28 -1
  301. package/lib/utils/offset.js +1 -1
  302. package/lib/utils/offsetParent.js +1 -1
  303. package/lib/utils/optionValueCompare.js +1 -1
  304. package/lib/utils/position.js +1 -1
  305. package/lib/utils/prettyBytes.js +1 -1
  306. package/lib/utils/renderer-event.js +35 -32
  307. package/lib/utils/replaceText.js +1 -1
  308. package/lib/utils/resize-sensor.js +1 -1
  309. package/lib/utils/resolveCondition.d.ts +1 -0
  310. package/lib/utils/resolveCondition.js +19 -3
  311. package/lib/utils/resolveVariable.js +3 -2
  312. package/lib/utils/resolveVariableAndFilter.js +1 -1
  313. package/lib/utils/resolveVariableAndFilterForAsync.d.ts +6 -1
  314. package/lib/utils/resolveVariableAndFilterForAsync.js +22 -3
  315. package/lib/utils/scrollPosition.js +1 -1
  316. package/lib/utils/string2regExp.js +1 -1
  317. package/lib/utils/stripNumber.js +1 -1
  318. package/lib/utils/style-helper.d.ts +12 -4
  319. package/lib/utils/style-helper.js +101 -18
  320. package/lib/utils/style.js +2 -2
  321. package/lib/utils/toNumber.js +1 -1
  322. package/lib/utils/tokenize.js +1 -1
  323. package/lib/utils/tpl-builtin.d.ts +2 -1
  324. package/lib/utils/tpl-builtin.js +19 -2
  325. package/lib/utils/tpl-lodash.js +3 -2
  326. package/lib/utils/tpl.d.ts +2 -0
  327. package/lib/utils/tpl.js +24 -1
  328. package/lib/utils/uncontrollable.js +1 -1
  329. package/lib/utils/validations.d.ts +4 -1
  330. package/lib/utils/validations.js +27 -12
  331. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -556,22 +556,23 @@ var uuidv4 = function () {
556
556
  * @param {Function} iterator 处理函数,返回的数据会被替换成新的。
557
557
  * @return {Tree} 返回处理过的 tree
558
558
  */
559
- function mapTree(tree, iterator, level, depthFirst, paths) {
559
+ function mapTree(tree, iterator, level, depthFirst, paths, indexes) {
560
560
  if (level === void 0) { level = 1; }
561
561
  if (depthFirst === void 0) { depthFirst = false; }
562
562
  if (paths === void 0) { paths = []; }
563
+ if (indexes === void 0) { indexes = []; }
563
564
  return tree.map(function (item, index) {
564
565
  if (depthFirst) {
565
566
  var children = item.children
566
- ? mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item))
567
+ ? mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item), indexes.concat(index))
567
568
  : undefined;
568
569
  children && (item = tslib.__assign(tslib.__assign({}, item), { children: children }));
569
- item = iterator(item, index, level, paths) || tslib.__assign({}, item);
570
+ item = iterator(item, index, level, paths, indexes.concat(index)) || tslib.__assign({}, item);
570
571
  return item;
571
572
  }
572
- item = iterator(item, index, level, paths) || tslib.__assign({}, item);
573
+ item = iterator(item, index, level, paths, indexes.concat(index)) || tslib.__assign({}, item);
573
574
  if (item.children && item.children.splice) {
574
- item.children = mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item));
575
+ item.children = mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item), indexes.concat(index));
575
576
  }
576
577
  return item;
577
578
  });
@@ -586,10 +587,9 @@ function eachTree(tree, iterator, level, paths) {
586
587
  if (paths === void 0) { paths = []; }
587
588
  tree.map(function (item, index) {
588
589
  var _a;
589
- var currentPath = paths.concat(item);
590
- iterator(item, index, level, currentPath);
590
+ iterator(item, index, level, paths);
591
591
  if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.splice) {
592
- eachTree(item.children, iterator, level + 1, currentPath);
592
+ eachTree(item.children, iterator, level + 1, paths.concat(item));
593
593
  }
594
594
  });
595
595
  }
@@ -609,6 +609,21 @@ function findTree(tree, iterator) {
609
609
  });
610
610
  return result;
611
611
  }
612
+ /**
613
+ * 在树中查找节点。
614
+ * @param tree
615
+ * @param iterator
616
+ */
617
+ function findTreeAll(tree, iterator) {
618
+ var result = [];
619
+ everyTree(tree, function (item, key, level, paths) {
620
+ if (iterator(item, key, level, paths)) {
621
+ result.push(item);
622
+ }
623
+ return true;
624
+ });
625
+ return result;
626
+ }
612
627
  /**
613
628
  * 在树中查找节点, 返回下标数组。
614
629
  * @param tree
@@ -654,28 +669,29 @@ function getTree(tree, idx) {
654
669
  * @param tree
655
670
  * @param iterator
656
671
  */
657
- function filterTree(tree, iterator, level, depthFirst) {
672
+ function filterTree(tree, iterator, level, depthFirst, paths) {
658
673
  if (level === void 0) { level = 1; }
659
674
  if (depthFirst === void 0) { depthFirst = false; }
675
+ if (paths === void 0) { paths = []; }
660
676
  if (depthFirst) {
661
677
  return tree
662
678
  .map(function (item) {
663
679
  var children = item.children
664
- ? filterTree(item.children, iterator, level + 1, depthFirst)
680
+ ? filterTree(item.children, iterator, level + 1, depthFirst, paths.concat(item))
665
681
  : undefined;
666
682
  if (Array.isArray(children) && Array.isArray(item.children)) {
667
683
  item = tslib.__assign(tslib.__assign({}, item), { children: children });
668
684
  }
669
685
  return item;
670
686
  })
671
- .filter(function (item, index) { return iterator(item, index, level); });
687
+ .filter(function (item, index) { return iterator(item, index, level, paths); });
672
688
  }
673
689
  return tree
674
- .filter(function (item, index) { return iterator(item, index, level); })
690
+ .filter(function (item, index) { return iterator(item, index, level, paths); })
675
691
  .map(function (item) {
676
692
  var _a;
677
693
  if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.splice) {
678
- var children = filterTree(item.children, iterator, level + 1, depthFirst);
694
+ var children = filterTree(item.children, iterator, level + 1, depthFirst, paths.concat(item));
679
695
  if (Array.isArray(children) && Array.isArray(item.children)) {
680
696
  item = tslib.__assign(tslib.__assign({}, item), { children: children });
681
697
  }
@@ -775,6 +791,9 @@ function spliceTree(tree, idx, deleteCount) {
775
791
  * @param tree
776
792
  */
777
793
  function getTreeDepth(tree) {
794
+ if (Array.isArray(tree) && tree.length === 0) {
795
+ return 0;
796
+ }
778
797
  return Math.max.apply(Math, tslib.__spreadArray([], tslib.__read(tree.map(function (item) {
779
798
  if (Array.isArray(item.children)) {
780
799
  return 1 + getTreeDepth(item.children);
@@ -1015,6 +1034,16 @@ function loadScript(src) {
1015
1034
  document.head.appendChild(script);
1016
1035
  });
1017
1036
  }
1037
+ function loadStyle(href) {
1038
+ return new Promise(function (ok, fail) {
1039
+ var link = document.createElement('link');
1040
+ link.rel = 'stylesheet';
1041
+ link.onerror = function (reason) { return fail(reason); };
1042
+ link.onload = function () { return ok(); };
1043
+ link.href = href;
1044
+ document.head.appendChild(link);
1045
+ });
1046
+ }
1018
1047
  var SkipOperation = /** @class */ (function (_super) {
1019
1048
  tslib.__extends(SkipOperation, _super);
1020
1049
  function SkipOperation() {
@@ -1189,7 +1218,7 @@ function isClickOnInput(e) {
1189
1218
  var formItem;
1190
1219
  if (!e.currentTarget.contains(target) ||
1191
1220
  ~['INPUT', 'TEXTAREA'].indexOf(target.tagName) ||
1192
- ((formItem = target.closest("button, a, [data-role=\"form-item\"]")) &&
1221
+ ((formItem = target.closest("button, a, [data-role=\"form-item\"], label[data-role=\"checkbox\"]")) &&
1193
1222
  e.currentTarget.contains(formItem))) {
1194
1223
  return true;
1195
1224
  }
@@ -1258,14 +1287,17 @@ function isNumeric(value) {
1258
1287
  * @param location Location对象,或者类Location结构的对象
1259
1288
  */
1260
1289
  function parseQuery(location) {
1261
- var _a, _b;
1290
+ var _a;
1262
1291
  var query = (location && !(location instanceof Location) && (location === null || location === void 0 ? void 0 : location.query)) ||
1263
1292
  (location && (location === null || location === void 0 ? void 0 : location.search) && qsparse(location.search.substring(1))) ||
1264
1293
  (window.location.search && qsparse(window.location.search.substring(1)));
1265
1294
  /* 处理hash中的query */
1266
- var hashQuery = ((_a = window.location) === null || _a === void 0 ? void 0 : _a.hash) && typeof ((_b = window.location) === null || _b === void 0 ? void 0 : _b.hash) === 'string'
1267
- ? qsparse(window.location.hash.replace(/^#.*\?/gi, ''))
1268
- : {};
1295
+ var hash = (_a = window.location) === null || _a === void 0 ? void 0 : _a.hash;
1296
+ var hashQuery = {};
1297
+ var idx = -1;
1298
+ if (typeof hash === 'string' && ~(idx = hash.indexOf('?'))) {
1299
+ hashQuery = qsparse(hash.substring(idx + 1));
1300
+ }
1269
1301
  var normalizedQuery = isPlainObject__default["default"](query) ? query : {};
1270
1302
  return merge__default["default"](normalizedQuery, hashQuery);
1271
1303
  }
@@ -1297,6 +1329,7 @@ exports.filterTree = filterTree;
1297
1329
  exports.findIndex = findIndex;
1298
1330
  exports.findObjectsWithKey = findObjectsWithKey;
1299
1331
  exports.findTree = findTree;
1332
+ exports.findTreeAll = findTreeAll;
1300
1333
  exports.findTreeIndex = findTreeIndex;
1301
1334
  exports.flattenTree = flattenTree;
1302
1335
  exports.flattenTreeWithLeafNodes = flattenTreeWithLeafNodes;
@@ -1331,6 +1364,7 @@ exports.isUnfolded = isUnfolded;
1331
1364
  exports.isVisible = isVisible;
1332
1365
  exports.lcFirst = lcFirst;
1333
1366
  exports.loadScript = loadScript;
1367
+ exports.loadStyle = loadStyle;
1334
1368
  exports.makeColumnClassBuild = makeColumnClassBuild;
1335
1369
  exports.makeHorizontalDeeper = makeHorizontalDeeper;
1336
1370
  exports.mapObject = mapObject;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -6,6 +6,11 @@ import { ClassNamesFn } from '../theme';
6
6
  export interface IconCheckedSchema {
7
7
  id: string;
8
8
  name?: string;
9
+ svg?: string;
10
+ }
11
+ export interface IconCheckedSchemaNew {
12
+ type: 'icon';
13
+ icon: IconCheckedSchema;
9
14
  }
10
15
  /**
11
16
  * 判断字符串来生成 i 或 img
@@ -13,4 +18,4 @@ export interface IconCheckedSchema {
13
18
  * @param className 内部用的 className
14
19
  * @param classNameProp amis 配置里设置的 className
15
20
  */
16
- export declare const generateIcon: (cx: ClassNamesFn, icon?: string | IconCheckedSchema | React.ReactNode, className?: string, classNameProp?: string) => JSX.Element | null | undefined;
21
+ export declare const generateIcon: (cx: ClassNamesFn, icon?: string | IconCheckedSchema | React.ReactNode | IconCheckedSchemaNew, className?: string, classNameProp?: string) => React.JSX.Element | null | undefined;
package/lib/utils/icon.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -24,6 +24,11 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
24
24
  * @param classNameProp amis 配置里设置的 className
25
25
  */
26
26
  var generateIcon = function (cx, icon, className, classNameProp) {
27
+ if (lodash.isObject(icon) &&
28
+ icon.type === 'icon' &&
29
+ icon.icon) {
30
+ icon = icon.icon;
31
+ }
27
32
  if (React__default["default"].isValidElement(icon)) {
28
33
  return icon;
29
34
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -7,12 +7,12 @@
7
7
 
8
8
  Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
- var amisFormula = require('amis-formula');
10
+ var memoryParse = require('./memoryParse.js');
11
11
 
12
12
  function isPureVariable(path) {
13
13
  if (typeof path === 'string') {
14
14
  try {
15
- var ast = amisFormula.parse(path);
15
+ var ast = memoryParse.memoryParse(path);
16
16
  // 只有一个成员说明是纯表达式模式
17
17
  return ast.body.length === 1 && ast.body[0].type === 'script';
18
18
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -0,0 +1,17 @@
1
+ export declare function memoryParse(input: string, options?: {
2
+ /**
3
+ * 直接是运算表达式?还是从模板开始 ${} 里面才算运算表达式
4
+ */
5
+ evalMode?: boolean;
6
+ /**
7
+ * 只支持取变量。
8
+ */
9
+ variableMode?: boolean;
10
+ /**
11
+ * 是否允许 filter 语法,比如:
12
+ *
13
+ * ${abc | html}
14
+ */
15
+ allowFilter?: boolean;
16
+ variableNamespaces?: Array<string>;
17
+ }): any;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * amis-core v3.1.0
3
+ * Copyright 2018-2023 fex
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ Object.defineProperty(exports, '__esModule', { value: true });
9
+
10
+ var amisFormula = require('amis-formula');
11
+
12
+ var cache = {};
13
+ function memoryParse(input, options) {
14
+ if (options === void 0) { options = {
15
+ evalMode: false
16
+ }; }
17
+ // @todo 优化内存缓存释放,比如只缓存最高频的模版
18
+ if (typeof input !== 'string') {
19
+ return;
20
+ }
21
+ var key = input + JSON.stringify(options);
22
+ if (cache[key]) {
23
+ return cache[key];
24
+ }
25
+ var ast = amisFormula.parse(input, options);
26
+ cache[key] = ast;
27
+ return ast;
28
+ }
29
+
30
+ exports.memoryParse = memoryParse;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -58,7 +58,9 @@ function normalizeOptions(options, share, valueField) {
58
58
  });
59
59
  }
60
60
  else if (Array.isArray(options)) {
61
- return options.map(function (item) {
61
+ return options
62
+ .filter(function (item) { return item !== null && item !== undefined; })
63
+ .map(function (item) {
62
64
  var _a;
63
65
  var value = item && item[valueField];
64
66
  var idx = value !== undefined && !item.children
@@ -3,6 +3,8 @@ export declare function createObject(superProps?: {
3
3
  }, props?: {
4
4
  [propName: string]: any;
5
5
  }, properties?: any): object;
6
+ export declare function extractObjectChain(value: any): object[];
7
+ export declare function createObjectFromChain(chain: Array<object>): object;
6
8
  export declare function cloneObject(target: any, persistOwnProps?: boolean): any;
7
9
  export declare function extendObject(target: any, src?: any, persistOwnProps?: boolean): any;
8
10
  export declare function isObject(obj: any): any;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -33,6 +33,31 @@ function createObject(superProps, props, properties) {
33
33
  Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
34
34
  return obj;
35
35
  }
36
+ function extractObjectChain(value) {
37
+ var result = value ? [value] : [];
38
+ while (value === null || value === void 0 ? void 0 : value.__super) {
39
+ result.unshift(value.__super);
40
+ value = value.__super;
41
+ }
42
+ return result;
43
+ }
44
+ function createObjectFromChain(chain) {
45
+ return chain
46
+ .filter(function (item) { return item; })
47
+ .reduce(function (proto, value) {
48
+ proto = proto || Object.prototype;
49
+ if (Object.isFrozen(proto)) {
50
+ proto = cloneObject(proto);
51
+ }
52
+ return Object.assign(Object.create(proto, {
53
+ __super: {
54
+ value: proto,
55
+ writable: false,
56
+ enumerable: false
57
+ }
58
+ }), value);
59
+ });
60
+ }
36
61
  function cloneObject(target, persistOwnProps) {
37
62
  if (persistOwnProps === void 0) { persistOwnProps = true; }
38
63
  var obj = target && target.__super
@@ -149,8 +174,10 @@ function pickValues(names, data) {
149
174
 
150
175
  exports.cloneObject = cloneObject;
151
176
  exports.createObject = createObject;
177
+ exports.createObjectFromChain = createObjectFromChain;
152
178
  exports.deleteVariable = deleteVariable;
153
179
  exports.extendObject = extendObject;
180
+ exports.extractObjectChain = extractObjectChain;
154
181
  exports.isObject = isObject;
155
182
  exports.pickValues = pickValues;
156
183
  exports.setVariable = setVariable;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -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.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-core v2.9.0
2
+ * amis-core v3.1.0
3
3
  * Copyright 2018-2023 fex
4
4
  */
5
5
 
@@ -3,3 +3,4 @@ export declare function registerConditionComputer(op: string, func: (left: any,
3
3
  export declare function getConditionComputers(): {
4
4
  [op: string]: (left: any, right: any, fieldType?: string | undefined) => boolean;
5
5
  };
6
+ export declare function setConditionComputeErrorHandler(fn: (conditions: any, data: any, defaultResult: boolean) => boolean | Promise<boolean>): void;