@flexilla/offcanvas
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -1,12 +0,1 @@ | ||
declare type BackdropHidden = { | ||
visibility: "hidden"; | ||
}; | ||
declare type BackdropOptions = BackdropVisible | BackdropHidden; | ||
declare type BackdropVisible = { | ||
visibility: "visible"; | ||
backdropClass: string; | ||
}; | ||
/** | ||
@@ -21,3 +10,2 @@ * Class representing an Offcanvas element. | ||
private staticBackdrop; | ||
private backdropClass; | ||
private backdrop; | ||
@@ -65,3 +53,3 @@ private options; | ||
allowBodyScroll?: boolean; | ||
backdrop?: BackdropOptions; | ||
backdrop?: string; | ||
beforeHide?: () => { | ||
@@ -68,0 +56,0 @@ cancelAction?: boolean; |
@@ -1,5 +0,5 @@ | ||
var p = Object.defineProperty; | ||
var E = (e, t, s) => t in e ? p(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s; | ||
var l = (e, t, s) => E(e, typeof t != "symbol" ? t + "" : t, s); | ||
const d = (e, t = document.body) => t.querySelector(e), f = (e, t = document.body) => Array.from(t.querySelectorAll(e)), b = ({ | ||
var E = Object.defineProperty; | ||
var p = (e, t, s) => t in e ? E(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s; | ||
var o = (e, t, s) => p(e, typeof t != "symbol" ? t + "" : t, s); | ||
const d = (e, t = document.body) => t.querySelector(e), r = (e, t = document.body) => Array.from(t.querySelectorAll(e)), b = ({ | ||
newElement: e, | ||
@@ -19,8 +19,8 @@ existingElement: t | ||
}) => { | ||
const i = getComputedStyle(e), o = s === "transition" ? i.transition : i.animation; | ||
if (o !== "none" && o !== "" && !a.includes(o)) { | ||
const n = s === "transition" ? "transitionend" : "animationend", r = () => { | ||
e.removeEventListener(n, r), t(); | ||
const n = getComputedStyle(e), i = s === "transition" ? n.transition : n.animation; | ||
if (i !== "none" && i !== "" && !a.includes(i)) { | ||
const l = s === "transition" ? "transitionend" : "animationend", f = () => { | ||
e.removeEventListener(l, f), t(); | ||
}; | ||
e.addEventListener(n, r, { once: !0 }); | ||
e.addEventListener(l, f, { once: !0 }); | ||
} else | ||
@@ -39,12 +39,2 @@ t(); | ||
}, k = (e) => { | ||
if (!e) return { backdropClass: "", isHidden: !1 }; | ||
const { visibility: t } = e; | ||
if (t === "hidden") | ||
return { | ||
backdropClass: "", | ||
isHidden: !0 | ||
}; | ||
const { backdropClass: s } = e; | ||
return { backdropClass: s || "", isHidden: !1 }; | ||
}, O = (e) => { | ||
var t; | ||
@@ -56,18 +46,17 @@ return (t = e.parentElement) == null ? void 0 : t.removeChild(e); | ||
callback() { | ||
O(e); | ||
k(e); | ||
} | ||
}); | ||
}, A = (e, t, s) => { | ||
if (!e) return; | ||
const { backdropClass: a, isHidden: i } = k(e), o = a !== "" && a || t; | ||
if (o === "" || i) return; | ||
const n = document.createElement("div"); | ||
if (n.setAttribute("aria-hidden", "true"), n.setAttribute("data-state", "visible"), n.setAttribute("data-fx-offcanvas-overlay", ""), n.setAttribute("data-offcanvas-el", s), o === "") return; | ||
const r = o.split(" "); | ||
return o !== "" && n.classList.add(...r), n; | ||
}, v = (e, t, s) => { | ||
e.setAttribute("aria-hidden", s === "open" ? "false" : "true"), e.setAttribute("data-state", s), t || w(s); | ||
}, w = (e) => { | ||
}, O = (e, t) => { | ||
const s = e; | ||
if (s === "" || !s) return; | ||
const a = document.createElement("div"); | ||
if (a.setAttribute("aria-hidden", "true"), a.setAttribute("data-state", "visible"), a.setAttribute("data-fx-offcanvas-overlay", ""), a.setAttribute("data-offcanvas-el", t), s === "") return; | ||
const n = s.split(" "); | ||
return s !== "" && a.classList.add(...n), a; | ||
}, h = (e, t, s) => { | ||
e.setAttribute("aria-hidden", s === "open" ? "false" : "true"), e.setAttribute("data-state", s), t || A(s); | ||
}, A = (e) => { | ||
document.body.style.overflow = e === "open" ? "hidden" : "", document.body.style.overflowY = e === "open" ? "hidden" : "auto"; | ||
}, B = (e, t) => { | ||
}, w = (e, t) => { | ||
if (e === t) return; | ||
@@ -77,6 +66,6 @@ e.setAttribute("aria-hidden", "true"), e.setAttribute("data-state", "close"); | ||
s instanceof HTMLElement && u(s); | ||
}, S = (e) => { | ||
const t = f("[data-fx-offcanvas][data-state=open]"); | ||
}, B = (e) => { | ||
const t = r("[data-fx-offcanvas][data-state=open]"); | ||
if (!(t.length <= 0)) | ||
for (const s of t) B(s, e); | ||
for (const s of t) w(s, e); | ||
}, c = class c { | ||
@@ -89,19 +78,18 @@ /** | ||
constructor(t, s = {}) { | ||
l(this, "offCanvasElement"); | ||
l(this, "offCanvasTriggers"); | ||
l(this, "offCanvasCloseBtns"); | ||
l(this, "allowBodyScroll"); | ||
l(this, "staticBackdrop"); | ||
l(this, "backdropClass"); | ||
l(this, "backdrop"); | ||
l(this, "options"); | ||
l(this, "closeOffCanvas", () => { | ||
var i, o, n, r, h; | ||
if ((n = (o = (i = this.options).beforeHide) == null ? void 0 : o.call(i)) == null ? void 0 : n.cancelAction) return; | ||
o(this, "offCanvasElement"); | ||
o(this, "offCanvasTriggers"); | ||
o(this, "offCanvasCloseBtns"); | ||
o(this, "allowBodyScroll"); | ||
o(this, "staticBackdrop"); | ||
o(this, "backdrop"); | ||
o(this, "options"); | ||
o(this, "closeOffCanvas", () => { | ||
var n, i, l, f, v; | ||
if ((l = (i = (n = this.options).beforeHide) == null ? void 0 : i.call(n)) == null ? void 0 : l.cancelAction) return; | ||
const s = this.offCanvasElement.getAttribute("id"), a = d(`[data-fx-offcanvas-overlay][data-offcanvas-el=${s}]`); | ||
a instanceof HTMLElement && u(a), v( | ||
a instanceof HTMLElement && u(a), h( | ||
this.offCanvasElement, | ||
this.allowBodyScroll, | ||
"close" | ||
), document.removeEventListener("keydown", this.closeWithEsc), !this.allowBodyScroll && !a && document.removeEventListener("click", (C) => this.closeWhenClickOutSide(C)), (h = (r = this.options).onHide) == null || h.call(r); | ||
), document.removeEventListener("keydown", this.closeWithEsc), !this.allowBodyScroll && !a && document.removeEventListener("click", (C) => this.closeWhenClickOutSide(C)), (v = (f = this.options).onHide) == null || v.call(f); | ||
}); | ||
@@ -111,3 +99,3 @@ /** | ||
*/ | ||
l(this, "closeWithEsc", (t) => { | ||
o(this, "closeWithEsc", (t) => { | ||
t.key === "Escape" && this.closeOffCanvas(); | ||
@@ -118,9 +106,9 @@ }); | ||
this.options = s; | ||
const { staticBackdrop: i, allowBodyScroll: o, backdrop: n } = this.options; | ||
this.offCanvasElement = a, this.setupAttributes(), this.staticBackdrop = i || a.hasAttribute("data-static-backdrop") && a.dataset.staticBackdrop !== "false" || !1, this.allowBodyScroll = o || a.hasAttribute("data-allow-body-scroll") && a.dataset.allowBodyScroll !== "false" || !1; | ||
const r = this.offCanvasElement.getAttribute("id"); | ||
this.offCanvasTriggers = this.findOffCanvasElements("[data-offcanvas-trigger]", !1, r), this.offCanvasCloseBtns = this.findOffCanvasElements("[data-offcanvas-close]", !0, r, this.offCanvasElement), this.backdrop = n, this.backdropClass = this.offCanvasElement.dataset.offcanvasBackdrop || "", this.setupOffcanvas(); | ||
const { staticBackdrop: n, allowBodyScroll: i, backdrop: l } = this.options; | ||
this.offCanvasElement = a, this.setupAttributes(), this.staticBackdrop = n || a.hasAttribute("data-static-backdrop") && a.dataset.staticBackdrop !== "false" || !1, this.allowBodyScroll = i || a.hasAttribute("data-allow-body-scroll") && a.dataset.allowBodyScroll !== "false" || !1; | ||
const f = this.offCanvasElement.getAttribute("id"); | ||
this.offCanvasTriggers = this.findOffCanvasElements("[data-offcanvas-trigger]", !1, f), this.offCanvasCloseBtns = this.findOffCanvasElements("[data-offcanvas-close]", !0, f, this.offCanvasElement), this.backdrop = l || this.offCanvasElement.dataset.offcanvasBackdrop || "", this.setupOffcanvas(); | ||
} | ||
findOffCanvasElements(t, s, a, i) { | ||
return s ? f(`${t}`, i) : f(`${t}[data-target=${a}]`); | ||
findOffCanvasElements(t, s, a, n) { | ||
return s ? r(`${t}`, n) : r(`${t}[data-target=${a}]`); | ||
} | ||
@@ -138,4 +126,4 @@ setupAttributes() { | ||
openOffCanvas() { | ||
var a, i, o, n; | ||
(i = (a = this.options).beforeShow) == null || i.call(a), S(this.offCanvasElement), v( | ||
var a, n, i, l; | ||
(n = (a = this.options).beforeShow) == null || n.call(a), B(this.offCanvasElement), h( | ||
this.offCanvasElement, | ||
@@ -145,8 +133,7 @@ this.allowBodyScroll, | ||
); | ||
const t = this.offCanvasElement.getAttribute("id"), s = A( | ||
const t = this.offCanvasElement.getAttribute("id"), s = O( | ||
this.backdrop, | ||
this.backdropClass, | ||
t | ||
); | ||
s instanceof HTMLElement && (b({ newElement: s, existingElement: this.offCanvasElement }), this.staticBackdrop || s.addEventListener("click", this.closeOffCanvas)), document.addEventListener("keydown", this.closeWithEsc), (n = (o = this.options).onShow) == null || n.call(o); | ||
s instanceof HTMLElement && (b({ newElement: s, existingElement: this.offCanvasElement }), this.staticBackdrop || s.addEventListener("click", this.closeOffCanvas)), document.addEventListener("keydown", this.closeWithEsc), (l = (i = this.options).onShow) == null || l.call(i); | ||
} | ||
@@ -176,4 +163,4 @@ initCloseBtns() { | ||
*/ | ||
l(c, "autoInit", (t = "[data-fx-offcanvas]") => { | ||
const s = f(t); | ||
o(c, "autoInit", (t = "[data-fx-offcanvas]") => { | ||
const s = r(t); | ||
for (const a of s) new c(a); | ||
@@ -185,3 +172,3 @@ }), /** | ||
*/ | ||
l(c, "init", (t, s = {}) => new c(t, s)); | ||
o(c, "init", (t, s = {}) => new c(t, s)); | ||
let m = c; | ||
@@ -188,0 +175,0 @@ export { |
{ | ||
"name": "@flexilla/offcanvas", | ||
"private": false, | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"type": "module", | ||
@@ -61,10 +61,9 @@ "description": "An offcanvas component for creating responsive and off-screen navigation panels in web applications.", | ||
"type": "git", | ||
"url": "https://github.com/unify-ui-dev/flexilla" | ||
"url": "https://github.com/unoforge/flexilla" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/unify-ui-dev/flexilla/issues" | ||
"url": "https://github.com/unoforge/flexilla/issues" | ||
}, | ||
"license": "MIT", | ||
"author": "johnkat-mj", | ||
"gitHead": "2eb26c556c72eb0c607dfc2de61b3ca6ef3128c9" | ||
"author": "johnkat-mj" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
16517
7
248