@whitesev/pops 2.0.7 → 2.0.8
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 +380 -55
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +380 -55
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +380 -55
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +380 -55
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +380 -55
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +380 -55
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +549 -199
- package/dist/types/src/components/rightClickMenu/index.d.ts +545 -199
- package/dist/types/src/components/tooltip/index.d.ts +9 -2
- package/dist/types/src/components/tooltip/indexType.d.ts +6 -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/index.ts +56 -16
- package/src/components/tooltip/indexType.ts +11 -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
|
*/
|
|
@@ -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
|
*/
|
|
@@ -15,18 +15,19 @@ export interface PopsToolTipDetails extends Pick<PopsCommonConfig, "useShadowRoo
|
|
|
15
15
|
content: string | (() => string);
|
|
16
16
|
/**
|
|
17
17
|
* 位置
|
|
18
|
+
* + `follow` 跟随鼠标|触摸位置移动
|
|
18
19
|
* @default "top"
|
|
19
20
|
*/
|
|
20
21
|
position?: PopsTooltipPosition;
|
|
21
22
|
/**
|
|
22
23
|
* 自定义className
|
|
23
24
|
*
|
|
24
|
-
* + github-tooltip github的样式
|
|
25
|
+
* + `github-tooltip` github的样式
|
|
25
26
|
* @default ""
|
|
26
27
|
*/
|
|
27
28
|
className?: string;
|
|
28
29
|
/**
|
|
29
|
-
* 是否使用fixed
|
|
30
|
+
* 是否使用fixed定位,false则是absolute定位
|
|
30
31
|
*
|
|
31
32
|
* @default false
|
|
32
33
|
*/
|
|
@@ -35,7 +36,7 @@ export interface PopsToolTipDetails extends Pick<PopsCommonConfig, "useShadowRoo
|
|
|
35
36
|
* 是否总是显示,默认为false
|
|
36
37
|
* + true 设置的triggerShowEventName、triggerCloseEventName将无效
|
|
37
38
|
* 返回提供show和close函数,取消on和off
|
|
38
|
-
* + false
|
|
39
|
+
* + false 事件触发才显示
|
|
39
40
|
*/
|
|
40
41
|
alwaysShow?: boolean;
|
|
41
42
|
/**
|
|
@@ -98,6 +99,7 @@ export interface PopsToolTipDetails extends Pick<PopsCommonConfig, "useShadowRoo
|
|
|
98
99
|
* 其它的距离(px)
|
|
99
100
|
* + 当position为left或者right,这个距离是上、下距离
|
|
100
101
|
* + 当position为top或者bottom,这个距离是左、右距离
|
|
102
|
+
* + 当position为follow,这个距离是上、左距离
|
|
101
103
|
* @default 0
|
|
102
104
|
*/
|
|
103
105
|
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.8",
|
|
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
|
/**
|
|
@@ -146,6 +146,7 @@ export class ToolTip {
|
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
148
|
* 计算 提示框的位置
|
|
149
|
+
* @param event 触发的事件
|
|
149
150
|
* @param targetElement 目标元素
|
|
150
151
|
* @param arrowDistance 箭头和目标元素的距离
|
|
151
152
|
* @param otherDistance 其它位置的偏移
|
|
@@ -153,7 +154,8 @@ export class ToolTip {
|
|
|
153
154
|
calcToolTipPosition(
|
|
154
155
|
targetElement: HTMLElement,
|
|
155
156
|
arrowDistance: number,
|
|
156
|
-
otherDistance: number
|
|
157
|
+
otherDistance: number,
|
|
158
|
+
event?: MouseEvent | TouchEvent | PointerEvent
|
|
157
159
|
) {
|
|
158
160
|
let offsetInfo = popsDOMUtils.offset(
|
|
159
161
|
targetElement,
|
|
@@ -180,6 +182,30 @@ export class ToolTip {
|
|
|
180
182
|
/* 目标元素的Y轴的中间位置 */
|
|
181
183
|
let targetElement_Y_center_pos =
|
|
182
184
|
targetElement_top + targetElement_height / 2 - toolTipElement_height / 2;
|
|
185
|
+
|
|
186
|
+
let mouseX = 0;
|
|
187
|
+
let mouseY = 0;
|
|
188
|
+
if (event != null) {
|
|
189
|
+
if (event instanceof MouseEvent || event instanceof PointerEvent) {
|
|
190
|
+
mouseX = event.pageX;
|
|
191
|
+
mouseY = event.y;
|
|
192
|
+
} else if (event instanceof TouchEvent) {
|
|
193
|
+
let touchEvent = event.touches[0];
|
|
194
|
+
mouseX = touchEvent.pageX;
|
|
195
|
+
mouseY = touchEvent.pageY;
|
|
196
|
+
} else {
|
|
197
|
+
// @ts-ignore
|
|
198
|
+
if (typeof event.clientX === "number") {
|
|
199
|
+
// @ts-ignore
|
|
200
|
+
mouseX = event.clientX;
|
|
201
|
+
}
|
|
202
|
+
// @ts-ignore
|
|
203
|
+
if (typeof event.clientY === "number") {
|
|
204
|
+
// @ts-ignore
|
|
205
|
+
mouseY = event.clientY;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
183
209
|
return {
|
|
184
210
|
TOP: {
|
|
185
211
|
left: targetElement_X_center_pos - otherDistance,
|
|
@@ -205,19 +231,26 @@ export class ToolTip {
|
|
|
205
231
|
arrow: "right",
|
|
206
232
|
motion: "fadeInLeft",
|
|
207
233
|
},
|
|
234
|
+
FOLLOW: {
|
|
235
|
+
left: mouseX + otherDistance,
|
|
236
|
+
top: mouseY + otherDistance,
|
|
237
|
+
arrow: "follow",
|
|
238
|
+
motion: "",
|
|
239
|
+
},
|
|
208
240
|
};
|
|
209
241
|
}
|
|
210
242
|
/**
|
|
211
243
|
* 动态修改tooltip的位置
|
|
212
244
|
*/
|
|
213
|
-
changePosition() {
|
|
245
|
+
changePosition(event?: MouseEvent | TouchEvent | PointerEvent) {
|
|
214
246
|
let positionInfo = this.calcToolTipPosition(
|
|
215
247
|
this.$data.config.target,
|
|
216
248
|
this.$data.config.arrowDistance,
|
|
217
|
-
this.$data.config.otherDistance
|
|
249
|
+
this.$data.config.otherDistance,
|
|
250
|
+
event
|
|
218
251
|
);
|
|
219
|
-
let positionKey =
|
|
220
|
-
|
|
252
|
+
let positionKey = this.$data.config.position.toUpperCase() as any as
|
|
253
|
+
| keyof typeof positionInfo;
|
|
221
254
|
let positionDetail = positionInfo[positionKey];
|
|
222
255
|
if (positionDetail) {
|
|
223
256
|
this.$el.$toolTip.style.left = positionDetail.left + "px";
|
|
@@ -276,12 +309,12 @@ export class ToolTip {
|
|
|
276
309
|
if (typeof timeId === "number") {
|
|
277
310
|
// 只清除一个
|
|
278
311
|
if (timeId == currentTimeId) {
|
|
279
|
-
clearTimeout(timeId);
|
|
312
|
+
popsUtils.clearTimeout(timeId);
|
|
280
313
|
timeIdList.splice(index, 1);
|
|
281
314
|
break;
|
|
282
315
|
}
|
|
283
316
|
} else {
|
|
284
|
-
clearTimeout(currentTimeId);
|
|
317
|
+
popsUtils.clearTimeout(currentTimeId);
|
|
285
318
|
timeIdList.splice(index, 1);
|
|
286
319
|
index--;
|
|
287
320
|
}
|
|
@@ -322,7 +355,7 @@ export class ToolTip {
|
|
|
322
355
|
// 更新内容
|
|
323
356
|
this.changeContent();
|
|
324
357
|
// 更新tip的位置
|
|
325
|
-
this.changePosition();
|
|
358
|
+
this.changePosition(event);
|
|
326
359
|
if (typeof this.$data.config.showAfterCallBack === "function") {
|
|
327
360
|
this.$data.config.showAfterCallBack(this.$el.$toolTip);
|
|
328
361
|
}
|
|
@@ -380,19 +413,26 @@ export class ToolTip {
|
|
|
380
413
|
) {
|
|
381
414
|
this.$data.config.delayCloseTime = 100;
|
|
382
415
|
}
|
|
383
|
-
let timeId = setTimeout(() => {
|
|
416
|
+
let timeId = popsUtils.setTimeout(() => {
|
|
384
417
|
// 设置属性触发关闭动画
|
|
385
418
|
this.clearCloseTimeoutId(eventType, timeId);
|
|
386
419
|
if (this.$el.$toolTip == null) {
|
|
387
420
|
// 已清除了
|
|
388
421
|
return;
|
|
389
422
|
}
|
|
390
|
-
this.$el.$toolTip.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
423
|
+
let motion = this.$el.$toolTip.getAttribute("data-motion");
|
|
424
|
+
if (motion == null || motion.trim() === "") {
|
|
425
|
+
// 没有动画
|
|
426
|
+
this.toolTipAnimationFinishEvent();
|
|
427
|
+
} else {
|
|
428
|
+
// 修改data-motion触发动画关闭
|
|
429
|
+
this.$el.$toolTip.setAttribute(
|
|
430
|
+
"data-motion",
|
|
431
|
+
this.$el.$toolTip
|
|
432
|
+
.getAttribute("data-motion")!
|
|
433
|
+
.replace("fadeIn", "fadeOut")
|
|
434
|
+
);
|
|
435
|
+
}
|
|
396
436
|
}, this.$data.config.delayCloseTime);
|
|
397
437
|
this.addCloseTimeoutId(eventType, timeId);
|
|
398
438
|
if (typeof this.$data.config.closeAfterCallBack === "function") {
|
|
@@ -554,7 +594,7 @@ export const PopsTooltip = {
|
|
|
554
594
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
555
595
|
config = popsUtils.assign(config, details);
|
|
556
596
|
if (!(config.target instanceof HTMLElement)) {
|
|
557
|
-
throw "config.target 必须是HTMLElement类型";
|
|
597
|
+
throw new TypeError("config.target 必须是HTMLElement类型");
|
|
558
598
|
}
|
|
559
599
|
config = PopsHandler.handleOnly(PopsType, config);
|
|
560
600
|
|
|
@@ -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
|
|
@@ -21,18 +26,19 @@ export interface PopsToolTipDetails
|
|
|
21
26
|
content: string | (() => string);
|
|
22
27
|
/**
|
|
23
28
|
* 位置
|
|
29
|
+
* + `follow` 跟随鼠标|触摸位置移动
|
|
24
30
|
* @default "top"
|
|
25
31
|
*/
|
|
26
32
|
position?: PopsTooltipPosition;
|
|
27
33
|
/**
|
|
28
34
|
* 自定义className
|
|
29
35
|
*
|
|
30
|
-
* + github-tooltip github的样式
|
|
36
|
+
* + `github-tooltip` github的样式
|
|
31
37
|
* @default ""
|
|
32
38
|
*/
|
|
33
39
|
className?: string;
|
|
34
40
|
/**
|
|
35
|
-
* 是否使用fixed
|
|
41
|
+
* 是否使用fixed定位,false则是absolute定位
|
|
36
42
|
*
|
|
37
43
|
* @default false
|
|
38
44
|
*/
|
|
@@ -41,7 +47,7 @@ export interface PopsToolTipDetails
|
|
|
41
47
|
* 是否总是显示,默认为false
|
|
42
48
|
* + true 设置的triggerShowEventName、triggerCloseEventName将无效
|
|
43
49
|
* 返回提供show和close函数,取消on和off
|
|
44
|
-
* + false
|
|
50
|
+
* + false 事件触发才显示
|
|
45
51
|
*/
|
|
46
52
|
alwaysShow?: boolean;
|
|
47
53
|
/**
|
|
@@ -105,6 +111,7 @@ export interface PopsToolTipDetails
|
|
|
105
111
|
* 其它的距离(px)
|
|
106
112
|
* + 当position为left或者right,这个距离是上、下距离
|
|
107
113
|
* + 当position为top或者bottom,这个距离是左、右距离
|
|
114
|
+
* + 当position为follow,这个距离是上、左距离
|
|
108
115
|
* @default 0
|
|
109
116
|
*/
|
|
110
117
|
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();
|