zero-tooltip 1.3.0 → 1.3.1
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/zero-tooltip.js +15 -15
- package/dist/zero-tooltip.umd.cjs +1 -1
- package/package.json +3 -2
- package/src/tooltip.ts +3 -4
package/dist/zero-tooltip.js
CHANGED
|
@@ -81,32 +81,32 @@ const { handleHideOnScroll: et } = g(), { handleHideOnResize: rt, resetResizeRef
|
|
|
81
81
|
created: (t, r, s) => {
|
|
82
82
|
const o = C();
|
|
83
83
|
s.el.$_tooltip = { uuid: o }, x(r.value, e, r.arg, t, o), typeof r.value != "string" && J(r.value) && K(r.value, (i) => {
|
|
84
|
-
h[o] &&
|
|
84
|
+
h[o] && F(h[o]), x(i, e, r.arg, t, o);
|
|
85
85
|
});
|
|
86
86
|
},
|
|
87
87
|
updated: (t, r, s) => {
|
|
88
88
|
const o = s.el.$_tooltip.uuid;
|
|
89
|
-
h[o] &&
|
|
89
|
+
h[o] && F(h[o]), x(r.value, e, r.arg, t, o);
|
|
90
90
|
},
|
|
91
91
|
beforeUnmount: (t, r, s) => {
|
|
92
92
|
const o = s.el.$_tooltip.uuid;
|
|
93
|
-
h[o] &&
|
|
93
|
+
h[o] && F(h[o]);
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
96
|
function x(e, t, r, s, o) {
|
|
97
97
|
let i = xt(e, t, r);
|
|
98
|
-
const d =
|
|
98
|
+
const d = yt(s, i, o);
|
|
99
99
|
h[o] = d, s.matches(":hover") && s.dispatchEvent(new Event("mouseenter"));
|
|
100
100
|
}
|
|
101
101
|
function xt(e, t, r) {
|
|
102
102
|
var L, H, I, A, D, E, $, _;
|
|
103
|
-
let s = (t == null ? void 0 : t.appendTo) ?? ot, o =
|
|
103
|
+
let s = (t == null ? void 0 : t.appendTo) ?? ot, o = Ft(e), i = r ?? (t == null ? void 0 : t.defaultPosition) ?? it, d = {
|
|
104
104
|
left: ((L = t == null ? void 0 : t.positions) == null ? void 0 : L.left) ?? T.left,
|
|
105
105
|
top: ((H = t == null ? void 0 : t.positions) == null ? void 0 : H.top) ?? T.top,
|
|
106
106
|
right: ((I = t == null ? void 0 : t.positions) == null ? void 0 : I.right) ?? T.right,
|
|
107
107
|
bottom: ((A = t == null ? void 0 : t.positions) == null ? void 0 : A.bottom) ?? T.bottom
|
|
108
|
-
}, n = (t == null ? void 0 : t.offsetFromSource) ?? dt, p = (t == null ? void 0 : t.offsetFromViewport) ?? nt, u = (t == null ? void 0 : t.minWidth) ?? pt, m = (t == null ? void 0 : t.maxWidth) ?? ht, a = (t == null ? void 0 : t.tooltipBorderWidth) ?? wt, c = O + " " + k + " " + ((t == null ? void 0 : t.tooltipClasses) ?? ""),
|
|
109
|
-
return typeof e != "string" && (e.appendTo !== void 0 && (s = e.appendTo), r === void 0 && e.defaultPosition !== void 0 && (i = e.defaultPosition), ((D = e.positions) == null ? void 0 : D.left) !== void 0 && (d.left = e.positions.left), ((E = e.positions) == null ? void 0 : E.top) !== void 0 && (d.top = e.positions.top), (($ = e.positions) == null ? void 0 : $.right) !== void 0 && (d.right = e.positions.right), ((_ = e.positions) == null ? void 0 : _.bottom) !== void 0 && (d.bottom = e.positions.bottom), e.offsetFromSource !== void 0 && (n = e.offsetFromSource), e.offsetFromViewport !== void 0 && (p = e.offsetFromViewport), e.minWidth !== void 0 && (u = e.minWidth), e.maxWidth !== void 0 && (m = e.maxWidth), e.tooltipBorderWidth !== void 0 && (a = e.tooltipBorderWidth), e.tooltipClasses !== void 0 && (c = O + " " + k + " " + e.tooltipClasses), e.textClasses !== void 0 && (
|
|
108
|
+
}, n = (t == null ? void 0 : t.offsetFromSource) ?? dt, p = (t == null ? void 0 : t.offsetFromViewport) ?? nt, u = (t == null ? void 0 : t.minWidth) ?? pt, m = (t == null ? void 0 : t.maxWidth) ?? ht, a = (t == null ? void 0 : t.tooltipBorderWidth) ?? wt, c = O + " " + k + " " + ((t == null ? void 0 : t.tooltipClasses) ?? ""), y = P + " " + j + " " + ((t == null ? void 0 : t.textClasses) ?? ""), f = (t == null ? void 0 : t.arrowSize) ?? ut, M = (t == null ? void 0 : t.arrowClasses) ?? "", z = (t == null ? void 0 : t.arrowMinOffsetFromTooltipCorner) ?? at, W = (t == null ? void 0 : t.zIndex) ?? ct, S = vt, V = (t == null ? void 0 : t.showDelay) ?? Tt, B = (t == null ? void 0 : t.hideDelay) ?? Ot;
|
|
109
|
+
return typeof e != "string" && (e.appendTo !== void 0 && (s = e.appendTo), r === void 0 && e.defaultPosition !== void 0 && (i = e.defaultPosition), ((D = e.positions) == null ? void 0 : D.left) !== void 0 && (d.left = e.positions.left), ((E = e.positions) == null ? void 0 : E.top) !== void 0 && (d.top = e.positions.top), (($ = e.positions) == null ? void 0 : $.right) !== void 0 && (d.right = e.positions.right), ((_ = e.positions) == null ? void 0 : _.bottom) !== void 0 && (d.bottom = e.positions.bottom), e.offsetFromSource !== void 0 && (n = e.offsetFromSource), e.offsetFromViewport !== void 0 && (p = e.offsetFromViewport), e.minWidth !== void 0 && (u = e.minWidth), e.maxWidth !== void 0 && (m = e.maxWidth), e.tooltipBorderWidth !== void 0 && (a = e.tooltipBorderWidth), e.tooltipClasses !== void 0 && (c = O + " " + k + " " + e.tooltipClasses), e.textClasses !== void 0 && (y = P + " " + j + " " + e.textClasses), e.arrowSize !== void 0 && (f = e.arrowSize), e.arrowClasses !== void 0 && (M = e.arrowClasses), e.arrowMinOffsetFromTooltipCorner !== void 0 && (z = e.arrowMinOffsetFromTooltipCorner), e.zIndex !== void 0 && (W = e.zIndex), e.show !== void 0 && (S = e.show), e.showDelay !== void 0 && (V = e.showDelay), e.hideDelay !== void 0 && (B = e.hideDelay)), {
|
|
110
110
|
appendTo: s,
|
|
111
111
|
tooltipText: o,
|
|
112
112
|
tooltipPosition: i,
|
|
@@ -117,7 +117,7 @@ function xt(e, t, r) {
|
|
|
117
117
|
tooltipMaxWidth: m,
|
|
118
118
|
tooltipBorderWidth: a,
|
|
119
119
|
tooltipClasses: c,
|
|
120
|
-
textClasses:
|
|
120
|
+
textClasses: y,
|
|
121
121
|
arrowSize: f,
|
|
122
122
|
arrowClasses: M,
|
|
123
123
|
arrowMinOffsetFromTooltipCorner: z,
|
|
@@ -127,19 +127,19 @@ function xt(e, t, r) {
|
|
|
127
127
|
hideDelay: B
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function Ft(e) {
|
|
131
131
|
const t = typeof e == "string" ? e : e.content;
|
|
132
132
|
if (!t)
|
|
133
133
|
throw new Error("Please enter valid tooltip value");
|
|
134
134
|
return t;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function yt(e, t, r) {
|
|
137
137
|
let s = e, o = ft(t.textClasses, t.tooltipText), i = Mt(t.tooltipClasses, t.tooltipBorderWidth);
|
|
138
138
|
i.append(o), i.dataset.uuid = r;
|
|
139
139
|
const d = {
|
|
140
140
|
currentInstanceId: Date.now(),
|
|
141
141
|
isHoveringOverAnchorElement: !1,
|
|
142
|
-
lastTooltipMouseLeaveTimestamp:
|
|
142
|
+
lastTooltipMouseLeaveTimestamp: 0
|
|
143
143
|
}, n = {
|
|
144
144
|
anchorElementMouseEnter: new AbortController(),
|
|
145
145
|
anchorElementMouseLeave: new AbortController(),
|
|
@@ -169,7 +169,7 @@ async function q(e, t, r, s, o) {
|
|
|
169
169
|
const d = 100;
|
|
170
170
|
!(o != null && o.isTooltip) && Date.now() - h[s].mouseEventState.lastTooltipMouseLeaveTimestamp <= d && (i = 0);
|
|
171
171
|
const n = Date.now();
|
|
172
|
-
if (h[s].mouseEventState.currentInstanceId = n, h[s].mouseEventState.isHoveringOverAnchorElement = !0, i > 0 && (await new Promise((c) => setTimeout(c,
|
|
172
|
+
if (h[s].mouseEventState.currentInstanceId = n, h[s].mouseEventState.isHoveringOverAnchorElement = !0, i > 0 && (await new Promise((c) => setTimeout(c, i)), !h[s].mouseEventState.isHoveringOverAnchorElement || h[s].mouseEventState.currentInstanceId !== n))
|
|
173
173
|
return;
|
|
174
174
|
const p = e.getBoundingClientRect(), u = document.querySelector(t.appendTo);
|
|
175
175
|
u == null || u.appendChild(r);
|
|
@@ -180,8 +180,8 @@ async function q(e, t, r, s, o) {
|
|
|
180
180
|
}
|
|
181
181
|
async function R(e, t, r) {
|
|
182
182
|
r != null && r.isTooltip && (h[t].mouseEventState.lastTooltipMouseLeaveTimestamp = Date.now());
|
|
183
|
-
const s =
|
|
184
|
-
h[t].mouseEventState.currentInstanceId =
|
|
183
|
+
const s = Date.now();
|
|
184
|
+
h[t].mouseEventState.currentInstanceId = s, h[t].mouseEventState.isHoveringOverAnchorElement = !1, !(e.hideDelay > 0 && (await new Promise((o) => setTimeout(o, e.hideDelay)), h[t].mouseEventState.isHoveringOverAnchorElement || h[t].mouseEventState.currentInstanceId !== s)) && l(t);
|
|
185
185
|
}
|
|
186
186
|
function zt(e, t, r) {
|
|
187
187
|
const s = Math.min(e.left - t.tooltipOffsetFromSource - t.tooltipOffsetFromViewport, t.tooltipMaxWidth), o = e.top >= t.tooltipOffsetFromViewport, i = window.innerHeight - e.bottom >= t.tooltipOffsetFromViewport;
|
|
@@ -272,7 +272,7 @@ function l(e) {
|
|
|
272
272
|
const t = document.querySelector(`.${O}`), r = (s = h[e]) == null ? void 0 : s.tooltipElement;
|
|
273
273
|
r && t && t instanceof HTMLElement && t === r && (st(), (o = t.querySelector(`.${G}`)) == null || o.remove(), t.style.left = "0", t.style.top = "0", t.remove());
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function F(e) {
|
|
276
276
|
const t = e.tooltipElement.dataset.uuid;
|
|
277
277
|
t && (l(t), delete h[t]);
|
|
278
278
|
for (const r of Object.values(e.mouseEnterEventControllers))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(v,T){typeof exports=="object"&&typeof module<"u"?module.exports=T(require("vue")):typeof define=="function"&&define.amd?define(["vue"],T):(v=typeof globalThis<"u"?globalThis:v||self,v.ZeroTooltip=T(v.Vue))})(this,function(v){"use strict";const T="";let O;const Q=new Uint8Array(16);function X(){if(!O&&(O=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!O))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return O(Q)}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Y(t,e=0){return h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]}const M={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function b(t,e,r){if(M.randomUUID&&!e&&!t)return M.randomUUID();t=t||{};const s=t.random||(t.rng||X)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=s[o];return e}return Y(s)}function C(){let t=[];const e=(o,i)=>{if(r(o),t.length>0)for(const d of t)d.addEventListener("scroll",i);window.addEventListener("scroll",()=>{i(),s(i)})},r=o=>{let i=o;for(;i!==null&&i.tagName!=="HTML";){if(i.scrollHeight!==i.clientHeight){const d=window.getComputedStyle(i);(d.overflow==="auto"||d.overflow==="scroll")&&t.push(i)}i=i.parentElement}},s=o=>{if(t.length>0){for(const i of t)i.removeEventListener("scroll",o);t=[]}window.removeEventListener("scroll",o)};return{handleHideOnScroll:e}}function g(){let t=null,e=null;return{handleHideOnResize:(o,i)=>{t=new ResizeObserver(d=>{const n=d[0].target;if(e===null)e=o.getBoundingClientRect();else{const p=n.getBoundingClientRect();(p.left!==e.left||p.top!==e.top||p.width!==e.width||p.height!==e.height)&&i()}}),t.observe(o)},resetResizeReferences:()=>{t!==null&&t.disconnect(),t=null,e=null}}}const{handleHideOnScroll:ee}=C(),{handleHideOnResize:te,resetResizeReferences:re}=g(),l="zero-tooltip__container",z="zero-tooltip__text",W="zero-tooltip__arrow",x={left:["left","right","top","bottom"],top:["top","bottom","right","left"],right:["right","left","top","bottom"],bottom:["bottom","top","right","left"]},se="body",oe="top",ie=10,de=20,ne=100,pe=250,ue=0,S="zt-fixed zt-opacity-0 zt-inline-block zt-w-fit zt-py-1.5 zt-px-2.5 zt-rounded-md zt-bg-[#495057] zt-shadow-[0_2px_12px_0_rgba(0,0,0,0.1)] zt-box-border",V="zt-text-sm zt-text-white zt-whitespace-pre-wrap zt-break-words",he=5,we="zt-absolute zt-border-solid zt-border-[#495057]",me=6,ae=1,ce=!0,ve=0,Te=0,u={},Oe=t=>({created:(e,r,s)=>{const o=b();s.el.$_tooltip={uuid:o},f(r.value,t,r.arg,e,o),typeof r.value!="string"&&v.isReactive(r.value)&&v.watch(r.value,i=>{u[o]&&F(u[o]),f(i,t,r.arg,e,o)})},updated:(e,r,s)=>{const o=s.el.$_tooltip.uuid;u[o]&&F(u[o]),f(r.value,t,r.arg,e,o)},beforeUnmount:(e,r,s)=>{const o=s.el.$_tooltip.uuid;u[o]&&F(u[o])}});function f(t,e,r,s,o){let i=le(t,e,r);const d=ye(s,i,o);u[o]=d,s.matches(":hover")&&s.dispatchEvent(new Event("mouseenter"))}function le(t,e,r){var j,q,R,Z,N,G,J,K;let s=(e==null?void 0:e.appendTo)??se,o=xe(t),i=r??(e==null?void 0:e.defaultPosition)??oe,d={left:((j=e==null?void 0:e.positions)==null?void 0:j.left)??x.left,top:((q=e==null?void 0:e.positions)==null?void 0:q.top)??x.top,right:((R=e==null?void 0:e.positions)==null?void 0:R.right)??x.right,bottom:((Z=e==null?void 0:e.positions)==null?void 0:Z.bottom)??x.bottom},n=(e==null?void 0:e.offsetFromSource)??ie,p=(e==null?void 0:e.offsetFromViewport)??de,w=(e==null?void 0:e.minWidth)??ne,m=(e==null?void 0:e.maxWidth)??pe,a=(e==null?void 0:e.tooltipBorderWidth)??ue,c=l+" "+S+" "+((e==null?void 0:e.tooltipClasses)??""),D=z+" "+V+" "+((e==null?void 0:e.textClasses)??""),A=(e==null?void 0:e.arrowSize)??he,E=(e==null?void 0:e.arrowClasses)??"",$=(e==null?void 0:e.arrowMinOffsetFromTooltipCorner)??me,_=(e==null?void 0:e.zIndex)??ae,U=ce,P=(e==null?void 0:e.showDelay)??ve,k=(e==null?void 0:e.hideDelay)??Te;return typeof t!="string"&&(t.appendTo!==void 0&&(s=t.appendTo),r===void 0&&t.defaultPosition!==void 0&&(i=t.defaultPosition),((N=t.positions)==null?void 0:N.left)!==void 0&&(d.left=t.positions.left),((G=t.positions)==null?void 0:G.top)!==void 0&&(d.top=t.positions.top),((J=t.positions)==null?void 0:J.right)!==void 0&&(d.right=t.positions.right),((K=t.positions)==null?void 0:K.bottom)!==void 0&&(d.bottom=t.positions.bottom),t.offsetFromSource!==void 0&&(n=t.offsetFromSource),t.offsetFromViewport!==void 0&&(p=t.offsetFromViewport),t.minWidth!==void 0&&(w=t.minWidth),t.maxWidth!==void 0&&(m=t.maxWidth),t.tooltipBorderWidth!==void 0&&(a=t.tooltipBorderWidth),t.tooltipClasses!==void 0&&(c=l+" "+S+" "+t.tooltipClasses),t.textClasses!==void 0&&(D=z+" "+V+" "+t.textClasses),t.arrowSize!==void 0&&(A=t.arrowSize),t.arrowClasses!==void 0&&(E=t.arrowClasses),t.arrowMinOffsetFromTooltipCorner!==void 0&&($=t.arrowMinOffsetFromTooltipCorner),t.zIndex!==void 0&&(_=t.zIndex),t.show!==void 0&&(U=t.show),t.showDelay!==void 0&&(P=t.showDelay),t.hideDelay!==void 0&&(k=t.hideDelay)),{appendTo:s,tooltipText:o,tooltipPosition:i,tooltipPositions:d,tooltipOffsetFromSource:n,tooltipOffsetFromViewport:p,tooltipMinWidth:w,tooltipMaxWidth:m,tooltipBorderWidth:a,tooltipClasses:c,textClasses:D,arrowSize:A,arrowClasses:E,arrowMinOffsetFromTooltipCorner:$,zIndex:_,shouldShow:U,showDelay:P,hideDelay:k}}function xe(t){const e=typeof t=="string"?t:t.content;if(!e)throw new Error("Please enter valid tooltip value");return e}function ye(t,e,r){let s=t,o=fe(e.textClasses,e.tooltipText),i=Fe(e.tooltipClasses,e.tooltipBorderWidth);i.append(o),i.dataset.uuid=r;const d={currentInstanceId:Date.now(),isHoveringOverAnchorElement:!1,lastTooltipMouseLeaveTimestamp:Date.now()},n={anchorElementMouseEnter:new AbortController,anchorElementMouseLeave:new AbortController,tooltipElementMouseEnter:new AbortController,tooltipElementMouseLeave:new AbortController};return s.addEventListener("mouseenter",()=>B(s,e,i,r),{signal:n.anchorElementMouseEnter.signal}),s.addEventListener("mouseleave",()=>L(e,r),{signal:n.anchorElementMouseLeave.signal}),i.addEventListener("mouseenter",()=>B(s,e,i,r,{isTooltip:!0}),{signal:n.tooltipElementMouseEnter.signal}),i.addEventListener("mouseleave",()=>L(e,r,{isTooltip:!0}),{signal:n.tooltipElementMouseLeave.signal}),{anchorElement:s,tooltipConfig:e,tooltipElement:i,mouseEnterEventControllers:n,mouseEventState:d}}function fe(t,e){let r=document.createElement("p");return r.classList.add(...t.trim().split(" ")),r.innerHTML=e,r}function Fe(t,e){let r=document.createElement("div");return r.classList.add(...t.trim().split(" ")),r.style.borderWidth=`${e}px`,r}async function B(t,e,r,s,o){if(!e.shouldShow)return;let i=o!=null&&o.isTooltip?0:e.showDelay;const d=100;!(o!=null&&o.isTooltip)&&Date.now()-u[s].mouseEventState.lastTooltipMouseLeaveTimestamp<=d&&(i=0);const n=Date.now();if(u[s].mouseEventState.currentInstanceId=n,u[s].mouseEventState.isHoveringOverAnchorElement=!0,i>0&&(await new Promise(c=>setTimeout(c,e.showDelay)),!u[s].mouseEventState.isHoveringOverAnchorElement||u[s].mouseEventState.currentInstanceId!==n))return;const p=t.getBoundingClientRect(),w=document.querySelector(e.appendTo);w==null||w.appendChild(r);let m=!1,a=e.tooltipPosition;for(let c=0;c<4&&(a=e.tooltipPositions[e.tooltipPosition][c],a==="left"?m=Me(p,e,r):a==="top"?m=We(p,e,r):a==="right"?m=ze(p,e,r):a==="bottom"&&(m=Se(p,e,r)),!m);c++);m&&(Ve(p,a,e,r),r.style.opacity="1",r.style.zIndex=typeof e.zIndex=="string"?e.zIndex:e.zIndex.toString(),ee(t,()=>y(s)),te(t,()=>y(s)))}async function L(t,e,r){r!=null&&r.isTooltip&&(u[e].mouseEventState.lastTooltipMouseLeaveTimestamp=Date.now());const s=r!=null&&r.isTooltip?0:t.hideDelay,o=Date.now();u[e].mouseEventState.currentInstanceId=o,u[e].mouseEventState.isHoveringOverAnchorElement=!1,!(s>0&&(await new Promise(i=>setTimeout(i,t.hideDelay)),u[e].mouseEventState.isHoveringOverAnchorElement||u[e].mouseEventState.currentInstanceId!==o))&&y(e)}function Me(t,e,r){const s=Math.min(t.left-e.tooltipOffsetFromSource-e.tooltipOffsetFromViewport,e.tooltipMaxWidth),o=t.top>=e.tooltipOffsetFromViewport,i=window.innerHeight-t.bottom>=e.tooltipOffsetFromViewport;if(s<e.tooltipMinWidth||!o||!i)return!1;r.style.maxWidth=`${s}px`;const d=r.getBoundingClientRect();let n=t.top+t.height/2-d.height/2;n<e.tooltipOffsetFromViewport?n=e.tooltipOffsetFromViewport:n+d.height>window.innerHeight-e.tooltipOffsetFromViewport&&(n=window.innerHeight-e.tooltipOffsetFromViewport-d.height);const p=t.left-e.tooltipOffsetFromSource-d.width;return t.bottom<n+e.arrowMinOffsetFromTooltipCorner*2||t.top>n+d.height-e.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${n}px`,r.style.left=`${p}px`,!0)}function ze(t,e,r){const s=Math.min(window.innerWidth-(t.right+e.tooltipOffsetFromSource)-e.tooltipOffsetFromViewport,e.tooltipMaxWidth),o=t.top>=e.tooltipOffsetFromViewport,i=window.innerHeight-t.bottom>=e.tooltipOffsetFromViewport;if(s<e.tooltipMinWidth||!o||!i)return!1;r.style.maxWidth=`${s}px`;const d=r.getBoundingClientRect();let n=t.top+t.height/2-d.height/2;n<e.tooltipOffsetFromViewport?n=e.tooltipOffsetFromViewport:n+d.height>window.innerHeight-e.tooltipOffsetFromViewport&&(n=window.innerHeight-e.tooltipOffsetFromViewport-d.height);const p=t.right+e.tooltipOffsetFromSource;return t.bottom<n+e.arrowMinOffsetFromTooltipCorner*2||t.top>n+d.height-e.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${n}px`,r.style.left=`${p}px`,!0)}function We(t,e,r){const s=Math.min(window.innerWidth-e.tooltipOffsetFromViewport*2,e.tooltipMaxWidth);r.style.maxWidth=`${s}px`;const o=r.getBoundingClientRect();let i=t.top-e.tooltipOffsetFromSource-o.height;if(i<e.tooltipOffsetFromViewport)return!1;let d=t.left+t.width/2-o.width/2;return d<e.tooltipOffsetFromViewport?d=e.tooltipOffsetFromViewport:d+o.width>window.innerWidth-e.tooltipOffsetFromViewport&&(d=window.innerWidth-e.tooltipOffsetFromViewport-o.width),t.left>d+o.width-e.arrowMinOffsetFromTooltipCorner*2||t.right<d+e.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${i}px`,r.style.left=`${d}px`,!0)}function Se(t,e,r){const s=Math.min(window.innerWidth-e.tooltipOffsetFromViewport*2,e.tooltipMaxWidth);r.style.maxWidth=`${s}px`;const o=r.getBoundingClientRect();let i=t.bottom+e.tooltipOffsetFromSource;if(i+o.height>window.innerHeight-e.tooltipOffsetFromViewport)return!1;let d=t.left+t.width/2-o.width/2;return d<e.tooltipOffsetFromViewport?d=e.tooltipOffsetFromViewport:d+o.width>window.innerWidth-e.tooltipOffsetFromViewport&&(d=window.innerWidth-e.tooltipOffsetFromViewport-o.width),t.left>d+o.width-e.arrowMinOffsetFromTooltipCorner*2||t.right<d+e.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${i}px`,r.style.left=`${d}px`,!0)}function Ve(t,e,r,s){var c;const o=document.createElement("div"),i=s.getBoundingClientRect(),d=Math.sin(45*(180/Math.PI))*r.arrowSize,n=1;let p=0,w=0,m="";switch(e){case"left":m="!zt-border-y-transparent !zt-border-r-transparent",p=t.top-i.top+t.height/2-d-r.tooltipBorderWidth,w=i.width-r.tooltipBorderWidth-n;break;case"top":m="!zt-border-x-transparent !zt-border-b-transparent",p=i.height-r.tooltipBorderWidth-n,w=t.left-i.left+t.width/2-d-r.tooltipBorderWidth;break;case"right":m="!zt-border-y-transparent !zt-border-l-transparent",p=t.top-i.top+t.height/2-d-r.tooltipBorderWidth,w=-r.arrowSize*2-r.tooltipBorderWidth+n;break;case"bottom":m="!zt-border-x-transparent !zt-border-t-transparent",p=-r.arrowSize*2-r.tooltipBorderWidth+n,w=t.left-i.left+t.width/2-d-r.tooltipBorderWidth;break}e==="left"||e==="right"?H(e,i,p,r)||(p=I(e,i,p,r)):H(e,i,w,r)||(w=I(e,i,w,r));const a=W+" "+we+" "+m+" "+r.arrowClasses;o.classList.add(...a.trim().split(" ")),o.style.top=`${p}px`,o.style.left=`${w}px`,o.style.borderWidth=`${r.arrowSize}px`,(c=document.querySelector(`.${l}`))==null||c.appendChild(o)}function H(t,e,r,s){switch(t){case"left":case"right":return r>s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth&&r<e.height+s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2;case"top":case"bottom":return r>s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth&&r<e.width+s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2}}function I(t,e,r,s){switch(t){case"left":case"right":return r<s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth?s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth:e.height-s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2;case"top":case"bottom":return r<s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth?s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth:e.width-s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2}}function y(t){var s,o;const e=document.querySelector(`.${l}`),r=(s=u[t])==null?void 0:s.tooltipElement;r&&e&&e instanceof HTMLElement&&e===r&&(re(),(o=e.querySelector(`.${W}`))==null||o.remove(),e.style.left="0",e.style.top="0",e.remove())}function F(t){const e=t.tooltipElement.dataset.uuid;e&&(y(e),delete u[e]);for(const r of Object.values(t.mouseEnterEventControllers))r.abort()}return{install:(t,e={})=>{t.directive("tooltip",Oe(e))}}});
|
|
1
|
+
(function(v,T){typeof exports=="object"&&typeof module<"u"?module.exports=T(require("vue")):typeof define=="function"&&define.amd?define(["vue"],T):(v=typeof globalThis<"u"?globalThis:v||self,v.ZeroTooltip=T(v.Vue))})(this,function(v){"use strict";const T="";let O;const Q=new Uint8Array(16);function X(){if(!O&&(O=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!O))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return O(Q)}const h=[];for(let t=0;t<256;++t)h.push((t+256).toString(16).slice(1));function Y(t,e=0){return h[t[e+0]]+h[t[e+1]]+h[t[e+2]]+h[t[e+3]]+"-"+h[t[e+4]]+h[t[e+5]]+"-"+h[t[e+6]]+h[t[e+7]]+"-"+h[t[e+8]]+h[t[e+9]]+"-"+h[t[e+10]]+h[t[e+11]]+h[t[e+12]]+h[t[e+13]]+h[t[e+14]]+h[t[e+15]]}const M={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function b(t,e,r){if(M.randomUUID&&!e&&!t)return M.randomUUID();t=t||{};const s=t.random||(t.rng||X)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=s[o];return e}return Y(s)}function C(){let t=[];const e=(o,i)=>{if(r(o),t.length>0)for(const d of t)d.addEventListener("scroll",i);window.addEventListener("scroll",()=>{i(),s(i)})},r=o=>{let i=o;for(;i!==null&&i.tagName!=="HTML";){if(i.scrollHeight!==i.clientHeight){const d=window.getComputedStyle(i);(d.overflow==="auto"||d.overflow==="scroll")&&t.push(i)}i=i.parentElement}},s=o=>{if(t.length>0){for(const i of t)i.removeEventListener("scroll",o);t=[]}window.removeEventListener("scroll",o)};return{handleHideOnScroll:e}}function g(){let t=null,e=null;return{handleHideOnResize:(o,i)=>{t=new ResizeObserver(d=>{const n=d[0].target;if(e===null)e=o.getBoundingClientRect();else{const p=n.getBoundingClientRect();(p.left!==e.left||p.top!==e.top||p.width!==e.width||p.height!==e.height)&&i()}}),t.observe(o)},resetResizeReferences:()=>{t!==null&&t.disconnect(),t=null,e=null}}}const{handleHideOnScroll:ee}=C(),{handleHideOnResize:te,resetResizeReferences:re}=g(),l="zero-tooltip__container",z="zero-tooltip__text",W="zero-tooltip__arrow",x={left:["left","right","top","bottom"],top:["top","bottom","right","left"],right:["right","left","top","bottom"],bottom:["bottom","top","right","left"]},se="body",oe="top",ie=10,de=20,ne=100,pe=250,ue=0,S="zt-fixed zt-opacity-0 zt-inline-block zt-w-fit zt-py-1.5 zt-px-2.5 zt-rounded-md zt-bg-[#495057] zt-shadow-[0_2px_12px_0_rgba(0,0,0,0.1)] zt-box-border",V="zt-text-sm zt-text-white zt-whitespace-pre-wrap zt-break-words",he=5,we="zt-absolute zt-border-solid zt-border-[#495057]",me=6,ae=1,ce=!0,ve=0,Te=0,u={},Oe=t=>({created:(e,r,s)=>{const o=b();s.el.$_tooltip={uuid:o},y(r.value,t,r.arg,e,o),typeof r.value!="string"&&v.isReactive(r.value)&&v.watch(r.value,i=>{u[o]&&F(u[o]),y(i,t,r.arg,e,o)})},updated:(e,r,s)=>{const o=s.el.$_tooltip.uuid;u[o]&&F(u[o]),y(r.value,t,r.arg,e,o)},beforeUnmount:(e,r,s)=>{const o=s.el.$_tooltip.uuid;u[o]&&F(u[o])}});function y(t,e,r,s,o){let i=le(t,e,r);const d=fe(s,i,o);u[o]=d,s.matches(":hover")&&s.dispatchEvent(new Event("mouseenter"))}function le(t,e,r){var j,q,R,Z,N,G,J,K;let s=(e==null?void 0:e.appendTo)??se,o=xe(t),i=r??(e==null?void 0:e.defaultPosition)??oe,d={left:((j=e==null?void 0:e.positions)==null?void 0:j.left)??x.left,top:((q=e==null?void 0:e.positions)==null?void 0:q.top)??x.top,right:((R=e==null?void 0:e.positions)==null?void 0:R.right)??x.right,bottom:((Z=e==null?void 0:e.positions)==null?void 0:Z.bottom)??x.bottom},n=(e==null?void 0:e.offsetFromSource)??ie,p=(e==null?void 0:e.offsetFromViewport)??de,w=(e==null?void 0:e.minWidth)??ne,m=(e==null?void 0:e.maxWidth)??pe,a=(e==null?void 0:e.tooltipBorderWidth)??ue,c=l+" "+S+" "+((e==null?void 0:e.tooltipClasses)??""),A=z+" "+V+" "+((e==null?void 0:e.textClasses)??""),D=(e==null?void 0:e.arrowSize)??he,E=(e==null?void 0:e.arrowClasses)??"",$=(e==null?void 0:e.arrowMinOffsetFromTooltipCorner)??me,_=(e==null?void 0:e.zIndex)??ae,U=ce,P=(e==null?void 0:e.showDelay)??ve,k=(e==null?void 0:e.hideDelay)??Te;return typeof t!="string"&&(t.appendTo!==void 0&&(s=t.appendTo),r===void 0&&t.defaultPosition!==void 0&&(i=t.defaultPosition),((N=t.positions)==null?void 0:N.left)!==void 0&&(d.left=t.positions.left),((G=t.positions)==null?void 0:G.top)!==void 0&&(d.top=t.positions.top),((J=t.positions)==null?void 0:J.right)!==void 0&&(d.right=t.positions.right),((K=t.positions)==null?void 0:K.bottom)!==void 0&&(d.bottom=t.positions.bottom),t.offsetFromSource!==void 0&&(n=t.offsetFromSource),t.offsetFromViewport!==void 0&&(p=t.offsetFromViewport),t.minWidth!==void 0&&(w=t.minWidth),t.maxWidth!==void 0&&(m=t.maxWidth),t.tooltipBorderWidth!==void 0&&(a=t.tooltipBorderWidth),t.tooltipClasses!==void 0&&(c=l+" "+S+" "+t.tooltipClasses),t.textClasses!==void 0&&(A=z+" "+V+" "+t.textClasses),t.arrowSize!==void 0&&(D=t.arrowSize),t.arrowClasses!==void 0&&(E=t.arrowClasses),t.arrowMinOffsetFromTooltipCorner!==void 0&&($=t.arrowMinOffsetFromTooltipCorner),t.zIndex!==void 0&&(_=t.zIndex),t.show!==void 0&&(U=t.show),t.showDelay!==void 0&&(P=t.showDelay),t.hideDelay!==void 0&&(k=t.hideDelay)),{appendTo:s,tooltipText:o,tooltipPosition:i,tooltipPositions:d,tooltipOffsetFromSource:n,tooltipOffsetFromViewport:p,tooltipMinWidth:w,tooltipMaxWidth:m,tooltipBorderWidth:a,tooltipClasses:c,textClasses:A,arrowSize:D,arrowClasses:E,arrowMinOffsetFromTooltipCorner:$,zIndex:_,shouldShow:U,showDelay:P,hideDelay:k}}function xe(t){const e=typeof t=="string"?t:t.content;if(!e)throw new Error("Please enter valid tooltip value");return e}function fe(t,e,r){let s=t,o=ye(e.textClasses,e.tooltipText),i=Fe(e.tooltipClasses,e.tooltipBorderWidth);i.append(o),i.dataset.uuid=r;const d={currentInstanceId:Date.now(),isHoveringOverAnchorElement:!1,lastTooltipMouseLeaveTimestamp:0},n={anchorElementMouseEnter:new AbortController,anchorElementMouseLeave:new AbortController,tooltipElementMouseEnter:new AbortController,tooltipElementMouseLeave:new AbortController};return s.addEventListener("mouseenter",()=>B(s,e,i,r),{signal:n.anchorElementMouseEnter.signal}),s.addEventListener("mouseleave",()=>L(e,r),{signal:n.anchorElementMouseLeave.signal}),i.addEventListener("mouseenter",()=>B(s,e,i,r,{isTooltip:!0}),{signal:n.tooltipElementMouseEnter.signal}),i.addEventListener("mouseleave",()=>L(e,r,{isTooltip:!0}),{signal:n.tooltipElementMouseLeave.signal}),{anchorElement:s,tooltipConfig:e,tooltipElement:i,mouseEnterEventControllers:n,mouseEventState:d}}function ye(t,e){let r=document.createElement("p");return r.classList.add(...t.trim().split(" ")),r.innerHTML=e,r}function Fe(t,e){let r=document.createElement("div");return r.classList.add(...t.trim().split(" ")),r.style.borderWidth=`${e}px`,r}async function B(t,e,r,s,o){if(!e.shouldShow)return;let i=o!=null&&o.isTooltip?0:e.showDelay;const d=100;!(o!=null&&o.isTooltip)&&Date.now()-u[s].mouseEventState.lastTooltipMouseLeaveTimestamp<=d&&(i=0);const n=Date.now();if(u[s].mouseEventState.currentInstanceId=n,u[s].mouseEventState.isHoveringOverAnchorElement=!0,i>0&&(await new Promise(c=>setTimeout(c,i)),!u[s].mouseEventState.isHoveringOverAnchorElement||u[s].mouseEventState.currentInstanceId!==n))return;const p=t.getBoundingClientRect(),w=document.querySelector(e.appendTo);w==null||w.appendChild(r);let m=!1,a=e.tooltipPosition;for(let c=0;c<4&&(a=e.tooltipPositions[e.tooltipPosition][c],a==="left"?m=Me(p,e,r):a==="top"?m=We(p,e,r):a==="right"?m=ze(p,e,r):a==="bottom"&&(m=Se(p,e,r)),!m);c++);m&&(Ve(p,a,e,r),r.style.opacity="1",r.style.zIndex=typeof e.zIndex=="string"?e.zIndex:e.zIndex.toString(),ee(t,()=>f(s)),te(t,()=>f(s)))}async function L(t,e,r){r!=null&&r.isTooltip&&(u[e].mouseEventState.lastTooltipMouseLeaveTimestamp=Date.now());const s=Date.now();u[e].mouseEventState.currentInstanceId=s,u[e].mouseEventState.isHoveringOverAnchorElement=!1,!(t.hideDelay>0&&(await new Promise(o=>setTimeout(o,t.hideDelay)),u[e].mouseEventState.isHoveringOverAnchorElement||u[e].mouseEventState.currentInstanceId!==s))&&f(e)}function Me(t,e,r){const s=Math.min(t.left-e.tooltipOffsetFromSource-e.tooltipOffsetFromViewport,e.tooltipMaxWidth),o=t.top>=e.tooltipOffsetFromViewport,i=window.innerHeight-t.bottom>=e.tooltipOffsetFromViewport;if(s<e.tooltipMinWidth||!o||!i)return!1;r.style.maxWidth=`${s}px`;const d=r.getBoundingClientRect();let n=t.top+t.height/2-d.height/2;n<e.tooltipOffsetFromViewport?n=e.tooltipOffsetFromViewport:n+d.height>window.innerHeight-e.tooltipOffsetFromViewport&&(n=window.innerHeight-e.tooltipOffsetFromViewport-d.height);const p=t.left-e.tooltipOffsetFromSource-d.width;return t.bottom<n+e.arrowMinOffsetFromTooltipCorner*2||t.top>n+d.height-e.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${n}px`,r.style.left=`${p}px`,!0)}function ze(t,e,r){const s=Math.min(window.innerWidth-(t.right+e.tooltipOffsetFromSource)-e.tooltipOffsetFromViewport,e.tooltipMaxWidth),o=t.top>=e.tooltipOffsetFromViewport,i=window.innerHeight-t.bottom>=e.tooltipOffsetFromViewport;if(s<e.tooltipMinWidth||!o||!i)return!1;r.style.maxWidth=`${s}px`;const d=r.getBoundingClientRect();let n=t.top+t.height/2-d.height/2;n<e.tooltipOffsetFromViewport?n=e.tooltipOffsetFromViewport:n+d.height>window.innerHeight-e.tooltipOffsetFromViewport&&(n=window.innerHeight-e.tooltipOffsetFromViewport-d.height);const p=t.right+e.tooltipOffsetFromSource;return t.bottom<n+e.arrowMinOffsetFromTooltipCorner*2||t.top>n+d.height-e.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${n}px`,r.style.left=`${p}px`,!0)}function We(t,e,r){const s=Math.min(window.innerWidth-e.tooltipOffsetFromViewport*2,e.tooltipMaxWidth);r.style.maxWidth=`${s}px`;const o=r.getBoundingClientRect();let i=t.top-e.tooltipOffsetFromSource-o.height;if(i<e.tooltipOffsetFromViewport)return!1;let d=t.left+t.width/2-o.width/2;return d<e.tooltipOffsetFromViewport?d=e.tooltipOffsetFromViewport:d+o.width>window.innerWidth-e.tooltipOffsetFromViewport&&(d=window.innerWidth-e.tooltipOffsetFromViewport-o.width),t.left>d+o.width-e.arrowMinOffsetFromTooltipCorner*2||t.right<d+e.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${i}px`,r.style.left=`${d}px`,!0)}function Se(t,e,r){const s=Math.min(window.innerWidth-e.tooltipOffsetFromViewport*2,e.tooltipMaxWidth);r.style.maxWidth=`${s}px`;const o=r.getBoundingClientRect();let i=t.bottom+e.tooltipOffsetFromSource;if(i+o.height>window.innerHeight-e.tooltipOffsetFromViewport)return!1;let d=t.left+t.width/2-o.width/2;return d<e.tooltipOffsetFromViewport?d=e.tooltipOffsetFromViewport:d+o.width>window.innerWidth-e.tooltipOffsetFromViewport&&(d=window.innerWidth-e.tooltipOffsetFromViewport-o.width),t.left>d+o.width-e.arrowMinOffsetFromTooltipCorner*2||t.right<d+e.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${i}px`,r.style.left=`${d}px`,!0)}function Ve(t,e,r,s){var c;const o=document.createElement("div"),i=s.getBoundingClientRect(),d=Math.sin(45*(180/Math.PI))*r.arrowSize,n=1;let p=0,w=0,m="";switch(e){case"left":m="!zt-border-y-transparent !zt-border-r-transparent",p=t.top-i.top+t.height/2-d-r.tooltipBorderWidth,w=i.width-r.tooltipBorderWidth-n;break;case"top":m="!zt-border-x-transparent !zt-border-b-transparent",p=i.height-r.tooltipBorderWidth-n,w=t.left-i.left+t.width/2-d-r.tooltipBorderWidth;break;case"right":m="!zt-border-y-transparent !zt-border-l-transparent",p=t.top-i.top+t.height/2-d-r.tooltipBorderWidth,w=-r.arrowSize*2-r.tooltipBorderWidth+n;break;case"bottom":m="!zt-border-x-transparent !zt-border-t-transparent",p=-r.arrowSize*2-r.tooltipBorderWidth+n,w=t.left-i.left+t.width/2-d-r.tooltipBorderWidth;break}e==="left"||e==="right"?H(e,i,p,r)||(p=I(e,i,p,r)):H(e,i,w,r)||(w=I(e,i,w,r));const a=W+" "+we+" "+m+" "+r.arrowClasses;o.classList.add(...a.trim().split(" ")),o.style.top=`${p}px`,o.style.left=`${w}px`,o.style.borderWidth=`${r.arrowSize}px`,(c=document.querySelector(`.${l}`))==null||c.appendChild(o)}function H(t,e,r,s){switch(t){case"left":case"right":return r>s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth&&r<e.height+s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2;case"top":case"bottom":return r>s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth&&r<e.width+s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2}}function I(t,e,r,s){switch(t){case"left":case"right":return r<s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth?s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth:e.height-s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2;case"top":case"bottom":return r<s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth?s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth:e.width-s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2}}function f(t){var s,o;const e=document.querySelector(`.${l}`),r=(s=u[t])==null?void 0:s.tooltipElement;r&&e&&e instanceof HTMLElement&&e===r&&(re(),(o=e.querySelector(`.${W}`))==null||o.remove(),e.style.left="0",e.style.top="0",e.remove())}function F(t){const e=t.tooltipElement.dataset.uuid;e&&(f(e),delete u[e]);for(const r of Object.values(t.mouseEnterEventControllers))r.abort()}return{install:(t,e={})=>{t.directive("tooltip",Oe(e))}}});
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dist",
|
|
19
19
|
"src"
|
|
20
20
|
],
|
|
21
|
-
"version": "1.3.
|
|
21
|
+
"version": "1.3.1",
|
|
22
22
|
"type": "module",
|
|
23
23
|
"scripts": {
|
|
24
24
|
"dev": "vite",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"vite": "4.4.5",
|
|
37
37
|
"vite-plugin-dts": "3.5.3",
|
|
38
38
|
"vue": "^3.0.0",
|
|
39
|
-
"vue-tsc": "1.8.5"
|
|
39
|
+
"vue-tsc": "1.8.5",
|
|
40
|
+
"primevue": "3.53.0"
|
|
40
41
|
},
|
|
41
42
|
"repository": {
|
|
42
43
|
"type": "git",
|
package/src/tooltip.ts
CHANGED
|
@@ -187,7 +187,7 @@ function initTooltip(targetElement: HTMLElement, tooltipConfig: ReturnType<typeo
|
|
|
187
187
|
const mouseEventState = {
|
|
188
188
|
currentInstanceId: Date.now(),
|
|
189
189
|
isHoveringOverAnchorElement: false,
|
|
190
|
-
lastTooltipMouseLeaveTimestamp:
|
|
190
|
+
lastTooltipMouseLeaveTimestamp: 0,
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
const mouseEnterEventControllers = {
|
|
@@ -250,7 +250,7 @@ async function onMouseEnter(
|
|
|
250
250
|
tooltips[uuid].mouseEventState.isHoveringOverAnchorElement = true
|
|
251
251
|
|
|
252
252
|
if (_showDelay > 0) {
|
|
253
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
253
|
+
await new Promise(resolve => setTimeout(resolve, _showDelay))
|
|
254
254
|
|
|
255
255
|
if (!tooltips[uuid].mouseEventState.isHoveringOverAnchorElement || tooltips[uuid].mouseEventState.currentInstanceId !== currentInstanceId) return
|
|
256
256
|
}
|
|
@@ -296,12 +296,11 @@ async function onMouseLeave(tooltipConfig: ReturnType<typeof getTooltipConfig>,
|
|
|
296
296
|
tooltips[uuid].mouseEventState.lastTooltipMouseLeaveTimestamp = Date.now()
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
-
const _hideDelay = options?.isTooltip ? 0 : tooltipConfig.hideDelay
|
|
300
299
|
const currentInstanceId = Date.now()
|
|
301
300
|
tooltips[uuid].mouseEventState.currentInstanceId = currentInstanceId
|
|
302
301
|
tooltips[uuid].mouseEventState.isHoveringOverAnchorElement = false
|
|
303
302
|
|
|
304
|
-
if (
|
|
303
|
+
if (tooltipConfig.hideDelay > 0) {
|
|
305
304
|
await new Promise(resolve => setTimeout(resolve, tooltipConfig.hideDelay))
|
|
306
305
|
|
|
307
306
|
if (tooltips[uuid].mouseEventState.isHoveringOverAnchorElement || tooltips[uuid].mouseEventState.currentInstanceId !== currentInstanceId) return
|