@flexilla/dismissible 1.1.1 → 2.0.0
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/README.md +2 -4
- package/dist/dismissible.js +23 -19
- package/dist/dismissible.umd.cjs +1 -1
- package/dist/index.d.ts +7 -7
- package/package.json +68 -67
package/README.md
CHANGED
|
@@ -23,13 +23,11 @@ import Dismissible from '@flexilla/dismissible';
|
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
25
|
<script>
|
|
26
|
-
const
|
|
27
|
-
const dismissible = new Dismissible({
|
|
28
|
-
dismissibleElement,
|
|
26
|
+
const dismissible = new Dismissible('.dismissable-element',
|
|
29
27
|
action: "remove-from-dom",
|
|
30
28
|
onDismiss: () => {
|
|
31
29
|
console.log("Element dismissed!");
|
|
32
30
|
}
|
|
33
|
-
|
|
31
|
+
);
|
|
34
32
|
</script>
|
|
35
33
|
```
|
package/dist/dismissible.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
var l = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var t = (
|
|
4
|
-
const o = ({
|
|
5
|
-
|
|
6
|
-
parentElement: e
|
|
7
|
-
}) => Array.from(e.querySelectorAll(i)), m = ({
|
|
8
|
-
element: i,
|
|
2
|
+
var d = (s, e, i) => e in s ? l(s, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : s[e] = i;
|
|
3
|
+
var t = (s, e, i) => (d(s, typeof e != "symbol" ? e + "" : e, i), i);
|
|
4
|
+
const r = (s, e = document.body) => e.querySelector(s), a = (s, e = document.body) => Array.from(e.querySelectorAll(s)), o = ({
|
|
5
|
+
element: s,
|
|
9
6
|
callback: e
|
|
10
7
|
}) => {
|
|
11
|
-
const
|
|
12
|
-
|
|
8
|
+
const i = getComputedStyle(s).transition;
|
|
9
|
+
i !== "none" && i !== "" && i !== "all 0s ease 0s" ? s.addEventListener(
|
|
13
10
|
"transitionend",
|
|
14
11
|
function n() {
|
|
15
|
-
|
|
12
|
+
s.removeEventListener("transitionend", n), e();
|
|
16
13
|
},
|
|
17
14
|
{ once: !0 }
|
|
18
15
|
) : e();
|
|
19
16
|
};
|
|
20
|
-
class
|
|
21
|
-
|
|
17
|
+
class c {
|
|
18
|
+
/**
|
|
19
|
+
* Dismissible Component
|
|
20
|
+
* @param dismissible
|
|
21
|
+
* @param action
|
|
22
|
+
* @param onDissmiss
|
|
23
|
+
*/
|
|
24
|
+
constructor(e, i, n) {
|
|
22
25
|
t(this, "dismissibleElement");
|
|
23
26
|
t(this, "dismissButtons");
|
|
24
27
|
t(this, "action");
|
|
@@ -28,28 +31,29 @@ class a {
|
|
|
28
31
|
this.dismissibleElement.style.display = "none", (e = this.onDismiss) == null || e.call(this);
|
|
29
32
|
});
|
|
30
33
|
t(this, "removeFromDom", () => {
|
|
31
|
-
var e,
|
|
32
|
-
(e = this.onDismiss) == null || e.call(this), (
|
|
34
|
+
var e, i;
|
|
35
|
+
(e = this.onDismiss) == null || e.call(this), (i = this.dismissibleElement.parentNode) == null || i.removeChild(this.dismissibleElement);
|
|
33
36
|
});
|
|
34
37
|
t(this, "dismiss", () => {
|
|
35
38
|
switch (this.action) {
|
|
36
39
|
case "hide-from-screen":
|
|
37
|
-
this.dismissibleElement.setAttribute("aria-hidden", "true"),
|
|
40
|
+
this.dismissibleElement.setAttribute("aria-hidden", "true"), o({
|
|
38
41
|
element: this.dismissibleElement,
|
|
39
42
|
callback: this.hideFromScreen
|
|
40
43
|
});
|
|
41
44
|
break;
|
|
42
45
|
default:
|
|
43
|
-
this.dismissibleElement.setAttribute("data-hidden", ""), this.dismissibleElement.setAttribute("aria-hidden", "true"),
|
|
46
|
+
this.dismissibleElement.setAttribute("data-hidden", ""), this.dismissibleElement.setAttribute("aria-hidden", "true"), o({
|
|
44
47
|
element: this.dismissibleElement,
|
|
45
48
|
callback: this.removeFromDom
|
|
46
49
|
});
|
|
47
50
|
break;
|
|
48
51
|
}
|
|
49
52
|
});
|
|
50
|
-
|
|
53
|
+
const m = typeof e == "string" ? r(e, document.body) : e;
|
|
54
|
+
if (!(m instanceof HTMLElement))
|
|
51
55
|
throw new Error("Provided Element not a valid HTMLElement");
|
|
52
|
-
this.dismissibleElement =
|
|
56
|
+
this.dismissibleElement = m, this.action = i || this.dismissibleElement.dataset.action || "hide-from-screen", this.dismissButtons = a("[data-dismiss-btn]", this.dismissibleElement), this.onDismiss = n, this.dismissibleElement.setAttribute("aria-hidden", "false"), this.init();
|
|
53
57
|
}
|
|
54
58
|
init() {
|
|
55
59
|
for (const e of this.dismissButtons)
|
|
@@ -57,5 +61,5 @@ class a {
|
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
export {
|
|
60
|
-
|
|
64
|
+
c as Dismissible
|
|
61
65
|
};
|
package/dist/dismissible.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(s=typeof globalThis<"u"?globalThis:s||self,i(s["@flexilla/dismissible"]={}))})(this,function(s){"use strict";var
|
|
1
|
+
(function(s,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(s=typeof globalThis<"u"?globalThis:s||self,i(s["@flexilla/dismissible"]={}))})(this,function(s){"use strict";var c=Object.defineProperty;var h=(s,i,d)=>i in s?c(s,i,{enumerable:!0,configurable:!0,writable:!0,value:d}):s[i]=d;var o=(s,i,d)=>(h(s,typeof i!="symbol"?i+"":i,d),d);const i=(t,e=document.body)=>e.querySelector(t),d=(t,e=document.body)=>Array.from(e.querySelectorAll(t)),l=({element:t,callback:e})=>{const n=getComputedStyle(t).transition;n!=="none"&&n!==""&&n!=="all 0s ease 0s"?t.addEventListener("transitionend",function m(){t.removeEventListener("transitionend",m),e()},{once:!0}):e()};class a{constructor(e,n,m){o(this,"dismissibleElement");o(this,"dismissButtons");o(this,"action");o(this,"onDismiss");o(this,"hideFromScreen",()=>{var e;this.dismissibleElement.style.display="none",(e=this.onDismiss)==null||e.call(this)});o(this,"removeFromDom",()=>{var e,n;(e=this.onDismiss)==null||e.call(this),(n=this.dismissibleElement.parentNode)==null||n.removeChild(this.dismissibleElement)});o(this,"dismiss",()=>{switch(this.action){case"hide-from-screen":this.dismissibleElement.setAttribute("aria-hidden","true"),l({element:this.dismissibleElement,callback:this.hideFromScreen});break;default:this.dismissibleElement.setAttribute("data-hidden",""),this.dismissibleElement.setAttribute("aria-hidden","true"),l({element:this.dismissibleElement,callback:this.removeFromDom});break}});const r=typeof e=="string"?i(e,document.body):e;if(!(r instanceof HTMLElement))throw new Error("Provided Element not a valid HTMLElement");this.dismissibleElement=r,this.action=n||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.init()}init(){for(const e of this.dismissButtons)e.addEventListener("click",this.dismiss)}}s.Dismissible=a,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.d.ts
CHANGED
|
@@ -3,17 +3,17 @@ export declare class Dismissible {
|
|
|
3
3
|
private dismissButtons;
|
|
4
4
|
private action;
|
|
5
5
|
private onDismiss;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Dismissible Component
|
|
8
|
+
* @param dismissible
|
|
9
|
+
* @param action
|
|
10
|
+
* @param onDissmiss
|
|
11
|
+
*/
|
|
12
|
+
constructor(dismissible: string | HTMLElement, action?: "remove-from-dom" | "hide-from-screen", onDissmiss?: () => void);
|
|
7
13
|
private hideFromScreen;
|
|
8
14
|
private removeFromDom;
|
|
9
15
|
dismiss: () => void;
|
|
10
16
|
private init;
|
|
11
17
|
}
|
|
12
18
|
|
|
13
|
-
export declare type DismissibleParams = {
|
|
14
|
-
dismissibleElement: HTMLElement;
|
|
15
|
-
action?: "remove-from-dom" | "hide-from-screen";
|
|
16
|
-
onDissmiss?: () => void;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
19
|
export { }
|
package/package.json
CHANGED
|
@@ -1,67 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@flexilla/dismissible",
|
|
3
|
-
"private": false,
|
|
4
|
-
"version": "
|
|
5
|
-
"type": "module",
|
|
6
|
-
"description": "A lightweight JavaScript component that automatically makes a component dismissible for easy user interaction.",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"main": "./dist/dismissible.umd.js",
|
|
11
|
-
"module": "./dist/dismissible.js",
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"import": {
|
|
16
|
-
"types": "./dist/index.d.ts",
|
|
17
|
-
"default": "./dist/dismissible.js"
|
|
18
|
-
},
|
|
19
|
-
"require": {
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
|
-
"default": "./dist/dismissible.umd.js"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"files": [
|
|
26
|
-
"dist",
|
|
27
|
-
"README.md",
|
|
28
|
-
"package.json",
|
|
29
|
-
"!vite.config.ts",
|
|
30
|
-
"!.gitignore",
|
|
31
|
-
"!tsconfig.json",
|
|
32
|
-
"!biome.js"
|
|
33
|
-
],
|
|
34
|
-
"scripts": {
|
|
35
|
-
"dev": "vite",
|
|
36
|
-
"build": "tsc && vite build",
|
|
37
|
-
"preview": "vite preview",
|
|
38
|
-
"format": "biome format --write ./src"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@biomejs/biome": "1.5.1",
|
|
42
|
-
"@flexilla/utilities": "latest",
|
|
43
|
-
"typescript": "^5.2.2",
|
|
44
|
-
"vite": "^5.0.8",
|
|
45
|
-
"vite-plugin-dts": "^3.7.0"
|
|
46
|
-
},
|
|
47
|
-
"keywords": [
|
|
48
|
-
"dismissible",
|
|
49
|
-
"remove-element",
|
|
50
|
-
"js",
|
|
51
|
-
"ts",
|
|
52
|
-
"component",
|
|
53
|
-
"interactive",
|
|
54
|
-
"intercative component",
|
|
55
|
-
"flexilla"
|
|
56
|
-
],
|
|
57
|
-
"homepage": "",
|
|
58
|
-
"repository": {
|
|
59
|
-
"type": "git",
|
|
60
|
-
"url": "https://github.com/unify-ui-dev/flexilla"
|
|
61
|
-
},
|
|
62
|
-
"bugs": {
|
|
63
|
-
"url": "https://github.com/unify-ui-dev/flexilla/issues"
|
|
64
|
-
},
|
|
65
|
-
"license": "MIT",
|
|
66
|
-
"author": "johnkat-mj"
|
|
67
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@flexilla/dismissible",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "A lightweight JavaScript component that automatically makes a component dismissible for easy user interaction.",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/dismissible.umd.js",
|
|
11
|
+
"module": "./dist/dismissible.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/dismissible.js"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"default": "./dist/dismissible.umd.js"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"package.json",
|
|
29
|
+
"!vite.config.ts",
|
|
30
|
+
"!.gitignore",
|
|
31
|
+
"!tsconfig.json",
|
|
32
|
+
"!biome.js"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"dev": "vite",
|
|
36
|
+
"build": "tsc && vite build",
|
|
37
|
+
"preview": "vite preview",
|
|
38
|
+
"format": "biome format --write ./src"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@biomejs/biome": "1.5.1",
|
|
42
|
+
"@flexilla/utilities": "latest",
|
|
43
|
+
"typescript": "^5.2.2",
|
|
44
|
+
"vite": "^5.0.8",
|
|
45
|
+
"vite-plugin-dts": "^3.7.0"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"dismissible",
|
|
49
|
+
"remove-element",
|
|
50
|
+
"js",
|
|
51
|
+
"ts",
|
|
52
|
+
"component",
|
|
53
|
+
"interactive",
|
|
54
|
+
"intercative component",
|
|
55
|
+
"flexilla"
|
|
56
|
+
],
|
|
57
|
+
"homepage": "",
|
|
58
|
+
"repository": {
|
|
59
|
+
"type": "git",
|
|
60
|
+
"url": "https://github.com/unify-ui-dev/flexilla"
|
|
61
|
+
},
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://github.com/unify-ui-dev/flexilla/issues"
|
|
64
|
+
},
|
|
65
|
+
"license": "MIT",
|
|
66
|
+
"author": "johnkat-mj",
|
|
67
|
+
"gitHead": "b182c7035953bc34e8f350b834df9862bec8acb5"
|
|
68
|
+
}
|