@whitesev/pops 1.9.0 → 1.9.2

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 (75) hide show
  1. package/dist/index.amd.js +288 -170
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +288 -170
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +288 -170
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +288 -170
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +288 -170
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +288 -170
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/GlobalConfig.d.ts +1 -0
  14. package/dist/types/src/Pops.d.ts +2 -0
  15. package/dist/types/src/components/alert/config.d.ts +1 -1
  16. package/dist/types/src/components/confirm/config.d.ts +1 -1
  17. package/dist/types/src/components/drawer/config.d.ts +1 -1
  18. package/dist/types/src/components/folder/config.d.ts +1 -1
  19. package/dist/types/src/components/iframe/config.d.ts +1 -1
  20. package/dist/types/src/components/loading/config.d.ts +1 -1
  21. package/dist/types/src/components/panel/config.d.ts +1 -1
  22. package/dist/types/src/components/prompt/config.d.ts +1 -1
  23. package/dist/types/src/components/rightClickMenu/config.d.ts +1 -1
  24. package/dist/types/src/components/rightClickMenu/indexType.d.ts +4 -21
  25. package/dist/types/src/components/searchSuggestion/config.d.ts +1 -1
  26. package/dist/types/src/components/searchSuggestion/indexType.d.ts +2 -10
  27. package/dist/types/src/components/tooltip/config.d.ts +1 -1
  28. package/dist/types/src/components/tooltip/index.d.ts +5 -5
  29. package/dist/types/src/components/tooltip/indexType.d.ts +28 -28
  30. package/dist/types/src/handler/PopsElementHandler.d.ts +1 -1
  31. package/dist/types/src/handler/PopsHandler.d.ts +7 -3
  32. package/dist/types/src/types/button.d.ts +13 -19
  33. package/dist/types/src/types/components.d.ts +26 -11
  34. package/dist/types/src/types/event.d.ts +1 -1
  35. package/dist/types/src/types/global.d.ts +9 -0
  36. package/dist/types/src/types/layer.d.ts +1 -1
  37. package/dist/types/src/types/mask.d.ts +14 -11
  38. package/dist/types/src/utils/PopsInstanceUtils.d.ts +2 -1
  39. package/package.json +1 -1
  40. package/src/Pops.ts +1 -1
  41. package/src/components/alert/config.ts +10 -9
  42. package/src/components/alert/index.ts +9 -9
  43. package/src/components/confirm/config.ts +18 -24
  44. package/src/components/confirm/index.ts +9 -9
  45. package/src/components/drawer/config.ts +22 -21
  46. package/src/components/drawer/index.ts +9 -9
  47. package/src/components/folder/config.ts +17 -16
  48. package/src/components/folder/index.ts +32 -24
  49. package/src/components/iframe/config.ts +3 -3
  50. package/src/components/iframe/index.ts +15 -11
  51. package/src/components/loading/config.ts +3 -3
  52. package/src/components/loading/index.ts +1 -1
  53. package/src/components/panel/config.ts +65 -2
  54. package/src/components/panel/index.ts +13 -11
  55. package/src/components/prompt/config.ts +17 -27
  56. package/src/components/prompt/index.ts +10 -8
  57. package/src/components/rightClickMenu/config.ts +117 -109
  58. package/src/components/rightClickMenu/index.ts +13 -12
  59. package/src/components/rightClickMenu/indexType.ts +13 -24
  60. package/src/components/searchSuggestion/config.ts +2 -1
  61. package/src/components/searchSuggestion/index.ts +11 -10
  62. package/src/components/searchSuggestion/indexType.ts +4 -10
  63. package/src/components/tooltip/config.ts +7 -5
  64. package/src/components/tooltip/index.ts +34 -21
  65. package/src/components/tooltip/indexType.ts +38 -35
  66. package/src/css/index.css +1 -1
  67. package/src/handler/PopsElementHandler.ts +2 -2
  68. package/src/handler/PopsHandler.ts +24 -20
  69. package/src/types/button.d.ts +13 -19
  70. package/src/types/components.d.ts +26 -11
  71. package/src/types/event.d.ts +1 -1
  72. package/src/types/global.d.ts +9 -0
  73. package/src/types/layer.d.ts +1 -1
  74. package/src/types/mask.d.ts +14 -11
  75. package/src/utils/PopsInstanceUtils.ts +8 -8
@@ -1,3 +1,4 @@
1
+ import type { PopsCommonConfig } from "../../types/components";
1
2
  import type { PopsIcon } from "../../types/icon";
2
3
 
3
4
  /**
@@ -40,11 +41,20 @@ export interface PopsRightClickMenuDataDetails {
40
41
  /**
41
42
  * pops.rightClickMenu
42
43
  */
43
- export interface PopsRightClickMenuDetails {
44
+ export interface PopsRightClickMenuDetails
45
+ extends Pick<
46
+ PopsCommonConfig,
47
+ "useShadowRoot" | "beforeAppendToPageCallBack" | "zIndex" | "style" | "only"
48
+ > {
44
49
  /**
45
- * 目标,默认为document.documentElement
50
+ * 目标,默认为document.documentElement G
46
51
  */
47
- target?: HTMLElement | typeof globalThis | Window | EventTarget | Node;
52
+ target?:
53
+ | HTMLElement
54
+ | (typeof globalThis & Window)
55
+ | Window
56
+ | EventTarget
57
+ | Node;
48
58
  /**
49
59
  * 目标的子元素选择器,默认为空
50
60
  */
@@ -57,33 +67,12 @@ export interface PopsRightClickMenuDetails {
57
67
  * 自定义className,默认为空
58
68
  */
59
69
  className?: string;
60
- /**
61
- * 是否是唯一的弹窗,默认false
62
- */
63
- only?: boolean;
64
70
  /**
65
71
  * 是否启用动画,默认true
66
72
  */
67
73
  isAnimation?: boolean;
68
- /**
69
- * 弹窗的显示层级,默认10000
70
- */
71
- zIndex?: number | (() => number);
72
74
  /**
73
75
  * 是否阻止默认contextmenu事件
74
76
  */
75
77
  preventDefault?: boolean;
76
- /**
77
- * (可选)自定义style
78
- */
79
- style?: string | null;
80
- /**
81
- * 在元素添加到页面前的事件
82
- * @param $shadowRoot 根元素
83
- * @param $shadowContainer 容器
84
- */
85
- beforeAppendToPageCallBack?: (
86
- $shadowRoot: ShadowRoot,
87
- $shadowContainer: HTMLDivElement
88
- ) => void;
89
78
  }
@@ -1,7 +1,7 @@
1
1
  import type { PopsSearchSuggestionDetails } from "./indexType";
2
2
 
3
3
  export const searchSuggestionConfig =
4
- (): Required<PopsSearchSuggestionDetails> => {
4
+ (): DeepRequired<PopsSearchSuggestionDetails> => {
5
5
  return {
6
6
  // @ts-ignore
7
7
  target: null,
@@ -25,6 +25,7 @@ export const searchSuggestionConfig =
25
25
  liElement.remove();
26
26
  },
27
27
  },
28
+ useShadowRoot: true,
28
29
  className: "",
29
30
  isAbsolute: true,
30
31
  isAnimation: true,
@@ -8,15 +8,11 @@ import { GlobalConfig } from "../../GlobalConfig";
8
8
 
9
9
  export class PopsSearchSuggestion {
10
10
  constructor(details: PopsSearchSuggestionDetails) {
11
- const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow();
12
- PopsHandler.handleInit($shadowRoot, [
13
- pops.config.cssText.index,
14
- pops.config.cssText.anim,
15
- pops.config.cssText.common,
16
- ]);
11
+ const guid = popsUtils.getRandomGUID();
12
+ // 设置当前类型
13
+ const PopsType = "searchSuggestion";
17
14
 
18
- let config: Required<PopsSearchSuggestionDetails> =
19
- PopsSearchSuggestionConfig();
15
+ let config = PopsSearchSuggestionConfig();
20
16
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
21
17
  config = popsUtils.assign(config, details);
22
18
  if (config.target == null) {
@@ -29,8 +25,13 @@ export class PopsSearchSuggestion {
29
25
  if (details.data) {
30
26
  config.data = details.data;
31
27
  }
32
- const guid = popsUtils.getRandomGUID();
33
- const PopsType = "searchSuggestion";
28
+
29
+ const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
30
+ PopsHandler.handleInit($shadowRoot, [
31
+ pops.config.cssText.index,
32
+ pops.config.cssText.anim,
33
+ pops.config.cssText.common,
34
+ ]);
34
35
 
35
36
  if (config.style != null) {
36
37
  let cssNode = document.createElement("style");
@@ -1,8 +1,11 @@
1
+ import type { PopsCommonConfig } from "../../types/components";
2
+
1
3
  /**
2
4
  * 搜索建议悬浮窗
3
5
  * pops.searchSuggestion
4
6
  */
5
- export interface PopsSearchSuggestionDetails<T = any> {
7
+ export interface PopsSearchSuggestionDetails<T = any>
8
+ extends Pick<PopsCommonConfig, "useShadowRoot" | "zIndex" | "style"> {
6
9
  /**
7
10
  * 当前的环境,可以是document,可以是shadowroot,默认是document
8
11
  * @default document
@@ -82,11 +85,6 @@ export interface PopsSearchSuggestionDetails<T = any> {
82
85
  * @default true
83
86
  */
84
87
  positionTopToReverse?: boolean;
85
- /**
86
- * 层级,默认10000
87
- * @default 10000
88
- */
89
- zIndex?: number | (() => number);
90
88
  /**
91
89
  * 搜索中的提示
92
90
  *
@@ -146,10 +144,6 @@ export interface PopsSearchSuggestionDetails<T = any> {
146
144
  liElement: HTMLLIElement,
147
145
  data: T
148
146
  ) => void;
149
- /**
150
- * (可选)自定义style
151
- */
152
- style?: string;
153
147
  }
154
148
 
155
149
  /**
@@ -1,9 +1,10 @@
1
1
  import type { PopsToolTipDetails } from "./indexType";
2
2
 
3
- export const PopsTooltipConfig = (): Required<PopsToolTipDetails> => {
3
+ export const PopsTooltipConfig = (): DeepRequired<PopsToolTipDetails> => {
4
+ // @ts-ignore
4
5
  return {
5
- // @ts-ignore
6
- target: null,
6
+ useShadowRoot: true,
7
+ target: null as any,
7
8
  content: "默认文字",
8
9
  position: "top",
9
10
  className: "",
@@ -22,10 +23,11 @@ export const PopsTooltipConfig = (): Required<PopsToolTipDetails> => {
22
23
  showAfterCallBack() {},
23
24
  closeBeforeCallBack() {},
24
25
  closeAfterCallBack() {},
26
+ delayCloseTime: 100,
27
+ showArrow: true,
25
28
  arrowDistance: 12.5,
26
29
  otherDistance: 0,
27
-
28
30
  style: "",
29
31
  beforeAppendToPageCallBack() {},
30
- };
32
+ } as Required<PopsToolTipDetails>;
31
33
  };
@@ -11,7 +11,7 @@ type ToolTipEventTypeName = "MouseEvent" | "TouchEvent";
11
11
  export class ToolTip {
12
12
  $el = {
13
13
  $shadowContainer: null as unknown as HTMLDivElement,
14
- $shadowRoot: null as unknown as ShadowRoot,
14
+ $shadowRoot: null as unknown as ShadowRoot | HTMLElement,
15
15
  $toolTip: null as unknown as HTMLElement,
16
16
  $content: null as unknown as HTMLElement,
17
17
  $arrow: null as unknown as HTMLElement,
@@ -27,7 +27,7 @@ export class ToolTip {
27
27
  guid: string,
28
28
  ShadowInfo: {
29
29
  $shadowContainer: HTMLDivElement;
30
- $shadowRoot: ShadowRoot;
30
+ $shadowRoot: ShadowRoot | HTMLElement;
31
31
  }
32
32
  ) {
33
33
  this.$data.config = config;
@@ -96,6 +96,10 @@ export class ToolTip {
96
96
  });
97
97
  $toolTipContainer.appendChild(cssNode);
98
98
  }
99
+ // 处理是否显示箭头元素
100
+ if (!this.$data.config.showArrow) {
101
+ $toolTipArrow.remove();
102
+ }
99
103
  return {
100
104
  $toolTipContainer: $toolTipContainer,
101
105
  $toolTipArrow: $toolTipArrow,
@@ -135,12 +139,12 @@ export class ToolTip {
135
139
  this.$el.$toolTip.style.setProperty("z-index", zIndex.toString());
136
140
  }
137
141
  /**
138
- * 获取 提示框的位置
142
+ * 计算 提示框的位置
139
143
  * @param targetElement 目标元素
140
144
  * @param arrowDistance 箭头和目标元素的距离
141
145
  * @param otherDistance 其它位置的偏移
142
146
  */
143
- getPosition(
147
+ calcToolTipPosition(
144
148
  targetElement: HTMLElement,
145
149
  arrowDistance: number,
146
150
  otherDistance: number
@@ -201,7 +205,7 @@ export class ToolTip {
201
205
  * 动态修改tooltip的位置
202
206
  */
203
207
  changePosition() {
204
- let positionInfo = this.getPosition(
208
+ let positionInfo = this.calcToolTipPosition(
205
209
  this.$data.config.target,
206
210
  this.$data.config.arrowDistance,
207
211
  this.$data.config.otherDistance
@@ -352,8 +356,8 @@ export class ToolTip {
352
356
  // 其它的如Touch事件不做处理
353
357
  if (event && event instanceof MouseEvent) {
354
358
  let $target = event.composedPath()[0];
355
- // 如果是子元素触发的话,忽视
356
- if ($target != this.$data.config.target) {
359
+ // 如果是目标元素的子元素/tooltip元素的子元素触发的话,那就不管
360
+ if ($target != this.$data.config.target && $target != this.$el.$toolTip) {
357
361
  return;
358
362
  }
359
363
  }
@@ -373,6 +377,10 @@ export class ToolTip {
373
377
  let timeId = setTimeout(() => {
374
378
  // 设置属性触发关闭动画
375
379
  this.clearCloseTimeoutId(eventType, timeId);
380
+ if (this.$el.$toolTip == null) {
381
+ // 已清除了
382
+ return;
383
+ }
376
384
  this.$el.$toolTip.setAttribute(
377
385
  "data-motion",
378
386
  this.$el.$toolTip
@@ -459,7 +467,10 @@ export class ToolTip {
459
467
  * 鼠标|触摸进入事件
460
468
  */
461
469
  toolTipMouseEnterEvent() {
462
- this.$el.$toolTip.style.animationPlayState = "paused";
470
+ this.clearCloseTimeoutId("MouseEvent");
471
+ this.clearCloseTimeoutId("TouchEvent");
472
+ // 重置动画状态
473
+ // this.$el.$toolTip.style.animationPlayState = "paused";
463
474
  // if (parseInt(getComputedStyle(toolTipElement)) > 0.5) {
464
475
  // toolTipElement.style.animationPlayState = "paused";
465
476
  // }
@@ -491,8 +502,9 @@ export class ToolTip {
491
502
  /**
492
503
  * 鼠标|触摸离开事件
493
504
  */
494
- toolTipMouseLeaveEvent() {
495
- this.$el.$toolTip.style.animationPlayState = "running";
505
+ toolTipMouseLeaveEvent(event: MouseEvent | PointerEvent) {
506
+ this.close(event);
507
+ // this.$el.$toolTip.style.animationPlayState = "running";
496
508
  }
497
509
  /**
498
510
  * 监听鼠标|触摸离开事件
@@ -528,25 +540,26 @@ export type PopsTooltipResult<T extends PopsToolTipDetails> = {
528
540
 
529
541
  export class PopsTooltip {
530
542
  constructor(details: PopsToolTipDetails) {
531
- const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow();
532
- PopsHandler.handleInit($shadowRoot, [
533
- pops.config.cssText.index,
534
- pops.config.cssText.anim,
535
- pops.config.cssText.common,
536
- pops.config.cssText.tooltipCSS,
537
- ]);
543
+ const guid = popsUtils.getRandomGUID();
544
+ // 设置当前类型
545
+ const PopsType = "tooltip";
538
546
 
539
- let config: Required<PopsToolTipDetails> = PopsTooltipConfig();
547
+ let config = PopsTooltipConfig();
540
548
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
541
549
  config = popsUtils.assign(config, details);
542
550
  if (!(config.target instanceof HTMLElement)) {
543
551
  throw "config.target 必须是HTMLElement类型";
544
552
  }
545
- let guid = popsUtils.getRandomGUID();
546
- const PopsType = "tooltip";
547
-
548
553
  config = PopsHandler.handleOnly(PopsType, config);
549
554
 
555
+ const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
556
+ PopsHandler.handleInit($shadowRoot, [
557
+ pops.config.cssText.index,
558
+ pops.config.cssText.anim,
559
+ pops.config.cssText.common,
560
+ pops.config.cssText.tooltipCSS,
561
+ ]);
562
+
550
563
  let toolTip = new ToolTip(config, guid, {
551
564
  $shadowContainer,
552
565
  $shadowRoot,
@@ -1,10 +1,16 @@
1
+ import type { PopsCommonConfig } from "../../types/components";
2
+
1
3
  /** tooltip的出现位置 */
2
4
  export type PopsTooltipPosition = "top" | "right" | "bottom" | "left";
3
5
 
4
6
  /**
5
7
  * pops.tooltip
6
8
  */
7
- export interface PopsToolTipDetails {
9
+ export interface PopsToolTipDetails
10
+ extends Pick<
11
+ PopsCommonConfig,
12
+ "useShadowRoot" | "only" | "zIndex" | "style" | "beforeAppendToPageCallBack"
13
+ > {
8
14
  /**
9
15
  * 目标元素
10
16
  */
@@ -14,20 +20,23 @@ export interface PopsToolTipDetails {
14
20
  */
15
21
  content: string | (() => string);
16
22
  /**
17
- * 位置,默认top
23
+ * 位置
24
+ * @default "top"
18
25
  */
19
26
  position?: PopsTooltipPosition;
20
27
  /**
21
- * 自定义className,默认为空
22
- * + github-tooltip
28
+ * 自定义className
29
+ *
30
+ * + github-tooltip github的样式
31
+ * @default ""
23
32
  */
24
33
  className?: string;
25
34
  /**
26
35
  * 是否使用fixed定位,默认是absolute
27
- *
36
+ *
28
37
  * @default false
29
38
  */
30
- isFixed?:boolean;
39
+ isFixed?: boolean;
31
40
  /**
32
41
  * 是否总是显示,默认为false
33
42
  * + true 设置的triggerShowEventName、triggerCloseEventName将无效
@@ -42,24 +51,20 @@ export interface PopsToolTipDetails {
42
51
  delayCloseTime?: number;
43
52
  /**
44
53
  * 触发显示事件的名称,默认mouseenter touchstart,如果是多个事件,按空格分割
54
+ * @default "mouseenter touchstart"
45
55
  */
46
56
  triggerShowEventName?: string;
47
57
  /**
48
58
  * 触发关闭事件的名称,默认mouseleave touchend,如果是多个事件,按空格分割
59
+ * @default "mouseleave touchend"
49
60
  */
50
61
  triggerCloseEventName?: string;
51
- /**
52
- * z-index,默认10000
53
- */
54
- zIndex?: number | (() => number);
55
- /**
56
- * 是否唯一,默认false
57
- */
58
- only?: boolean;
59
62
  /**
60
63
  * 监听的事件配置
61
64
  */
62
- eventOption?: AddEventListenerOptions;
65
+ eventOption?: {
66
+ [P in keyof AddEventListenerOptions]: AddEventListenerOptions[P];
67
+ };
63
68
  /**
64
69
  * 触发显示前的回调
65
70
  * @returns
@@ -72,37 +77,35 @@ export interface PopsToolTipDetails {
72
77
  showAfterCallBack?: ($toolTip: HTMLElement) => void;
73
78
  /**
74
79
  * 触发关闭前的回调
75
- * @returns
76
- * + false 可阻止关闭
77
80
  */
78
- closeBeforeCallBack?: ($toolTip: HTMLElement) => false | void;
81
+ closeBeforeCallBack?: (
82
+ /**
83
+ *
84
+ * @returns
85
+ * + false 可阻止关闭
86
+ */
87
+ $toolTip: HTMLElement
88
+ ) => false | void;
79
89
  /**
80
90
  * 触发关闭后的回调
81
91
  */
82
92
  closeAfterCallBack?: ($toolTip: HTMLElement) => void;
83
93
  /**
84
- * 箭头与目标的的距离,默认12.5(px)
94
+ * 是否显示箭头
95
+ * @default true
96
+ */
97
+ showArrow?: boolean;
98
+ /**
99
+ * 箭头与目标的的距离(px)
100
+ *
101
+ * @default 12.5
85
102
  */
86
103
  arrowDistance?: number;
87
104
  /**
88
- * 其它的距离,默认0(px)
105
+ * 其它的距离(px)
89
106
  * + 当position为left或者right,这个距离是上、下距离
90
107
  * + 当position为top或者bottom,这个距离是左、右距离
108
+ * @default 0
91
109
  */
92
110
  otherDistance?: number;
93
- /**
94
- * (可选)自定义style
95
- */
96
- style?: string;
97
- /**
98
- * 在元素添加到页面前的事件
99
- *
100
- * 当tooltip添加到ShadowRoot内时也会触发
101
- * @param $shadowRoot 根元素
102
- * @param $shadowContainer 容器
103
- */
104
- beforeAppendToPageCallBack?: (
105
- $shadowRoot: ShadowRoot,
106
- $shadowContainer: HTMLDivElement
107
- ) => void;
108
111
  }
package/src/css/index.css CHANGED
@@ -1,5 +1,5 @@
1
1
  @charset "utf-8";
2
- * {
2
+ .pops * {
3
3
  -webkit-box-sizing: border-box;
4
4
  box-sizing: border-box;
5
5
  margin: 0;
@@ -65,7 +65,7 @@ export const PopsElementHandler = {
65
65
  <div
66
66
  class="pops-anim"
67
67
  anim="${__config.animation || ""}"
68
- style="${popsAnimStyle};"
68
+ style="${popsAnimStyle}"
69
69
  data-guid="${guid}">
70
70
  ${
71
71
  config.style != null
@@ -140,7 +140,7 @@ export const PopsElementHandler = {
140
140
  */
141
141
  getBottomBtnHTML(
142
142
  type: PopsTypeSupportBottomBtn,
143
- config: PopsSupportBottomBtn[keyof PopsSupportBottomBtn]
143
+ config: Omit<PopsSupportBottomBtn[keyof PopsSupportBottomBtn], "content">
144
144
  ): string {
145
145
  if (!config.btn) {
146
146
  // 未设置btn参数
@@ -8,6 +8,7 @@ import type { PopsPanelDetails } from "../components/panel/indexType";
8
8
  import type { PopsPromptDetails } from "../components/prompt/indexType";
9
9
  import { PopsCore } from "../Core";
10
10
  import { pops } from "../Pops";
11
+ import type { PopsCommonConfig } from "../types/components";
11
12
  import { PopsEventDetails, PopsHandlerEventDetails } from "../types/event";
12
13
  import { PopsLayerCommonConfig } from "../types/layer";
13
14
  import type {
@@ -24,21 +25,31 @@ export const PopsHandler = {
24
25
  /**
25
26
  * 创建shadow
26
27
  */
27
- handlerShadow() {
28
+ handlerShadow(config: Pick<PopsCommonConfig, "useShadowRoot">) {
28
29
  let $shadowContainer = document.createElement("div");
29
30
  $shadowContainer.className = "pops-shadow-container";
30
- let $shadowRoot = $shadowContainer.attachShadow({ mode: "open" });
31
- return {
32
- $shadowContainer,
33
- $shadowRoot,
34
- };
31
+ if (config.useShadowRoot) {
32
+ let $shadowRoot = $shadowContainer.attachShadow({ mode: "open" });
33
+ return {
34
+ $shadowContainer,
35
+ $shadowRoot,
36
+ };
37
+ } else {
38
+ return {
39
+ $shadowContainer,
40
+ $shadowRoot: $shadowContainer,
41
+ };
42
+ }
35
43
  },
36
44
  /**
37
45
  * 处理初始化
38
46
  * @param $shadowRoot 所在的shadowRoot
39
47
  * @param cssText 添加进ShadowRoot的CSS
40
48
  */
41
- handleInit($shadowRoot?: ShadowRoot, cssText?: string | string[]) {
49
+ handleInit(
50
+ $shadowRoot?: ShadowRoot | HTMLElement,
51
+ cssText?: string | string[]
52
+ ) {
42
53
  pops.init();
43
54
  if (!arguments.length) {
44
55
  return;
@@ -364,7 +375,7 @@ export const PopsHandler = {
364
375
  handleEventDetails(
365
376
  guid: string,
366
377
  $shadowContainer: HTMLDivElement,
367
- $shadowRoot: ShadowRoot,
378
+ $shadowRoot: ShadowRoot | HTMLElement,
368
379
  mode: PopsLayerMode,
369
380
  animElement: HTMLDivElement,
370
381
  popsElement: HTMLDivElement,
@@ -658,20 +669,13 @@ export const PopsHandler = {
658
669
  } else {
659
670
  // 对配置进行处理
660
671
  // 选择配置的z-index和已有的pops实例的最大z-index值
661
- if (typeof config.zIndex === "function") {
662
- let originZIndexFn = config.zIndex;
663
- config.zIndex = () => {
664
- const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(
665
- PopsHandler.handleZIndex(originZIndexFn) + 100
666
- );
667
- return maxZIndex;
668
- };
669
- } else {
672
+ let originZIndex = config.zIndex;
673
+ config.zIndex = () => {
670
674
  const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(
671
- PopsHandler.handleZIndex(config.zIndex) + 100
675
+ PopsHandler.handleZIndex(originZIndex) + 100
672
676
  );
673
- config.zIndex = maxZIndex;
674
- }
677
+ return maxZIndex;
678
+ };
675
679
  }
676
680
  return config;
677
681
  },
@@ -85,15 +85,18 @@ export interface PopsButtonDetails<T = {}> {
85
85
  */
86
86
  rightIcon: boolean;
87
87
  /**
88
- * 图标按钮是否是旋转360°,默认false
88
+ * 图标按钮是否是旋转360°
89
+ * @default false
89
90
  */
90
91
  iconIsLoading: boolean;
91
92
  /**
92
- * 按钮尺寸大小,默认为空
93
+ * 按钮尺寸大小
94
+ * @default ""
93
95
  */
94
- size: PopsButtonSize;
96
+ size: PopsButtonSize | "";
95
97
  /**
96
- * 按钮样式类型,默认为default
98
+ * 按钮样式类型
99
+ * @default "default"
97
100
  */
98
101
  type: PopsButtonStyleType;
99
102
  /**
@@ -126,11 +129,13 @@ export interface PopsButtonDetailsAnyType<T = {}> {
126
129
  */
127
130
  rightIcon: boolean;
128
131
  /**
129
- * 图标按钮是否是旋转360°,默认false
132
+ * 图标按钮是否是旋转360°
133
+ * @default false
130
134
  */
131
135
  iconIsLoading: boolean;
132
136
  /**
133
- * 按钮尺寸大小,默认为空
137
+ * 按钮尺寸大小
138
+ * @default ""
134
139
  */
135
140
  size: PopsButtonSize;
136
141
  /**
@@ -138,7 +143,8 @@ export interface PopsButtonDetailsAnyType<T = {}> {
138
143
  */
139
144
  type: string;
140
145
  /**
141
- * 按钮文字,默认为空
146
+ * 按钮文字
147
+ * @default ""
142
148
  */
143
149
  text: string;
144
150
  /**
@@ -204,18 +210,6 @@ export interface PopsHeaderCloseButtonDetails {
204
210
  * 是否启用按钮
205
211
  */
206
212
  enable?: boolean;
207
- /**
208
- * 按钮尺寸大小,默认为空
209
- */
210
- size?: PopsButtonSize;
211
- /**
212
- * 按钮样式类型,默认为default
213
- */
214
- type?: PopsButtonStyleType;
215
- /**
216
- * 按钮文字,默认为空
217
- */
218
- text?: string;
219
213
  /**
220
214
  * 按钮点击的回调
221
215
  */