@whitesev/pops 2.0.8 → 2.0.9

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.
@@ -298,6 +298,7 @@ declare class Pops {
298
298
  config: {
299
299
  target: HTMLElement;
300
300
  content: string | (() => string);
301
+ isDiffContent: boolean;
301
302
  position: import("./components/tooltip/indexType").PopsTooltipPosition;
302
303
  className: string;
303
304
  isFixed: boolean;
@@ -184,6 +184,7 @@ export declare const PopsTooltip: {
184
184
  config: {
185
185
  target: HTMLElement;
186
186
  content: string | (() => string);
187
+ isDiffContent: boolean;
187
188
  position: import("./indexType").PopsTooltipPosition;
188
189
  className: string;
189
190
  isFixed: boolean;
@@ -13,6 +13,13 @@ export interface PopsToolTipDetails extends Pick<PopsCommonConfig, "useShadowRoo
13
13
  * 显示的文字
14
14
  */
15
15
  content: string | (() => string);
16
+ /**
17
+ * 是否比较获取到的content的内容是否改变
18
+ *
19
+ * 如果未改变,则在触发.show时不修改内容
20
+ * @default false
21
+ */
22
+ isDiffContent?: boolean;
16
23
  /**
17
24
  * 位置
18
25
  * + `follow` 跟随鼠标|触摸位置移动
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/pops",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "弹窗库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -6,6 +6,7 @@ export const PopsTooltipConfig = (): DeepRequired<PopsToolTipDetails> => {
6
6
  useShadowRoot: true,
7
7
  target: null as any,
8
8
  content: "默认文字",
9
+ isDiffContent: false,
9
10
  position: "top",
10
11
  className: "",
11
12
  isFixed: false,
@@ -128,6 +128,19 @@ export class ToolTip {
128
128
  if (text == null) {
129
129
  text = this.getContent();
130
130
  }
131
+ if (this.$data.config.isDiffContent) {
132
+ let contentPropKey = "data-content";
133
+ // @ts-ignore
134
+ let originContentText: string = this.$el.$content[contentPropKey];
135
+ if (typeof originContentText === "string") {
136
+ if (originContentText === text) {
137
+ // 内容未改变,不修改避免渲染
138
+ return;
139
+ }
140
+ }
141
+ // @ts-ignore
142
+ this.$el.$content[contentPropKey] = text;
143
+ }
131
144
  PopsSafeUtils.setSafeHTML(this.$el.$content, text);
132
145
  }
133
146
  /**
@@ -24,6 +24,13 @@ export interface PopsToolTipDetails
24
24
  * 显示的文字
25
25
  */
26
26
  content: string | (() => string);
27
+ /**
28
+ * 是否比较获取到的content的内容是否改变
29
+ *
30
+ * 如果未改变,则在触发.show时不修改内容
31
+ * @default false
32
+ */
33
+ isDiffContent?: boolean;
27
34
  /**
28
35
  * 位置
29
36
  * + `follow` 跟随鼠标|触摸位置移动