@vrembem/drawer
Advanced tools
Comparing version 4.0.0-next.15 to 4.0.0-next.16
@@ -194,3 +194,8 @@ var __typeError = (msg) => { | ||
} | ||
function cssVar(property, el = document.body) { | ||
function cssVar(property, options) { | ||
const settings = { | ||
fallback: null, | ||
element: document.body, | ||
...options | ||
}; | ||
if (property.slice(0, 2) !== "--") { | ||
@@ -203,7 +208,11 @@ const prefixValue = getPrefix(); | ||
} | ||
const cssValue = getComputedStyle(el).getPropertyValue(property).trim(); | ||
const cssValue = getComputedStyle(settings.element).getPropertyValue(property).trim(); | ||
if (cssValue) { | ||
return cssValue; | ||
} else { | ||
throw new Error(`CSS variable "${property}" was not found!`); | ||
if (settings.fallback) { | ||
return settings.fallback; | ||
} else { | ||
throw new Error(`CSS variable "${property}" was not found!`); | ||
} | ||
} | ||
@@ -237,3 +246,3 @@ } | ||
if (typeof duration === "string") { | ||
const cssValue = cssVar(duration, el); | ||
const cssValue = cssVar(duration, { element: el }); | ||
const ms = cssValue.includes("ms") ? true : false; | ||
@@ -240,0 +249,0 @@ duration = parseFloat(cssValue) * (ms ? 1 : 1e3); |
@@ -5,3 +5,3 @@ var x = (t) => { | ||
var C = (t, i, e) => i.has(t) || x("Cannot " + e); | ||
var l = (t, i, e) => (C(t, i, "read from private field"), e ? e.call(t) : i.get(t)), f = (t, i, e) => i.has(t) ? x("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(t) : i.set(t, e), u = (t, i, e, s) => (C(t, i, "write to private field"), s ? s.call(t, e) : i.set(t, e), e); | ||
var r = (t, i, e) => (C(t, i, "read from private field"), e ? e.call(t) : i.get(t)), f = (t, i, e) => i.has(t) ? x("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(t) : i.set(t, e), u = (t, i, e, s) => (C(t, i, "write to private field"), s ? s.call(t, e) : i.set(t, e), e); | ||
var c; | ||
@@ -14,13 +14,13 @@ class D { | ||
get handler() { | ||
return l(this, c); | ||
return r(this, c); | ||
} | ||
// Unmount existing handler before setting a new one. | ||
set handler(i) { | ||
this.mql && this.mql.removeEventListener("change", l(this, c)), u(this, c, i); | ||
this.mql && this.mql.removeEventListener("change", r(this, c)), u(this, c, i); | ||
} | ||
mount(i, e) { | ||
return i && (this.value = i), e && u(this, c, e), this.value ? (this.mql = window.matchMedia(`(min-width: ${this.value})`), this.mql.addEventListener("change", l(this, c)), l(this, c).call(this, this.mql), this) : this; | ||
return i && (this.value = i), e && u(this, c, e), this.value ? (this.mql = window.matchMedia(`(min-width: ${this.value})`), this.mql.addEventListener("change", r(this, c)), r(this, c).call(this, this.mql), this) : this; | ||
} | ||
unmount() { | ||
return this.mql ? (this.mql.removeEventListener("change", l(this, c)), this.value = null, u(this, c, null), this.mql = null, this) : this; | ||
return this.mql ? (this.mql.removeEventListener("change", r(this, c)), this.value = null, u(this, c, null), this.mql = null, this) : this; | ||
} | ||
@@ -91,6 +91,6 @@ } | ||
get focusable() { | ||
return l(this, b); | ||
return r(this, b); | ||
} | ||
set focusable(i) { | ||
u(this, b, i), l(this, b).length ? (document.removeEventListener("keydown", l(this, m)), document.addEventListener("keydown", l(this, g))) : (document.removeEventListener("keydown", l(this, g)), document.addEventListener("keydown", l(this, m))); | ||
u(this, b, i), r(this, b).length ? (document.removeEventListener("keydown", r(this, m)), document.addEventListener("keydown", r(this, g))) : (document.removeEventListener("keydown", r(this, g)), document.addEventListener("keydown", r(this, m))); | ||
} | ||
@@ -107,3 +107,3 @@ get focusableFirst() { | ||
unmount() { | ||
this.el = null, this.focusable = [], document.removeEventListener("keydown", l(this, g)), document.removeEventListener("keydown", l(this, m)); | ||
this.el = null, this.focusable = [], document.removeEventListener("keydown", r(this, g)), document.removeEventListener("keydown", r(this, m)); | ||
} | ||
@@ -115,4 +115,4 @@ focus(i = this.el, e = this.selectorFocus) { | ||
const e = [], s = document.activeElement, n = i.scrollTop; | ||
return i.querySelectorAll(P.join(",")).forEach((r) => { | ||
r.focus(), document.activeElement === r && e.push(r); | ||
return i.querySelectorAll(P.join(",")).forEach((l) => { | ||
l.focus(), document.activeElement === l && e.push(l); | ||
}), i.scrollTop = n, s.focus(), e; | ||
@@ -131,10 +131,17 @@ } | ||
} | ||
function V(t, i = document.body) { | ||
function V(t, i) { | ||
const e = { | ||
fallback: null, | ||
element: document.body, | ||
...i | ||
}; | ||
if (t.slice(0, 2) !== "--") { | ||
const s = T(); | ||
s && (t = `${s}${t}`), t = `--${t}`; | ||
const n = T(); | ||
n && (t = `${n}${t}`), t = `--${t}`; | ||
} | ||
const e = getComputedStyle(i).getPropertyValue(t).trim(); | ||
if (e) | ||
return e; | ||
const s = getComputedStyle(e.element).getPropertyValue(t).trim(); | ||
if (s) | ||
return s; | ||
if (e.fallback) | ||
return e.fallback; | ||
throw new Error(`CSS variable "${t}" was not found!`); | ||
@@ -160,4 +167,4 @@ } | ||
if (typeof s == "string") { | ||
const h = V(s, t), r = !!h.includes("ms"); | ||
s = parseFloat(h) * (r ? 1 : 1e3); | ||
const h = V(s, { element: t }), l = !!h.includes("ms"); | ||
s = parseFloat(h) * (l ? 1 : 1e3); | ||
} | ||
@@ -330,3 +337,3 @@ t.classList.remove(i.finish), t.classList.add(e.start), setTimeout(() => { | ||
let n, h = "indeterminate"; | ||
const r = { | ||
const l = { | ||
id: t.id, | ||
@@ -383,5 +390,5 @@ el: t, | ||
}; | ||
this.collection.push(r); | ||
const k = t.querySelector(r.getSetting("selectorDialog")); | ||
return r.dialog = k || t, r.getSetting("setTabindex") && r.dialog.setAttribute("tabindex", "-1"), await J(r), r.inlineState = r.state, r.mode = t.classList.contains(r.getSetting("classModal")) ? "modal" : "inline", r.breakpoint && r.mountBreakpoint(), r; | ||
this.collection.push(l); | ||
const k = t.querySelector(l.getSetting("selectorDialog")); | ||
return l.dialog = k || t, l.getSetting("setTabindex") && l.dialog.setAttribute("tabindex", "-1"), await J(l), l.inlineState = l.state, l.mode = t.classList.contains(l.getSetting("classModal")) ? "modal" : "inline", l.breakpoint && l.mountBreakpoint(), l; | ||
} | ||
@@ -408,6 +415,6 @@ var w, v; | ||
mountEventListeners() { | ||
document.addEventListener("click", l(this, w), !1), document.addEventListener("keydown", l(this, v), !1); | ||
document.addEventListener("click", r(this, w), !1), document.addEventListener("keydown", r(this, v), !1); | ||
} | ||
unmountEventListeners() { | ||
document.removeEventListener("click", l(this, w), !1), document.removeEventListener("keydown", l(this, v), !1); | ||
document.removeEventListener("click", r(this, w), !1), document.removeEventListener("keydown", r(this, v), !1); | ||
} | ||
@@ -414,0 +421,0 @@ register(e, s = {}) { |
{ | ||
"name": "@vrembem/drawer", | ||
"description": "A container component that slides in from the left or right. Typically containing menus, search or other content.", | ||
"version": "4.0.0-next.15", | ||
"version": "4.0.0-next.16", | ||
"license": "MIT", | ||
@@ -53,3 +53,3 @@ "type": "module", | ||
"dependencies": { | ||
"@vrembem/core": "^4.0.0-next.15" | ||
"@vrembem/core": "^4.0.0-next.16" | ||
}, | ||
@@ -59,3 +59,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "379930fa4d7186167507abde8418ba276e8f02b7" | ||
"gitHead": "398444c4984269f047211386bb8402be8aa429c8" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
325355
2935
Updated@vrembem/core@^4.0.0-next.16