@whitesev/pops 3.3.4 → 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 (93) hide show
  1. package/dist/index.amd.js +13118 -12906
  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 +805 -593
  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 +805 -593
  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 -12907
  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 -12910
  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 -12909
  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 +61 -46
  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/folder/types/index.d.ts +4 -0
  33. package/dist/types/src/components/iframe/index.d.ts +6 -1
  34. package/dist/types/src/components/iframe/types/index.d.ts +4 -2
  35. package/dist/types/src/components/loading/index.d.ts +3 -1
  36. package/dist/types/src/components/panel/handlerComponents.d.ts +4 -1
  37. package/dist/types/src/components/panel/index.d.ts +2 -16
  38. package/dist/types/src/components/panel/types/index.d.ts +7 -2
  39. package/dist/types/src/components/prompt/index.d.ts +3 -1
  40. package/dist/types/src/components/searchSuggestion/index.d.ts +4 -1
  41. package/dist/types/src/components/tooltip/index.d.ts +6 -2
  42. package/dist/types/src/config/GlobalConfig.d.ts +1 -0
  43. package/dist/types/src/event/EventEmiter.d.ts +33 -0
  44. package/dist/types/src/handler/PopsHandler.d.ts +18 -16
  45. package/dist/types/src/handler/PopsInstHandler.d.ts +67 -0
  46. package/dist/types/src/types/EventEmitter.d.ts +18 -0
  47. package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +4 -0
  48. package/dist/types/src/types/button.d.ts +2 -1
  49. package/dist/types/src/types/components.d.ts +7 -0
  50. package/dist/types/src/types/event.d.ts +6 -2
  51. package/dist/types/src/types/inst.d.ts +4 -4
  52. package/dist/types/src/utils/PopsDOMUtils.d.ts +0 -16
  53. package/dist/types/src/utils/PopsInstanceUtils.d.ts +0 -88
  54. package/dist/types/src/utils/PopsUtils.d.ts +57 -0
  55. package/package.json +3 -3
  56. package/src/Pops.ts +7 -2
  57. package/src/PopsAnimation.ts +126 -0
  58. package/src/components/alert/defaultConfig.ts +1 -0
  59. package/src/components/alert/index.ts +9 -9
  60. package/src/components/confirm/defaultConfig.ts +1 -0
  61. package/src/components/confirm/index.ts +9 -9
  62. package/src/components/drawer/defaultConfig.ts +1 -0
  63. package/src/components/drawer/index.ts +12 -9
  64. package/src/components/folder/defaultConfig.ts +1 -0
  65. package/src/components/folder/index.ts +9 -8
  66. package/src/components/folder/types/index.ts +4 -0
  67. package/src/components/iframe/defaultConfig.ts +1 -0
  68. package/src/components/iframe/index.ts +18 -12
  69. package/src/components/iframe/types/index.ts +10 -8
  70. package/src/components/loading/defaultConfig.ts +1 -0
  71. package/src/components/loading/index.ts +12 -6
  72. package/src/components/panel/defaultConfig.ts +2 -0
  73. package/src/components/panel/handlerComponents.ts +41 -111
  74. package/src/components/panel/index.ts +34 -28
  75. package/src/components/panel/types/index.ts +7 -2
  76. package/src/components/prompt/defaultConfig.ts +1 -0
  77. package/src/components/prompt/index.ts +9 -8
  78. package/src/components/rightClickMenu/index.ts +17 -14
  79. package/src/components/searchSuggestion/index.ts +5 -1
  80. package/src/components/tooltip/index.ts +20 -10
  81. package/src/event/EventEmiter.ts +95 -0
  82. package/src/handler/PopsElementHandler.ts +6 -4
  83. package/src/handler/PopsHandler.ts +100 -58
  84. package/src/handler/PopsInstHandler.ts +557 -0
  85. package/src/types/EventEmitter.d.ts +18 -0
  86. package/src/types/PopsDOMUtilsEventType.d.ts +4 -0
  87. package/src/types/button.d.ts +2 -1
  88. package/src/types/components.d.ts +7 -0
  89. package/src/types/event.d.ts +6 -2
  90. package/src/types/inst.d.ts +4 -4
  91. package/src/utils/PopsDOMUtils.ts +1 -40
  92. package/src/utils/PopsInstanceUtils.ts +19 -627
  93. 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,60 +3196,71 @@ 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
+ });
3114
3255
  }
3256
+ else {
3257
+ endCallback();
3258
+ resolve();
3259
+ }
3260
+ }
3261
+ else {
3262
+ console.error("hide-error: 该实例未存储");
3263
+ resolve();
3115
3264
  }
3116
3265
  });
3117
3266
  },
@@ -3125,97 +3274,128 @@ 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);
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", "");
3290
+ }
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);
3301
+ }
3143
3302
  }
3144
3303
  else {
3145
- console.error("未知direction:", direction);
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 = "";
3146
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();
3147
3334
  resolve();
3148
- }, drawerConfig.openDelay ?? 0);
3335
+ }
3149
3336
  }
3150
3337
  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();
3166
- }
3167
- instConfigItem.$anim.style.display = "";
3168
- if (instConfigItem.$mask) {
3169
- instConfigItem.$mask.style.display = "";
3170
- }
3171
- popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3172
- capture: true,
3173
- });
3174
- }
3175
- else {
3176
- instConfigItem.$anim.style.display = "";
3177
- if (instConfigItem.$mask) {
3178
- instConfigItem.$mask.style.display = "";
3179
- }
3180
- resolve();
3181
- }
3338
+ console.error("show-error: 该实例未存储");
3339
+ resolve();
3340
+ }
3341
+ });
3342
+ },
3343
+ /**
3344
+ * 关闭
3345
+ * @param popsType
3346
+ * @param instConfigList
3347
+ * @param guid
3348
+ * @param config
3349
+ * @param $anim
3350
+ */
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);
3182
3371
  }
3183
3372
  }
3184
3373
  });
3185
- },
3186
- /**
3187
- * 关闭
3188
- * @param popsType
3189
- * @param instConfigList
3190
- * @param guid
3191
- * @param config
3192
- * @param $anim
3193
- */
3194
- async close(config, popsType, instConfigList, guid, $anim) {
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 = {
@@ -3490,19 +3600,37 @@ const PopsHandler = {
3490
3600
  const $shadowContainer = popsDOMUtils.createElement("div", {
3491
3601
  className: "pops-shadow-container",
3492
3602
  });
3603
+ let $shadowRoot;
3493
3604
  if (config.useShadowRoot) {
3494
- const $shadowRoot = $shadowContainer.attachShadow({ mode: "open" });
3495
- return {
3496
- $shadowContainer,
3497
- $shadowRoot,
3498
- };
3605
+ $shadowRoot = $shadowContainer.attachShadow({ mode: "open" });
3499
3606
  }
3500
3607
  else {
3501
- return {
3502
- $shadowContainer,
3503
- $shadowRoot: $shadowContainer,
3504
- };
3608
+ $shadowRoot = $shadowContainer;
3609
+ }
3610
+ // 添加键盘监听
3611
+ // rightClickMenu
3612
+ // searchSuggestion
3613
+ // tooltip
3614
+ // 以上都不需要添加该事件监听
3615
+ if (config.stopKeyDownEventPropagation) {
3616
+ popsDOMUtils.on($shadowRoot, "keydown", [
3617
+ 'input[type="text"]',
3618
+ 'input[type="password"]',
3619
+ 'input[type="number"]',
3620
+ 'input[type="email"]',
3621
+ 'input[type="url"]',
3622
+ 'input[type="search"]',
3623
+ "input:not([type])",
3624
+ "textarea",
3625
+ ], (evt) => {
3626
+ evt.stopImmediatePropagation();
3627
+ evt.stopPropagation();
3628
+ }, { capture: true });
3505
3629
  }
3630
+ return {
3631
+ $shadowContainer,
3632
+ $shadowRoot,
3633
+ };
3506
3634
  },
3507
3635
  /**
3508
3636
  * 处理初始化
@@ -3575,11 +3703,11 @@ const PopsHandler = {
3575
3703
  function originalRun() {
3576
3704
  if (config.config.mask.clickEvent.toClose) {
3577
3705
  // 关闭
3578
- 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);
3579
3707
  }
3580
3708
  else if (config.config.mask.clickEvent.toHide) {
3581
3709
  // 隐藏
3582
- 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);
3583
3711
  }
3584
3712
  }
3585
3713
  if (typeof config.config.mask.clickCallBack === "function") {
@@ -3766,7 +3894,7 @@ const PopsHandler = {
3766
3894
  * @param $mask 遮罩层
3767
3895
  * @param config 当前配置
3768
3896
  */
3769
- handleEventConfig(config, guid, $shadowContainer, $shadowRoot, type, $anim, $pops, $mask) {
3897
+ handleEventConfig(config, guid, $shadowContainer, $shadowRoot, type, $anim, $pops, emitter, $mask) {
3770
3898
  return {
3771
3899
  $shadowContainer: $shadowContainer,
3772
3900
  $shadowRoot: $shadowRoot,
@@ -3776,17 +3904,18 @@ const PopsHandler = {
3776
3904
  $mask: $mask,
3777
3905
  mode: type,
3778
3906
  guid: guid,
3907
+ emitter: emitter,
3779
3908
  close() {
3780
- return PopsInstanceUtils.close(config, type, PopsInstData[type], guid, $anim);
3909
+ return PopsInstHandler.close(config, type, PopsInstData[type], guid, $anim);
3781
3910
  },
3782
3911
  hide() {
3783
- return PopsInstanceUtils.hide(config, type, PopsInstData[type], guid, $anim, $mask);
3912
+ return PopsInstHandler.hide(config, type, PopsInstData[type], guid, $anim, $mask);
3784
3913
  },
3785
3914
  show($parent) {
3786
3915
  if ($parent) {
3787
3916
  $parent.appendChild(PopsInstData[type][0].$shadowRoot);
3788
3917
  }
3789
- return PopsInstanceUtils.show(config, type, PopsInstData[type], guid, $anim, $mask);
3918
+ return PopsInstHandler.show(config, type, PopsInstData[type], guid, $anim, $mask);
3790
3919
  },
3791
3920
  };
3792
3921
  },
@@ -3799,7 +3928,7 @@ const PopsHandler = {
3799
3928
  * @param $mask 遮罩层
3800
3929
  * @param config 当前配置
3801
3930
  */
3802
- handleLoadingEventConfig(config, guid, type, $anim, $pops, $mask) {
3931
+ handleLoadingEventConfig(config, guid, type, $anim, $pops, emitter, $mask) {
3803
3932
  return {
3804
3933
  $el: $anim,
3805
3934
  $anim: $anim,
@@ -3807,14 +3936,15 @@ const PopsHandler = {
3807
3936
  $mask: $mask,
3808
3937
  mode: type,
3809
3938
  guid: guid,
3939
+ emitter,
3810
3940
  close() {
3811
- return PopsInstanceUtils.close(config, type, PopsInstData[type], guid, $anim);
3941
+ return PopsInstHandler.close(config, type, PopsInstData[type], guid, $anim);
3812
3942
  },
3813
3943
  hide() {
3814
- return PopsInstanceUtils.hide(config, type, PopsInstData[type], guid, $anim, $mask);
3944
+ return PopsInstHandler.hide(config, type, PopsInstData[type], guid, $anim, $mask);
3815
3945
  },
3816
3946
  show() {
3817
- return PopsInstanceUtils.show(config, type, PopsInstData[type], guid, $anim, $mask);
3947
+ return PopsInstHandler.show(config, type, PopsInstData[type], guid, $anim, $mask);
3818
3948
  },
3819
3949
  };
3820
3950
  },
@@ -3838,7 +3968,7 @@ const PopsHandler = {
3838
3968
  handleClickEvent(type, $btn, eventConfig, callback) {
3839
3969
  if (typeof callback !== "function")
3840
3970
  return;
3841
- popsDOMUtils.on($btn, "click", (event) => {
3971
+ return popsDOMUtils.on($btn, "click", (event) => {
3842
3972
  const extraParam = {
3843
3973
  type: type,
3844
3974
  };
@@ -3876,16 +4006,10 @@ const PopsHandler = {
3876
4006
  callback && callback(event);
3877
4007
  }
3878
4008
  };
3879
- popsDOMUtils.on(PopsCore.globalThis, "keydown", keyboardEvent, {
4009
+ const listener = popsDOMUtils.on(PopsCore.globalThis, "keydown", keyboardEvent, {
3880
4010
  capture: true,
3881
4011
  });
3882
- return {
3883
- removeKeyboardEvent() {
3884
- popsDOMUtils.off(globalThis, "keydown", keyboardEvent, {
3885
- capture: true,
3886
- });
3887
- },
3888
- };
4012
+ return listener;
3889
4013
  },
3890
4014
  /**
3891
4015
  * 处理prompt的点击事件
@@ -3908,15 +4032,16 @@ const PopsHandler = {
3908
4032
  });
3909
4033
  },
3910
4034
  /**
3911
- * 把配置的z-index配置转为数字
3912
- * @param zIndex
4035
+ * 获取数值
4036
+ * @param target
3913
4037
  */
3914
- handleZIndex(zIndex) {
3915
- if (typeof zIndex === "function") {
3916
- return zIndex();
4038
+ getTargerOrFunctionValue(target) {
4039
+ if (typeof target === "function") {
4040
+ const result = target();
4041
+ return result;
3917
4042
  }
3918
4043
  else {
3919
- return zIndex;
4044
+ return target;
3920
4045
  }
3921
4046
  },
3922
4047
  /**
@@ -3933,11 +4058,11 @@ const PopsHandler = {
3933
4058
  if (type === "loading" || type === "tooltip" || type === "rightClickMenu") {
3934
4059
  const inst = PopsInstData[type];
3935
4060
  if (inst) {
3936
- PopsInstanceUtils.removeInstance([inst], "", true);
4061
+ PopsInstHandler.removeInstance([inst], "", true);
3937
4062
  }
3938
4063
  }
3939
4064
  else {
3940
- PopsInstanceUtils.removeInstance([
4065
+ PopsInstHandler.removeInstance([
3941
4066
  PopsInstData.alert,
3942
4067
  PopsInstData.confirm,
3943
4068
  PopsInstData.drawer,
@@ -3948,15 +4073,30 @@ const PopsHandler = {
3948
4073
  ], "", true);
3949
4074
  }
3950
4075
  }
3951
- else {
3952
- // 对配置进行处理
3953
- // 选择配置的z-index和已有的pops实例的最大z-index值
3954
- const originZIndex = config.zIndex;
3955
- config.zIndex = () => {
3956
- const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(PopsHandler.handleZIndex(originZIndex) + 100);
3957
- return maxZIndex;
3958
- };
3959
- }
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;
3960
4100
  return config;
3961
4101
  },
3962
4102
  /**
@@ -4029,6 +4169,7 @@ const PopsAlertDefaultConfig = () => {
4029
4169
  lightStyle: null,
4030
4170
  darkStyle: null,
4031
4171
  beforeAppendToPageCallBack() { },
4172
+ stopKeyDownEventPropagation: true,
4032
4173
  };
4033
4174
  };
4034
4175
 
@@ -4037,6 +4178,7 @@ const PopsAlert = {
4037
4178
  const guid = popsUtils.getRandomGUID();
4038
4179
  // 设置当前类型
4039
4180
  const popsType = "alert";
4181
+ const emitter = new EventEmiter(popsType);
4040
4182
  let config = PopsAlertDefaultConfig();
4041
4183
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4042
4184
  config = popsUtils.assign(config, __config__);
@@ -4073,7 +4215,7 @@ const PopsAlert = {
4073
4215
  },
4074
4216
  ]);
4075
4217
  // 先把z-index提取出来
4076
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
4218
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
4077
4219
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
4078
4220
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
4079
4221
  const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
@@ -4109,7 +4251,7 @@ const PopsAlert = {
4109
4251
  $elList.push($mask);
4110
4252
  }
4111
4253
  // 处理返回的配置
4112
- 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);
4113
4255
  const result = PopsHandler.handleResultConfig(evtConfig);
4114
4256
  // 为顶部右边的关闭按钮添加点击事件
4115
4257
  PopsHandler.handleClickEvent("close", $headerCloseBtn, evtConfig, config.btn.close?.callback);
@@ -4117,9 +4259,7 @@ const PopsAlert = {
4117
4259
  PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok?.callback);
4118
4260
  // 创建到页面中
4119
4261
  popsDOMUtils.append($shadowRoot, $elList);
4120
- if (typeof config.beforeAppendToPageCallBack === "function") {
4121
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
4122
- }
4262
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
4123
4263
  popsDOMUtils.appendBody($shadowContainer);
4124
4264
  if ($mask != null) {
4125
4265
  // 添加遮罩层
@@ -4134,11 +4274,11 @@ const PopsAlert = {
4134
4274
  $shadowContainer: $shadowContainer,
4135
4275
  $shadowRoot: $shadowRoot,
4136
4276
  config: config,
4137
- destory: result.close,
4277
+ emitter,
4138
4278
  });
4139
4279
  // 拖拽
4140
4280
  if (config.drag) {
4141
- PopsInstanceUtils.drag($pops, {
4281
+ PopsInstHandler.drag($pops, {
4142
4282
  dragElement: $title,
4143
4283
  limit: config.dragLimit,
4144
4284
  extraDistance: config.dragExtraDistance,
@@ -4237,6 +4377,7 @@ const PopsConfirmDefaultConfig = () => {
4237
4377
  lightStyle: null,
4238
4378
  darkStyle: null,
4239
4379
  beforeAppendToPageCallBack() { },
4380
+ stopKeyDownEventPropagation: true,
4240
4381
  };
4241
4382
  };
4242
4383
 
@@ -4245,6 +4386,7 @@ const PopsConfirm = {
4245
4386
  const guid = popsUtils.getRandomGUID();
4246
4387
  // 设置当前类型
4247
4388
  const popsType = "confirm";
4389
+ const emitter = new EventEmiter(popsType);
4248
4390
  let config = PopsConfirmDefaultConfig();
4249
4391
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4250
4392
  config = popsUtils.assign(config, __config__);
@@ -4281,7 +4423,7 @@ const PopsConfirm = {
4281
4423
  },
4282
4424
  ]);
4283
4425
  // 先把z-index提取出来
4284
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
4426
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
4285
4427
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
4286
4428
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
4287
4429
  const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
@@ -4320,7 +4462,7 @@ const PopsConfirm = {
4320
4462
  $mask = handleMask.maskElement;
4321
4463
  $elList.push($mask);
4322
4464
  }
4323
- 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);
4324
4466
  const result = PopsHandler.handleResultConfig(evtConfig);
4325
4467
  PopsHandler.handleClickEvent("close", $btnClose, evtConfig, config.btn.close.callback);
4326
4468
  PopsHandler.handleClickEvent("ok", $btnOk, evtConfig, config.btn.ok.callback);
@@ -4328,9 +4470,7 @@ const PopsConfirm = {
4328
4470
  PopsHandler.handleClickEvent("other", $btnOther, evtConfig, config.btn.other.callback);
4329
4471
  // 创建到页面中
4330
4472
  popsDOMUtils.append($shadowRoot, $elList);
4331
- if (typeof config.beforeAppendToPageCallBack === "function") {
4332
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
4333
- }
4473
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
4334
4474
  popsDOMUtils.appendBody($shadowContainer);
4335
4475
  if ($mask != null) {
4336
4476
  $anim.after($mask);
@@ -4343,11 +4483,11 @@ const PopsConfirm = {
4343
4483
  $shadowContainer: $shadowContainer,
4344
4484
  $shadowRoot: $shadowRoot,
4345
4485
  config: config,
4346
- destory: result.close,
4486
+ emitter,
4347
4487
  });
4348
4488
  // 拖拽
4349
4489
  if (config.drag) {
4350
- PopsInstanceUtils.drag($pops, {
4490
+ PopsInstHandler.drag($pops, {
4351
4491
  dragElement: $title,
4352
4492
  limit: config.dragLimit,
4353
4493
  extraDistance: config.dragExtraDistance,
@@ -4445,6 +4585,7 @@ const PopsDrawerDefaultConfig = () => {
4445
4585
  darkStyle: null,
4446
4586
  beforeAppendToPageCallBack() { },
4447
4587
  forbiddenScroll: false,
4588
+ stopKeyDownEventPropagation: true,
4448
4589
  };
4449
4590
  };
4450
4591
 
@@ -4453,6 +4594,7 @@ const PopsDrawer = {
4453
4594
  const guid = popsUtils.getRandomGUID();
4454
4595
  // 设置当前类型
4455
4596
  const popsType = "drawer";
4597
+ const emitter = new EventEmiter(popsType);
4456
4598
  let config = PopsDrawerDefaultConfig();
4457
4599
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4458
4600
  config = popsUtils.assign(config, __config__);
@@ -4489,7 +4631,7 @@ const PopsDrawer = {
4489
4631
  },
4490
4632
  ]);
4491
4633
  // 先把z-index提取出来
4492
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
4634
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
4493
4635
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
4494
4636
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
4495
4637
  const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
@@ -4534,7 +4676,7 @@ const PopsDrawer = {
4534
4676
  $mask = handleMask.maskElement;
4535
4677
  $elList.push($mask);
4536
4678
  }
4537
- 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);
4538
4680
  const result = PopsHandler.handleResultConfig(evtConfig);
4539
4681
  // 处理方向
4540
4682
  $pops.setAttribute("direction", config.direction);
@@ -4558,9 +4700,12 @@ const PopsDrawer = {
4558
4700
  }
4559
4701
  // 按下Esc键触发关闭
4560
4702
  if (config.closeOnPressEscape) {
4561
- PopsHandler.handleKeyboardEvent("Escape", [], function () {
4703
+ const listener = PopsHandler.handleKeyboardEvent("Escape", [], function () {
4562
4704
  evtConfig.close();
4563
4705
  });
4706
+ emitter.on("pops:destory", () => {
4707
+ listener.off();
4708
+ });
4564
4709
  }
4565
4710
  // 待处理的点击事件列表
4566
4711
  const needHandleClickEventList = [
@@ -4612,9 +4757,7 @@ const PopsDrawer = {
4612
4757
  });
4613
4758
  // 创建到页面中
4614
4759
  popsDOMUtils.append($shadowRoot, $elList);
4615
- if (typeof config.beforeAppendToPageCallBack === "function") {
4616
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
4617
- }
4760
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
4618
4761
  popsDOMUtils.appendBody($shadowContainer);
4619
4762
  popsUtils.setTimeout(() => {
4620
4763
  popsUtils.setTimeout(() => {
@@ -4632,7 +4775,7 @@ const PopsDrawer = {
4632
4775
  $shadowContainer: $shadowContainer,
4633
4776
  $shadowRoot: $shadowRoot,
4634
4777
  config: config,
4635
- destory: result.close,
4778
+ emitter: emitter,
4636
4779
  });
4637
4780
  return result;
4638
4781
  },
@@ -4665,6 +4808,7 @@ const PopsLoadingDefaultConfig = () => {
4665
4808
  lightStyle: null,
4666
4809
  darkStyle: null,
4667
4810
  addIndexCSS: true,
4811
+ stopKeyDownEventPropagation: true,
4668
4812
  };
4669
4813
  };
4670
4814
 
@@ -4673,12 +4817,13 @@ const PopsLoading = {
4673
4817
  const guid = popsUtils.getRandomGUID();
4674
4818
  // 设置当前类型
4675
4819
  const PopsType = "loading";
4820
+ const emitter = new EventEmiter(PopsType);
4676
4821
  let config = PopsLoadingDefaultConfig();
4677
4822
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4678
4823
  config = popsUtils.assign(config, __config__);
4679
4824
  config = PopsHandler.handleOnly(PopsType, config);
4680
4825
  // 先把z-index提取出来
4681
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
4826
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
4682
4827
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
4683
4828
  const { contentPStyle } = PopsElementHandler.createContentStyle("loading", config);
4684
4829
  const animHTML = PopsElementHandler.createAnim(guid, PopsType, config,
@@ -4721,17 +4866,20 @@ const PopsLoading = {
4721
4866
  $mask = handleMask.maskElement;
4722
4867
  $elList.push($mask);
4723
4868
  }
4724
- const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, $mask);
4869
+ const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, emitter, $mask);
4725
4870
  popsDOMUtils.append(config.$parent, $elList);
4726
4871
  if ($mask != null) {
4727
4872
  $anim.after($mask);
4728
4873
  }
4729
- // @ts-ignore
4730
4874
  PopsHandler.handlePush(PopsType, {
4875
+ $shadowContainer: $pops,
4876
+ $shadowRoot: $pops,
4731
4877
  guid: guid,
4732
4878
  $anim: $anim,
4733
4879
  $pops: $pops,
4734
4880
  $mask: $mask,
4881
+ emitter: emitter,
4882
+ config: config,
4735
4883
  });
4736
4884
  if (config.isAbsolute) {
4737
4885
  // 遮罩层必须是跟随主内容
@@ -4893,6 +5041,7 @@ const PopsFolderDefaultConfig = () => {
4893
5041
  lightStyle: null,
4894
5042
  darkStyle: null,
4895
5043
  beforeAppendToPageCallBack() { },
5044
+ stopKeyDownEventPropagation: true,
4896
5045
  };
4897
5046
  };
4898
5047
 
@@ -4929,6 +5078,7 @@ const PopsFolder = {
4929
5078
  const guid = popsUtils.getRandomGUID();
4930
5079
  // 设置当前类型
4931
5080
  const popsType = "folder";
5081
+ const emitter = new EventEmiter(popsType);
4932
5082
  let config = PopsFolderDefaultConfig();
4933
5083
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4934
5084
  config = popsUtils.assign(config, __config__);
@@ -5012,7 +5162,7 @@ const PopsFolder = {
5012
5162
  Reflect.set(config, "folder", config.folder);
5013
5163
  }
5014
5164
  // 先把z-index提取出来
5015
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
5165
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
5016
5166
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
5017
5167
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
5018
5168
  const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
@@ -5145,7 +5295,7 @@ const PopsFolder = {
5145
5295
  $elList.push($mask);
5146
5296
  }
5147
5297
  // 事件
5148
- 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);
5149
5299
  const result = PopsHandler.handleResultConfig(evtConfig);
5150
5300
  PopsHandler.handleClickEvent("close", $btnCloseBtn, evtConfig, config.btn.close.callback);
5151
5301
  PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok.callback);
@@ -5153,9 +5303,7 @@ const PopsFolder = {
5153
5303
  PopsHandler.handleClickEvent("other", btnOtherElement, evtConfig, config.btn.other.callback);
5154
5304
  // 创建到页面中
5155
5305
  popsDOMUtils.append($shadowRoot, $elList);
5156
- if (typeof config.beforeAppendToPageCallBack === "function") {
5157
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
5158
- }
5306
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
5159
5307
  popsDOMUtils.appendBody($shadowContainer);
5160
5308
  if ($mask != null) {
5161
5309
  $anim.after($mask);
@@ -5779,7 +5927,7 @@ const PopsFolder = {
5779
5927
  Reflect.set($pops, "data-pops-folder", popsFolder);
5780
5928
  // 拖拽
5781
5929
  if (config.drag) {
5782
- PopsInstanceUtils.drag($pops, {
5930
+ PopsInstHandler.drag($pops, {
5783
5931
  dragElement: $title,
5784
5932
  limit: config.dragLimit,
5785
5933
  extraDistance: config.dragExtraDistance,
@@ -5795,7 +5943,7 @@ const PopsFolder = {
5795
5943
  $shadowContainer: $shadowContainer,
5796
5944
  $shadowRoot: $shadowRoot,
5797
5945
  config: config,
5798
- destory: result.close,
5946
+ emitter,
5799
5947
  });
5800
5948
  return result;
5801
5949
  },
@@ -5858,6 +6006,7 @@ const PopsIframeDefaultConfig = () => {
5858
6006
  lightStyle: null,
5859
6007
  darkStyle: null,
5860
6008
  beforeAppendToPageCallBack() { },
6009
+ stopKeyDownEventPropagation: true,
5861
6010
  };
5862
6011
  };
5863
6012
 
@@ -5866,6 +6015,7 @@ const PopsIframe = {
5866
6015
  const guid = popsUtils.getRandomGUID();
5867
6016
  // 设置当前类型
5868
6017
  const popsType = "iframe";
6018
+ const emitter = new EventEmiter(popsType);
5869
6019
  let config = PopsIframeDefaultConfig();
5870
6020
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
5871
6021
  config = popsUtils.assign(config, __config__);
@@ -5902,7 +6052,7 @@ const PopsIframe = {
5902
6052
  ]);
5903
6053
  const maskExtraStyle = config.animation != null && config.animation != "" ? "position:absolute;" : "";
5904
6054
  // 先把z-index提取出来
5905
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
6055
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
5906
6056
  const maskHTML = PopsElementHandler.createMask(guid, zIndex, maskExtraStyle);
5907
6057
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
5908
6058
  const iframeLoadingHTML = /*html*/ '<div class="pops-loading"></div>';
@@ -5951,7 +6101,7 @@ const PopsIframe = {
5951
6101
  $mask = handleMask.maskElement;
5952
6102
  $elList.push($mask);
5953
6103
  }
5954
- 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);
5955
6105
  // 赋值额外的$iframe参数
5956
6106
  evtConfig.$iframe = $iframe;
5957
6107
  const result = PopsHandler.handleResultConfig(evtConfig);
@@ -5976,16 +6126,14 @@ const PopsIframe = {
5976
6126
  });
5977
6127
  // 创建到页面中
5978
6128
  popsDOMUtils.append($shadowRoot, $elList);
5979
- if (typeof config.beforeAppendToPageCallBack === "function") {
5980
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
5981
- }
6129
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
5982
6130
  $iframeContainer.appendChild($shadowContainer);
5983
6131
  if ($mask != null) {
5984
6132
  $anim.after($mask);
5985
6133
  }
5986
6134
  // 拖拽
5987
6135
  if (config.drag) {
5988
- PopsInstanceUtils.drag($pops, {
6136
+ PopsInstHandler.drag($pops, {
5989
6137
  dragElement: $title,
5990
6138
  limit: config.dragLimit,
5991
6139
  extraDistance: config.dragExtraDistance,
@@ -6016,6 +6164,7 @@ const PopsIframe = {
6016
6164
  if (typeof config?.btn?.min?.callback === "function") {
6017
6165
  config.btn.min.callback(evtConfig, event);
6018
6166
  }
6167
+ emitter.emit("pops:iframe-min", evtConfig, event);
6019
6168
  }, {
6020
6169
  capture: true,
6021
6170
  });
@@ -6045,6 +6194,7 @@ const PopsIframe = {
6045
6194
  if (typeof config?.btn?.max?.callback === "function") {
6046
6195
  config.btn.max.callback(evtConfig, event);
6047
6196
  }
6197
+ emitter.emit("pops:iframe-max", evtConfig, event);
6048
6198
  }, {
6049
6199
  capture: true,
6050
6200
  });
@@ -6082,6 +6232,7 @@ const PopsIframe = {
6082
6232
  if (typeof config?.btn?.mise?.callback === "function") {
6083
6233
  config.btn.mise.callback(evtConfig, event);
6084
6234
  }
6235
+ emitter.emit("pops:iframe-mise", evtConfig, event);
6085
6236
  }, {
6086
6237
  capture: true,
6087
6238
  });
@@ -6089,7 +6240,7 @@ const PopsIframe = {
6089
6240
  popsDOMUtils.on(headerCloseBtnElement, "click", async (event) => {
6090
6241
  event.preventDefault();
6091
6242
  event.stopPropagation();
6092
- await PopsInstanceUtils.removeInstance([PopsInstData.iframe], guid, false);
6243
+ await PopsInstHandler.removeInstance([PopsInstData.iframe], guid, false);
6093
6244
  if (typeof config?.btn?.close?.callback === "function") {
6094
6245
  config.btn.close.callback(evtConfig, event);
6095
6246
  }
@@ -6104,7 +6255,7 @@ const PopsIframe = {
6104
6255
  $shadowContainer: $shadowContainer,
6105
6256
  $shadowRoot: $shadowRoot,
6106
6257
  config: config,
6107
- destory: result.close,
6258
+ emitter,
6108
6259
  });
6109
6260
  return result;
6110
6261
  },
@@ -6981,6 +7132,8 @@ const PopsPanelDefaultConfig = () => {
6981
7132
  lightStyle: null,
6982
7133
  darkStyle: null,
6983
7134
  beforeAppendToPageCallBack() { },
7135
+ stopKeyDownEventPropagation: true,
7136
+ listenEscapeKeyUpToExitDeepMenu: true,
6984
7137
  };
6985
7138
  };
6986
7139
 
@@ -7104,13 +7257,15 @@ class ToolTip {
7104
7257
  $content: null,
7105
7258
  $arrow: null,
7106
7259
  };
7260
+ emitter;
7107
7261
  $data = {
7108
7262
  config: null,
7109
7263
  guid: null,
7110
7264
  timeId_close_TouchEvent: [],
7111
7265
  timeId_close_MouseEvent: [],
7112
7266
  };
7113
- constructor(config, guid, ShadowInfo) {
7267
+ constructor(config, guid, ShadowInfo, emitter) {
7268
+ this.emitter = emitter;
7114
7269
  this.$data.config = config;
7115
7270
  this.$data.guid = guid;
7116
7271
  this.$el.$shadowContainer = ShadowInfo.$shadowContainer;
@@ -7156,7 +7311,7 @@ class ToolTip {
7156
7311
  // 处理className
7157
7312
  popsDOMUtils.addClassName($toolTipContainer, this.$data.config.className);
7158
7313
  // 添加z-index
7159
- $toolTipContainer.style.zIndex = PopsHandler.handleZIndex(this.$data.config.zIndex).toString();
7314
+ $toolTipContainer.style.zIndex = PopsHandler.getTargerOrFunctionValue(this.$data.config.zIndex).toString();
7160
7315
  // 添加自定义style
7161
7316
  PopsElementHandler.addStyle($toolTipContainer, this.$data.config.style);
7162
7317
  // 添加自定义浅色style
@@ -7204,7 +7359,7 @@ class ToolTip {
7204
7359
  * 获取z-index
7205
7360
  */
7206
7361
  getZIndex() {
7207
- const zIndex = PopsHandler.handleZIndex(this.$data.config.zIndex);
7362
+ const zIndex = PopsHandler.getTargerOrFunctionValue(this.$data.config.zIndex);
7208
7363
  return zIndex;
7209
7364
  }
7210
7365
  /**
@@ -7387,9 +7542,7 @@ class ToolTip {
7387
7542
  }
7388
7543
  if (!popsUtils.contains(this.$el.$shadowContainer)) {
7389
7544
  // 页面不存在Shadow,添加
7390
- if (typeof this.$data.config.beforeAppendToPageCallBack === "function") {
7391
- this.$data.config.beforeAppendToPageCallBack(this.$el.$shadowRoot, this.$el.$shadowContainer);
7392
- }
7545
+ this.emitter.emit("pops:before-append-to-page", this.$el.$shadowRoot, this.$el.$shadowContainer);
7393
7546
  popsDOMUtils.append(document.body, this.$el.$shadowContainer);
7394
7547
  }
7395
7548
  // 更新内容
@@ -7560,6 +7713,7 @@ const PopsTooltip = {
7560
7713
  const guid = popsUtils.getRandomGUID();
7561
7714
  // 设置当前类型
7562
7715
  const popsType = "tooltip";
7716
+ const emitter = new EventEmiter(popsType);
7563
7717
  let config = PopsTooltipDefaultConfig();
7564
7718
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
7565
7719
  config = popsUtils.assign(config, __config__);
@@ -7598,7 +7752,7 @@ const PopsTooltip = {
7598
7752
  const toolTip = new ToolTip(config, guid, {
7599
7753
  $shadowContainer,
7600
7754
  $shadowRoot,
7601
- });
7755
+ }, emitter);
7602
7756
  if (config.alwaysShow) {
7603
7757
  // 总是显示
7604
7758
  // 直接显示
@@ -7610,6 +7764,7 @@ const PopsTooltip = {
7610
7764
  $shadowContainer,
7611
7765
  $shadowRoot,
7612
7766
  toolTip,
7767
+ emitter,
7613
7768
  };
7614
7769
  },
7615
7770
  };
@@ -7658,6 +7813,7 @@ const PanelHandlerComponents = () => {
7658
7813
  nodeStoreConfigKey: "data-view-config",
7659
7814
  },
7660
7815
  $config: {},
7816
+ emitter: null,
7661
7817
  /**
7662
7818
  * 初始化
7663
7819
  * @param data
@@ -7668,6 +7824,7 @@ const PanelHandlerComponents = () => {
7668
7824
  ...data.$el,
7669
7825
  };
7670
7826
  this.$config = data.config;
7827
+ this.emitter = data.emitter;
7671
7828
  this.asideULElement = this.$el.$panelLeftAside.querySelector(`ul.pops-${PopsType}-aside-top-container`);
7672
7829
  this.asideBottomULElement = this.$el.$panelLeftAside.querySelector(`ul.pops-${PopsType}-aside-bottom-container`);
7673
7830
  this.sectionContainerHeaderULElement = this.$el.$panelContentSectionContainer.querySelector(`ul.pops-${PopsType}-container-header-ul`);
@@ -8578,7 +8735,8 @@ const PanelHandlerComponents = () => {
8578
8735
  $target: this.$ele.button,
8579
8736
  content: getToolTipContent,
8580
8737
  zIndex: () => {
8581
- return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
8738
+ // return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
8739
+ return popsUtils.getMaxZIndexNodeInfoFromPoint(this.$ele.button)[0].zIndex;
8582
8740
  },
8583
8741
  isFixed: true,
8584
8742
  className: "github-tooltip",
@@ -11169,91 +11327,31 @@ const PanelHandlerComponents = () => {
11169
11327
  className: "pops-panel-deepMenu-container-left-arrow-icon",
11170
11328
  innerHTML: PopsIcon.getIcon("arrowLeft"),
11171
11329
  });
11172
- // 动画配置
11173
- const animOptions = {
11174
- // 150 220 300
11175
- duration: 220,
11176
- easing: "ease-in-out",
11177
- };
11178
- // 进入动画
11179
- const enterViewTransition = () => {
11180
- // 隐藏旧的容器
11181
- popsDOMUtils.cssHide($currentSection, true);
11182
- popsDOMUtils.on($headerLeftArrow, "click", async (event) => {
11183
- popsDOMUtils.preventEvent(event);
11184
- // 返回动画
11185
- const leaveViewTransition = () => {
11186
- const $prev = $currentSection;
11187
- popsDOMUtils.cssShow($prev);
11188
- $deepMenuSection.remove();
11189
- };
11190
- // 返回上一层菜单
11191
- if (that.$config.useDeepMenuSwtichAnimation && document.startViewTransition) {
11192
- const leaveTransition = document.startViewTransition(leaveViewTransition);
11193
- await leaveTransition.ready;
11194
- // 向右移出
11195
- await Promise.all([
11196
- $deepMenuSection.animate([
11197
- {
11198
- // from
11199
- transform: "translateX(0)",
11200
- },
11201
- {
11202
- // to
11203
- transform: "translateX(100%)",
11204
- },
11205
- ], animOptions).finished,
11206
- // 向右移入
11207
- $currentSection.animate([
11208
- {
11209
- // from
11210
- transform: "translateX(-100%)",
11211
- },
11212
- {
11213
- // to
11214
- transform: "translateX(0)",
11215
- },
11216
- ], animOptions).finished,
11217
- ]);
11218
- await leaveTransition.finished;
11219
- }
11220
- else {
11221
- leaveViewTransition();
11222
- }
11223
- that.emitRenderRightContainer($currentSection);
11224
- }, {
11225
- once: true,
11226
- });
11227
- popsDOMUtils.before($header.firstElementChild, $headerLeftArrow);
11228
- $deepMenuHeaderUL.appendChild($header);
11229
- $deepMenuSection.appendChild($deepMenuHeaderUL);
11230
- $deepMenuSection.appendChild($deepMenuMain);
11231
- if (viewConfig.views && Array.isArray(viewConfig.views)) {
11232
- for (let index = 0; index < viewConfig.views.length; index++) {
11233
- const formItemConfig = viewConfig.views[index];
11234
- 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
+ }
11235
11350
  }
11236
- }
11237
- that.$el.$panelRightSectionWrapper.appendChild($deepMenuSection);
11238
- };
11239
- if (that.$config.useDeepMenuSwtichAnimation && document.startViewTransition) {
11240
- const transition = document.startViewTransition(enterViewTransition);
11241
- await transition.ready;
11242
- await $deepMenuSection.animate([
11243
- {
11244
- // from
11245
- transform: "translateX(100%)",
11246
- },
11247
- {
11248
- // to
11249
- transform: "translateX(0)",
11250
- },
11251
- ], animOptions).finished;
11252
- await transition.finished;
11253
- }
11254
- else {
11255
- enterViewTransition();
11256
- }
11351
+ that.$el.$panelRightSectionWrapper.appendChild($deepMenuSection);
11352
+ },
11353
+ });
11354
+ await switchAnim.enter();
11257
11355
  if (typeof viewConfig.afterEnterDeepMenuCallBack === "function") {
11258
11356
  viewConfig.afterEnterDeepMenuCallBack(viewConfig, {
11259
11357
  $sectionContainer: $deepMenuSection,
@@ -11425,11 +11523,9 @@ const PanelHandlerComponents = () => {
11425
11523
  */
11426
11524
  emitRenderRightContainer($container) {
11427
11525
  const dataViewConfig = Reflect.get($container, this.$data.nodeStoreConfigKey);
11428
- this.$el.$pops.dispatchEvent(new CustomEvent("pops:renderRightContainer", {
11429
- detail: {
11430
- viewConfig: dataViewConfig,
11431
- },
11432
- }));
11526
+ this.emitter.emit("pops:renderRightContainer", {
11527
+ viewConfig: dataViewConfig,
11528
+ });
11433
11529
  },
11434
11530
  /**
11435
11531
  *
@@ -11499,6 +11595,7 @@ const PopsPanel = {
11499
11595
  const guid = popsUtils.getRandomGUID();
11500
11596
  // 设置当前类型
11501
11597
  const popsType = "panel";
11598
+ const emitter = new EventEmiter(popsType);
11502
11599
  let config = PopsPanelDefaultConfig();
11503
11600
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11504
11601
  config = popsUtils.assign(config, __config__);
@@ -11535,7 +11632,7 @@ const PopsPanel = {
11535
11632
  },
11536
11633
  ]);
11537
11634
  // 先把z-index提取出来
11538
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
11635
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
11539
11636
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
11540
11637
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
11541
11638
  const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
@@ -11593,15 +11690,13 @@ const PopsPanel = {
11593
11690
  $elList.push($mask);
11594
11691
  }
11595
11692
  // 处理返回的配置
11596
- 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);
11597
11694
  const result = PopsHandler.handleResultConfig(evtConfig);
11598
11695
  // 为顶部右边的关闭按钮添加点击事件
11599
11696
  PopsHandler.handleClickEvent("close", $headerBtnClose, evtConfig, config.btn?.close?.callback);
11600
11697
  // 创建到页面中
11601
11698
  popsDOMUtils.append($shadowRoot, $elList);
11602
- if (typeof config.beforeAppendToPageCallBack === "function") {
11603
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
11604
- }
11699
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
11605
11700
  popsDOMUtils.appendBody($shadowContainer);
11606
11701
  // 追加遮罩层元素
11607
11702
  if ($mask != null) {
@@ -11624,6 +11719,7 @@ const PopsPanel = {
11624
11719
  $panelBottomLeftContainer,
11625
11720
  $panelBottomRightContainer,
11626
11721
  },
11722
+ emitter,
11627
11723
  });
11628
11724
  PopsHandler.handlePush(popsType, {
11629
11725
  guid: guid,
@@ -11633,11 +11729,11 @@ const PopsPanel = {
11633
11729
  $shadowContainer: $shadowContainer,
11634
11730
  $shadowRoot: $shadowRoot,
11635
11731
  config: config,
11636
- destory: result.close,
11732
+ emitter,
11637
11733
  });
11638
11734
  // 拖拽
11639
11735
  if (config.drag) {
11640
- PopsInstanceUtils.drag($pops, {
11736
+ PopsInstHandler.drag($pops, {
11641
11737
  dragElement: $title,
11642
11738
  limit: config.dragLimit,
11643
11739
  extraDistance: config.dragExtraDistance,
@@ -11645,15 +11741,21 @@ const PopsPanel = {
11645
11741
  endCallBack: config.dragEndCallBack,
11646
11742
  });
11647
11743
  }
11648
- return {
11649
- ...result,
11650
- addEventListener: (event, listener, options) => {
11651
- $pops.addEventListener(event, listener, options);
11652
- },
11653
- removeEventListener: (event, listener, options) => {
11654
- $pops.removeEventListener(event, listener, options);
11655
- },
11656
- };
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;
11657
11759
  },
11658
11760
  };
11659
11761
 
@@ -11748,6 +11850,7 @@ const PopsPromptDefaultConfig = () => {
11748
11850
  lightStyle: null,
11749
11851
  darkStyle: null,
11750
11852
  beforeAppendToPageCallBack() { },
11853
+ stopKeyDownEventPropagation: true,
11751
11854
  };
11752
11855
  };
11753
11856
 
@@ -11756,6 +11859,7 @@ const PopsPrompt = {
11756
11859
  const guid = popsUtils.getRandomGUID();
11757
11860
  // 设置当前类型
11758
11861
  const popsType = "prompt";
11862
+ const emitter = new EventEmiter(popsType);
11759
11863
  let config = PopsPromptDefaultConfig();
11760
11864
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11761
11865
  config = popsUtils.assign(config, __config__);
@@ -11792,7 +11896,7 @@ const PopsPrompt = {
11792
11896
  },
11793
11897
  ]);
11794
11898
  // 先把z-index提取出来
11795
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
11899
+ const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
11796
11900
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
11797
11901
  const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
11798
11902
  const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
@@ -11837,7 +11941,7 @@ const PopsPrompt = {
11837
11941
  $mask = handleMask.maskElement;
11838
11942
  $elList.push($mask);
11839
11943
  }
11840
- 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);
11841
11945
  const result = PopsHandler.handleResultConfig(evtConfig);
11842
11946
  // 输入框赋值初始值
11843
11947
  $input.value = config.content.text;
@@ -11847,9 +11951,7 @@ const PopsPrompt = {
11847
11951
  PopsHandler.handlePromptClickEvent("other", $input, $btnOther, evtConfig, config.btn.other.callback);
11848
11952
  // 创建到页面中
11849
11953
  popsDOMUtils.append($shadowRoot, $elList);
11850
- if (typeof config.beforeAppendToPageCallBack === "function") {
11851
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
11852
- }
11954
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
11853
11955
  popsDOMUtils.appendBody($shadowContainer);
11854
11956
  if ($mask != null) {
11855
11957
  $anim.after($mask);
@@ -11862,11 +11964,11 @@ const PopsPrompt = {
11862
11964
  $shadowContainer: $shadowContainer,
11863
11965
  $shadowRoot: $shadowRoot,
11864
11966
  config: config,
11865
- destory: result.close,
11967
+ emitter,
11866
11968
  });
11867
11969
  // 拖拽
11868
11970
  if (config.drag) {
11869
- PopsInstanceUtils.drag($pops, {
11971
+ PopsInstHandler.drag($pops, {
11870
11972
  dragElement: $title,
11871
11973
  limit: config.dragLimit,
11872
11974
  extraDistance: config.dragExtraDistance,
@@ -11994,6 +12096,7 @@ const PopsRightClickMenu = {
11994
12096
  const guid = popsUtils.getRandomGUID();
11995
12097
  // 设置当前类型
11996
12098
  const popsType = "rightClickMenu";
12099
+ const emitter = new EventEmiter(popsType);
11997
12100
  let config = PopsRightClickMenuDefaultConfig();
11998
12101
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11999
12102
  config = popsUtils.assign(config, __config__);
@@ -12122,13 +12225,14 @@ const PopsRightClickMenu = {
12122
12225
  guid: guid,
12123
12226
  $anim: rootElement,
12124
12227
  $pops: rootElement,
12125
- beforeRemoveCallBack(instCommonConfig) {
12126
- PopsContextMenu.closeAllMenu(instCommonConfig.$pops);
12127
- },
12128
12228
  config: config,
12129
- destory: () => {
12130
- PopsContextMenu.closeAllMenu(rootElement);
12131
- },
12229
+ emitter,
12230
+ });
12231
+ emitter.on("pops:before-destory", () => {
12232
+ PopsContextMenu.closeAllMenu(rootElement);
12233
+ });
12234
+ emitter.on("pops:destory", () => {
12235
+ PopsContextMenu.closeAllMenu(rootElement);
12132
12236
  });
12133
12237
  }
12134
12238
  },
@@ -12216,6 +12320,7 @@ const PopsRightClickMenu = {
12216
12320
  });
12217
12321
  const zIndex = this.getMenuZIndex();
12218
12322
  if (zIndex > 10000) {
12323
+ // 大于默认值
12219
12324
  $menu.style.zIndex = zIndex.toString();
12220
12325
  }
12221
12326
  if (isChildren) {
@@ -12236,7 +12341,7 @@ const PopsRightClickMenu = {
12236
12341
  * 动态获取配的z-index
12237
12342
  */
12238
12343
  getMenuZIndex() {
12239
- return PopsHandler.handleZIndex(config.zIndex);
12344
+ return PopsHandler.getTargerOrFunctionValue(config.zIndex);
12240
12345
  },
12241
12346
  /**
12242
12347
  * 获取left、top偏移
@@ -12350,9 +12455,7 @@ const PopsRightClickMenu = {
12350
12455
  popsDOMUtils.append($shadowRoot, menuElement);
12351
12456
  // 判断容器是否存在
12352
12457
  if (!document.contains($shadowContainer)) {
12353
- if (typeof config.beforeAppendToPageCallBack === "function") {
12354
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
12355
- }
12458
+ emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
12356
12459
  popsDOMUtils.appendBody($shadowContainer);
12357
12460
  }
12358
12461
  this.handlerShowMenuCSS(menuElement, menuEvent);
@@ -12627,6 +12730,7 @@ const PopsSearchSuggestion = {
12627
12730
  const guid = popsUtils.getRandomGUID();
12628
12731
  // 设置当前类型
12629
12732
  const popsType = "searchSuggestion";
12733
+ const emitter = new EventEmiter(popsType);
12630
12734
  let config = PopsSearchSuggestionDefaultConfig();
12631
12735
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
12632
12736
  config = popsUtils.assign(config, __config__);
@@ -12663,6 +12767,7 @@ const PopsSearchSuggestion = {
12663
12767
  passive: true,
12664
12768
  };
12665
12769
  const SearchSuggestion = {
12770
+ emitter: emitter,
12666
12771
  /**
12667
12772
  * 当前的环境,可以是document,可以是shadowroot,默认是document
12668
12773
  */
@@ -12878,7 +12983,7 @@ const PopsSearchSuggestion = {
12878
12983
  border: initial;
12879
12984
  overflow: initial;
12880
12985
  position: ${config.isAbsolute ? "absolute" : "fixed"};
12881
- z-index: ${PopsHandler.handleZIndex(config.zIndex)};
12986
+ z-index: ${PopsHandler.getTargerOrFunctionValue(config.zIndex)};
12882
12987
  }
12883
12988
  .pops-${popsType}-search-suggestion-dropdown-wrapper{
12884
12989
  max-height: ${config.maxHeight};
@@ -13401,7 +13506,110 @@ const PopsSearchSuggestion = {
13401
13506
  },
13402
13507
  };
13403
13508
 
13404
- const version = "3.3.4";
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
+ };
13405
13613
 
13406
13614
  class Pops {
13407
13615
  /** 配置 */
@@ -13430,7 +13638,11 @@ class Pops {
13430
13638
  /** pops处理float类型使用的工具类 */
13431
13639
  MathFloatUtils: PopsMathFloatUtils,
13432
13640
  /** pops.panel中用于处理各个类型的工具 */
13433
- PanelHandlerComponents: PanelHandlerComponents,
13641
+ PanelHandlerComponents,
13642
+ /** pops.panel中的动画 */
13643
+ PopsAnimation,
13644
+ /** 事件类 */
13645
+ EventEmiter,
13434
13646
  };
13435
13647
  init() { }
13436
13648
  /**