@flexilla/dismissible 2.0.7 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dismissible.js +20 -17
- package/dist/dismissible.umd.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/package.json +2 -2
package/dist/dismissible.js
CHANGED
|
@@ -7,12 +7,12 @@ const E = (s, e = document.body) => e.querySelector(s), r = (s, e = document.bod
|
|
|
7
7
|
type: t,
|
|
8
8
|
keysCheck: n
|
|
9
9
|
}) => {
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
s.removeEventListener(
|
|
10
|
+
const l = getComputedStyle(s), o = l.transition;
|
|
11
|
+
if (o !== "none" && o !== "" && !n.includes(o)) {
|
|
12
|
+
const d = "transitionend", a = () => {
|
|
13
|
+
s.removeEventListener(d, a), e();
|
|
14
14
|
};
|
|
15
|
-
s.addEventListener(
|
|
15
|
+
s.addEventListener(d, a, { once: !0 });
|
|
16
16
|
} else
|
|
17
17
|
e();
|
|
18
18
|
}, c = ({
|
|
@@ -25,7 +25,7 @@ const E = (s, e = document.body) => e.querySelector(s), r = (s, e = document.bod
|
|
|
25
25
|
type: "transition",
|
|
26
26
|
keysCheck: ["all 0s ease 0s", "all"]
|
|
27
27
|
});
|
|
28
|
-
},
|
|
28
|
+
}, m = class m {
|
|
29
29
|
/**
|
|
30
30
|
* Dismissible Component
|
|
31
31
|
* @param dismissible
|
|
@@ -61,22 +61,25 @@ const E = (s, e = document.body) => e.querySelector(s), r = (s, e = document.bod
|
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
|
-
const
|
|
65
|
-
if (!(
|
|
66
|
-
this.dismissibleElement =
|
|
64
|
+
const l = typeof e == "string" ? E(e, document.body) : e;
|
|
65
|
+
if (!(l instanceof HTMLElement)) throw new Error("Provided Element not a valid HTMLElement");
|
|
66
|
+
this.dismissibleElement = l, this.action = t || this.dismissibleElement.dataset.action || "hide-from-screen", this.dismissButtons = r("[data-dismiss-btn]", this.dismissibleElement), this.onDismiss = n, this.dismissibleElement.setAttribute("aria-hidden", "false"), this.setupDismissible();
|
|
67
67
|
}
|
|
68
68
|
setupDismissible() {
|
|
69
69
|
for (const e of this.dismissButtons)
|
|
70
70
|
e.addEventListener("click", this.dismiss);
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Cleanup method to remove event listeners
|
|
74
|
+
*/
|
|
75
|
+
cleanup() {
|
|
76
|
+
for (const e of this.dismissButtons)
|
|
77
|
+
e.removeEventListener("click", this.dismiss);
|
|
78
|
+
}
|
|
72
79
|
};
|
|
73
|
-
|
|
74
|
-
* auto init Dismissible Element based on the selector provided
|
|
75
|
-
* @param selector {string} default is [data-fx-dismissible]
|
|
76
|
-
*/
|
|
77
|
-
i(l, "autoInit", (e = "[data-fx-dismissible]") => {
|
|
80
|
+
i(m, "autoInit", (e = "[data-fx-dismissible]") => {
|
|
78
81
|
const t = r(e);
|
|
79
|
-
for (const n of t) new
|
|
82
|
+
for (const n of t) new m(n);
|
|
80
83
|
}), /**
|
|
81
84
|
*
|
|
82
85
|
* @param dismissible
|
|
@@ -84,8 +87,8 @@ i(l, "autoInit", (e = "[data-fx-dismissible]") => {
|
|
|
84
87
|
* @param onDissmiss
|
|
85
88
|
* @returns
|
|
86
89
|
*/
|
|
87
|
-
i(
|
|
88
|
-
let h =
|
|
90
|
+
i(m, "init", (e, t, n) => new m(e, t, n));
|
|
91
|
+
let h = m;
|
|
89
92
|
export {
|
|
90
93
|
h as Dismissible
|
|
91
94
|
};
|
package/dist/dismissible.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(i,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(i=typeof globalThis<"u"?globalThis:i||self,s(i["@flexilla/dismissible"]={}))})(this,function(i){"use strict";var E=Object.defineProperty;var y=(i,s,
|
|
1
|
+
(function(i,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(i=typeof globalThis<"u"?globalThis:i||self,s(i["@flexilla/dismissible"]={}))})(this,function(i){"use strict";var E=Object.defineProperty;var y=(i,s,o)=>s in i?E(i,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[s]=o;var t=(i,s,o)=>y(i,typeof s!="symbol"?s+"":s,o);const s=(n,e=document.body)=>e.querySelector(n),o=(n,e=document.body)=>Array.from(e.querySelectorAll(n)),f=({element:n,callback:e,type:l,keysCheck:d})=>{const a=getComputedStyle(n),c=a.transition;if(c!=="none"&&c!==""&&!d.includes(c)){const b="transitionend",u=()=>{n.removeEventListener(b,u),e()};n.addEventListener(b,u,{once:!0})}else e()},h=({element:n,callback:e})=>{f({element:n,callback:e,type:"transition",keysCheck:["all 0s ease 0s","all"]})},m=class m{constructor(e,l,d){t(this,"dismissibleElement");t(this,"dismissButtons");t(this,"action");t(this,"onDismiss");t(this,"hideFromScreen",()=>{var e;this.dismissibleElement.style.display="none",(e=this.onDismiss)==null||e.call(this)});t(this,"removeFromDom",()=>{var e,l;(e=this.onDismiss)==null||e.call(this),(l=this.dismissibleElement.parentElement)==null||l.removeChild(this.dismissibleElement)});t(this,"dismiss",()=>{switch(this.action){case"hide-from-screen":this.dismissibleElement.setAttribute("aria-hidden","true"),this.dismissibleElement.setAttribute("data-state","hidden"),h({element:this.dismissibleElement,callback:this.hideFromScreen});break;default:this.dismissibleElement.setAttribute("data-hidden",""),this.dismissibleElement.setAttribute("aria-hidden","true"),this.dismissibleElement.setAttribute("data-state","removed"),h({element:this.dismissibleElement,callback:this.removeFromDom});break}});const a=typeof e=="string"?s(e,document.body):e;if(!(a instanceof HTMLElement))throw new Error("Provided Element not a valid HTMLElement");this.dismissibleElement=a,this.action=l||this.dismissibleElement.dataset.action||"hide-from-screen",this.dismissButtons=o("[data-dismiss-btn]",this.dismissibleElement),this.onDismiss=d,this.dismissibleElement.setAttribute("aria-hidden","false"),this.setupDismissible()}setupDismissible(){for(const e of this.dismissButtons)e.addEventListener("click",this.dismiss)}cleanup(){for(const e of this.dismissButtons)e.removeEventListener("click",this.dismiss)}};t(m,"autoInit",(e="[data-fx-dismissible]")=>{const l=o(e);for(const d of l)new m(d)}),t(m,"init",(e,l,d)=>new m(e,l,d));let r=m;i.Dismissible=r,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ export declare class Dismissible {
|
|
|
15
15
|
dismiss: () => void;
|
|
16
16
|
private setupDismissible;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param selector {string} default is [data-fx-dismissible]
|
|
18
|
+
* Cleanup method to remove event listeners
|
|
20
19
|
*/
|
|
20
|
+
cleanup(): void;
|
|
21
21
|
static autoInit: (selector?: string) => void;
|
|
22
22
|
/**
|
|
23
23
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flexilla/dismissible",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A lightweight JavaScript component that automatically makes a component dismissible for easy user interaction.",
|
|
7
7
|
"publishConfig": {
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
},
|
|
62
62
|
"license": "MIT",
|
|
63
63
|
"author": "johnkat-mj",
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "e03f36f1dc6006668fd79949e0803fc2e08219c1"
|
|
65
65
|
}
|