@whitesev/pops 2.5.2 → 2.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 (45) hide show
  1. package/dist/index.amd.js +76 -112
  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 +76 -112
  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 +76 -112
  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 +76 -112
  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 +76 -112
  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 +76 -112
  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 +4 -4
  26. package/dist/types/src/components/panel/handlerComponents.d.ts +2 -2
  27. package/dist/types/src/components/panel/types/components-common.d.ts +3 -5
  28. package/dist/types/src/components/panel/types/index.d.ts +5 -11
  29. package/dist/types/src/components/rightClickMenu/index.d.ts +1 -1
  30. package/dist/types/src/components/rightClickMenu/types/index.d.ts +3 -2
  31. package/dist/types/src/components/searchSuggestion/types/index.d.ts +3 -2
  32. package/dist/types/src/components/tooltip/index.d.ts +1 -1
  33. package/dist/types/src/components/tooltip/types/index.d.ts +2 -1
  34. package/dist/types/src/utils/PopsDOMUtils.d.ts +1 -1
  35. package/package.json +1 -1
  36. package/src/components/panel/config.ts +37 -79
  37. package/src/components/panel/handlerComponents.ts +7 -22
  38. package/src/components/panel/index.ts +12 -2
  39. package/src/components/panel/types/components-common.ts +5 -9
  40. package/src/components/panel/types/index.ts +5 -13
  41. package/src/components/rightClickMenu/types/index.ts +3 -2
  42. package/src/components/searchSuggestion/types/index.ts +3 -2
  43. package/src/components/tooltip/index.ts +1 -3
  44. package/src/components/tooltip/types/index.ts +2 -1
  45. package/src/utils/PopsDOMUtils.ts +23 -10
@@ -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