@whitesev/pops 3.3.4 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/index.amd.js +13118 -12906
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.amd.min.js +1 -1
  4. package/dist/index.amd.min.js.map +1 -1
  5. package/dist/index.cjs.js +805 -593
  6. package/dist/index.cjs.js.map +1 -1
  7. package/dist/index.cjs.min.js +1 -1
  8. package/dist/index.cjs.min.js.map +1 -1
  9. package/dist/index.esm.js +805 -593
  10. package/dist/index.esm.js.map +1 -1
  11. package/dist/index.esm.min.js +1 -1
  12. package/dist/index.esm.min.js.map +1 -1
  13. package/dist/index.iife.js +13119 -12907
  14. package/dist/index.iife.js.map +1 -1
  15. package/dist/index.iife.min.js +1 -1
  16. package/dist/index.iife.min.js.map +1 -1
  17. package/dist/index.system.js +13122 -12910
  18. package/dist/index.system.js.map +1 -1
  19. package/dist/index.system.min.js +1 -1
  20. package/dist/index.system.min.js.map +1 -1
  21. package/dist/index.umd.js +13121 -12909
  22. package/dist/index.umd.js.map +1 -1
  23. package/dist/index.umd.min.js +1 -1
  24. package/dist/index.umd.min.js.map +1 -1
  25. package/dist/types/src/Pops.d.ts +61 -46
  26. package/dist/types/src/PopsAnimation.d.ts +33 -0
  27. package/dist/types/src/PopsIcon.d.ts +1 -1
  28. package/dist/types/src/components/alert/index.d.ts +3 -1
  29. package/dist/types/src/components/confirm/index.d.ts +3 -1
  30. package/dist/types/src/components/drawer/index.d.ts +3 -1
  31. package/dist/types/src/components/folder/index.d.ts +3 -1
  32. package/dist/types/src/components/folder/types/index.d.ts +4 -0
  33. package/dist/types/src/components/iframe/index.d.ts +6 -1
  34. package/dist/types/src/components/iframe/types/index.d.ts +4 -2
  35. package/dist/types/src/components/loading/index.d.ts +3 -1
  36. package/dist/types/src/components/panel/handlerComponents.d.ts +4 -1
  37. package/dist/types/src/components/panel/index.d.ts +2 -16
  38. package/dist/types/src/components/panel/types/index.d.ts +7 -2
  39. package/dist/types/src/components/prompt/index.d.ts +3 -1
  40. package/dist/types/src/components/searchSuggestion/index.d.ts +4 -1
  41. package/dist/types/src/components/tooltip/index.d.ts +6 -2
  42. package/dist/types/src/config/GlobalConfig.d.ts +1 -0
  43. package/dist/types/src/event/EventEmiter.d.ts +33 -0
  44. package/dist/types/src/handler/PopsHandler.d.ts +18 -16
  45. package/dist/types/src/handler/PopsInstHandler.d.ts +67 -0
  46. package/dist/types/src/types/EventEmitter.d.ts +18 -0
  47. package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +4 -0
  48. package/dist/types/src/types/button.d.ts +2 -1
  49. package/dist/types/src/types/components.d.ts +7 -0
  50. package/dist/types/src/types/event.d.ts +6 -2
  51. package/dist/types/src/types/inst.d.ts +4 -4
  52. package/dist/types/src/utils/PopsDOMUtils.d.ts +0 -16
  53. package/dist/types/src/utils/PopsInstanceUtils.d.ts +0 -88
  54. package/dist/types/src/utils/PopsUtils.d.ts +57 -0
  55. package/package.json +3 -3
  56. package/src/Pops.ts +7 -2
  57. package/src/PopsAnimation.ts +126 -0
  58. package/src/components/alert/defaultConfig.ts +1 -0
  59. package/src/components/alert/index.ts +9 -9
  60. package/src/components/confirm/defaultConfig.ts +1 -0
  61. package/src/components/confirm/index.ts +9 -9
  62. package/src/components/drawer/defaultConfig.ts +1 -0
  63. package/src/components/drawer/index.ts +12 -9
  64. package/src/components/folder/defaultConfig.ts +1 -0
  65. package/src/components/folder/index.ts +9 -8
  66. package/src/components/folder/types/index.ts +4 -0
  67. package/src/components/iframe/defaultConfig.ts +1 -0
  68. package/src/components/iframe/index.ts +18 -12
  69. package/src/components/iframe/types/index.ts +10 -8
  70. package/src/components/loading/defaultConfig.ts +1 -0
  71. package/src/components/loading/index.ts +12 -6
  72. package/src/components/panel/defaultConfig.ts +2 -0
  73. package/src/components/panel/handlerComponents.ts +41 -111
  74. package/src/components/panel/index.ts +34 -28
  75. package/src/components/panel/types/index.ts +7 -2
  76. package/src/components/prompt/defaultConfig.ts +1 -0
  77. package/src/components/prompt/index.ts +9 -8
  78. package/src/components/rightClickMenu/index.ts +17 -14
  79. package/src/components/searchSuggestion/index.ts +5 -1
  80. package/src/components/tooltip/index.ts +20 -10
  81. package/src/event/EventEmiter.ts +95 -0
  82. package/src/handler/PopsElementHandler.ts +6 -4
  83. package/src/handler/PopsHandler.ts +100 -58
  84. package/src/handler/PopsInstHandler.ts +557 -0
  85. package/src/types/EventEmitter.d.ts +18 -0
  86. package/src/types/PopsDOMUtilsEventType.d.ts +4 -0
  87. package/src/types/button.d.ts +2 -1
  88. package/src/types/components.d.ts +7 -0
  89. package/src/types/event.d.ts +6 -2
  90. package/src/types/inst.d.ts +4 -4
  91. package/src/utils/PopsDOMUtils.ts +1 -40
  92. package/src/utils/PopsInstanceUtils.ts +19 -627
  93. package/src/utils/PopsUtils.ts +194 -0
@@ -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="pops ${
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
  /**
@@ -6,37 +6,63 @@ 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 { PopsCore } from "../PopsCore";
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, PopsType, PopsSupportAnimConfigType, PopsSupportOnlyConfig } from "../types/main";
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
  /**
22
24
  * 创建shadow
23
25
  */
24
- handlerShadow(config: Pick<PopsGeneralConfig, "useShadowRoot">) {
26
+ handlerShadow(config: Pick<PopsGeneralConfig, "useShadowRoot" | "stopKeyDownEventPropagation">) {
25
27
  const $shadowContainer = popsDOMUtils.createElement("div", {
26
28
  className: "pops-shadow-container",
27
29
  });
30
+ let $shadowRoot: ShadowRoot | HTMLElement;
28
31
  if (config.useShadowRoot) {
29
- const $shadowRoot = $shadowContainer.attachShadow({ mode: "open" });
30
- return {
31
- $shadowContainer,
32
- $shadowRoot,
33
- };
32
+ $shadowRoot = $shadowContainer.attachShadow({ mode: "open" });
34
33
  } else {
35
- return {
36
- $shadowContainer,
37
- $shadowRoot: $shadowContainer,
38
- };
34
+ $shadowRoot = $shadowContainer;
39
35
  }
36
+ // 添加键盘监听
37
+ // rightClickMenu
38
+ // searchSuggestion
39
+ // tooltip
40
+ // 以上都不需要添加该事件监听
41
+ if (config.stopKeyDownEventPropagation) {
42
+ popsDOMUtils.on(
43
+ $shadowRoot,
44
+ "keydown",
45
+ [
46
+ 'input[type="text"]',
47
+ 'input[type="password"]',
48
+ 'input[type="number"]',
49
+ 'input[type="email"]',
50
+ 'input[type="url"]',
51
+ 'input[type="search"]',
52
+ "input:not([type])",
53
+ "textarea",
54
+ ],
55
+ (evt) => {
56
+ evt.stopImmediatePropagation();
57
+ evt.stopPropagation();
58
+ },
59
+ { capture: true }
60
+ );
61
+ }
62
+ return {
63
+ $shadowContainer,
64
+ $shadowRoot,
65
+ };
40
66
  },
41
67
  /**
42
68
  * 处理初始化
@@ -135,10 +161,10 @@ export const PopsHandler = {
135
161
  function originalRun() {
136
162
  if (config.config.mask!.clickEvent!.toClose) {
137
163
  // 关闭
138
- return PopsInstanceUtils.close(config.config, config.type, targetInst, config.guid, config.animElement);
164
+ return PopsInstHandler.close(config.config, config.type, targetInst, config.guid, config.animElement);
139
165
  } else if (config.config.mask!.clickEvent!.toHide) {
140
166
  // 隐藏
141
- return PopsInstanceUtils.hide(
167
+ return PopsInstHandler.hide(
142
168
  config.config,
143
169
  config.type,
144
170
  targetInst,
@@ -349,7 +375,7 @@ export const PopsHandler = {
349
375
  * @param $mask 遮罩层
350
376
  * @param config 当前配置
351
377
  */
352
- handleEventConfig(
378
+ handleEventConfig<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(
353
379
  config:
354
380
  | PopsAlertConfig
355
381
  | PopsDrawerConfig
@@ -365,8 +391,9 @@ export const PopsHandler = {
365
391
  type: PopsInstStoreType,
366
392
  $anim: HTMLDivElement,
367
393
  $pops: HTMLDivElement,
394
+ emitter: E,
368
395
  $mask?: HTMLDivElement
369
- ): PopsEventConfig {
396
+ ): PopsEventConfig<E> {
370
397
  return {
371
398
  $shadowContainer: $shadowContainer,
372
399
  $shadowRoot: $shadowRoot,
@@ -376,17 +403,18 @@ export const PopsHandler = {
376
403
  $mask: $mask,
377
404
  mode: type,
378
405
  guid: guid,
406
+ emitter: emitter,
379
407
  close() {
380
- return PopsInstanceUtils.close(config, type, PopsInstData[type], guid, $anim);
408
+ return PopsInstHandler.close(config, type, PopsInstData[type], guid, $anim);
381
409
  },
382
410
  hide() {
383
- return PopsInstanceUtils.hide(config, type, PopsInstData[type], guid, $anim, $mask);
411
+ return PopsInstHandler.hide(config, type, PopsInstData[type], guid, $anim, $mask);
384
412
  },
385
413
  show($parent?: HTMLElement | Document | ShadowRoot) {
386
414
  if ($parent) {
387
415
  $parent.appendChild(PopsInstData[type][0].$shadowRoot);
388
416
  }
389
- return PopsInstanceUtils.show(config, type, PopsInstData[type], guid, $anim, $mask);
417
+ return PopsInstHandler.show(config, type, PopsInstData[type], guid, $anim, $mask);
390
418
  },
391
419
  };
392
420
  },
@@ -399,7 +427,7 @@ export const PopsHandler = {
399
427
  * @param $mask 遮罩层
400
428
  * @param config 当前配置
401
429
  */
402
- handleLoadingEventConfig(
430
+ handleLoadingEventConfig<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(
403
431
  config:
404
432
  | PopsAlertConfig
405
433
  | PopsDrawerConfig
@@ -413,8 +441,9 @@ export const PopsHandler = {
413
441
  type: "loading",
414
442
  $anim: HTMLDivElement,
415
443
  $pops: HTMLDivElement,
444
+ emitter: E,
416
445
  $mask?: HTMLDivElement
417
- ): Omit<PopsEventConfig, "$shadowContainer" | "$shadowRoot"> {
446
+ ): Omit<PopsEventConfig<E>, "$shadowContainer" | "$shadowRoot"> {
418
447
  return {
419
448
  $el: $anim,
420
449
  $anim: $anim,
@@ -422,14 +451,15 @@ export const PopsHandler = {
422
451
  $mask: $mask,
423
452
  mode: type,
424
453
  guid: guid,
454
+ emitter,
425
455
  close() {
426
- return PopsInstanceUtils.close(config, type, PopsInstData[type], guid, $anim);
456
+ return PopsInstHandler.close(config, type, PopsInstData[type], guid, $anim);
427
457
  },
428
458
  hide() {
429
- return PopsInstanceUtils.hide(config, type, PopsInstData[type], guid, $anim, $mask);
459
+ return PopsInstHandler.hide(config, type, PopsInstData[type], guid, $anim, $mask);
430
460
  },
431
461
  show() {
432
- return PopsInstanceUtils.show(config, type, PopsInstData[type], guid, $anim, $mask);
462
+ return PopsInstHandler.show(config, type, PopsInstData[type], guid, $anim, $mask);
433
463
  },
434
464
  };
435
465
  },
@@ -450,14 +480,14 @@ export const PopsHandler = {
450
480
  * @param eventConfig 事件配置,由popsHandler.handleEventConfig创建的
451
481
  * @param callback 点击回调
452
482
  */
453
- handleClickEvent(
454
- type: PopsHandlerEventConfig["type"],
483
+ handleClickEvent<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(
484
+ type: PopsHandlerEventConfig<E>["type"],
455
485
  $btn: HTMLElement,
456
- eventConfig: PopsEventConfig,
457
- callback?: (details: PopsHandlerEventConfig, event: PointerEvent | MouseEvent) => void
486
+ eventConfig: PopsEventConfig<E>,
487
+ callback?: (details: PopsHandlerEventConfig<E>, event: PointerEvent | MouseEvent) => void
458
488
  ) {
459
489
  if (typeof callback !== "function") return;
460
- popsDOMUtils.on<PointerEvent | MouseEvent>(
490
+ return popsDOMUtils.on<PointerEvent | MouseEvent>(
461
491
  $btn,
462
492
  "click",
463
493
  (event) => {
@@ -499,16 +529,10 @@ export const PopsHandler = {
499
529
  callback && callback(event);
500
530
  }
501
531
  };
502
- popsDOMUtils.on(PopsCore.globalThis, "keydown", keyboardEvent, {
532
+ const listener = popsDOMUtils.on(PopsCore.globalThis, "keydown", keyboardEvent, {
503
533
  capture: true,
504
534
  });
505
- return {
506
- removeKeyboardEvent() {
507
- popsDOMUtils.off(globalThis, "keydown", keyboardEvent, {
508
- capture: true,
509
- });
510
- },
511
- };
535
+ return listener;
512
536
  },
513
537
  /**
514
538
  * 处理prompt的点击事件
@@ -518,13 +542,13 @@ export const PopsHandler = {
518
542
  * @param eventConfig 事件配置,由popsHandler.handleEventConfig创建的
519
543
  * @param callback 点击回调
520
544
  */
521
- handlePromptClickEvent(
522
- type: PopsHandlerEventConfig["type"],
545
+ handlePromptClickEvent<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(
546
+ type: PopsHandlerEventConfig<E>["type"],
523
547
  inputElement: HTMLInputElement | HTMLTextAreaElement,
524
548
  $btn: HTMLElement,
525
- eventConfig: PopsEventConfig,
549
+ eventConfig: PopsEventConfig<E>,
526
550
  callback: (
527
- details: PopsEventConfig & {
551
+ details: PopsEventConfig<E> & {
528
552
  type: any;
529
553
  text: string;
530
554
  },
@@ -548,14 +572,15 @@ export const PopsHandler = {
548
572
  );
549
573
  },
550
574
  /**
551
- * 把配置的z-index配置转为数字
552
- * @param zIndex
575
+ * 获取数值
576
+ * @param target
553
577
  */
554
- handleZIndex(zIndex: number | (() => number)): number {
555
- if (typeof zIndex === "function") {
556
- return zIndex();
578
+ getTargerOrFunctionValue<T>(target: T | (() => T)): T {
579
+ if (typeof target === "function") {
580
+ const result = (target as () => T)();
581
+ return result;
557
582
  } else {
558
- return zIndex;
583
+ return target;
559
584
  }
560
585
  },
561
586
  /**
@@ -572,10 +597,10 @@ export const PopsHandler = {
572
597
  if (type === "loading" || type === "tooltip" || type === "rightClickMenu") {
573
598
  const inst = PopsInstData[type as keyof typeof PopsInstData];
574
599
  if (inst) {
575
- PopsInstanceUtils.removeInstance([inst], "", true);
600
+ PopsInstHandler.removeInstance([inst], "", true);
576
601
  }
577
602
  } else {
578
- PopsInstanceUtils.removeInstance(
603
+ PopsInstHandler.removeInstance(
579
604
  [
580
605
  PopsInstData.alert,
581
606
  PopsInstData.confirm,
@@ -589,15 +614,32 @@ export const PopsHandler = {
589
614
  true
590
615
  );
591
616
  }
592
- } else {
593
- // 对配置进行处理
594
- // 选择配置的z-index和已有的pops实例的最大z-index值
595
- const originZIndex = config.zIndex;
596
- config.zIndex = () => {
597
- const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(PopsHandler.handleZIndex(originZIndex) + 100);
598
- return maxZIndex;
599
- };
600
617
  }
618
+ config = this.handleZIndex(config);
619
+
620
+ return config;
621
+ },
622
+ /**
623
+ * 处理z-index
624
+ * @param config 配置
625
+ */
626
+ handleZIndex<T extends Required<PopsSupportOnlyConfig[keyof PopsSupportOnlyConfig]>>(config: T): T {
627
+ // 对配置进行处理
628
+ // 选择配置的z-index和已有的pops实例的最大z-index值
629
+ const originZIndex = config.zIndex;
630
+ const handler = () => {
631
+ let deviation = 100;
632
+ if (originZIndex.toString() !== handler.toString()) {
633
+ // 避免叠加覆盖
634
+ deviation += PopsHandler.getTargerOrFunctionValue(originZIndex) ?? 0;
635
+ }
636
+ let maxZIndex = deviation;
637
+ const pointZIndexInfoList = popsUtils.getMaxZIndexNodeInfoFromPoint(deviation);
638
+ const pointZIndexInfo = pointZIndexInfoList[0];
639
+ maxZIndex = Math.max(maxZIndex, pointZIndexInfo?.zIndex ?? deviation);
640
+ return maxZIndex;
641
+ };
642
+ config.zIndex = handler;
601
643
  return config;
602
644
  },
603
645
  /**