@whitesev/pops 3.3.5 → 4.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 (81) hide show
  1. package/dist/index.amd.js +13118 -12932
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.amd.min.js +1 -1
  4. package/dist/index.amd.min.js.map +1 -1
  5. package/dist/index.cjs.js +761 -575
  6. package/dist/index.cjs.js.map +1 -1
  7. package/dist/index.cjs.min.js +1 -1
  8. package/dist/index.cjs.min.js.map +1 -1
  9. package/dist/index.esm.js +761 -575
  10. package/dist/index.esm.js.map +1 -1
  11. package/dist/index.esm.min.js +1 -1
  12. package/dist/index.esm.min.js.map +1 -1
  13. package/dist/index.iife.js +13119 -12933
  14. package/dist/index.iife.js.map +1 -1
  15. package/dist/index.iife.min.js +1 -1
  16. package/dist/index.iife.min.js.map +1 -1
  17. package/dist/index.system.js +13122 -12936
  18. package/dist/index.system.js.map +1 -1
  19. package/dist/index.system.min.js +1 -1
  20. package/dist/index.system.min.js.map +1 -1
  21. package/dist/index.umd.js +13121 -12935
  22. package/dist/index.umd.js.map +1 -1
  23. package/dist/index.umd.min.js +1 -1
  24. package/dist/index.umd.min.js.map +1 -1
  25. package/dist/types/src/Pops.d.ts +66 -52
  26. package/dist/types/src/PopsAnimation.d.ts +33 -0
  27. package/dist/types/src/PopsIcon.d.ts +1 -1
  28. package/dist/types/src/components/alert/index.d.ts +3 -1
  29. package/dist/types/src/components/confirm/index.d.ts +3 -1
  30. package/dist/types/src/components/drawer/index.d.ts +3 -1
  31. package/dist/types/src/components/folder/index.d.ts +3 -1
  32. package/dist/types/src/components/iframe/index.d.ts +6 -1
  33. package/dist/types/src/components/iframe/types/index.d.ts +4 -2
  34. package/dist/types/src/components/loading/index.d.ts +3 -1
  35. package/dist/types/src/components/panel/handlerComponents.d.ts +4 -1
  36. package/dist/types/src/components/panel/index.d.ts +2 -16
  37. package/dist/types/src/components/panel/types/index.d.ts +7 -2
  38. package/dist/types/src/components/prompt/index.d.ts +3 -1
  39. package/dist/types/src/components/searchSuggestion/index.d.ts +4 -1
  40. package/dist/types/src/components/tooltip/index.d.ts +5 -1
  41. package/dist/types/src/event/EventEmiter.d.ts +33 -0
  42. package/dist/types/src/handler/PopsHandler.d.ts +16 -11
  43. package/dist/types/src/handler/PopsInstHandler.d.ts +67 -0
  44. package/dist/types/src/types/EventEmitter.d.ts +18 -0
  45. package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +4 -0
  46. package/dist/types/src/types/button.d.ts +2 -1
  47. package/dist/types/src/types/event.d.ts +6 -2
  48. package/dist/types/src/types/inst.d.ts +4 -4
  49. package/dist/types/src/utils/PopsDOMUtils.d.ts +0 -16
  50. package/dist/types/src/utils/PopsInstanceUtils.d.ts +0 -88
  51. package/dist/types/src/utils/PopsUtils.d.ts +57 -0
  52. package/package.json +3 -3
  53. package/src/Pops.ts +7 -2
  54. package/src/PopsAnimation.ts +126 -0
  55. package/src/components/alert/index.ts +9 -9
  56. package/src/components/confirm/index.ts +9 -9
  57. package/src/components/drawer/index.ts +12 -9
  58. package/src/components/folder/index.ts +9 -8
  59. package/src/components/iframe/index.ts +18 -12
  60. package/src/components/iframe/types/index.ts +10 -8
  61. package/src/components/loading/index.ts +12 -6
  62. package/src/components/panel/defaultConfig.ts +1 -0
  63. package/src/components/panel/handlerComponents.ts +41 -111
  64. package/src/components/panel/index.ts +34 -28
  65. package/src/components/panel/types/index.ts +7 -2
  66. package/src/components/prompt/index.ts +9 -8
  67. package/src/components/rightClickMenu/index.ts +17 -14
  68. package/src/components/searchSuggestion/index.ts +5 -1
  69. package/src/components/tooltip/index.ts +20 -10
  70. package/src/event/EventEmiter.ts +95 -0
  71. package/src/handler/PopsElementHandler.ts +6 -4
  72. package/src/handler/PopsHandler.ts +66 -48
  73. package/src/handler/PopsInstHandler.ts +557 -0
  74. package/src/types/EventEmitter.d.ts +18 -0
  75. package/src/types/PopsDOMUtilsEventType.d.ts +4 -0
  76. package/src/types/button.d.ts +2 -1
  77. package/src/types/event.d.ts +6 -2
  78. package/src/types/inst.d.ts +4 -4
  79. package/src/utils/PopsDOMUtils.ts +1 -40
  80. package/src/utils/PopsInstanceUtils.ts +19 -627
  81. package/src/utils/PopsUtils.ts +194 -0
package/dist/index.esm.js CHANGED
@@ -1,3 +1,5 @@
1
+ const version = "4.0.0";
2
+
1
3
  const GlobalConfig = {
2
4
  config: {},
3
5
  /**
@@ -51,6 +53,72 @@ const GlobalConfig = {
51
53
  },
52
54
  };
53
55
 
56
+ class EventEmiter {
57
+ #type;
58
+ #data = new Map();
59
+ constructor(type) {
60
+ this.#type = type;
61
+ }
62
+ on(eventName, callback) {
63
+ const eventList = this.#data.get(eventName) ?? [];
64
+ eventList.push({ type: this.#type, time: Date.now(), callback: callback });
65
+ this.#data.set(eventName, eventList);
66
+ return {
67
+ off: () => {
68
+ this.off(eventName, callback);
69
+ },
70
+ emit: (...args) => {
71
+ this.emit(eventName, ...args);
72
+ },
73
+ };
74
+ }
75
+ off(eventName, callback) {
76
+ const eventList = this.#data.get(eventName) ?? [];
77
+ let isOffSuccess = false;
78
+ for (let index = eventList.length - 1; index >= 0; index--) {
79
+ if (eventList[index].callback === callback) {
80
+ isOffSuccess = true;
81
+ eventList.splice(index, 1);
82
+ }
83
+ }
84
+ if (eventList.length === 0) {
85
+ // empty
86
+ this.#data.delete(eventName);
87
+ }
88
+ else {
89
+ if (isOffSuccess) {
90
+ // update
91
+ this.#data.set(eventName, eventList);
92
+ }
93
+ }
94
+ }
95
+ async emit(eventName, ...args) {
96
+ const eventList = this.#data.get(eventName) ?? [];
97
+ for (const item of eventList) {
98
+ await item.callback(...args);
99
+ }
100
+ }
101
+ offAll(eventName) {
102
+ if (typeof eventName === "string") {
103
+ this.#data.delete(eventName);
104
+ }
105
+ else {
106
+ this.#data.clear();
107
+ }
108
+ }
109
+ /**
110
+ * 获取所有添加的事件
111
+ */
112
+ getAllEvents(eventName) {
113
+ if (typeof eventName === "string") {
114
+ return this.#data.get(eventName);
115
+ }
116
+ else {
117
+ return Array.from(this.#data.values());
118
+ }
119
+ }
120
+ }
121
+
54
122
  var SVG_min = "<svg viewBox=\"0 0 1024 1024\" xmlns=\"http://www.w3.org/2000/svg\" data-type=\"min\">\r\n <path fill=\"currentColor\" d=\"M128 544h768a32 32 0 1 0 0-64H128a32 32 0 0 0 0 64z\"></path>\r\n</svg>\r\n";
55
123
 
56
124
  var SVG_mise = "<svg viewBox=\"0 0 1024 1024\" xmlns=\"http://www.w3.org/2000/svg\" data-type=\"mise\">\r\n <path\r\n fill=\"currentColor\"\r\n d=\"M885.333333 85.333333H330.410667a53.333333 53.333333 0 0 0-53.333334 53.333334v106.666666H138.666667A53.333333 53.333333 0 0 0 85.333333 298.666667v586.666666a53.333333 53.333333 0 0 0 53.333334 53.333334H725.333333a53.333333 53.333333 0 0 0 53.333334-53.333334V746.154667h106.666666c29.44 0 53.333333-23.893333 53.333334-53.333334V138.666667A53.333333 53.333333 0 0 0 885.333333 85.333333zM725.333333 692.821333v192.512H138.666667V298.666667H725.333333v394.154666z m157.866667 0H778.666667V298.666667a53.333333 53.333333 0 0 0-53.333334-53.333334H330.410667v-106.666666h554.922666l-2.133333 554.154666z\"></path>\r\n</svg>\r\n";
@@ -251,6 +319,16 @@ function e(e){e.use(r$2,{name:"doubletap",tapTimes:2});const a=e.get("doubletap"
251
319
  class i extends l$1{constructor(t,u$1){super(t,u$1),this.use(r$2),this.use(u),this.use(a),this.use(c),this.use(r),this.use(i$1);}}i.STATE_POSSIBLE=0,i.STATE_START=4,i.STATE_MOVE=5,i.STATE_END=1,i.STATE_CANCELLED=3,i.STATE_FAILED=2,i.STATE_RECOGNIZED=1,i.tap=r$2,i.pan=u,i.swipe=a,i.press=c,i.rotate=i$1,i.pinch=r,i.doubletap=e;
252
320
 
253
321
  class PopsUtils {
322
+ /**
323
+ * 超时时间
324
+ */
325
+ sleep(timeout) {
326
+ return new Promise((resolve) => {
327
+ setTimeout(() => {
328
+ resolve(true);
329
+ }, timeout);
330
+ });
331
+ }
254
332
  /**
255
333
  * 判断是否是window,例如window、self、globalThis
256
334
  * @param target
@@ -542,6 +620,127 @@ class PopsUtils {
542
620
  }
543
621
  target[key] = newArr;
544
622
  }
623
+ getMaxZIndexNodeInfoFromPoint($el, deviation) {
624
+ if (typeof $el === "function") {
625
+ $el = $el();
626
+ }
627
+ if (typeof $el === "number") {
628
+ deviation = $el;
629
+ $el = void 0;
630
+ }
631
+ if (typeof deviation !== "number" || Number.isNaN(deviation)) {
632
+ deviation = 10;
633
+ }
634
+ const leftTop = {
635
+ x: globalThis.innerWidth * (1 / 8),
636
+ y: globalThis.innerHeight * (1 / 8),
637
+ };
638
+ const leftBottom = {
639
+ x: globalThis.innerWidth * (1 / 8),
640
+ y: globalThis.innerHeight * (7 / 8),
641
+ };
642
+ const rightTop = {
643
+ x: globalThis.innerWidth * (7 / 8),
644
+ y: globalThis.innerHeight * (1 / 8),
645
+ };
646
+ const rightBottom = {
647
+ x: globalThis.innerWidth * (7 / 8),
648
+ y: globalThis.innerHeight * (7 / 8),
649
+ };
650
+ const center = {
651
+ x: globalThis.innerWidth / 2,
652
+ y: globalThis.innerHeight / 2,
653
+ };
654
+ const delayHandlerElementPostionList = [
655
+ leftTop,
656
+ leftBottom,
657
+ rightTop,
658
+ rightBottom,
659
+ center,
660
+ ];
661
+ if ($el) {
662
+ delayHandlerElementPostionList.length = 0;
663
+ if (Array.isArray($el)) {
664
+ delayHandlerElementPostionList.push(...$el);
665
+ }
666
+ else {
667
+ delayHandlerElementPostionList.push($el);
668
+ }
669
+ }
670
+ const positionInfoList = delayHandlerElementPostionList
671
+ .map((position) => {
672
+ let positionNode;
673
+ let positionX;
674
+ let positionY;
675
+ if (position instanceof HTMLElement) {
676
+ positionNode = position;
677
+ const nodeRect = position.getBoundingClientRect();
678
+ positionX = nodeRect.x + nodeRect.width / 2;
679
+ positionY = nodeRect.y + nodeRect.height / 2;
680
+ }
681
+ else {
682
+ positionNode = document.elementFromPoint(position.x, position.y);
683
+ positionX = position.x;
684
+ positionY = position.y;
685
+ }
686
+ const shadowRoot = positionNode?.shadowRoot;
687
+ if (shadowRoot) {
688
+ positionNode = shadowRoot.elementFromPoint(positionX, positionY);
689
+ }
690
+ if (positionNode instanceof HTMLStyleElement)
691
+ return;
692
+ if (positionNode instanceof HTMLScriptElement)
693
+ return;
694
+ if (positionNode instanceof HTMLMetaElement)
695
+ return;
696
+ if (positionNode instanceof HTMLHeadElement)
697
+ return;
698
+ if (!(positionNode instanceof HTMLElement))
699
+ return;
700
+ let parent = positionNode;
701
+ let zIndex = 0;
702
+ let maxZIndexNode = null;
703
+ while (parent) {
704
+ const nodeStyle = globalThis.getComputedStyle(parent);
705
+ const nodeZIndex = parseInt(nodeStyle.zIndex);
706
+ if (nodeStyle.position !== "static" && !isNaN(nodeZIndex)) {
707
+ if (nodeZIndex > zIndex) {
708
+ zIndex = nodeZIndex;
709
+ maxZIndexNode = parent;
710
+ }
711
+ }
712
+ parent = parent.parentElement;
713
+ }
714
+ return {
715
+ /** 处理了偏移量后的z-index值 */
716
+ zIndex: zIndex + deviation,
717
+ /** 原始z-index值 */
718
+ originZIndex: zIndex,
719
+ /** 拥有最大z-index的元素 */
720
+ node: maxZIndexNode,
721
+ /** 目标坐标元素 */
722
+ positionNode: positionNode,
723
+ /** x坐标 */
724
+ positionX: positionX,
725
+ /** y坐标 */
726
+ positionY: positionY,
727
+ };
728
+ })
729
+ .filter((it) => it != null);
730
+ // 降序排序
731
+ positionInfoList.sort((a, b) => {
732
+ if (a.zIndex < b.zIndex) {
733
+ return 1;
734
+ }
735
+ else if (a.zIndex > b.zIndex) {
736
+ return -1;
737
+ }
738
+ else {
739
+ return 0;
740
+ }
741
+ });
742
+ return positionInfoList;
743
+ }
545
744
  }
546
745
  const popsUtils = new PopsUtils();
547
746
 
@@ -832,16 +1031,6 @@ class PopsDOMUtilsEvent {
832
1031
  // 这是存在selector的情况
833
1032
  listenerOption = getOption(args, 4, listenerOption);
834
1033
  }
835
- // 是否移除所有事件
836
- let isRemoveAll = false;
837
- if (args.length === 2) {
838
- // 目标函数、事件名
839
- isRemoveAll = true;
840
- }
841
- else if ((args.length === 3 && typeof args[2] === "string") || Array.isArray(args[2])) {
842
- // 目标函数、事件名、子元素选择器
843
- isRemoveAll = true;
844
- }
845
1034
  if (args.length === 5 && typeof args[4] === "function" && typeof filter !== "function") {
846
1035
  // 目标函数、事件名、回调函数、事件配置、过滤函数
847
1036
  filter = option;
@@ -871,7 +1060,7 @@ class PopsDOMUtilsEvent {
871
1060
  // 事件的配置项不同
872
1061
  flag = false;
873
1062
  }
874
- if (flag || isRemoveAll) {
1063
+ if (flag) {
875
1064
  elementItem.removeEventListener(eventName, handler.callback, handler.option);
876
1065
  const findIndex = handlers.findIndex((item) => item === handler);
877
1066
  if (findIndex !== -1) {
@@ -1263,31 +1452,6 @@ class PopsDOMUtilsEvent {
1263
1452
  const listener = this.on(target, "keydown", handler, option);
1264
1453
  return listener;
1265
1454
  }
1266
- /**
1267
- * 当按键按下时触发事件
1268
- * keydown - > keypress - > keyup
1269
- * @param target 目标
1270
- * @param handler 事件处理函数
1271
- * @param option 配置
1272
- * @example
1273
- * // 监听a.xx元素的按键按下
1274
- * DOMUtils.keypress(document.querySelector("a.xx"),()=>{
1275
- * console.log("按键按下");
1276
- * })
1277
- * DOMUtils.keypress("a.xx",()=>{
1278
- * console.log("按键按下");
1279
- * })
1280
- */
1281
- onKeypress(target, handler, option) {
1282
- if (target == null) {
1283
- return;
1284
- }
1285
- if (typeof target === "string") {
1286
- target = this.selector(target);
1287
- }
1288
- const listener = this.on(target, "keypress", handler, option);
1289
- return listener;
1290
- }
1291
1455
  preventEvent(...args) {
1292
1456
  /**
1293
1457
  * 阻止事件的默认行为发生,并阻止事件传播
@@ -2458,7 +2622,7 @@ const PopsElementHandler = {
2458
2622
  const popsPosition = __config__.position || "";
2459
2623
  if (config.zIndex != null) {
2460
2624
  popsAnimStyle += `z-index: ${zIndex};`;
2461
- popsStyle += `z-index: ${zIndex};`;
2625
+ // popsStyle += `z-index: ${zIndex};`;
2462
2626
  }
2463
2627
  if (__config__.width != null) {
2464
2628
  popsStyle += `width: ${__config__.width};`;
@@ -2467,11 +2631,15 @@ const PopsElementHandler = {
2467
2631
  popsStyle += `height: ${__config__.height};`;
2468
2632
  }
2469
2633
  const hasBottomBtn = bottomBtnHTML.trim() === "" ? false : true;
2634
+ const popsClassNameList = ["pops"];
2635
+ if (config.class) {
2636
+ popsClassNameList.push(...config.class.split(" "));
2637
+ }
2470
2638
  return /*html*/ `
2471
2639
  <div class="pops-anim" anim="${__config__.animation || ""}" style="${popsAnimStyle}" data-guid="${guid}">${config.style != null ? /*html*/ `<style tyle="text/css" data-name="style">${config.style}</style>` : ""}
2472
2640
  ${config.lightStyle != null ? /*html*/ `<style tyle="text/css" data-name="lightStyle">@media (prefers-color-scheme: light) {${config.lightStyle}}</style>` : ""}
2473
2641
  ${config.darkStyle != null ? /*html*/ `<style tyle="text/css" data-name="darkStyle">@media (prefers-color-scheme: dark) {${config.darkStyle}}</style>` : ""}
2474
- <div class="pops ${config.class || ""}" data-bottom-btn="${hasBottomBtn}" type-value="${type}" style="${popsStyle}" position="${popsPosition}" data-guid="${guid}">${html}</div>
2642
+ <div class="${popsClassNameList.join(" ")}" data-bottom-btn="${hasBottomBtn}" type-value="${type}" style="${popsStyle}" position="${popsPosition}" data-guid="${guid}">${html}</div>
2475
2643
  </div>`;
2476
2644
  },
2477
2645
  /**
@@ -2837,6 +3005,105 @@ const PopsAnimation = {
2837
3005
  hasAnim(name) {
2838
3006
  return Object.prototype.hasOwnProperty.call(this.$data, name);
2839
3007
  },
3008
+ /**
3009
+ * 带动画的进入元素
3010
+ * @param $el 当前元素
3011
+ * @param $next 切换的元素
3012
+ * @param option 配置
3013
+ */
3014
+ createSwitchElementWithAnimation($el, $next, option) {
3015
+ const animOptions = {
3016
+ // 150 220 300
3017
+ duration: 220,
3018
+ easing: "ease-in-out",
3019
+ ...(option.animOptions ?? {}),
3020
+ };
3021
+ if (option.useAnimation == null) {
3022
+ option.useAnimation = true;
3023
+ }
3024
+ return {
3025
+ /**
3026
+ * 进入
3027
+ */
3028
+ async enter() {
3029
+ const transitionEndCallback = async () => {
3030
+ // 先直接隐藏旧的容器
3031
+ popsDOMUtils.cssHide($el, true);
3032
+ // 添加元素
3033
+ await option.enterToAddElementCallback();
3034
+ };
3035
+ // 进入下一层
3036
+ if (option.useAnimation && typeof document.startViewTransition == "function") {
3037
+ // 处理添加的元素的动画
3038
+ const transition = document.startViewTransition(transitionEndCallback);
3039
+ await transition.ready;
3040
+ await $next.animate(
3041
+ // 从右向左移入(进入动画)
3042
+ [
3043
+ {
3044
+ // from
3045
+ transform: "translateX(100%)",
3046
+ },
3047
+ {
3048
+ // to
3049
+ transform: "translateX(0)",
3050
+ },
3051
+ ], animOptions).finished;
3052
+ await transition.finished;
3053
+ }
3054
+ else {
3055
+ await transitionEndCallback();
3056
+ }
3057
+ },
3058
+ /**
3059
+ * 退出
3060
+ */
3061
+ async exit() {
3062
+ // 返回上一层菜单
3063
+ const transitionEndCallback = async () => {
3064
+ // 显示上层菜单
3065
+ popsDOMUtils.cssShow($el);
3066
+ // 移除下一层的菜单
3067
+ $next.remove();
3068
+ if (typeof option.exitToRemoveElementCallback === "function") {
3069
+ await option.exitToRemoveElementCallback();
3070
+ }
3071
+ };
3072
+ if (option.useAnimation && typeof document.startViewTransition == "function") {
3073
+ const leaveTransition = document.startViewTransition(transitionEndCallback);
3074
+ await leaveTransition.ready;
3075
+ await Promise.all([
3076
+ // 从原位置向右移出
3077
+ $next.animate([
3078
+ {
3079
+ // from
3080
+ transform: "translateX(0)",
3081
+ },
3082
+ {
3083
+ // to
3084
+ transform: "translateX(100%)",
3085
+ },
3086
+ ], animOptions).finished,
3087
+ // 从最左边向右移入
3088
+ $el.animate([
3089
+ {
3090
+ // from
3091
+ transform: "translateX(-100%)",
3092
+ },
3093
+ {
3094
+ // to
3095
+ transform: "translateX(0)",
3096
+ },
3097
+ ], animOptions).finished,
3098
+ ]);
3099
+ await leaveTransition.finished;
3100
+ }
3101
+ else {
3102
+ await transitionEndCallback();
3103
+ }
3104
+ },
3105
+ };
3106
+ },
2840
3107
  };
2841
3108
 
2842
3109
  /**
@@ -2856,137 +3123,7 @@ const PopsInstData = {
2856
3123
  tooltip: [],
2857
3124
  };
2858
3125
 
2859
- const PopsInstanceUtils = {
2860
- /**
2861
- * 获取页面中最大的z-index的元素信息
2862
- * @param deviation 获取最大的z-index值的偏移,默认是+1
2863
- * @param node 进行判断的元素,默认是document
2864
- * @param ignoreCallBack 执行元素处理时调用的函数,返回false可忽略不想要处理的元素
2865
- * @example
2866
- * Utils.getMaxZIndexNodeInfo();
2867
- * > {
2868
- * node: ...,
2869
- * zIndex: 1001
2870
- * }
2871
- **/
2872
- getMaxZIndexNodeInfo(deviation = 1, target = PopsCore.document, ignoreCallBack) {
2873
- deviation = Number.isNaN(deviation) ? 1 : deviation;
2874
- // 最大值 2147483647
2875
- // const maxZIndex = Math.pow(2, 31) - 1;
2876
- // 比较值 2000000000
2877
- const maxZIndexCompare = 2 * Math.pow(10, 9);
2878
- // 当前页面最大的z-index
2879
- let zIndex = 0;
2880
- // 当前的最大z-index的元素,调试使用
2881
- let maxZIndexNode = null;
2882
- /**
2883
- * 元素是否可见
2884
- * @param $css
2885
- */
2886
- function isVisibleNode($css) {
2887
- return $css.position !== "static" && $css.display !== "none";
2888
- }
2889
- /**
2890
- * 查询元素的z-index
2891
- * 并比较值是否是已获取的最大值
2892
- * @param $ele
2893
- */
2894
- function queryMaxZIndex($ele) {
2895
- if (typeof ignoreCallBack === "function") {
2896
- const ignoreResult = ignoreCallBack($ele);
2897
- if (typeof ignoreResult === "boolean" && !ignoreResult) {
2898
- return;
2899
- }
2900
- }
2901
- /** 元素的样式 */
2902
- const nodeStyle = PopsCore.window.getComputedStyle($ele);
2903
- // 不对position为static和display为none的元素进行获取它们的z-index
2904
- if (isVisibleNode(nodeStyle)) {
2905
- const nodeZIndex = parseInt(nodeStyle.zIndex);
2906
- if (!isNaN(nodeZIndex)) {
2907
- if (nodeZIndex > zIndex) {
2908
- // 赋值到全局
2909
- zIndex = nodeZIndex;
2910
- maxZIndexNode = $ele;
2911
- }
2912
- }
2913
- // 判断shadowRoot
2914
- if ($ele.shadowRoot != null && $ele instanceof ShadowRoot) {
2915
- $ele.shadowRoot.querySelectorAll("*").forEach(($shadowEle) => {
2916
- queryMaxZIndex($shadowEle);
2917
- });
2918
- }
2919
- }
2920
- }
2921
- target.querySelectorAll("*").forEach(($ele) => {
2922
- queryMaxZIndex($ele);
2923
- });
2924
- zIndex += deviation;
2925
- if (zIndex >= maxZIndexCompare) {
2926
- // 最好不要超过最大值
2927
- zIndex = maxZIndexCompare;
2928
- }
2929
- return {
2930
- node: maxZIndexNode,
2931
- zIndex: zIndex,
2932
- };
2933
- },
2934
- /**
2935
- * 获取pops所有弹窗中的最大的z-index
2936
- * @param deviation
2937
- */
2938
- getPopsMaxZIndex(deviation = 1) {
2939
- deviation = Number.isNaN(deviation) ? 1 : deviation;
2940
- // 最大值 2147483647
2941
- // const browserMaxZIndex = Math.pow(2, 31) - 1;
2942
- // 比较值 2000000000
2943
- const maxZIndex = 2 * Math.pow(10, 9);
2944
- // 当前页面最大的z-index
2945
- let zIndex = 0;
2946
- // 当前的最大z-index的元素,调试使用
2947
- let maxZIndexNode = null;
2948
- /**
2949
- * 元素是否可见
2950
- * @param $css
2951
- */
2952
- function isVisibleNode($css) {
2953
- return $css.position !== "static" && $css.display !== "none";
2954
- }
2955
- Object.keys(PopsInstData).forEach((instKeyName) => {
2956
- const instData = PopsInstData[instKeyName];
2957
- for (let index = 0; index < instData.length; index++) {
2958
- const inst = instData[index];
2959
- const nodeStyle = window.getComputedStyle(inst.$anim);
2960
- // 不对position为static和display为none的元素进行获取它们的z-index
2961
- if (isVisibleNode(nodeStyle)) {
2962
- const nodeZIndex = parseInt(nodeStyle.zIndex);
2963
- if (!isNaN(nodeZIndex)) {
2964
- if (nodeZIndex > zIndex) {
2965
- zIndex = nodeZIndex;
2966
- maxZIndexNode = inst.$anim;
2967
- }
2968
- }
2969
- }
2970
- }
2971
- });
2972
- zIndex += deviation;
2973
- const isOverMaxZIndex = zIndex >= maxZIndex;
2974
- if (isOverMaxZIndex) {
2975
- // 超出z-index最大值
2976
- zIndex = maxZIndex;
2977
- }
2978
- return { zIndex: zIndex, animElement: maxZIndexNode, isOverMaxZIndex };
2979
- },
2980
- /**
2981
- * 获取页面中最大的z-index
2982
- * @param deviation 获取最大的z-index值的偏移,默认是+1
2983
- * @example
2984
- * getMaxZIndex();
2985
- * > 1001
2986
- **/
2987
- getMaxZIndex(deviation = 1) {
2988
- return this.getMaxZIndexNodeInfo(deviation).zIndex;
2989
- },
3126
+ const PopsInstHandler = {
2990
3127
  /**
2991
3128
  * 删除配置中对应的对象
2992
3129
  * @param totalInstConfigList 配置实例列表
@@ -2998,21 +3135,21 @@ const PopsInstanceUtils = {
2998
3135
  * 移除元素实例
2999
3136
  * @param instCommonConfig
3000
3137
  */
3001
- const removeInst = function (instCommonConfig) {
3002
- if (typeof instCommonConfig.beforeRemoveCallBack === "function") {
3003
- // 调用移除签的回调
3004
- instCommonConfig.beforeRemoveCallBack(instCommonConfig);
3005
- }
3138
+ const removeInst = async (instCommonConfig) => {
3139
+ await instCommonConfig.emitter.emit("pops:before-destory", instCommonConfig);
3006
3140
  instCommonConfig?.$anim?.remove();
3007
3141
  instCommonConfig?.$pops?.remove();
3008
3142
  instCommonConfig?.$mask?.remove();
3009
3143
  instCommonConfig?.$shadowContainer?.remove();
3144
+ await instCommonConfig.emitter.emit("pops:destory");
3145
+ // 再清空全部监听的事件
3146
+ await instCommonConfig.emitter.offAll();
3010
3147
  };
3011
3148
  const asyncInstTask = [];
3012
3149
  // [ inst[], inst[],...]
3013
- totalInstConfigList.forEach((instConfigList) => {
3014
- // inst[]
3015
- instConfigList.forEach(async (instConfigItem, index) => {
3150
+ for (const instConfigList of totalInstConfigList) {
3151
+ for (let index = 0; index < instConfigList.length; index++) {
3152
+ const instConfigItem = instConfigList[index];
3016
3153
  // 移除全部或者guid相同
3017
3154
  if (isAll || (typeof guid === "string" && instConfigItem.guid === guid)) {
3018
3155
  // 判断是否有动画
@@ -3024,8 +3161,8 @@ const PopsInstanceUtils = {
3024
3161
  popsDOMUtils.css(instConfigItem.$anim, "animation-name", reverseAnimName);
3025
3162
  if (PopsAnimation.hasAnim(popsDOMUtils.css(instConfigItem.$anim, "animation-name"))) {
3026
3163
  asyncInstTask.push(new Promise((resolve) => {
3027
- popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), function () {
3028
- removeInst(instConfigItem);
3164
+ popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), async () => {
3165
+ await removeInst(instConfigItem);
3029
3166
  resolve();
3030
3167
  }, {
3031
3168
  capture: true,
@@ -3033,16 +3170,17 @@ const PopsInstanceUtils = {
3033
3170
  }));
3034
3171
  }
3035
3172
  else {
3036
- removeInst(instConfigItem);
3173
+ asyncInstTask.push(removeInst(instConfigItem));
3037
3174
  }
3038
3175
  }
3039
3176
  else {
3040
- removeInst(instConfigItem);
3177
+ asyncInstTask.push(removeInst(instConfigItem));
3041
3178
  }
3042
3179
  instConfigList.splice(index, 1);
3180
+ index--;
3043
3181
  }
3044
- });
3045
- });
3182
+ }
3183
+ }
3046
3184
  await Promise.all(asyncInstTask);
3047
3185
  return totalInstConfigList;
3048
3186
  },
@@ -3056,61 +3194,72 @@ const PopsInstanceUtils = {
3056
3194
  * @param $mask
3057
3195
  */
3058
3196
  hide(config, popsType, instConfigList, guid, $anim, $mask) {
3059
- return new Promise((resolve) => {
3197
+ // oxlint-disable-next-line no-async-promise-executor
3198
+ return new Promise(async (resolve) => {
3060
3199
  const $pops = $anim.querySelector(".pops[type-value]");
3061
- if (popsType === "drawer") {
3062
- const drawerConfig = config;
3063
- popsUtils.setTimeout(() => {
3064
- if ($mask) {
3065
- popsDOMUtils.css($mask, "display", "none");
3066
- }
3067
- if (["top", "bottom"].includes(drawerConfig.direction)) {
3068
- $pops.style.setProperty("height", "0");
3069
- }
3070
- else if (["left", "right"].includes(drawerConfig.direction)) {
3071
- $pops.style.setProperty("width", "0");
3200
+ const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
3201
+ if (fintInst) {
3202
+ // 存在实例
3203
+ const startAnim = async () => {
3204
+ if (popsType === "drawer") {
3205
+ // drawer是抽屉
3206
+ // 单独处理动画
3207
+ const drawerConfig = config;
3208
+ await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3209
+ if ($mask) {
3210
+ popsDOMUtils.css($mask, "display", "none");
3211
+ }
3212
+ const direction = drawerConfig.direction;
3213
+ const size = "0";
3214
+ if (["top", "bottom"].includes(direction)) {
3215
+ $pops.style.setProperty("height", size);
3216
+ }
3217
+ else if (["left", "right"].includes(direction)) {
3218
+ $pops.style.setProperty("width", size);
3219
+ }
3220
+ else {
3221
+ console.error("未知direction: ", direction);
3222
+ }
3072
3223
  }
3073
3224
  else {
3074
- console.error("未知direction:", drawerConfig.direction);
3225
+ instConfigItem.$anim.style.width = "100%";
3226
+ instConfigItem.$anim.style.height = "100%";
3227
+ Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim") + "-reverse");
3075
3228
  }
3076
- resolve();
3077
- }, drawerConfig.closeDelay);
3078
- }
3079
- else {
3080
- const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
3081
- if (fintInst) {
3082
- // 存在动画
3083
- const instConfigItem = fintInst;
3084
- instConfigItem.$anim.style.width = "100%";
3085
- instConfigItem.$anim.style.height = "100%";
3086
- Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim") + "-reverse");
3087
- if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
3088
- /**
3089
- * 动画结束的回调
3090
- */
3091
- function animationendCallBack() {
3092
- instConfigItem.$anim.style.display = "none";
3093
- if (instConfigItem.$mask) {
3094
- instConfigItem.$mask.style.display = "none";
3095
- }
3096
- popsDOMUtils.off(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3097
- capture: true,
3098
- });
3099
- resolve();
3100
- }
3101
- popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3102
- capture: true,
3103
- });
3229
+ };
3230
+ const endCallback = () => {
3231
+ instConfigItem.$anim.style.display = "none";
3232
+ if (instConfigItem.$mask) {
3233
+ instConfigItem.$mask.style.display = "none";
3104
3234
  }
3105
- else {
3106
- instConfigItem.$anim.style.display = "none";
3107
- if (instConfigItem.$mask) {
3108
- instConfigItem.$mask.style.display = "none";
3109
- }
3235
+ fintInst.emitter.emit("pops:hide", instConfigItem);
3236
+ };
3237
+ const instConfigItem = fintInst;
3238
+ fintInst.emitter.emit("pops:before-hide", instConfigItem);
3239
+ await startAnim();
3240
+ if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
3241
+ /**
3242
+ * 动画结束的回调
3243
+ */
3244
+ const animationendCallBack = () => {
3245
+ listener.off();
3246
+ endCallback();
3110
3247
  resolve();
3111
- }
3248
+ };
3249
+ const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3250
+ capture: true,
3251
+ once: true,
3252
+ });
3253
+ }
3254
+ else {
3255
+ endCallback();
3256
+ resolve();
3112
3257
  }
3113
3258
  }
3259
+ else {
3260
+ console.error("hide-error: 该实例未存储");
3261
+ resolve();
3262
+ }
3114
3263
  });
3115
3264
  },
3116
3265
  /**
@@ -3123,62 +3272,70 @@ const PopsInstanceUtils = {
3123
3272
  * @param $mask
3124
3273
  */
3125
3274
  show(config, popsType, instConfigList, guid, $anim, $mask) {
3126
- return new Promise((resolve) => {
3275
+ // oxlint-disable-next-line no-async-promise-executor
3276
+ return new Promise(async (resolve) => {
3127
3277
  const $pops = $anim.querySelector(".pops[type-value]");
3128
- if (popsType === "drawer") {
3129
- const drawerConfig = config;
3130
- popsUtils.setTimeout(() => {
3131
- if ($mask) {
3132
- popsDOMUtils.css($mask, "display", "");
3133
- }
3134
- const direction = drawerConfig.direction;
3135
- const size = drawerConfig.size.toString();
3136
- if (["top", "bottom"].includes(direction)) {
3137
- $pops.style.setProperty("height", size);
3138
- }
3139
- else if (["left", "right"].includes(direction)) {
3140
- $pops.style.setProperty("width", size);
3141
- }
3142
- else {
3143
- console.error("未知direction:", direction);
3144
- }
3145
- resolve();
3146
- }, drawerConfig.openDelay ?? 0);
3147
- }
3148
- else {
3149
- const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
3150
- if (fintInst) {
3151
- const instConfigItem = fintInst;
3152
- instConfigItem.$anim.style.width = "";
3153
- instConfigItem.$anim.style.height = "";
3154
- Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim").replace("-reverse", ""));
3155
- if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
3156
- /**
3157
- * 动画结束的回调
3158
- */
3159
- function animationendCallBack() {
3160
- popsDOMUtils.off(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3161
- capture: true,
3162
- });
3163
- resolve();
3278
+ const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
3279
+ if (fintInst) {
3280
+ const startAnim = async () => {
3281
+ if (popsType === "drawer") {
3282
+ // drawer是抽屉
3283
+ // 单独处理动画
3284
+ const drawerConfig = config;
3285
+ await popsUtils.sleep(drawerConfig.openDelay ?? 0);
3286
+ if ($mask) {
3287
+ popsDOMUtils.css($mask, "display", "");
3164
3288
  }
3165
- instConfigItem.$anim.style.display = "";
3166
- if (instConfigItem.$mask) {
3167
- instConfigItem.$mask.style.display = "";
3289
+ const direction = drawerConfig.direction;
3290
+ const size = drawerConfig.size.toString();
3291
+ if (["top", "bottom"].includes(direction)) {
3292
+ $pops.style.setProperty("height", size);
3293
+ }
3294
+ else if (["left", "right"].includes(direction)) {
3295
+ $pops.style.setProperty("width", size);
3296
+ }
3297
+ else {
3298
+ console.error("未知direction:", direction);
3168
3299
  }
3169
- popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3170
- capture: true,
3171
- });
3172
3300
  }
3173
3301
  else {
3174
- instConfigItem.$anim.style.display = "";
3175
- if (instConfigItem.$mask) {
3176
- instConfigItem.$mask.style.display = "";
3177
- }
3178
- resolve();
3302
+ instConfigItem.$anim.style.width = "";
3303
+ instConfigItem.$anim.style.height = "";
3304
+ Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim").replace("-reverse", ""));
3305
+ }
3306
+ };
3307
+ const endCallback = () => {
3308
+ instConfigItem.$anim.style.display = "";
3309
+ if (instConfigItem.$mask) {
3310
+ instConfigItem.$mask.style.display = "";
3179
3311
  }
3312
+ fintInst.emitter.emit("pops:show", instConfigItem);
3313
+ };
3314
+ const instConfigItem = fintInst;
3315
+ fintInst.emitter.emit("pops:before-show", instConfigItem);
3316
+ await startAnim();
3317
+ if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
3318
+ /**
3319
+ * 动画结束的回调
3320
+ */
3321
+ const animationendCallBack = () => {
3322
+ listener.off();
3323
+ endCallback();
3324
+ resolve();
3325
+ };
3326
+ const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3327
+ capture: true,
3328
+ });
3329
+ }
3330
+ else {
3331
+ endCallback();
3332
+ resolve();
3180
3333
  }
3181
3334
  }
3335
+ else {
3336
+ console.error("show-error: 该实例未存储");
3337
+ resolve();
3338
+ }
3182
3339
  });
3183
3340
  },
3184
3341
  /**
@@ -3190,30 +3347,53 @@ const PopsInstanceUtils = {
3190
3347
  * @param $anim
3191
3348
  */
3192
3349
  async close(config, popsType, instConfigList, guid, $anim) {
3350
+ // 判断组件内部是否有rightClickMenu、tooltip、searchSuggestion组件
3351
+ // 有的话也需要关闭
3352
+ PopsInstData.rightClickMenu.forEach((itemConfig) => {
3353
+ const config = itemConfig.config;
3354
+ if (config.$target instanceof HTMLElement) {
3355
+ const $root = config.$target.getRootNode();
3356
+ if ($root instanceof HTMLElement && $root.parentElement == null) {
3357
+ // 触发销毁元素
3358
+ itemConfig.emitter.emit("pops:before-destory", itemConfig);
3359
+ }
3360
+ }
3361
+ });
3362
+ PopsInstData.tooltip.forEach((itemConfig) => {
3363
+ const config = itemConfig.config;
3364
+ if (config.$target instanceof HTMLElement) {
3365
+ const $root = config.$target.getRootNode();
3366
+ if ($root instanceof HTMLElement && $root.parentElement == null) {
3367
+ // 触发销毁元素
3368
+ itemConfig.emitter.emit("pops:before-destory", itemConfig);
3369
+ }
3370
+ }
3371
+ });
3193
3372
  // eslint-disable-next-line no-async-promise-executor
3194
3373
  await new Promise(async (resolve) => {
3195
3374
  const $pops = $anim.querySelector(".pops[type-value]");
3196
3375
  const drawerConfig = config;
3197
- /**
3198
- * 动画结束事件
3199
- */
3200
- function transitionendEvent() {
3376
+ const start = () => {
3201
3377
  /**
3202
3378
  * 弹窗已关闭的回调
3203
3379
  */
3204
- async function closeCallBack(event) {
3380
+ const transtionEndCallback = async (event) => {
3205
3381
  if (event.propertyName !== "transform") {
3206
3382
  return;
3207
3383
  }
3208
- popsDOMUtils.off($pops, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
3209
- await PopsInstanceUtils.removeInstance([instConfigList], guid);
3384
+ listener.off();
3385
+ await PopsInstHandler.removeInstance([instConfigList], guid);
3210
3386
  resolve();
3211
- }
3387
+ };
3212
3388
  // 监听过渡结束
3213
- popsDOMUtils.on($pops, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
3214
- const popsTransForm = getComputedStyle($pops).transform;
3389
+ const listener = popsDOMUtils.on($pops, popsDOMUtils.getTransitionEndNameList(), transtionEndCallback, {
3390
+ once: true,
3391
+ });
3392
+ const popsTransForm = globalThis.getComputedStyle($pops).transform;
3215
3393
  if (popsTransForm !== "none") {
3216
- popsDOMUtils.emit($pops, popsDOMUtils.getTransitionEndNameList(), void 0, true);
3394
+ // 不存在动画
3395
+ // 直接移除实例
3396
+ listener.emit({ propertyName: "transform" });
3217
3397
  return;
3218
3398
  }
3219
3399
  if (["top"].includes(drawerConfig.direction)) {
@@ -3229,41 +3409,18 @@ const PopsInstanceUtils = {
3229
3409
  $pops.style.setProperty("transform", "translateX(100%)");
3230
3410
  }
3231
3411
  else {
3232
- console.error("未知direction", drawerConfig.direction);
3412
+ console.error("未知direction: ", drawerConfig.direction);
3233
3413
  }
3234
- }
3414
+ };
3235
3415
  if (popsType === "drawer") {
3236
- popsUtils.setTimeout(() => {
3237
- transitionendEvent();
3238
- }, drawerConfig.closeDelay);
3416
+ await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3417
+ start();
3239
3418
  }
3240
3419
  else {
3241
- await PopsInstanceUtils.removeInstance([instConfigList], guid);
3420
+ await PopsInstHandler.removeInstance([instConfigList], guid);
3242
3421
  resolve();
3243
3422
  }
3244
3423
  });
3245
- // 判断组件内是否有rightClickMenu、tooltip、searchSuggestion组件
3246
- // 有的话也需要关闭
3247
- PopsInstData.rightClickMenu.forEach((itemConfig) => {
3248
- const config = itemConfig.config;
3249
- if (config.$target instanceof HTMLElement) {
3250
- const $root = config.$target.getRootNode();
3251
- if ($root instanceof HTMLElement && $root.parentElement == null) {
3252
- // 触发销毁元素
3253
- itemConfig.destory();
3254
- }
3255
- }
3256
- });
3257
- PopsInstData.tooltip.forEach((itemConfig) => {
3258
- const config = itemConfig.config;
3259
- if (config.$target instanceof HTMLElement) {
3260
- const $root = config.$target.getRootNode();
3261
- if ($root instanceof HTMLElement && $root.parentElement == null) {
3262
- // 触发销毁元素
3263
- itemConfig.destory();
3264
- }
3265
- }
3266
- });
3267
3424
  },
3268
3425
  /**
3269
3426
  * 拖拽元素
@@ -3351,17 +3508,10 @@ const PopsInstanceUtils = {
3351
3508
  clickElementLeftOffset = event.x - rect.left;
3352
3509
  clickElementTopOffset = event.y - rect.top;
3353
3510
  transformInfo = popsDOMUtils.getTransform($move);
3354
- //if (event.nativeEvent.offsetX) {
3355
- // clickElementLeftOffset = parseInt(event.nativeEvent.offsetX);
3356
- //} else {
3357
- // clickElementLeftOffset = parseInt(event.getOffset().x);
3358
- //}
3359
- //if (event.nativeEvent.offsetY) {
3360
- // clickElementTopOffset = parseInt(event.nativeEvent.offsetY);
3361
- //} else {
3362
- // clickElementTopOffset = parseInt(event.getOffset().y);
3363
- //}
3364
3511
  resumeMoveElementStyle = changeMoveElementStyle($move);
3512
+ if (typeof options.startCallBack === "function") {
3513
+ options.startCallBack($move, clickElementLeftOffset, clickElementTopOffset);
3514
+ }
3365
3515
  }
3366
3516
  /** 当前移动的left偏移 */
3367
3517
  let currentMoveLeftOffset = event.x - clickElementLeftOffset + transformInfo.transformLeft;
@@ -3438,46 +3588,6 @@ const PopsInstanceUtils = {
3438
3588
  });
3439
3589
  }
3440
3590
  },
3441
- /**
3442
- * 排序数组
3443
- * @param getBeforeValueFun
3444
- * @param getAfterValueFun
3445
- * @param sortByDesc 排序是否降序,默认降序
3446
- */
3447
- sortElementListByProperty(getBeforeValueFun, getAfterValueFun, sortByDesc = true) {
3448
- if (typeof sortByDesc !== "boolean") {
3449
- throw new TypeError("参数 sortByDesc 必须为boolean类型");
3450
- }
3451
- if (getBeforeValueFun == null || getAfterValueFun == null) {
3452
- throw new Error("获取前面的值或后面的值的方法不能为空");
3453
- }
3454
- return function (after_obj, before_obj) {
3455
- const beforeValue = getBeforeValueFun(before_obj); // 前
3456
- const afterValue = getAfterValueFun(after_obj); // 后
3457
- if (sortByDesc) {
3458
- if (afterValue > beforeValue) {
3459
- return -1;
3460
- }
3461
- else if (afterValue < beforeValue) {
3462
- return 1;
3463
- }
3464
- else {
3465
- return 0;
3466
- }
3467
- }
3468
- else {
3469
- if (afterValue < beforeValue) {
3470
- return -1;
3471
- }
3472
- else if (afterValue > beforeValue) {
3473
- return 1;
3474
- }
3475
- else {
3476
- return 0;
3477
- }
3478
- }
3479
- };
3480
- },
3481
3591
  };
3482
3592
 
3483
3593
  const PopsHandler = {
@@ -3591,11 +3701,11 @@ const PopsHandler = {
3591
3701
  function originalRun() {
3592
3702
  if (config.config.mask.clickEvent.toClose) {
3593
3703
  // 关闭
3594
- return PopsInstanceUtils.close(config.config, config.type, targetInst, config.guid, config.animElement);
3704
+ return PopsInstHandler.close(config.config, config.type, targetInst, config.guid, config.animElement);
3595
3705
  }
3596
3706
  else if (config.config.mask.clickEvent.toHide) {
3597
3707
  // 隐藏
3598
- return PopsInstanceUtils.hide(config.config, config.type, targetInst, config.guid, config.animElement, result.maskElement);
3708
+ return PopsInstHandler.hide(config.config, config.type, targetInst, config.guid, config.animElement, result.maskElement);
3599
3709
  }
3600
3710
  }
3601
3711
  if (typeof config.config.mask.clickCallBack === "function") {
@@ -3782,7 +3892,7 @@ const PopsHandler = {
3782
3892
  * @param $mask 遮罩层
3783
3893
  * @param config 当前配置
3784
3894
  */
3785
- handleEventConfig(config, guid, $shadowContainer, $shadowRoot, type, $anim, $pops, $mask) {
3895
+ handleEventConfig(config, guid, $shadowContainer, $shadowRoot, type, $anim, $pops, emitter, $mask) {
3786
3896
  return {
3787
3897
  $shadowContainer: $shadowContainer,
3788
3898
  $shadowRoot: $shadowRoot,
@@ -3792,17 +3902,18 @@ const PopsHandler = {
3792
3902
  $mask: $mask,
3793
3903
  mode: type,
3794
3904
  guid: guid,
3905
+ emitter: emitter,
3795
3906
  close() {
3796
- return PopsInstanceUtils.close(config, type, PopsInstData[type], guid, $anim);
3907
+ return PopsInstHandler.close(config, type, PopsInstData[type], guid, $anim);
3797
3908
  },
3798
3909
  hide() {
3799
- return PopsInstanceUtils.hide(config, type, PopsInstData[type], guid, $anim, $mask);
3910
+ return PopsInstHandler.hide(config, type, PopsInstData[type], guid, $anim, $mask);
3800
3911
  },
3801
3912
  show($parent) {
3802
3913
  if ($parent) {
3803
3914
  $parent.appendChild(PopsInstData[type][0].$shadowRoot);
3804
3915
  }
3805
- return PopsInstanceUtils.show(config, type, PopsInstData[type], guid, $anim, $mask);
3916
+ return PopsInstHandler.show(config, type, PopsInstData[type], guid, $anim, $mask);
3806
3917
  },
3807
3918
  };
3808
3919
  },
@@ -3815,7 +3926,7 @@ const PopsHandler = {
3815
3926
  * @param $mask 遮罩层
3816
3927
  * @param config 当前配置
3817
3928
  */
3818
- handleLoadingEventConfig(config, guid, type, $anim, $pops, $mask) {
3929
+ handleLoadingEventConfig(config, guid, type, $anim, $pops, emitter, $mask) {
3819
3930
  return {
3820
3931
  $el: $anim,
3821
3932
  $anim: $anim,
@@ -3823,14 +3934,15 @@ const PopsHandler = {
3823
3934
  $mask: $mask,
3824
3935
  mode: type,
3825
3936
  guid: guid,
3937
+ emitter,
3826
3938
  close() {
3827
- return PopsInstanceUtils.close(config, type, PopsInstData[type], guid, $anim);
3939
+ return PopsInstHandler.close(config, type, PopsInstData[type], guid, $anim);
3828
3940
  },
3829
3941
  hide() {
3830
- return PopsInstanceUtils.hide(config, type, PopsInstData[type], guid, $anim, $mask);
3942
+ return PopsInstHandler.hide(config, type, PopsInstData[type], guid, $anim, $mask);
3831
3943
  },
3832
3944
  show() {
3833
- return PopsInstanceUtils.show(config, type, PopsInstData[type], guid, $anim, $mask);
3945
+ return PopsInstHandler.show(config, type, PopsInstData[type], guid, $anim, $mask);
3834
3946
  },
3835
3947
  };
3836
3948
  },
@@ -3854,7 +3966,7 @@ const PopsHandler = {
3854
3966
  handleClickEvent(type, $btn, eventConfig, callback) {
3855
3967
  if (typeof callback !== "function")
3856
3968
  return;
3857
- popsDOMUtils.on($btn, "click", (event) => {
3969
+ return popsDOMUtils.on($btn, "click", (event) => {
3858
3970
  const extraParam = {
3859
3971
  type: type,
3860
3972
  };
@@ -3892,16 +4004,10 @@ const PopsHandler = {
3892
4004
  callback && callback(event);
3893
4005
  }
3894
4006
  };
3895
- popsDOMUtils.on(PopsCore.globalThis, "keydown", keyboardEvent, {
4007
+ const listener = popsDOMUtils.on(PopsCore.globalThis, "keydown", keyboardEvent, {
3896
4008
  capture: true,
3897
4009
  });
3898
- return {
3899
- removeKeyboardEvent() {
3900
- popsDOMUtils.off(globalThis, "keydown", keyboardEvent, {
3901
- capture: true,
3902
- });
3903
- },
3904
- };
4010
+ return listener;
3905
4011
  },
3906
4012
  /**
3907
4013
  * 处理prompt的点击事件
@@ -3924,15 +4030,16 @@ const PopsHandler = {
3924
4030
  });
3925
4031
  },
3926
4032
  /**
3927
- * 把配置的z-index配置转为数字
3928
- * @param zIndex
4033
+ * 获取数值
4034
+ * @param target
3929
4035
  */
3930
- handleZIndex(zIndex) {
3931
- if (typeof zIndex === "function") {
3932
- return zIndex();
4036
+ getTargerOrFunctionValue(target) {
4037
+ if (typeof target === "function") {
4038
+ const result = target();
4039
+ return result;
3933
4040
  }
3934
4041
  else {
3935
- return zIndex;
4042
+ return target;
3936
4043
  }
3937
4044
  },
3938
4045
  /**
@@ -3949,11 +4056,11 @@ const PopsHandler = {
3949
4056
  if (type === "loading" || type === "tooltip" || type === "rightClickMenu") {
3950
4057
  const inst = PopsInstData[type];
3951
4058
  if (inst) {
3952
- PopsInstanceUtils.removeInstance([inst], "", true);
4059
+ PopsInstHandler.removeInstance([inst], "", true);
3953
4060
  }
3954
4061
  }
3955
4062
  else {
3956
- PopsInstanceUtils.removeInstance([
4063
+ PopsInstHandler.removeInstance([
3957
4064
  PopsInstData.alert,
3958
4065
  PopsInstData.confirm,
3959
4066
  PopsInstData.drawer,
@@ -3964,15 +4071,30 @@ const PopsHandler = {
3964
4071
  ], "", true);
3965
4072
  }
3966
4073
  }
3967
- else {
3968
- // 对配置进行处理
3969
- // 选择配置的z-index和已有的pops实例的最大z-index值
3970
- const originZIndex = config.zIndex;
3971
- config.zIndex = () => {
3972
- const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(PopsHandler.handleZIndex(originZIndex) + 100);
3973
- return maxZIndex;
3974
- };
3975
- }
4074
+ config = this.handleZIndex(config);
4075
+ return config;
4076
+ },
4077
+ /**
4078
+ * 处理z-index
4079
+ * @param config 配置
4080
+ */
4081
+ handleZIndex(config) {
4082
+ // 对配置进行处理
4083
+ // 选择配置的z-index和已有的pops实例的最大z-index值
4084
+ const originZIndex = config.zIndex;
4085
+ const handler = () => {
4086
+ let deviation = 100;
4087
+ if (originZIndex.toString() !== handler.toString()) {
4088
+ // 避免叠加覆盖
4089
+ deviation += PopsHandler.getTargerOrFunctionValue(originZIndex) ?? 0;
4090
+ }
4091
+ let maxZIndex = deviation;
4092
+ const pointZIndexInfoList = popsUtils.getMaxZIndexNodeInfoFromPoint(deviation);
4093
+ const pointZIndexInfo = pointZIndexInfoList[0];
4094
+ maxZIndex = Math.max(maxZIndex, pointZIndexInfo?.zIndex ?? deviation);
4095
+ return maxZIndex;
4096
+ };
4097
+ config.zIndex = handler;
3976
4098
  return config;
3977
4099
  },
3978
4100
  /**
@@ -4054,6 +4176,7 @@ const PopsAlert = {
4054
4176
  const guid = popsUtils.getRandomGUID();
4055
4177
  // 设置当前类型
4056
4178
  const popsType = "alert";
4179
+ const emitter = new EventEmiter(popsType);
4057
4180
  let config = PopsAlertDefaultConfig();
4058
4181
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4059
4182
  config = popsUtils.assign(config, __config__);
@@ -4090,7 +4213,7 @@ const PopsAlert = {
4090
4213
  },
4091
4214
  ]);
4092
4215
  // 先把z-index提取出来
4093
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
4216
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
4094
4217
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
4095
4218
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
4096
4219
  const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
@@ -4126,7 +4249,7 @@ const PopsAlert = {
4126
4249
  $elList.push($mask);
4127
4250
  }
4128
4251
  // 处理返回的配置
4129
- const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
4252
+ const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
4130
4253
  const result = PopsHandler.handleResultConfig(evtConfig);
4131
4254
  // 为顶部右边的关闭按钮添加点击事件
4132
4255
  PopsHandler.handleClickEvent("close", $headerCloseBtn, evtConfig, config.btn.close?.callback);
@@ -4134,9 +4257,7 @@ const PopsAlert = {
4134
4257
  PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok?.callback);
4135
4258
  // 创建到页面中
4136
4259
  popsDOMUtils.append($shadowRoot, $elList);
4137
- if (typeof config.beforeAppendToPageCallBack === "function") {
4138
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
4139
- }
4260
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
4140
4261
  popsDOMUtils.appendBody($shadowContainer);
4141
4262
  if ($mask != null) {
4142
4263
  // 添加遮罩层
@@ -4151,11 +4272,11 @@ const PopsAlert = {
4151
4272
  $shadowContainer: $shadowContainer,
4152
4273
  $shadowRoot: $shadowRoot,
4153
4274
  config: config,
4154
- destory: result.close,
4275
+ emitter,
4155
4276
  });
4156
4277
  // 拖拽
4157
4278
  if (config.drag) {
4158
- PopsInstanceUtils.drag($pops, {
4279
+ PopsInstHandler.drag($pops, {
4159
4280
  dragElement: $title,
4160
4281
  limit: config.dragLimit,
4161
4282
  extraDistance: config.dragExtraDistance,
@@ -4263,6 +4384,7 @@ const PopsConfirm = {
4263
4384
  const guid = popsUtils.getRandomGUID();
4264
4385
  // 设置当前类型
4265
4386
  const popsType = "confirm";
4387
+ const emitter = new EventEmiter(popsType);
4266
4388
  let config = PopsConfirmDefaultConfig();
4267
4389
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4268
4390
  config = popsUtils.assign(config, __config__);
@@ -4299,7 +4421,7 @@ const PopsConfirm = {
4299
4421
  },
4300
4422
  ]);
4301
4423
  // 先把z-index提取出来
4302
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
4424
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
4303
4425
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
4304
4426
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
4305
4427
  const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
@@ -4338,7 +4460,7 @@ const PopsConfirm = {
4338
4460
  $mask = handleMask.maskElement;
4339
4461
  $elList.push($mask);
4340
4462
  }
4341
- const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
4463
+ const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
4342
4464
  const result = PopsHandler.handleResultConfig(evtConfig);
4343
4465
  PopsHandler.handleClickEvent("close", $btnClose, evtConfig, config.btn.close.callback);
4344
4466
  PopsHandler.handleClickEvent("ok", $btnOk, evtConfig, config.btn.ok.callback);
@@ -4346,9 +4468,7 @@ const PopsConfirm = {
4346
4468
  PopsHandler.handleClickEvent("other", $btnOther, evtConfig, config.btn.other.callback);
4347
4469
  // 创建到页面中
4348
4470
  popsDOMUtils.append($shadowRoot, $elList);
4349
- if (typeof config.beforeAppendToPageCallBack === "function") {
4350
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
4351
- }
4471
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
4352
4472
  popsDOMUtils.appendBody($shadowContainer);
4353
4473
  if ($mask != null) {
4354
4474
  $anim.after($mask);
@@ -4361,11 +4481,11 @@ const PopsConfirm = {
4361
4481
  $shadowContainer: $shadowContainer,
4362
4482
  $shadowRoot: $shadowRoot,
4363
4483
  config: config,
4364
- destory: result.close,
4484
+ emitter,
4365
4485
  });
4366
4486
  // 拖拽
4367
4487
  if (config.drag) {
4368
- PopsInstanceUtils.drag($pops, {
4488
+ PopsInstHandler.drag($pops, {
4369
4489
  dragElement: $title,
4370
4490
  limit: config.dragLimit,
4371
4491
  extraDistance: config.dragExtraDistance,
@@ -4472,6 +4592,7 @@ const PopsDrawer = {
4472
4592
  const guid = popsUtils.getRandomGUID();
4473
4593
  // 设置当前类型
4474
4594
  const popsType = "drawer";
4595
+ const emitter = new EventEmiter(popsType);
4475
4596
  let config = PopsDrawerDefaultConfig();
4476
4597
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4477
4598
  config = popsUtils.assign(config, __config__);
@@ -4508,7 +4629,7 @@ const PopsDrawer = {
4508
4629
  },
4509
4630
  ]);
4510
4631
  // 先把z-index提取出来
4511
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
4632
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
4512
4633
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
4513
4634
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
4514
4635
  const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
@@ -4553,7 +4674,7 @@ const PopsDrawer = {
4553
4674
  $mask = handleMask.maskElement;
4554
4675
  $elList.push($mask);
4555
4676
  }
4556
- const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
4677
+ const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
4557
4678
  const result = PopsHandler.handleResultConfig(evtConfig);
4558
4679
  // 处理方向
4559
4680
  $pops.setAttribute("direction", config.direction);
@@ -4577,9 +4698,12 @@ const PopsDrawer = {
4577
4698
  }
4578
4699
  // 按下Esc键触发关闭
4579
4700
  if (config.closeOnPressEscape) {
4580
- PopsHandler.handleKeyboardEvent("Escape", [], function () {
4701
+ const listener = PopsHandler.handleKeyboardEvent("Escape", [], function () {
4581
4702
  evtConfig.close();
4582
4703
  });
4704
+ emitter.on("pops:destory", () => {
4705
+ listener.off();
4706
+ });
4583
4707
  }
4584
4708
  // 待处理的点击事件列表
4585
4709
  const needHandleClickEventList = [
@@ -4631,9 +4755,7 @@ const PopsDrawer = {
4631
4755
  });
4632
4756
  // 创建到页面中
4633
4757
  popsDOMUtils.append($shadowRoot, $elList);
4634
- if (typeof config.beforeAppendToPageCallBack === "function") {
4635
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
4636
- }
4758
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
4637
4759
  popsDOMUtils.appendBody($shadowContainer);
4638
4760
  popsUtils.setTimeout(() => {
4639
4761
  popsUtils.setTimeout(() => {
@@ -4651,7 +4773,7 @@ const PopsDrawer = {
4651
4773
  $shadowContainer: $shadowContainer,
4652
4774
  $shadowRoot: $shadowRoot,
4653
4775
  config: config,
4654
- destory: result.close,
4776
+ emitter: emitter,
4655
4777
  });
4656
4778
  return result;
4657
4779
  },
@@ -4693,12 +4815,13 @@ const PopsLoading = {
4693
4815
  const guid = popsUtils.getRandomGUID();
4694
4816
  // 设置当前类型
4695
4817
  const PopsType = "loading";
4818
+ const emitter = new EventEmiter(PopsType);
4696
4819
  let config = PopsLoadingDefaultConfig();
4697
4820
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4698
4821
  config = popsUtils.assign(config, __config__);
4699
4822
  config = PopsHandler.handleOnly(PopsType, config);
4700
4823
  // 先把z-index提取出来
4701
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
4824
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
4702
4825
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
4703
4826
  const { contentPStyle } = PopsElementHandler.createContentStyle("loading", config);
4704
4827
  const animHTML = PopsElementHandler.createAnim(guid, PopsType, config,
@@ -4741,17 +4864,20 @@ const PopsLoading = {
4741
4864
  $mask = handleMask.maskElement;
4742
4865
  $elList.push($mask);
4743
4866
  }
4744
- const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, $mask);
4867
+ const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, emitter, $mask);
4745
4868
  popsDOMUtils.append(config.$parent, $elList);
4746
4869
  if ($mask != null) {
4747
4870
  $anim.after($mask);
4748
4871
  }
4749
- // @ts-ignore
4750
4872
  PopsHandler.handlePush(PopsType, {
4873
+ $shadowContainer: $pops,
4874
+ $shadowRoot: $pops,
4751
4875
  guid: guid,
4752
4876
  $anim: $anim,
4753
4877
  $pops: $pops,
4754
4878
  $mask: $mask,
4879
+ emitter: emitter,
4880
+ config: config,
4755
4881
  });
4756
4882
  if (config.isAbsolute) {
4757
4883
  // 遮罩层必须是跟随主内容
@@ -4950,6 +5076,7 @@ const PopsFolder = {
4950
5076
  const guid = popsUtils.getRandomGUID();
4951
5077
  // 设置当前类型
4952
5078
  const popsType = "folder";
5079
+ const emitter = new EventEmiter(popsType);
4953
5080
  let config = PopsFolderDefaultConfig();
4954
5081
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4955
5082
  config = popsUtils.assign(config, __config__);
@@ -5033,7 +5160,7 @@ const PopsFolder = {
5033
5160
  Reflect.set(config, "folder", config.folder);
5034
5161
  }
5035
5162
  // 先把z-index提取出来
5036
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
5163
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
5037
5164
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
5038
5165
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
5039
5166
  const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
@@ -5166,7 +5293,7 @@ const PopsFolder = {
5166
5293
  $elList.push($mask);
5167
5294
  }
5168
5295
  // 事件
5169
- const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
5296
+ const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
5170
5297
  const result = PopsHandler.handleResultConfig(evtConfig);
5171
5298
  PopsHandler.handleClickEvent("close", $btnCloseBtn, evtConfig, config.btn.close.callback);
5172
5299
  PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok.callback);
@@ -5174,9 +5301,7 @@ const PopsFolder = {
5174
5301
  PopsHandler.handleClickEvent("other", btnOtherElement, evtConfig, config.btn.other.callback);
5175
5302
  // 创建到页面中
5176
5303
  popsDOMUtils.append($shadowRoot, $elList);
5177
- if (typeof config.beforeAppendToPageCallBack === "function") {
5178
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
5179
- }
5304
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
5180
5305
  popsDOMUtils.appendBody($shadowContainer);
5181
5306
  if ($mask != null) {
5182
5307
  $anim.after($mask);
@@ -5800,7 +5925,7 @@ const PopsFolder = {
5800
5925
  Reflect.set($pops, "data-pops-folder", popsFolder);
5801
5926
  // 拖拽
5802
5927
  if (config.drag) {
5803
- PopsInstanceUtils.drag($pops, {
5928
+ PopsInstHandler.drag($pops, {
5804
5929
  dragElement: $title,
5805
5930
  limit: config.dragLimit,
5806
5931
  extraDistance: config.dragExtraDistance,
@@ -5816,7 +5941,7 @@ const PopsFolder = {
5816
5941
  $shadowContainer: $shadowContainer,
5817
5942
  $shadowRoot: $shadowRoot,
5818
5943
  config: config,
5819
- destory: result.close,
5944
+ emitter,
5820
5945
  });
5821
5946
  return result;
5822
5947
  },
@@ -5888,6 +6013,7 @@ const PopsIframe = {
5888
6013
  const guid = popsUtils.getRandomGUID();
5889
6014
  // 设置当前类型
5890
6015
  const popsType = "iframe";
6016
+ const emitter = new EventEmiter(popsType);
5891
6017
  let config = PopsIframeDefaultConfig();
5892
6018
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
5893
6019
  config = popsUtils.assign(config, __config__);
@@ -5924,7 +6050,7 @@ const PopsIframe = {
5924
6050
  ]);
5925
6051
  const maskExtraStyle = config.animation != null && config.animation != "" ? "position:absolute;" : "";
5926
6052
  // 先把z-index提取出来
5927
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
6053
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
5928
6054
  const maskHTML = PopsElementHandler.createMask(guid, zIndex, maskExtraStyle);
5929
6055
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
5930
6056
  const iframeLoadingHTML = /*html*/ '<div class="pops-loading"></div>';
@@ -5973,7 +6099,7 @@ const PopsIframe = {
5973
6099
  $mask = handleMask.maskElement;
5974
6100
  $elList.push($mask);
5975
6101
  }
5976
- const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
6102
+ const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
5977
6103
  // 赋值额外的$iframe参数
5978
6104
  evtConfig.$iframe = $iframe;
5979
6105
  const result = PopsHandler.handleResultConfig(evtConfig);
@@ -5998,16 +6124,14 @@ const PopsIframe = {
5998
6124
  });
5999
6125
  // 创建到页面中
6000
6126
  popsDOMUtils.append($shadowRoot, $elList);
6001
- if (typeof config.beforeAppendToPageCallBack === "function") {
6002
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
6003
- }
6127
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
6004
6128
  $iframeContainer.appendChild($shadowContainer);
6005
6129
  if ($mask != null) {
6006
6130
  $anim.after($mask);
6007
6131
  }
6008
6132
  // 拖拽
6009
6133
  if (config.drag) {
6010
- PopsInstanceUtils.drag($pops, {
6134
+ PopsInstHandler.drag($pops, {
6011
6135
  dragElement: $title,
6012
6136
  limit: config.dragLimit,
6013
6137
  extraDistance: config.dragExtraDistance,
@@ -6038,6 +6162,7 @@ const PopsIframe = {
6038
6162
  if (typeof config?.btn?.min?.callback === "function") {
6039
6163
  config.btn.min.callback(evtConfig, event);
6040
6164
  }
6165
+ emitter.emit("pops:iframe-min", evtConfig, event);
6041
6166
  }, {
6042
6167
  capture: true,
6043
6168
  });
@@ -6067,6 +6192,7 @@ const PopsIframe = {
6067
6192
  if (typeof config?.btn?.max?.callback === "function") {
6068
6193
  config.btn.max.callback(evtConfig, event);
6069
6194
  }
6195
+ emitter.emit("pops:iframe-max", evtConfig, event);
6070
6196
  }, {
6071
6197
  capture: true,
6072
6198
  });
@@ -6104,6 +6230,7 @@ const PopsIframe = {
6104
6230
  if (typeof config?.btn?.mise?.callback === "function") {
6105
6231
  config.btn.mise.callback(evtConfig, event);
6106
6232
  }
6233
+ emitter.emit("pops:iframe-mise", evtConfig, event);
6107
6234
  }, {
6108
6235
  capture: true,
6109
6236
  });
@@ -6111,7 +6238,7 @@ const PopsIframe = {
6111
6238
  popsDOMUtils.on(headerCloseBtnElement, "click", async (event) => {
6112
6239
  event.preventDefault();
6113
6240
  event.stopPropagation();
6114
- await PopsInstanceUtils.removeInstance([PopsInstData.iframe], guid, false);
6241
+ await PopsInstHandler.removeInstance([PopsInstData.iframe], guid, false);
6115
6242
  if (typeof config?.btn?.close?.callback === "function") {
6116
6243
  config.btn.close.callback(evtConfig, event);
6117
6244
  }
@@ -6126,7 +6253,7 @@ const PopsIframe = {
6126
6253
  $shadowContainer: $shadowContainer,
6127
6254
  $shadowRoot: $shadowRoot,
6128
6255
  config: config,
6129
- destory: result.close,
6256
+ emitter,
6130
6257
  });
6131
6258
  return result;
6132
6259
  },
@@ -7004,6 +7131,7 @@ const PopsPanelDefaultConfig = () => {
7004
7131
  darkStyle: null,
7005
7132
  beforeAppendToPageCallBack() { },
7006
7133
  stopKeyDownEventPropagation: true,
7134
+ listenEscapeKeyUpToExitDeepMenu: true,
7007
7135
  };
7008
7136
  };
7009
7137
 
@@ -7127,13 +7255,15 @@ class ToolTip {
7127
7255
  $content: null,
7128
7256
  $arrow: null,
7129
7257
  };
7258
+ emitter;
7130
7259
  $data = {
7131
7260
  config: null,
7132
7261
  guid: null,
7133
7262
  timeId_close_TouchEvent: [],
7134
7263
  timeId_close_MouseEvent: [],
7135
7264
  };
7136
- constructor(config, guid, ShadowInfo) {
7265
+ constructor(config, guid, ShadowInfo, emitter) {
7266
+ this.emitter = emitter;
7137
7267
  this.$data.config = config;
7138
7268
  this.$data.guid = guid;
7139
7269
  this.$el.$shadowContainer = ShadowInfo.$shadowContainer;
@@ -7179,7 +7309,7 @@ class ToolTip {
7179
7309
  // 处理className
7180
7310
  popsDOMUtils.addClassName($toolTipContainer, this.$data.config.className);
7181
7311
  // 添加z-index
7182
- $toolTipContainer.style.zIndex = PopsHandler.handleZIndex(this.$data.config.zIndex).toString();
7312
+ $toolTipContainer.style.zIndex = PopsHandler.getTargerOrFunctionValue(this.$data.config.zIndex).toString();
7183
7313
  // 添加自定义style
7184
7314
  PopsElementHandler.addStyle($toolTipContainer, this.$data.config.style);
7185
7315
  // 添加自定义浅色style
@@ -7227,7 +7357,7 @@ class ToolTip {
7227
7357
  * 获取z-index
7228
7358
  */
7229
7359
  getZIndex() {
7230
- const zIndex = PopsHandler.handleZIndex(this.$data.config.zIndex);
7360
+ const zIndex = PopsHandler.getTargerOrFunctionValue(this.$data.config.zIndex);
7231
7361
  return zIndex;
7232
7362
  }
7233
7363
  /**
@@ -7410,9 +7540,7 @@ class ToolTip {
7410
7540
  }
7411
7541
  if (!popsUtils.contains(this.$el.$shadowContainer)) {
7412
7542
  // 页面不存在Shadow,添加
7413
- if (typeof this.$data.config.beforeAppendToPageCallBack === "function") {
7414
- this.$data.config.beforeAppendToPageCallBack(this.$el.$shadowRoot, this.$el.$shadowContainer);
7415
- }
7543
+ this.emitter.emit("pops:before-append-to-page", this.$el.$shadowRoot, this.$el.$shadowContainer);
7416
7544
  popsDOMUtils.append(document.body, this.$el.$shadowContainer);
7417
7545
  }
7418
7546
  // 更新内容
@@ -7583,6 +7711,7 @@ const PopsTooltip = {
7583
7711
  const guid = popsUtils.getRandomGUID();
7584
7712
  // 设置当前类型
7585
7713
  const popsType = "tooltip";
7714
+ const emitter = new EventEmiter(popsType);
7586
7715
  let config = PopsTooltipDefaultConfig();
7587
7716
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
7588
7717
  config = popsUtils.assign(config, __config__);
@@ -7621,7 +7750,7 @@ const PopsTooltip = {
7621
7750
  const toolTip = new ToolTip(config, guid, {
7622
7751
  $shadowContainer,
7623
7752
  $shadowRoot,
7624
- });
7753
+ }, emitter);
7625
7754
  if (config.alwaysShow) {
7626
7755
  // 总是显示
7627
7756
  // 直接显示
@@ -7633,6 +7762,7 @@ const PopsTooltip = {
7633
7762
  $shadowContainer,
7634
7763
  $shadowRoot,
7635
7764
  toolTip,
7765
+ emitter,
7636
7766
  };
7637
7767
  },
7638
7768
  };
@@ -7681,6 +7811,7 @@ const PanelHandlerComponents = () => {
7681
7811
  nodeStoreConfigKey: "data-view-config",
7682
7812
  },
7683
7813
  $config: {},
7814
+ emitter: null,
7684
7815
  /**
7685
7816
  * 初始化
7686
7817
  * @param data
@@ -7691,6 +7822,7 @@ const PanelHandlerComponents = () => {
7691
7822
  ...data.$el,
7692
7823
  };
7693
7824
  this.$config = data.config;
7825
+ this.emitter = data.emitter;
7694
7826
  this.asideULElement = this.$el.$panelLeftAside.querySelector(`ul.pops-${PopsType}-aside-top-container`);
7695
7827
  this.asideBottomULElement = this.$el.$panelLeftAside.querySelector(`ul.pops-${PopsType}-aside-bottom-container`);
7696
7828
  this.sectionContainerHeaderULElement = this.$el.$panelContentSectionContainer.querySelector(`ul.pops-${PopsType}-container-header-ul`);
@@ -8601,7 +8733,8 @@ const PanelHandlerComponents = () => {
8601
8733
  $target: this.$ele.button,
8602
8734
  content: getToolTipContent,
8603
8735
  zIndex: () => {
8604
- return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
8736
+ // return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
8737
+ return popsUtils.getMaxZIndexNodeInfoFromPoint(this.$ele.button)[0].zIndex;
8605
8738
  },
8606
8739
  isFixed: true,
8607
8740
  className: "github-tooltip",
@@ -11192,91 +11325,31 @@ const PanelHandlerComponents = () => {
11192
11325
  className: "pops-panel-deepMenu-container-left-arrow-icon",
11193
11326
  innerHTML: PopsIcon.getIcon("arrowLeft"),
11194
11327
  });
11195
- // 动画配置
11196
- const animOptions = {
11197
- // 150 220 300
11198
- duration: 220,
11199
- easing: "ease-in-out",
11200
- };
11201
- // 进入动画
11202
- const enterViewTransition = () => {
11203
- // 隐藏旧的容器
11204
- popsDOMUtils.cssHide($currentSection, true);
11205
- popsDOMUtils.on($headerLeftArrow, "click", async (event) => {
11206
- popsDOMUtils.preventEvent(event);
11207
- // 返回动画
11208
- const leaveViewTransition = () => {
11209
- const $prev = $currentSection;
11210
- popsDOMUtils.cssShow($prev);
11211
- $deepMenuSection.remove();
11212
- };
11213
- // 返回上一层菜单
11214
- if (that.$config.useDeepMenuSwtichAnimation && document.startViewTransition) {
11215
- const leaveTransition = document.startViewTransition(leaveViewTransition);
11216
- await leaveTransition.ready;
11217
- // 向右移出
11218
- await Promise.all([
11219
- $deepMenuSection.animate([
11220
- {
11221
- // from
11222
- transform: "translateX(0)",
11223
- },
11224
- {
11225
- // to
11226
- transform: "translateX(100%)",
11227
- },
11228
- ], animOptions).finished,
11229
- // 向右移入
11230
- $currentSection.animate([
11231
- {
11232
- // from
11233
- transform: "translateX(-100%)",
11234
- },
11235
- {
11236
- // to
11237
- transform: "translateX(0)",
11238
- },
11239
- ], animOptions).finished,
11240
- ]);
11241
- await leaveTransition.finished;
11242
- }
11243
- else {
11244
- leaveViewTransition();
11245
- }
11246
- that.emitRenderRightContainer($currentSection);
11247
- }, {
11248
- once: true,
11249
- });
11250
- popsDOMUtils.before($header.firstElementChild, $headerLeftArrow);
11251
- $deepMenuHeaderUL.appendChild($header);
11252
- $deepMenuSection.appendChild($deepMenuHeaderUL);
11253
- $deepMenuSection.appendChild($deepMenuMain);
11254
- if (viewConfig.views && Array.isArray(viewConfig.views)) {
11255
- for (let index = 0; index < viewConfig.views.length; index++) {
11256
- const formItemConfig = viewConfig.views[index];
11257
- this.initContainerItem($deepMenuMain, formItemConfig);
11328
+ const switchAnim = PopsAnimation.createSwitchElementWithAnimation($currentSection, $deepMenuSection, {
11329
+ useAnimation: that.$config.useDeepMenuSwtichAnimation,
11330
+ enterToAddElementCallback: () => {
11331
+ popsDOMUtils.on($headerLeftArrow, "click", async (event) => {
11332
+ popsDOMUtils.preventEvent(event);
11333
+ // 返回动画
11334
+ await switchAnim.exit();
11335
+ that.emitRenderRightContainer($currentSection);
11336
+ }, {
11337
+ once: true,
11338
+ });
11339
+ popsDOMUtils.before($header.firstElementChild, $headerLeftArrow);
11340
+ $deepMenuHeaderUL.appendChild($header);
11341
+ $deepMenuSection.appendChild($deepMenuHeaderUL);
11342
+ $deepMenuSection.appendChild($deepMenuMain);
11343
+ if (viewConfig.views && Array.isArray(viewConfig.views)) {
11344
+ for (let index = 0; index < viewConfig.views.length; index++) {
11345
+ const formItemConfig = viewConfig.views[index];
11346
+ this.initContainerItem($deepMenuMain, formItemConfig);
11347
+ }
11258
11348
  }
11259
- }
11260
- that.$el.$panelRightSectionWrapper.appendChild($deepMenuSection);
11261
- };
11262
- if (that.$config.useDeepMenuSwtichAnimation && document.startViewTransition) {
11263
- const transition = document.startViewTransition(enterViewTransition);
11264
- await transition.ready;
11265
- await $deepMenuSection.animate([
11266
- {
11267
- // from
11268
- transform: "translateX(100%)",
11269
- },
11270
- {
11271
- // to
11272
- transform: "translateX(0)",
11273
- },
11274
- ], animOptions).finished;
11275
- await transition.finished;
11276
- }
11277
- else {
11278
- enterViewTransition();
11279
- }
11349
+ that.$el.$panelRightSectionWrapper.appendChild($deepMenuSection);
11350
+ },
11351
+ });
11352
+ await switchAnim.enter();
11280
11353
  if (typeof viewConfig.afterEnterDeepMenuCallBack === "function") {
11281
11354
  viewConfig.afterEnterDeepMenuCallBack(viewConfig, {
11282
11355
  $sectionContainer: $deepMenuSection,
@@ -11448,11 +11521,9 @@ const PanelHandlerComponents = () => {
11448
11521
  */
11449
11522
  emitRenderRightContainer($container) {
11450
11523
  const dataViewConfig = Reflect.get($container, this.$data.nodeStoreConfigKey);
11451
- this.$el.$pops.dispatchEvent(new CustomEvent("pops:renderRightContainer", {
11452
- detail: {
11453
- viewConfig: dataViewConfig,
11454
- },
11455
- }));
11524
+ this.emitter.emit("pops:renderRightContainer", {
11525
+ viewConfig: dataViewConfig,
11526
+ });
11456
11527
  },
11457
11528
  /**
11458
11529
  *
@@ -11522,6 +11593,7 @@ const PopsPanel = {
11522
11593
  const guid = popsUtils.getRandomGUID();
11523
11594
  // 设置当前类型
11524
11595
  const popsType = "panel";
11596
+ const emitter = new EventEmiter(popsType);
11525
11597
  let config = PopsPanelDefaultConfig();
11526
11598
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11527
11599
  config = popsUtils.assign(config, __config__);
@@ -11558,7 +11630,7 @@ const PopsPanel = {
11558
11630
  },
11559
11631
  ]);
11560
11632
  // 先把z-index提取出来
11561
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
11633
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
11562
11634
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
11563
11635
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
11564
11636
  const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
@@ -11616,15 +11688,13 @@ const PopsPanel = {
11616
11688
  $elList.push($mask);
11617
11689
  }
11618
11690
  // 处理返回的配置
11619
- const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
11691
+ const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
11620
11692
  const result = PopsHandler.handleResultConfig(evtConfig);
11621
11693
  // 为顶部右边的关闭按钮添加点击事件
11622
11694
  PopsHandler.handleClickEvent("close", $headerBtnClose, evtConfig, config.btn?.close?.callback);
11623
11695
  // 创建到页面中
11624
11696
  popsDOMUtils.append($shadowRoot, $elList);
11625
- if (typeof config.beforeAppendToPageCallBack === "function") {
11626
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
11627
- }
11697
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
11628
11698
  popsDOMUtils.appendBody($shadowContainer);
11629
11699
  // 追加遮罩层元素
11630
11700
  if ($mask != null) {
@@ -11647,6 +11717,7 @@ const PopsPanel = {
11647
11717
  $panelBottomLeftContainer,
11648
11718
  $panelBottomRightContainer,
11649
11719
  },
11720
+ emitter,
11650
11721
  });
11651
11722
  PopsHandler.handlePush(popsType, {
11652
11723
  guid: guid,
@@ -11656,11 +11727,11 @@ const PopsPanel = {
11656
11727
  $shadowContainer: $shadowContainer,
11657
11728
  $shadowRoot: $shadowRoot,
11658
11729
  config: config,
11659
- destory: result.close,
11730
+ emitter,
11660
11731
  });
11661
11732
  // 拖拽
11662
11733
  if (config.drag) {
11663
- PopsInstanceUtils.drag($pops, {
11734
+ PopsInstHandler.drag($pops, {
11664
11735
  dragElement: $title,
11665
11736
  limit: config.dragLimit,
11666
11737
  extraDistance: config.dragExtraDistance,
@@ -11668,15 +11739,21 @@ const PopsPanel = {
11668
11739
  endCallBack: config.dragEndCallBack,
11669
11740
  });
11670
11741
  }
11671
- return {
11672
- ...result,
11673
- addEventListener: (event, listener, options) => {
11674
- $pops.addEventListener(event, listener, options);
11675
- },
11676
- removeEventListener: (event, listener, options) => {
11677
- $pops.removeEventListener(event, listener, options);
11678
- },
11679
- };
11742
+ if (config.listenEscapeKeyUpToExitDeepMenu) {
11743
+ const escapeListener = popsDOMUtils.onKeyup(globalThis, (evt) => {
11744
+ if (evt.key === "Escape" && !evt.ctrlKey && !evt.shiftKey && !evt.altKey && !evt.metaKey) {
11745
+ // Esc
11746
+ const $exitBtn = $panelRightSectionWrapper.querySelector(".pops-panel-deepMenu-container-left-arrow-icon");
11747
+ if ($exitBtn) {
11748
+ $exitBtn.click();
11749
+ }
11750
+ }
11751
+ }, { capture: true });
11752
+ emitter.on("pops:before-destory", () => {
11753
+ escapeListener?.off();
11754
+ });
11755
+ }
11756
+ return result;
11680
11757
  },
11681
11758
  };
11682
11759
 
@@ -11780,6 +11857,7 @@ const PopsPrompt = {
11780
11857
  const guid = popsUtils.getRandomGUID();
11781
11858
  // 设置当前类型
11782
11859
  const popsType = "prompt";
11860
+ const emitter = new EventEmiter(popsType);
11783
11861
  let config = PopsPromptDefaultConfig();
11784
11862
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11785
11863
  config = popsUtils.assign(config, __config__);
@@ -11816,7 +11894,7 @@ const PopsPrompt = {
11816
11894
  },
11817
11895
  ]);
11818
11896
  // 先把z-index提取出来
11819
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
11897
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
11820
11898
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
11821
11899
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
11822
11900
  const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
@@ -11861,7 +11939,7 @@ const PopsPrompt = {
11861
11939
  $mask = handleMask.maskElement;
11862
11940
  $elList.push($mask);
11863
11941
  }
11864
- const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
11942
+ const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
11865
11943
  const result = PopsHandler.handleResultConfig(evtConfig);
11866
11944
  // 输入框赋值初始值
11867
11945
  $input.value = config.content.text;
@@ -11871,9 +11949,7 @@ const PopsPrompt = {
11871
11949
  PopsHandler.handlePromptClickEvent("other", $input, $btnOther, evtConfig, config.btn.other.callback);
11872
11950
  // 创建到页面中
11873
11951
  popsDOMUtils.append($shadowRoot, $elList);
11874
- if (typeof config.beforeAppendToPageCallBack === "function") {
11875
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
11876
- }
11952
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
11877
11953
  popsDOMUtils.appendBody($shadowContainer);
11878
11954
  if ($mask != null) {
11879
11955
  $anim.after($mask);
@@ -11886,11 +11962,11 @@ const PopsPrompt = {
11886
11962
  $shadowContainer: $shadowContainer,
11887
11963
  $shadowRoot: $shadowRoot,
11888
11964
  config: config,
11889
- destory: result.close,
11965
+ emitter,
11890
11966
  });
11891
11967
  // 拖拽
11892
11968
  if (config.drag) {
11893
- PopsInstanceUtils.drag($pops, {
11969
+ PopsInstHandler.drag($pops, {
11894
11970
  dragElement: $title,
11895
11971
  limit: config.dragLimit,
11896
11972
  extraDistance: config.dragExtraDistance,
@@ -12018,6 +12094,7 @@ const PopsRightClickMenu = {
12018
12094
  const guid = popsUtils.getRandomGUID();
12019
12095
  // 设置当前类型
12020
12096
  const popsType = "rightClickMenu";
12097
+ const emitter = new EventEmiter(popsType);
12021
12098
  let config = PopsRightClickMenuDefaultConfig();
12022
12099
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
12023
12100
  config = popsUtils.assign(config, __config__);
@@ -12146,13 +12223,14 @@ const PopsRightClickMenu = {
12146
12223
  guid: guid,
12147
12224
  $anim: rootElement,
12148
12225
  $pops: rootElement,
12149
- beforeRemoveCallBack(instCommonConfig) {
12150
- PopsContextMenu.closeAllMenu(instCommonConfig.$pops);
12151
- },
12152
12226
  config: config,
12153
- destory: () => {
12154
- PopsContextMenu.closeAllMenu(rootElement);
12155
- },
12227
+ emitter,
12228
+ });
12229
+ emitter.on("pops:before-destory", () => {
12230
+ PopsContextMenu.closeAllMenu(rootElement);
12231
+ });
12232
+ emitter.on("pops:destory", () => {
12233
+ PopsContextMenu.closeAllMenu(rootElement);
12156
12234
  });
12157
12235
  }
12158
12236
  },
@@ -12240,6 +12318,7 @@ const PopsRightClickMenu = {
12240
12318
  });
12241
12319
  const zIndex = this.getMenuZIndex();
12242
12320
  if (zIndex > 10000) {
12321
+ // 大于默认值
12243
12322
  $menu.style.zIndex = zIndex.toString();
12244
12323
  }
12245
12324
  if (isChildren) {
@@ -12260,7 +12339,7 @@ const PopsRightClickMenu = {
12260
12339
  * 动态获取配的z-index
12261
12340
  */
12262
12341
  getMenuZIndex() {
12263
- return PopsHandler.handleZIndex(config.zIndex);
12342
+ return PopsHandler.getTargerOrFunctionValue(config.zIndex);
12264
12343
  },
12265
12344
  /**
12266
12345
  * 获取left、top偏移
@@ -12374,9 +12453,7 @@ const PopsRightClickMenu = {
12374
12453
  popsDOMUtils.append($shadowRoot, menuElement);
12375
12454
  // 判断容器是否存在
12376
12455
  if (!document.contains($shadowContainer)) {
12377
- if (typeof config.beforeAppendToPageCallBack === "function") {
12378
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
12379
- }
12456
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
12380
12457
  popsDOMUtils.appendBody($shadowContainer);
12381
12458
  }
12382
12459
  this.handlerShowMenuCSS(menuElement, menuEvent);
@@ -12651,6 +12728,7 @@ const PopsSearchSuggestion = {
12651
12728
  const guid = popsUtils.getRandomGUID();
12652
12729
  // 设置当前类型
12653
12730
  const popsType = "searchSuggestion";
12731
+ const emitter = new EventEmiter(popsType);
12654
12732
  let config = PopsSearchSuggestionDefaultConfig();
12655
12733
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
12656
12734
  config = popsUtils.assign(config, __config__);
@@ -12687,6 +12765,7 @@ const PopsSearchSuggestion = {
12687
12765
  passive: true,
12688
12766
  };
12689
12767
  const SearchSuggestion = {
12768
+ emitter: emitter,
12690
12769
  /**
12691
12770
  * 当前的环境,可以是document,可以是shadowroot,默认是document
12692
12771
  */
@@ -12902,7 +12981,7 @@ const PopsSearchSuggestion = {
12902
12981
  border: initial;
12903
12982
  overflow: initial;
12904
12983
  position: ${config.isAbsolute ? "absolute" : "fixed"};
12905
- z-index: ${PopsHandler.handleZIndex(config.zIndex)};
12984
+ z-index: ${PopsHandler.getTargerOrFunctionValue(config.zIndex)};
12906
12985
  }
12907
12986
  .pops-${popsType}-search-suggestion-dropdown-wrapper{
12908
12987
  max-height: ${config.maxHeight};
@@ -13425,7 +13504,110 @@ const PopsSearchSuggestion = {
13425
13504
  },
13426
13505
  };
13427
13506
 
13428
- const version = "3.3.5";
13507
+ const PopsInstanceUtils = {
13508
+ /**
13509
+ * 获取pops所有弹窗中的最大的z-index
13510
+ * @param deviation
13511
+ */
13512
+ getPopsMaxZIndex(deviation = 1) {
13513
+ deviation = Number.isNaN(deviation) ? 1 : deviation;
13514
+ // 最大值 2147483647
13515
+ // const browserMaxZIndex = Math.pow(2, 31) - 1;
13516
+ // 比较值 2000000000
13517
+ const maxZIndex = 2 * Math.pow(10, 9);
13518
+ // 当前页面最大的z-index
13519
+ let zIndex = 0;
13520
+ // 当前的最大z-index的元素,调试使用
13521
+ let maxZIndexNode = null;
13522
+ /**
13523
+ * 元素是否可见
13524
+ * @param $el
13525
+ * @param $css
13526
+ */
13527
+ function isVisibleNode($el, $css) {
13528
+ let flag = true;
13529
+ if (typeof $el.checkVisibility === "function") {
13530
+ flag = $el.checkVisibility();
13531
+ }
13532
+ else {
13533
+ flag =
13534
+ $css.position !== "static" && $css.display !== "none" && $css.visibility !== "hidden" && $css.opacity !== "0";
13535
+ }
13536
+ if (flag) {
13537
+ // css样式上可见
13538
+ // 再判断宽高
13539
+ const rect = $el.getBoundingClientRect();
13540
+ // 确保该元素的中心点在屏幕内
13541
+ flag = rect.width > 0 && rect.height > 0 && rect.x > 0 && rect.y > 0;
13542
+ }
13543
+ return flag;
13544
+ }
13545
+ Object.keys(PopsInstData).forEach((instKeyName) => {
13546
+ const instData = PopsInstData[instKeyName];
13547
+ for (let index = 0; index < instData.length; index++) {
13548
+ const inst = instData[index];
13549
+ const nodeStyle = window.getComputedStyle(inst.$anim);
13550
+ // 不对position为static和display为none的元素进行获取它们的z-index
13551
+ if (isVisibleNode(inst.$anim, nodeStyle)) {
13552
+ const nodeZIndex = parseInt(nodeStyle.zIndex);
13553
+ if (!isNaN(nodeZIndex)) {
13554
+ if (nodeZIndex > zIndex) {
13555
+ zIndex = nodeZIndex;
13556
+ maxZIndexNode = inst.$anim;
13557
+ }
13558
+ }
13559
+ }
13560
+ }
13561
+ });
13562
+ zIndex += deviation;
13563
+ const isOverMaxZIndex = zIndex >= maxZIndex;
13564
+ if (isOverMaxZIndex) {
13565
+ // 超出z-index最大值
13566
+ zIndex = maxZIndex;
13567
+ }
13568
+ return { zIndex: zIndex, animElement: maxZIndexNode, isOverMaxZIndex };
13569
+ },
13570
+ /**
13571
+ * 排序数组
13572
+ * @param getBeforeValueFun
13573
+ * @param getAfterValueFun
13574
+ * @param sortByDesc 排序是否降序,默认降序
13575
+ */
13576
+ sortElementListByProperty(getBeforeValueFun, getAfterValueFun, sortByDesc = true) {
13577
+ if (typeof sortByDesc !== "boolean") {
13578
+ throw new TypeError("参数 sortByDesc 必须为boolean类型");
13579
+ }
13580
+ if (getBeforeValueFun == null || getAfterValueFun == null) {
13581
+ throw new Error("获取前面的值或后面的值的方法不能为空");
13582
+ }
13583
+ return function (after_obj, before_obj) {
13584
+ const beforeValue = getBeforeValueFun(before_obj); // 前
13585
+ const afterValue = getAfterValueFun(after_obj); // 后
13586
+ if (sortByDesc) {
13587
+ if (afterValue > beforeValue) {
13588
+ return -1;
13589
+ }
13590
+ else if (afterValue < beforeValue) {
13591
+ return 1;
13592
+ }
13593
+ else {
13594
+ return 0;
13595
+ }
13596
+ }
13597
+ else {
13598
+ if (afterValue < beforeValue) {
13599
+ return -1;
13600
+ }
13601
+ else if (afterValue > beforeValue) {
13602
+ return 1;
13603
+ }
13604
+ else {
13605
+ return 0;
13606
+ }
13607
+ }
13608
+ };
13609
+ },
13610
+ };
13429
13611
 
13430
13612
  class Pops {
13431
13613
  /** 配置 */
@@ -13454,7 +13636,11 @@ class Pops {
13454
13636
  /** pops处理float类型使用的工具类 */
13455
13637
  MathFloatUtils: PopsMathFloatUtils,
13456
13638
  /** pops.panel中用于处理各个类型的工具 */
13457
- PanelHandlerComponents: PanelHandlerComponents,
13639
+ PanelHandlerComponents,
13640
+ /** pops.panel中的动画 */
13641
+ PopsAnimation,
13642
+ /** 事件类 */
13643
+ EventEmiter,
13458
13644
  };
13459
13645
  init() { }
13460
13646
  /**