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