v-tooltip-lite
Version:
Lightweight, Customizable Tooltip/Dropdown Component for Vue 3
1,143 lines (1,142 loc) • 36.9 kB
JavaScript
import { ref as oe, onMounted as ut, nextTick as Ce, onBeforeUnmount as Ct, watch as Rt, defineComponent as Dt, computed as Bt, onUnmounted as jt, createElementBlock as Re, openBlock as ge, createElementVNode as Qe, createBlock as Lt, createCommentVNode as De, normalizeClass as Be, renderSlot as Ze, normalizeProps as _e, guardReactiveProps as et, unref as ye, resolveDynamicComponent as St, Teleport as $t, withCtx as Wt, normalizeStyle as Ht, createTextVNode as Mt, toDisplayString as Nt } from "vue";
const Q = () => {
};
function pt(e) {
return typeof e == "function" ? e() : e && typeof e == "object" && "value" in e ? e.value : e;
}
function we(e) {
return pt(e);
}
const Vt = typeof window > "u" || !window.navigator ? !1 : /iP(?:ad|hone|od)/.test(window.navigator.userAgent) || window.navigator.maxTouchPoints > 2 && /iPad|Macintosh/.test(window.navigator.userAgent);
function je(e, t, r, n) {
return e.addEventListener(t, r, n), () => e.removeEventListener(t, r, n);
}
let tt = !1;
function It(e, t, r = {}) {
const { window: n = typeof globalThis < "u" ? globalThis.window : void 0, ignore: o = [], capture: i = !0, detectIframe: l = !1, controls: s = !1 } = r;
if (!n)
return s ? { stop: Q, cancel: Q, trigger: Q } : Q;
if (Vt && !tt) {
tt = !0;
const u = { passive: !0 };
Array.from(n.document.body.children).forEach((d) => d.addEventListener("click", Q, u)), n.document.documentElement.addEventListener("click", Q, u);
}
let a = !0;
const c = (u) => pt(o).some((d) => {
if (typeof d == "string")
return Array.from(n.document.querySelectorAll(d)).some((m) => m === u.target || u.composedPath().includes(m));
{
const m = we(d);
return m && (u.target === m || u.composedPath().includes(m));
}
}), f = (u) => {
if (!u.target)
return;
const d = we(e);
if (d && !(d === u.target || u.composedPath().includes(d))) {
if ("detail" in u && u.detail === 0 && (a = !c(u)), !a) {
a = !0;
return;
}
t(u);
}
};
let p = !1;
const w = [
je(n, "click", (u) => {
p || (p = !0, setTimeout(() => {
p = !1;
}, 0), f(u));
}, { passive: !0, capture: i }),
je(n, "pointerdown", (u) => {
const d = we(e);
a = !c(u) && !!(d && !u.composedPath().includes(d));
}, { passive: !0 }),
l && je(n, "blur", (u) => {
setTimeout(() => {
var m;
const d = we(e);
((m = n.document.activeElement) == null ? void 0 : m.tagName) === "IFRAME" && !(d != null && d.contains(n.document.activeElement)) && t(u);
}, 0);
}, { passive: !0 })
].filter(Boolean), v = () => w.forEach((u) => u());
return s ? {
stop: v,
cancel: () => {
a = !1;
},
trigger: (u) => {
a = !0, f(u), a = !1;
}
} : v;
}
var R = "top", S = "bottom", $ = "right", D = "left", $e = "auto", ce = [R, S, $, D], Z = "start", fe = "end", Ft = "clippingParents", dt = "viewport", ae = "popper", qt = "reference", rt = /* @__PURE__ */ ce.reduce(function(e, t) {
return e.concat([t + "-" + Z, t + "-" + fe]);
}, []), vt = /* @__PURE__ */ [].concat(ce, [$e]).reduce(function(e, t) {
return e.concat([t, t + "-" + Z, t + "-" + fe]);
}, []), zt = "beforeRead", Ut = "read", Xt = "afterRead", Yt = "beforeMain", Gt = "main", Jt = "afterMain", Kt = "beforeWrite", Qt = "write", Zt = "afterWrite", _t = [zt, Ut, Xt, Yt, Gt, Jt, Kt, Qt, Zt];
function N(e) {
return e ? (e.nodeName || "").toLowerCase() : null;
}
function j(e) {
if (e == null)
return window;
if (e.toString() !== "[object Window]") {
var t = e.ownerDocument;
return t && t.defaultView || window;
}
return e;
}
function J(e) {
var t = j(e).Element;
return e instanceof t || e instanceof Element;
}
function L(e) {
var t = j(e).HTMLElement;
return e instanceof t || e instanceof HTMLElement;
}
function We(e) {
if (typeof ShadowRoot > "u")
return !1;
var t = j(e).ShadowRoot;
return e instanceof t || e instanceof ShadowRoot;
}
function er(e) {
var t = e.state;
Object.keys(t.elements).forEach(function(r) {
var n = t.styles[r] || {}, o = t.attributes[r] || {}, i = t.elements[r];
!L(i) || !N(i) || (Object.assign(i.style, n), Object.keys(o).forEach(function(l) {
var s = o[l];
s === !1 ? i.removeAttribute(l) : i.setAttribute(l, s === !0 ? "" : s);
}));
});
}
function tr(e) {
var t = e.state, r = {
popper: {
position: t.options.strategy,
left: "0",
top: "0",
margin: "0"
},
arrow: {
position: "absolute"
},
reference: {}
};
return Object.assign(t.elements.popper.style, r.popper), t.styles = r, t.elements.arrow && Object.assign(t.elements.arrow.style, r.arrow), function() {
Object.keys(t.elements).forEach(function(n) {
var o = t.elements[n], i = t.attributes[n] || {}, l = Object.keys(t.styles.hasOwnProperty(n) ? t.styles[n] : r[n]), s = l.reduce(function(a, c) {
return a[c] = "", a;
}, {});
!L(o) || !N(o) || (Object.assign(o.style, s), Object.keys(i).forEach(function(a) {
o.removeAttribute(a);
}));
});
};
}
const rr = {
name: "applyStyles",
enabled: !0,
phase: "write",
fn: er,
effect: tr,
requires: ["computeStyles"]
};
function M(e) {
return e.split("-")[0];
}
var G = Math.max, Oe = Math.min, _ = Math.round;
function Le() {
var e = navigator.userAgentData;
return e != null && e.brands && Array.isArray(e.brands) ? e.brands.map(function(t) {
return t.brand + "/" + t.version;
}).join(" ") : navigator.userAgent;
}
function mt() {
return !/^((?!chrome|android).)*safari/i.test(Le());
}
function ee(e, t, r) {
t === void 0 && (t = !1), r === void 0 && (r = !1);
var n = e.getBoundingClientRect(), o = 1, i = 1;
t && L(e) && (o = e.offsetWidth > 0 && _(n.width) / e.offsetWidth || 1, i = e.offsetHeight > 0 && _(n.height) / e.offsetHeight || 1);
var l = J(e) ? j(e) : window, s = l.visualViewport, a = !mt() && r, c = (n.left + (a && s ? s.offsetLeft : 0)) / o, f = (n.top + (a && s ? s.offsetTop : 0)) / i, p = n.width / o, w = n.height / i;
return {
width: p,
height: w,
top: f,
right: c + p,
bottom: f + w,
left: c,
x: c,
y: f
};
}
function He(e) {
var t = ee(e), r = e.offsetWidth, n = e.offsetHeight;
return Math.abs(t.width - r) <= 1 && (r = t.width), Math.abs(t.height - n) <= 1 && (n = t.height), {
x: e.offsetLeft,
y: e.offsetTop,
width: r,
height: n
};
}
function ht(e, t) {
var r = t.getRootNode && t.getRootNode();
if (e.contains(t))
return !0;
if (r && We(r)) {
var n = t;
do {
if (n && e.isSameNode(n))
return !0;
n = n.parentNode || n.host;
} while (n);
}
return !1;
}
function V(e) {
return j(e).getComputedStyle(e);
}
function nr(e) {
return ["table", "td", "th"].indexOf(N(e)) >= 0;
}
function F(e) {
return ((J(e) ? e.ownerDocument : (
// $FlowFixMe[prop-missing]
e.document
)) || window.document).documentElement;
}
function Ee(e) {
return N(e) === "html" ? e : (
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
// $FlowFixMe[incompatible-return]
// $FlowFixMe[prop-missing]
e.assignedSlot || // step into the shadow DOM of the parent of a slotted node
e.parentNode || // DOM Element detected
(We(e) ? e.host : null) || // ShadowRoot detected
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
F(e)
);
}
function nt(e) {
return !L(e) || // https://github.com/popperjs/popper-core/issues/837
V(e).position === "fixed" ? null : e.offsetParent;
}
function or(e) {
var t = /firefox/i.test(Le()), r = /Trident/i.test(Le());
if (r && L(e)) {
var n = V(e);
if (n.position === "fixed")
return null;
}
var o = Ee(e);
for (We(o) && (o = o.host); L(o) && ["html", "body"].indexOf(N(o)) < 0; ) {
var i = V(o);
if (i.transform !== "none" || i.perspective !== "none" || i.contain === "paint" || ["transform", "perspective"].indexOf(i.willChange) !== -1 || t && i.willChange === "filter" || t && i.filter && i.filter !== "none")
return o;
o = o.parentNode;
}
return null;
}
function ue(e) {
for (var t = j(e), r = nt(e); r && nr(r) && V(r).position === "static"; )
r = nt(r);
return r && (N(r) === "html" || N(r) === "body" && V(r).position === "static") ? t : r || or(e) || t;
}
function Me(e) {
return ["top", "bottom"].indexOf(e) >= 0 ? "x" : "y";
}
function ie(e, t, r) {
return G(e, Oe(t, r));
}
function ar(e, t, r) {
var n = ie(e, t, r);
return n > r ? r : n;
}
function gt() {
return {
top: 0,
right: 0,
bottom: 0,
left: 0
};
}
function yt(e) {
return Object.assign({}, gt(), e);
}
function wt(e, t) {
return t.reduce(function(r, n) {
return r[n] = e, r;
}, {});
}
var ir = function(t, r) {
return t = typeof t == "function" ? t(Object.assign({}, r.rects, {
placement: r.placement
})) : t, yt(typeof t != "number" ? t : wt(t, ce));
};
function sr(e) {
var t, r = e.state, n = e.name, o = e.options, i = r.elements.arrow, l = r.modifiersData.popperOffsets, s = M(r.placement), a = Me(s), c = [D, $].indexOf(s) >= 0, f = c ? "height" : "width";
if (!(!i || !l)) {
var p = ir(o.padding, r), w = He(i), v = a === "y" ? R : D, u = a === "y" ? S : $, d = r.rects.reference[f] + r.rects.reference[a] - l[a] - r.rects.popper[f], m = l[a] - r.rects.reference[a], b = ue(i), g = b ? a === "y" ? b.clientHeight || 0 : b.clientWidth || 0 : 0, y = d / 2 - m / 2, h = p[v], x = g - w[f] - p[u], O = g / 2 - w[f] / 2 + y, E = ie(h, O, x), k = a;
r.modifiersData[n] = (t = {}, t[k] = E, t.centerOffset = E - O, t);
}
}
function fr(e) {
var t = e.state, r = e.options, n = r.element, o = n === void 0 ? "[data-popper-arrow]" : n;
o != null && (typeof o == "string" && (o = t.elements.popper.querySelector(o), !o) || ht(t.elements.popper, o) && (t.elements.arrow = o));
}
const lr = {
name: "arrow",
enabled: !0,
phase: "main",
fn: sr,
effect: fr,
requires: ["popperOffsets"],
requiresIfExists: ["preventOverflow"]
};
function te(e) {
return e.split("-")[1];
}
var cr = {
top: "auto",
right: "auto",
bottom: "auto",
left: "auto"
};
function ur(e, t) {
var r = e.x, n = e.y, o = t.devicePixelRatio || 1;
return {
x: _(r * o) / o || 0,
y: _(n * o) / o || 0
};
}
function ot(e) {
var t, r = e.popper, n = e.popperRect, o = e.placement, i = e.variation, l = e.offsets, s = e.position, a = e.gpuAcceleration, c = e.adaptive, f = e.roundOffsets, p = e.isFixed, w = l.x, v = w === void 0 ? 0 : w, u = l.y, d = u === void 0 ? 0 : u, m = typeof f == "function" ? f({
x: v,
y: d
}) : {
x: v,
y: d
};
v = m.x, d = m.y;
var b = l.hasOwnProperty("x"), g = l.hasOwnProperty("y"), y = D, h = R, x = window;
if (c) {
var O = ue(r), E = "clientHeight", k = "clientWidth";
if (O === j(r) && (O = F(r), V(O).position !== "static" && s === "absolute" && (E = "scrollHeight", k = "scrollWidth")), O = O, o === R || (o === D || o === $) && i === fe) {
h = S;
var A = p && O === x && x.visualViewport ? x.visualViewport.height : (
// $FlowFixMe[prop-missing]
O[E]
);
d -= A - n.height, d *= a ? 1 : -1;
}
if (o === D || (o === R || o === S) && i === fe) {
y = $;
var P = p && O === x && x.visualViewport ? x.visualViewport.width : (
// $FlowFixMe[prop-missing]
O[k]
);
v -= P - n.width, v *= a ? 1 : -1;
}
}
var T = Object.assign({
position: s
}, c && cr), W = f === !0 ? ur({
x: v,
y: d
}, j(r)) : {
x: v,
y: d
};
if (v = W.x, d = W.y, a) {
var C;
return Object.assign({}, T, (C = {}, C[h] = g ? "0" : "", C[y] = b ? "0" : "", C.transform = (x.devicePixelRatio || 1) <= 1 ? "translate(" + v + "px, " + d + "px)" : "translate3d(" + v + "px, " + d + "px, 0)", C));
}
return Object.assign({}, T, (t = {}, t[h] = g ? d + "px" : "", t[y] = b ? v + "px" : "", t.transform = "", t));
}
function pr(e) {
var t = e.state, r = e.options, n = r.gpuAcceleration, o = n === void 0 ? !0 : n, i = r.adaptive, l = i === void 0 ? !0 : i, s = r.roundOffsets, a = s === void 0 ? !0 : s, c = {
placement: M(t.placement),
variation: te(t.placement),
popper: t.elements.popper,
popperRect: t.rects.popper,
gpuAcceleration: o,
isFixed: t.options.strategy === "fixed"
};
t.modifiersData.popperOffsets != null && (t.styles.popper = Object.assign({}, t.styles.popper, ot(Object.assign({}, c, {
offsets: t.modifiersData.popperOffsets,
position: t.options.strategy,
adaptive: l,
roundOffsets: a
})))), t.modifiersData.arrow != null && (t.styles.arrow = Object.assign({}, t.styles.arrow, ot(Object.assign({}, c, {
offsets: t.modifiersData.arrow,
position: "absolute",
adaptive: !1,
roundOffsets: a
})))), t.attributes.popper = Object.assign({}, t.attributes.popper, {
"data-popper-placement": t.placement
});
}
const dr = {
name: "computeStyles",
enabled: !0,
phase: "beforeWrite",
fn: pr,
data: {}
};
var be = {
passive: !0
};
function vr(e) {
var t = e.state, r = e.instance, n = e.options, o = n.scroll, i = o === void 0 ? !0 : o, l = n.resize, s = l === void 0 ? !0 : l, a = j(t.elements.popper), c = [].concat(t.scrollParents.reference, t.scrollParents.popper);
return i && c.forEach(function(f) {
f.addEventListener("scroll", r.update, be);
}), s && a.addEventListener("resize", r.update, be), function() {
i && c.forEach(function(f) {
f.removeEventListener("scroll", r.update, be);
}), s && a.removeEventListener("resize", r.update, be);
};
}
const mr = {
name: "eventListeners",
enabled: !0,
phase: "write",
fn: function() {
},
effect: vr,
data: {}
};
var hr = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
};
function xe(e) {
return e.replace(/left|right|bottom|top/g, function(t) {
return hr[t];
});
}
var gr = {
start: "end",
end: "start"
};
function at(e) {
return e.replace(/start|end/g, function(t) {
return gr[t];
});
}
function Ne(e) {
var t = j(e), r = t.pageXOffset, n = t.pageYOffset;
return {
scrollLeft: r,
scrollTop: n
};
}
function Ve(e) {
return ee(F(e)).left + Ne(e).scrollLeft;
}
function yr(e, t) {
var r = j(e), n = F(e), o = r.visualViewport, i = n.clientWidth, l = n.clientHeight, s = 0, a = 0;
if (o) {
i = o.width, l = o.height;
var c = mt();
(c || !c && t === "fixed") && (s = o.offsetLeft, a = o.offsetTop);
}
return {
width: i,
height: l,
x: s + Ve(e),
y: a
};
}
function wr(e) {
var t, r = F(e), n = Ne(e), o = (t = e.ownerDocument) == null ? void 0 : t.body, i = G(r.scrollWidth, r.clientWidth, o ? o.scrollWidth : 0, o ? o.clientWidth : 0), l = G(r.scrollHeight, r.clientHeight, o ? o.scrollHeight : 0, o ? o.clientHeight : 0), s = -n.scrollLeft + Ve(e), a = -n.scrollTop;
return V(o || r).direction === "rtl" && (s += G(r.clientWidth, o ? o.clientWidth : 0) - i), {
width: i,
height: l,
x: s,
y: a
};
}
function Ie(e) {
var t = V(e), r = t.overflow, n = t.overflowX, o = t.overflowY;
return /auto|scroll|overlay|hidden/.test(r + o + n);
}
function bt(e) {
return ["html", "body", "#document"].indexOf(N(e)) >= 0 ? e.ownerDocument.body : L(e) && Ie(e) ? e : bt(Ee(e));
}
function se(e, t) {
var r;
t === void 0 && (t = []);
var n = bt(e), o = n === ((r = e.ownerDocument) == null ? void 0 : r.body), i = j(n), l = o ? [i].concat(i.visualViewport || [], Ie(n) ? n : []) : n, s = t.concat(l);
return o ? s : (
// $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
s.concat(se(Ee(l)))
);
}
function Se(e) {
return Object.assign({}, e, {
left: e.x,
top: e.y,
right: e.x + e.width,
bottom: e.y + e.height
});
}
function br(e, t) {
var r = ee(e, !1, t === "fixed");
return r.top = r.top + e.clientTop, r.left = r.left + e.clientLeft, r.bottom = r.top + e.clientHeight, r.right = r.left + e.clientWidth, r.width = e.clientWidth, r.height = e.clientHeight, r.x = r.left, r.y = r.top, r;
}
function it(e, t, r) {
return t === dt ? Se(yr(e, r)) : J(t) ? br(t, r) : Se(wr(F(e)));
}
function xr(e) {
var t = se(Ee(e)), r = ["absolute", "fixed"].indexOf(V(e).position) >= 0, n = r && L(e) ? ue(e) : e;
return J(n) ? t.filter(function(o) {
return J(o) && ht(o, n) && N(o) !== "body";
}) : [];
}
function Or(e, t, r, n) {
var o = t === "clippingParents" ? xr(e) : [].concat(t), i = [].concat(o, [r]), l = i[0], s = i.reduce(function(a, c) {
var f = it(e, c, n);
return a.top = G(f.top, a.top), a.right = Oe(f.right, a.right), a.bottom = Oe(f.bottom, a.bottom), a.left = G(f.left, a.left), a;
}, it(e, l, n));
return s.width = s.right - s.left, s.height = s.bottom - s.top, s.x = s.left, s.y = s.top, s;
}
function xt(e) {
var t = e.reference, r = e.element, n = e.placement, o = n ? M(n) : null, i = n ? te(n) : null, l = t.x + t.width / 2 - r.width / 2, s = t.y + t.height / 2 - r.height / 2, a;
switch (o) {
case R:
a = {
x: l,
y: t.y - r.height
};
break;
case S:
a = {
x: l,
y: t.y + t.height
};
break;
case $:
a = {
x: t.x + t.width,
y: s
};
break;
case D:
a = {
x: t.x - r.width,
y: s
};
break;
default:
a = {
x: t.x,
y: t.y
};
}
var c = o ? Me(o) : null;
if (c != null) {
var f = c === "y" ? "height" : "width";
switch (i) {
case Z:
a[c] = a[c] - (t[f] / 2 - r[f] / 2);
break;
case fe:
a[c] = a[c] + (t[f] / 2 - r[f] / 2);
break;
}
}
return a;
}
function le(e, t) {
t === void 0 && (t = {});
var r = t, n = r.placement, o = n === void 0 ? e.placement : n, i = r.strategy, l = i === void 0 ? e.strategy : i, s = r.boundary, a = s === void 0 ? Ft : s, c = r.rootBoundary, f = c === void 0 ? dt : c, p = r.elementContext, w = p === void 0 ? ae : p, v = r.altBoundary, u = v === void 0 ? !1 : v, d = r.padding, m = d === void 0 ? 0 : d, b = yt(typeof m != "number" ? m : wt(m, ce)), g = w === ae ? qt : ae, y = e.rects.popper, h = e.elements[u ? g : w], x = Or(J(h) ? h : h.contextElement || F(e.elements.popper), a, f, l), O = ee(e.elements.reference), E = xt({
reference: O,
element: y,
placement: o
}), k = Se(Object.assign({}, y, E)), A = w === ae ? k : O, P = {
top: x.top - A.top + b.top,
bottom: A.bottom - x.bottom + b.bottom,
left: x.left - A.left + b.left,
right: A.right - x.right + b.right
}, T = e.modifiersData.offset;
if (w === ae && T) {
var W = T[o];
Object.keys(P).forEach(function(C) {
var q = [$, S].indexOf(C) >= 0 ? 1 : -1, z = [R, S].indexOf(C) >= 0 ? "y" : "x";
P[C] += W[z] * q;
});
}
return P;
}
function Er(e, t) {
t === void 0 && (t = {});
var r = t, n = r.placement, o = r.boundary, i = r.rootBoundary, l = r.padding, s = r.flipVariations, a = r.allowedAutoPlacements, c = a === void 0 ? vt : a, f = te(n), p = f ? s ? rt : rt.filter(function(u) {
return te(u) === f;
}) : ce, w = p.filter(function(u) {
return c.indexOf(u) >= 0;
});
w.length === 0 && (w = p);
var v = w.reduce(function(u, d) {
return u[d] = le(e, {
placement: d,
boundary: o,
rootBoundary: i,
padding: l
})[M(d)], u;
}, {});
return Object.keys(v).sort(function(u, d) {
return v[u] - v[d];
});
}
function Pr(e) {
if (M(e) === $e)
return [];
var t = xe(e);
return [at(e), t, at(t)];
}
function Ar(e) {
var t = e.state, r = e.options, n = e.name;
if (!t.modifiersData[n]._skip) {
for (var o = r.mainAxis, i = o === void 0 ? !0 : o, l = r.altAxis, s = l === void 0 ? !0 : l, a = r.fallbackPlacements, c = r.padding, f = r.boundary, p = r.rootBoundary, w = r.altBoundary, v = r.flipVariations, u = v === void 0 ? !0 : v, d = r.allowedAutoPlacements, m = t.options.placement, b = M(m), g = b === m, y = a || (g || !u ? [xe(m)] : Pr(m)), h = [m].concat(y).reduce(function(K, I) {
return K.concat(M(I) === $e ? Er(t, {
placement: I,
boundary: f,
rootBoundary: p,
padding: c,
flipVariations: u,
allowedAutoPlacements: d
}) : I);
}, []), x = t.rects.reference, O = t.rects.popper, E = /* @__PURE__ */ new Map(), k = !0, A = h[0], P = 0; P < h.length; P++) {
var T = h[P], W = M(T), C = te(T) === Z, q = [R, S].indexOf(W) >= 0, z = q ? "width" : "height", B = le(t, {
placement: T,
boundary: f,
rootBoundary: p,
altBoundary: w,
padding: c
}), H = q ? C ? $ : D : C ? S : R;
x[z] > O[z] && (H = xe(H));
var pe = xe(H), U = [];
if (i && U.push(B[W] <= 0), s && U.push(B[H] <= 0, B[pe] <= 0), U.every(function(K) {
return K;
})) {
A = T, k = !1;
break;
}
E.set(T, U);
}
if (k)
for (var de = u ? 3 : 1, Pe = function(I) {
var ne = h.find(function(me) {
var X = E.get(me);
if (X)
return X.slice(0, I).every(function(Ae) {
return Ae;
});
});
if (ne)
return A = ne, "break";
}, re = de; re > 0; re--) {
var ve = Pe(re);
if (ve === "break") break;
}
t.placement !== A && (t.modifiersData[n]._skip = !0, t.placement = A, t.reset = !0);
}
}
const kr = {
name: "flip",
enabled: !0,
phase: "main",
fn: Ar,
requiresIfExists: ["offset"],
data: {
_skip: !1
}
};
function st(e, t, r) {
return r === void 0 && (r = {
x: 0,
y: 0
}), {
top: e.top - t.height - r.y,
right: e.right - t.width + r.x,
bottom: e.bottom - t.height + r.y,
left: e.left - t.width - r.x
};
}
function ft(e) {
return [R, $, S, D].some(function(t) {
return e[t] >= 0;
});
}
function Tr(e) {
var t = e.state, r = e.name, n = t.rects.reference, o = t.rects.popper, i = t.modifiersData.preventOverflow, l = le(t, {
elementContext: "reference"
}), s = le(t, {
altBoundary: !0
}), a = st(l, n), c = st(s, o, i), f = ft(a), p = ft(c);
t.modifiersData[r] = {
referenceClippingOffsets: a,
popperEscapeOffsets: c,
isReferenceHidden: f,
hasPopperEscaped: p
}, t.attributes.popper = Object.assign({}, t.attributes.popper, {
"data-popper-reference-hidden": f,
"data-popper-escaped": p
});
}
const Cr = {
name: "hide",
enabled: !0,
phase: "main",
requiresIfExists: ["preventOverflow"],
fn: Tr
};
function Rr(e, t, r) {
var n = M(e), o = [D, R].indexOf(n) >= 0 ? -1 : 1, i = typeof r == "function" ? r(Object.assign({}, t, {
placement: e
})) : r, l = i[0], s = i[1];
return l = l || 0, s = (s || 0) * o, [D, $].indexOf(n) >= 0 ? {
x: s,
y: l
} : {
x: l,
y: s
};
}
function Dr(e) {
var t = e.state, r = e.options, n = e.name, o = r.offset, i = o === void 0 ? [0, 0] : o, l = vt.reduce(function(f, p) {
return f[p] = Rr(p, t.rects, i), f;
}, {}), s = l[t.placement], a = s.x, c = s.y;
t.modifiersData.popperOffsets != null && (t.modifiersData.popperOffsets.x += a, t.modifiersData.popperOffsets.y += c), t.modifiersData[n] = l;
}
const Br = {
name: "offset",
enabled: !0,
phase: "main",
requires: ["popperOffsets"],
fn: Dr
};
function jr(e) {
var t = e.state, r = e.name;
t.modifiersData[r] = xt({
reference: t.rects.reference,
element: t.rects.popper,
placement: t.placement
});
}
const Lr = {
name: "popperOffsets",
enabled: !0,
phase: "read",
fn: jr,
data: {}
};
function Sr(e) {
return e === "x" ? "y" : "x";
}
function $r(e) {
var t = e.state, r = e.options, n = e.name, o = r.mainAxis, i = o === void 0 ? !0 : o, l = r.altAxis, s = l === void 0 ? !1 : l, a = r.boundary, c = r.rootBoundary, f = r.altBoundary, p = r.padding, w = r.tether, v = w === void 0 ? !0 : w, u = r.tetherOffset, d = u === void 0 ? 0 : u, m = le(t, {
boundary: a,
rootBoundary: c,
padding: p,
altBoundary: f
}), b = M(t.placement), g = te(t.placement), y = !g, h = Me(b), x = Sr(h), O = t.modifiersData.popperOffsets, E = t.rects.reference, k = t.rects.popper, A = typeof d == "function" ? d(Object.assign({}, t.rects, {
placement: t.placement
})) : d, P = typeof A == "number" ? {
mainAxis: A,
altAxis: A
} : Object.assign({
mainAxis: 0,
altAxis: 0
}, A), T = t.modifiersData.offset ? t.modifiersData.offset[t.placement] : null, W = {
x: 0,
y: 0
};
if (O) {
if (i) {
var C, q = h === "y" ? R : D, z = h === "y" ? S : $, B = h === "y" ? "height" : "width", H = O[h], pe = H + m[q], U = H - m[z], de = v ? -k[B] / 2 : 0, Pe = g === Z ? E[B] : k[B], re = g === Z ? -k[B] : -E[B], ve = t.elements.arrow, K = v && ve ? He(ve) : {
width: 0,
height: 0
}, I = t.modifiersData["arrow#persistent"] ? t.modifiersData["arrow#persistent"].padding : gt(), ne = I[q], me = I[z], X = ie(0, E[B], K[B]), Ae = y ? E[B] / 2 - de - X - ne - P.mainAxis : Pe - X - ne - P.mainAxis, Ot = y ? -E[B] / 2 + de + X + me + P.mainAxis : re + X + me + P.mainAxis, ke = t.elements.arrow && ue(t.elements.arrow), Et = ke ? h === "y" ? ke.clientTop || 0 : ke.clientLeft || 0 : 0, Fe = (C = T == null ? void 0 : T[h]) != null ? C : 0, Pt = H + Ae - Fe - Et, At = H + Ot - Fe, qe = ie(v ? Oe(pe, Pt) : pe, H, v ? G(U, At) : U);
O[h] = qe, W[h] = qe - H;
}
if (s) {
var ze, kt = h === "x" ? R : D, Tt = h === "x" ? S : $, Y = O[x], he = x === "y" ? "height" : "width", Ue = Y + m[kt], Xe = Y - m[Tt], Te = [R, D].indexOf(b) !== -1, Ye = (ze = T == null ? void 0 : T[x]) != null ? ze : 0, Ge = Te ? Ue : Y - E[he] - k[he] - Ye + P.altAxis, Je = Te ? Y + E[he] + k[he] - Ye - P.altAxis : Xe, Ke = v && Te ? ar(Ge, Y, Je) : ie(v ? Ge : Ue, Y, v ? Je : Xe);
O[x] = Ke, W[x] = Ke - Y;
}
t.modifiersData[n] = W;
}
}
const Wr = {
name: "preventOverflow",
enabled: !0,
phase: "main",
fn: $r,
requiresIfExists: ["offset"]
};
function Hr(e) {
return {
scrollLeft: e.scrollLeft,
scrollTop: e.scrollTop
};
}
function Mr(e) {
return e === j(e) || !L(e) ? Ne(e) : Hr(e);
}
function Nr(e) {
var t = e.getBoundingClientRect(), r = _(t.width) / e.offsetWidth || 1, n = _(t.height) / e.offsetHeight || 1;
return r !== 1 || n !== 1;
}
function Vr(e, t, r) {
r === void 0 && (r = !1);
var n = L(t), o = L(t) && Nr(t), i = F(t), l = ee(e, o, r), s = {
scrollLeft: 0,
scrollTop: 0
}, a = {
x: 0,
y: 0
};
return (n || !n && !r) && ((N(t) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
Ie(i)) && (s = Mr(t)), L(t) ? (a = ee(t, !0), a.x += t.clientLeft, a.y += t.clientTop) : i && (a.x = Ve(i))), {
x: l.left + s.scrollLeft - a.x,
y: l.top + s.scrollTop - a.y,
width: l.width,
height: l.height
};
}
function Ir(e) {
var t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), n = [];
e.forEach(function(i) {
t.set(i.name, i);
});
function o(i) {
r.add(i.name);
var l = [].concat(i.requires || [], i.requiresIfExists || []);
l.forEach(function(s) {
if (!r.has(s)) {
var a = t.get(s);
a && o(a);
}
}), n.push(i);
}
return e.forEach(function(i) {
r.has(i.name) || o(i);
}), n;
}
function Fr(e) {
var t = Ir(e);
return _t.reduce(function(r, n) {
return r.concat(t.filter(function(o) {
return o.phase === n;
}));
}, []);
}
function qr(e) {
var t;
return function() {
return t || (t = new Promise(function(r) {
Promise.resolve().then(function() {
t = void 0, r(e());
});
})), t;
};
}
function zr(e) {
var t = e.reduce(function(r, n) {
var o = r[n.name];
return r[n.name] = o ? Object.assign({}, o, n, {
options: Object.assign({}, o.options, n.options),
data: Object.assign({}, o.data, n.data)
}) : n, r;
}, {});
return Object.keys(t).map(function(r) {
return t[r];
});
}
var lt = {
placement: "bottom",
modifiers: [],
strategy: "absolute"
};
function ct() {
for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
t[r] = arguments[r];
return !t.some(function(n) {
return !(n && typeof n.getBoundingClientRect == "function");
});
}
function Ur(e) {
e === void 0 && (e = {});
var t = e, r = t.defaultModifiers, n = r === void 0 ? [] : r, o = t.defaultOptions, i = o === void 0 ? lt : o;
return function(s, a, c) {
c === void 0 && (c = i);
var f = {
placement: "bottom",
orderedModifiers: [],
options: Object.assign({}, lt, i),
modifiersData: {},
elements: {
reference: s,
popper: a
},
attributes: {},
styles: {}
}, p = [], w = !1, v = {
state: f,
setOptions: function(b) {
var g = typeof b == "function" ? b(f.options) : b;
d(), f.options = Object.assign({}, i, f.options, g), f.scrollParents = {
reference: J(s) ? se(s) : s.contextElement ? se(s.contextElement) : [],
popper: se(a)
};
var y = Fr(zr([].concat(n, f.options.modifiers)));
return f.orderedModifiers = y.filter(function(h) {
return h.enabled;
}), u(), v.update();
},
// Sync update – it will always be executed, even if not necessary. This
// is useful for low frequency updates where sync behavior simplifies the
// logic.
// For high frequency updates (e.g. `resize` and `scroll` events), always
// prefer the async Popper#update method
forceUpdate: function() {
if (!w) {
var b = f.elements, g = b.reference, y = b.popper;
if (ct(g, y)) {
f.rects = {
reference: Vr(g, ue(y), f.options.strategy === "fixed"),
popper: He(y)
}, f.reset = !1, f.placement = f.options.placement, f.orderedModifiers.forEach(function(P) {
return f.modifiersData[P.name] = Object.assign({}, P.data);
});
for (var h = 0; h < f.orderedModifiers.length; h++) {
if (f.reset === !0) {
f.reset = !1, h = -1;
continue;
}
var x = f.orderedModifiers[h], O = x.fn, E = x.options, k = E === void 0 ? {} : E, A = x.name;
typeof O == "function" && (f = O({
state: f,
options: k,
name: A,
instance: v
}) || f);
}
}
}
},
// Async and optimistically optimized update – it will not be executed if
// not necessary (debounced to run at most once-per-tick)
update: qr(function() {
return new Promise(function(m) {
v.forceUpdate(), m(f);
});
}),
destroy: function() {
d(), w = !0;
}
};
if (!ct(s, a))
return v;
v.setOptions(c).then(function(m) {
!w && c.onFirstUpdate && c.onFirstUpdate(m);
});
function u() {
f.orderedModifiers.forEach(function(m) {
var b = m.name, g = m.options, y = g === void 0 ? {} : g, h = m.effect;
if (typeof h == "function") {
var x = h({
state: f,
name: b,
instance: v,
options: y
}), O = function() {
};
p.push(x || O);
}
});
}
function d() {
p.forEach(function(m) {
return m();
}), p = [];
}
return v;
};
}
var Xr = [mr, Lr, dr, rr, Br, kr, Wr, lr, Cr], Yr = /* @__PURE__ */ Ur({
defaultModifiers: Xr
});
function Gr(e, t = [0, 8], r, n = {}) {
const o = oe(null), i = oe(null), l = oe(null), s = oe(e), a = oe(!1);
let c = null, f = null;
const p = () => {
c && (clearTimeout(c), c = null), f && (clearTimeout(f), f = null);
}, w = async () => {
var g;
o.value && i.value && ((g = l.value) == null || g.destroy(), await Ce(), l.value = Yr(o.value, i.value, {
placement: e,
strategy: "absolute",
modifiers: [
{
name: "offset",
options: {
offset: t
}
},
{
name: "preventOverflow",
options: {
boundary: "viewport",
padding: 8
}
},
{
name: "flip",
options: {
fallbackPlacements: ["top", "bottom", "left", "right"]
}
},
{
name: "arrow",
options: {
element: ".tooltip-arrow",
padding: 8
}
},
{
name: "updateActualPlacement",
enabled: !0,
phase: "afterWrite",
fn({ state: y }) {
s.value = y.placement;
}
}
]
}));
}, v = async () => {
p(), a.value || (c = window.setTimeout(
async () => {
var g;
a.value = !0, await Ce(), i.value && (await w(), (g = n.onShow) == null || g.call(n), setTimeout(() => {
var y;
(y = l.value) == null || y.forceUpdate();
}, 0));
},
r === "hover" ? 150 : 0
));
}, u = () => {
p(), a.value && (f = window.setTimeout(
() => {
var g, y;
a.value = !1, (g = l.value) == null || g.destroy(), l.value = null, (y = n.onHide) == null || y.call(n);
},
r === "hover" ? 100 : 0
));
}, d = () => {
a.value ? u() : v();
}, m = () => {
var g;
(g = l.value) == null || g.forceUpdate();
}, b = () => {
p(), l.value && (l.value.destroy(), l.value = null);
};
return ut(async () => {
var g, y, h;
await Ce(), r === "click" && ((g = o.value) == null || g.addEventListener("click", d)), r === "hover" && ((y = o.value) == null || y.addEventListener("mouseenter", v), (h = o.value) == null || h.addEventListener("mouseleave", u)), It(i, () => {
a.value && r === "click" && u();
});
}), Ct(() => {
var g, y, h;
b(), r === "click" && ((g = o.value) == null || g.removeEventListener("click", d)), r === "hover" && ((y = o.value) == null || y.removeEventListener("mouseenter", v), (h = o.value) == null || h.removeEventListener("mouseleave", u));
}), Rt(
() => e,
() => {
a.value && w();
}
), {
triggerRef: o,
containerRef: i,
popperInstance: l,
actualPlacement: s,
isOpen: a,
initializePopper: w,
updatePopper: m,
destroyPopper: b,
showTooltip: v,
hideTooltip: u
};
}
const Jr = { class: "tooltip-wrapper" }, Kr = { class: "tooltip-content" }, Zr = /* @__PURE__ */ Dt({
__name: "ToolTip",
props: {
content: { default: "" },
placement: { default: "bottom-end" },
offset: { default: () => [0, 8] },
trigger: { default: "hover" },
arrow: { type: Boolean, default: !0 },
triggerClass: {},
className: {},
contentClass: {},
teleport: { type: Boolean, default: !0 },
styles: {}
},
emits: ["onShow", "onHide"],
setup(e, { emit: t }) {
const r = e, n = t, { triggerRef: o, containerRef: i, actualPlacement: l, initializePopper: s, destroyPopper: a, isOpen: c } = Gr(r.placement, r.offset, r.trigger, {
onShow: () => n("onShow"),
onHide: () => n("onHide")
}), f = Bt(() => {
if (!r.arrow) return "";
const p = l.value;
return p.includes("top") ? "tooltip-arrow--bottom" : p.includes("bottom") ? "tooltip-arrow--top" : p.includes("left") ? "tooltip-arrow--right" : p.includes("right") ? "tooltip-arrow--left" : "tooltip-arrow--top";
});
return ut(() => {
s();
}), jt(() => {
a();
}), (p, w) => (ge(), Re("div", Jr, [
Qe("span", {
ref_key: "triggerRef",
ref: o,
class: Be(["tooltip-trigger", p.triggerClass])
}, [
Ze(p.$slots, "trigger", _e(et({ isOpen: ye(c) })))
], 2),
ye(c) ? (ge(), Lt(St(p.teleport ? $t : "div"), {
key: 0,
to: "body"
}, {
default: Wt(() => [
ye(c) ? (ge(), Re("div", {
key: 0,
style: Ht(p.styles),
ref_key: "containerRef",
ref: i,
class: Be(["tooltip-container tooltip-container--open", p.className]),
role: "tooltip",
"aria-hidden": "true"
}, [
Qe("div", Kr, [
Ze(p.$slots, "default", _e(et({ isOpen: ye(c) })), () => [
Mt(Nt(p.content), 1)
])
]),
p.arrow ? (ge(), Re("div", {
key: 0,
class: Be(["tooltip-arrow", f.value])
}, null, 2)) : De("", !0)
], 6)) : De("", !0)
]),
_: 3
})) : De("", !0)
]));
}
});
export {
Zr as default
};