@flexilla/dismissible 2.0.5 → 2.0.6
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 +24 -24
- package/dist/dismissible.umd.cjs +1 -1
- package/package.json +3 -6
package/dist/dismissible.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
var b = Object.defineProperty;
|
|
2
|
-
var u = (
|
|
3
|
-
var i = (
|
|
4
|
-
const E = (
|
|
5
|
-
element:
|
|
2
|
+
var u = (s, e, t) => e in s ? b(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var i = (s, e, t) => u(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
const E = (s, e = document.body) => e.querySelector(s), r = (s, e = document.body) => Array.from(e.querySelectorAll(s)), f = ({
|
|
5
|
+
element: s,
|
|
6
6
|
callback: e,
|
|
7
|
-
type:
|
|
7
|
+
type: t,
|
|
8
8
|
keysCheck: n
|
|
9
9
|
}) => {
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
|
|
10
|
+
const m = getComputedStyle(s), d = m.transition;
|
|
11
|
+
if (d !== "none" && d !== "" && !n.includes(d)) {
|
|
12
|
+
const o = "transitionend", a = () => {
|
|
13
|
+
s.removeEventListener(o, a), e();
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
s.addEventListener(o, a, { once: !0 });
|
|
16
16
|
} else
|
|
17
17
|
e();
|
|
18
18
|
}, c = ({
|
|
19
|
-
element:
|
|
19
|
+
element: s,
|
|
20
20
|
callback: e
|
|
21
21
|
}) => {
|
|
22
22
|
f({
|
|
23
|
-
element:
|
|
23
|
+
element: s,
|
|
24
24
|
callback: e,
|
|
25
25
|
type: "transition",
|
|
26
26
|
keysCheck: ["all 0s ease 0s", "all"]
|
|
27
27
|
});
|
|
28
|
-
},
|
|
28
|
+
}, l = class l {
|
|
29
29
|
/**
|
|
30
30
|
* Dismissible Component
|
|
31
31
|
* @param dismissible
|
|
32
32
|
* @param action
|
|
33
33
|
* @param onDissmiss
|
|
34
34
|
*/
|
|
35
|
-
constructor(e,
|
|
35
|
+
constructor(e, t, n) {
|
|
36
36
|
i(this, "dismissibleElement");
|
|
37
37
|
i(this, "dismissButtons");
|
|
38
38
|
i(this, "action");
|
|
@@ -42,8 +42,8 @@ const E = (t, e = document.body) => e.querySelector(t), r = (t, e = document.bod
|
|
|
42
42
|
this.dismissibleElement.style.display = "none", (e = this.onDismiss) == null || e.call(this);
|
|
43
43
|
});
|
|
44
44
|
i(this, "removeFromDom", () => {
|
|
45
|
-
var e,
|
|
46
|
-
(e = this.onDismiss) == null || e.call(this), (
|
|
45
|
+
var e, t;
|
|
46
|
+
(e = this.onDismiss) == null || e.call(this), (t = this.dismissibleElement.parentElement) == null || t.removeChild(this.dismissibleElement);
|
|
47
47
|
});
|
|
48
48
|
i(this, "dismiss", () => {
|
|
49
49
|
switch (this.action) {
|
|
@@ -61,9 +61,9 @@ const E = (t, e = document.body) => e.querySelector(t), r = (t, e = document.bod
|
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
|
-
const
|
|
65
|
-
if (!(
|
|
66
|
-
this.dismissibleElement =
|
|
64
|
+
const m = typeof e == "string" ? E(e, document.body) : e;
|
|
65
|
+
if (!(m instanceof HTMLElement)) throw new Error("Provided Element not a valid HTMLElement");
|
|
66
|
+
this.dismissibleElement = m, 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)
|
|
@@ -74,9 +74,9 @@ const E = (t, e = document.body) => e.querySelector(t), r = (t, e = document.bod
|
|
|
74
74
|
* auto init Dismissible Element based on the selector provided
|
|
75
75
|
* @param selector {string} default is [data-fx-dismissible]
|
|
76
76
|
*/
|
|
77
|
-
i(
|
|
78
|
-
const
|
|
79
|
-
for (const n of
|
|
77
|
+
i(l, "autoInit", (e = "[data-fx-dismissible]") => {
|
|
78
|
+
const t = r(e);
|
|
79
|
+
for (const n of t) new l(n);
|
|
80
80
|
}), /**
|
|
81
81
|
*
|
|
82
82
|
* @param dismissible
|
|
@@ -84,8 +84,8 @@ i(m, "autoInit", (e = "[data-fx-dismissible]") => {
|
|
|
84
84
|
* @param onDissmiss
|
|
85
85
|
* @returns
|
|
86
86
|
*/
|
|
87
|
-
i(
|
|
88
|
-
let h =
|
|
87
|
+
i(l, "init", (e, t, n) => new l(e, t, n));
|
|
88
|
+
let h = l;
|
|
89
89
|
export {
|
|
90
90
|
h as Dismissible
|
|
91
91
|
};
|
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,d)=>s in i?E(i,s,{enumerable:!0,configurable:!0,writable:!0,value:d}):i[s]=d;var t=(i,s,d)=>y(i,typeof s!="symbol"?s+"":s,d);const s=(n,e=document.body)=>e.querySelector(n),d=(n,e=document.body)=>Array.from(e.querySelectorAll(n)),f=({element:n,callback:e,type:l,keysCheck:m})=>{const a=getComputedStyle(n),c=a.transition;if(c!=="none"&&c!==""&&!m.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"]})},o=class o{constructor(e,l,m){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=d("[data-dismiss-btn]",this.dismissibleElement),this.onDismiss=m,this.dismissibleElement.setAttribute("aria-hidden","false"),this.setupDismissible()}setupDismissible(){for(const e of this.dismissButtons)e.addEventListener("click",this.dismiss)}};t(o,"autoInit",(e="[data-fx-dismissible]")=>{const l=d(e);for(const m of l)new o(m)}),t(o,"init",(e,l,m)=>new o(e,l,m));let r=o;i.Dismissible=r,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
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.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A lightweight JavaScript component that automatically makes a component dismissible for easy user interaction.",
|
|
7
7
|
"publishConfig": {
|
|
@@ -34,11 +34,9 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"dev": "vite",
|
|
36
36
|
"build": "tsc && vite build",
|
|
37
|
-
"preview": "vite preview"
|
|
38
|
-
"format": "biome format --write ./src"
|
|
37
|
+
"preview": "vite preview"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
|
-
"@biomejs/biome": "1.5.1",
|
|
42
40
|
"@flexilla/utilities": "latest",
|
|
43
41
|
"typescript": "^5.2.2",
|
|
44
42
|
"vite": "^5.0.8",
|
|
@@ -63,6 +61,5 @@
|
|
|
63
61
|
"url": "https://github.com/unoforge/flexilla/issues"
|
|
64
62
|
},
|
|
65
63
|
"license": "MIT",
|
|
66
|
-
"author": "johnkat-mj"
|
|
67
|
-
"gitHead": "645c56a48c9495587cd958f6bf6285291f1d485c"
|
|
64
|
+
"author": "johnkat-mj"
|
|
68
65
|
}
|