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
 
@@ -544,22 +544,23 @@ var uuidv4 = function () {
544
544
  * @param {Function} iterator 处理函数,返回的数据会被替换成新的。
545
545
  * @return {Tree} 返回处理过的 tree
546
546
  */
547
- function mapTree(tree, iterator, level, depthFirst, paths) {
547
+ function mapTree(tree, iterator, level, depthFirst, paths, indexes) {
548
548
  if (level === void 0) { level = 1; }
549
549
  if (depthFirst === void 0) { depthFirst = false; }
550
550
  if (paths === void 0) { paths = []; }
551
+ if (indexes === void 0) { indexes = []; }
551
552
  return tree.map(function (item, index) {
552
553
  if (depthFirst) {
553
554
  var children = item.children
554
- ? mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item))
555
+ ? mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item), indexes.concat(index))
555
556
  : undefined;
556
557
  children && (item = __assign(__assign({}, item), { children: children }));
557
- item = iterator(item, index, level, paths) || __assign({}, item);
558
+ item = iterator(item, index, level, paths, indexes.concat(index)) || __assign({}, item);
558
559
  return item;
559
560
  }
560
- item = iterator(item, index, level, paths) || __assign({}, item);
561
+ item = iterator(item, index, level, paths, indexes.concat(index)) || __assign({}, item);
561
562
  if (item.children && item.children.splice) {
562
- item.children = mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item));
563
+ item.children = mapTree(item.children, iterator, level + 1, depthFirst, paths.concat(item), indexes.concat(index));
563
564
  }
564
565
  return item;
565
566
  });
@@ -574,10 +575,9 @@ function eachTree(tree, iterator, level, paths) {
574
575
  if (paths === void 0) { paths = []; }
575
576
  tree.map(function (item, index) {
576
577
  var _a;
577
- var currentPath = paths.concat(item);
578
- iterator(item, index, level, currentPath);
578
+ iterator(item, index, level, paths);
579
579
  if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.splice) {
580
- eachTree(item.children, iterator, level + 1, currentPath);
580
+ eachTree(item.children, iterator, level + 1, paths.concat(item));
581
581
  }
582
582
  });
583
583
  }
@@ -597,6 +597,21 @@ function findTree(tree, iterator) {
597
597
  });
598
598
  return result;
599
599
  }
600
+ /**
601
+ * 在树中查找节点。
602
+ * @param tree
603
+ * @param iterator
604
+ */
605
+ function findTreeAll(tree, iterator) {
606
+ var result = [];
607
+ everyTree(tree, function (item, key, level, paths) {
608
+ if (iterator(item, key, level, paths)) {
609
+ result.push(item);
610
+ }
611
+ return true;
612
+ });
613
+ return result;
614
+ }
600
615
  /**
601
616
  * 在树中查找节点, 返回下标数组。
602
617
  * @param tree
@@ -642,28 +657,29 @@ function getTree(tree, idx) {
642
657
  * @param tree
643
658
  * @param iterator
644
659
  */
645
- function filterTree(tree, iterator, level, depthFirst) {
660
+ function filterTree(tree, iterator, level, depthFirst, paths) {
646
661
  if (level === void 0) { level = 1; }
647
662
  if (depthFirst === void 0) { depthFirst = false; }
663
+ if (paths === void 0) { paths = []; }
648
664
  if (depthFirst) {
649
665
  return tree
650
666
  .map(function (item) {
651
667
  var children = item.children
652
- ? filterTree(item.children, iterator, level + 1, depthFirst)
668
+ ? filterTree(item.children, iterator, level + 1, depthFirst, paths.concat(item))
653
669
  : undefined;
654
670
  if (Array.isArray(children) && Array.isArray(item.children)) {
655
671
  item = __assign(__assign({}, item), { children: children });
656
672
  }
657
673
  return item;
658
674
  })
659
- .filter(function (item, index) { return iterator(item, index, level); });
675
+ .filter(function (item, index) { return iterator(item, index, level, paths); });
660
676
  }
661
677
  return tree
662
- .filter(function (item, index) { return iterator(item, index, level); })
678
+ .filter(function (item, index) { return iterator(item, index, level, paths); })
663
679
  .map(function (item) {
664
680
  var _a;
665
681
  if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.splice) {
666
- var children = filterTree(item.children, iterator, level + 1, depthFirst);
682
+ var children = filterTree(item.children, iterator, level + 1, depthFirst, paths.concat(item));
667
683
  if (Array.isArray(children) && Array.isArray(item.children)) {
668
684
  item = __assign(__assign({}, item), { children: children });
669
685
  }
@@ -763,6 +779,9 @@ function spliceTree(tree, idx, deleteCount) {
763
779
  * @param tree
764
780
  */
765
781
  function getTreeDepth(tree) {
782
+ if (Array.isArray(tree) && tree.length === 0) {
783
+ return 0;
784
+ }
766
785
  return Math.max.apply(Math, __spreadArray([], __read(tree.map(function (item) {
767
786
  if (Array.isArray(item.children)) {
768
787
  return 1 + getTreeDepth(item.children);
@@ -1003,6 +1022,16 @@ function loadScript(src) {
1003
1022
  document.head.appendChild(script);
1004
1023
  });
1005
1024
  }
1025
+ function loadStyle(href) {
1026
+ return new Promise(function (ok, fail) {
1027
+ var link = document.createElement('link');
1028
+ link.rel = 'stylesheet';
1029
+ link.onerror = function (reason) { return fail(reason); };
1030
+ link.onload = function () { return ok(); };
1031
+ link.href = href;
1032
+ document.head.appendChild(link);
1033
+ });
1034
+ }
1006
1035
  var SkipOperation = /** @class */ (function (_super) {
1007
1036
  __extends(SkipOperation, _super);
1008
1037
  function SkipOperation() {
@@ -1177,7 +1206,7 @@ function isClickOnInput(e) {
1177
1206
  var formItem;
1178
1207
  if (!e.currentTarget.contains(target) ||
1179
1208
  ~['INPUT', 'TEXTAREA'].indexOf(target.tagName) ||
1180
- ((formItem = target.closest("button, a, [data-role=\"form-item\"]")) &&
1209
+ ((formItem = target.closest("button, a, [data-role=\"form-item\"], label[data-role=\"checkbox\"]")) &&
1181
1210
  e.currentTarget.contains(formItem))) {
1182
1211
  return true;
1183
1212
  }
@@ -1246,16 +1275,19 @@ function isNumeric(value) {
1246
1275
  * @param location Location对象,或者类Location结构的对象
1247
1276
  */
1248
1277
  function parseQuery(location) {
1249
- var _a, _b;
1278
+ var _a;
1250
1279
  var query = (location && !(location instanceof Location) && (location === null || location === void 0 ? void 0 : location.query)) ||
1251
1280
  (location && (location === null || location === void 0 ? void 0 : location.search) && qsparse(location.search.substring(1))) ||
1252
1281
  (window.location.search && qsparse(window.location.search.substring(1)));
1253
1282
  /* 处理hash中的query */
1254
- 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'
1255
- ? qsparse(window.location.hash.replace(/^#.*\?/gi, ''))
1256
- : {};
1283
+ var hash = (_a = window.location) === null || _a === void 0 ? void 0 : _a.hash;
1284
+ var hashQuery = {};
1285
+ var idx = -1;
1286
+ if (typeof hash === 'string' && ~(idx = hash.indexOf('?'))) {
1287
+ hashQuery = qsparse(hash.substring(idx + 1));
1288
+ }
1257
1289
  var normalizedQuery = isPlainObject(query) ? query : {};
1258
1290
  return merge(normalizedQuery, hashQuery);
1259
1291
  }
1260
1292
 
1261
- export { JSONTraverse, SkipOperation, __uri, anyChanged, autobind, bulkBindFunctions, camel, chainEvents, chainFunctions, convertArrayValueToMoment, detectPropValueChanged, difference, eachTree, everyTree, filterTree, findIndex, findObjectsWithKey, findTree, findTreeIndex, flattenTree, flattenTreeWithLeafNodes, getLevelFromClassName, getPropValue, getRange, getScrollParent, getScrollbarWidth, getTree, getTreeAncestors, getTreeDepth, getTreeParent, getWidthRate, guid, hasAbility, hasFile, hasOwnPropertyInPath, hasVisibleExpression, hashCode, immutableExtends, injectPropsToObject, isArrayChildrenModified, isBreakpoint, isClickOnInput, isDisabled, isEmpty, isMobile, isNumeric, isObjectShallowModified, isSuperDataModified, isUnfolded, isVisible, lcFirst, loadScript, makeColumnClassBuild, makeHorizontalDeeper, mapObject, mapTree, noop, normalizeNodePath, object2formData, omitControls, padArr, parseQuery, pickEventsProps, preventDefault, promisify, qsparse, qsstringify, range, removeHTMLTag, repeatCount, rmUndefined, someTree, sortArray, spliceTree, syncDataFromSuper, ucFirst, until, uuid, uuidv4, visibilityFilter };
1293
+ export { JSONTraverse, SkipOperation, __uri, anyChanged, autobind, bulkBindFunctions, camel, chainEvents, chainFunctions, convertArrayValueToMoment, detectPropValueChanged, difference, eachTree, everyTree, filterTree, findIndex, findObjectsWithKey, findTree, findTreeAll, findTreeIndex, flattenTree, flattenTreeWithLeafNodes, getLevelFromClassName, getPropValue, getRange, getScrollParent, getScrollbarWidth, getTree, getTreeAncestors, getTreeDepth, getTreeParent, getWidthRate, guid, hasAbility, hasFile, hasOwnPropertyInPath, hasVisibleExpression, hashCode, immutableExtends, injectPropsToObject, isArrayChildrenModified, isBreakpoint, isClickOnInput, isDisabled, isEmpty, isMobile, isNumeric, isObjectShallowModified, isSuperDataModified, isUnfolded, isVisible, lcFirst, loadScript, loadStyle, makeColumnClassBuild, makeHorizontalDeeper, mapObject, mapTree, noop, normalizeNodePath, object2formData, omitControls, padArr, parseQuery, pickEventsProps, preventDefault, promisify, qsparse, qsstringify, range, removeHTMLTag, repeatCount, rmUndefined, someTree, sortArray, spliceTree, syncDataFromSuper, ucFirst, until, uuid, uuidv4, visibilityFilter };
@@ -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/esm/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
 
@@ -16,6 +16,11 @@ import { isObject } from 'lodash';
16
16
  * @param classNameProp amis 配置里设置的 className
17
17
  */
18
18
  var generateIcon = function (cx, icon, className, classNameProp) {
19
+ if (isObject(icon) &&
20
+ icon.type === 'icon' &&
21
+ icon.icon) {
22
+ icon = icon.icon;
23
+ }
19
24
  if (React.isValidElement(icon)) {
20
25
  return icon;
21
26
  }
@@ -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,14 +1,14 @@
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
- import { parse } from 'amis-formula';
6
+ import { memoryParse } from './memoryParse.js';
7
7
 
8
8
  function isPureVariable(path) {
9
9
  if (typeof path === 'string') {
10
10
  try {
11
- var ast = parse(path);
11
+ var ast = memoryParse(path);
12
12
  // 只有一个成员说明是纯表达式模式
13
13
  return ast.body.length === 1 && ast.body[0].type === 'script';
14
14
  }
@@ -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,26 @@
1
+ /**
2
+ * amis-core v3.1.0
3
+ * Copyright 2018-2023 fex
4
+ */
5
+
6
+ import { parse } from 'amis-formula';
7
+
8
+ var cache = {};
9
+ function memoryParse(input, options) {
10
+ if (options === void 0) { options = {
11
+ evalMode: false
12
+ }; }
13
+ // @todo 优化内存缓存释放,比如只缓存最高频的模版
14
+ if (typeof input !== 'string') {
15
+ return;
16
+ }
17
+ var key = input + JSON.stringify(options);
18
+ if (cache[key]) {
19
+ return cache[key];
20
+ }
21
+ var ast = parse(input, options);
22
+ cache[key] = ast;
23
+ return ast;
24
+ }
25
+
26
+ export { 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
 
@@ -50,7 +50,9 @@ function normalizeOptions(options, share, valueField) {
50
50
  });
51
51
  }
52
52
  else if (Array.isArray(options)) {
53
- return options.map(function (item) {
53
+ return options
54
+ .filter(function (item) { return item !== null && item !== undefined; })
55
+ .map(function (item) {
54
56
  var _a;
55
57
  var value = item && item[valueField];
56
58
  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
 
@@ -25,6 +25,31 @@ function createObject(superProps, props, properties) {
25
25
  Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
26
26
  return obj;
27
27
  }
28
+ function extractObjectChain(value) {
29
+ var result = value ? [value] : [];
30
+ while (value === null || value === void 0 ? void 0 : value.__super) {
31
+ result.unshift(value.__super);
32
+ value = value.__super;
33
+ }
34
+ return result;
35
+ }
36
+ function createObjectFromChain(chain) {
37
+ return chain
38
+ .filter(function (item) { return item; })
39
+ .reduce(function (proto, value) {
40
+ proto = proto || Object.prototype;
41
+ if (Object.isFrozen(proto)) {
42
+ proto = cloneObject(proto);
43
+ }
44
+ return Object.assign(Object.create(proto, {
45
+ __super: {
46
+ value: proto,
47
+ writable: false,
48
+ enumerable: false
49
+ }
50
+ }), value);
51
+ });
52
+ }
28
53
  function cloneObject(target, persistOwnProps) {
29
54
  if (persistOwnProps === void 0) { persistOwnProps = true; }
30
55
  var obj = target && target.__super
@@ -139,4 +164,4 @@ function pickValues(names, data) {
139
164
  return ret;
140
165
  }
141
166
 
142
- export { cloneObject, createObject, deleteVariable, extendObject, isObject, pickValues, setVariable };
167
+ export { cloneObject, createObject, createObjectFromChain, deleteVariable, extendObject, extractObjectChain, isObject, pickValues, 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
 
@@ -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.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;