@whitesev/pops 2.5.1 → 2.5.3

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 (46) hide show
  1. package/dist/index.amd.js +62 -74
  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 +62 -74
  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 +62 -74
  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 +62 -74
  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 +62 -74
  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 +62 -74
  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 +16 -16
  26. package/dist/types/src/components/panel/handlerComponents.d.ts +2 -2
  27. package/dist/types/src/components/panel/index.d.ts +1 -1
  28. package/dist/types/src/components/panel/types/components-common.d.ts +3 -5
  29. package/dist/types/src/components/panel/types/index.d.ts +5 -13
  30. package/dist/types/src/components/rightClickMenu/index.d.ts +4 -4
  31. package/dist/types/src/components/rightClickMenu/types/index.d.ts +3 -2
  32. package/dist/types/src/components/searchSuggestion/index.d.ts +1 -1
  33. package/dist/types/src/components/searchSuggestion/types/index.d.ts +3 -2
  34. package/dist/types/src/components/tooltip/index.d.ts +4 -4
  35. package/dist/types/src/components/tooltip/types/index.d.ts +2 -1
  36. package/dist/types/src/utils/PopsDOMUtils.d.ts +1 -1
  37. package/package.json +1 -1
  38. package/src/components/panel/config.ts +36 -43
  39. package/src/components/panel/handlerComponents.ts +7 -22
  40. package/src/components/panel/types/components-common.ts +5 -9
  41. package/src/components/panel/types/index.ts +5 -17
  42. package/src/components/rightClickMenu/types/index.ts +3 -2
  43. package/src/components/searchSuggestion/types/index.ts +3 -2
  44. package/src/components/tooltip/index.ts +1 -3
  45. package/src/components/tooltip/types/index.ts +2 -1
  46. package/src/utils/PopsDOMUtils.ts +23 -10
@@ -21,21 +21,17 @@ export interface PopsPanelRightAsideContainerOptions {
21
21
  */
22
22
  export interface PopsPanelCommonDetails<T extends PopsPanelFormsTotalDetails | PopsPanelFormsDetails> {
23
23
  /**
24
- * (可选)className属性
24
+ * (可选)元素的className,值为空的话就不设置
25
25
  * @default ""
26
26
  */
27
- className?: string;
27
+ className?: string | string[] | (() => string | string[]);
28
28
  /**
29
29
  * (可选)自定义元素属性
30
30
  * @default {}
31
31
  */
32
- attributes?:
33
- | {
34
- [key: string]: any;
35
- }
36
- | {
37
- [key: string]: any;
38
- }[];
32
+ attributes?: {
33
+ [key: string]: any;
34
+ };
39
35
  /**
40
36
  * (可选)自定义属性
41
37
  * @default {}
@@ -51,7 +51,7 @@ export interface PopsPanelContentConfig {
51
51
  * (可选)元素的className,值为空的话就不设置
52
52
  * @default ""
53
53
  */
54
- className?: string | string[];
54
+ className?: PopsPanelCommonDetails<any>["className"];
55
55
  /**
56
56
  * 显示的文本,可以是html格式
57
57
  */
@@ -138,7 +138,7 @@ export interface PopsPanelBottomContentConfig {
138
138
  * (可选)元素的className,值为空的话就不设置
139
139
  * @default ""
140
140
  */
141
- className?: string | string[];
141
+ className?: PopsPanelCommonDetails<any>["className"];
142
142
  /**
143
143
  * (可选)配置所在位置
144
144
  *
@@ -158,24 +158,12 @@ export interface PopsPanelBottomContentConfig {
158
158
  * (可选)自定义元素属性.setAttribute、.getAttribute
159
159
  * @default {}
160
160
  */
161
- attributes?:
162
- | {
163
- [key: string]: any;
164
- }
165
- | {
166
- [key: string]: any;
167
- }[];
161
+ attributes?: PopsPanelCommonDetails<any>["attributes"];
168
162
  /**
169
163
  * (可选)自定义元素内部的属性值
170
164
  * @default {}
171
165
  */
172
- props?:
173
- | {
174
- [K in keyof HTMLElement]?: HTMLElement[K];
175
- }
176
- | {
177
- [key: string]: any;
178
- };
166
+ props?: PopsPanelCommonDetails<any>["props"];
179
167
  /**
180
168
  * 该项的点击回调
181
169
  */
@@ -231,7 +219,7 @@ export interface PopsPanelDetails extends PopsTitleConfig, PopsDragConfig, PopsC
231
219
  *
232
220
  * @default "pops-panel-is-mobile"
233
221
  */
234
- mobileClassName?: string;
222
+ mobileClassName?: PopsPanelCommonDetails<any>["className"];
235
223
  /**
236
224
  * 是否强制是移动端,默认false
237
225
  * + true 强制为移动端
@@ -1,5 +1,6 @@
1
1
  import type { PopsCommonConfig } from "../../../types/components";
2
2
  import type { PopsIconType } from "../../../types/icon";
3
+ import type { PopsPanelCommonDetails } from "../../panel/types/components-common";
3
4
 
4
5
  /**
5
6
  * pops.rightClickMenu的右键菜单配置
@@ -71,10 +72,10 @@ export interface PopsRightClickMenuDetails
71
72
  */
72
73
  childMenuTopOrBottomDistance?: number;
73
74
  /**
74
- * 自定义className,默认为空
75
+ * (可选)元素的className,值为空的话就不设置
75
76
  * @default ""
76
77
  */
77
- className?: string;
78
+ className?: PopsPanelCommonDetails<any>["className"];
78
79
  /**
79
80
  * 是否启用动画,默认false
80
81
  *
@@ -1,4 +1,5 @@
1
1
  import type { PopsCommonConfig } from "../../../types/components";
2
+ import type { PopsPanelCommonDetails } from "../../panel/types/components-common";
2
3
 
3
4
  export type PopsSearchSuggestionData<T = any> = {
4
5
  /**
@@ -126,10 +127,10 @@ export interface PopsSearchSuggestionDetails<T = any>
126
127
  */
127
128
  data: PopsSearchSuggestionData<T>[] | (() => PopsSearchSuggestionData<T>[]);
128
129
  /**
129
- * 自定义的className
130
+ * (可选)元素的className,值为空的话就不设置
130
131
  * @default ""
131
132
  */
132
- className?: string;
133
+ className?: PopsPanelCommonDetails<any>["className"];
133
134
  /**
134
135
  * 建议框的position位置
135
136
  *
@@ -82,9 +82,7 @@ export class ToolTip {
82
82
  const $toolTipArrow = $toolTipContainer.querySelector<HTMLElement>(".pops-tip-arrow")!;
83
83
 
84
84
  // 处理className
85
- if (typeof this.$data.config.className === "string" && this.$data.config.className.trim() !== "") {
86
- popsDOMUtils.addClassName($toolTipContainer, this.$data.config.className);
87
- }
85
+ popsDOMUtils.addClassName($toolTipContainer, this.$data.config.className);
88
86
  // 添加z-index
89
87
  $toolTipContainer.style.zIndex = PopsHandler.handleZIndex(this.$data.config.zIndex).toString();
90
88
  if (this.$data.config.style != null) {
@@ -1,4 +1,5 @@
1
1
  import type { PopsCommonConfig } from "../../../types/components";
2
+ import type { PopsPanelCommonDetails } from "../../panel/types/components-common";
2
3
 
3
4
  /** tooltip的出现位置 */
4
5
  export type PopsTooltipPosition = "top" | "right" | "bottom" | "left" | "follow";
@@ -35,7 +36,7 @@ export interface PopsToolTipDetails
35
36
  * + `github-tooltip` github的样式
36
37
  * @default ""
37
38
  */
38
- className?: string;
39
+ className?: PopsPanelCommonDetails<any>["className"];
39
40
  /**
40
41
  * 是否使用fixed定位,false则是absolute定位
41
42
  *
@@ -1575,18 +1575,31 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
1575
1575
  * @param $el 目标元素
1576
1576
  * @param className className属性
1577
1577
  */
1578
- addClassName($el: Element | undefined | null, className: string) {
1579
- if ($el == null) {
1580
- return;
1578
+ addClassName(
1579
+ $el: Element | undefined | null | undefined,
1580
+ className: string | string[] | (() => string | string[]) | undefined | null
1581
+ ) {
1582
+ if ($el == null) return;
1583
+ if (className == null) return;
1584
+
1585
+ if (typeof className === "function") {
1586
+ className = className();
1581
1587
  }
1582
- if (typeof className !== "string") {
1583
- return;
1588
+ if (!Array.isArray(className)) {
1589
+ className = [className];
1584
1590
  }
1585
- if (className.trim() === "") {
1586
- return;
1587
- }
1588
- const classNameList = className.split(" ").filter((item) => item.trim() !== "");
1589
- $el.classList.add(...classNameList);
1591
+ className.forEach((classNameStrItem) => {
1592
+ if (typeof classNameStrItem !== "string") {
1593
+ // 不是字符串
1594
+ return;
1595
+ }
1596
+ if (classNameStrItem.trim() === "") {
1597
+ // 空字符串
1598
+ return;
1599
+ }
1600
+ const classNameList = classNameStrItem.split(" ").filter((item) => item.trim() !== "");
1601
+ $el?.classList?.add?.(...classNameList);
1602
+ });
1590
1603
  }
1591
1604
  /**
1592
1605
  * 删除className