@flexilla/alpine-modal 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2025 Unoforge
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 ADDED
@@ -0,0 +1,45 @@
1
+ <h1 align="center">Alpine Modal</h1>
2
+
3
+ <p align="center">
4
+ A port of Flexilla Modal for <a href="https://alpinejs.dev">Alpine.js</a>
5
+ </p>
6
+
7
+
8
+ ## Installation
9
+
10
+ ### CDN
11
+
12
+ Include the following `<script>` tag in the `<head>` of your document, just before Alpine.
13
+
14
+ ```html
15
+
16
+ ```
17
+
18
+ ### NPM
19
+
20
+ ```shell
21
+ npm install @flexilla/alpine-modal
22
+ ```
23
+
24
+ Add the `x-modal` directive to your project by importing the package **before** starting Alpine.
25
+
26
+ ```js
27
+ import Alpine from 'alpinejs';
28
+ import PluginModal from '@flexilla/alpine-modal';
29
+
30
+ Alpine.plugin(PluginModal);
31
+
32
+ Alpine.start();
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ```html
38
+
39
+ ```
40
+
41
+ ## License
42
+
43
+ Copyright (c) 2025 Johnkat MJ and contributors.
44
+
45
+ Licensed under the MIT license, see [LICENSE](LICENSE) for details.
package/dist/cdn.js ADDED
@@ -0,0 +1,228 @@
1
+ (() => {
2
+ // ../../node_modules/@flexilla/modal/dist/modal.js
3
+ var j = Object.defineProperty;
4
+ var z = (t, e, n) => e in t ? j(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
5
+ var c = (t, e, n) => z(t, typeof e != "symbol" ? e + "" : e, n);
6
+ var O = class {
7
+ static initGlobalRegistry() {
8
+ window.$flexillaInstances || (window.$flexillaInstances = {});
9
+ }
10
+ static register(e, n, a) {
11
+ return this.initGlobalRegistry(), window.$flexillaInstances[e] || (window.$flexillaInstances[e] = []), this.getInstance(e, n) || (window.$flexillaInstances[e].push({ element: n, instance: a }), a);
12
+ }
13
+ static getInstance(e, n) {
14
+ var a, d;
15
+ return this.initGlobalRegistry(), (d = (a = window.$flexillaInstances[e]) == null ? void 0 : a.find(
16
+ (s) => s.element === n
17
+ )) == null ? void 0 : d.instance;
18
+ }
19
+ static removeInstance(e, n) {
20
+ this.initGlobalRegistry(), window.$flexillaInstances[e] && (window.$flexillaInstances[e] = window.$flexillaInstances[e].filter(
21
+ (a) => a.element !== n
22
+ ));
23
+ }
24
+ };
25
+ var r = (t, e = document.body) => e.querySelector(t);
26
+ var H = (t, e = document.body) => Array.from(e.querySelectorAll(t));
27
+ var J = ({
28
+ newElement: t,
29
+ existingElement: e
30
+ }) => {
31
+ if (!(t instanceof HTMLElement) || !(e instanceof HTMLElement))
32
+ throw new Error("Both parameters must be valid HTML elements.");
33
+ const n = e.parentElement;
34
+ if (n) n.insertBefore(t, e);
35
+ else throw new Error("Existing element must have a parent element.");
36
+ };
37
+ var Q = ({
38
+ element: t,
39
+ callback: e,
40
+ type: n,
41
+ keysCheck: a
42
+ }) => {
43
+ const d = getComputedStyle(t), s = d.animation;
44
+ if (s !== "none" && s !== "" && !a.includes(s)) {
45
+ const f = "animationend", u = () => {
46
+ t.removeEventListener(f, u), e();
47
+ };
48
+ t.addEventListener(f, u, { once: true });
49
+ } else
50
+ e();
51
+ };
52
+ var N = ({ element: t, callback: e }) => {
53
+ Q({
54
+ element: t,
55
+ callback: e,
56
+ type: "animation",
57
+ keysCheck: ["none 0s ease 0s 1 normal none running"]
58
+ });
59
+ };
60
+ var B = (t, e, n) => {
61
+ const a = new CustomEvent(e, { detail: n });
62
+ t.dispatchEvent(a);
63
+ };
64
+ var W = (t) => {
65
+ var e;
66
+ t instanceof HTMLElement && ((e = t.parentElement) == null || e.removeChild(t));
67
+ };
68
+ var U = ({ modalContent: t, overlayClassName: e }) => {
69
+ const n = document.createElement("span");
70
+ return n.setAttribute("aria-hidden", "true"), J({ newElement: n, existingElement: t }), n.classList.add(...e), n.setAttribute("data-modal-overlay", ""), n;
71
+ };
72
+ var k = (t, e, n) => {
73
+ if (!(e instanceof HTMLElement)) throw new Error("No modal-content found");
74
+ t.setAttribute("aria-hidden", n === "open" ? "false" : "true"), t.setAttribute("data-state", n), e.setAttribute("data-state", n);
75
+ const a = r("[data-modal-overlay]", t);
76
+ a instanceof HTMLElement && a.setAttribute("data-state", n);
77
+ };
78
+ var V = (t, e, n) => {
79
+ if (!t) {
80
+ e || (document.body.style.overflowY = "auto");
81
+ return;
82
+ }
83
+ H("[data-fx-modal][data-state=open]:not([data-allow-body-scroll=true]").filter((s) => s !== n).length === 0 && !e && (document.body.style.overflowY = "auto");
84
+ };
85
+ var Z = (t, e, n) => {
86
+ var q;
87
+ if (!(t instanceof HTMLElement)) throw new Error("Modal Element must be a valid element");
88
+ const { animateContent: a, allowBodyScroll: d, preventCloseModal: s, overlayClass: f, onShow: u, onHide: h, onToggle: m, beforeHide: b, enableStackedModals: g } = n, p = d || t.hasAttribute("data-allow-body-scroll") && t.getAttribute("data-allow-body-scroll") !== "false", F = s || t.hasAttribute("data-prevent-close-modal") && t.getAttribute("data-prevent-close-modal") !== "false", C = g || t.hasAttribute("data-enable-stacked") && t.getAttribute("data-enable-stacked") !== "false", K = (f == null ? void 0 : f.split(" ")) || ((q = t.dataset.modalOverlay) == null ? void 0 : q.split(" ")) || "";
89
+ let x = false;
90
+ t.setAttribute("data-allow-body-scroll", `${p}`);
91
+ const o = r("[data-modal-content]", t), L = H("[data-close-modal]", t);
92
+ let i = null, S = false;
93
+ if (r("[data-modal-overlay]", t) instanceof HTMLElement && (i = r("[data-modal-overlay]", t), i.setAttribute("data-overlay-nature", "default"), S = true), !(o instanceof HTMLElement)) throw new Error("Modal content element not found");
94
+ const D = o.dataset.enterAnimation || "", P = o.dataset.exitAnimation || "";
95
+ o.setAttribute("data-state", "close");
96
+ const R = (l) => {
97
+ l.preventDefault(), l.key === "Escape" && !F && A();
98
+ }, X = (l) => {
99
+ if (C) return;
100
+ const w = H("[data-fx-modal][data-state=open]");
101
+ for (const y of w)
102
+ if (y !== l) {
103
+ const M = r("[data-modal-overlay]", y);
104
+ M.setAttribute("data-state", "close");
105
+ const I = r("[data-modal-content]", y), E = M.getAttribute("data-overlay-nature") === "default";
106
+ k(y, I, "close"), E || W(M);
107
+ }
108
+ }, T = () => {
109
+ if (t.getAttribute("data-state") !== "open") {
110
+ if (X(t), i = S ? i : U({
111
+ modalContent: o,
112
+ overlayClassName: K
113
+ }), i == null || i.setAttribute("data-state", "open"), B(t, "modal-open", { modalId: t.id }), a || D !== "") {
114
+ const w = a ? a.enterAnimation : D;
115
+ w !== "" && o.style.setProperty("--un-modal-animation", w), k(t, o, "open"), N({
116
+ element: o,
117
+ callback: () => {
118
+ o.style.removeProperty("--un-modal-animation");
119
+ }
120
+ });
121
+ } else
122
+ k(t, o, "open");
123
+ p || (document.body.style.overflow = "hidden"), x || (document.addEventListener("keydown", R), x = true), t.focus(), s || i.addEventListener("click", A), u == null || u(), m == null || m({ isHidden: false });
124
+ }
125
+ }, A = () => {
126
+ var E;
127
+ let l = false;
128
+ B(t, "before-hide", {
129
+ modalId: t.id,
130
+ setExitAction: ($) => {
131
+ l = $;
132
+ }
133
+ });
134
+ const w = (E = b == null ? void 0 : b()) == null ? void 0 : E.cancelAction;
135
+ if (l || w) return;
136
+ const y = () => {
137
+ k(t, o, "close"), V(C, p, t), S || W(i), B(t, "modal-close", { modalId: t.id });
138
+ }, M = () => {
139
+ x && (document.removeEventListener("keydown", R), x = false), t.blur(), h == null || h(), m == null || m({ isHidden: true });
140
+ }, I = (a == null ? void 0 : a.exitAnimation) && a.exitAnimation !== "" || P !== "";
141
+ if (i == null || i.setAttribute("data-state", "close"), o.setAttribute("data-state", "close"), I) {
142
+ const $ = a ? a.exitAnimation || "" : P;
143
+ o.style.setProperty("--un-modal-animation", $);
144
+ }
145
+ N({
146
+ element: o,
147
+ callback: () => {
148
+ I && o.style.removeProperty("--un-modal-animation"), y(), M();
149
+ }
150
+ });
151
+ }, G = (l) => {
152
+ l.preventDefault(), A();
153
+ };
154
+ return { autoInitModal: () => {
155
+ if (e instanceof HTMLElement && e.addEventListener("click", T), L.length > 0)
156
+ for (const l of L)
157
+ l.addEventListener("click", G);
158
+ }, showModal: T, hideModal: A, isHidden: () => t.dataset.state === "close", cleanup: () => {
159
+ if (e instanceof HTMLElement && e.removeEventListener("click", T), L.length > 0)
160
+ for (const l of L)
161
+ l.removeEventListener("click", G);
162
+ !s && i instanceof HTMLElement && i.removeEventListener("click", A), O.removeInstance("modal", t);
163
+ } };
164
+ };
165
+ var v = class v2 {
166
+ /**
167
+ * Creates a new Modal instance
168
+ * @param modal - The modal element or selector string to initialize
169
+ * @param options - Configuration options for the modal behavior
170
+ * @param triggerElement - Optional trigger element or selector that opens the modal
171
+ * @throws {Error} When the provided modal element is invalid or cannot be found
172
+ */
173
+ constructor(e, n = {}, a) {
174
+ c(this, "modalElement");
175
+ c(this, "showModal");
176
+ c(this, "hideModal");
177
+ c(this, "cleanup");
178
+ c(this, "isHidden");
179
+ c(this, "options");
180
+ c(this, "state");
181
+ const d = typeof e == "string" ? r(e) : e;
182
+ if (!(d instanceof HTMLElement)) throw new Error("Modal element not found or invalid. Please provide a valid HTMLElement or selector.");
183
+ this.modalElement = d, this.options = n, this.state = (n == null ? void 0 : n.defaultState) || this.modalElement.dataset.state || "close";
184
+ const s = O.getInstance("modal", this.modalElement);
185
+ if (s)
186
+ return s;
187
+ this.modalElement.hasAttribute("data-fx-modal") || this.modalElement.setAttribute("data-fx-modal", "");
188
+ const f = d.dataset.modalId, u = (typeof a == "string" ? r(a) : a) || r(`[data-modal-target='${f}']`), { showModal: h, hideModal: m, autoInitModal: b, isHidden: g, cleanup: p } = Z(d, u, this.options);
189
+ this.state === "open" && h(), b(), this.showModal = h, this.hideModal = m, this.isHidden = g, this.cleanup = p, O.register("modal", this.modalElement, this);
190
+ }
191
+ };
192
+ c(v, "autoInit", (e = "[data-fx-modal]") => {
193
+ const n = H(e);
194
+ for (const a of n) new v(a);
195
+ }), /**
196
+ * Creates and initializes a new Modal instance
197
+ * @param modal - The modal element or selector string
198
+ * @param options - Configuration options for the modal
199
+ * @param triggerElement - Optional trigger element or selector
200
+ * @returns {Modal} A new Modal instance
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * const modal = Modal.init('#myModal', {
205
+ * defaultState: 'open',
206
+ * allowBodyScroll: true
207
+ * });
208
+ * ```
209
+ */
210
+ c(v, "init", (e, n = {}, a) => new v(e, n, a));
211
+ var Y = v;
212
+
213
+ // src/index.js
214
+ function Modal(Alpine) {
215
+ Alpine.directive("modal", (el, {}, { cleanup }) => {
216
+ const modal_ = new Y(el);
217
+ cleanup(() => {
218
+ modal_.cleanup();
219
+ });
220
+ });
221
+ }
222
+ var src_default = Modal;
223
+
224
+ // builds/cdn.js
225
+ document.addEventListener("alpine:init", () => {
226
+ src_default(window.Alpine);
227
+ });
228
+ })();
@@ -0,0 +1 @@
1
+ (()=>{var Q=Object.defineProperty,U=(e,t,a)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,r=(e,t,a)=>U(e,typeof t!="symbol"?t+"":t,a),p=class{static initGlobalRegistry(){window.$flexillaInstances||(window.$flexillaInstances={})}static register(t,a,n){return this.initGlobalRegistry(),window.$flexillaInstances[t]||(window.$flexillaInstances[t]=[]),this.getInstance(t,a)||(window.$flexillaInstances[t].push({element:a,instance:n}),n)}static getInstance(t,a){var n,o;return this.initGlobalRegistry(),(o=(n=window.$flexillaInstances[t])==null?void 0:n.find(d=>d.element===a))==null?void 0:o.instance}static removeInstance(t,a){this.initGlobalRegistry(),window.$flexillaInstances[t]&&(window.$flexillaInstances[t]=window.$flexillaInstances[t].filter(n=>n.element!==a))}},c=(e,t=document.body)=>t.querySelector(e),I=(e,t=document.body)=>Array.from(t.querySelectorAll(e)),V=({newElement:e,existingElement:t})=>{if(!(e instanceof HTMLElement)||!(t instanceof HTMLElement))throw new Error("Both parameters must be valid HTML elements.");let a=t.parentElement;if(a)a.insertBefore(e,t);else throw new Error("Existing element must have a parent element.")},W=({element:e,callback:t,type:a,keysCheck:n})=>{let o=getComputedStyle(e),d=o.animation;if(d!=="none"&&d!==""&&!n.includes(d)){let m="animationend",u=()=>{e.removeEventListener(m,u),t()};e.addEventListener(m,u,{once:!0})}else t()},Y=({element:e,callback:t})=>{W({element:e,callback:t,type:"animation",keysCheck:["none 0s ease 0s 1 normal none running"]})},G=(e,t,a)=>{let n=new CustomEvent(t,{detail:a});e.dispatchEvent(n)},j=e=>{var t;e instanceof HTMLElement&&((t=e.parentElement)==null||t.removeChild(e))},X=({modalContent:e,overlayClassName:t})=>{let a=document.createElement("span");return a.setAttribute("aria-hidden","true"),V({newElement:a,existingElement:e}),a.classList.add(...t),a.setAttribute("data-modal-overlay",""),a},H=(e,t,a)=>{if(!(t instanceof HTMLElement))throw new Error("No modal-content found");e.setAttribute("aria-hidden",a==="open"?"false":"true"),e.setAttribute("data-state",a),t.setAttribute("data-state",a);let n=c("[data-modal-overlay]",e);n instanceof HTMLElement&&n.setAttribute("data-state",a)},Z=(e,t,a)=>{if(!e){t||(document.body.style.overflowY="auto");return}I("[data-fx-modal][data-state=open]:not([data-allow-body-scroll=true]").filter(n=>n!==a).length===0&&!t&&(document.body.style.overflowY="auto")},_=(e,t,a)=>{var n;if(!(e instanceof HTMLElement))throw new Error("Modal Element must be a valid element");let{animateContent:o,allowBodyScroll:d,preventCloseModal:m,overlayClass:u,onShow:h,onHide:E,onToggle:f,beforeHide:M,enableStackedModals:k}=a,T=d||e.hasAttribute("data-allow-body-scroll")&&e.getAttribute("data-allow-body-scroll")!=="false",J=m||e.hasAttribute("data-prevent-close-modal")&&e.getAttribute("data-prevent-close-modal")!=="false",R=k||e.hasAttribute("data-enable-stacked")&&e.getAttribute("data-enable-stacked")!=="false",K=u?.split(" ")||((n=e.dataset.modalOverlay)==null?void 0:n.split(" "))||"",A=!1;e.setAttribute("data-allow-body-scroll",`${T}`);let i=c("[data-modal-content]",e),g=I("[data-close-modal]",e),s=null,C=!1;if(c("[data-modal-overlay]",e)instanceof HTMLElement&&(s=c("[data-modal-overlay]",e),s.setAttribute("data-overlay-nature","default"),C=!0),!(i instanceof HTMLElement))throw new Error("Modal content element not found");let B=i.dataset.enterAnimation||"",N=i.dataset.exitAnimation||"";i.setAttribute("data-state","close");let q=l=>{l.preventDefault(),l.key==="Escape"&&!J&&w()},O=l=>{if(R)return;let L=I("[data-fx-modal][data-state=open]");for(let v of L)if(v!==l){let b=c("[data-modal-overlay]",v);b.setAttribute("data-state","close");let S=c("[data-modal-content]",v),x=b.getAttribute("data-overlay-nature")==="default";H(v,S,"close"),x||j(b)}},$=()=>{if(e.getAttribute("data-state")!=="open"){if(O(e),s=C?s:X({modalContent:i,overlayClassName:K}),s?.setAttribute("data-state","open"),G(e,"modal-open",{modalId:e.id}),o||B!==""){let l=o?o.enterAnimation:B;l!==""&&i.style.setProperty("--un-modal-animation",l),H(e,i,"open"),Y({element:i,callback:()=>{i.style.removeProperty("--un-modal-animation")}})}else H(e,i,"open");T||(document.body.style.overflow="hidden"),A||(document.addEventListener("keydown",q),A=!0),e.focus(),m||s.addEventListener("click",w),h?.(),f?.({isHidden:!1})}},w=()=>{var l;let L=!1;G(e,"before-hide",{modalId:e.id,setExitAction:P=>{L=P}});let v=(l=M?.())==null?void 0:l.cancelAction;if(L||v)return;let b=()=>{H(e,i,"close"),Z(R,T,e),C||j(s),G(e,"modal-close",{modalId:e.id})},S=()=>{A&&(document.removeEventListener("keydown",q),A=!1),e.blur(),E?.(),f?.({isHidden:!0})},x=o?.exitAnimation&&o.exitAnimation!==""||N!=="";if(s?.setAttribute("data-state","close"),i.setAttribute("data-state","close"),x){let P=o?o.exitAnimation||"":N;i.style.setProperty("--un-modal-animation",P)}Y({element:i,callback:()=>{x&&i.style.removeProperty("--un-modal-animation"),b(),S()}})},D=l=>{l.preventDefault(),w()};return{autoInitModal:()=>{if(t instanceof HTMLElement&&t.addEventListener("click",$),g.length>0)for(let l of g)l.addEventListener("click",D)},showModal:$,hideModal:w,isHidden:()=>e.dataset.state==="close",cleanup:()=>{if(t instanceof HTMLElement&&t.removeEventListener("click",$),g.length>0)for(let l of g)l.removeEventListener("click",D);!m&&s instanceof HTMLElement&&s.removeEventListener("click",w),p.removeInstance("modal",e)}}},y=class{constructor(t,a={},n){r(this,"modalElement"),r(this,"showModal"),r(this,"hideModal"),r(this,"cleanup"),r(this,"isHidden"),r(this,"options"),r(this,"state");let o=typeof t=="string"?c(t):t;if(!(o instanceof HTMLElement))throw new Error("Modal element not found or invalid. Please provide a valid HTMLElement or selector.");this.modalElement=o,this.options=a,this.state=a?.defaultState||this.modalElement.dataset.state||"close";let d=p.getInstance("modal",this.modalElement);if(d)return d;this.modalElement.hasAttribute("data-fx-modal")||this.modalElement.setAttribute("data-fx-modal","");let m=o.dataset.modalId,u=(typeof n=="string"?c(n):n)||c(`[data-modal-target='${m}']`),{showModal:h,hideModal:E,autoInitModal:f,isHidden:M,cleanup:k}=_(o,u,this.options);this.state==="open"&&h(),f(),this.showModal=h,this.hideModal=E,this.isHidden=M,this.cleanup=k,p.register("modal",this.modalElement,this)}};r(y,"autoInit",(e="[data-fx-modal]")=>{let t=I(e);for(let a of t)new y(a)}),r(y,"init",(e,t={},a)=>new y(e,t,a));var F=y;function ee(e){e.directive("modal",(t,{},{cleanup:a})=>{let n=new F(t);a(()=>{n.cleanup()})})}var z=ee;document.addEventListener("alpine:init",()=>{z(window.Alpine)});})();
@@ -0,0 +1,249 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // builds/module.js
20
+ var module_exports = {};
21
+ __export(module_exports, {
22
+ default: () => module_default
23
+ });
24
+ module.exports = __toCommonJS(module_exports);
25
+
26
+ // ../../node_modules/@flexilla/modal/dist/modal.js
27
+ var j = Object.defineProperty;
28
+ var z = (t, e, n) => e in t ? j(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
29
+ var c = (t, e, n) => z(t, typeof e != "symbol" ? e + "" : e, n);
30
+ var O = class {
31
+ static initGlobalRegistry() {
32
+ window.$flexillaInstances || (window.$flexillaInstances = {});
33
+ }
34
+ static register(e, n, a) {
35
+ return this.initGlobalRegistry(), window.$flexillaInstances[e] || (window.$flexillaInstances[e] = []), this.getInstance(e, n) || (window.$flexillaInstances[e].push({ element: n, instance: a }), a);
36
+ }
37
+ static getInstance(e, n) {
38
+ var a, d;
39
+ return this.initGlobalRegistry(), (d = (a = window.$flexillaInstances[e]) == null ? void 0 : a.find(
40
+ (s) => s.element === n
41
+ )) == null ? void 0 : d.instance;
42
+ }
43
+ static removeInstance(e, n) {
44
+ this.initGlobalRegistry(), window.$flexillaInstances[e] && (window.$flexillaInstances[e] = window.$flexillaInstances[e].filter(
45
+ (a) => a.element !== n
46
+ ));
47
+ }
48
+ };
49
+ var r = (t, e = document.body) => e.querySelector(t);
50
+ var H = (t, e = document.body) => Array.from(e.querySelectorAll(t));
51
+ var J = ({
52
+ newElement: t,
53
+ existingElement: e
54
+ }) => {
55
+ if (!(t instanceof HTMLElement) || !(e instanceof HTMLElement))
56
+ throw new Error("Both parameters must be valid HTML elements.");
57
+ const n = e.parentElement;
58
+ if (n) n.insertBefore(t, e);
59
+ else throw new Error("Existing element must have a parent element.");
60
+ };
61
+ var Q = ({
62
+ element: t,
63
+ callback: e,
64
+ type: n,
65
+ keysCheck: a
66
+ }) => {
67
+ const d = getComputedStyle(t), s = d.animation;
68
+ if (s !== "none" && s !== "" && !a.includes(s)) {
69
+ const f = "animationend", u = () => {
70
+ t.removeEventListener(f, u), e();
71
+ };
72
+ t.addEventListener(f, u, { once: true });
73
+ } else
74
+ e();
75
+ };
76
+ var N = ({ element: t, callback: e }) => {
77
+ Q({
78
+ element: t,
79
+ callback: e,
80
+ type: "animation",
81
+ keysCheck: ["none 0s ease 0s 1 normal none running"]
82
+ });
83
+ };
84
+ var B = (t, e, n) => {
85
+ const a = new CustomEvent(e, { detail: n });
86
+ t.dispatchEvent(a);
87
+ };
88
+ var W = (t) => {
89
+ var e;
90
+ t instanceof HTMLElement && ((e = t.parentElement) == null || e.removeChild(t));
91
+ };
92
+ var U = ({ modalContent: t, overlayClassName: e }) => {
93
+ const n = document.createElement("span");
94
+ return n.setAttribute("aria-hidden", "true"), J({ newElement: n, existingElement: t }), n.classList.add(...e), n.setAttribute("data-modal-overlay", ""), n;
95
+ };
96
+ var k = (t, e, n) => {
97
+ if (!(e instanceof HTMLElement)) throw new Error("No modal-content found");
98
+ t.setAttribute("aria-hidden", n === "open" ? "false" : "true"), t.setAttribute("data-state", n), e.setAttribute("data-state", n);
99
+ const a = r("[data-modal-overlay]", t);
100
+ a instanceof HTMLElement && a.setAttribute("data-state", n);
101
+ };
102
+ var V = (t, e, n) => {
103
+ if (!t) {
104
+ e || (document.body.style.overflowY = "auto");
105
+ return;
106
+ }
107
+ H("[data-fx-modal][data-state=open]:not([data-allow-body-scroll=true]").filter((s) => s !== n).length === 0 && !e && (document.body.style.overflowY = "auto");
108
+ };
109
+ var Z = (t, e, n) => {
110
+ var q;
111
+ if (!(t instanceof HTMLElement)) throw new Error("Modal Element must be a valid element");
112
+ const { animateContent: a, allowBodyScroll: d, preventCloseModal: s, overlayClass: f, onShow: u, onHide: h, onToggle: m, beforeHide: b, enableStackedModals: g } = n, p = d || t.hasAttribute("data-allow-body-scroll") && t.getAttribute("data-allow-body-scroll") !== "false", F = s || t.hasAttribute("data-prevent-close-modal") && t.getAttribute("data-prevent-close-modal") !== "false", C = g || t.hasAttribute("data-enable-stacked") && t.getAttribute("data-enable-stacked") !== "false", K = (f == null ? void 0 : f.split(" ")) || ((q = t.dataset.modalOverlay) == null ? void 0 : q.split(" ")) || "";
113
+ let x = false;
114
+ t.setAttribute("data-allow-body-scroll", `${p}`);
115
+ const o = r("[data-modal-content]", t), L = H("[data-close-modal]", t);
116
+ let i = null, S = false;
117
+ if (r("[data-modal-overlay]", t) instanceof HTMLElement && (i = r("[data-modal-overlay]", t), i.setAttribute("data-overlay-nature", "default"), S = true), !(o instanceof HTMLElement)) throw new Error("Modal content element not found");
118
+ const D = o.dataset.enterAnimation || "", P = o.dataset.exitAnimation || "";
119
+ o.setAttribute("data-state", "close");
120
+ const R = (l) => {
121
+ l.preventDefault(), l.key === "Escape" && !F && A();
122
+ }, X = (l) => {
123
+ if (C) return;
124
+ const w = H("[data-fx-modal][data-state=open]");
125
+ for (const y of w)
126
+ if (y !== l) {
127
+ const M = r("[data-modal-overlay]", y);
128
+ M.setAttribute("data-state", "close");
129
+ const I = r("[data-modal-content]", y), E = M.getAttribute("data-overlay-nature") === "default";
130
+ k(y, I, "close"), E || W(M);
131
+ }
132
+ }, T = () => {
133
+ if (t.getAttribute("data-state") !== "open") {
134
+ if (X(t), i = S ? i : U({
135
+ modalContent: o,
136
+ overlayClassName: K
137
+ }), i == null || i.setAttribute("data-state", "open"), B(t, "modal-open", { modalId: t.id }), a || D !== "") {
138
+ const w = a ? a.enterAnimation : D;
139
+ w !== "" && o.style.setProperty("--un-modal-animation", w), k(t, o, "open"), N({
140
+ element: o,
141
+ callback: () => {
142
+ o.style.removeProperty("--un-modal-animation");
143
+ }
144
+ });
145
+ } else
146
+ k(t, o, "open");
147
+ p || (document.body.style.overflow = "hidden"), x || (document.addEventListener("keydown", R), x = true), t.focus(), s || i.addEventListener("click", A), u == null || u(), m == null || m({ isHidden: false });
148
+ }
149
+ }, A = () => {
150
+ var E;
151
+ let l = false;
152
+ B(t, "before-hide", {
153
+ modalId: t.id,
154
+ setExitAction: ($) => {
155
+ l = $;
156
+ }
157
+ });
158
+ const w = (E = b == null ? void 0 : b()) == null ? void 0 : E.cancelAction;
159
+ if (l || w) return;
160
+ const y = () => {
161
+ k(t, o, "close"), V(C, p, t), S || W(i), B(t, "modal-close", { modalId: t.id });
162
+ }, M = () => {
163
+ x && (document.removeEventListener("keydown", R), x = false), t.blur(), h == null || h(), m == null || m({ isHidden: true });
164
+ }, I = (a == null ? void 0 : a.exitAnimation) && a.exitAnimation !== "" || P !== "";
165
+ if (i == null || i.setAttribute("data-state", "close"), o.setAttribute("data-state", "close"), I) {
166
+ const $ = a ? a.exitAnimation || "" : P;
167
+ o.style.setProperty("--un-modal-animation", $);
168
+ }
169
+ N({
170
+ element: o,
171
+ callback: () => {
172
+ I && o.style.removeProperty("--un-modal-animation"), y(), M();
173
+ }
174
+ });
175
+ }, G = (l) => {
176
+ l.preventDefault(), A();
177
+ };
178
+ return { autoInitModal: () => {
179
+ if (e instanceof HTMLElement && e.addEventListener("click", T), L.length > 0)
180
+ for (const l of L)
181
+ l.addEventListener("click", G);
182
+ }, showModal: T, hideModal: A, isHidden: () => t.dataset.state === "close", cleanup: () => {
183
+ if (e instanceof HTMLElement && e.removeEventListener("click", T), L.length > 0)
184
+ for (const l of L)
185
+ l.removeEventListener("click", G);
186
+ !s && i instanceof HTMLElement && i.removeEventListener("click", A), O.removeInstance("modal", t);
187
+ } };
188
+ };
189
+ var v = class v2 {
190
+ /**
191
+ * Creates a new Modal instance
192
+ * @param modal - The modal element or selector string to initialize
193
+ * @param options - Configuration options for the modal behavior
194
+ * @param triggerElement - Optional trigger element or selector that opens the modal
195
+ * @throws {Error} When the provided modal element is invalid or cannot be found
196
+ */
197
+ constructor(e, n = {}, a) {
198
+ c(this, "modalElement");
199
+ c(this, "showModal");
200
+ c(this, "hideModal");
201
+ c(this, "cleanup");
202
+ c(this, "isHidden");
203
+ c(this, "options");
204
+ c(this, "state");
205
+ const d = typeof e == "string" ? r(e) : e;
206
+ if (!(d instanceof HTMLElement)) throw new Error("Modal element not found or invalid. Please provide a valid HTMLElement or selector.");
207
+ this.modalElement = d, this.options = n, this.state = (n == null ? void 0 : n.defaultState) || this.modalElement.dataset.state || "close";
208
+ const s = O.getInstance("modal", this.modalElement);
209
+ if (s)
210
+ return s;
211
+ this.modalElement.hasAttribute("data-fx-modal") || this.modalElement.setAttribute("data-fx-modal", "");
212
+ const f = d.dataset.modalId, u = (typeof a == "string" ? r(a) : a) || r(`[data-modal-target='${f}']`), { showModal: h, hideModal: m, autoInitModal: b, isHidden: g, cleanup: p } = Z(d, u, this.options);
213
+ this.state === "open" && h(), b(), this.showModal = h, this.hideModal = m, this.isHidden = g, this.cleanup = p, O.register("modal", this.modalElement, this);
214
+ }
215
+ };
216
+ c(v, "autoInit", (e = "[data-fx-modal]") => {
217
+ const n = H(e);
218
+ for (const a of n) new v(a);
219
+ }), /**
220
+ * Creates and initializes a new Modal instance
221
+ * @param modal - The modal element or selector string
222
+ * @param options - Configuration options for the modal
223
+ * @param triggerElement - Optional trigger element or selector
224
+ * @returns {Modal} A new Modal instance
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * const modal = Modal.init('#myModal', {
229
+ * defaultState: 'open',
230
+ * allowBodyScroll: true
231
+ * });
232
+ * ```
233
+ */
234
+ c(v, "init", (e, n = {}, a) => new v(e, n, a));
235
+ var Y = v;
236
+
237
+ // src/index.js
238
+ function Modal(Alpine) {
239
+ Alpine.directive("modal", (el, {}, { cleanup }) => {
240
+ const modal_ = new Y(el);
241
+ cleanup(() => {
242
+ modal_.cleanup();
243
+ });
244
+ });
245
+ }
246
+ var src_default = Modal;
247
+
248
+ // builds/module.js
249
+ var module_default = src_default;
@@ -0,0 +1,227 @@
1
+ // ../../node_modules/@flexilla/modal/dist/modal.js
2
+ var j = Object.defineProperty;
3
+ var z = (t, e, n) => e in t ? j(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
4
+ var c = (t, e, n) => z(t, typeof e != "symbol" ? e + "" : e, n);
5
+ var O = class {
6
+ static initGlobalRegistry() {
7
+ window.$flexillaInstances || (window.$flexillaInstances = {});
8
+ }
9
+ static register(e, n, a) {
10
+ return this.initGlobalRegistry(), window.$flexillaInstances[e] || (window.$flexillaInstances[e] = []), this.getInstance(e, n) || (window.$flexillaInstances[e].push({ element: n, instance: a }), a);
11
+ }
12
+ static getInstance(e, n) {
13
+ var a, d;
14
+ return this.initGlobalRegistry(), (d = (a = window.$flexillaInstances[e]) == null ? void 0 : a.find(
15
+ (s) => s.element === n
16
+ )) == null ? void 0 : d.instance;
17
+ }
18
+ static removeInstance(e, n) {
19
+ this.initGlobalRegistry(), window.$flexillaInstances[e] && (window.$flexillaInstances[e] = window.$flexillaInstances[e].filter(
20
+ (a) => a.element !== n
21
+ ));
22
+ }
23
+ };
24
+ var r = (t, e = document.body) => e.querySelector(t);
25
+ var H = (t, e = document.body) => Array.from(e.querySelectorAll(t));
26
+ var J = ({
27
+ newElement: t,
28
+ existingElement: e
29
+ }) => {
30
+ if (!(t instanceof HTMLElement) || !(e instanceof HTMLElement))
31
+ throw new Error("Both parameters must be valid HTML elements.");
32
+ const n = e.parentElement;
33
+ if (n) n.insertBefore(t, e);
34
+ else throw new Error("Existing element must have a parent element.");
35
+ };
36
+ var Q = ({
37
+ element: t,
38
+ callback: e,
39
+ type: n,
40
+ keysCheck: a
41
+ }) => {
42
+ const d = getComputedStyle(t), s = d.animation;
43
+ if (s !== "none" && s !== "" && !a.includes(s)) {
44
+ const f = "animationend", u = () => {
45
+ t.removeEventListener(f, u), e();
46
+ };
47
+ t.addEventListener(f, u, { once: true });
48
+ } else
49
+ e();
50
+ };
51
+ var N = ({ element: t, callback: e }) => {
52
+ Q({
53
+ element: t,
54
+ callback: e,
55
+ type: "animation",
56
+ keysCheck: ["none 0s ease 0s 1 normal none running"]
57
+ });
58
+ };
59
+ var B = (t, e, n) => {
60
+ const a = new CustomEvent(e, { detail: n });
61
+ t.dispatchEvent(a);
62
+ };
63
+ var W = (t) => {
64
+ var e;
65
+ t instanceof HTMLElement && ((e = t.parentElement) == null || e.removeChild(t));
66
+ };
67
+ var U = ({ modalContent: t, overlayClassName: e }) => {
68
+ const n = document.createElement("span");
69
+ return n.setAttribute("aria-hidden", "true"), J({ newElement: n, existingElement: t }), n.classList.add(...e), n.setAttribute("data-modal-overlay", ""), n;
70
+ };
71
+ var k = (t, e, n) => {
72
+ if (!(e instanceof HTMLElement)) throw new Error("No modal-content found");
73
+ t.setAttribute("aria-hidden", n === "open" ? "false" : "true"), t.setAttribute("data-state", n), e.setAttribute("data-state", n);
74
+ const a = r("[data-modal-overlay]", t);
75
+ a instanceof HTMLElement && a.setAttribute("data-state", n);
76
+ };
77
+ var V = (t, e, n) => {
78
+ if (!t) {
79
+ e || (document.body.style.overflowY = "auto");
80
+ return;
81
+ }
82
+ H("[data-fx-modal][data-state=open]:not([data-allow-body-scroll=true]").filter((s) => s !== n).length === 0 && !e && (document.body.style.overflowY = "auto");
83
+ };
84
+ var Z = (t, e, n) => {
85
+ var q;
86
+ if (!(t instanceof HTMLElement)) throw new Error("Modal Element must be a valid element");
87
+ const { animateContent: a, allowBodyScroll: d, preventCloseModal: s, overlayClass: f, onShow: u, onHide: h, onToggle: m, beforeHide: b, enableStackedModals: g } = n, p = d || t.hasAttribute("data-allow-body-scroll") && t.getAttribute("data-allow-body-scroll") !== "false", F = s || t.hasAttribute("data-prevent-close-modal") && t.getAttribute("data-prevent-close-modal") !== "false", C = g || t.hasAttribute("data-enable-stacked") && t.getAttribute("data-enable-stacked") !== "false", K = (f == null ? void 0 : f.split(" ")) || ((q = t.dataset.modalOverlay) == null ? void 0 : q.split(" ")) || "";
88
+ let x = false;
89
+ t.setAttribute("data-allow-body-scroll", `${p}`);
90
+ const o = r("[data-modal-content]", t), L = H("[data-close-modal]", t);
91
+ let i = null, S = false;
92
+ if (r("[data-modal-overlay]", t) instanceof HTMLElement && (i = r("[data-modal-overlay]", t), i.setAttribute("data-overlay-nature", "default"), S = true), !(o instanceof HTMLElement)) throw new Error("Modal content element not found");
93
+ const D = o.dataset.enterAnimation || "", P = o.dataset.exitAnimation || "";
94
+ o.setAttribute("data-state", "close");
95
+ const R = (l) => {
96
+ l.preventDefault(), l.key === "Escape" && !F && A();
97
+ }, X = (l) => {
98
+ if (C) return;
99
+ const w = H("[data-fx-modal][data-state=open]");
100
+ for (const y of w)
101
+ if (y !== l) {
102
+ const M = r("[data-modal-overlay]", y);
103
+ M.setAttribute("data-state", "close");
104
+ const I = r("[data-modal-content]", y), E = M.getAttribute("data-overlay-nature") === "default";
105
+ k(y, I, "close"), E || W(M);
106
+ }
107
+ }, T = () => {
108
+ if (t.getAttribute("data-state") !== "open") {
109
+ if (X(t), i = S ? i : U({
110
+ modalContent: o,
111
+ overlayClassName: K
112
+ }), i == null || i.setAttribute("data-state", "open"), B(t, "modal-open", { modalId: t.id }), a || D !== "") {
113
+ const w = a ? a.enterAnimation : D;
114
+ w !== "" && o.style.setProperty("--un-modal-animation", w), k(t, o, "open"), N({
115
+ element: o,
116
+ callback: () => {
117
+ o.style.removeProperty("--un-modal-animation");
118
+ }
119
+ });
120
+ } else
121
+ k(t, o, "open");
122
+ p || (document.body.style.overflow = "hidden"), x || (document.addEventListener("keydown", R), x = true), t.focus(), s || i.addEventListener("click", A), u == null || u(), m == null || m({ isHidden: false });
123
+ }
124
+ }, A = () => {
125
+ var E;
126
+ let l = false;
127
+ B(t, "before-hide", {
128
+ modalId: t.id,
129
+ setExitAction: ($) => {
130
+ l = $;
131
+ }
132
+ });
133
+ const w = (E = b == null ? void 0 : b()) == null ? void 0 : E.cancelAction;
134
+ if (l || w) return;
135
+ const y = () => {
136
+ k(t, o, "close"), V(C, p, t), S || W(i), B(t, "modal-close", { modalId: t.id });
137
+ }, M = () => {
138
+ x && (document.removeEventListener("keydown", R), x = false), t.blur(), h == null || h(), m == null || m({ isHidden: true });
139
+ }, I = (a == null ? void 0 : a.exitAnimation) && a.exitAnimation !== "" || P !== "";
140
+ if (i == null || i.setAttribute("data-state", "close"), o.setAttribute("data-state", "close"), I) {
141
+ const $ = a ? a.exitAnimation || "" : P;
142
+ o.style.setProperty("--un-modal-animation", $);
143
+ }
144
+ N({
145
+ element: o,
146
+ callback: () => {
147
+ I && o.style.removeProperty("--un-modal-animation"), y(), M();
148
+ }
149
+ });
150
+ }, G = (l) => {
151
+ l.preventDefault(), A();
152
+ };
153
+ return { autoInitModal: () => {
154
+ if (e instanceof HTMLElement && e.addEventListener("click", T), L.length > 0)
155
+ for (const l of L)
156
+ l.addEventListener("click", G);
157
+ }, showModal: T, hideModal: A, isHidden: () => t.dataset.state === "close", cleanup: () => {
158
+ if (e instanceof HTMLElement && e.removeEventListener("click", T), L.length > 0)
159
+ for (const l of L)
160
+ l.removeEventListener("click", G);
161
+ !s && i instanceof HTMLElement && i.removeEventListener("click", A), O.removeInstance("modal", t);
162
+ } };
163
+ };
164
+ var v = class v2 {
165
+ /**
166
+ * Creates a new Modal instance
167
+ * @param modal - The modal element or selector string to initialize
168
+ * @param options - Configuration options for the modal behavior
169
+ * @param triggerElement - Optional trigger element or selector that opens the modal
170
+ * @throws {Error} When the provided modal element is invalid or cannot be found
171
+ */
172
+ constructor(e, n = {}, a) {
173
+ c(this, "modalElement");
174
+ c(this, "showModal");
175
+ c(this, "hideModal");
176
+ c(this, "cleanup");
177
+ c(this, "isHidden");
178
+ c(this, "options");
179
+ c(this, "state");
180
+ const d = typeof e == "string" ? r(e) : e;
181
+ if (!(d instanceof HTMLElement)) throw new Error("Modal element not found or invalid. Please provide a valid HTMLElement or selector.");
182
+ this.modalElement = d, this.options = n, this.state = (n == null ? void 0 : n.defaultState) || this.modalElement.dataset.state || "close";
183
+ const s = O.getInstance("modal", this.modalElement);
184
+ if (s)
185
+ return s;
186
+ this.modalElement.hasAttribute("data-fx-modal") || this.modalElement.setAttribute("data-fx-modal", "");
187
+ const f = d.dataset.modalId, u = (typeof a == "string" ? r(a) : a) || r(`[data-modal-target='${f}']`), { showModal: h, hideModal: m, autoInitModal: b, isHidden: g, cleanup: p } = Z(d, u, this.options);
188
+ this.state === "open" && h(), b(), this.showModal = h, this.hideModal = m, this.isHidden = g, this.cleanup = p, O.register("modal", this.modalElement, this);
189
+ }
190
+ };
191
+ c(v, "autoInit", (e = "[data-fx-modal]") => {
192
+ const n = H(e);
193
+ for (const a of n) new v(a);
194
+ }), /**
195
+ * Creates and initializes a new Modal instance
196
+ * @param modal - The modal element or selector string
197
+ * @param options - Configuration options for the modal
198
+ * @param triggerElement - Optional trigger element or selector
199
+ * @returns {Modal} A new Modal instance
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * const modal = Modal.init('#myModal', {
204
+ * defaultState: 'open',
205
+ * allowBodyScroll: true
206
+ * });
207
+ * ```
208
+ */
209
+ c(v, "init", (e, n = {}, a) => new v(e, n, a));
210
+ var Y = v;
211
+
212
+ // src/index.js
213
+ function Modal(Alpine) {
214
+ Alpine.directive("modal", (el, {}, { cleanup }) => {
215
+ const modal_ = new Y(el);
216
+ cleanup(() => {
217
+ modal_.cleanup();
218
+ });
219
+ });
220
+ }
221
+ var src_default = Modal;
222
+
223
+ // builds/module.js
224
+ var module_default = src_default;
225
+ export {
226
+ module_default as default
227
+ };
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@flexilla/alpine-modal",
3
+ "version": "0.0.0",
4
+ "description": "AlpineJS plugin for creating Modal, Dialog, alert dialog components",
5
+ "type": "module",
6
+ "private": false,
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "license": "MIT",
11
+ "author": {
12
+ "name": "Johnkat MJ",
13
+ "url": "https://github.com/johnkat-mj"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/unoforge/alpine-plugin.git"
18
+ },
19
+ "main": "src/index.js",
20
+ "module": "dist/module.esm.js",
21
+ "scripts": {
22
+ "build": "node ./scripts/build.js",
23
+ "watch": "node ./scripts/build.js --watch",
24
+ "lint": "eslint .",
25
+ "lint-fix": "eslint . --fix"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/unoforge/alpine-plugin/issues"
29
+ },
30
+ "homepage": "https://github.com/unoforge/alpine-plugin/packages/alpine-modal/README.md",
31
+ "devDependencies": {
32
+ "brotli-size": "^4.0.0",
33
+ "esbuild": "^0.25.1",
34
+ "eslint-plugin-import": "^2.31.0",
35
+ "eslint-plugin-node": "^11.1.0",
36
+ "eslint-plugin-promise": "^7.2.1",
37
+ "eslint-plugin-standard": "^4.1.0",
38
+ "lint-staged": "^15.5.0"
39
+ },
40
+ "files": [
41
+ "LICENSE",
42
+ "README.md",
43
+ "src/index.js",
44
+ "package.json",
45
+ "dist"
46
+ ],
47
+ "keywords": [
48
+ "AlpineJS",
49
+ "Alpine Modal",
50
+ "Dialog",
51
+ "Modal",
52
+ "Alert Dialog",
53
+ "Modal Dialog",
54
+ "Alpine Modal Plugin",
55
+ "Alpine Dialog Plugin",
56
+ "Alpine Plugin",
57
+ "Alpinejs Pugin",
58
+ "ts",
59
+ "Dissmissible",
60
+ "component",
61
+ "interactive",
62
+ "intercative component",
63
+ "Flexilla",
64
+ "Dissmiss"
65
+ ],
66
+ "dependencies": {
67
+ "@flexilla/modal": "^2.0.9"
68
+ },
69
+ "gitHead": "3c7ea3f74d67ac5d9ab2817d747ad7127eb542b5"
70
+ }
package/src/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import { Modal as FlexillaModal } from "@flexilla/modal";
2
+
3
+ function Modal(Alpine) {
4
+ Alpine.directive("modal", (el, {}, { cleanup }) => {
5
+ const modal_ = new FlexillaModal(el);
6
+ cleanup(() => {
7
+ modal_.cleanup()
8
+ });
9
+ });
10
+ }
11
+
12
+ export default Modal;