@whitesev/pops 1.5.2 → 1.5.4

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 (38) hide show
  1. package/dist/index.amd.js +178 -83
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +178 -83
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +178 -83
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +178 -83
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +178 -83
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +178 -83
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/components/rightClickMenu/indexType.d.ts +1 -1
  14. package/dist/types/src/components/searchSuggestion/indexType.d.ts +1 -1
  15. package/dist/types/src/components/tooltip/indexType.d.ts +1 -1
  16. package/dist/types/src/handler/PopsElementHandler.d.ts +2 -1
  17. package/dist/types/src/handler/PopsHandler.d.ts +5 -0
  18. package/dist/types/src/types/components.d.ts +1 -1
  19. package/package.json +3 -2
  20. package/src/Pops.ts +1 -1
  21. package/src/components/alert/index.ts +6 -3
  22. package/src/components/confirm/index.ts +6 -3
  23. package/src/components/drawer/index.ts +6 -3
  24. package/src/components/folder/index.ts +79 -40
  25. package/src/components/iframe/index.ts +12 -8
  26. package/src/components/loading/index.ts +8 -3
  27. package/src/components/panel/index.ts +8 -3
  28. package/src/components/prompt/index.ts +7 -4
  29. package/src/components/rightClickMenu/index.ts +15 -3
  30. package/src/components/rightClickMenu/indexType.ts +1 -1
  31. package/src/components/searchSuggestion/index.ts +1 -1
  32. package/src/components/searchSuggestion/indexType.ts +1 -1
  33. package/src/components/tooltip/index.ts +3 -1
  34. package/src/components/tooltip/indexType.ts +1 -1
  35. package/src/handler/PopsElementHandler.ts +24 -18
  36. package/src/handler/PopsHandler.ts +27 -4
  37. package/src/types/components.d.ts +1 -1
  38. package/src/utils/PopsUtils.ts +8 -4
@@ -24,6 +24,9 @@ export const PopsElementHandler = {
24
24
  */
25
25
  getMaskHTML(guid: string, zIndex: number = 101, style = ""): string {
26
26
  zIndex = zIndex - 100;
27
+ if (style.startsWith(";")) {
28
+ style = style.replace(";", "");
29
+ }
27
30
  return `<div class="pops-mask" data-guid="${guid}" style="z-index:${zIndex};${style}"></div>`;
28
31
  },
29
32
  /**
@@ -33,21 +36,23 @@ export const PopsElementHandler = {
33
36
  * @param config
34
37
  * @param html
35
38
  * @param bottomBtnHTML
39
+ * @param zIndex
36
40
  */
37
41
  getAnimHTML(
38
42
  guid: string,
39
43
  type: PopsTypeSupportAnim,
40
44
  config: PopsSupportAnim[keyof PopsSupportAnim],
41
45
  html = "",
42
- bottomBtnHTML = ""
46
+ bottomBtnHTML = "",
47
+ zIndex: number
43
48
  ) {
44
49
  let __config = config as PopsAlertDetails;
45
50
  let popsAnimStyle = "";
46
51
  let popsStyle = "";
47
52
  let popsPosition = __config.position || "";
48
53
  if (config.zIndex != null) {
49
- popsAnimStyle += `z-index: ${config.zIndex};`;
50
- popsStyle += `z-index: ${config.zIndex};`;
54
+ popsAnimStyle += `z-index: ${zIndex};`;
55
+ popsStyle += `z-index: ${zIndex};`;
51
56
  }
52
57
  if (__config.width != null) {
53
58
  popsStyle += `width: ${__config.width};`;
@@ -56,26 +61,27 @@ export const PopsElementHandler = {
56
61
  popsStyle += `height: ${__config.height};`;
57
62
  }
58
63
  let hasBottomBtn = bottomBtnHTML.trim() === "" ? false : true;
59
- return `<div
60
- class="pops-anim"
61
- anim="${__config.animation || ""}"
62
- style="${popsAnimStyle};"
63
- data-guid="${guid}">
64
+ return /*html*/ `
65
+ <div
66
+ class="pops-anim"
67
+ anim="${__config.animation || ""}"
68
+ style="${popsAnimStyle};"
69
+ data-guid="${guid}">
64
70
  ${
65
71
  config.style != null
66
72
  ? `<style tyle="text/css">${config.style}</style>`
67
73
  : ""
68
74
  }
69
- <div
70
- class="pops ${config.class || ""}"
71
- data-bottom-btn="${hasBottomBtn}"
72
- type-value="${type}"
73
- style="${popsStyle}"
74
- position="${popsPosition}"
75
- data-guid="${guid}">
76
- ${html}
77
- </div>
78
- </div>`;
75
+ <div
76
+ class="pops ${config.class || ""}"
77
+ data-bottom-btn="${hasBottomBtn}"
78
+ type-value="${type}"
79
+ style="${popsStyle}"
80
+ position="${popsPosition}"
81
+ data-guid="${guid}">
82
+ ${html}
83
+ </div>
84
+ </div>`;
79
85
  },
80
86
  /**
81
87
  * 获取顶部按钮层HTML
@@ -605,6 +605,17 @@ export const PopsHandler = {
605
605
  }
606
606
  );
607
607
  },
608
+ /**
609
+ * 把配置的z-index配置转为数字
610
+ * @param zIndex
611
+ */
612
+ handleZIndex(zIndex: number | (() => number)): number {
613
+ if (typeof zIndex === "function") {
614
+ return zIndex();
615
+ } else {
616
+ return zIndex;
617
+ }
618
+ },
608
619
  /**
609
620
  * 处理config.only
610
621
  * @param type 当前弹窗类型
@@ -641,10 +652,22 @@ export const PopsHandler = {
641
652
  );
642
653
  }
643
654
  } else {
644
- const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(
645
- config.zIndex + 100
646
- );
647
- config.zIndex = maxZIndex;
655
+ // 对配置进行处理
656
+ // 选择配置的z-index和已有的pops实例的最大z-index值
657
+ if (typeof config.zIndex === "function") {
658
+ let originZIndexFn = config.zIndex;
659
+ config.zIndex = () => {
660
+ const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(
661
+ PopsHandler.handleZIndex(originZIndexFn) + 100
662
+ );
663
+ return maxZIndex;
664
+ };
665
+ }else{
666
+ const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(
667
+ PopsHandler.handleZIndex(config.zIndex) + 100
668
+ );
669
+ config.zIndex = maxZIndex;
670
+ }
648
671
  }
649
672
  return config;
650
673
  },
@@ -170,7 +170,7 @@ export interface PopsCommonConfig {
170
170
  /**
171
171
  * z-index显示层级,默认10000
172
172
  */
173
- zIndex?: number;
173
+ zIndex?: number | (() => number);
174
174
  /**
175
175
  * 遮罩层
176
176
  */
@@ -130,8 +130,10 @@ class PopsUtils {
130
130
  } else {
131
131
  for (const targetKeyName in target) {
132
132
  if (targetKeyName in source) {
133
- let targetValue = (target as any)[targetKeyName];
134
- let sourceValue = (source as any)[targetKeyName];
133
+ // @ts-ignore
134
+ let targetValue = target[targetKeyName];
135
+ // @ts-ignore
136
+ let sourceValue = source[targetKeyName];
135
137
  if (
136
138
  typeof sourceValue === "object" &&
137
139
  sourceValue != null &&
@@ -139,7 +141,8 @@ class PopsUtils {
139
141
  Object.keys(sourceValue).length
140
142
  ) {
141
143
  /* 源端的值是object类型,且不是元素节点 */
142
- (target as any)[targetKeyName] = UtilsContext.assign(
144
+ // @ts-ignore
145
+ target[targetKeyName] = UtilsContext.assign(
143
146
  targetValue,
144
147
  sourceValue,
145
148
  isAdd
@@ -147,7 +150,8 @@ class PopsUtils {
147
150
  continue;
148
151
  }
149
152
  /* 直接赋值 */
150
- (target as any)[targetKeyName] = sourceValue;
153
+ // @ts-ignore
154
+ target[targetKeyName] = sourceValue;
151
155
  }
152
156
  }
153
157
  }