@anoki/fse-ui
Version:
FSE UI components library
138 lines (137 loc) • 3.53 kB
JavaScript
function u() {
return typeof window < "u";
}
function a(t) {
return m(t) ? (t.nodeName || "").toLowerCase() : "#document";
}
function i(t) {
var n;
return (t == null || (n = t.ownerDocument) == null ? void 0 : n.defaultView) || window;
}
function L(t) {
var n;
return (n = (m(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : n.documentElement;
}
function m(t) {
return u() ? t instanceof Node || t instanceof i(t).Node : !1;
}
function h(t) {
return u() ? t instanceof Element || t instanceof i(t).Element : !1;
}
function g(t) {
return u() ? t instanceof HTMLElement || t instanceof i(t).HTMLElement : !1;
}
function p(t) {
return !u() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof i(t).ShadowRoot;
}
function y(t) {
const {
overflow: n,
overflowX: r,
overflowY: c,
display: e
} = b(t);
return /auto|scroll|overlay|hidden|clip/.test(n + c + r) && e !== "inline" && e !== "contents";
}
function _(t) {
return /^(table|td|th)$/.test(a(t));
}
function T(t) {
try {
if (t.matches(":popover-open"))
return !0;
} catch {
}
try {
return t.matches(":modal");
} catch {
return !1;
}
}
const v = /transform|translate|scale|rotate|perspective|filter/, C = /paint|layout|strict|content/, o = (t) => !!t && t !== "none";
let s;
function D(t) {
const n = h(t) ? b(t) : t;
return o(n.transform) || o(n.translate) || o(n.scale) || o(n.rotate) || o(n.perspective) || !R() && (o(n.backdropFilter) || o(n.filter)) || v.test(n.willChange || "") || C.test(n.contain || "");
}
function W(t) {
let n = f(t);
for (; g(n) && !N(n); ) {
if (D(n))
return n;
if (T(n))
return null;
n = f(n);
}
return null;
}
function R() {
return s == null && (s = typeof CSS < "u" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none")), s;
}
function N(t) {
return /^(html|body|#document)$/.test(a(t));
}
function b(t) {
return i(t).getComputedStyle(t);
}
function $(t) {
return h(t) ? {
scrollLeft: t.scrollLeft,
scrollTop: t.scrollTop
} : {
scrollLeft: t.scrollX,
scrollTop: t.scrollY
};
}
function f(t) {
if (a(t) === "html")
return t;
const n = (
// Step into the shadow DOM of the parent of a slotted node.
t.assignedSlot || // DOM Element detected.
t.parentNode || // ShadowRoot detected.
p(t) && t.host || // Fallback.
L(t)
);
return p(n) ? n.host : n;
}
function S(t) {
const n = f(t);
return N(n) ? t.ownerDocument ? t.ownerDocument.body : t.body : g(n) && y(n) ? n : S(n);
}
function w(t, n, r) {
var c;
n === void 0 && (n = []), r === void 0 && (r = !0);
const e = S(t), E = e === ((c = t.ownerDocument) == null ? void 0 : c.body), l = i(e);
if (E) {
const d = k(l);
return n.concat(l, l.visualViewport || [], y(e) ? e : [], d && r ? w(d) : []);
} else
return n.concat(e, w(e, [], r));
}
function k(t) {
return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
}
export {
b as getComputedStyle,
W as getContainingBlock,
L as getDocumentElement,
k as getFrameElement,
S as getNearestOverflowAncestor,
a as getNodeName,
$ as getNodeScroll,
w as getOverflowAncestors,
f as getParentNode,
i as getWindow,
D as isContainingBlock,
h as isElement,
g as isHTMLElement,
N as isLastTraversableNode,
m as isNode,
y as isOverflowElement,
p as isShadowRoot,
_ as isTableElement,
T as isTopLayer,
R as isWebKit
};
//# sourceMappingURL=index.es804.js.map