@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.
- package/dist/index.amd.js +13118 -12906
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +805 -593
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +805 -593
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +13119 -12907
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +13122 -12910
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +13121 -12909
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Pops.d.ts +61 -46
- package/dist/types/src/PopsAnimation.d.ts +33 -0
- package/dist/types/src/PopsIcon.d.ts +1 -1
- package/dist/types/src/components/alert/index.d.ts +3 -1
- package/dist/types/src/components/confirm/index.d.ts +3 -1
- package/dist/types/src/components/drawer/index.d.ts +3 -1
- package/dist/types/src/components/folder/index.d.ts +3 -1
- package/dist/types/src/components/folder/types/index.d.ts +4 -0
- package/dist/types/src/components/iframe/index.d.ts +6 -1
- package/dist/types/src/components/iframe/types/index.d.ts +4 -2
- package/dist/types/src/components/loading/index.d.ts +3 -1
- package/dist/types/src/components/panel/handlerComponents.d.ts +4 -1
- package/dist/types/src/components/panel/index.d.ts +2 -16
- package/dist/types/src/components/panel/types/index.d.ts +7 -2
- package/dist/types/src/components/prompt/index.d.ts +3 -1
- package/dist/types/src/components/searchSuggestion/index.d.ts +4 -1
- package/dist/types/src/components/tooltip/index.d.ts +6 -2
- package/dist/types/src/config/GlobalConfig.d.ts +1 -0
- package/dist/types/src/event/EventEmiter.d.ts +33 -0
- package/dist/types/src/handler/PopsHandler.d.ts +18 -16
- package/dist/types/src/handler/PopsInstHandler.d.ts +67 -0
- package/dist/types/src/types/EventEmitter.d.ts +18 -0
- package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +4 -0
- package/dist/types/src/types/button.d.ts +2 -1
- package/dist/types/src/types/components.d.ts +7 -0
- package/dist/types/src/types/event.d.ts +6 -2
- package/dist/types/src/types/inst.d.ts +4 -4
- package/dist/types/src/utils/PopsDOMUtils.d.ts +0 -16
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +0 -88
- package/dist/types/src/utils/PopsUtils.d.ts +57 -0
- package/package.json +3 -3
- package/src/Pops.ts +7 -2
- package/src/PopsAnimation.ts +126 -0
- package/src/components/alert/defaultConfig.ts +1 -0
- package/src/components/alert/index.ts +9 -9
- package/src/components/confirm/defaultConfig.ts +1 -0
- package/src/components/confirm/index.ts +9 -9
- package/src/components/drawer/defaultConfig.ts +1 -0
- package/src/components/drawer/index.ts +12 -9
- package/src/components/folder/defaultConfig.ts +1 -0
- package/src/components/folder/index.ts +9 -8
- package/src/components/folder/types/index.ts +4 -0
- package/src/components/iframe/defaultConfig.ts +1 -0
- package/src/components/iframe/index.ts +18 -12
- package/src/components/iframe/types/index.ts +10 -8
- package/src/components/loading/defaultConfig.ts +1 -0
- package/src/components/loading/index.ts +12 -6
- package/src/components/panel/defaultConfig.ts +2 -0
- package/src/components/panel/handlerComponents.ts +41 -111
- package/src/components/panel/index.ts +34 -28
- package/src/components/panel/types/index.ts +7 -2
- package/src/components/prompt/defaultConfig.ts +1 -0
- package/src/components/prompt/index.ts +9 -8
- package/src/components/rightClickMenu/index.ts +17 -14
- package/src/components/searchSuggestion/index.ts +5 -1
- package/src/components/tooltip/index.ts +20 -10
- package/src/event/EventEmiter.ts +95 -0
- package/src/handler/PopsElementHandler.ts +6 -4
- package/src/handler/PopsHandler.ts +100 -58
- package/src/handler/PopsInstHandler.ts +557 -0
- package/src/types/EventEmitter.d.ts +18 -0
- package/src/types/PopsDOMUtilsEventType.d.ts +4 -0
- package/src/types/button.d.ts +2 -1
- package/src/types/components.d.ts +7 -0
- package/src/types/event.d.ts +6 -2
- package/src/types/inst.d.ts +4 -4
- package/src/utils/PopsDOMUtils.ts +1 -40
- package/src/utils/PopsInstanceUtils.ts +19 -627
- package/src/utils/PopsUtils.ts +194 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const version = "4.0.0";
|
|
2
|
+
|
|
1
3
|
const GlobalConfig = {
|
|
2
4
|
config: {},
|
|
3
5
|
/**
|
|
@@ -51,6 +53,72 @@ const GlobalConfig = {
|
|
|
51
53
|
},
|
|
52
54
|
};
|
|
53
55
|
|
|
56
|
+
class EventEmiter {
|
|
57
|
+
#type;
|
|
58
|
+
#data = new Map();
|
|
59
|
+
constructor(type) {
|
|
60
|
+
this.#type = type;
|
|
61
|
+
}
|
|
62
|
+
on(eventName, callback) {
|
|
63
|
+
const eventList = this.#data.get(eventName) ?? [];
|
|
64
|
+
eventList.push({ type: this.#type, time: Date.now(), callback: callback });
|
|
65
|
+
this.#data.set(eventName, eventList);
|
|
66
|
+
return {
|
|
67
|
+
off: () => {
|
|
68
|
+
this.off(eventName, callback);
|
|
69
|
+
},
|
|
70
|
+
emit: (...args) => {
|
|
71
|
+
this.emit(eventName, ...args);
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
off(eventName, callback) {
|
|
76
|
+
const eventList = this.#data.get(eventName) ?? [];
|
|
77
|
+
let isOffSuccess = false;
|
|
78
|
+
for (let index = eventList.length - 1; index >= 0; index--) {
|
|
79
|
+
if (eventList[index].callback === callback) {
|
|
80
|
+
isOffSuccess = true;
|
|
81
|
+
eventList.splice(index, 1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (eventList.length === 0) {
|
|
85
|
+
// empty
|
|
86
|
+
this.#data.delete(eventName);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
if (isOffSuccess) {
|
|
90
|
+
// update
|
|
91
|
+
this.#data.set(eventName, eventList);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async emit(eventName, ...args) {
|
|
96
|
+
const eventList = this.#data.get(eventName) ?? [];
|
|
97
|
+
for (const item of eventList) {
|
|
98
|
+
await item.callback(...args);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
offAll(eventName) {
|
|
102
|
+
if (typeof eventName === "string") {
|
|
103
|
+
this.#data.delete(eventName);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
this.#data.clear();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 获取所有添加的事件
|
|
111
|
+
*/
|
|
112
|
+
getAllEvents(eventName) {
|
|
113
|
+
if (typeof eventName === "string") {
|
|
114
|
+
return this.#data.get(eventName);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
return Array.from(this.#data.values());
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
54
122
|
var SVG_min = "<svg viewBox=\"0 0 1024 1024\" xmlns=\"http://www.w3.org/2000/svg\" data-type=\"min\">\r\n <path fill=\"currentColor\" d=\"M128 544h768a32 32 0 1 0 0-64H128a32 32 0 0 0 0 64z\"></path>\r\n</svg>\r\n";
|
|
55
123
|
|
|
56
124
|
var SVG_mise = "<svg viewBox=\"0 0 1024 1024\" xmlns=\"http://www.w3.org/2000/svg\" data-type=\"mise\">\r\n <path\r\n fill=\"currentColor\"\r\n d=\"M885.333333 85.333333H330.410667a53.333333 53.333333 0 0 0-53.333334 53.333334v106.666666H138.666667A53.333333 53.333333 0 0 0 85.333333 298.666667v586.666666a53.333333 53.333333 0 0 0 53.333334 53.333334H725.333333a53.333333 53.333333 0 0 0 53.333334-53.333334V746.154667h106.666666c29.44 0 53.333333-23.893333 53.333334-53.333334V138.666667A53.333333 53.333333 0 0 0 885.333333 85.333333zM725.333333 692.821333v192.512H138.666667V298.666667H725.333333v394.154666z m157.866667 0H778.666667V298.666667a53.333333 53.333333 0 0 0-53.333334-53.333334H330.410667v-106.666666h554.922666l-2.133333 554.154666z\"></path>\r\n</svg>\r\n";
|
|
@@ -251,6 +319,16 @@ function e(e){e.use(r$2,{name:"doubletap",tapTimes:2});const a=e.get("doubletap"
|
|
|
251
319
|
class i extends l$1{constructor(t,u$1){super(t,u$1),this.use(r$2),this.use(u),this.use(a),this.use(c),this.use(r),this.use(i$1);}}i.STATE_POSSIBLE=0,i.STATE_START=4,i.STATE_MOVE=5,i.STATE_END=1,i.STATE_CANCELLED=3,i.STATE_FAILED=2,i.STATE_RECOGNIZED=1,i.tap=r$2,i.pan=u,i.swipe=a,i.press=c,i.rotate=i$1,i.pinch=r,i.doubletap=e;
|
|
252
320
|
|
|
253
321
|
class PopsUtils {
|
|
322
|
+
/**
|
|
323
|
+
* 超时时间
|
|
324
|
+
*/
|
|
325
|
+
sleep(timeout) {
|
|
326
|
+
return new Promise((resolve) => {
|
|
327
|
+
setTimeout(() => {
|
|
328
|
+
resolve(true);
|
|
329
|
+
}, timeout);
|
|
330
|
+
});
|
|
331
|
+
}
|
|
254
332
|
/**
|
|
255
333
|
* 判断是否是window,例如window、self、globalThis
|
|
256
334
|
* @param target
|
|
@@ -542,6 +620,127 @@ class PopsUtils {
|
|
|
542
620
|
}
|
|
543
621
|
target[key] = newArr;
|
|
544
622
|
}
|
|
623
|
+
getMaxZIndexNodeInfoFromPoint($el, deviation) {
|
|
624
|
+
if (typeof $el === "function") {
|
|
625
|
+
$el = $el();
|
|
626
|
+
}
|
|
627
|
+
if (typeof $el === "number") {
|
|
628
|
+
deviation = $el;
|
|
629
|
+
$el = void 0;
|
|
630
|
+
}
|
|
631
|
+
if (typeof deviation !== "number" || Number.isNaN(deviation)) {
|
|
632
|
+
deviation = 10;
|
|
633
|
+
}
|
|
634
|
+
const leftTop = {
|
|
635
|
+
x: globalThis.innerWidth * (1 / 8),
|
|
636
|
+
y: globalThis.innerHeight * (1 / 8),
|
|
637
|
+
};
|
|
638
|
+
const leftBottom = {
|
|
639
|
+
x: globalThis.innerWidth * (1 / 8),
|
|
640
|
+
y: globalThis.innerHeight * (7 / 8),
|
|
641
|
+
};
|
|
642
|
+
const rightTop = {
|
|
643
|
+
x: globalThis.innerWidth * (7 / 8),
|
|
644
|
+
y: globalThis.innerHeight * (1 / 8),
|
|
645
|
+
};
|
|
646
|
+
const rightBottom = {
|
|
647
|
+
x: globalThis.innerWidth * (7 / 8),
|
|
648
|
+
y: globalThis.innerHeight * (7 / 8),
|
|
649
|
+
};
|
|
650
|
+
const center = {
|
|
651
|
+
x: globalThis.innerWidth / 2,
|
|
652
|
+
y: globalThis.innerHeight / 2,
|
|
653
|
+
};
|
|
654
|
+
const delayHandlerElementPostionList = [
|
|
655
|
+
leftTop,
|
|
656
|
+
leftBottom,
|
|
657
|
+
rightTop,
|
|
658
|
+
rightBottom,
|
|
659
|
+
center,
|
|
660
|
+
];
|
|
661
|
+
if ($el) {
|
|
662
|
+
delayHandlerElementPostionList.length = 0;
|
|
663
|
+
if (Array.isArray($el)) {
|
|
664
|
+
delayHandlerElementPostionList.push(...$el);
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
delayHandlerElementPostionList.push($el);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
const positionInfoList = delayHandlerElementPostionList
|
|
671
|
+
.map((position) => {
|
|
672
|
+
let positionNode;
|
|
673
|
+
let positionX;
|
|
674
|
+
let positionY;
|
|
675
|
+
if (position instanceof HTMLElement) {
|
|
676
|
+
positionNode = position;
|
|
677
|
+
const nodeRect = position.getBoundingClientRect();
|
|
678
|
+
positionX = nodeRect.x + nodeRect.width / 2;
|
|
679
|
+
positionY = nodeRect.y + nodeRect.height / 2;
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
positionNode = document.elementFromPoint(position.x, position.y);
|
|
683
|
+
positionX = position.x;
|
|
684
|
+
positionY = position.y;
|
|
685
|
+
}
|
|
686
|
+
const shadowRoot = positionNode?.shadowRoot;
|
|
687
|
+
if (shadowRoot) {
|
|
688
|
+
positionNode = shadowRoot.elementFromPoint(positionX, positionY);
|
|
689
|
+
}
|
|
690
|
+
if (positionNode instanceof HTMLStyleElement)
|
|
691
|
+
return;
|
|
692
|
+
if (positionNode instanceof HTMLScriptElement)
|
|
693
|
+
return;
|
|
694
|
+
if (positionNode instanceof HTMLMetaElement)
|
|
695
|
+
return;
|
|
696
|
+
if (positionNode instanceof HTMLHeadElement)
|
|
697
|
+
return;
|
|
698
|
+
if (!(positionNode instanceof HTMLElement))
|
|
699
|
+
return;
|
|
700
|
+
let parent = positionNode;
|
|
701
|
+
let zIndex = 0;
|
|
702
|
+
let maxZIndexNode = null;
|
|
703
|
+
while (parent) {
|
|
704
|
+
const nodeStyle = globalThis.getComputedStyle(parent);
|
|
705
|
+
const nodeZIndex = parseInt(nodeStyle.zIndex);
|
|
706
|
+
if (nodeStyle.position !== "static" && !isNaN(nodeZIndex)) {
|
|
707
|
+
if (nodeZIndex > zIndex) {
|
|
708
|
+
zIndex = nodeZIndex;
|
|
709
|
+
maxZIndexNode = parent;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
parent = parent.parentElement;
|
|
713
|
+
}
|
|
714
|
+
return {
|
|
715
|
+
/** 处理了偏移量后的z-index值 */
|
|
716
|
+
zIndex: zIndex + deviation,
|
|
717
|
+
/** 原始z-index值 */
|
|
718
|
+
originZIndex: zIndex,
|
|
719
|
+
/** 拥有最大z-index的元素 */
|
|
720
|
+
node: maxZIndexNode,
|
|
721
|
+
/** 目标坐标元素 */
|
|
722
|
+
positionNode: positionNode,
|
|
723
|
+
/** x坐标 */
|
|
724
|
+
positionX: positionX,
|
|
725
|
+
/** y坐标 */
|
|
726
|
+
positionY: positionY,
|
|
727
|
+
};
|
|
728
|
+
})
|
|
729
|
+
.filter((it) => it != null);
|
|
730
|
+
// 降序排序
|
|
731
|
+
positionInfoList.sort((a, b) => {
|
|
732
|
+
if (a.zIndex < b.zIndex) {
|
|
733
|
+
return 1;
|
|
734
|
+
}
|
|
735
|
+
else if (a.zIndex > b.zIndex) {
|
|
736
|
+
return -1;
|
|
737
|
+
}
|
|
738
|
+
else {
|
|
739
|
+
return 0;
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
return positionInfoList;
|
|
743
|
+
}
|
|
545
744
|
}
|
|
546
745
|
const popsUtils = new PopsUtils();
|
|
547
746
|
|
|
@@ -832,16 +1031,6 @@ class PopsDOMUtilsEvent {
|
|
|
832
1031
|
// 这是存在selector的情况
|
|
833
1032
|
listenerOption = getOption(args, 4, listenerOption);
|
|
834
1033
|
}
|
|
835
|
-
// 是否移除所有事件
|
|
836
|
-
let isRemoveAll = false;
|
|
837
|
-
if (args.length === 2) {
|
|
838
|
-
// 目标函数、事件名
|
|
839
|
-
isRemoveAll = true;
|
|
840
|
-
}
|
|
841
|
-
else if ((args.length === 3 && typeof args[2] === "string") || Array.isArray(args[2])) {
|
|
842
|
-
// 目标函数、事件名、子元素选择器
|
|
843
|
-
isRemoveAll = true;
|
|
844
|
-
}
|
|
845
1034
|
if (args.length === 5 && typeof args[4] === "function" && typeof filter !== "function") {
|
|
846
1035
|
// 目标函数、事件名、回调函数、事件配置、过滤函数
|
|
847
1036
|
filter = option;
|
|
@@ -871,7 +1060,7 @@ class PopsDOMUtilsEvent {
|
|
|
871
1060
|
// 事件的配置项不同
|
|
872
1061
|
flag = false;
|
|
873
1062
|
}
|
|
874
|
-
if (flag
|
|
1063
|
+
if (flag) {
|
|
875
1064
|
elementItem.removeEventListener(eventName, handler.callback, handler.option);
|
|
876
1065
|
const findIndex = handlers.findIndex((item) => item === handler);
|
|
877
1066
|
if (findIndex !== -1) {
|
|
@@ -1263,31 +1452,6 @@ class PopsDOMUtilsEvent {
|
|
|
1263
1452
|
const listener = this.on(target, "keydown", handler, option);
|
|
1264
1453
|
return listener;
|
|
1265
1454
|
}
|
|
1266
|
-
/**
|
|
1267
|
-
* 当按键按下时触发事件
|
|
1268
|
-
* keydown - > keypress - > keyup
|
|
1269
|
-
* @param target 目标
|
|
1270
|
-
* @param handler 事件处理函数
|
|
1271
|
-
* @param option 配置
|
|
1272
|
-
* @example
|
|
1273
|
-
* // 监听a.xx元素的按键按下
|
|
1274
|
-
* DOMUtils.keypress(document.querySelector("a.xx"),()=>{
|
|
1275
|
-
* console.log("按键按下");
|
|
1276
|
-
* })
|
|
1277
|
-
* DOMUtils.keypress("a.xx",()=>{
|
|
1278
|
-
* console.log("按键按下");
|
|
1279
|
-
* })
|
|
1280
|
-
*/
|
|
1281
|
-
onKeypress(target, handler, option) {
|
|
1282
|
-
if (target == null) {
|
|
1283
|
-
return;
|
|
1284
|
-
}
|
|
1285
|
-
if (typeof target === "string") {
|
|
1286
|
-
target = this.selector(target);
|
|
1287
|
-
}
|
|
1288
|
-
const listener = this.on(target, "keypress", handler, option);
|
|
1289
|
-
return listener;
|
|
1290
|
-
}
|
|
1291
1455
|
preventEvent(...args) {
|
|
1292
1456
|
/**
|
|
1293
1457
|
* 阻止事件的默认行为发生,并阻止事件传播
|
|
@@ -2458,7 +2622,7 @@ const PopsElementHandler = {
|
|
|
2458
2622
|
const popsPosition = __config__.position || "";
|
|
2459
2623
|
if (config.zIndex != null) {
|
|
2460
2624
|
popsAnimStyle += `z-index: ${zIndex};`;
|
|
2461
|
-
popsStyle += `z-index: ${zIndex};`;
|
|
2625
|
+
// popsStyle += `z-index: ${zIndex};`;
|
|
2462
2626
|
}
|
|
2463
2627
|
if (__config__.width != null) {
|
|
2464
2628
|
popsStyle += `width: ${__config__.width};`;
|
|
@@ -2467,11 +2631,15 @@ const PopsElementHandler = {
|
|
|
2467
2631
|
popsStyle += `height: ${__config__.height};`;
|
|
2468
2632
|
}
|
|
2469
2633
|
const hasBottomBtn = bottomBtnHTML.trim() === "" ? false : true;
|
|
2634
|
+
const popsClassNameList = ["pops"];
|
|
2635
|
+
if (config.class) {
|
|
2636
|
+
popsClassNameList.push(...config.class.split(" "));
|
|
2637
|
+
}
|
|
2470
2638
|
return /*html*/ `
|
|
2471
2639
|
<div class="pops-anim" anim="${__config__.animation || ""}" style="${popsAnimStyle}" data-guid="${guid}">${config.style != null ? /*html*/ `<style tyle="text/css" data-name="style">${config.style}</style>` : ""}
|
|
2472
2640
|
${config.lightStyle != null ? /*html*/ `<style tyle="text/css" data-name="lightStyle">@media (prefers-color-scheme: light) {${config.lightStyle}}</style>` : ""}
|
|
2473
2641
|
${config.darkStyle != null ? /*html*/ `<style tyle="text/css" data-name="darkStyle">@media (prefers-color-scheme: dark) {${config.darkStyle}}</style>` : ""}
|
|
2474
|
-
<div class="
|
|
2642
|
+
<div class="${popsClassNameList.join(" ")}" data-bottom-btn="${hasBottomBtn}" type-value="${type}" style="${popsStyle}" position="${popsPosition}" data-guid="${guid}">${html}</div>
|
|
2475
2643
|
</div>`;
|
|
2476
2644
|
},
|
|
2477
2645
|
/**
|
|
@@ -2837,6 +3005,105 @@ const PopsAnimation = {
|
|
|
2837
3005
|
hasAnim(name) {
|
|
2838
3006
|
return Object.prototype.hasOwnProperty.call(this.$data, name);
|
|
2839
3007
|
},
|
|
3008
|
+
/**
|
|
3009
|
+
* 带动画的进入元素
|
|
3010
|
+
* @param $el 当前元素
|
|
3011
|
+
* @param $next 切换的元素
|
|
3012
|
+
* @param option 配置
|
|
3013
|
+
*/
|
|
3014
|
+
createSwitchElementWithAnimation($el, $next, option) {
|
|
3015
|
+
const animOptions = {
|
|
3016
|
+
// 150 220 300
|
|
3017
|
+
duration: 220,
|
|
3018
|
+
easing: "ease-in-out",
|
|
3019
|
+
...(option.animOptions ?? {}),
|
|
3020
|
+
};
|
|
3021
|
+
if (option.useAnimation == null) {
|
|
3022
|
+
option.useAnimation = true;
|
|
3023
|
+
}
|
|
3024
|
+
return {
|
|
3025
|
+
/**
|
|
3026
|
+
* 进入
|
|
3027
|
+
*/
|
|
3028
|
+
async enter() {
|
|
3029
|
+
const transitionEndCallback = async () => {
|
|
3030
|
+
// 先直接隐藏旧的容器
|
|
3031
|
+
popsDOMUtils.cssHide($el, true);
|
|
3032
|
+
// 添加元素
|
|
3033
|
+
await option.enterToAddElementCallback();
|
|
3034
|
+
};
|
|
3035
|
+
// 进入下一层
|
|
3036
|
+
if (option.useAnimation && typeof document.startViewTransition == "function") {
|
|
3037
|
+
// 处理添加的元素的动画
|
|
3038
|
+
const transition = document.startViewTransition(transitionEndCallback);
|
|
3039
|
+
await transition.ready;
|
|
3040
|
+
await $next.animate(
|
|
3041
|
+
// 从右向左移入(进入动画)
|
|
3042
|
+
[
|
|
3043
|
+
{
|
|
3044
|
+
// from
|
|
3045
|
+
transform: "translateX(100%)",
|
|
3046
|
+
},
|
|
3047
|
+
{
|
|
3048
|
+
// to
|
|
3049
|
+
transform: "translateX(0)",
|
|
3050
|
+
},
|
|
3051
|
+
], animOptions).finished;
|
|
3052
|
+
await transition.finished;
|
|
3053
|
+
}
|
|
3054
|
+
else {
|
|
3055
|
+
await transitionEndCallback();
|
|
3056
|
+
}
|
|
3057
|
+
},
|
|
3058
|
+
/**
|
|
3059
|
+
* 退出
|
|
3060
|
+
*/
|
|
3061
|
+
async exit() {
|
|
3062
|
+
// 返回上一层菜单
|
|
3063
|
+
const transitionEndCallback = async () => {
|
|
3064
|
+
// 显示上层菜单
|
|
3065
|
+
popsDOMUtils.cssShow($el);
|
|
3066
|
+
// 移除下一层的菜单
|
|
3067
|
+
$next.remove();
|
|
3068
|
+
if (typeof option.exitToRemoveElementCallback === "function") {
|
|
3069
|
+
await option.exitToRemoveElementCallback();
|
|
3070
|
+
}
|
|
3071
|
+
};
|
|
3072
|
+
if (option.useAnimation && typeof document.startViewTransition == "function") {
|
|
3073
|
+
const leaveTransition = document.startViewTransition(transitionEndCallback);
|
|
3074
|
+
await leaveTransition.ready;
|
|
3075
|
+
await Promise.all([
|
|
3076
|
+
// 从原位置向右移出
|
|
3077
|
+
$next.animate([
|
|
3078
|
+
{
|
|
3079
|
+
// from
|
|
3080
|
+
transform: "translateX(0)",
|
|
3081
|
+
},
|
|
3082
|
+
{
|
|
3083
|
+
// to
|
|
3084
|
+
transform: "translateX(100%)",
|
|
3085
|
+
},
|
|
3086
|
+
], animOptions).finished,
|
|
3087
|
+
// 从最左边向右移入
|
|
3088
|
+
$el.animate([
|
|
3089
|
+
{
|
|
3090
|
+
// from
|
|
3091
|
+
transform: "translateX(-100%)",
|
|
3092
|
+
},
|
|
3093
|
+
{
|
|
3094
|
+
// to
|
|
3095
|
+
transform: "translateX(0)",
|
|
3096
|
+
},
|
|
3097
|
+
], animOptions).finished,
|
|
3098
|
+
]);
|
|
3099
|
+
await leaveTransition.finished;
|
|
3100
|
+
}
|
|
3101
|
+
else {
|
|
3102
|
+
await transitionEndCallback();
|
|
3103
|
+
}
|
|
3104
|
+
},
|
|
3105
|
+
};
|
|
3106
|
+
},
|
|
2840
3107
|
};
|
|
2841
3108
|
|
|
2842
3109
|
/**
|
|
@@ -2856,137 +3123,7 @@ const PopsInstData = {
|
|
|
2856
3123
|
tooltip: [],
|
|
2857
3124
|
};
|
|
2858
3125
|
|
|
2859
|
-
const
|
|
2860
|
-
/**
|
|
2861
|
-
* 获取页面中最大的z-index的元素信息
|
|
2862
|
-
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
2863
|
-
* @param node 进行判断的元素,默认是document
|
|
2864
|
-
* @param ignoreCallBack 执行元素处理时调用的函数,返回false可忽略不想要处理的元素
|
|
2865
|
-
* @example
|
|
2866
|
-
* Utils.getMaxZIndexNodeInfo();
|
|
2867
|
-
* > {
|
|
2868
|
-
* node: ...,
|
|
2869
|
-
* zIndex: 1001
|
|
2870
|
-
* }
|
|
2871
|
-
**/
|
|
2872
|
-
getMaxZIndexNodeInfo(deviation = 1, target = PopsCore.document, ignoreCallBack) {
|
|
2873
|
-
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
2874
|
-
// 最大值 2147483647
|
|
2875
|
-
// const maxZIndex = Math.pow(2, 31) - 1;
|
|
2876
|
-
// 比较值 2000000000
|
|
2877
|
-
const maxZIndexCompare = 2 * Math.pow(10, 9);
|
|
2878
|
-
// 当前页面最大的z-index
|
|
2879
|
-
let zIndex = 0;
|
|
2880
|
-
// 当前的最大z-index的元素,调试使用
|
|
2881
|
-
let maxZIndexNode = null;
|
|
2882
|
-
/**
|
|
2883
|
-
* 元素是否可见
|
|
2884
|
-
* @param $css
|
|
2885
|
-
*/
|
|
2886
|
-
function isVisibleNode($css) {
|
|
2887
|
-
return $css.position !== "static" && $css.display !== "none";
|
|
2888
|
-
}
|
|
2889
|
-
/**
|
|
2890
|
-
* 查询元素的z-index
|
|
2891
|
-
* 并比较值是否是已获取的最大值
|
|
2892
|
-
* @param $ele
|
|
2893
|
-
*/
|
|
2894
|
-
function queryMaxZIndex($ele) {
|
|
2895
|
-
if (typeof ignoreCallBack === "function") {
|
|
2896
|
-
const ignoreResult = ignoreCallBack($ele);
|
|
2897
|
-
if (typeof ignoreResult === "boolean" && !ignoreResult) {
|
|
2898
|
-
return;
|
|
2899
|
-
}
|
|
2900
|
-
}
|
|
2901
|
-
/** 元素的样式 */
|
|
2902
|
-
const nodeStyle = PopsCore.window.getComputedStyle($ele);
|
|
2903
|
-
// 不对position为static和display为none的元素进行获取它们的z-index
|
|
2904
|
-
if (isVisibleNode(nodeStyle)) {
|
|
2905
|
-
const nodeZIndex = parseInt(nodeStyle.zIndex);
|
|
2906
|
-
if (!isNaN(nodeZIndex)) {
|
|
2907
|
-
if (nodeZIndex > zIndex) {
|
|
2908
|
-
// 赋值到全局
|
|
2909
|
-
zIndex = nodeZIndex;
|
|
2910
|
-
maxZIndexNode = $ele;
|
|
2911
|
-
}
|
|
2912
|
-
}
|
|
2913
|
-
// 判断shadowRoot
|
|
2914
|
-
if ($ele.shadowRoot != null && $ele instanceof ShadowRoot) {
|
|
2915
|
-
$ele.shadowRoot.querySelectorAll("*").forEach(($shadowEle) => {
|
|
2916
|
-
queryMaxZIndex($shadowEle);
|
|
2917
|
-
});
|
|
2918
|
-
}
|
|
2919
|
-
}
|
|
2920
|
-
}
|
|
2921
|
-
target.querySelectorAll("*").forEach(($ele) => {
|
|
2922
|
-
queryMaxZIndex($ele);
|
|
2923
|
-
});
|
|
2924
|
-
zIndex += deviation;
|
|
2925
|
-
if (zIndex >= maxZIndexCompare) {
|
|
2926
|
-
// 最好不要超过最大值
|
|
2927
|
-
zIndex = maxZIndexCompare;
|
|
2928
|
-
}
|
|
2929
|
-
return {
|
|
2930
|
-
node: maxZIndexNode,
|
|
2931
|
-
zIndex: zIndex,
|
|
2932
|
-
};
|
|
2933
|
-
},
|
|
2934
|
-
/**
|
|
2935
|
-
* 获取pops所有弹窗中的最大的z-index
|
|
2936
|
-
* @param deviation
|
|
2937
|
-
*/
|
|
2938
|
-
getPopsMaxZIndex(deviation = 1) {
|
|
2939
|
-
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
2940
|
-
// 最大值 2147483647
|
|
2941
|
-
// const browserMaxZIndex = Math.pow(2, 31) - 1;
|
|
2942
|
-
// 比较值 2000000000
|
|
2943
|
-
const maxZIndex = 2 * Math.pow(10, 9);
|
|
2944
|
-
// 当前页面最大的z-index
|
|
2945
|
-
let zIndex = 0;
|
|
2946
|
-
// 当前的最大z-index的元素,调试使用
|
|
2947
|
-
let maxZIndexNode = null;
|
|
2948
|
-
/**
|
|
2949
|
-
* 元素是否可见
|
|
2950
|
-
* @param $css
|
|
2951
|
-
*/
|
|
2952
|
-
function isVisibleNode($css) {
|
|
2953
|
-
return $css.position !== "static" && $css.display !== "none";
|
|
2954
|
-
}
|
|
2955
|
-
Object.keys(PopsInstData).forEach((instKeyName) => {
|
|
2956
|
-
const instData = PopsInstData[instKeyName];
|
|
2957
|
-
for (let index = 0; index < instData.length; index++) {
|
|
2958
|
-
const inst = instData[index];
|
|
2959
|
-
const nodeStyle = window.getComputedStyle(inst.$anim);
|
|
2960
|
-
// 不对position为static和display为none的元素进行获取它们的z-index
|
|
2961
|
-
if (isVisibleNode(nodeStyle)) {
|
|
2962
|
-
const nodeZIndex = parseInt(nodeStyle.zIndex);
|
|
2963
|
-
if (!isNaN(nodeZIndex)) {
|
|
2964
|
-
if (nodeZIndex > zIndex) {
|
|
2965
|
-
zIndex = nodeZIndex;
|
|
2966
|
-
maxZIndexNode = inst.$anim;
|
|
2967
|
-
}
|
|
2968
|
-
}
|
|
2969
|
-
}
|
|
2970
|
-
}
|
|
2971
|
-
});
|
|
2972
|
-
zIndex += deviation;
|
|
2973
|
-
const isOverMaxZIndex = zIndex >= maxZIndex;
|
|
2974
|
-
if (isOverMaxZIndex) {
|
|
2975
|
-
// 超出z-index最大值
|
|
2976
|
-
zIndex = maxZIndex;
|
|
2977
|
-
}
|
|
2978
|
-
return { zIndex: zIndex, animElement: maxZIndexNode, isOverMaxZIndex };
|
|
2979
|
-
},
|
|
2980
|
-
/**
|
|
2981
|
-
* 获取页面中最大的z-index
|
|
2982
|
-
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
2983
|
-
* @example
|
|
2984
|
-
* getMaxZIndex();
|
|
2985
|
-
* > 1001
|
|
2986
|
-
**/
|
|
2987
|
-
getMaxZIndex(deviation = 1) {
|
|
2988
|
-
return this.getMaxZIndexNodeInfo(deviation).zIndex;
|
|
2989
|
-
},
|
|
3126
|
+
const PopsInstHandler = {
|
|
2990
3127
|
/**
|
|
2991
3128
|
* 删除配置中对应的对象
|
|
2992
3129
|
* @param totalInstConfigList 配置实例列表
|
|
@@ -2998,21 +3135,21 @@ const PopsInstanceUtils = {
|
|
|
2998
3135
|
* 移除元素实例
|
|
2999
3136
|
* @param instCommonConfig
|
|
3000
3137
|
*/
|
|
3001
|
-
const removeInst =
|
|
3002
|
-
|
|
3003
|
-
// 调用移除签的回调
|
|
3004
|
-
instCommonConfig.beforeRemoveCallBack(instCommonConfig);
|
|
3005
|
-
}
|
|
3138
|
+
const removeInst = async (instCommonConfig) => {
|
|
3139
|
+
await instCommonConfig.emitter.emit("pops:before-destory", instCommonConfig);
|
|
3006
3140
|
instCommonConfig?.$anim?.remove();
|
|
3007
3141
|
instCommonConfig?.$pops?.remove();
|
|
3008
3142
|
instCommonConfig?.$mask?.remove();
|
|
3009
3143
|
instCommonConfig?.$shadowContainer?.remove();
|
|
3144
|
+
await instCommonConfig.emitter.emit("pops:destory");
|
|
3145
|
+
// 再清空全部监听的事件
|
|
3146
|
+
await instCommonConfig.emitter.offAll();
|
|
3010
3147
|
};
|
|
3011
3148
|
const asyncInstTask = [];
|
|
3012
3149
|
// [ inst[], inst[],...]
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3150
|
+
for (const instConfigList of totalInstConfigList) {
|
|
3151
|
+
for (let index = 0; index < instConfigList.length; index++) {
|
|
3152
|
+
const instConfigItem = instConfigList[index];
|
|
3016
3153
|
// 移除全部或者guid相同
|
|
3017
3154
|
if (isAll || (typeof guid === "string" && instConfigItem.guid === guid)) {
|
|
3018
3155
|
// 判断是否有动画
|
|
@@ -3024,8 +3161,8 @@ const PopsInstanceUtils = {
|
|
|
3024
3161
|
popsDOMUtils.css(instConfigItem.$anim, "animation-name", reverseAnimName);
|
|
3025
3162
|
if (PopsAnimation.hasAnim(popsDOMUtils.css(instConfigItem.$anim, "animation-name"))) {
|
|
3026
3163
|
asyncInstTask.push(new Promise((resolve) => {
|
|
3027
|
-
popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(),
|
|
3028
|
-
removeInst(instConfigItem);
|
|
3164
|
+
popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), async () => {
|
|
3165
|
+
await removeInst(instConfigItem);
|
|
3029
3166
|
resolve();
|
|
3030
3167
|
}, {
|
|
3031
3168
|
capture: true,
|
|
@@ -3033,16 +3170,17 @@ const PopsInstanceUtils = {
|
|
|
3033
3170
|
}));
|
|
3034
3171
|
}
|
|
3035
3172
|
else {
|
|
3036
|
-
removeInst(instConfigItem);
|
|
3173
|
+
asyncInstTask.push(removeInst(instConfigItem));
|
|
3037
3174
|
}
|
|
3038
3175
|
}
|
|
3039
3176
|
else {
|
|
3040
|
-
removeInst(instConfigItem);
|
|
3177
|
+
asyncInstTask.push(removeInst(instConfigItem));
|
|
3041
3178
|
}
|
|
3042
3179
|
instConfigList.splice(index, 1);
|
|
3180
|
+
index--;
|
|
3043
3181
|
}
|
|
3044
|
-
}
|
|
3045
|
-
}
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3046
3184
|
await Promise.all(asyncInstTask);
|
|
3047
3185
|
return totalInstConfigList;
|
|
3048
3186
|
},
|
|
@@ -3056,60 +3194,71 @@ const PopsInstanceUtils = {
|
|
|
3056
3194
|
* @param $mask
|
|
3057
3195
|
*/
|
|
3058
3196
|
hide(config, popsType, instConfigList, guid, $anim, $mask) {
|
|
3059
|
-
|
|
3197
|
+
// oxlint-disable-next-line no-async-promise-executor
|
|
3198
|
+
return new Promise(async (resolve) => {
|
|
3060
3199
|
const $pops = $anim.querySelector(".pops[type-value]");
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3200
|
+
const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
|
|
3201
|
+
if (fintInst) {
|
|
3202
|
+
// 存在实例
|
|
3203
|
+
const startAnim = async () => {
|
|
3204
|
+
if (popsType === "drawer") {
|
|
3205
|
+
// drawer是抽屉
|
|
3206
|
+
// 单独处理动画
|
|
3207
|
+
const drawerConfig = config;
|
|
3208
|
+
await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
|
|
3209
|
+
if ($mask) {
|
|
3210
|
+
popsDOMUtils.css($mask, "display", "none");
|
|
3211
|
+
}
|
|
3212
|
+
const direction = drawerConfig.direction;
|
|
3213
|
+
const size = "0";
|
|
3214
|
+
if (["top", "bottom"].includes(direction)) {
|
|
3215
|
+
$pops.style.setProperty("height", size);
|
|
3216
|
+
}
|
|
3217
|
+
else if (["left", "right"].includes(direction)) {
|
|
3218
|
+
$pops.style.setProperty("width", size);
|
|
3219
|
+
}
|
|
3220
|
+
else {
|
|
3221
|
+
console.error("未知direction: ", direction);
|
|
3222
|
+
}
|
|
3072
3223
|
}
|
|
3073
3224
|
else {
|
|
3074
|
-
|
|
3225
|
+
instConfigItem.$anim.style.width = "100%";
|
|
3226
|
+
instConfigItem.$anim.style.height = "100%";
|
|
3227
|
+
Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim") + "-reverse");
|
|
3075
3228
|
}
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
if (fintInst) {
|
|
3082
|
-
// 存在动画
|
|
3083
|
-
const instConfigItem = fintInst;
|
|
3084
|
-
instConfigItem.$anim.style.width = "100%";
|
|
3085
|
-
instConfigItem.$anim.style.height = "100%";
|
|
3086
|
-
Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim") + "-reverse");
|
|
3087
|
-
if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
|
|
3088
|
-
/**
|
|
3089
|
-
* 动画结束的回调
|
|
3090
|
-
*/
|
|
3091
|
-
function animationendCallBack() {
|
|
3092
|
-
instConfigItem.$anim.style.display = "none";
|
|
3093
|
-
if (instConfigItem.$mask) {
|
|
3094
|
-
instConfigItem.$mask.style.display = "none";
|
|
3095
|
-
}
|
|
3096
|
-
popsDOMUtils.off(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
3097
|
-
capture: true,
|
|
3098
|
-
});
|
|
3099
|
-
resolve();
|
|
3100
|
-
}
|
|
3101
|
-
popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
3102
|
-
capture: true,
|
|
3103
|
-
});
|
|
3229
|
+
};
|
|
3230
|
+
const endCallback = () => {
|
|
3231
|
+
instConfigItem.$anim.style.display = "none";
|
|
3232
|
+
if (instConfigItem.$mask) {
|
|
3233
|
+
instConfigItem.$mask.style.display = "none";
|
|
3104
3234
|
}
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3235
|
+
fintInst.emitter.emit("pops:hide", instConfigItem);
|
|
3236
|
+
};
|
|
3237
|
+
const instConfigItem = fintInst;
|
|
3238
|
+
fintInst.emitter.emit("pops:before-hide", instConfigItem);
|
|
3239
|
+
await startAnim();
|
|
3240
|
+
if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
|
|
3241
|
+
/**
|
|
3242
|
+
* 动画结束的回调
|
|
3243
|
+
*/
|
|
3244
|
+
const animationendCallBack = () => {
|
|
3245
|
+
listener.off();
|
|
3246
|
+
endCallback();
|
|
3110
3247
|
resolve();
|
|
3111
|
-
}
|
|
3248
|
+
};
|
|
3249
|
+
const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
3250
|
+
capture: true,
|
|
3251
|
+
once: true,
|
|
3252
|
+
});
|
|
3112
3253
|
}
|
|
3254
|
+
else {
|
|
3255
|
+
endCallback();
|
|
3256
|
+
resolve();
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
else {
|
|
3260
|
+
console.error("hide-error: 该实例未存储");
|
|
3261
|
+
resolve();
|
|
3113
3262
|
}
|
|
3114
3263
|
});
|
|
3115
3264
|
},
|
|
@@ -3123,97 +3272,128 @@ const PopsInstanceUtils = {
|
|
|
3123
3272
|
* @param $mask
|
|
3124
3273
|
*/
|
|
3125
3274
|
show(config, popsType, instConfigList, guid, $anim, $mask) {
|
|
3126
|
-
|
|
3275
|
+
// oxlint-disable-next-line no-async-promise-executor
|
|
3276
|
+
return new Promise(async (resolve) => {
|
|
3127
3277
|
const $pops = $anim.querySelector(".pops[type-value]");
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
if (
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3278
|
+
const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
|
|
3279
|
+
if (fintInst) {
|
|
3280
|
+
const startAnim = async () => {
|
|
3281
|
+
if (popsType === "drawer") {
|
|
3282
|
+
// drawer是抽屉
|
|
3283
|
+
// 单独处理动画
|
|
3284
|
+
const drawerConfig = config;
|
|
3285
|
+
await popsUtils.sleep(drawerConfig.openDelay ?? 0);
|
|
3286
|
+
if ($mask) {
|
|
3287
|
+
popsDOMUtils.css($mask, "display", "");
|
|
3288
|
+
}
|
|
3289
|
+
const direction = drawerConfig.direction;
|
|
3290
|
+
const size = drawerConfig.size.toString();
|
|
3291
|
+
if (["top", "bottom"].includes(direction)) {
|
|
3292
|
+
$pops.style.setProperty("height", size);
|
|
3293
|
+
}
|
|
3294
|
+
else if (["left", "right"].includes(direction)) {
|
|
3295
|
+
$pops.style.setProperty("width", size);
|
|
3296
|
+
}
|
|
3297
|
+
else {
|
|
3298
|
+
console.error("未知direction:", direction);
|
|
3299
|
+
}
|
|
3141
3300
|
}
|
|
3142
3301
|
else {
|
|
3143
|
-
|
|
3302
|
+
instConfigItem.$anim.style.width = "";
|
|
3303
|
+
instConfigItem.$anim.style.height = "";
|
|
3304
|
+
Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim").replace("-reverse", ""));
|
|
3305
|
+
}
|
|
3306
|
+
};
|
|
3307
|
+
const endCallback = () => {
|
|
3308
|
+
instConfigItem.$anim.style.display = "";
|
|
3309
|
+
if (instConfigItem.$mask) {
|
|
3310
|
+
instConfigItem.$mask.style.display = "";
|
|
3144
3311
|
}
|
|
3312
|
+
fintInst.emitter.emit("pops:show", instConfigItem);
|
|
3313
|
+
};
|
|
3314
|
+
const instConfigItem = fintInst;
|
|
3315
|
+
fintInst.emitter.emit("pops:before-show", instConfigItem);
|
|
3316
|
+
await startAnim();
|
|
3317
|
+
if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
|
|
3318
|
+
/**
|
|
3319
|
+
* 动画结束的回调
|
|
3320
|
+
*/
|
|
3321
|
+
const animationendCallBack = () => {
|
|
3322
|
+
listener.off();
|
|
3323
|
+
endCallback();
|
|
3324
|
+
resolve();
|
|
3325
|
+
};
|
|
3326
|
+
const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
3327
|
+
capture: true,
|
|
3328
|
+
});
|
|
3329
|
+
}
|
|
3330
|
+
else {
|
|
3331
|
+
endCallback();
|
|
3145
3332
|
resolve();
|
|
3146
|
-
}
|
|
3333
|
+
}
|
|
3147
3334
|
}
|
|
3148
3335
|
else {
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3336
|
+
console.error("show-error: 该实例未存储");
|
|
3337
|
+
resolve();
|
|
3338
|
+
}
|
|
3339
|
+
});
|
|
3340
|
+
},
|
|
3341
|
+
/**
|
|
3342
|
+
* 关闭
|
|
3343
|
+
* @param popsType
|
|
3344
|
+
* @param instConfigList
|
|
3345
|
+
* @param guid
|
|
3346
|
+
* @param config
|
|
3347
|
+
* @param $anim
|
|
3348
|
+
*/
|
|
3349
|
+
async close(config, popsType, instConfigList, guid, $anim) {
|
|
3350
|
+
// 判断组件内部是否有rightClickMenu、tooltip、searchSuggestion组件
|
|
3351
|
+
// 有的话也需要关闭
|
|
3352
|
+
PopsInstData.rightClickMenu.forEach((itemConfig) => {
|
|
3353
|
+
const config = itemConfig.config;
|
|
3354
|
+
if (config.$target instanceof HTMLElement) {
|
|
3355
|
+
const $root = config.$target.getRootNode();
|
|
3356
|
+
if ($root instanceof HTMLElement && $root.parentElement == null) {
|
|
3357
|
+
// 触发销毁元素
|
|
3358
|
+
itemConfig.emitter.emit("pops:before-destory", itemConfig);
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
});
|
|
3362
|
+
PopsInstData.tooltip.forEach((itemConfig) => {
|
|
3363
|
+
const config = itemConfig.config;
|
|
3364
|
+
if (config.$target instanceof HTMLElement) {
|
|
3365
|
+
const $root = config.$target.getRootNode();
|
|
3366
|
+
if ($root instanceof HTMLElement && $root.parentElement == null) {
|
|
3367
|
+
// 触发销毁元素
|
|
3368
|
+
itemConfig.emitter.emit("pops:before-destory", itemConfig);
|
|
3180
3369
|
}
|
|
3181
3370
|
}
|
|
3182
3371
|
});
|
|
3183
|
-
},
|
|
3184
|
-
/**
|
|
3185
|
-
* 关闭
|
|
3186
|
-
* @param popsType
|
|
3187
|
-
* @param instConfigList
|
|
3188
|
-
* @param guid
|
|
3189
|
-
* @param config
|
|
3190
|
-
* @param $anim
|
|
3191
|
-
*/
|
|
3192
|
-
async close(config, popsType, instConfigList, guid, $anim) {
|
|
3193
3372
|
// eslint-disable-next-line no-async-promise-executor
|
|
3194
3373
|
await new Promise(async (resolve) => {
|
|
3195
3374
|
const $pops = $anim.querySelector(".pops[type-value]");
|
|
3196
3375
|
const drawerConfig = config;
|
|
3197
|
-
|
|
3198
|
-
* 动画结束事件
|
|
3199
|
-
*/
|
|
3200
|
-
function transitionendEvent() {
|
|
3376
|
+
const start = () => {
|
|
3201
3377
|
/**
|
|
3202
3378
|
* 弹窗已关闭的回调
|
|
3203
3379
|
*/
|
|
3204
|
-
async
|
|
3380
|
+
const transtionEndCallback = async (event) => {
|
|
3205
3381
|
if (event.propertyName !== "transform") {
|
|
3206
3382
|
return;
|
|
3207
3383
|
}
|
|
3208
|
-
|
|
3209
|
-
await
|
|
3384
|
+
listener.off();
|
|
3385
|
+
await PopsInstHandler.removeInstance([instConfigList], guid);
|
|
3210
3386
|
resolve();
|
|
3211
|
-
}
|
|
3387
|
+
};
|
|
3212
3388
|
// 监听过渡结束
|
|
3213
|
-
popsDOMUtils.on($pops, popsDOMUtils.getTransitionEndNameList(),
|
|
3214
|
-
|
|
3389
|
+
const listener = popsDOMUtils.on($pops, popsDOMUtils.getTransitionEndNameList(), transtionEndCallback, {
|
|
3390
|
+
once: true,
|
|
3391
|
+
});
|
|
3392
|
+
const popsTransForm = globalThis.getComputedStyle($pops).transform;
|
|
3215
3393
|
if (popsTransForm !== "none") {
|
|
3216
|
-
|
|
3394
|
+
// 不存在动画
|
|
3395
|
+
// 直接移除实例
|
|
3396
|
+
listener.emit({ propertyName: "transform" });
|
|
3217
3397
|
return;
|
|
3218
3398
|
}
|
|
3219
3399
|
if (["top"].includes(drawerConfig.direction)) {
|
|
@@ -3229,41 +3409,18 @@ const PopsInstanceUtils = {
|
|
|
3229
3409
|
$pops.style.setProperty("transform", "translateX(100%)");
|
|
3230
3410
|
}
|
|
3231
3411
|
else {
|
|
3232
|
-
console.error("未知direction
|
|
3412
|
+
console.error("未知direction: ", drawerConfig.direction);
|
|
3233
3413
|
}
|
|
3234
|
-
}
|
|
3414
|
+
};
|
|
3235
3415
|
if (popsType === "drawer") {
|
|
3236
|
-
popsUtils.
|
|
3237
|
-
|
|
3238
|
-
}, drawerConfig.closeDelay);
|
|
3416
|
+
await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
|
|
3417
|
+
start();
|
|
3239
3418
|
}
|
|
3240
3419
|
else {
|
|
3241
|
-
await
|
|
3420
|
+
await PopsInstHandler.removeInstance([instConfigList], guid);
|
|
3242
3421
|
resolve();
|
|
3243
3422
|
}
|
|
3244
3423
|
});
|
|
3245
|
-
// 判断组件内是否有rightClickMenu、tooltip、searchSuggestion组件
|
|
3246
|
-
// 有的话也需要关闭
|
|
3247
|
-
PopsInstData.rightClickMenu.forEach((itemConfig) => {
|
|
3248
|
-
const config = itemConfig.config;
|
|
3249
|
-
if (config.$target instanceof HTMLElement) {
|
|
3250
|
-
const $root = config.$target.getRootNode();
|
|
3251
|
-
if ($root instanceof HTMLElement && $root.parentElement == null) {
|
|
3252
|
-
// 触发销毁元素
|
|
3253
|
-
itemConfig.destory();
|
|
3254
|
-
}
|
|
3255
|
-
}
|
|
3256
|
-
});
|
|
3257
|
-
PopsInstData.tooltip.forEach((itemConfig) => {
|
|
3258
|
-
const config = itemConfig.config;
|
|
3259
|
-
if (config.$target instanceof HTMLElement) {
|
|
3260
|
-
const $root = config.$target.getRootNode();
|
|
3261
|
-
if ($root instanceof HTMLElement && $root.parentElement == null) {
|
|
3262
|
-
// 触发销毁元素
|
|
3263
|
-
itemConfig.destory();
|
|
3264
|
-
}
|
|
3265
|
-
}
|
|
3266
|
-
});
|
|
3267
3424
|
},
|
|
3268
3425
|
/**
|
|
3269
3426
|
* 拖拽元素
|
|
@@ -3351,17 +3508,10 @@ const PopsInstanceUtils = {
|
|
|
3351
3508
|
clickElementLeftOffset = event.x - rect.left;
|
|
3352
3509
|
clickElementTopOffset = event.y - rect.top;
|
|
3353
3510
|
transformInfo = popsDOMUtils.getTransform($move);
|
|
3354
|
-
//if (event.nativeEvent.offsetX) {
|
|
3355
|
-
// clickElementLeftOffset = parseInt(event.nativeEvent.offsetX);
|
|
3356
|
-
//} else {
|
|
3357
|
-
// clickElementLeftOffset = parseInt(event.getOffset().x);
|
|
3358
|
-
//}
|
|
3359
|
-
//if (event.nativeEvent.offsetY) {
|
|
3360
|
-
// clickElementTopOffset = parseInt(event.nativeEvent.offsetY);
|
|
3361
|
-
//} else {
|
|
3362
|
-
// clickElementTopOffset = parseInt(event.getOffset().y);
|
|
3363
|
-
//}
|
|
3364
3511
|
resumeMoveElementStyle = changeMoveElementStyle($move);
|
|
3512
|
+
if (typeof options.startCallBack === "function") {
|
|
3513
|
+
options.startCallBack($move, clickElementLeftOffset, clickElementTopOffset);
|
|
3514
|
+
}
|
|
3365
3515
|
}
|
|
3366
3516
|
/** 当前移动的left偏移 */
|
|
3367
3517
|
let currentMoveLeftOffset = event.x - clickElementLeftOffset + transformInfo.transformLeft;
|
|
@@ -3438,46 +3588,6 @@ const PopsInstanceUtils = {
|
|
|
3438
3588
|
});
|
|
3439
3589
|
}
|
|
3440
3590
|
},
|
|
3441
|
-
/**
|
|
3442
|
-
* 排序数组
|
|
3443
|
-
* @param getBeforeValueFun
|
|
3444
|
-
* @param getAfterValueFun
|
|
3445
|
-
* @param sortByDesc 排序是否降序,默认降序
|
|
3446
|
-
*/
|
|
3447
|
-
sortElementListByProperty(getBeforeValueFun, getAfterValueFun, sortByDesc = true) {
|
|
3448
|
-
if (typeof sortByDesc !== "boolean") {
|
|
3449
|
-
throw new TypeError("参数 sortByDesc 必须为boolean类型");
|
|
3450
|
-
}
|
|
3451
|
-
if (getBeforeValueFun == null || getAfterValueFun == null) {
|
|
3452
|
-
throw new Error("获取前面的值或后面的值的方法不能为空");
|
|
3453
|
-
}
|
|
3454
|
-
return function (after_obj, before_obj) {
|
|
3455
|
-
const beforeValue = getBeforeValueFun(before_obj); // 前
|
|
3456
|
-
const afterValue = getAfterValueFun(after_obj); // 后
|
|
3457
|
-
if (sortByDesc) {
|
|
3458
|
-
if (afterValue > beforeValue) {
|
|
3459
|
-
return -1;
|
|
3460
|
-
}
|
|
3461
|
-
else if (afterValue < beforeValue) {
|
|
3462
|
-
return 1;
|
|
3463
|
-
}
|
|
3464
|
-
else {
|
|
3465
|
-
return 0;
|
|
3466
|
-
}
|
|
3467
|
-
}
|
|
3468
|
-
else {
|
|
3469
|
-
if (afterValue < beforeValue) {
|
|
3470
|
-
return -1;
|
|
3471
|
-
}
|
|
3472
|
-
else if (afterValue > beforeValue) {
|
|
3473
|
-
return 1;
|
|
3474
|
-
}
|
|
3475
|
-
else {
|
|
3476
|
-
return 0;
|
|
3477
|
-
}
|
|
3478
|
-
}
|
|
3479
|
-
};
|
|
3480
|
-
},
|
|
3481
3591
|
};
|
|
3482
3592
|
|
|
3483
3593
|
const PopsHandler = {
|
|
@@ -3488,19 +3598,37 @@ const PopsHandler = {
|
|
|
3488
3598
|
const $shadowContainer = popsDOMUtils.createElement("div", {
|
|
3489
3599
|
className: "pops-shadow-container",
|
|
3490
3600
|
});
|
|
3601
|
+
let $shadowRoot;
|
|
3491
3602
|
if (config.useShadowRoot) {
|
|
3492
|
-
|
|
3493
|
-
return {
|
|
3494
|
-
$shadowContainer,
|
|
3495
|
-
$shadowRoot,
|
|
3496
|
-
};
|
|
3603
|
+
$shadowRoot = $shadowContainer.attachShadow({ mode: "open" });
|
|
3497
3604
|
}
|
|
3498
3605
|
else {
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3606
|
+
$shadowRoot = $shadowContainer;
|
|
3607
|
+
}
|
|
3608
|
+
// 添加键盘监听
|
|
3609
|
+
// rightClickMenu
|
|
3610
|
+
// searchSuggestion
|
|
3611
|
+
// tooltip
|
|
3612
|
+
// 以上都不需要添加该事件监听
|
|
3613
|
+
if (config.stopKeyDownEventPropagation) {
|
|
3614
|
+
popsDOMUtils.on($shadowRoot, "keydown", [
|
|
3615
|
+
'input[type="text"]',
|
|
3616
|
+
'input[type="password"]',
|
|
3617
|
+
'input[type="number"]',
|
|
3618
|
+
'input[type="email"]',
|
|
3619
|
+
'input[type="url"]',
|
|
3620
|
+
'input[type="search"]',
|
|
3621
|
+
"input:not([type])",
|
|
3622
|
+
"textarea",
|
|
3623
|
+
], (evt) => {
|
|
3624
|
+
evt.stopImmediatePropagation();
|
|
3625
|
+
evt.stopPropagation();
|
|
3626
|
+
}, { capture: true });
|
|
3503
3627
|
}
|
|
3628
|
+
return {
|
|
3629
|
+
$shadowContainer,
|
|
3630
|
+
$shadowRoot,
|
|
3631
|
+
};
|
|
3504
3632
|
},
|
|
3505
3633
|
/**
|
|
3506
3634
|
* 处理初始化
|
|
@@ -3573,11 +3701,11 @@ const PopsHandler = {
|
|
|
3573
3701
|
function originalRun() {
|
|
3574
3702
|
if (config.config.mask.clickEvent.toClose) {
|
|
3575
3703
|
// 关闭
|
|
3576
|
-
return
|
|
3704
|
+
return PopsInstHandler.close(config.config, config.type, targetInst, config.guid, config.animElement);
|
|
3577
3705
|
}
|
|
3578
3706
|
else if (config.config.mask.clickEvent.toHide) {
|
|
3579
3707
|
// 隐藏
|
|
3580
|
-
return
|
|
3708
|
+
return PopsInstHandler.hide(config.config, config.type, targetInst, config.guid, config.animElement, result.maskElement);
|
|
3581
3709
|
}
|
|
3582
3710
|
}
|
|
3583
3711
|
if (typeof config.config.mask.clickCallBack === "function") {
|
|
@@ -3764,7 +3892,7 @@ const PopsHandler = {
|
|
|
3764
3892
|
* @param $mask 遮罩层
|
|
3765
3893
|
* @param config 当前配置
|
|
3766
3894
|
*/
|
|
3767
|
-
handleEventConfig(config, guid, $shadowContainer, $shadowRoot, type, $anim, $pops, $mask) {
|
|
3895
|
+
handleEventConfig(config, guid, $shadowContainer, $shadowRoot, type, $anim, $pops, emitter, $mask) {
|
|
3768
3896
|
return {
|
|
3769
3897
|
$shadowContainer: $shadowContainer,
|
|
3770
3898
|
$shadowRoot: $shadowRoot,
|
|
@@ -3774,17 +3902,18 @@ const PopsHandler = {
|
|
|
3774
3902
|
$mask: $mask,
|
|
3775
3903
|
mode: type,
|
|
3776
3904
|
guid: guid,
|
|
3905
|
+
emitter: emitter,
|
|
3777
3906
|
close() {
|
|
3778
|
-
return
|
|
3907
|
+
return PopsInstHandler.close(config, type, PopsInstData[type], guid, $anim);
|
|
3779
3908
|
},
|
|
3780
3909
|
hide() {
|
|
3781
|
-
return
|
|
3910
|
+
return PopsInstHandler.hide(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3782
3911
|
},
|
|
3783
3912
|
show($parent) {
|
|
3784
3913
|
if ($parent) {
|
|
3785
3914
|
$parent.appendChild(PopsInstData[type][0].$shadowRoot);
|
|
3786
3915
|
}
|
|
3787
|
-
return
|
|
3916
|
+
return PopsInstHandler.show(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3788
3917
|
},
|
|
3789
3918
|
};
|
|
3790
3919
|
},
|
|
@@ -3797,7 +3926,7 @@ const PopsHandler = {
|
|
|
3797
3926
|
* @param $mask 遮罩层
|
|
3798
3927
|
* @param config 当前配置
|
|
3799
3928
|
*/
|
|
3800
|
-
handleLoadingEventConfig(config, guid, type, $anim, $pops, $mask) {
|
|
3929
|
+
handleLoadingEventConfig(config, guid, type, $anim, $pops, emitter, $mask) {
|
|
3801
3930
|
return {
|
|
3802
3931
|
$el: $anim,
|
|
3803
3932
|
$anim: $anim,
|
|
@@ -3805,14 +3934,15 @@ const PopsHandler = {
|
|
|
3805
3934
|
$mask: $mask,
|
|
3806
3935
|
mode: type,
|
|
3807
3936
|
guid: guid,
|
|
3937
|
+
emitter,
|
|
3808
3938
|
close() {
|
|
3809
|
-
return
|
|
3939
|
+
return PopsInstHandler.close(config, type, PopsInstData[type], guid, $anim);
|
|
3810
3940
|
},
|
|
3811
3941
|
hide() {
|
|
3812
|
-
return
|
|
3942
|
+
return PopsInstHandler.hide(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3813
3943
|
},
|
|
3814
3944
|
show() {
|
|
3815
|
-
return
|
|
3945
|
+
return PopsInstHandler.show(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3816
3946
|
},
|
|
3817
3947
|
};
|
|
3818
3948
|
},
|
|
@@ -3836,7 +3966,7 @@ const PopsHandler = {
|
|
|
3836
3966
|
handleClickEvent(type, $btn, eventConfig, callback) {
|
|
3837
3967
|
if (typeof callback !== "function")
|
|
3838
3968
|
return;
|
|
3839
|
-
popsDOMUtils.on($btn, "click", (event) => {
|
|
3969
|
+
return popsDOMUtils.on($btn, "click", (event) => {
|
|
3840
3970
|
const extraParam = {
|
|
3841
3971
|
type: type,
|
|
3842
3972
|
};
|
|
@@ -3874,16 +4004,10 @@ const PopsHandler = {
|
|
|
3874
4004
|
callback && callback(event);
|
|
3875
4005
|
}
|
|
3876
4006
|
};
|
|
3877
|
-
popsDOMUtils.on(PopsCore.globalThis, "keydown", keyboardEvent, {
|
|
4007
|
+
const listener = popsDOMUtils.on(PopsCore.globalThis, "keydown", keyboardEvent, {
|
|
3878
4008
|
capture: true,
|
|
3879
4009
|
});
|
|
3880
|
-
return
|
|
3881
|
-
removeKeyboardEvent() {
|
|
3882
|
-
popsDOMUtils.off(globalThis, "keydown", keyboardEvent, {
|
|
3883
|
-
capture: true,
|
|
3884
|
-
});
|
|
3885
|
-
},
|
|
3886
|
-
};
|
|
4010
|
+
return listener;
|
|
3887
4011
|
},
|
|
3888
4012
|
/**
|
|
3889
4013
|
* 处理prompt的点击事件
|
|
@@ -3906,15 +4030,16 @@ const PopsHandler = {
|
|
|
3906
4030
|
});
|
|
3907
4031
|
},
|
|
3908
4032
|
/**
|
|
3909
|
-
*
|
|
3910
|
-
* @param
|
|
4033
|
+
* 获取数值
|
|
4034
|
+
* @param target
|
|
3911
4035
|
*/
|
|
3912
|
-
|
|
3913
|
-
if (typeof
|
|
3914
|
-
|
|
4036
|
+
getTargerOrFunctionValue(target) {
|
|
4037
|
+
if (typeof target === "function") {
|
|
4038
|
+
const result = target();
|
|
4039
|
+
return result;
|
|
3915
4040
|
}
|
|
3916
4041
|
else {
|
|
3917
|
-
return
|
|
4042
|
+
return target;
|
|
3918
4043
|
}
|
|
3919
4044
|
},
|
|
3920
4045
|
/**
|
|
@@ -3931,11 +4056,11 @@ const PopsHandler = {
|
|
|
3931
4056
|
if (type === "loading" || type === "tooltip" || type === "rightClickMenu") {
|
|
3932
4057
|
const inst = PopsInstData[type];
|
|
3933
4058
|
if (inst) {
|
|
3934
|
-
|
|
4059
|
+
PopsInstHandler.removeInstance([inst], "", true);
|
|
3935
4060
|
}
|
|
3936
4061
|
}
|
|
3937
4062
|
else {
|
|
3938
|
-
|
|
4063
|
+
PopsInstHandler.removeInstance([
|
|
3939
4064
|
PopsInstData.alert,
|
|
3940
4065
|
PopsInstData.confirm,
|
|
3941
4066
|
PopsInstData.drawer,
|
|
@@ -3946,15 +4071,30 @@ const PopsHandler = {
|
|
|
3946
4071
|
], "", true);
|
|
3947
4072
|
}
|
|
3948
4073
|
}
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
4074
|
+
config = this.handleZIndex(config);
|
|
4075
|
+
return config;
|
|
4076
|
+
},
|
|
4077
|
+
/**
|
|
4078
|
+
* 处理z-index
|
|
4079
|
+
* @param config 配置
|
|
4080
|
+
*/
|
|
4081
|
+
handleZIndex(config) {
|
|
4082
|
+
// 对配置进行处理
|
|
4083
|
+
// 选择配置的z-index和已有的pops实例的最大z-index值
|
|
4084
|
+
const originZIndex = config.zIndex;
|
|
4085
|
+
const handler = () => {
|
|
4086
|
+
let deviation = 100;
|
|
4087
|
+
if (originZIndex.toString() !== handler.toString()) {
|
|
4088
|
+
// 避免叠加覆盖
|
|
4089
|
+
deviation += PopsHandler.getTargerOrFunctionValue(originZIndex) ?? 0;
|
|
4090
|
+
}
|
|
4091
|
+
let maxZIndex = deviation;
|
|
4092
|
+
const pointZIndexInfoList = popsUtils.getMaxZIndexNodeInfoFromPoint(deviation);
|
|
4093
|
+
const pointZIndexInfo = pointZIndexInfoList[0];
|
|
4094
|
+
maxZIndex = Math.max(maxZIndex, pointZIndexInfo?.zIndex ?? deviation);
|
|
4095
|
+
return maxZIndex;
|
|
4096
|
+
};
|
|
4097
|
+
config.zIndex = handler;
|
|
3958
4098
|
return config;
|
|
3959
4099
|
},
|
|
3960
4100
|
/**
|
|
@@ -4027,6 +4167,7 @@ const PopsAlertDefaultConfig = () => {
|
|
|
4027
4167
|
lightStyle: null,
|
|
4028
4168
|
darkStyle: null,
|
|
4029
4169
|
beforeAppendToPageCallBack() { },
|
|
4170
|
+
stopKeyDownEventPropagation: true,
|
|
4030
4171
|
};
|
|
4031
4172
|
};
|
|
4032
4173
|
|
|
@@ -4035,6 +4176,7 @@ const PopsAlert = {
|
|
|
4035
4176
|
const guid = popsUtils.getRandomGUID();
|
|
4036
4177
|
// 设置当前类型
|
|
4037
4178
|
const popsType = "alert";
|
|
4179
|
+
const emitter = new EventEmiter(popsType);
|
|
4038
4180
|
let config = PopsAlertDefaultConfig();
|
|
4039
4181
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
4040
4182
|
config = popsUtils.assign(config, __config__);
|
|
@@ -4071,7 +4213,7 @@ const PopsAlert = {
|
|
|
4071
4213
|
},
|
|
4072
4214
|
]);
|
|
4073
4215
|
// 先把z-index提取出来
|
|
4074
|
-
const zIndex = PopsHandler.
|
|
4216
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
4075
4217
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
4076
4218
|
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
4077
4219
|
const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
|
|
@@ -4107,7 +4249,7 @@ const PopsAlert = {
|
|
|
4107
4249
|
$elList.push($mask);
|
|
4108
4250
|
}
|
|
4109
4251
|
// 处理返回的配置
|
|
4110
|
-
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
4252
|
+
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
|
|
4111
4253
|
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4112
4254
|
// 为顶部右边的关闭按钮添加点击事件
|
|
4113
4255
|
PopsHandler.handleClickEvent("close", $headerCloseBtn, evtConfig, config.btn.close?.callback);
|
|
@@ -4115,9 +4257,7 @@ const PopsAlert = {
|
|
|
4115
4257
|
PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok?.callback);
|
|
4116
4258
|
// 创建到页面中
|
|
4117
4259
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
4118
|
-
|
|
4119
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
4120
|
-
}
|
|
4260
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
4121
4261
|
popsDOMUtils.appendBody($shadowContainer);
|
|
4122
4262
|
if ($mask != null) {
|
|
4123
4263
|
// 添加遮罩层
|
|
@@ -4132,11 +4272,11 @@ const PopsAlert = {
|
|
|
4132
4272
|
$shadowContainer: $shadowContainer,
|
|
4133
4273
|
$shadowRoot: $shadowRoot,
|
|
4134
4274
|
config: config,
|
|
4135
|
-
|
|
4275
|
+
emitter,
|
|
4136
4276
|
});
|
|
4137
4277
|
// 拖拽
|
|
4138
4278
|
if (config.drag) {
|
|
4139
|
-
|
|
4279
|
+
PopsInstHandler.drag($pops, {
|
|
4140
4280
|
dragElement: $title,
|
|
4141
4281
|
limit: config.dragLimit,
|
|
4142
4282
|
extraDistance: config.dragExtraDistance,
|
|
@@ -4235,6 +4375,7 @@ const PopsConfirmDefaultConfig = () => {
|
|
|
4235
4375
|
lightStyle: null,
|
|
4236
4376
|
darkStyle: null,
|
|
4237
4377
|
beforeAppendToPageCallBack() { },
|
|
4378
|
+
stopKeyDownEventPropagation: true,
|
|
4238
4379
|
};
|
|
4239
4380
|
};
|
|
4240
4381
|
|
|
@@ -4243,6 +4384,7 @@ const PopsConfirm = {
|
|
|
4243
4384
|
const guid = popsUtils.getRandomGUID();
|
|
4244
4385
|
// 设置当前类型
|
|
4245
4386
|
const popsType = "confirm";
|
|
4387
|
+
const emitter = new EventEmiter(popsType);
|
|
4246
4388
|
let config = PopsConfirmDefaultConfig();
|
|
4247
4389
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
4248
4390
|
config = popsUtils.assign(config, __config__);
|
|
@@ -4279,7 +4421,7 @@ const PopsConfirm = {
|
|
|
4279
4421
|
},
|
|
4280
4422
|
]);
|
|
4281
4423
|
// 先把z-index提取出来
|
|
4282
|
-
const zIndex = PopsHandler.
|
|
4424
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
4283
4425
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
4284
4426
|
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
4285
4427
|
const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
|
|
@@ -4318,7 +4460,7 @@ const PopsConfirm = {
|
|
|
4318
4460
|
$mask = handleMask.maskElement;
|
|
4319
4461
|
$elList.push($mask);
|
|
4320
4462
|
}
|
|
4321
|
-
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
4463
|
+
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
|
|
4322
4464
|
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4323
4465
|
PopsHandler.handleClickEvent("close", $btnClose, evtConfig, config.btn.close.callback);
|
|
4324
4466
|
PopsHandler.handleClickEvent("ok", $btnOk, evtConfig, config.btn.ok.callback);
|
|
@@ -4326,9 +4468,7 @@ const PopsConfirm = {
|
|
|
4326
4468
|
PopsHandler.handleClickEvent("other", $btnOther, evtConfig, config.btn.other.callback);
|
|
4327
4469
|
// 创建到页面中
|
|
4328
4470
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
4329
|
-
|
|
4330
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
4331
|
-
}
|
|
4471
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
4332
4472
|
popsDOMUtils.appendBody($shadowContainer);
|
|
4333
4473
|
if ($mask != null) {
|
|
4334
4474
|
$anim.after($mask);
|
|
@@ -4341,11 +4481,11 @@ const PopsConfirm = {
|
|
|
4341
4481
|
$shadowContainer: $shadowContainer,
|
|
4342
4482
|
$shadowRoot: $shadowRoot,
|
|
4343
4483
|
config: config,
|
|
4344
|
-
|
|
4484
|
+
emitter,
|
|
4345
4485
|
});
|
|
4346
4486
|
// 拖拽
|
|
4347
4487
|
if (config.drag) {
|
|
4348
|
-
|
|
4488
|
+
PopsInstHandler.drag($pops, {
|
|
4349
4489
|
dragElement: $title,
|
|
4350
4490
|
limit: config.dragLimit,
|
|
4351
4491
|
extraDistance: config.dragExtraDistance,
|
|
@@ -4443,6 +4583,7 @@ const PopsDrawerDefaultConfig = () => {
|
|
|
4443
4583
|
darkStyle: null,
|
|
4444
4584
|
beforeAppendToPageCallBack() { },
|
|
4445
4585
|
forbiddenScroll: false,
|
|
4586
|
+
stopKeyDownEventPropagation: true,
|
|
4446
4587
|
};
|
|
4447
4588
|
};
|
|
4448
4589
|
|
|
@@ -4451,6 +4592,7 @@ const PopsDrawer = {
|
|
|
4451
4592
|
const guid = popsUtils.getRandomGUID();
|
|
4452
4593
|
// 设置当前类型
|
|
4453
4594
|
const popsType = "drawer";
|
|
4595
|
+
const emitter = new EventEmiter(popsType);
|
|
4454
4596
|
let config = PopsDrawerDefaultConfig();
|
|
4455
4597
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
4456
4598
|
config = popsUtils.assign(config, __config__);
|
|
@@ -4487,7 +4629,7 @@ const PopsDrawer = {
|
|
|
4487
4629
|
},
|
|
4488
4630
|
]);
|
|
4489
4631
|
// 先把z-index提取出来
|
|
4490
|
-
const zIndex = PopsHandler.
|
|
4632
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
4491
4633
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
4492
4634
|
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
4493
4635
|
const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
|
|
@@ -4532,7 +4674,7 @@ const PopsDrawer = {
|
|
|
4532
4674
|
$mask = handleMask.maskElement;
|
|
4533
4675
|
$elList.push($mask);
|
|
4534
4676
|
}
|
|
4535
|
-
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
4677
|
+
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
|
|
4536
4678
|
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4537
4679
|
// 处理方向
|
|
4538
4680
|
$pops.setAttribute("direction", config.direction);
|
|
@@ -4556,9 +4698,12 @@ const PopsDrawer = {
|
|
|
4556
4698
|
}
|
|
4557
4699
|
// 按下Esc键触发关闭
|
|
4558
4700
|
if (config.closeOnPressEscape) {
|
|
4559
|
-
PopsHandler.handleKeyboardEvent("Escape", [], function () {
|
|
4701
|
+
const listener = PopsHandler.handleKeyboardEvent("Escape", [], function () {
|
|
4560
4702
|
evtConfig.close();
|
|
4561
4703
|
});
|
|
4704
|
+
emitter.on("pops:destory", () => {
|
|
4705
|
+
listener.off();
|
|
4706
|
+
});
|
|
4562
4707
|
}
|
|
4563
4708
|
// 待处理的点击事件列表
|
|
4564
4709
|
const needHandleClickEventList = [
|
|
@@ -4610,9 +4755,7 @@ const PopsDrawer = {
|
|
|
4610
4755
|
});
|
|
4611
4756
|
// 创建到页面中
|
|
4612
4757
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
4613
|
-
|
|
4614
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
4615
|
-
}
|
|
4758
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
4616
4759
|
popsDOMUtils.appendBody($shadowContainer);
|
|
4617
4760
|
popsUtils.setTimeout(() => {
|
|
4618
4761
|
popsUtils.setTimeout(() => {
|
|
@@ -4630,7 +4773,7 @@ const PopsDrawer = {
|
|
|
4630
4773
|
$shadowContainer: $shadowContainer,
|
|
4631
4774
|
$shadowRoot: $shadowRoot,
|
|
4632
4775
|
config: config,
|
|
4633
|
-
|
|
4776
|
+
emitter: emitter,
|
|
4634
4777
|
});
|
|
4635
4778
|
return result;
|
|
4636
4779
|
},
|
|
@@ -4663,6 +4806,7 @@ const PopsLoadingDefaultConfig = () => {
|
|
|
4663
4806
|
lightStyle: null,
|
|
4664
4807
|
darkStyle: null,
|
|
4665
4808
|
addIndexCSS: true,
|
|
4809
|
+
stopKeyDownEventPropagation: true,
|
|
4666
4810
|
};
|
|
4667
4811
|
};
|
|
4668
4812
|
|
|
@@ -4671,12 +4815,13 @@ const PopsLoading = {
|
|
|
4671
4815
|
const guid = popsUtils.getRandomGUID();
|
|
4672
4816
|
// 设置当前类型
|
|
4673
4817
|
const PopsType = "loading";
|
|
4818
|
+
const emitter = new EventEmiter(PopsType);
|
|
4674
4819
|
let config = PopsLoadingDefaultConfig();
|
|
4675
4820
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
4676
4821
|
config = popsUtils.assign(config, __config__);
|
|
4677
4822
|
config = PopsHandler.handleOnly(PopsType, config);
|
|
4678
4823
|
// 先把z-index提取出来
|
|
4679
|
-
const zIndex = PopsHandler.
|
|
4824
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
4680
4825
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
4681
4826
|
const { contentPStyle } = PopsElementHandler.createContentStyle("loading", config);
|
|
4682
4827
|
const animHTML = PopsElementHandler.createAnim(guid, PopsType, config,
|
|
@@ -4719,17 +4864,20 @@ const PopsLoading = {
|
|
|
4719
4864
|
$mask = handleMask.maskElement;
|
|
4720
4865
|
$elList.push($mask);
|
|
4721
4866
|
}
|
|
4722
|
-
const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, $mask);
|
|
4867
|
+
const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, emitter, $mask);
|
|
4723
4868
|
popsDOMUtils.append(config.$parent, $elList);
|
|
4724
4869
|
if ($mask != null) {
|
|
4725
4870
|
$anim.after($mask);
|
|
4726
4871
|
}
|
|
4727
|
-
// @ts-ignore
|
|
4728
4872
|
PopsHandler.handlePush(PopsType, {
|
|
4873
|
+
$shadowContainer: $pops,
|
|
4874
|
+
$shadowRoot: $pops,
|
|
4729
4875
|
guid: guid,
|
|
4730
4876
|
$anim: $anim,
|
|
4731
4877
|
$pops: $pops,
|
|
4732
4878
|
$mask: $mask,
|
|
4879
|
+
emitter: emitter,
|
|
4880
|
+
config: config,
|
|
4733
4881
|
});
|
|
4734
4882
|
if (config.isAbsolute) {
|
|
4735
4883
|
// 遮罩层必须是跟随主内容
|
|
@@ -4891,6 +5039,7 @@ const PopsFolderDefaultConfig = () => {
|
|
|
4891
5039
|
lightStyle: null,
|
|
4892
5040
|
darkStyle: null,
|
|
4893
5041
|
beforeAppendToPageCallBack() { },
|
|
5042
|
+
stopKeyDownEventPropagation: true,
|
|
4894
5043
|
};
|
|
4895
5044
|
};
|
|
4896
5045
|
|
|
@@ -4927,6 +5076,7 @@ const PopsFolder = {
|
|
|
4927
5076
|
const guid = popsUtils.getRandomGUID();
|
|
4928
5077
|
// 设置当前类型
|
|
4929
5078
|
const popsType = "folder";
|
|
5079
|
+
const emitter = new EventEmiter(popsType);
|
|
4930
5080
|
let config = PopsFolderDefaultConfig();
|
|
4931
5081
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
4932
5082
|
config = popsUtils.assign(config, __config__);
|
|
@@ -5010,7 +5160,7 @@ const PopsFolder = {
|
|
|
5010
5160
|
Reflect.set(config, "folder", config.folder);
|
|
5011
5161
|
}
|
|
5012
5162
|
// 先把z-index提取出来
|
|
5013
|
-
const zIndex = PopsHandler.
|
|
5163
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
5014
5164
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
5015
5165
|
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
5016
5166
|
const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
|
|
@@ -5143,7 +5293,7 @@ const PopsFolder = {
|
|
|
5143
5293
|
$elList.push($mask);
|
|
5144
5294
|
}
|
|
5145
5295
|
// 事件
|
|
5146
|
-
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
5296
|
+
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
|
|
5147
5297
|
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
5148
5298
|
PopsHandler.handleClickEvent("close", $btnCloseBtn, evtConfig, config.btn.close.callback);
|
|
5149
5299
|
PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok.callback);
|
|
@@ -5151,9 +5301,7 @@ const PopsFolder = {
|
|
|
5151
5301
|
PopsHandler.handleClickEvent("other", btnOtherElement, evtConfig, config.btn.other.callback);
|
|
5152
5302
|
// 创建到页面中
|
|
5153
5303
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
5154
|
-
|
|
5155
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
5156
|
-
}
|
|
5304
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
5157
5305
|
popsDOMUtils.appendBody($shadowContainer);
|
|
5158
5306
|
if ($mask != null) {
|
|
5159
5307
|
$anim.after($mask);
|
|
@@ -5777,7 +5925,7 @@ const PopsFolder = {
|
|
|
5777
5925
|
Reflect.set($pops, "data-pops-folder", popsFolder);
|
|
5778
5926
|
// 拖拽
|
|
5779
5927
|
if (config.drag) {
|
|
5780
|
-
|
|
5928
|
+
PopsInstHandler.drag($pops, {
|
|
5781
5929
|
dragElement: $title,
|
|
5782
5930
|
limit: config.dragLimit,
|
|
5783
5931
|
extraDistance: config.dragExtraDistance,
|
|
@@ -5793,7 +5941,7 @@ const PopsFolder = {
|
|
|
5793
5941
|
$shadowContainer: $shadowContainer,
|
|
5794
5942
|
$shadowRoot: $shadowRoot,
|
|
5795
5943
|
config: config,
|
|
5796
|
-
|
|
5944
|
+
emitter,
|
|
5797
5945
|
});
|
|
5798
5946
|
return result;
|
|
5799
5947
|
},
|
|
@@ -5856,6 +6004,7 @@ const PopsIframeDefaultConfig = () => {
|
|
|
5856
6004
|
lightStyle: null,
|
|
5857
6005
|
darkStyle: null,
|
|
5858
6006
|
beforeAppendToPageCallBack() { },
|
|
6007
|
+
stopKeyDownEventPropagation: true,
|
|
5859
6008
|
};
|
|
5860
6009
|
};
|
|
5861
6010
|
|
|
@@ -5864,6 +6013,7 @@ const PopsIframe = {
|
|
|
5864
6013
|
const guid = popsUtils.getRandomGUID();
|
|
5865
6014
|
// 设置当前类型
|
|
5866
6015
|
const popsType = "iframe";
|
|
6016
|
+
const emitter = new EventEmiter(popsType);
|
|
5867
6017
|
let config = PopsIframeDefaultConfig();
|
|
5868
6018
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
5869
6019
|
config = popsUtils.assign(config, __config__);
|
|
@@ -5900,7 +6050,7 @@ const PopsIframe = {
|
|
|
5900
6050
|
]);
|
|
5901
6051
|
const maskExtraStyle = config.animation != null && config.animation != "" ? "position:absolute;" : "";
|
|
5902
6052
|
// 先把z-index提取出来
|
|
5903
|
-
const zIndex = PopsHandler.
|
|
6053
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
5904
6054
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex, maskExtraStyle);
|
|
5905
6055
|
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
5906
6056
|
const iframeLoadingHTML = /*html*/ '<div class="pops-loading"></div>';
|
|
@@ -5949,7 +6099,7 @@ const PopsIframe = {
|
|
|
5949
6099
|
$mask = handleMask.maskElement;
|
|
5950
6100
|
$elList.push($mask);
|
|
5951
6101
|
}
|
|
5952
|
-
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
6102
|
+
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
|
|
5953
6103
|
// 赋值额外的$iframe参数
|
|
5954
6104
|
evtConfig.$iframe = $iframe;
|
|
5955
6105
|
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
@@ -5974,16 +6124,14 @@ const PopsIframe = {
|
|
|
5974
6124
|
});
|
|
5975
6125
|
// 创建到页面中
|
|
5976
6126
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
5977
|
-
|
|
5978
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
5979
|
-
}
|
|
6127
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
5980
6128
|
$iframeContainer.appendChild($shadowContainer);
|
|
5981
6129
|
if ($mask != null) {
|
|
5982
6130
|
$anim.after($mask);
|
|
5983
6131
|
}
|
|
5984
6132
|
// 拖拽
|
|
5985
6133
|
if (config.drag) {
|
|
5986
|
-
|
|
6134
|
+
PopsInstHandler.drag($pops, {
|
|
5987
6135
|
dragElement: $title,
|
|
5988
6136
|
limit: config.dragLimit,
|
|
5989
6137
|
extraDistance: config.dragExtraDistance,
|
|
@@ -6014,6 +6162,7 @@ const PopsIframe = {
|
|
|
6014
6162
|
if (typeof config?.btn?.min?.callback === "function") {
|
|
6015
6163
|
config.btn.min.callback(evtConfig, event);
|
|
6016
6164
|
}
|
|
6165
|
+
emitter.emit("pops:iframe-min", evtConfig, event);
|
|
6017
6166
|
}, {
|
|
6018
6167
|
capture: true,
|
|
6019
6168
|
});
|
|
@@ -6043,6 +6192,7 @@ const PopsIframe = {
|
|
|
6043
6192
|
if (typeof config?.btn?.max?.callback === "function") {
|
|
6044
6193
|
config.btn.max.callback(evtConfig, event);
|
|
6045
6194
|
}
|
|
6195
|
+
emitter.emit("pops:iframe-max", evtConfig, event);
|
|
6046
6196
|
}, {
|
|
6047
6197
|
capture: true,
|
|
6048
6198
|
});
|
|
@@ -6080,6 +6230,7 @@ const PopsIframe = {
|
|
|
6080
6230
|
if (typeof config?.btn?.mise?.callback === "function") {
|
|
6081
6231
|
config.btn.mise.callback(evtConfig, event);
|
|
6082
6232
|
}
|
|
6233
|
+
emitter.emit("pops:iframe-mise", evtConfig, event);
|
|
6083
6234
|
}, {
|
|
6084
6235
|
capture: true,
|
|
6085
6236
|
});
|
|
@@ -6087,7 +6238,7 @@ const PopsIframe = {
|
|
|
6087
6238
|
popsDOMUtils.on(headerCloseBtnElement, "click", async (event) => {
|
|
6088
6239
|
event.preventDefault();
|
|
6089
6240
|
event.stopPropagation();
|
|
6090
|
-
await
|
|
6241
|
+
await PopsInstHandler.removeInstance([PopsInstData.iframe], guid, false);
|
|
6091
6242
|
if (typeof config?.btn?.close?.callback === "function") {
|
|
6092
6243
|
config.btn.close.callback(evtConfig, event);
|
|
6093
6244
|
}
|
|
@@ -6102,7 +6253,7 @@ const PopsIframe = {
|
|
|
6102
6253
|
$shadowContainer: $shadowContainer,
|
|
6103
6254
|
$shadowRoot: $shadowRoot,
|
|
6104
6255
|
config: config,
|
|
6105
|
-
|
|
6256
|
+
emitter,
|
|
6106
6257
|
});
|
|
6107
6258
|
return result;
|
|
6108
6259
|
},
|
|
@@ -6979,6 +7130,8 @@ const PopsPanelDefaultConfig = () => {
|
|
|
6979
7130
|
lightStyle: null,
|
|
6980
7131
|
darkStyle: null,
|
|
6981
7132
|
beforeAppendToPageCallBack() { },
|
|
7133
|
+
stopKeyDownEventPropagation: true,
|
|
7134
|
+
listenEscapeKeyUpToExitDeepMenu: true,
|
|
6982
7135
|
};
|
|
6983
7136
|
};
|
|
6984
7137
|
|
|
@@ -7102,13 +7255,15 @@ class ToolTip {
|
|
|
7102
7255
|
$content: null,
|
|
7103
7256
|
$arrow: null,
|
|
7104
7257
|
};
|
|
7258
|
+
emitter;
|
|
7105
7259
|
$data = {
|
|
7106
7260
|
config: null,
|
|
7107
7261
|
guid: null,
|
|
7108
7262
|
timeId_close_TouchEvent: [],
|
|
7109
7263
|
timeId_close_MouseEvent: [],
|
|
7110
7264
|
};
|
|
7111
|
-
constructor(config, guid, ShadowInfo) {
|
|
7265
|
+
constructor(config, guid, ShadowInfo, emitter) {
|
|
7266
|
+
this.emitter = emitter;
|
|
7112
7267
|
this.$data.config = config;
|
|
7113
7268
|
this.$data.guid = guid;
|
|
7114
7269
|
this.$el.$shadowContainer = ShadowInfo.$shadowContainer;
|
|
@@ -7154,7 +7309,7 @@ class ToolTip {
|
|
|
7154
7309
|
// 处理className
|
|
7155
7310
|
popsDOMUtils.addClassName($toolTipContainer, this.$data.config.className);
|
|
7156
7311
|
// 添加z-index
|
|
7157
|
-
$toolTipContainer.style.zIndex = PopsHandler.
|
|
7312
|
+
$toolTipContainer.style.zIndex = PopsHandler.getTargerOrFunctionValue(this.$data.config.zIndex).toString();
|
|
7158
7313
|
// 添加自定义style
|
|
7159
7314
|
PopsElementHandler.addStyle($toolTipContainer, this.$data.config.style);
|
|
7160
7315
|
// 添加自定义浅色style
|
|
@@ -7202,7 +7357,7 @@ class ToolTip {
|
|
|
7202
7357
|
* 获取z-index
|
|
7203
7358
|
*/
|
|
7204
7359
|
getZIndex() {
|
|
7205
|
-
const zIndex = PopsHandler.
|
|
7360
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(this.$data.config.zIndex);
|
|
7206
7361
|
return zIndex;
|
|
7207
7362
|
}
|
|
7208
7363
|
/**
|
|
@@ -7385,9 +7540,7 @@ class ToolTip {
|
|
|
7385
7540
|
}
|
|
7386
7541
|
if (!popsUtils.contains(this.$el.$shadowContainer)) {
|
|
7387
7542
|
// 页面不存在Shadow,添加
|
|
7388
|
-
|
|
7389
|
-
this.$data.config.beforeAppendToPageCallBack(this.$el.$shadowRoot, this.$el.$shadowContainer);
|
|
7390
|
-
}
|
|
7543
|
+
this.emitter.emit("pops:before-append-to-page", this.$el.$shadowRoot, this.$el.$shadowContainer);
|
|
7391
7544
|
popsDOMUtils.append(document.body, this.$el.$shadowContainer);
|
|
7392
7545
|
}
|
|
7393
7546
|
// 更新内容
|
|
@@ -7558,6 +7711,7 @@ const PopsTooltip = {
|
|
|
7558
7711
|
const guid = popsUtils.getRandomGUID();
|
|
7559
7712
|
// 设置当前类型
|
|
7560
7713
|
const popsType = "tooltip";
|
|
7714
|
+
const emitter = new EventEmiter(popsType);
|
|
7561
7715
|
let config = PopsTooltipDefaultConfig();
|
|
7562
7716
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
7563
7717
|
config = popsUtils.assign(config, __config__);
|
|
@@ -7596,7 +7750,7 @@ const PopsTooltip = {
|
|
|
7596
7750
|
const toolTip = new ToolTip(config, guid, {
|
|
7597
7751
|
$shadowContainer,
|
|
7598
7752
|
$shadowRoot,
|
|
7599
|
-
});
|
|
7753
|
+
}, emitter);
|
|
7600
7754
|
if (config.alwaysShow) {
|
|
7601
7755
|
// 总是显示
|
|
7602
7756
|
// 直接显示
|
|
@@ -7608,6 +7762,7 @@ const PopsTooltip = {
|
|
|
7608
7762
|
$shadowContainer,
|
|
7609
7763
|
$shadowRoot,
|
|
7610
7764
|
toolTip,
|
|
7765
|
+
emitter,
|
|
7611
7766
|
};
|
|
7612
7767
|
},
|
|
7613
7768
|
};
|
|
@@ -7656,6 +7811,7 @@ const PanelHandlerComponents = () => {
|
|
|
7656
7811
|
nodeStoreConfigKey: "data-view-config",
|
|
7657
7812
|
},
|
|
7658
7813
|
$config: {},
|
|
7814
|
+
emitter: null,
|
|
7659
7815
|
/**
|
|
7660
7816
|
* 初始化
|
|
7661
7817
|
* @param data
|
|
@@ -7666,6 +7822,7 @@ const PanelHandlerComponents = () => {
|
|
|
7666
7822
|
...data.$el,
|
|
7667
7823
|
};
|
|
7668
7824
|
this.$config = data.config;
|
|
7825
|
+
this.emitter = data.emitter;
|
|
7669
7826
|
this.asideULElement = this.$el.$panelLeftAside.querySelector(`ul.pops-${PopsType}-aside-top-container`);
|
|
7670
7827
|
this.asideBottomULElement = this.$el.$panelLeftAside.querySelector(`ul.pops-${PopsType}-aside-bottom-container`);
|
|
7671
7828
|
this.sectionContainerHeaderULElement = this.$el.$panelContentSectionContainer.querySelector(`ul.pops-${PopsType}-container-header-ul`);
|
|
@@ -8576,7 +8733,8 @@ const PanelHandlerComponents = () => {
|
|
|
8576
8733
|
$target: this.$ele.button,
|
|
8577
8734
|
content: getToolTipContent,
|
|
8578
8735
|
zIndex: () => {
|
|
8579
|
-
return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
|
|
8736
|
+
// return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
|
|
8737
|
+
return popsUtils.getMaxZIndexNodeInfoFromPoint(this.$ele.button)[0].zIndex;
|
|
8580
8738
|
},
|
|
8581
8739
|
isFixed: true,
|
|
8582
8740
|
className: "github-tooltip",
|
|
@@ -11167,91 +11325,31 @@ const PanelHandlerComponents = () => {
|
|
|
11167
11325
|
className: "pops-panel-deepMenu-container-left-arrow-icon",
|
|
11168
11326
|
innerHTML: PopsIcon.getIcon("arrowLeft"),
|
|
11169
11327
|
});
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
popsDOMUtils.
|
|
11182
|
-
|
|
11183
|
-
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
const leaveTransition = document.startViewTransition(leaveViewTransition);
|
|
11191
|
-
await leaveTransition.ready;
|
|
11192
|
-
// 向右移出
|
|
11193
|
-
await Promise.all([
|
|
11194
|
-
$deepMenuSection.animate([
|
|
11195
|
-
{
|
|
11196
|
-
// from
|
|
11197
|
-
transform: "translateX(0)",
|
|
11198
|
-
},
|
|
11199
|
-
{
|
|
11200
|
-
// to
|
|
11201
|
-
transform: "translateX(100%)",
|
|
11202
|
-
},
|
|
11203
|
-
], animOptions).finished,
|
|
11204
|
-
// 向右移入
|
|
11205
|
-
$currentSection.animate([
|
|
11206
|
-
{
|
|
11207
|
-
// from
|
|
11208
|
-
transform: "translateX(-100%)",
|
|
11209
|
-
},
|
|
11210
|
-
{
|
|
11211
|
-
// to
|
|
11212
|
-
transform: "translateX(0)",
|
|
11213
|
-
},
|
|
11214
|
-
], animOptions).finished,
|
|
11215
|
-
]);
|
|
11216
|
-
await leaveTransition.finished;
|
|
11217
|
-
}
|
|
11218
|
-
else {
|
|
11219
|
-
leaveViewTransition();
|
|
11220
|
-
}
|
|
11221
|
-
that.emitRenderRightContainer($currentSection);
|
|
11222
|
-
}, {
|
|
11223
|
-
once: true,
|
|
11224
|
-
});
|
|
11225
|
-
popsDOMUtils.before($header.firstElementChild, $headerLeftArrow);
|
|
11226
|
-
$deepMenuHeaderUL.appendChild($header);
|
|
11227
|
-
$deepMenuSection.appendChild($deepMenuHeaderUL);
|
|
11228
|
-
$deepMenuSection.appendChild($deepMenuMain);
|
|
11229
|
-
if (viewConfig.views && Array.isArray(viewConfig.views)) {
|
|
11230
|
-
for (let index = 0; index < viewConfig.views.length; index++) {
|
|
11231
|
-
const formItemConfig = viewConfig.views[index];
|
|
11232
|
-
this.initContainerItem($deepMenuMain, formItemConfig);
|
|
11328
|
+
const switchAnim = PopsAnimation.createSwitchElementWithAnimation($currentSection, $deepMenuSection, {
|
|
11329
|
+
useAnimation: that.$config.useDeepMenuSwtichAnimation,
|
|
11330
|
+
enterToAddElementCallback: () => {
|
|
11331
|
+
popsDOMUtils.on($headerLeftArrow, "click", async (event) => {
|
|
11332
|
+
popsDOMUtils.preventEvent(event);
|
|
11333
|
+
// 返回动画
|
|
11334
|
+
await switchAnim.exit();
|
|
11335
|
+
that.emitRenderRightContainer($currentSection);
|
|
11336
|
+
}, {
|
|
11337
|
+
once: true,
|
|
11338
|
+
});
|
|
11339
|
+
popsDOMUtils.before($header.firstElementChild, $headerLeftArrow);
|
|
11340
|
+
$deepMenuHeaderUL.appendChild($header);
|
|
11341
|
+
$deepMenuSection.appendChild($deepMenuHeaderUL);
|
|
11342
|
+
$deepMenuSection.appendChild($deepMenuMain);
|
|
11343
|
+
if (viewConfig.views && Array.isArray(viewConfig.views)) {
|
|
11344
|
+
for (let index = 0; index < viewConfig.views.length; index++) {
|
|
11345
|
+
const formItemConfig = viewConfig.views[index];
|
|
11346
|
+
this.initContainerItem($deepMenuMain, formItemConfig);
|
|
11347
|
+
}
|
|
11233
11348
|
}
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
};
|
|
11237
|
-
|
|
11238
|
-
const transition = document.startViewTransition(enterViewTransition);
|
|
11239
|
-
await transition.ready;
|
|
11240
|
-
await $deepMenuSection.animate([
|
|
11241
|
-
{
|
|
11242
|
-
// from
|
|
11243
|
-
transform: "translateX(100%)",
|
|
11244
|
-
},
|
|
11245
|
-
{
|
|
11246
|
-
// to
|
|
11247
|
-
transform: "translateX(0)",
|
|
11248
|
-
},
|
|
11249
|
-
], animOptions).finished;
|
|
11250
|
-
await transition.finished;
|
|
11251
|
-
}
|
|
11252
|
-
else {
|
|
11253
|
-
enterViewTransition();
|
|
11254
|
-
}
|
|
11349
|
+
that.$el.$panelRightSectionWrapper.appendChild($deepMenuSection);
|
|
11350
|
+
},
|
|
11351
|
+
});
|
|
11352
|
+
await switchAnim.enter();
|
|
11255
11353
|
if (typeof viewConfig.afterEnterDeepMenuCallBack === "function") {
|
|
11256
11354
|
viewConfig.afterEnterDeepMenuCallBack(viewConfig, {
|
|
11257
11355
|
$sectionContainer: $deepMenuSection,
|
|
@@ -11423,11 +11521,9 @@ const PanelHandlerComponents = () => {
|
|
|
11423
11521
|
*/
|
|
11424
11522
|
emitRenderRightContainer($container) {
|
|
11425
11523
|
const dataViewConfig = Reflect.get($container, this.$data.nodeStoreConfigKey);
|
|
11426
|
-
this
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
},
|
|
11430
|
-
}));
|
|
11524
|
+
this.emitter.emit("pops:renderRightContainer", {
|
|
11525
|
+
viewConfig: dataViewConfig,
|
|
11526
|
+
});
|
|
11431
11527
|
},
|
|
11432
11528
|
/**
|
|
11433
11529
|
*
|
|
@@ -11497,6 +11593,7 @@ const PopsPanel = {
|
|
|
11497
11593
|
const guid = popsUtils.getRandomGUID();
|
|
11498
11594
|
// 设置当前类型
|
|
11499
11595
|
const popsType = "panel";
|
|
11596
|
+
const emitter = new EventEmiter(popsType);
|
|
11500
11597
|
let config = PopsPanelDefaultConfig();
|
|
11501
11598
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
11502
11599
|
config = popsUtils.assign(config, __config__);
|
|
@@ -11533,7 +11630,7 @@ const PopsPanel = {
|
|
|
11533
11630
|
},
|
|
11534
11631
|
]);
|
|
11535
11632
|
// 先把z-index提取出来
|
|
11536
|
-
const zIndex = PopsHandler.
|
|
11633
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
11537
11634
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
11538
11635
|
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
11539
11636
|
const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
|
|
@@ -11591,15 +11688,13 @@ const PopsPanel = {
|
|
|
11591
11688
|
$elList.push($mask);
|
|
11592
11689
|
}
|
|
11593
11690
|
// 处理返回的配置
|
|
11594
|
-
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
11691
|
+
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
|
|
11595
11692
|
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11596
11693
|
// 为顶部右边的关闭按钮添加点击事件
|
|
11597
11694
|
PopsHandler.handleClickEvent("close", $headerBtnClose, evtConfig, config.btn?.close?.callback);
|
|
11598
11695
|
// 创建到页面中
|
|
11599
11696
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
11600
|
-
|
|
11601
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
11602
|
-
}
|
|
11697
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
11603
11698
|
popsDOMUtils.appendBody($shadowContainer);
|
|
11604
11699
|
// 追加遮罩层元素
|
|
11605
11700
|
if ($mask != null) {
|
|
@@ -11622,6 +11717,7 @@ const PopsPanel = {
|
|
|
11622
11717
|
$panelBottomLeftContainer,
|
|
11623
11718
|
$panelBottomRightContainer,
|
|
11624
11719
|
},
|
|
11720
|
+
emitter,
|
|
11625
11721
|
});
|
|
11626
11722
|
PopsHandler.handlePush(popsType, {
|
|
11627
11723
|
guid: guid,
|
|
@@ -11631,11 +11727,11 @@ const PopsPanel = {
|
|
|
11631
11727
|
$shadowContainer: $shadowContainer,
|
|
11632
11728
|
$shadowRoot: $shadowRoot,
|
|
11633
11729
|
config: config,
|
|
11634
|
-
|
|
11730
|
+
emitter,
|
|
11635
11731
|
});
|
|
11636
11732
|
// 拖拽
|
|
11637
11733
|
if (config.drag) {
|
|
11638
|
-
|
|
11734
|
+
PopsInstHandler.drag($pops, {
|
|
11639
11735
|
dragElement: $title,
|
|
11640
11736
|
limit: config.dragLimit,
|
|
11641
11737
|
extraDistance: config.dragExtraDistance,
|
|
@@ -11643,15 +11739,21 @@ const PopsPanel = {
|
|
|
11643
11739
|
endCallBack: config.dragEndCallBack,
|
|
11644
11740
|
});
|
|
11645
11741
|
}
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
11742
|
+
if (config.listenEscapeKeyUpToExitDeepMenu) {
|
|
11743
|
+
const escapeListener = popsDOMUtils.onKeyup(globalThis, (evt) => {
|
|
11744
|
+
if (evt.key === "Escape" && !evt.ctrlKey && !evt.shiftKey && !evt.altKey && !evt.metaKey) {
|
|
11745
|
+
// Esc
|
|
11746
|
+
const $exitBtn = $panelRightSectionWrapper.querySelector(".pops-panel-deepMenu-container-left-arrow-icon");
|
|
11747
|
+
if ($exitBtn) {
|
|
11748
|
+
$exitBtn.click();
|
|
11749
|
+
}
|
|
11750
|
+
}
|
|
11751
|
+
}, { capture: true });
|
|
11752
|
+
emitter.on("pops:before-destory", () => {
|
|
11753
|
+
escapeListener?.off();
|
|
11754
|
+
});
|
|
11755
|
+
}
|
|
11756
|
+
return result;
|
|
11655
11757
|
},
|
|
11656
11758
|
};
|
|
11657
11759
|
|
|
@@ -11746,6 +11848,7 @@ const PopsPromptDefaultConfig = () => {
|
|
|
11746
11848
|
lightStyle: null,
|
|
11747
11849
|
darkStyle: null,
|
|
11748
11850
|
beforeAppendToPageCallBack() { },
|
|
11851
|
+
stopKeyDownEventPropagation: true,
|
|
11749
11852
|
};
|
|
11750
11853
|
};
|
|
11751
11854
|
|
|
@@ -11754,6 +11857,7 @@ const PopsPrompt = {
|
|
|
11754
11857
|
const guid = popsUtils.getRandomGUID();
|
|
11755
11858
|
// 设置当前类型
|
|
11756
11859
|
const popsType = "prompt";
|
|
11860
|
+
const emitter = new EventEmiter(popsType);
|
|
11757
11861
|
let config = PopsPromptDefaultConfig();
|
|
11758
11862
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
11759
11863
|
config = popsUtils.assign(config, __config__);
|
|
@@ -11790,7 +11894,7 @@ const PopsPrompt = {
|
|
|
11790
11894
|
},
|
|
11791
11895
|
]);
|
|
11792
11896
|
// 先把z-index提取出来
|
|
11793
|
-
const zIndex = PopsHandler.
|
|
11897
|
+
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
11794
11898
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
11795
11899
|
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
11796
11900
|
const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
|
|
@@ -11835,7 +11939,7 @@ const PopsPrompt = {
|
|
|
11835
11939
|
$mask = handleMask.maskElement;
|
|
11836
11940
|
$elList.push($mask);
|
|
11837
11941
|
}
|
|
11838
|
-
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
11942
|
+
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, emitter, $mask);
|
|
11839
11943
|
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11840
11944
|
// 输入框赋值初始值
|
|
11841
11945
|
$input.value = config.content.text;
|
|
@@ -11845,9 +11949,7 @@ const PopsPrompt = {
|
|
|
11845
11949
|
PopsHandler.handlePromptClickEvent("other", $input, $btnOther, evtConfig, config.btn.other.callback);
|
|
11846
11950
|
// 创建到页面中
|
|
11847
11951
|
popsDOMUtils.append($shadowRoot, $elList);
|
|
11848
|
-
|
|
11849
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
11850
|
-
}
|
|
11952
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
11851
11953
|
popsDOMUtils.appendBody($shadowContainer);
|
|
11852
11954
|
if ($mask != null) {
|
|
11853
11955
|
$anim.after($mask);
|
|
@@ -11860,11 +11962,11 @@ const PopsPrompt = {
|
|
|
11860
11962
|
$shadowContainer: $shadowContainer,
|
|
11861
11963
|
$shadowRoot: $shadowRoot,
|
|
11862
11964
|
config: config,
|
|
11863
|
-
|
|
11965
|
+
emitter,
|
|
11864
11966
|
});
|
|
11865
11967
|
// 拖拽
|
|
11866
11968
|
if (config.drag) {
|
|
11867
|
-
|
|
11969
|
+
PopsInstHandler.drag($pops, {
|
|
11868
11970
|
dragElement: $title,
|
|
11869
11971
|
limit: config.dragLimit,
|
|
11870
11972
|
extraDistance: config.dragExtraDistance,
|
|
@@ -11992,6 +12094,7 @@ const PopsRightClickMenu = {
|
|
|
11992
12094
|
const guid = popsUtils.getRandomGUID();
|
|
11993
12095
|
// 设置当前类型
|
|
11994
12096
|
const popsType = "rightClickMenu";
|
|
12097
|
+
const emitter = new EventEmiter(popsType);
|
|
11995
12098
|
let config = PopsRightClickMenuDefaultConfig();
|
|
11996
12099
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
11997
12100
|
config = popsUtils.assign(config, __config__);
|
|
@@ -12120,13 +12223,14 @@ const PopsRightClickMenu = {
|
|
|
12120
12223
|
guid: guid,
|
|
12121
12224
|
$anim: rootElement,
|
|
12122
12225
|
$pops: rootElement,
|
|
12123
|
-
beforeRemoveCallBack(instCommonConfig) {
|
|
12124
|
-
PopsContextMenu.closeAllMenu(instCommonConfig.$pops);
|
|
12125
|
-
},
|
|
12126
12226
|
config: config,
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12227
|
+
emitter,
|
|
12228
|
+
});
|
|
12229
|
+
emitter.on("pops:before-destory", () => {
|
|
12230
|
+
PopsContextMenu.closeAllMenu(rootElement);
|
|
12231
|
+
});
|
|
12232
|
+
emitter.on("pops:destory", () => {
|
|
12233
|
+
PopsContextMenu.closeAllMenu(rootElement);
|
|
12130
12234
|
});
|
|
12131
12235
|
}
|
|
12132
12236
|
},
|
|
@@ -12214,6 +12318,7 @@ const PopsRightClickMenu = {
|
|
|
12214
12318
|
});
|
|
12215
12319
|
const zIndex = this.getMenuZIndex();
|
|
12216
12320
|
if (zIndex > 10000) {
|
|
12321
|
+
// 大于默认值
|
|
12217
12322
|
$menu.style.zIndex = zIndex.toString();
|
|
12218
12323
|
}
|
|
12219
12324
|
if (isChildren) {
|
|
@@ -12234,7 +12339,7 @@ const PopsRightClickMenu = {
|
|
|
12234
12339
|
* 动态获取配的z-index
|
|
12235
12340
|
*/
|
|
12236
12341
|
getMenuZIndex() {
|
|
12237
|
-
return PopsHandler.
|
|
12342
|
+
return PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
12238
12343
|
},
|
|
12239
12344
|
/**
|
|
12240
12345
|
* 获取left、top偏移
|
|
@@ -12348,9 +12453,7 @@ const PopsRightClickMenu = {
|
|
|
12348
12453
|
popsDOMUtils.append($shadowRoot, menuElement);
|
|
12349
12454
|
// 判断容器是否存在
|
|
12350
12455
|
if (!document.contains($shadowContainer)) {
|
|
12351
|
-
|
|
12352
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
12353
|
-
}
|
|
12456
|
+
emitter.emit("pops:before-append-to-page", $shadowRoot, $shadowContainer);
|
|
12354
12457
|
popsDOMUtils.appendBody($shadowContainer);
|
|
12355
12458
|
}
|
|
12356
12459
|
this.handlerShowMenuCSS(menuElement, menuEvent);
|
|
@@ -12625,6 +12728,7 @@ const PopsSearchSuggestion = {
|
|
|
12625
12728
|
const guid = popsUtils.getRandomGUID();
|
|
12626
12729
|
// 设置当前类型
|
|
12627
12730
|
const popsType = "searchSuggestion";
|
|
12731
|
+
const emitter = new EventEmiter(popsType);
|
|
12628
12732
|
let config = PopsSearchSuggestionDefaultConfig();
|
|
12629
12733
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
12630
12734
|
config = popsUtils.assign(config, __config__);
|
|
@@ -12661,6 +12765,7 @@ const PopsSearchSuggestion = {
|
|
|
12661
12765
|
passive: true,
|
|
12662
12766
|
};
|
|
12663
12767
|
const SearchSuggestion = {
|
|
12768
|
+
emitter: emitter,
|
|
12664
12769
|
/**
|
|
12665
12770
|
* 当前的环境,可以是document,可以是shadowroot,默认是document
|
|
12666
12771
|
*/
|
|
@@ -12876,7 +12981,7 @@ const PopsSearchSuggestion = {
|
|
|
12876
12981
|
border: initial;
|
|
12877
12982
|
overflow: initial;
|
|
12878
12983
|
position: ${config.isAbsolute ? "absolute" : "fixed"};
|
|
12879
|
-
z-index: ${PopsHandler.
|
|
12984
|
+
z-index: ${PopsHandler.getTargerOrFunctionValue(config.zIndex)};
|
|
12880
12985
|
}
|
|
12881
12986
|
.pops-${popsType}-search-suggestion-dropdown-wrapper{
|
|
12882
12987
|
max-height: ${config.maxHeight};
|
|
@@ -13399,7 +13504,110 @@ const PopsSearchSuggestion = {
|
|
|
13399
13504
|
},
|
|
13400
13505
|
};
|
|
13401
13506
|
|
|
13402
|
-
const
|
|
13507
|
+
const PopsInstanceUtils = {
|
|
13508
|
+
/**
|
|
13509
|
+
* 获取pops所有弹窗中的最大的z-index
|
|
13510
|
+
* @param deviation
|
|
13511
|
+
*/
|
|
13512
|
+
getPopsMaxZIndex(deviation = 1) {
|
|
13513
|
+
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
13514
|
+
// 最大值 2147483647
|
|
13515
|
+
// const browserMaxZIndex = Math.pow(2, 31) - 1;
|
|
13516
|
+
// 比较值 2000000000
|
|
13517
|
+
const maxZIndex = 2 * Math.pow(10, 9);
|
|
13518
|
+
// 当前页面最大的z-index
|
|
13519
|
+
let zIndex = 0;
|
|
13520
|
+
// 当前的最大z-index的元素,调试使用
|
|
13521
|
+
let maxZIndexNode = null;
|
|
13522
|
+
/**
|
|
13523
|
+
* 元素是否可见
|
|
13524
|
+
* @param $el
|
|
13525
|
+
* @param $css
|
|
13526
|
+
*/
|
|
13527
|
+
function isVisibleNode($el, $css) {
|
|
13528
|
+
let flag = true;
|
|
13529
|
+
if (typeof $el.checkVisibility === "function") {
|
|
13530
|
+
flag = $el.checkVisibility();
|
|
13531
|
+
}
|
|
13532
|
+
else {
|
|
13533
|
+
flag =
|
|
13534
|
+
$css.position !== "static" && $css.display !== "none" && $css.visibility !== "hidden" && $css.opacity !== "0";
|
|
13535
|
+
}
|
|
13536
|
+
if (flag) {
|
|
13537
|
+
// css样式上可见
|
|
13538
|
+
// 再判断宽高
|
|
13539
|
+
const rect = $el.getBoundingClientRect();
|
|
13540
|
+
// 确保该元素的中心点在屏幕内
|
|
13541
|
+
flag = rect.width > 0 && rect.height > 0 && rect.x > 0 && rect.y > 0;
|
|
13542
|
+
}
|
|
13543
|
+
return flag;
|
|
13544
|
+
}
|
|
13545
|
+
Object.keys(PopsInstData).forEach((instKeyName) => {
|
|
13546
|
+
const instData = PopsInstData[instKeyName];
|
|
13547
|
+
for (let index = 0; index < instData.length; index++) {
|
|
13548
|
+
const inst = instData[index];
|
|
13549
|
+
const nodeStyle = window.getComputedStyle(inst.$anim);
|
|
13550
|
+
// 不对position为static和display为none的元素进行获取它们的z-index
|
|
13551
|
+
if (isVisibleNode(inst.$anim, nodeStyle)) {
|
|
13552
|
+
const nodeZIndex = parseInt(nodeStyle.zIndex);
|
|
13553
|
+
if (!isNaN(nodeZIndex)) {
|
|
13554
|
+
if (nodeZIndex > zIndex) {
|
|
13555
|
+
zIndex = nodeZIndex;
|
|
13556
|
+
maxZIndexNode = inst.$anim;
|
|
13557
|
+
}
|
|
13558
|
+
}
|
|
13559
|
+
}
|
|
13560
|
+
}
|
|
13561
|
+
});
|
|
13562
|
+
zIndex += deviation;
|
|
13563
|
+
const isOverMaxZIndex = zIndex >= maxZIndex;
|
|
13564
|
+
if (isOverMaxZIndex) {
|
|
13565
|
+
// 超出z-index最大值
|
|
13566
|
+
zIndex = maxZIndex;
|
|
13567
|
+
}
|
|
13568
|
+
return { zIndex: zIndex, animElement: maxZIndexNode, isOverMaxZIndex };
|
|
13569
|
+
},
|
|
13570
|
+
/**
|
|
13571
|
+
* 排序数组
|
|
13572
|
+
* @param getBeforeValueFun
|
|
13573
|
+
* @param getAfterValueFun
|
|
13574
|
+
* @param sortByDesc 排序是否降序,默认降序
|
|
13575
|
+
*/
|
|
13576
|
+
sortElementListByProperty(getBeforeValueFun, getAfterValueFun, sortByDesc = true) {
|
|
13577
|
+
if (typeof sortByDesc !== "boolean") {
|
|
13578
|
+
throw new TypeError("参数 sortByDesc 必须为boolean类型");
|
|
13579
|
+
}
|
|
13580
|
+
if (getBeforeValueFun == null || getAfterValueFun == null) {
|
|
13581
|
+
throw new Error("获取前面的值或后面的值的方法不能为空");
|
|
13582
|
+
}
|
|
13583
|
+
return function (after_obj, before_obj) {
|
|
13584
|
+
const beforeValue = getBeforeValueFun(before_obj); // 前
|
|
13585
|
+
const afterValue = getAfterValueFun(after_obj); // 后
|
|
13586
|
+
if (sortByDesc) {
|
|
13587
|
+
if (afterValue > beforeValue) {
|
|
13588
|
+
return -1;
|
|
13589
|
+
}
|
|
13590
|
+
else if (afterValue < beforeValue) {
|
|
13591
|
+
return 1;
|
|
13592
|
+
}
|
|
13593
|
+
else {
|
|
13594
|
+
return 0;
|
|
13595
|
+
}
|
|
13596
|
+
}
|
|
13597
|
+
else {
|
|
13598
|
+
if (afterValue < beforeValue) {
|
|
13599
|
+
return -1;
|
|
13600
|
+
}
|
|
13601
|
+
else if (afterValue > beforeValue) {
|
|
13602
|
+
return 1;
|
|
13603
|
+
}
|
|
13604
|
+
else {
|
|
13605
|
+
return 0;
|
|
13606
|
+
}
|
|
13607
|
+
}
|
|
13608
|
+
};
|
|
13609
|
+
},
|
|
13610
|
+
};
|
|
13403
13611
|
|
|
13404
13612
|
class Pops {
|
|
13405
13613
|
/** 配置 */
|
|
@@ -13428,7 +13636,11 @@ class Pops {
|
|
|
13428
13636
|
/** pops处理float类型使用的工具类 */
|
|
13429
13637
|
MathFloatUtils: PopsMathFloatUtils,
|
|
13430
13638
|
/** pops.panel中用于处理各个类型的工具 */
|
|
13431
|
-
PanelHandlerComponents
|
|
13639
|
+
PanelHandlerComponents,
|
|
13640
|
+
/** pops.panel中的动画 */
|
|
13641
|
+
PopsAnimation,
|
|
13642
|
+
/** 事件类 */
|
|
13643
|
+
EventEmiter,
|
|
13432
13644
|
};
|
|
13433
13645
|
init() { }
|
|
13434
13646
|
/**
|