@whitesev/pops 2.0.7 → 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.
- package/dist/index.amd.js +394 -55
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +394 -55
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +394 -55
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +394 -55
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +394 -55
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +394 -55
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +550 -199
- package/dist/types/src/components/rightClickMenu/index.d.ts +545 -199
- package/dist/types/src/components/tooltip/index.d.ts +10 -2
- package/dist/types/src/components/tooltip/indexType.d.ts +13 -4
- package/dist/types/src/utils/PopsUtils.d.ts +16 -0
- package/package.json +6 -5
- package/src/Pops.ts +2 -2
- package/src/components/drawer/index.ts +2 -2
- package/src/components/folder/index.ts +2 -2
- package/src/components/iframe/index.ts +1 -1
- package/src/components/panel/PanelHandleContentDetails.ts +9 -9
- package/src/components/rightClickMenu/index.ts +1 -1
- package/src/components/searchSuggestion/index.ts +2 -2
- package/src/components/tooltip/config.ts +1 -0
- package/src/components/tooltip/index.ts +69 -16
- package/src/components/tooltip/indexType.ts +18 -4
- package/src/utils/PopsDOMUtils.ts +1 -1
- package/src/utils/PopsInstanceUtils.ts +6 -6
- package/src/utils/PopsUtils.ts +53 -1
|
@@ -46,11 +46,12 @@ export declare class ToolTip {
|
|
|
46
46
|
changeZIndex(): void;
|
|
47
47
|
/**
|
|
48
48
|
* 计算 提示框的位置
|
|
49
|
+
* @param event 触发的事件
|
|
49
50
|
* @param targetElement 目标元素
|
|
50
51
|
* @param arrowDistance 箭头和目标元素的距离
|
|
51
52
|
* @param otherDistance 其它位置的偏移
|
|
52
53
|
*/
|
|
53
|
-
calcToolTipPosition(targetElement: HTMLElement, arrowDistance: number, otherDistance: number): {
|
|
54
|
+
calcToolTipPosition(targetElement: HTMLElement, arrowDistance: number, otherDistance: number, event?: MouseEvent | TouchEvent | PointerEvent): {
|
|
54
55
|
TOP: {
|
|
55
56
|
left: number;
|
|
56
57
|
top: number;
|
|
@@ -75,11 +76,17 @@ export declare class ToolTip {
|
|
|
75
76
|
arrow: string;
|
|
76
77
|
motion: string;
|
|
77
78
|
};
|
|
79
|
+
FOLLOW: {
|
|
80
|
+
left: number;
|
|
81
|
+
top: number;
|
|
82
|
+
arrow: string;
|
|
83
|
+
motion: string;
|
|
84
|
+
};
|
|
78
85
|
};
|
|
79
86
|
/**
|
|
80
87
|
* 动态修改tooltip的位置
|
|
81
88
|
*/
|
|
82
|
-
changePosition(): void;
|
|
89
|
+
changePosition(event?: MouseEvent | TouchEvent | PointerEvent): void;
|
|
83
90
|
/**
|
|
84
91
|
* 事件绑定
|
|
85
92
|
*/
|
|
@@ -177,6 +184,7 @@ export declare const PopsTooltip: {
|
|
|
177
184
|
config: {
|
|
178
185
|
target: HTMLElement;
|
|
179
186
|
content: string | (() => string);
|
|
187
|
+
isDiffContent: boolean;
|
|
180
188
|
position: import("./indexType").PopsTooltipPosition;
|
|
181
189
|
className: string;
|
|
182
190
|
isFixed: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PopsCommonConfig } from "../../types/components";
|
|
2
2
|
/** tooltip的出现位置 */
|
|
3
|
-
export type PopsTooltipPosition = "top" | "right" | "bottom" | "left";
|
|
3
|
+
export type PopsTooltipPosition = "top" | "right" | "bottom" | "left" | "follow";
|
|
4
4
|
/**
|
|
5
5
|
* pops.tooltip
|
|
6
6
|
*/
|
|
@@ -13,20 +13,28 @@ 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
|
* 位置
|
|
25
|
+
* + `follow` 跟随鼠标|触摸位置移动
|
|
18
26
|
* @default "top"
|
|
19
27
|
*/
|
|
20
28
|
position?: PopsTooltipPosition;
|
|
21
29
|
/**
|
|
22
30
|
* 自定义className
|
|
23
31
|
*
|
|
24
|
-
* + github-tooltip github的样式
|
|
32
|
+
* + `github-tooltip` github的样式
|
|
25
33
|
* @default ""
|
|
26
34
|
*/
|
|
27
35
|
className?: string;
|
|
28
36
|
/**
|
|
29
|
-
* 是否使用fixed
|
|
37
|
+
* 是否使用fixed定位,false则是absolute定位
|
|
30
38
|
*
|
|
31
39
|
* @default false
|
|
32
40
|
*/
|
|
@@ -35,7 +43,7 @@ export interface PopsToolTipDetails extends Pick<PopsCommonConfig, "useShadowRoo
|
|
|
35
43
|
* 是否总是显示,默认为false
|
|
36
44
|
* + true 设置的triggerShowEventName、triggerCloseEventName将无效
|
|
37
45
|
* 返回提供show和close函数,取消on和off
|
|
38
|
-
* + false
|
|
46
|
+
* + false 事件触发才显示
|
|
39
47
|
*/
|
|
40
48
|
alwaysShow?: boolean;
|
|
41
49
|
/**
|
|
@@ -98,6 +106,7 @@ export interface PopsToolTipDetails extends Pick<PopsCommonConfig, "useShadowRoo
|
|
|
98
106
|
* 其它的距离(px)
|
|
99
107
|
* + 当position为left或者right,这个距离是上、下距离
|
|
100
108
|
* + 当position为top或者bottom,这个距离是左、右距离
|
|
109
|
+
* + 当position为follow,这个距离是上、左距离
|
|
101
110
|
* @default 0
|
|
102
111
|
*/
|
|
103
112
|
otherDistance?: number;
|
|
@@ -119,6 +119,22 @@ declare class PopsUtils {
|
|
|
119
119
|
**/
|
|
120
120
|
formatByteToSize<T extends boolean>(byteSize: number | string, addType?: T): T extends true ? string : number;
|
|
121
121
|
AnyTouch: () => typeof AnyTouch;
|
|
122
|
+
/**
|
|
123
|
+
* 自动使用 Worker 执行 setTimeout
|
|
124
|
+
*/
|
|
125
|
+
setTimeout(callback: Function, timeout?: number): number;
|
|
126
|
+
/**
|
|
127
|
+
* 配合 .setTimeout 使用
|
|
128
|
+
*/
|
|
129
|
+
clearTimeout(timeId: number | undefined): void;
|
|
130
|
+
/**
|
|
131
|
+
* 自动使用 Worker 执行 setInterval
|
|
132
|
+
*/
|
|
133
|
+
setInterval(callback: Function, timeout?: number): number;
|
|
134
|
+
/**
|
|
135
|
+
* 配合 .setInterval 使用
|
|
136
|
+
*/
|
|
137
|
+
clearInterval(timeId: number | undefined): void;
|
|
122
138
|
}
|
|
123
139
|
declare const popsUtils: PopsUtils;
|
|
124
140
|
export { popsUtils };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whitesev/pops",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"description": "弹窗库",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -35,17 +35,18 @@
|
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@rollup/plugin-commonjs": "^25.0.8",
|
|
38
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
38
|
+
"@rollup/plugin-node-resolve": "^15.3.1",
|
|
39
39
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
40
40
|
"any-touch": "^2.2.0",
|
|
41
41
|
"rollup-plugin-clear": "^2.0.7",
|
|
42
|
-
"tslib": "^2.
|
|
42
|
+
"tslib": "^2.8.1",
|
|
43
|
+
"worker-timers": "^8.0.21"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"rollup-plugin-import-css": "^3.5.
|
|
46
|
+
"rollup-plugin-import-css": "^3.5.8",
|
|
46
47
|
"rollup-plugin-livereload": "^2.0.5",
|
|
47
48
|
"rollup-plugin-serve": "^1.1.1",
|
|
48
|
-
"typescript": "^5.
|
|
49
|
+
"typescript": "^5.8.3"
|
|
49
50
|
},
|
|
50
51
|
"scripts": {
|
|
51
52
|
"dev": "rollup --config --watch",
|
package/src/Pops.ts
CHANGED
|
@@ -80,7 +80,7 @@ class Pops {
|
|
|
80
80
|
/** 配置 */
|
|
81
81
|
config = {
|
|
82
82
|
/** 版本号 */
|
|
83
|
-
version: "2025.5.
|
|
83
|
+
version: "2025.5.26",
|
|
84
84
|
cssText: {
|
|
85
85
|
/** 主CSS */
|
|
86
86
|
index: indexCSS,
|
|
@@ -197,7 +197,7 @@ class Pops {
|
|
|
197
197
|
this.config.animation = PopsInstanceUtils.getKeyFrames(
|
|
198
198
|
animationStyle.sheet!
|
|
199
199
|
);
|
|
200
|
-
setTimeout(() => {
|
|
200
|
+
popsUtils.setTimeout(() => {
|
|
201
201
|
animationStyle.remove();
|
|
202
202
|
}, 50);
|
|
203
203
|
}
|
|
@@ -215,8 +215,8 @@ export const PopsDrawer = {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
popsDOMUtils.appendBody($shadowContainer);
|
|
218
|
-
setTimeout(() => {
|
|
219
|
-
setTimeout(() => {
|
|
218
|
+
popsUtils.setTimeout(() => {
|
|
219
|
+
popsUtils.setTimeout(() => {
|
|
220
220
|
$pops.style.setProperty("transform", "");
|
|
221
221
|
}, config.openDelay);
|
|
222
222
|
}, 50);
|
|
@@ -713,12 +713,12 @@ export const PopsFolder = {
|
|
|
713
713
|
|
|
714
714
|
downloadIframeLinkElement.src = downloadInfo.url;
|
|
715
715
|
downloadIframeLinkElement.onload = function () {
|
|
716
|
-
setTimeout(() => {
|
|
716
|
+
popsUtils.setTimeout(() => {
|
|
717
717
|
downloadIframeLinkElement.remove();
|
|
718
718
|
}, 1000);
|
|
719
719
|
};
|
|
720
720
|
$shadowRoot.appendChild(downloadIframeLinkElement);
|
|
721
|
-
setTimeout(() => {
|
|
721
|
+
popsUtils.setTimeout(() => {
|
|
722
722
|
downloadIframeLinkElement.remove();
|
|
723
723
|
}, 3 * 60 * 1000);
|
|
724
724
|
} else {
|
|
@@ -20,7 +20,7 @@ export const PopsIframe = {
|
|
|
20
20
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
21
21
|
config = popsUtils.assign(config, details);
|
|
22
22
|
if (config.url == null) {
|
|
23
|
-
throw "config.url不能为空";
|
|
23
|
+
throw new Error("config.url不能为空");
|
|
24
24
|
}
|
|
25
25
|
config = PopsHandler.handleOnly(PopsType, config);
|
|
26
26
|
|
|
@@ -576,11 +576,11 @@ export const PanelHandleContentDetails = () => {
|
|
|
576
576
|
let isSuccess = false;
|
|
577
577
|
let oldTotalWidth = this.$data.totalWidth;
|
|
578
578
|
let timer: number | undefined = void 0;
|
|
579
|
-
let interval = setInterval(() => {
|
|
579
|
+
let interval = popsUtils.setInterval(() => {
|
|
580
580
|
if (isSuccess) {
|
|
581
581
|
this.$interval.isCheck = false;
|
|
582
|
-
clearTimeout(timer);
|
|
583
|
-
clearInterval(interval);
|
|
582
|
+
popsUtils.clearTimeout(timer);
|
|
583
|
+
popsUtils.clearInterval(interval);
|
|
584
584
|
} else {
|
|
585
585
|
this.initTotalWidth();
|
|
586
586
|
if (this.$data.totalWidth !== 0) {
|
|
@@ -598,8 +598,8 @@ export const PanelHandleContentDetails = () => {
|
|
|
598
598
|
}
|
|
599
599
|
}, checkStepTime);
|
|
600
600
|
/* 最长检测时间是10s */
|
|
601
|
-
timer = setTimeout(() => {
|
|
602
|
-
clearInterval(interval);
|
|
601
|
+
timer = popsUtils.setTimeout(() => {
|
|
602
|
+
popsUtils.clearInterval(interval);
|
|
603
603
|
}, maxTime);
|
|
604
604
|
},
|
|
605
605
|
/**
|
|
@@ -981,16 +981,16 @@ export const PanelHandleContentDetails = () => {
|
|
|
981
981
|
return;
|
|
982
982
|
}
|
|
983
983
|
this.$data.isCheckingStopDragMove = true;
|
|
984
|
-
let interval = setInterval(() => {
|
|
984
|
+
let interval = popsUtils.setInterval(() => {
|
|
985
985
|
if (!this.$data.isMove) {
|
|
986
986
|
this.$data.isCheckingStopDragMove = false;
|
|
987
987
|
this.closeToolTip();
|
|
988
|
-
clearInterval(interval);
|
|
988
|
+
popsUtils.clearInterval(interval);
|
|
989
989
|
}
|
|
990
990
|
}, 200);
|
|
991
|
-
setTimeout(() => {
|
|
991
|
+
popsUtils.setTimeout(() => {
|
|
992
992
|
this.$data.isCheckingStopDragMove = false;
|
|
993
|
-
clearInterval(interval);
|
|
993
|
+
popsUtils.clearInterval(interval);
|
|
994
994
|
}, 2000);
|
|
995
995
|
},
|
|
996
996
|
/**
|
|
@@ -23,7 +23,7 @@ export const PopsRightClickMenu = {
|
|
|
23
23
|
config = popsUtils.assign(config, details);
|
|
24
24
|
config = PopsHandler.handleOnly(PopsType, config);
|
|
25
25
|
if (config.target == null) {
|
|
26
|
-
throw "config.target 不能为空";
|
|
26
|
+
throw new Error("config.target 不能为空");
|
|
27
27
|
}
|
|
28
28
|
if (details.data) {
|
|
29
29
|
// @ts-ignore
|
|
@@ -17,7 +17,7 @@ export const PopsSearchSuggestion = {
|
|
|
17
17
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
18
18
|
config = popsUtils.assign(config, details);
|
|
19
19
|
if (config.target == null) {
|
|
20
|
-
throw new
|
|
20
|
+
throw new Error("config.target 不能为空");
|
|
21
21
|
}
|
|
22
22
|
/* 做下兼容处理 */
|
|
23
23
|
if (config.inputTarget == null) {
|
|
@@ -352,7 +352,7 @@ export const PopsSearchSuggestion = {
|
|
|
352
352
|
option
|
|
353
353
|
);
|
|
354
354
|
} else {
|
|
355
|
-
throw new
|
|
355
|
+
throw new Error("未知followPosition:" + config.followPosition);
|
|
356
356
|
}
|
|
357
357
|
},
|
|
358
358
|
/**
|
|
@@ -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
|
/**
|
|
@@ -146,6 +159,7 @@ export class ToolTip {
|
|
|
146
159
|
}
|
|
147
160
|
/**
|
|
148
161
|
* 计算 提示框的位置
|
|
162
|
+
* @param event 触发的事件
|
|
149
163
|
* @param targetElement 目标元素
|
|
150
164
|
* @param arrowDistance 箭头和目标元素的距离
|
|
151
165
|
* @param otherDistance 其它位置的偏移
|
|
@@ -153,7 +167,8 @@ export class ToolTip {
|
|
|
153
167
|
calcToolTipPosition(
|
|
154
168
|
targetElement: HTMLElement,
|
|
155
169
|
arrowDistance: number,
|
|
156
|
-
otherDistance: number
|
|
170
|
+
otherDistance: number,
|
|
171
|
+
event?: MouseEvent | TouchEvent | PointerEvent
|
|
157
172
|
) {
|
|
158
173
|
let offsetInfo = popsDOMUtils.offset(
|
|
159
174
|
targetElement,
|
|
@@ -180,6 +195,30 @@ export class ToolTip {
|
|
|
180
195
|
/* 目标元素的Y轴的中间位置 */
|
|
181
196
|
let targetElement_Y_center_pos =
|
|
182
197
|
targetElement_top + targetElement_height / 2 - toolTipElement_height / 2;
|
|
198
|
+
|
|
199
|
+
let mouseX = 0;
|
|
200
|
+
let mouseY = 0;
|
|
201
|
+
if (event != null) {
|
|
202
|
+
if (event instanceof MouseEvent || event instanceof PointerEvent) {
|
|
203
|
+
mouseX = event.pageX;
|
|
204
|
+
mouseY = event.y;
|
|
205
|
+
} else if (event instanceof TouchEvent) {
|
|
206
|
+
let touchEvent = event.touches[0];
|
|
207
|
+
mouseX = touchEvent.pageX;
|
|
208
|
+
mouseY = touchEvent.pageY;
|
|
209
|
+
} else {
|
|
210
|
+
// @ts-ignore
|
|
211
|
+
if (typeof event.clientX === "number") {
|
|
212
|
+
// @ts-ignore
|
|
213
|
+
mouseX = event.clientX;
|
|
214
|
+
}
|
|
215
|
+
// @ts-ignore
|
|
216
|
+
if (typeof event.clientY === "number") {
|
|
217
|
+
// @ts-ignore
|
|
218
|
+
mouseY = event.clientY;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
183
222
|
return {
|
|
184
223
|
TOP: {
|
|
185
224
|
left: targetElement_X_center_pos - otherDistance,
|
|
@@ -205,19 +244,26 @@ export class ToolTip {
|
|
|
205
244
|
arrow: "right",
|
|
206
245
|
motion: "fadeInLeft",
|
|
207
246
|
},
|
|
247
|
+
FOLLOW: {
|
|
248
|
+
left: mouseX + otherDistance,
|
|
249
|
+
top: mouseY + otherDistance,
|
|
250
|
+
arrow: "follow",
|
|
251
|
+
motion: "",
|
|
252
|
+
},
|
|
208
253
|
};
|
|
209
254
|
}
|
|
210
255
|
/**
|
|
211
256
|
* 动态修改tooltip的位置
|
|
212
257
|
*/
|
|
213
|
-
changePosition() {
|
|
258
|
+
changePosition(event?: MouseEvent | TouchEvent | PointerEvent) {
|
|
214
259
|
let positionInfo = this.calcToolTipPosition(
|
|
215
260
|
this.$data.config.target,
|
|
216
261
|
this.$data.config.arrowDistance,
|
|
217
|
-
this.$data.config.otherDistance
|
|
262
|
+
this.$data.config.otherDistance,
|
|
263
|
+
event
|
|
218
264
|
);
|
|
219
|
-
let positionKey =
|
|
220
|
-
|
|
265
|
+
let positionKey = this.$data.config.position.toUpperCase() as any as
|
|
266
|
+
| keyof typeof positionInfo;
|
|
221
267
|
let positionDetail = positionInfo[positionKey];
|
|
222
268
|
if (positionDetail) {
|
|
223
269
|
this.$el.$toolTip.style.left = positionDetail.left + "px";
|
|
@@ -276,12 +322,12 @@ export class ToolTip {
|
|
|
276
322
|
if (typeof timeId === "number") {
|
|
277
323
|
// 只清除一个
|
|
278
324
|
if (timeId == currentTimeId) {
|
|
279
|
-
clearTimeout(timeId);
|
|
325
|
+
popsUtils.clearTimeout(timeId);
|
|
280
326
|
timeIdList.splice(index, 1);
|
|
281
327
|
break;
|
|
282
328
|
}
|
|
283
329
|
} else {
|
|
284
|
-
clearTimeout(currentTimeId);
|
|
330
|
+
popsUtils.clearTimeout(currentTimeId);
|
|
285
331
|
timeIdList.splice(index, 1);
|
|
286
332
|
index--;
|
|
287
333
|
}
|
|
@@ -322,7 +368,7 @@ export class ToolTip {
|
|
|
322
368
|
// 更新内容
|
|
323
369
|
this.changeContent();
|
|
324
370
|
// 更新tip的位置
|
|
325
|
-
this.changePosition();
|
|
371
|
+
this.changePosition(event);
|
|
326
372
|
if (typeof this.$data.config.showAfterCallBack === "function") {
|
|
327
373
|
this.$data.config.showAfterCallBack(this.$el.$toolTip);
|
|
328
374
|
}
|
|
@@ -380,19 +426,26 @@ export class ToolTip {
|
|
|
380
426
|
) {
|
|
381
427
|
this.$data.config.delayCloseTime = 100;
|
|
382
428
|
}
|
|
383
|
-
let timeId = setTimeout(() => {
|
|
429
|
+
let timeId = popsUtils.setTimeout(() => {
|
|
384
430
|
// 设置属性触发关闭动画
|
|
385
431
|
this.clearCloseTimeoutId(eventType, timeId);
|
|
386
432
|
if (this.$el.$toolTip == null) {
|
|
387
433
|
// 已清除了
|
|
388
434
|
return;
|
|
389
435
|
}
|
|
390
|
-
this.$el.$toolTip.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
436
|
+
let motion = this.$el.$toolTip.getAttribute("data-motion");
|
|
437
|
+
if (motion == null || motion.trim() === "") {
|
|
438
|
+
// 没有动画
|
|
439
|
+
this.toolTipAnimationFinishEvent();
|
|
440
|
+
} else {
|
|
441
|
+
// 修改data-motion触发动画关闭
|
|
442
|
+
this.$el.$toolTip.setAttribute(
|
|
443
|
+
"data-motion",
|
|
444
|
+
this.$el.$toolTip
|
|
445
|
+
.getAttribute("data-motion")!
|
|
446
|
+
.replace("fadeIn", "fadeOut")
|
|
447
|
+
);
|
|
448
|
+
}
|
|
396
449
|
}, this.$data.config.delayCloseTime);
|
|
397
450
|
this.addCloseTimeoutId(eventType, timeId);
|
|
398
451
|
if (typeof this.$data.config.closeAfterCallBack === "function") {
|
|
@@ -554,7 +607,7 @@ export const PopsTooltip = {
|
|
|
554
607
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
555
608
|
config = popsUtils.assign(config, details);
|
|
556
609
|
if (!(config.target instanceof HTMLElement)) {
|
|
557
|
-
throw "config.target 必须是HTMLElement类型";
|
|
610
|
+
throw new TypeError("config.target 必须是HTMLElement类型");
|
|
558
611
|
}
|
|
559
612
|
config = PopsHandler.handleOnly(PopsType, config);
|
|
560
613
|
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { PopsCommonConfig } from "../../types/components";
|
|
2
2
|
|
|
3
3
|
/** tooltip的出现位置 */
|
|
4
|
-
export type PopsTooltipPosition =
|
|
4
|
+
export type PopsTooltipPosition =
|
|
5
|
+
| "top"
|
|
6
|
+
| "right"
|
|
7
|
+
| "bottom"
|
|
8
|
+
| "left"
|
|
9
|
+
| "follow";
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* pops.tooltip
|
|
@@ -19,20 +24,28 @@ export interface PopsToolTipDetails
|
|
|
19
24
|
* 显示的文字
|
|
20
25
|
*/
|
|
21
26
|
content: string | (() => string);
|
|
27
|
+
/**
|
|
28
|
+
* 是否比较获取到的content的内容是否改变
|
|
29
|
+
*
|
|
30
|
+
* 如果未改变,则在触发.show时不修改内容
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
isDiffContent?: boolean;
|
|
22
34
|
/**
|
|
23
35
|
* 位置
|
|
36
|
+
* + `follow` 跟随鼠标|触摸位置移动
|
|
24
37
|
* @default "top"
|
|
25
38
|
*/
|
|
26
39
|
position?: PopsTooltipPosition;
|
|
27
40
|
/**
|
|
28
41
|
* 自定义className
|
|
29
42
|
*
|
|
30
|
-
* + github-tooltip github的样式
|
|
43
|
+
* + `github-tooltip` github的样式
|
|
31
44
|
* @default ""
|
|
32
45
|
*/
|
|
33
46
|
className?: string;
|
|
34
47
|
/**
|
|
35
|
-
* 是否使用fixed
|
|
48
|
+
* 是否使用fixed定位,false则是absolute定位
|
|
36
49
|
*
|
|
37
50
|
* @default false
|
|
38
51
|
*/
|
|
@@ -41,7 +54,7 @@ export interface PopsToolTipDetails
|
|
|
41
54
|
* 是否总是显示,默认为false
|
|
42
55
|
* + true 设置的triggerShowEventName、triggerCloseEventName将无效
|
|
43
56
|
* 返回提供show和close函数,取消on和off
|
|
44
|
-
* + false
|
|
57
|
+
* + false 事件触发才显示
|
|
45
58
|
*/
|
|
46
59
|
alwaysShow?: boolean;
|
|
47
60
|
/**
|
|
@@ -105,6 +118,7 @@ export interface PopsToolTipDetails
|
|
|
105
118
|
* 其它的距离(px)
|
|
106
119
|
* + 当position为left或者right,这个距离是上、下距离
|
|
107
120
|
* + 当position为top或者bottom,这个距离是左、右距离
|
|
121
|
+
* + 当position为follow,这个距离是上、左距离
|
|
108
122
|
* @default 0
|
|
109
123
|
*/
|
|
110
124
|
otherDistance?: number;
|
|
@@ -273,7 +273,7 @@ export const PopsInstanceUtils = {
|
|
|
273
273
|
animElement.querySelector<HTMLDivElement>(".pops[type-value]")!;
|
|
274
274
|
if (popsType === "drawer") {
|
|
275
275
|
let drawerConfig = config as Required<PopsDrawerDetails>;
|
|
276
|
-
setTimeout(() => {
|
|
276
|
+
popsUtils.setTimeout(() => {
|
|
277
277
|
maskElement.style.setProperty("display", "none");
|
|
278
278
|
if (["top", "bottom"].includes(drawerConfig.direction)) {
|
|
279
279
|
popsElement.style.setProperty("height", "0");
|
|
@@ -368,7 +368,7 @@ export const PopsInstanceUtils = {
|
|
|
368
368
|
animElement.querySelector<HTMLDivElement>(".pops[type-value]")!;
|
|
369
369
|
if (popsType === "drawer") {
|
|
370
370
|
let drawerConfig = config as PopsDrawerDetails;
|
|
371
|
-
setTimeout(() => {
|
|
371
|
+
popsUtils.setTimeout(() => {
|
|
372
372
|
popsDOMUtils.css(maskElement!, "display", "");
|
|
373
373
|
let direction = drawerConfig.direction!;
|
|
374
374
|
let size = drawerConfig.size!.toString();
|
|
@@ -380,7 +380,7 @@ export const PopsInstanceUtils = {
|
|
|
380
380
|
console.error("未知direction:", direction);
|
|
381
381
|
}
|
|
382
382
|
resolve();
|
|
383
|
-
}, drawerConfig.openDelay);
|
|
383
|
+
}, drawerConfig.openDelay ?? 0);
|
|
384
384
|
} else {
|
|
385
385
|
let findLayerIns = layerConfigList.find(
|
|
386
386
|
(layerConfigItem) => layerConfigItem.guid === guid
|
|
@@ -512,7 +512,7 @@ export const PopsInstanceUtils = {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
if (popsType === "drawer") {
|
|
515
|
-
setTimeout(() => {
|
|
515
|
+
popsUtils.setTimeout(() => {
|
|
516
516
|
transitionendEvent();
|
|
517
517
|
}, drawerConfig.closeDelay);
|
|
518
518
|
} else {
|
|
@@ -786,10 +786,10 @@ export const PopsInstanceUtils = {
|
|
|
786
786
|
sortByDesc = true
|
|
787
787
|
) {
|
|
788
788
|
if (typeof sortByDesc !== "boolean") {
|
|
789
|
-
throw "参数 sortByDesc 必须为boolean类型";
|
|
789
|
+
throw new TypeError("参数 sortByDesc 必须为boolean类型");
|
|
790
790
|
}
|
|
791
791
|
if (getBeforeValueFun == null || getAfterValueFun == null) {
|
|
792
|
-
throw "获取前面的值或后面的值的方法不能为空";
|
|
792
|
+
throw new Error("获取前面的值或后面的值的方法不能为空");
|
|
793
793
|
}
|
|
794
794
|
return function (after_obj: T, before_obj: T) {
|
|
795
795
|
var beforeValue = getBeforeValueFun(before_obj); /* 前 */
|
package/src/utils/PopsUtils.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { PopsCore } from "../Core";
|
|
2
2
|
import type { PopsUtilsOwnObject } from "../types/main";
|
|
3
3
|
import { popsDOMUtils } from "./PopsDOMUtils";
|
|
4
|
+
import {
|
|
5
|
+
clearInterval as WorkerClearInterval,
|
|
6
|
+
clearTimeout as WorkerClearTimeout,
|
|
7
|
+
setInterval as WorkerSetInterval,
|
|
8
|
+
setTimeout as WorkerSetTimeout,
|
|
9
|
+
} from "worker-timers";
|
|
4
10
|
import AnyTouch from "any-touch";
|
|
5
11
|
|
|
6
12
|
class PopsUtils {
|
|
@@ -349,7 +355,7 @@ class PopsUtils {
|
|
|
349
355
|
formatByteToSize(byteSize: number | string, addType = true) {
|
|
350
356
|
byteSize = parseInt(byteSize.toString());
|
|
351
357
|
if (isNaN(byteSize)) {
|
|
352
|
-
throw new
|
|
358
|
+
throw new TypeError("Utils.formatByteToSize 参数 byteSize 格式不正确");
|
|
353
359
|
}
|
|
354
360
|
let result = 0;
|
|
355
361
|
let resultType = "KB";
|
|
@@ -383,6 +389,52 @@ class PopsUtils {
|
|
|
383
389
|
AnyTouch = () => {
|
|
384
390
|
return AnyTouch;
|
|
385
391
|
};
|
|
392
|
+
/**
|
|
393
|
+
* 自动使用 Worker 执行 setTimeout
|
|
394
|
+
*/
|
|
395
|
+
setTimeout(callback: Function, timeout: number = 0) {
|
|
396
|
+
try {
|
|
397
|
+
return WorkerSetTimeout(callback, timeout);
|
|
398
|
+
} catch (error) {
|
|
399
|
+
return globalThis.setTimeout(callback, timeout);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* 配合 .setTimeout 使用
|
|
404
|
+
*/
|
|
405
|
+
clearTimeout(timeId: number | undefined) {
|
|
406
|
+
try {
|
|
407
|
+
if (timeId != null) {
|
|
408
|
+
WorkerClearTimeout(timeId);
|
|
409
|
+
}
|
|
410
|
+
} catch (error) {
|
|
411
|
+
} finally {
|
|
412
|
+
globalThis.clearTimeout(timeId);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* 自动使用 Worker 执行 setInterval
|
|
417
|
+
*/
|
|
418
|
+
setInterval(callback: Function, timeout: number = 0) {
|
|
419
|
+
try {
|
|
420
|
+
return WorkerSetInterval(callback, timeout);
|
|
421
|
+
} catch (error) {
|
|
422
|
+
return globalThis.setInterval(callback, timeout);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* 配合 .setInterval 使用
|
|
427
|
+
*/
|
|
428
|
+
clearInterval(timeId: number | undefined) {
|
|
429
|
+
try {
|
|
430
|
+
if (timeId != null) {
|
|
431
|
+
WorkerClearInterval(timeId);
|
|
432
|
+
}
|
|
433
|
+
} catch (error) {
|
|
434
|
+
} finally {
|
|
435
|
+
globalThis.clearInterval(timeId);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
386
438
|
}
|
|
387
439
|
|
|
388
440
|
const popsUtils = new PopsUtils();
|