@whitesev/pops 1.8.5 → 1.8.6

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.
@@ -13,6 +13,7 @@ import type { PopsPanelDetails } from "./components/panel/indexType";
13
13
  import type { PopsRightClickMenuDetails } from "./components/rightClickMenu/indexType";
14
14
  import type { PopsIcon } from "./types/icon";
15
15
  import type { PopsSearchSuggestionDetails, PopsSearchSuggestionResult } from "./components/searchSuggestion/indexType";
16
+ import { type PopsTooltipResult } from "./components/tooltip";
16
17
  declare class Pops {
17
18
  /** 配置 */
18
19
  config: {
@@ -219,7 +220,6 @@ declare class Pops {
219
220
  setAsideItemClickEvent(asideLiElement: HTMLElement, asideConfig: import("./components/panel/indexType").PopsPanelContentConfig): void;
220
221
  };
221
222
  };
222
- constructor();
223
223
  init(): void;
224
224
  /**
225
225
  * 释放原有的pops控制权
@@ -289,23 +289,7 @@ declare class Pops {
289
289
  * 提示框
290
290
  * @param details 配置
291
291
  */
292
- tooltip: (details: PopsToolTipDetails) => {
293
- guid: string;
294
- config: Required<PopsToolTipDetails>;
295
- toolTipNode: HTMLDivElement;
296
- show: () => void;
297
- close: () => void;
298
- } | {
299
- $shadowContainer: HTMLDivElement;
300
- $shadowRoot: ShadowRoot;
301
- guid: string;
302
- config: Required<PopsToolTipDetails>;
303
- toolTipNode: HTMLDivElement;
304
- show: () => void;
305
- close: () => void;
306
- off: () => void;
307
- on: () => void;
308
- };
292
+ tooltip: <T extends PopsToolTipDetails>(details: T) => PopsTooltipResult<T>;
309
293
  /**
310
294
  * 抽屉
311
295
  * @param details 配置
@@ -1,4 +1,148 @@
1
1
  import type { PopsToolTipDetails } from "./indexType";
2
+ export declare class ToolTip {
3
+ $el: {
4
+ $shadowContainer: HTMLDivElement;
5
+ $shadowRoot: ShadowRoot;
6
+ $toolTip: HTMLElement;
7
+ $content: HTMLElement;
8
+ $arrow: HTMLElement;
9
+ };
10
+ $data: {
11
+ config: Required<PopsToolTipDetails>;
12
+ guid: string;
13
+ timeId_show: number[];
14
+ timeId_close: number[];
15
+ };
16
+ constructor(config: Required<PopsToolTipDetails>, guid: string, ShadowInfo: {
17
+ $shadowContainer: HTMLDivElement;
18
+ $shadowRoot: ShadowRoot;
19
+ });
20
+ init(): void;
21
+ /**
22
+ * 创建提示元素
23
+ */
24
+ createToolTip(): {
25
+ $toolTipContainer: HTMLDivElement;
26
+ $toolTipArrow: HTMLElement;
27
+ $toolTipContent: HTMLElement;
28
+ };
29
+ /**
30
+ * 获取提示的内容
31
+ */
32
+ getContent(): string;
33
+ /**
34
+ * 修改提示的内容
35
+ * @param text
36
+ */
37
+ changeContent(text?: string): void;
38
+ /**
39
+ * 获取z-index
40
+ */
41
+ getZIndex(): number;
42
+ /**
43
+ * 动态修改z-index
44
+ */
45
+ changeZIndex(): void;
46
+ /**
47
+ * 获取 提示框的位置
48
+ * @param targetElement 目标元素
49
+ * @param arrowDistance 箭头和目标元素的距离
50
+ * @param otherDistance 其它位置的偏移
51
+ */
52
+ getPosition(targetElement: HTMLElement, arrowDistance: number, otherDistance: number): {
53
+ TOP: {
54
+ left: number;
55
+ top: number;
56
+ arrow: string;
57
+ motion: string;
58
+ };
59
+ RIGHT: {
60
+ left: number;
61
+ top: number;
62
+ arrow: string;
63
+ motion: string;
64
+ };
65
+ BOTTOM: {
66
+ left: number;
67
+ top: number;
68
+ arrow: string;
69
+ motion: string;
70
+ };
71
+ LEFT: {
72
+ left: number;
73
+ top: number;
74
+ arrow: string;
75
+ motion: string;
76
+ };
77
+ };
78
+ /**
79
+ * 动态修改tooltip的位置
80
+ */
81
+ changePosition(): void;
82
+ /**
83
+ * 事件绑定
84
+ */
85
+ onEvent(): void;
86
+ /**
87
+ * 取消事件绑定
88
+ */
89
+ offEvent(): void;
90
+ /**
91
+ * 显示提示框
92
+ */
93
+ show(): void;
94
+ /**
95
+ * 绑定 显示事件
96
+ */
97
+ onShowEvent(): void;
98
+ /**
99
+ * 取消绑定 显示事件
100
+ */
101
+ offShowEvent(): void;
102
+ /**
103
+ * 关闭提示框
104
+ */
105
+ close(...args: any[]): void;
106
+ /**
107
+ * 绑定 关闭事件
108
+ */
109
+ onCloseEvent(): void;
110
+ /**
111
+ * 取消绑定 关闭事件
112
+ */
113
+ offCloseEvent(): void;
114
+ /**
115
+ * 销毁元素
116
+ */
117
+ destory(): void;
118
+ /**
119
+ * 动画结束事件
120
+ */
121
+ animationFinishEvent(): void;
122
+ /**
123
+ * 监听动画结束
124
+ */
125
+ onAnimationFinishEvent(): void;
126
+ /**
127
+ * 取消监听动画结束
128
+ */
129
+ offAnimationFinishEvent(): void;
130
+ /**
131
+ * 当鼠标|手触摸
132
+ */
133
+ onMouseEnterEvent(): void;
134
+ /**
135
+ * 当鼠标|手离开,开始当前动画
136
+ */
137
+ onMouseLeaveEvent(): void;
138
+ }
139
+ export type PopsTooltipResult<T extends PopsToolTipDetails> = {
140
+ guid: string;
141
+ config: T;
142
+ $shadowContainer: HTMLDivElement;
143
+ $shadowRoot: ShadowRoot;
144
+ toolTip: typeof ToolTip.prototype;
145
+ };
2
146
  export declare class PopsTooltip {
3
147
  constructor(details: PopsToolTipDetails);
4
148
  }
@@ -25,9 +25,14 @@ export interface PopsToolTipDetails {
25
25
  * 是否总是显示,默认为false
26
26
  * + true 设置的triggerShowEventName、triggerCloseEventName将无效
27
27
  * 返回提供show和close函数,取消on和off
28
- * + false 返回提供on和off,取消close函数
28
+ * + false 不添加事件,只显示
29
29
  */
30
30
  alwaysShow?: boolean;
31
+ /**
32
+ * 延迟xxms关闭tooltip
33
+ * @default 100
34
+ */
35
+ delayCloseTime?: number;
31
36
  /**
32
37
  * 触发显示事件的名称,默认mouseenter touchstart,如果是多个事件,按空格分割
33
38
  */
@@ -50,22 +55,24 @@ export interface PopsToolTipDetails {
50
55
  eventOption?: AddEventListenerOptions;
51
56
  /**
52
57
  * 触发显示前的回调
53
- * 返回值为false可阻止显示
58
+ * @returns
59
+ * + false 可阻止显示
54
60
  */
55
- showBeforeCallBack?: () => boolean | void;
61
+ showBeforeCallBack?: ($toolTip: HTMLElement) => false | void;
56
62
  /**
57
63
  * 触发显示后的回调
58
64
  */
59
- showAfterCallBack?: (toolTipElement: HTMLElement) => void;
65
+ showAfterCallBack?: ($toolTip: HTMLElement) => void;
60
66
  /**
61
67
  * 触发关闭前的回调
62
- * 返回值为false可阻止关闭
68
+ * @returns
69
+ * + false 可阻止关闭
63
70
  */
64
- closeBeforeCallBack?: (toolTipElement: HTMLElement) => boolean | void;
71
+ closeBeforeCallBack?: ($toolTip: HTMLElement) => false | void;
65
72
  /**
66
73
  * 触发关闭后的回调
67
74
  */
68
- closeAfterCallBack?: (toolTipElement: HTMLElement) => void;
75
+ closeAfterCallBack?: ($toolTip: HTMLElement) => void;
69
76
  /**
70
77
  * 箭头与目标的的距离,默认12.5(px)
71
78
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/pops",
3
- "version": "1.8.5",
3
+ "version": "1.8.6",
4
4
  "description": "弹窗库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
package/src/Pops.ts CHANGED
@@ -59,7 +59,6 @@ import { PopsLoading } from "./components/loading";
59
59
  import type { PopsIframeDetails } from "./components/iframe/indexType";
60
60
  import { PopsIframe } from "./components/iframe";
61
61
  import type { PopsToolTipDetails } from "./components/tooltip/indexType";
62
- import { PopsTooltip } from "./components/tooltip";
63
62
  import { PopsDrawer } from "./components/drawer";
64
63
  import type { PopsDrawerDetails } from "./components/drawer/indexType";
65
64
  import type { PopsFolderDetails } from "./components/folder/indexType";
@@ -78,12 +77,13 @@ import { PopsSearchSuggestion } from "./components/searchSuggestion";
78
77
  import { PopsMathFloatUtils } from "./utils/PopsMathUtils";
79
78
  import { PanelHandleContentDetails } from "./components/panel/PanelHandleContentDetails";
80
79
  import { GlobalConfig } from "./GlobalConfig";
80
+ import { PopsTooltip, type PopsTooltipResult } from "./components/tooltip";
81
81
 
82
82
  class Pops {
83
83
  /** 配置 */
84
84
  config = {
85
85
  /** 版本号 */
86
- version: "2024.11.2",
86
+ version: "2024.11.3",
87
87
  cssText: {
88
88
  /** 主CSS */
89
89
  index: indexCSS,
@@ -189,7 +189,6 @@ class Pops {
189
189
  /** pops.panel中用于处理各个类型的工具 */
190
190
  panelHandleContentUtils: PanelHandleContentDetails,
191
191
  };
192
- constructor() {}
193
192
  init() {
194
193
  if (!this.config.isInit) {
195
194
  /* 处理获取当前所有的动画名 */
@@ -284,26 +283,9 @@ class Pops {
284
283
  * 提示框
285
284
  * @param details 配置
286
285
  */
287
- tooltip = (details: PopsToolTipDetails) => {
288
- return new PopsTooltip(details) as
289
- | {
290
- guid: string;
291
- config: Required<PopsToolTipDetails>;
292
- toolTipNode: HTMLDivElement;
293
- show: () => void;
294
- close: () => void;
295
- }
296
- | {
297
- $shadowContainer: HTMLDivElement;
298
- $shadowRoot: ShadowRoot;
299
- guid: string;
300
- config: Required<PopsToolTipDetails>;
301
- toolTipNode: HTMLDivElement;
302
- show: () => void;
303
- close: () => void;
304
- off: () => void;
305
- on: () => void;
306
- };
286
+ tooltip = <T extends PopsToolTipDetails>(details: T) => {
287
+ let popsTooltip = new PopsTooltip(details) as PopsTooltipResult<T>;
288
+ return popsTooltip;
307
289
  };
308
290
 
309
291
  /**
@@ -1,8 +1,10 @@
1
1
  import { pops } from "../../Pops";
2
2
  import { popsDOMUtils } from "../../utils/PopsDOMUtils";
3
+ import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
3
4
  import { PopsMathFloatUtils } from "../../utils/PopsMathUtils";
4
5
  import { popsUtils } from "../../utils/PopsUtils";
5
6
  import type { PopsAlertDetails } from "../alert/indexType";
7
+ import type { PopsTooltipResult } from "../tooltip";
6
8
  import type { PopsToolTipDetails } from "../tooltip/indexType";
7
9
  import type { PopsPanelButtonDetails } from "./buttonType";
8
10
  import type { PopsPanelRightAsideContainerOptions } from "./commonType";
@@ -393,13 +395,13 @@ export const PanelHandleContentDetails = () => {
393
395
  };
394
396
  let tooltip = pops.tooltip({
395
397
  target: rangeInputElement.parentElement!,
396
- content: getToolTipContent(rangeInputElement.value),
397
- zIndex: 1000000,
398
- className: "github-tooltip",
399
- showBeforeCallBack() {
400
- tooltip.toolTipNode.querySelector("div")!.innerText =
401
- getToolTipContent(rangeInputElement.value);
398
+ content: () => {
399
+ return getToolTipContent(rangeInputElement.value);
400
+ },
401
+ zIndex: () => {
402
+ return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
402
403
  },
404
+ className: "github-tooltip",
403
405
  alwaysShow: false,
404
406
  only: false,
405
407
  position: "top",
@@ -410,8 +412,9 @@ export const PanelHandleContentDetails = () => {
410
412
  ["input", "propertychange"],
411
413
  void 0,
412
414
  function (event) {
413
- tooltip.toolTipNode.querySelector("div")!.innerText =
414
- getToolTipContent(rangeInputElement.value);
415
+ tooltip.toolTip.changeContent(
416
+ getToolTipContent(rangeInputElement.value)
417
+ );
415
418
  if (typeof formConfig.callback === "function") {
416
419
  formConfig.callback(
417
420
  event as InputEvent,
@@ -520,6 +523,7 @@ export const PanelHandleContentDetails = () => {
520
523
  percent: number;
521
524
  }
522
525
  >(),
526
+ tooltip: null as any as PopsTooltipResult<PopsToolTipDetails>,
523
527
  },
524
528
  $ele: {
525
529
  slider: liElement.querySelector<HTMLDivElement>(".pops-slider")!,
@@ -533,17 +537,6 @@ export const PanelHandleContentDetails = () => {
533
537
  button: liElement.querySelector<HTMLDivElement>(
534
538
  ".pops-slider__button"
535
539
  )!,
536
- tooltip: null as any as {
537
- $shadowContainer: HTMLDivElement;
538
- $shadowRoot: ShadowRoot;
539
- guid: string;
540
- config: Required<PopsToolTipDetails>;
541
- toolTipNode: HTMLDivElement;
542
- show: () => void;
543
- close: () => void;
544
- off: () => void;
545
- on: () => void;
546
- },
547
540
  },
548
541
  $interval: {
549
542
  isCheck: false,
@@ -938,13 +931,13 @@ export const PanelHandleContentDetails = () => {
938
931
  * 显示悬浮的
939
932
  */
940
933
  showToolTip() {
941
- this.$ele.tooltip.show();
934
+ this.$data.tooltip.toolTip.show();
942
935
  },
943
936
  /**
944
937
  * 关闭悬浮的
945
938
  */
946
939
  closeToolTip() {
947
- this.$ele.tooltip.close();
940
+ this.$data.tooltip.toolTip.close();
948
941
  },
949
942
  /**
950
943
  * 检测在1000ms内,是否停止了拖拽
@@ -980,12 +973,13 @@ export const PanelHandleContentDetails = () => {
980
973
  return PopsPanelSlider.value as any as string;
981
974
  }
982
975
  }
983
- let tooltipContent = null as any as HTMLElement;
984
976
 
985
- this.$ele.tooltip = pops.tooltip({
977
+ let tooltip = pops.tooltip({
986
978
  target: this.$ele.button,
987
979
  content: getToolTipContent,
988
- zIndex: 1000000,
980
+ zIndex: () => {
981
+ return PopsInstanceUtils.getPopsMaxZIndex().zIndex;
982
+ },
989
983
  className: "github-tooltip",
990
984
  only: false,
991
985
  eventOption: {
@@ -996,7 +990,7 @@ export const PanelHandleContentDetails = () => {
996
990
  this.intervalInit();
997
991
  },
998
992
  showAfterCallBack: (toolTipNode) => {
999
- tooltipContent.innerText = getToolTipContent();
993
+ tooltip.toolTip.changeContent(getToolTipContent());
1000
994
  },
1001
995
  closeBeforeCallBack: () => {
1002
996
  if (this.$data.isMove) {
@@ -1009,9 +1003,8 @@ export const PanelHandleContentDetails = () => {
1009
1003
  // only: false,
1010
1004
  position: "top",
1011
1005
  arrowDistance: 10,
1012
- }) as any;
1013
- tooltipContent =
1014
- this.$ele.tooltip.toolTipNode.querySelector<HTMLDivElement>("div")!;
1006
+ });
1007
+ this.$data.tooltip = tooltip;
1015
1008
  },
1016
1009
  };
1017
1010
  PopsPanelSlider.init();