UNPKG

xtreme-ui

Version:

Collection of reusable components that can be used in web projects

39 lines (38 loc) 1.72 kB
const c = typeof window < "u", o = c ? window : void 0, f = c ? document : void 0, g = c ? localStorage : void 0, s = (n, e) => c ? getComputedStyle((e == null ? void 0 : e.current) || document.documentElement).getPropertyValue(n) : "", h = (n, e) => parseInt(s(n, e).replace(/px/g, "")), b = (n, e) => { const t = parseInt(s(n, e).replace(/vh/g, "")); return [((o == null ? void 0 : o.innerHeight) ?? 0) * t / 100, t]; }, l = (n, e) => { const t = parseInt(s(n, e).replace(/vw/g, "")); return [((o == null ? void 0 : o.innerWidth) ?? 0) * t / 100, t]; }, P = (n, e, t) => c ? ((t == null ? void 0 : t.current) || document.documentElement).style.setProperty(n, e) : "", w = (n) => new Promise((e) => { let t = document.querySelector(n); if (t) return e(t); const r = new MutationObserver(() => { t = document.querySelector(n), t && (e(t), r.disconnect()); }); r.observe(document.body, { childList: !0, subtree: !0 }); }), C = (n, e) => { var t; (t = e == null ? void 0 : e.forEach) == null || t.call(e, (r) => { let d; new MutationObserver((u) => { var a; document.querySelector(r) && (d = document.querySelector(r)), (a = u == null ? void 0 : u.forEach) == null || a.call(u, (i) => { i.type === "childList" && (Array.from(i.addedNodes).indexOf(d) > -1 && n(d, "added", i), Array.from(i.removedNodes).indexOf(d) > -1 && n(d, "removed", i)); }); }).observe(document.body, { childList: !0, subtree: !0 }); }); }; export { f as doc, C as elementObserver, s as getCssProperty, h as getCssPropertyPx, b as getCssPropertyVh, l as getCssPropertyVw, c as isClient, g as localStore, P as setCssProperty, w as waitForElement, o as win };