2025-04-02 21:57:33 +08:00

84 lines
2.6 KiB
JavaScript

/*! NanoPop 2.4.2 MIT | https://github.com/Simonwep/nanopop */
const N = "2.4.2", I = {
variantFlipOrder: { start: "sme", middle: "mse", end: "ems" },
positionFlipOrder: { top: "tbrl", right: "rltb", bottom: "btrl", left: "lrbt" },
position: "bottom",
margin: 8,
padding: 0
}, J = (n, i, m) => {
const {
container: r,
arrow: a,
margin: e,
padding: l,
position: V,
variantFlipOrder: C,
positionFlipOrder: M
} = {
container: document.documentElement.getBoundingClientRect(),
...I,
...m
}, { left: F, top: K } = i.style;
i.style.left = "0", i.style.top = "0";
const t = n.getBoundingClientRect(), o = i.getBoundingClientRect(), P = {
t: t.top - o.height - e,
b: t.bottom + e,
r: t.right + e,
l: t.left - o.width - e
}, R = {
vs: t.left,
vm: t.left + t.width / 2 - o.width / 2,
ve: t.left + t.width - o.width,
hs: t.top,
hm: t.bottom - t.height / 2 - o.height / 2,
he: t.bottom - o.height
}, [$, E = "middle"] = V.split("-"), L = M[$], j = C[E], { top: y, left: x, bottom: B, right: O } = r;
for (const c of L) {
const s = c === "t" || c === "b";
let p = P[c];
const [d, g] = s ? ["top", "left"] : ["left", "top"], [u, v] = s ? [o.height, o.width] : [o.width, o.height], [z, T] = s ? [B, O] : [O, B], [H, k] = s ? [y, x] : [x, y];
if (!(p < H || p + u + l > z))
for (const b of j) {
let f = R[(s ? "v" : "h") + b];
if (!(f < k || f + v + l > T)) {
if (f -= o[g], p -= o[d], i.style[g] = `${f}px`, i.style[d] = `${p}px`, a) {
const w = s ? t.width / 2 : t.height / 2, h = v / 2, S = w > h, q = {
s: S ? h : w,
m: h,
e: S ? h : v - w
}, A = {
t: u,
b: 0,
r: 0,
l: u
}, D = f + q[b], G = p + A[c];
a.style[g] = `${D}px`, a.style[d] = `${G}px`;
}
return c + b;
}
}
}
return i.style.left = F, i.style.top = K, null;
}, Q = (n, i, m) => {
const r = typeof n == "object" && !(n instanceof HTMLElement) ? n : { reference: n, popper: i, ...m };
return {
/**
* Repositions the current popper.
* @param options Optional options which get merged with the current ones.
*/
update(a = r) {
const { reference: e, popper: l } = Object.assign(r, a);
if (!l || !e)
throw new Error("Popper- or reference-element missing.");
return J(e, l, r);
}
};
};
export {
Q as createPopper,
I as defaults,
J as reposition,
N as version
};
//# sourceMappingURL=nanopop.mjs.map