@whitesev/pops 3.3.5 → 4.0.1
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 +13099 -12934
- 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 +752 -587
- 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 +752 -587
- 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 +13100 -12935
- 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 +13103 -12938
- 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 +13102 -12937
- 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 +131 -77
- 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/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 +5 -1
- package/dist/types/src/config/GlobalConfig.d.ts +63 -23
- package/dist/types/src/event/EventEmiter.d.ts +33 -0
- package/dist/types/src/handler/PopsHandler.d.ts +16 -11
- 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/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 +1 -89
- 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/index.ts +9 -9
- package/src/components/confirm/index.ts +9 -9
- package/src/components/drawer/index.ts +12 -9
- package/src/components/folder/index.ts +9 -8
- package/src/components/iframe/index.ts +18 -12
- package/src/components/iframe/types/index.ts +10 -8
- package/src/components/loading/index.ts +12 -6
- package/src/components/panel/defaultConfig.ts +1 -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/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/config/GlobalConfig.ts +21 -14
- package/src/css/index.css +2 -0
- package/src/event/EventEmiter.ts +95 -0
- package/src/handler/PopsElementHandler.ts +8 -6
- package/src/handler/PopsHandler.ts +65 -48
- 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/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 +10 -639
- package/src/utils/PopsUtils.ts +194 -0
package/src/css/index.css
CHANGED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { EventMap, CustomEventMap } from "../types/EventEmitter";
|
|
2
|
+
import type { PopsType } from "../types/main";
|
|
3
|
+
|
|
4
|
+
class EventEmiter<T extends CustomEventMap = CustomEventMap> {
|
|
5
|
+
#type: PopsType;
|
|
6
|
+
#data = new Map<
|
|
7
|
+
string,
|
|
8
|
+
{
|
|
9
|
+
type: PopsType;
|
|
10
|
+
time: number;
|
|
11
|
+
callback: (...args: any[]) => IPromise<void>;
|
|
12
|
+
}[]
|
|
13
|
+
>();
|
|
14
|
+
constructor(type: PopsType) {
|
|
15
|
+
this.#type = type;
|
|
16
|
+
document.addEventListener;
|
|
17
|
+
}
|
|
18
|
+
on<P extends keyof EventMap>(
|
|
19
|
+
eventName: P,
|
|
20
|
+
callback: EventMap[P]
|
|
21
|
+
): {
|
|
22
|
+
off: () => IPromise<void>;
|
|
23
|
+
emit: (...args: Parameters<T[P]>) => IPromise<void>;
|
|
24
|
+
};
|
|
25
|
+
on<P extends keyof T>(
|
|
26
|
+
eventName: P,
|
|
27
|
+
callback: T[P]
|
|
28
|
+
): {
|
|
29
|
+
off: () => IPromise<void>;
|
|
30
|
+
emit: (...args: Parameters<T[P]>) => IPromise<void>;
|
|
31
|
+
};
|
|
32
|
+
on<P extends keyof EventMap | keyof CustomEventMap>(eventName: P, callback: (EventMap & CustomEventMap)[P]) {
|
|
33
|
+
const eventList = this.#data.get(eventName) ?? [];
|
|
34
|
+
eventList.push({ type: this.#type, time: Date.now(), callback: callback });
|
|
35
|
+
this.#data.set(eventName, eventList);
|
|
36
|
+
return {
|
|
37
|
+
off: () => {
|
|
38
|
+
this.off(eventName as keyof EventMap, callback);
|
|
39
|
+
},
|
|
40
|
+
emit: (...args: Parameters<T[P]>) => {
|
|
41
|
+
this.emit(eventName, ...args);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
off<P extends keyof EventMap>(eventName: P, callback: EventMap[P]): IPromise<void>;
|
|
46
|
+
off<P extends keyof T>(eventName: P, callback: T[P]): IPromise<void>;
|
|
47
|
+
off<P extends keyof EventMap | keyof CustomEventMap>(eventName: P, callback: (EventMap & CustomEventMap)[P]) {
|
|
48
|
+
const eventList = this.#data.get(eventName) ?? [];
|
|
49
|
+
let isOffSuccess = false;
|
|
50
|
+
for (let index = eventList.length - 1; index >= 0; index--) {
|
|
51
|
+
if (eventList[index].callback === callback) {
|
|
52
|
+
isOffSuccess = true;
|
|
53
|
+
eventList.splice(index, 1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (eventList.length === 0) {
|
|
57
|
+
// empty
|
|
58
|
+
this.#data.delete(eventName);
|
|
59
|
+
} else {
|
|
60
|
+
if (isOffSuccess) {
|
|
61
|
+
// update
|
|
62
|
+
this.#data.set(eventName, eventList);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
emit<P extends keyof T>(eventName: P, ...args: Parameters<T[P]>): IPromise<void>;
|
|
67
|
+
emit<P extends keyof EventMap>(eventName: P, ...args: Parameters<EventMap[P]>): IPromise<void>;
|
|
68
|
+
async emit<P extends keyof EventMap | keyof CustomEventMap>(eventName: P, ...args: Parameters<T[P]>) {
|
|
69
|
+
const eventList = this.#data.get(eventName) ?? [];
|
|
70
|
+
for (const item of eventList) {
|
|
71
|
+
await item.callback(...args);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
offAll<P extends keyof EventMap>(eventName?: P): IPromise<void>;
|
|
75
|
+
offAll<P extends keyof T>(eventName?: P): IPromise<void>;
|
|
76
|
+
offAll<P extends keyof EventMap | keyof CustomEventMap>(eventName?: P) {
|
|
77
|
+
if (typeof eventName === "string") {
|
|
78
|
+
this.#data.delete(eventName);
|
|
79
|
+
} else {
|
|
80
|
+
this.#data.clear();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 获取所有添加的事件
|
|
85
|
+
*/
|
|
86
|
+
getAllEvents(eventName?: string) {
|
|
87
|
+
if (typeof eventName === "string") {
|
|
88
|
+
return this.#data.get(eventName);
|
|
89
|
+
} else {
|
|
90
|
+
return Array.from(this.#data.values());
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { EventEmiter };
|
|
@@ -52,7 +52,7 @@ export const PopsElementHandler = {
|
|
|
52
52
|
const popsPosition = __config__.position || "";
|
|
53
53
|
if (config.zIndex != null) {
|
|
54
54
|
popsAnimStyle += `z-index: ${zIndex};`;
|
|
55
|
-
popsStyle += `z-index: ${zIndex};`;
|
|
55
|
+
// popsStyle += `z-index: ${zIndex};`;
|
|
56
56
|
}
|
|
57
57
|
if (__config__.width != null) {
|
|
58
58
|
popsStyle += `width: ${__config__.width};`;
|
|
@@ -61,15 +61,17 @@ export const PopsElementHandler = {
|
|
|
61
61
|
popsStyle += `height: ${__config__.height};`;
|
|
62
62
|
}
|
|
63
63
|
const hasBottomBtn = bottomBtnHTML.trim() === "" ? false : true;
|
|
64
|
+
const popsClassNameList = ["pops"];
|
|
65
|
+
if (config.class) {
|
|
66
|
+
popsClassNameList.push(...config.class.split(" "));
|
|
67
|
+
}
|
|
64
68
|
return /*html*/ `
|
|
65
69
|
<div class="pops-anim" anim="${__config__.animation || ""}" style="${popsAnimStyle}" data-guid="${guid}">${
|
|
66
70
|
config.style != null ? /*html*/ `<style tyle="text/css" data-name="style">${config.style}</style>` : ""
|
|
67
71
|
}
|
|
68
72
|
${config.lightStyle != null ? /*html*/ `<style tyle="text/css" data-name="lightStyle">@media (prefers-color-scheme: light) {${config.lightStyle}}</style>` : ""}
|
|
69
73
|
${config.darkStyle != null ? /*html*/ `<style tyle="text/css" data-name="darkStyle">@media (prefers-color-scheme: dark) {${config.darkStyle}}</style>` : ""}
|
|
70
|
-
<div class="
|
|
71
|
-
config.class || ""
|
|
72
|
-
}" data-bottom-btn="${hasBottomBtn}" type-value="${type}" style="${popsStyle}" position="${popsPosition}" data-guid="${guid}">${html}</div>
|
|
74
|
+
<div class="${popsClassNameList.join(" ")}" data-bottom-btn="${hasBottomBtn}" type-value="${type}" style="${popsStyle}" position="${popsPosition}" data-guid="${guid}">${html}</div>
|
|
73
75
|
</div>`;
|
|
74
76
|
},
|
|
75
77
|
/**
|
|
@@ -326,7 +328,7 @@ export const PopsElementHandler = {
|
|
|
326
328
|
addLightStyle($parent: HTMLElement | ShadowRoot, style?: string | null) {
|
|
327
329
|
const darkCSS = /*css*/ `
|
|
328
330
|
@media (prefers-color-scheme: light) {
|
|
329
|
-
${style}
|
|
331
|
+
${style ?? ""}
|
|
330
332
|
}
|
|
331
333
|
`;
|
|
332
334
|
const $css = this.addStyle($parent, darkCSS);
|
|
@@ -342,7 +344,7 @@ export const PopsElementHandler = {
|
|
|
342
344
|
addDarkStyle($parent: HTMLElement | ShadowRoot, style?: string | null) {
|
|
343
345
|
const darkCSS = /*css*/ `
|
|
344
346
|
@media (prefers-color-scheme: dark) {
|
|
345
|
-
${style}
|
|
347
|
+
${style ?? ""}
|
|
346
348
|
}
|
|
347
349
|
`;
|
|
348
350
|
const $css = this.addStyle($parent, darkCSS);
|
|
@@ -6,16 +6,18 @@ import type { PopsIframeConfig } from "../components/iframe/types";
|
|
|
6
6
|
import type { PopsLoadingConfig } from "../components/loading/types";
|
|
7
7
|
import type { PopsPanelConfig } from "../components/panel/types";
|
|
8
8
|
import type { PopsPromptConfig } from "../components/prompt/types/index";
|
|
9
|
-
import {
|
|
9
|
+
import type { EventEmiter } from "../event/EventEmiter";
|
|
10
10
|
import { PopsAnimation } from "../PopsAnimation";
|
|
11
|
+
import { PopsCore } from "../PopsCore";
|
|
11
12
|
import { PopsInstData } from "../PopsInst";
|
|
12
13
|
import type { PopsGeneralConfig } from "../types/components";
|
|
13
14
|
import type { PopsEventConfig, PopsHandlerEventConfig } from "../types/event";
|
|
15
|
+
import type { CustomEventMap } from "../types/EventEmitter";
|
|
14
16
|
import type { PopsInstGeneralConfig } from "../types/inst";
|
|
15
|
-
import type { PopsInstStoreType,
|
|
17
|
+
import type { PopsInstStoreType, PopsSupportAnimConfigType, PopsSupportOnlyConfig, PopsType } from "../types/main";
|
|
16
18
|
import { popsDOMUtils } from "../utils/PopsDOMUtils";
|
|
17
|
-
import { PopsInstanceUtils } from "../utils/PopsInstanceUtils";
|
|
18
19
|
import { popsUtils } from "../utils/PopsUtils";
|
|
20
|
+
import { PopsInstHandler } from "./PopsInstHandler";
|
|
19
21
|
|
|
20
22
|
export const PopsHandler = {
|
|
21
23
|
/**
|
|
@@ -159,10 +161,10 @@ export const PopsHandler = {
|
|
|
159
161
|
function originalRun() {
|
|
160
162
|
if (config.config.mask!.clickEvent!.toClose) {
|
|
161
163
|
// 关闭
|
|
162
|
-
return
|
|
164
|
+
return PopsInstHandler.close(config.config, config.type, targetInst, config.guid, config.animElement);
|
|
163
165
|
} else if (config.config.mask!.clickEvent!.toHide) {
|
|
164
166
|
// 隐藏
|
|
165
|
-
return
|
|
167
|
+
return PopsInstHandler.hide(
|
|
166
168
|
config.config,
|
|
167
169
|
config.type,
|
|
168
170
|
targetInst,
|
|
@@ -373,7 +375,7 @@ export const PopsHandler = {
|
|
|
373
375
|
* @param $mask 遮罩层
|
|
374
376
|
* @param config 当前配置
|
|
375
377
|
*/
|
|
376
|
-
handleEventConfig(
|
|
378
|
+
handleEventConfig<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(
|
|
377
379
|
config:
|
|
378
380
|
| PopsAlertConfig
|
|
379
381
|
| PopsDrawerConfig
|
|
@@ -389,8 +391,9 @@ export const PopsHandler = {
|
|
|
389
391
|
type: PopsInstStoreType,
|
|
390
392
|
$anim: HTMLDivElement,
|
|
391
393
|
$pops: HTMLDivElement,
|
|
394
|
+
emitter: E,
|
|
392
395
|
$mask?: HTMLDivElement
|
|
393
|
-
): PopsEventConfig {
|
|
396
|
+
): PopsEventConfig<E> {
|
|
394
397
|
return {
|
|
395
398
|
$shadowContainer: $shadowContainer,
|
|
396
399
|
$shadowRoot: $shadowRoot,
|
|
@@ -400,17 +403,18 @@ export const PopsHandler = {
|
|
|
400
403
|
$mask: $mask,
|
|
401
404
|
mode: type,
|
|
402
405
|
guid: guid,
|
|
406
|
+
emitter: emitter,
|
|
403
407
|
close() {
|
|
404
|
-
return
|
|
408
|
+
return PopsInstHandler.close(config, type, PopsInstData[type], guid, $anim);
|
|
405
409
|
},
|
|
406
410
|
hide() {
|
|
407
|
-
return
|
|
411
|
+
return PopsInstHandler.hide(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
408
412
|
},
|
|
409
413
|
show($parent?: HTMLElement | Document | ShadowRoot) {
|
|
410
414
|
if ($parent) {
|
|
411
415
|
$parent.appendChild(PopsInstData[type][0].$shadowRoot);
|
|
412
416
|
}
|
|
413
|
-
return
|
|
417
|
+
return PopsInstHandler.show(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
414
418
|
},
|
|
415
419
|
};
|
|
416
420
|
},
|
|
@@ -423,7 +427,7 @@ export const PopsHandler = {
|
|
|
423
427
|
* @param $mask 遮罩层
|
|
424
428
|
* @param config 当前配置
|
|
425
429
|
*/
|
|
426
|
-
handleLoadingEventConfig(
|
|
430
|
+
handleLoadingEventConfig<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(
|
|
427
431
|
config:
|
|
428
432
|
| PopsAlertConfig
|
|
429
433
|
| PopsDrawerConfig
|
|
@@ -437,8 +441,9 @@ export const PopsHandler = {
|
|
|
437
441
|
type: "loading",
|
|
438
442
|
$anim: HTMLDivElement,
|
|
439
443
|
$pops: HTMLDivElement,
|
|
444
|
+
emitter: E,
|
|
440
445
|
$mask?: HTMLDivElement
|
|
441
|
-
): Omit<PopsEventConfig
|
|
446
|
+
): Omit<PopsEventConfig<E>, "$shadowContainer" | "$shadowRoot"> {
|
|
442
447
|
return {
|
|
443
448
|
$el: $anim,
|
|
444
449
|
$anim: $anim,
|
|
@@ -446,14 +451,15 @@ export const PopsHandler = {
|
|
|
446
451
|
$mask: $mask,
|
|
447
452
|
mode: type,
|
|
448
453
|
guid: guid,
|
|
454
|
+
emitter,
|
|
449
455
|
close() {
|
|
450
|
-
return
|
|
456
|
+
return PopsInstHandler.close(config, type, PopsInstData[type], guid, $anim);
|
|
451
457
|
},
|
|
452
458
|
hide() {
|
|
453
|
-
return
|
|
459
|
+
return PopsInstHandler.hide(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
454
460
|
},
|
|
455
461
|
show() {
|
|
456
|
-
return
|
|
462
|
+
return PopsInstHandler.show(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
457
463
|
},
|
|
458
464
|
};
|
|
459
465
|
},
|
|
@@ -474,14 +480,14 @@ export const PopsHandler = {
|
|
|
474
480
|
* @param eventConfig 事件配置,由popsHandler.handleEventConfig创建的
|
|
475
481
|
* @param callback 点击回调
|
|
476
482
|
*/
|
|
477
|
-
handleClickEvent(
|
|
478
|
-
type: PopsHandlerEventConfig["type"],
|
|
483
|
+
handleClickEvent<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(
|
|
484
|
+
type: PopsHandlerEventConfig<E>["type"],
|
|
479
485
|
$btn: HTMLElement,
|
|
480
|
-
eventConfig: PopsEventConfig
|
|
481
|
-
callback?: (details: PopsHandlerEventConfig
|
|
486
|
+
eventConfig: PopsEventConfig<E>,
|
|
487
|
+
callback?: (details: PopsHandlerEventConfig<E>, event: PointerEvent | MouseEvent) => void
|
|
482
488
|
) {
|
|
483
489
|
if (typeof callback !== "function") return;
|
|
484
|
-
popsDOMUtils.on<PointerEvent | MouseEvent>(
|
|
490
|
+
return popsDOMUtils.on<PointerEvent | MouseEvent>(
|
|
485
491
|
$btn,
|
|
486
492
|
"click",
|
|
487
493
|
(event) => {
|
|
@@ -523,16 +529,10 @@ export const PopsHandler = {
|
|
|
523
529
|
callback && callback(event);
|
|
524
530
|
}
|
|
525
531
|
};
|
|
526
|
-
popsDOMUtils.on(PopsCore.globalThis, "keydown", keyboardEvent, {
|
|
532
|
+
const listener = popsDOMUtils.on(PopsCore.globalThis, "keydown", keyboardEvent, {
|
|
527
533
|
capture: true,
|
|
528
534
|
});
|
|
529
|
-
return
|
|
530
|
-
removeKeyboardEvent() {
|
|
531
|
-
popsDOMUtils.off(globalThis, "keydown", keyboardEvent, {
|
|
532
|
-
capture: true,
|
|
533
|
-
});
|
|
534
|
-
},
|
|
535
|
-
};
|
|
535
|
+
return listener;
|
|
536
536
|
},
|
|
537
537
|
/**
|
|
538
538
|
* 处理prompt的点击事件
|
|
@@ -542,13 +542,13 @@ export const PopsHandler = {
|
|
|
542
542
|
* @param eventConfig 事件配置,由popsHandler.handleEventConfig创建的
|
|
543
543
|
* @param callback 点击回调
|
|
544
544
|
*/
|
|
545
|
-
handlePromptClickEvent(
|
|
546
|
-
type: PopsHandlerEventConfig["type"],
|
|
545
|
+
handlePromptClickEvent<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(
|
|
546
|
+
type: PopsHandlerEventConfig<E>["type"],
|
|
547
547
|
inputElement: HTMLInputElement | HTMLTextAreaElement,
|
|
548
548
|
$btn: HTMLElement,
|
|
549
|
-
eventConfig: PopsEventConfig
|
|
549
|
+
eventConfig: PopsEventConfig<E>,
|
|
550
550
|
callback: (
|
|
551
|
-
details: PopsEventConfig & {
|
|
551
|
+
details: PopsEventConfig<E> & {
|
|
552
552
|
type: any;
|
|
553
553
|
text: string;
|
|
554
554
|
},
|
|
@@ -572,14 +572,15 @@ export const PopsHandler = {
|
|
|
572
572
|
);
|
|
573
573
|
},
|
|
574
574
|
/**
|
|
575
|
-
*
|
|
576
|
-
* @param
|
|
575
|
+
* 获取数值
|
|
576
|
+
* @param target
|
|
577
577
|
*/
|
|
578
|
-
|
|
579
|
-
if (typeof
|
|
580
|
-
|
|
578
|
+
getTargerOrFunctionValue<T>(target: T | (() => T)): T {
|
|
579
|
+
if (typeof target === "function") {
|
|
580
|
+
const result = (target as () => T)();
|
|
581
|
+
return result;
|
|
581
582
|
} else {
|
|
582
|
-
return
|
|
583
|
+
return target;
|
|
583
584
|
}
|
|
584
585
|
},
|
|
585
586
|
/**
|
|
@@ -596,10 +597,10 @@ export const PopsHandler = {
|
|
|
596
597
|
if (type === "loading" || type === "tooltip" || type === "rightClickMenu") {
|
|
597
598
|
const inst = PopsInstData[type as keyof typeof PopsInstData];
|
|
598
599
|
if (inst) {
|
|
599
|
-
|
|
600
|
+
PopsInstHandler.removeInstance([inst], "", true);
|
|
600
601
|
}
|
|
601
602
|
} else {
|
|
602
|
-
|
|
603
|
+
PopsInstHandler.removeInstance(
|
|
603
604
|
[
|
|
604
605
|
PopsInstData.alert,
|
|
605
606
|
PopsInstData.confirm,
|
|
@@ -613,15 +614,31 @@ export const PopsHandler = {
|
|
|
613
614
|
true
|
|
614
615
|
);
|
|
615
616
|
}
|
|
616
|
-
} else {
|
|
617
|
-
// 对配置进行处理
|
|
618
|
-
// 选择配置的z-index和已有的pops实例的最大z-index值
|
|
619
|
-
const originZIndex = config.zIndex;
|
|
620
|
-
config.zIndex = () => {
|
|
621
|
-
const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(PopsHandler.handleZIndex(originZIndex) + 100);
|
|
622
|
-
return maxZIndex;
|
|
623
|
-
};
|
|
624
617
|
}
|
|
618
|
+
if (type !== "rightClickMenu") {
|
|
619
|
+
// rightClickMenu在配置处理时就处理了一次,这里不需要重复处理
|
|
620
|
+
config = this.handleZIndex(config);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
return config;
|
|
624
|
+
},
|
|
625
|
+
/**
|
|
626
|
+
* 处理z-index
|
|
627
|
+
* @param config 配置
|
|
628
|
+
*/
|
|
629
|
+
handleZIndex<T extends Required<PopsSupportOnlyConfig[keyof PopsSupportOnlyConfig]>>(config: T): T {
|
|
630
|
+
// 对配置进行处理
|
|
631
|
+
// 选择配置的z-index和已有的pops实例的最大z-index值
|
|
632
|
+
const originZIndex = config.zIndex;
|
|
633
|
+
const handler = () => {
|
|
634
|
+
let deviation = 100;
|
|
635
|
+
deviation += PopsHandler.getTargerOrFunctionValue(originZIndex) ?? 0;
|
|
636
|
+
let maxZIndex = deviation;
|
|
637
|
+
const pointZIndex = popsUtils.getMaxZIndexNodeInfoFromPoint(deviation)[0]?.zIndex ?? 0;
|
|
638
|
+
maxZIndex = Math.max(maxZIndex, pointZIndex);
|
|
639
|
+
return maxZIndex === deviation ? maxZIndex : maxZIndex + deviation;
|
|
640
|
+
};
|
|
641
|
+
config.zIndex = handler;
|
|
625
642
|
return config;
|
|
626
643
|
},
|
|
627
644
|
/**
|