@flexilla/dismissible 2.0.2 → 2.0.5

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 UnifyUI Dev
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 UnifyUI Dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,39 +1,39 @@
1
- # @flexilla/dismissible | Dismissible Component
2
-
3
- `@flexilla/dismissible` is a lightweight package that provides a way to dismiss elements from the DOM or hide them from the screen.
4
-
5
- ## Installation
6
-
7
- ```shell
8
- npm install @flexilla/dismissible
9
- ```
10
- Import
11
- ```js
12
- import Dismissible from '@flexilla/dismissible';
13
- ```
14
-
15
- ## Params
16
-
17
- | Name | Description | Data Attributes | Type | | --------------------- | -------------------------------------- | --------------- | -------------------- | | dismissibleElement | The element to be dismissed. | - | HTMLElement | | action | The action to perform when dismissing the element. Available options: "remove-from-dom", "hide-from-screen". | data-action | "remove-from-dom" \| "hide-from-screen" | | onDismiss | The callback function to be executed when the element is dismissed. | - | () => void |
18
-
19
- ## Example
20
- ```html
21
- <div class="dismissable-element" data-action="remove-from-dom">
22
- <button class="dismiss-button" data-dismiss-btn>Dismiss</button>
23
- </div>
24
-
25
- <script>
26
- const dismissible = new Dismissible('.dismissable-element',
27
- action: "remove-from-dom",
28
- onDismiss: () => {
29
- console.log("Element dismissed!");
30
- });
31
-
32
- // or
33
- fDismissible('.dismissable-element',
34
- action: "remove-from-dom",
35
- onDismiss: () => {
36
- console.log("Element dismissed!");
37
- })
38
- </script>
1
+ # @flexilla/dismissible | Dismissible Component
2
+
3
+ `@flexilla/dismissible` is a lightweight package that provides a way to dismiss elements from the DOM or hide them from the screen.
4
+
5
+ ## Installation
6
+
7
+ ```shell
8
+ npm install @flexilla/dismissible
9
+ ```
10
+ Import
11
+ ```js
12
+ import Dismissible from '@flexilla/dismissible';
13
+ ```
14
+
15
+ ## Params
16
+
17
+ | Name | Description | Data Attributes | Type | | --------------------- | -------------------------------------- | --------------- | -------------------- | | dismissibleElement | The element to be dismissed. | - | HTMLElement | | action | The action to perform when dismissing the element. Available options: "remove-from-dom", "hide-from-screen". | data-action | "remove-from-dom" \| "hide-from-screen" | | onDismiss | The callback function to be executed when the element is dismissed. | - | () => void |
18
+
19
+ ## Example
20
+ ```html
21
+ <div class="dismissable-element" data-action="remove-from-dom">
22
+ <button class="dismiss-button" data-dismiss-btn>Dismiss</button>
23
+ </div>
24
+
25
+ <script>
26
+ const dismissible = new Dismissible('.dismissable-element',
27
+ action: "remove-from-dom",
28
+ onDismiss: () => {
29
+ console.log("Element dismissed!");
30
+ });
31
+
32
+ // or
33
+ fDismissible('.dismissable-element',
34
+ action: "remove-from-dom",
35
+ onDismiss: () => {
36
+ console.log("Element dismissed!");
37
+ })
38
+ </script>
39
39
  ```
@@ -1,18 +1,30 @@
1
- var a = Object.defineProperty;
2
- var c = (i, e, s) => e in i ? a(i, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : i[e] = s;
3
- var t = (i, e, s) => (c(i, typeof e != "symbol" ? e + "" : e, s), s);
4
- const h = (i, e = document.body) => e.querySelector(i), l = (i, e = document.body) => Array.from(e.querySelectorAll(i)), r = ({
5
- element: i,
1
+ var b = Object.defineProperty;
2
+ var u = (t, e, s) => e in t ? b(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var i = (t, e, s) => u(t, typeof e != "symbol" ? e + "" : e, s);
4
+ const E = (t, e = document.body) => e.querySelector(t), r = (t, e = document.body) => Array.from(e.querySelectorAll(t)), f = ({
5
+ element: t,
6
+ callback: e,
7
+ type: s,
8
+ keysCheck: n
9
+ }) => {
10
+ const l = getComputedStyle(t), o = s === "transition" ? l.transition : l.animation;
11
+ if (o !== "none" && o !== "" && !n.includes(o)) {
12
+ const d = s === "transition" ? "transitionend" : "animationend", a = () => {
13
+ t.removeEventListener(d, a), e();
14
+ };
15
+ t.addEventListener(d, a, { once: !0 });
16
+ } else
17
+ e();
18
+ }, c = ({
19
+ element: t,
6
20
  callback: e
7
21
  }) => {
8
- const s = getComputedStyle(i).transition;
9
- s !== "none" && s !== "" && s !== "all 0s ease 0s" && s !== "all" ? i.addEventListener(
10
- "transitionend",
11
- function n() {
12
- i.removeEventListener("transitionend", n), e();
13
- },
14
- { once: !0 }
15
- ) : e();
22
+ f({
23
+ element: t,
24
+ callback: e,
25
+ type: "transition",
26
+ keysCheck: ["all 0s ease 0s", "all"]
27
+ });
16
28
  }, m = class m {
17
29
  /**
18
30
  * Dismissible Component
@@ -21,40 +33,39 @@ const h = (i, e = document.body) => e.querySelector(i), l = (i, e = document.bod
21
33
  * @param onDissmiss
22
34
  */
23
35
  constructor(e, s, n) {
24
- t(this, "dismissibleElement");
25
- t(this, "dismissButtons");
26
- t(this, "action");
27
- t(this, "onDismiss");
28
- t(this, "hideFromScreen", () => {
36
+ i(this, "dismissibleElement");
37
+ i(this, "dismissButtons");
38
+ i(this, "action");
39
+ i(this, "onDismiss");
40
+ i(this, "hideFromScreen", () => {
29
41
  var e;
30
42
  this.dismissibleElement.style.display = "none", (e = this.onDismiss) == null || e.call(this);
31
43
  });
32
- t(this, "removeFromDom", () => {
44
+ i(this, "removeFromDom", () => {
33
45
  var e, s;
34
46
  (e = this.onDismiss) == null || e.call(this), (s = this.dismissibleElement.parentElement) == null || s.removeChild(this.dismissibleElement);
35
47
  });
36
- t(this, "dismiss", () => {
48
+ i(this, "dismiss", () => {
37
49
  switch (this.action) {
38
50
  case "hide-from-screen":
39
- this.dismissibleElement.setAttribute("aria-hidden", "true"), this.dismissibleElement.setAttribute("data-state", "hidden"), r({
51
+ this.dismissibleElement.setAttribute("aria-hidden", "true"), this.dismissibleElement.setAttribute("data-state", "hidden"), c({
40
52
  element: this.dismissibleElement,
41
53
  callback: this.hideFromScreen
42
54
  });
43
55
  break;
44
56
  default:
45
- this.dismissibleElement.setAttribute("data-hidden", ""), this.dismissibleElement.setAttribute("aria-hidden", "true"), this.dismissibleElement.setAttribute("data-state", "removed"), r({
57
+ this.dismissibleElement.setAttribute("data-hidden", ""), this.dismissibleElement.setAttribute("aria-hidden", "true"), this.dismissibleElement.setAttribute("data-state", "removed"), c({
46
58
  element: this.dismissibleElement,
47
59
  callback: this.removeFromDom
48
60
  });
49
61
  break;
50
62
  }
51
63
  });
52
- const o = typeof e == "string" ? h(e, document.body) : e;
53
- if (!(o instanceof HTMLElement))
54
- throw new Error("Provided Element not a valid HTMLElement");
55
- this.dismissibleElement = o, this.action = s || this.dismissibleElement.dataset.action || "hide-from-screen", this.dismissButtons = l("[data-dismiss-btn]", this.dismissibleElement), this.onDismiss = n, this.dismissibleElement.setAttribute("aria-hidden", "false"), this.init();
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 = s || 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();
56
67
  }
57
- init() {
68
+ setupDismissible() {
58
69
  for (const e of this.dismissButtons)
59
70
  e.addEventListener("click", this.dismiss);
60
71
  }
@@ -63,14 +74,18 @@ const h = (i, e = document.body) => e.querySelector(i), l = (i, e = document.bod
63
74
  * auto init Dismissible Element based on the selector provided
64
75
  * @param selector {string} default is [data-fx-dismissible]
65
76
  */
66
- t(m, "autoInit", (e = "[data-fx-dismissible]") => {
67
- const s = l(e);
68
- for (const n of s)
69
- new m(n);
70
- });
71
- let d = m;
72
- const E = (i, e, s) => new d(i, e, s);
77
+ i(m, "autoInit", (e = "[data-fx-dismissible]") => {
78
+ const s = r(e);
79
+ for (const n of s) new m(n);
80
+ }), /**
81
+ *
82
+ * @param dismissible
83
+ * @param action
84
+ * @param onDissmiss
85
+ * @returns
86
+ */
87
+ i(m, "init", (e, s, n) => new m(e, s, n));
88
+ let h = m;
73
89
  export {
74
- d as Dismissible,
75
- E as fDismissible
90
+ h as Dismissible
76
91
  };
@@ -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 b=Object.defineProperty;var u=(i,s,o)=>s in i?b(i,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[s]=o;var d=(i,s,o)=>(u(i,typeof s!="symbol"?s+"":s,o),o);const s=(n,e=document.body)=>e.querySelector(n),o=(n,e=document.body)=>Array.from(e.querySelectorAll(n)),a=({element:n,callback:e})=>{const t=getComputedStyle(n).transition;t!=="none"&&t!==""&&t!=="all 0s ease 0s"&&t!=="all"?n.addEventListener("transitionend",function l(){n.removeEventListener("transitionend",l),e()},{once:!0}):e()},r=class r{constructor(e,t,l){d(this,"dismissibleElement");d(this,"dismissButtons");d(this,"action");d(this,"onDismiss");d(this,"hideFromScreen",()=>{var e;this.dismissibleElement.style.display="none",(e=this.onDismiss)==null||e.call(this)});d(this,"removeFromDom",()=>{var e,t;(e=this.onDismiss)==null||e.call(this),(t=this.dismissibleElement.parentElement)==null||t.removeChild(this.dismissibleElement)});d(this,"dismiss",()=>{switch(this.action){case"hide-from-screen":this.dismissibleElement.setAttribute("aria-hidden","true"),this.dismissibleElement.setAttribute("data-state","hidden"),a({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"),a({element:this.dismissibleElement,callback:this.removeFromDom});break}});const c=typeof e=="string"?s(e,document.body):e;if(!(c instanceof HTMLElement))throw new Error("Provided Element not a valid HTMLElement");this.dismissibleElement=c,this.action=t||this.dismissibleElement.dataset.action||"hide-from-screen",this.dismissButtons=o("[data-dismiss-btn]",this.dismissibleElement),this.onDismiss=l,this.dismissibleElement.setAttribute("aria-hidden","false"),this.init()}init(){for(const e of this.dismissButtons)e.addEventListener("click",this.dismiss)}};d(r,"autoInit",(e="[data-fx-dismissible]")=>{const t=o(e);for(const l of t)new r(l)});let m=r;const h=(n,e,t)=>new m(n,e,t);i.Dismissible=m,i.fDismissible=h,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
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 n=(i,s,o)=>y(i,typeof s!="symbol"?s+"":s,o);const s=(l,e=document.body)=>e.querySelector(l),o=(l,e=document.body)=>Array.from(e.querySelectorAll(l)),f=({element:l,callback:e,type:t,keysCheck:d})=>{const a=getComputedStyle(l),c=t==="transition"?a.transition:a.animation;if(c!=="none"&&c!==""&&!d.includes(c)){const b=t==="transition"?"transitionend":"animationend",u=()=>{l.removeEventListener(b,u),e()};l.addEventListener(b,u,{once:!0})}else e()},h=({element:l,callback:e})=>{f({element:l,callback:e,type:"transition",keysCheck:["all 0s ease 0s","all"]})},m=class m{constructor(e,t,d){n(this,"dismissibleElement");n(this,"dismissButtons");n(this,"action");n(this,"onDismiss");n(this,"hideFromScreen",()=>{var e;this.dismissibleElement.style.display="none",(e=this.onDismiss)==null||e.call(this)});n(this,"removeFromDom",()=>{var e,t;(e=this.onDismiss)==null||e.call(this),(t=this.dismissibleElement.parentElement)==null||t.removeChild(this.dismissibleElement)});n(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=t||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)}};n(m,"autoInit",(e="[data-fx-dismissible]")=>{const t=o(e);for(const d of t)new m(d)}),n(m,"init",(e,t,d)=>new m(e,t,d));let r=m;i.Dismissible=r,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
package/dist/index.d.ts CHANGED
@@ -13,21 +13,20 @@ export declare class Dismissible {
13
13
  private hideFromScreen;
14
14
  private removeFromDom;
15
15
  dismiss: () => void;
16
- private init;
16
+ private setupDismissible;
17
17
  /**
18
18
  * auto init Dismissible Element based on the selector provided
19
19
  * @param selector {string} default is [data-fx-dismissible]
20
20
  */
21
21
  static autoInit: (selector?: string) => void;
22
+ /**
23
+ *
24
+ * @param dismissible
25
+ * @param action
26
+ * @param onDissmiss
27
+ * @returns
28
+ */
29
+ static init: (dismissible: string | HTMLElement, action?: "remove-from-dom" | "hide-from-screen", onDissmiss?: () => void) => Dismissible;
22
30
  }
23
31
 
24
- /**
25
- *
26
- * @param dismissible
27
- * @param action
28
- * @param onDissmiss
29
- * @returns
30
- */
31
- export declare const fDismissible: (dismissible: string | HTMLElement, action?: "remove-from-dom" | "hide-from-screen", onDissmiss?: () => void) => Dismissible;
32
-
33
32
  export { }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flexilla/dismissible",
3
3
  "private": false,
4
- "version": "2.0.2",
4
+ "version": "2.0.5",
5
5
  "type": "module",
6
6
  "description": "A lightweight JavaScript component that automatically makes a component dismissible for easy user interaction.",
7
7
  "publishConfig": {
@@ -57,12 +57,12 @@
57
57
  "homepage": "",
58
58
  "repository": {
59
59
  "type": "git",
60
- "url": "https://github.com/unify-ui-dev/flexilla"
60
+ "url": "https://github.com/unoforge/flexilla"
61
61
  },
62
62
  "bugs": {
63
- "url": "https://github.com/unify-ui-dev/flexilla/issues"
63
+ "url": "https://github.com/unoforge/flexilla/issues"
64
64
  },
65
65
  "license": "MIT",
66
66
  "author": "johnkat-mj",
67
- "gitHead": "98932fa7279389be90368e974e58fab0fb1ba654"
67
+ "gitHead": "645c56a48c9495587cd958f6bf6285291f1d485c"
68
68
  }