@flexilla/alpine-offcanvas 0.3.0 → 0.3.1

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/cdn.js CHANGED
@@ -1,158 +1,172 @@
1
1
  (() => {
2
2
  // ../../node_modules/@flexilla/offcanvas/dist/offcanvas.js
3
- var g = Object.defineProperty;
4
- var w = (t, e, n) => e in t ? g(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
5
- var o = (t, e, n) => w(t, typeof e != "symbol" ? e + "" : e, n);
6
- var m = (t, e = document.body) => e.querySelector(t);
7
- var h = (t, e = document.body) => Array.from(e.querySelectorAll(t));
8
- var y = ({
9
- newElement: t,
10
- existingElement: e
3
+ var y = Object.defineProperty;
4
+ var A = (e, t, n) => t in e ? y(e, t, { enumerable: true, configurable: true, writable: true, value: n }) : e[t] = n;
5
+ var o = (e, t, n) => A(e, typeof t != "symbol" ? t + "" : t, n);
6
+ var u = (e, t = document.body) => t.querySelector(e);
7
+ var v = (e, t = document.body) => Array.from(t.querySelectorAll(e));
8
+ var k = ({
9
+ newElement: e,
10
+ existingElement: t
11
11
  }) => {
12
- if (!(t instanceof HTMLElement) || !(e instanceof HTMLElement))
12
+ if (!(e instanceof HTMLElement) || !(t instanceof HTMLElement))
13
13
  throw new Error("Both parameters must be valid HTML elements.");
14
- const n = e.parentElement;
14
+ const n = t.parentElement;
15
15
  if (n)
16
- n.insertBefore(t, e);
16
+ n.insertBefore(e, t);
17
17
  else
18
18
  throw new Error("Existing element must have a parent element.");
19
19
  };
20
- var k = ({
21
- element: t,
22
- callback: e,
20
+ var O = ({
21
+ element: e,
22
+ callback: t,
23
23
  type: n,
24
24
  keysCheck: s
25
25
  }) => {
26
- const a = getComputedStyle(t), i = a.transition;
26
+ const a = getComputedStyle(e), i = a.transition;
27
27
  if (i !== "none" && i !== "" && !s.includes(i)) {
28
- const l = "transitionend", c = () => {
29
- t.removeEventListener(l, c), e();
28
+ const l = "transitionend", f = () => {
29
+ e.removeEventListener(l, f), t();
30
30
  };
31
- t.addEventListener(l, c, { once: true });
31
+ e.addEventListener(l, f, { once: true });
32
32
  } else
33
- e();
33
+ t();
34
34
  };
35
- var O = ({
36
- element: t,
37
- callback: e
35
+ var B = ({
36
+ element: e,
37
+ callback: t
38
38
  }) => {
39
- k({
40
- element: t,
41
- callback: e,
39
+ O({
40
+ element: e,
41
+ callback: t,
42
42
  type: "transition",
43
43
  keysCheck: ["all 0s ease 0s", "all"]
44
44
  });
45
45
  };
46
- var v = (t, e, n) => {
47
- const s = new CustomEvent(e, { detail: n });
48
- t.dispatchEvent(s);
46
+ var h = (e, t, n) => {
47
+ const s = new CustomEvent(t, { detail: n });
48
+ e.dispatchEvent(s);
49
49
  };
50
- function B(t) {
51
- const e = () => {
50
+ function I(e) {
51
+ const t = () => {
52
52
  document.querySelector(
53
53
  "[data-fx-component]:not([data-component-initialized])"
54
- ) ? requestAnimationFrame(e) : t();
54
+ ) ? requestAnimationFrame(t) : e();
55
55
  };
56
- e();
56
+ t();
57
57
  }
58
- function A(t, e, n = "move") {
59
- if (!(t instanceof HTMLElement))
60
- throw new Error("Source element must be an HTMLElement");
58
+ var E = "data-fx-teleport-root";
59
+ var m = "data-fx-teleported";
60
+ var L = {
61
+ append: () => {
62
+ },
63
+ remove: () => {
64
+ },
65
+ restore: () => {
66
+ }
67
+ };
68
+ function S(e, t, n = "move") {
69
+ var s;
61
70
  if (!(e instanceof HTMLElement))
71
+ throw new Error("Source element must be an HTMLElement");
72
+ if (!(t instanceof HTMLElement))
62
73
  throw new Error("Target element must be an HTMLElement");
63
74
  if (!["move", "detachable"].includes(n))
64
75
  throw new Error(`Invalid teleport mode: ${n}. Must be "move" or "detachable".`);
65
- let s = document.createComment("teleporter-placeholder");
66
- const a = t.parentNode;
67
- return a ? a.insertBefore(s, t) : console.warn("Element has no parent; placeholder not inserted."), n === "move" ? (t.parentNode && e.appendChild(t), {
76
+ if ((s = e.parentElement) != null && s.closest(`[${E}]`))
77
+ return L;
78
+ e.setAttribute(E, "");
79
+ let a = document.createComment("teleporter-placeholder");
80
+ const i = e.parentNode;
81
+ return i && i.insertBefore(a, e), n === "move" ? (e.parentNode && (t.appendChild(e), e.setAttribute(m, "")), {
68
82
  append() {
69
- t.parentNode !== e && e.appendChild(t);
83
+ e.parentNode !== t && (t.appendChild(e), e.setAttribute(m, ""));
70
84
  },
71
85
  remove() {
72
- s != null && s.parentNode && t.parentNode && s.parentNode.insertBefore(t, s);
86
+ a != null && a.parentNode && e.parentNode && a.parentNode.insertBefore(e, a);
73
87
  },
74
88
  restore() {
75
- s != null && s.parentNode && t.parentNode !== a && s.parentNode.insertBefore(t, s);
89
+ a != null && a.parentNode && e.parentNode !== i && a.parentNode.insertBefore(e, a);
76
90
  }
77
- }) : (t.parentNode && e.appendChild(t), {
91
+ }) : (e.parentNode && (t.appendChild(e), e.setAttribute(m, "")), {
78
92
  append() {
79
- e.contains(t) || e.appendChild(t);
93
+ t.contains(e) || t.appendChild(e);
80
94
  },
81
95
  remove() {
82
- t.parentNode && t.remove();
96
+ e.parentNode && e.remove();
83
97
  },
84
98
  restore() {
85
- s != null && s.parentNode && !t.parentNode && s.parentNode.insertBefore(t, s);
99
+ a != null && a.parentNode && !e.parentNode && a.parentNode.insertBefore(e, a);
86
100
  }
87
101
  });
88
102
  }
89
- var I = (t) => {
90
- var e;
91
- return (e = t.parentElement) == null ? void 0 : e.removeChild(t);
103
+ var T = (e) => {
104
+ var t;
105
+ return (t = e.parentElement) == null ? void 0 : t.removeChild(e);
92
106
  };
93
- var C = (t) => {
94
- t.setAttribute("data-state", "invisible"), O({
95
- element: t,
107
+ var g = (e) => {
108
+ e.setAttribute("data-state", "invisible"), B({
109
+ element: e,
96
110
  callback() {
97
- I(t);
111
+ T(e);
98
112
  }
99
113
  });
100
114
  };
101
- var L = (t, e) => {
102
- const n = t;
115
+ var x = (e, t) => {
116
+ const n = e;
103
117
  if (n === "" || !n)
104
118
  return;
105
119
  const s = document.createElement("div");
106
- if (s.setAttribute("aria-hidden", "true"), s.setAttribute("data-state", "visible"), s.setAttribute("data-fx-offcanvas-overlay", ""), s.setAttribute("data-offcanvas-el", e), n === "")
120
+ if (s.setAttribute("aria-hidden", "true"), s.setAttribute("data-state", "visible"), s.setAttribute("data-fx-offcanvas-overlay", ""), s.setAttribute("data-offcanvas-el", t), n === "")
107
121
  return;
108
122
  const a = n.split(" ");
109
123
  return n !== "" && s.classList.add(...a), s;
110
124
  };
111
- var u = (t, e, n) => {
112
- t.setAttribute("aria-hidden", n === "open" ? "false" : "true"), t.setAttribute("data-state", n), e || S(n);
125
+ var C = (e, t, n) => {
126
+ e.setAttribute("aria-hidden", n === "open" ? "false" : "true"), e.setAttribute("data-state", n), t || $(n);
113
127
  };
114
- var S = (t) => {
115
- document.body.style.overflow = t === "open" ? "hidden" : "", document.body.style.overflowY = t === "open" ? "hidden" : "auto";
128
+ var $ = (e) => {
129
+ document.body.style.overflow = e === "open" ? "hidden" : "", document.body.style.overflowY = e === "open" ? "hidden" : "auto";
116
130
  };
117
- var T = (t, e) => {
118
- if (t === e)
131
+ var N = (e, t) => {
132
+ if (e === t)
119
133
  return;
120
- t.setAttribute("aria-hidden", "true"), t.setAttribute("data-state", "close");
121
- const n = m(`[data-fx-offcanvas-overlay][data-offcanvas-el=${t.getAttribute("id")}]`, t.parentElement);
122
- n instanceof HTMLElement && C(n);
134
+ e.setAttribute("aria-hidden", "true"), e.setAttribute("data-state", "close");
135
+ const n = u(`[data-fx-offcanvas-overlay][data-offcanvas-el=${e.getAttribute("id")}]`, e.parentElement);
136
+ n instanceof HTMLElement && g(n);
123
137
  };
124
- var x = (t) => {
125
- const e = h("[data-fx-offcanvas][data-state=open]");
126
- if (!(e.length <= 0))
127
- for (const n of e)
128
- T(n, t);
138
+ var H = (e) => {
139
+ const t = v("[data-fx-offcanvas][data-state=open]");
140
+ if (!(t.length <= 0))
141
+ for (const n of t)
142
+ N(n, e);
129
143
  };
130
144
  var d = class {
131
145
  static initGlobalRegistry() {
132
146
  window.$flexillaInstances || (window.$flexillaInstances = {});
133
147
  }
134
- static register(e, n, s) {
135
- return this.initGlobalRegistry(), window.$flexillaInstances[e] || (window.$flexillaInstances[e] = []), this.getInstance(e, n) || (window.$flexillaInstances[e].push({ element: n, instance: s }), s);
148
+ static register(t, n, s) {
149
+ return this.initGlobalRegistry(), window.$flexillaInstances[t] || (window.$flexillaInstances[t] = []), this.getInstance(t, n) || (window.$flexillaInstances[t].push({ element: n, instance: s }), s);
136
150
  }
137
- static getInstance(e, n) {
151
+ static getInstance(t, n) {
138
152
  var s, a;
139
- return this.initGlobalRegistry(), (a = (s = window.$flexillaInstances[e]) == null ? void 0 : s.find(
153
+ return this.initGlobalRegistry(), (a = (s = window.$flexillaInstances[t]) == null ? void 0 : s.find(
140
154
  (i) => i.element === n
141
155
  )) == null ? void 0 : a.instance;
142
156
  }
143
- static removeInstance(e, n) {
144
- this.initGlobalRegistry(), window.$flexillaInstances[e] && (window.$flexillaInstances[e] = window.$flexillaInstances[e].filter(
157
+ static removeInstance(t, n) {
158
+ this.initGlobalRegistry(), window.$flexillaInstances[t] && (window.$flexillaInstances[t] = window.$flexillaInstances[t].filter(
145
159
  (s) => s.element !== n
146
160
  ));
147
161
  }
148
- static setup(e) {
149
- e.setAttribute("data-fx-component", "fx");
162
+ static setup(t) {
163
+ t.setAttribute("data-fx-component", "fx");
150
164
  }
151
- static initialized(e) {
152
- e.setAttribute("data-component-initialized", "initialized");
165
+ static initialized(t) {
166
+ t.setAttribute("data-component-initialized", "initialized");
153
167
  }
154
168
  };
155
- var f = class f2 {
169
+ var c = class c2 {
156
170
  /**
157
171
  * Creates an instance of Offcanvas.
158
172
  * @param offcanvas - The offcanvas element selector or HTMLElement
@@ -170,7 +184,7 @@
170
184
  * });
171
185
  * ```
172
186
  */
173
- constructor(e, n = {}) {
187
+ constructor(t, n = {}) {
174
188
  o(this, "offCanvasElement");
175
189
  o(this, "offCanvasTriggers");
176
190
  o(this, "offCanvasCloseBtns");
@@ -182,34 +196,34 @@
182
196
  o(this, "options");
183
197
  o(this, "teleporter");
184
198
  o(this, "moveElOnInit", () => {
185
- B(() => this.teleporter.append());
199
+ I(() => this.teleporter.append());
186
200
  });
187
- o(this, "closeWhenClickOutSide", (e2) => {
188
- const n2 = this.offCanvasElement.getAttribute("data-state") === "open", s2 = !this.offCanvasElement.contains(e2.target) && ![...this.offCanvasTriggers].includes(e2.target);
201
+ o(this, "closeWhenClickOutSide", (t2) => {
202
+ const n2 = this.offCanvasElement.getAttribute("data-state") === "open", s2 = !this.offCanvasElement.contains(t2.target) && ![...this.offCanvasTriggers].includes(t2.target);
189
203
  n2 && s2 && this.closeOffCanvas();
190
204
  });
191
205
  o(this, "closeOffCanvas", () => {
192
- var i2, l2, c2, r2, p;
193
- let e2 = false;
194
- if (v(this.offCanvasElement, "offcanvas-before-hide", {
206
+ var i2, l2, f2, r2, p;
207
+ let t2 = false;
208
+ if (h(this.offCanvasElement, "offcanvas-before-hide", {
195
209
  offcanvasId: this.offCanvasElement.id,
196
- setExitAction: (b) => {
197
- e2 = b;
210
+ setExitAction: (w) => {
211
+ t2 = w;
198
212
  }
199
- }), ((c2 = (l2 = (i2 = this.options).beforeHide) == null ? void 0 : l2.call(i2)) == null ? void 0 : c2.cancelAction) || e2)
213
+ }), ((f2 = (l2 = (i2 = this.options).beforeHide) == null ? void 0 : l2.call(i2)) == null ? void 0 : f2.cancelAction) || t2)
200
214
  return;
201
- const s2 = this.offCanvasElement.getAttribute("id"), a2 = m(`[data-fx-offcanvas-overlay][data-offcanvas-el=${s2}]`);
202
- a2 instanceof HTMLElement && C(a2), this.offCanvasElement.blur(), u(
215
+ const s2 = this.offCanvasElement.getAttribute("id"), a2 = u(`[data-fx-offcanvas-overlay][data-offcanvas-el=${s2}]`);
216
+ a2 instanceof HTMLElement && g(a2), this.offCanvasElement.blur(), C(
203
217
  this.offCanvasElement,
204
218
  this.allowBodyScroll,
205
219
  "close"
206
- ), document.removeEventListener("keydown", this.closeWithEsc), !this.allowBodyScroll && !a2 && document.removeEventListener("click", this.closeWhenClickOutSide), (p = (r2 = this.options).onHide) == null || p.call(r2), v(this.offCanvasElement, "offcanvas-close", { offcanvasId: this.offCanvasElement.id });
220
+ ), document.removeEventListener("keydown", this.closeWithEsc), !this.allowBodyScroll && !a2 && document.removeEventListener("click", this.closeWhenClickOutSide), (p = (r2 = this.options).onHide) == null || p.call(r2), h(this.offCanvasElement, "offcanvas-close", { offcanvasId: this.offCanvasElement.id });
207
221
  });
208
- o(this, "closeWithEsc", (e2) => {
209
- e2.key === "Escape" && (e2.preventDefault(), this.closeOffCanvas());
222
+ o(this, "closeWithEsc", (t2) => {
223
+ t2.key === "Escape" && (t2.preventDefault(), this.closeOffCanvas());
210
224
  });
211
- o(this, "closeFromCloseBtn", (e2) => {
212
- e2.target.blur(), this.closeOffCanvas();
225
+ o(this, "closeFromCloseBtn", (t2) => {
226
+ t2.target.blur(), this.closeOffCanvas();
213
227
  });
214
228
  o(this, "changeState", () => {
215
229
  this.offCanvasElement.getAttribute("data-state") === "open" ? this.closeOffCanvas() : this.openOffCanvas();
@@ -220,10 +234,10 @@
220
234
  o(this, "close", () => {
221
235
  this.closeOffCanvas();
222
236
  });
223
- o(this, "setOptions", ({ allowBodyscroll: e2 }) => {
224
- e2 !== void 0 && (this.allowBodyScroll = e2);
237
+ o(this, "setOptions", ({ allowBodyscroll: t2 }) => {
238
+ t2 !== void 0 && (this.allowBodyScroll = t2);
225
239
  });
226
- const s = typeof e == "string" ? m(e) : e;
240
+ const s = typeof t == "string" ? u(t) : t;
227
241
  if (!(s instanceof HTMLElement))
228
242
  throw new Error("Invalid Offcanvas, the provided Element is not a valid HTMLElement");
229
243
  this.offCanvasElement = s;
@@ -231,39 +245,39 @@
231
245
  if (a)
232
246
  return a;
233
247
  d.setup(this.offCanvasElement), this.options = n;
234
- const { staticBackdrop: i, allowBodyScroll: l, backdrop: c } = this.options;
248
+ const { staticBackdrop: i, allowBodyScroll: l, backdrop: f } = this.options;
235
249
  this.setupAttributes(), this.staticBackdrop = i || s.hasAttribute("data-static-backdrop") && s.dataset.staticBackdrop !== "false" || false, this.allowBodyScroll = l || s.hasAttribute("data-allow-body-scroll") && s.dataset.allowBodyScroll !== "false" || false;
236
250
  const r = this.offCanvasElement.getAttribute("id");
237
251
  if (!r || r === "")
238
252
  throw new Error("\u274C id is required but missing on element:");
239
- this.offCanvasId = r, this.offCanvasTriggers = this.findOffCanvasElements("[data-offcanvas-trigger]", false, r), this.offCanvasCloseBtns = this.findOffCanvasElements("[data-offcanvas-close]", true, r, this.offCanvasElement), this.backdrop = c || this.offCanvasElement.dataset.offcanvasBackdrop || "", this.dispatchEventToDocument = this.dispatchEventToDocument = this.options.dispatchEventToDocument || true, this.teleporter = A(this.offCanvasElement, document.body, "move"), this.setupOffcanvas(), this.moveElOnInit(), d.register("offcanvas", this.offCanvasElement, this), d.initialized(this.offCanvasElement);
253
+ this.offCanvasId = r, this.offCanvasTriggers = this.findOffCanvasElements("[data-offcanvas-trigger]", false, r), this.offCanvasCloseBtns = this.findOffCanvasElements("[data-offcanvas-close]", true, r, this.offCanvasElement), this.backdrop = f || this.offCanvasElement.dataset.offcanvasBackdrop || "", this.dispatchEventToDocument = this.dispatchEventToDocument = this.options.dispatchEventToDocument || true, this.teleporter = S(this.offCanvasElement, document.body, "move"), this.setupOffcanvas(), this.moveElOnInit(), d.register("offcanvas", this.offCanvasElement, this), d.initialized(this.offCanvasElement);
240
254
  }
241
- findOffCanvasElements(e, n, s, a) {
242
- return n ? h(`${e}`, a) : h(`${e}[data-target=${s}]`);
255
+ findOffCanvasElements(t, n, s, a) {
256
+ return n ? v(`${t}`, a) : v(`${t}[data-target=${s}]`);
243
257
  }
244
258
  setupAttributes() {
245
259
  this.offCanvasElement.hasAttribute("data-fx-offcanvas") || this.offCanvasElement.setAttribute("data-fx-offcanvas", "");
246
260
  }
247
261
  openOffCanvas() {
248
262
  var s, a, i, l;
249
- (a = (s = this.options).beforeShow) == null || a.call(s), x(this.offCanvasElement), u(
263
+ (a = (s = this.options).beforeShow) == null || a.call(s), H(this.offCanvasElement), C(
250
264
  this.offCanvasElement,
251
265
  this.allowBodyScroll,
252
266
  "open"
253
267
  );
254
- const e = this.offCanvasElement.getAttribute("id"), n = L(
268
+ const t = this.offCanvasElement.getAttribute("id"), n = x(
255
269
  this.backdrop,
256
- e
270
+ t
257
271
  );
258
- n instanceof HTMLElement && (y({ newElement: n, existingElement: this.offCanvasElement }), this.staticBackdrop || n.addEventListener("click", this.closeOffCanvas)), document.addEventListener("keydown", this.closeWithEsc), (l = (i = this.options).onShow) == null || l.call(i), v(this.offCanvasElement, "offcanvas-open", { offcanvasId: this.offCanvasElement.id });
272
+ n instanceof HTMLElement && (k({ newElement: n, existingElement: this.offCanvasElement }), this.staticBackdrop || n.addEventListener("click", this.closeOffCanvas)), document.addEventListener("keydown", this.closeWithEsc), (l = (i = this.options).onShow) == null || l.call(i), h(this.offCanvasElement, "offcanvas-open", { offcanvasId: this.offCanvasElement.id });
259
273
  }
260
274
  initCloseBtns() {
261
- for (const e of this.offCanvasCloseBtns)
262
- e.addEventListener("click", this.closeFromCloseBtn);
275
+ for (const t of this.offCanvasCloseBtns)
276
+ t.addEventListener("click", this.closeFromCloseBtn);
263
277
  }
264
278
  initTriggers() {
265
- for (const e of this.offCanvasTriggers)
266
- e.addEventListener("click", this.changeState);
279
+ for (const t of this.offCanvasTriggers)
280
+ t.addEventListener("click", this.changeState);
267
281
  }
268
282
  setupOffcanvas() {
269
283
  this.initTriggers(), this.initCloseBtns(), this.dispatchEventToDocument && document.addEventListener(`sheet:${this.offCanvasId}:open`, this.open), this.dispatchEventToDocument && document.addEventListener(`sheet:${this.offCanvasId}:close`, this.close);
@@ -280,17 +294,17 @@
280
294
  * ```
281
295
  */
282
296
  cleanup() {
283
- for (const e of this.offCanvasTriggers)
284
- e.removeEventListener("click", this.changeState);
285
- for (const e of this.offCanvasCloseBtns)
286
- e.removeEventListener("click", this.closeOffCanvas);
297
+ for (const t of this.offCanvasTriggers)
298
+ t.removeEventListener("click", this.changeState);
299
+ for (const t of this.offCanvasCloseBtns)
300
+ t.removeEventListener("click", this.closeOffCanvas);
287
301
  document.removeEventListener("keydown", this.closeWithEsc), this.allowBodyScroll || document.removeEventListener("click", this.closeWhenClickOutSide), this.dispatchEventToDocument && document.removeEventListener(`sheet:${this.offCanvasId}:open`, this.open), this.dispatchEventToDocument && document.removeEventListener(`sheet:${this.offCanvasId}:close`, this.close), d.removeInstance("offcanvas", this.offCanvasElement);
288
302
  }
289
303
  };
290
- o(f, "autoInit", (e = "[data-fx-offcanvas]") => {
291
- const n = h(e);
304
+ o(c, "autoInit", (t = "[data-fx-offcanvas]") => {
305
+ const n = v(t);
292
306
  for (const s of n)
293
- new f(s);
307
+ new c(s);
294
308
  }), /**
295
309
  * This is an alternative to using the constructor directly.
296
310
  * @param offcanvas - The offcanvas element selector or HTMLElement
@@ -305,8 +319,8 @@
305
319
  * });
306
320
  * ```
307
321
  */
308
- o(f, "init", (e, n = {}) => new f(e, n));
309
- var E = f;
322
+ o(c, "init", (t, n = {}) => new c(t, n));
323
+ var b = c;
310
324
 
311
325
  // src/index.js
312
326
  function Offcanvas(Alpine) {
@@ -316,7 +330,7 @@
316
330
  console.error("\u274C id is required but missing on element:", el);
317
331
  return;
318
332
  }
319
- const offcanvas_ = new E(el);
333
+ const offcanvas_ = new b(el);
320
334
  if (!Alpine.store("sheets")) {
321
335
  Alpine.store("sheets", {});
322
336
  }
package/dist/cdn.min.js CHANGED
@@ -1 +1 @@
1
- (()=>{var T=Object.defineProperty,x=(t,e,s)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,o=(t,e,s)=>x(t,typeof e!="symbol"?e+"":e,s),C=(t,e=document.body)=>e.querySelector(t),u=(t,e=document.body)=>Array.from(e.querySelectorAll(t)),A=({newElement:t,existingElement:e})=>{if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new Error("Both parameters must be valid HTML elements.");let s=e.parentElement;if(s)s.insertBefore(t,e);else throw new Error("Existing element must have a parent element.")},$=({element:t,callback:e,type:s,keysCheck:n})=>{let a=getComputedStyle(t),l=a.transition;if(l!=="none"&&l!==""&&!n.includes(l)){let r="transitionend",h=()=>{t.removeEventListener(r,h),e()};t.addEventListener(r,h,{once:!0})}else e()},S=({element:t,callback:e})=>{$({element:t,callback:e,type:"transition",keysCheck:["all 0s ease 0s","all"]})},E=(t,e,s)=>{let n=new CustomEvent(e,{detail:s});t.dispatchEvent(n)};function H(t){let e=()=>{document.querySelector("[data-fx-component]:not([data-component-initialized])")?requestAnimationFrame(e):t()};e()}function N(t,e,s="move"){if(!(t instanceof HTMLElement))throw new Error("Source element must be an HTMLElement");if(!(e instanceof HTMLElement))throw new Error("Target element must be an HTMLElement");if(!["move","detachable"].includes(s))throw new Error(`Invalid teleport mode: ${s}. Must be "move" or "detachable".`);let n=document.createComment("teleporter-placeholder"),a=t.parentNode;return a?a.insertBefore(n,t):console.warn("Element has no parent; placeholder not inserted."),s==="move"?(t.parentNode&&e.appendChild(t),{append(){t.parentNode!==e&&e.appendChild(t)},remove(){n!=null&&n.parentNode&&t.parentNode&&n.parentNode.insertBefore(t,n)},restore(){n!=null&&n.parentNode&&t.parentNode!==a&&n.parentNode.insertBefore(t,n)}}):(t.parentNode&&e.appendChild(t),{append(){e.contains(t)||e.appendChild(t)},remove(){t.parentNode&&t.remove()},restore(){n!=null&&n.parentNode&&!t.parentNode&&n.parentNode.insertBefore(t,n)}})}var M=t=>{var e;return(e=t.parentElement)==null?void 0:e.removeChild(t)},L=t=>{t.setAttribute("data-state","invisible"),S({element:t,callback(){M(t)}})},D=(t,e)=>{let s=t;if(s===""||!s)return;let n=document.createElement("div");if(n.setAttribute("aria-hidden","true"),n.setAttribute("data-state","visible"),n.setAttribute("data-fx-offcanvas-overlay",""),n.setAttribute("data-offcanvas-el",e),s==="")return;let a=s.split(" ");return s!==""&&n.classList.add(...a),n},y=(t,e,s)=>{t.setAttribute("aria-hidden",s==="open"?"false":"true"),t.setAttribute("data-state",s),e||W(s)},W=t=>{document.body.style.overflow=t==="open"?"hidden":"",document.body.style.overflowY=t==="open"?"hidden":"auto"},q=(t,e)=>{if(t===e)return;t.setAttribute("aria-hidden","true"),t.setAttribute("data-state","close");let s=C(`[data-fx-offcanvas-overlay][data-offcanvas-el=${t.getAttribute("id")}]`,t.parentElement);s instanceof HTMLElement&&L(s)},z=t=>{let e=u("[data-fx-offcanvas][data-state=open]");if(!(e.length<=0))for(let s of e)q(s,t)},c=class{static initGlobalRegistry(){window.$flexillaInstances||(window.$flexillaInstances={})}static register(e,s,n){return this.initGlobalRegistry(),window.$flexillaInstances[e]||(window.$flexillaInstances[e]=[]),this.getInstance(e,s)||(window.$flexillaInstances[e].push({element:s,instance:n}),n)}static getInstance(e,s){var n,a;return this.initGlobalRegistry(),(a=(n=window.$flexillaInstances[e])==null?void 0:n.find(l=>l.element===s))==null?void 0:a.instance}static removeInstance(e,s){this.initGlobalRegistry(),window.$flexillaInstances[e]&&(window.$flexillaInstances[e]=window.$flexillaInstances[e].filter(n=>n.element!==s))}static setup(e){e.setAttribute("data-fx-component","fx")}static initialized(e){e.setAttribute("data-component-initialized","initialized")}},d=class{constructor(e,s={}){o(this,"offCanvasElement"),o(this,"offCanvasTriggers"),o(this,"offCanvasCloseBtns"),o(this,"offCanvasId",""),o(this,"dispatchEventToDocument"),o(this,"allowBodyScroll"),o(this,"staticBackdrop"),o(this,"backdrop"),o(this,"options"),o(this,"teleporter"),o(this,"moveElOnInit",()=>{H(()=>this.teleporter.append())}),o(this,"closeWhenClickOutSide",i=>{let v=this.offCanvasElement.getAttribute("data-state")==="open",m=!this.offCanvasElement.contains(i.target)&&![...this.offCanvasTriggers].includes(i.target);v&&m&&this.closeOffCanvas()}),o(this,"closeOffCanvas",()=>{var i,v,m,b,w;let g=!1;if(E(this.offCanvasElement,"offcanvas-before-hide",{offcanvasId:this.offCanvasElement.id,setExitAction:O=>{g=O}}),((m=(v=(i=this.options).beforeHide)==null?void 0:v.call(i))==null?void 0:m.cancelAction)||g)return;let I=this.offCanvasElement.getAttribute("id"),p=C(`[data-fx-offcanvas-overlay][data-offcanvas-el=${I}]`);p instanceof HTMLElement&&L(p),this.offCanvasElement.blur(),y(this.offCanvasElement,this.allowBodyScroll,"close"),document.removeEventListener("keydown",this.closeWithEsc),!this.allowBodyScroll&&!p&&document.removeEventListener("click",this.closeWhenClickOutSide),(w=(b=this.options).onHide)==null||w.call(b),E(this.offCanvasElement,"offcanvas-close",{offcanvasId:this.offCanvasElement.id})}),o(this,"closeWithEsc",i=>{i.key==="Escape"&&(i.preventDefault(),this.closeOffCanvas())}),o(this,"closeFromCloseBtn",i=>{i.target.blur(),this.closeOffCanvas()}),o(this,"changeState",()=>{this.offCanvasElement.getAttribute("data-state")==="open"?this.closeOffCanvas():this.openOffCanvas()}),o(this,"open",()=>{this.openOffCanvas()}),o(this,"close",()=>{this.closeOffCanvas()}),o(this,"setOptions",({allowBodyscroll:i})=>{i!==void 0&&(this.allowBodyScroll=i)});let n=typeof e=="string"?C(e):e;if(!(n instanceof HTMLElement))throw new Error("Invalid Offcanvas, the provided Element is not a valid HTMLElement");this.offCanvasElement=n;let a=c.getInstance("offcanvas",n);if(a)return a;c.setup(this.offCanvasElement),this.options=s;let{staticBackdrop:l,allowBodyScroll:r,backdrop:h}=this.options;this.setupAttributes(),this.staticBackdrop=l||n.hasAttribute("data-static-backdrop")&&n.dataset.staticBackdrop!=="false"||!1,this.allowBodyScroll=r||n.hasAttribute("data-allow-body-scroll")&&n.dataset.allowBodyScroll!=="false"||!1;let f=this.offCanvasElement.getAttribute("id");if(!f||f==="")throw new Error("\u274C id is required but missing on element:");this.offCanvasId=f,this.offCanvasTriggers=this.findOffCanvasElements("[data-offcanvas-trigger]",!1,f),this.offCanvasCloseBtns=this.findOffCanvasElements("[data-offcanvas-close]",!0,f,this.offCanvasElement),this.backdrop=h||this.offCanvasElement.dataset.offcanvasBackdrop||"",this.dispatchEventToDocument=this.dispatchEventToDocument=this.options.dispatchEventToDocument||!0,this.teleporter=N(this.offCanvasElement,document.body,"move"),this.setupOffcanvas(),this.moveElOnInit(),c.register("offcanvas",this.offCanvasElement,this),c.initialized(this.offCanvasElement)}findOffCanvasElements(e,s,n,a){return s?u(`${e}`,a):u(`${e}[data-target=${n}]`)}setupAttributes(){this.offCanvasElement.hasAttribute("data-fx-offcanvas")||this.offCanvasElement.setAttribute("data-fx-offcanvas","")}openOffCanvas(){var e,s,n,a;(s=(e=this.options).beforeShow)==null||s.call(e),z(this.offCanvasElement),y(this.offCanvasElement,this.allowBodyScroll,"open");let l=this.offCanvasElement.getAttribute("id"),r=D(this.backdrop,l);r instanceof HTMLElement&&(A({newElement:r,existingElement:this.offCanvasElement}),this.staticBackdrop||r.addEventListener("click",this.closeOffCanvas)),document.addEventListener("keydown",this.closeWithEsc),(a=(n=this.options).onShow)==null||a.call(n),E(this.offCanvasElement,"offcanvas-open",{offcanvasId:this.offCanvasElement.id})}initCloseBtns(){for(let e of this.offCanvasCloseBtns)e.addEventListener("click",this.closeFromCloseBtn)}initTriggers(){for(let e of this.offCanvasTriggers)e.addEventListener("click",this.changeState)}setupOffcanvas(){this.initTriggers(),this.initCloseBtns(),this.dispatchEventToDocument&&document.addEventListener(`sheet:${this.offCanvasId}:open`,this.open),this.dispatchEventToDocument&&document.addEventListener(`sheet:${this.offCanvasId}:close`,this.close)}cleanup(){for(let e of this.offCanvasTriggers)e.removeEventListener("click",this.changeState);for(let e of this.offCanvasCloseBtns)e.removeEventListener("click",this.closeOffCanvas);document.removeEventListener("keydown",this.closeWithEsc),this.allowBodyScroll||document.removeEventListener("click",this.closeWhenClickOutSide),this.dispatchEventToDocument&&document.removeEventListener(`sheet:${this.offCanvasId}:open`,this.open),this.dispatchEventToDocument&&document.removeEventListener(`sheet:${this.offCanvasId}:close`,this.close),c.removeInstance("offcanvas",this.offCanvasElement)}};o(d,"autoInit",(t="[data-fx-offcanvas]")=>{let e=u(t);for(let s of e)new d(s)}),o(d,"init",(t,e={})=>new d(t,e));var k=d;function F(t){t.directive("offcanvas",(e,{},{cleanup:s})=>{let n=e.getAttribute("id");if(!n){console.error("\u274C id is required but missing on element:",e);return}let a=new k(e);t.store("sheets")||t.store("sheets",{}),t.store("sheets")[n]=a;let l=()=>a.open(),r=()=>a.close();document.addEventListener(`sheet:${n}:open`,l),document.addEventListener(`sheet:${n}:close`,r),s(()=>{document.removeEventListener(`sheet:${n}:open`,l),document.removeEventListener(`sheet:${n}:close`,r),a.cleanup(),delete t.store("sheets")[n]})}),t.magic("offcanvas",e=>s=>t.store("sheets")?t.store("sheets")[s]?t.store("sheets")[s]:(console.warn(`\u26A0\uFE0F No offcanvas instance found for ID: ${s}`),null):(console.warn("\u26A0\uFE0F Alpine store for Offcanvas is not initialized."),null))}var B=F;document.addEventListener("alpine:init",()=>{B(window.Alpine)});})();
1
+ (()=>{var A=Object.defineProperty,$=(t,e,n)=>e in t?A(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,o=(t,e,n)=>$(t,typeof e!="symbol"?e+"":e,n),b=(t,e=document.body)=>e.querySelector(t),u=(t,e=document.body)=>Array.from(e.querySelectorAll(t)),S=({newElement:t,existingElement:e})=>{if(!(t instanceof HTMLElement)||!(e instanceof HTMLElement))throw new Error("Both parameters must be valid HTML elements.");let n=e.parentElement;if(n)n.insertBefore(t,e);else throw new Error("Existing element must have a parent element.")},H=({element:t,callback:e,type:n,keysCheck:s})=>{let a=getComputedStyle(t),i=a.transition;if(i!=="none"&&i!==""&&!s.includes(i)){let r="transitionend",h=()=>{t.removeEventListener(r,h),e()};t.addEventListener(r,h,{once:!0})}else e()},N=({element:t,callback:e})=>{H({element:t,callback:e,type:"transition",keysCheck:["all 0s ease 0s","all"]})},E=(t,e,n)=>{let s=new CustomEvent(e,{detail:n});t.dispatchEvent(s)};function M(t){let e=()=>{document.querySelector("[data-fx-component]:not([data-component-initialized])")?requestAnimationFrame(e):t()};e()}var L="data-fx-teleport-root",C="data-fx-teleported",D={append:()=>{},remove:()=>{},restore:()=>{}};function W(t,e,n="move"){var s;if(!(t instanceof HTMLElement))throw new Error("Source element must be an HTMLElement");if(!(e instanceof HTMLElement))throw new Error("Target element must be an HTMLElement");if(!["move","detachable"].includes(n))throw new Error(`Invalid teleport mode: ${n}. Must be "move" or "detachable".`);if((s=t.parentElement)!=null&&s.closest(`[${L}]`))return D;t.setAttribute(L,"");let a=document.createComment("teleporter-placeholder"),i=t.parentNode;return i&&i.insertBefore(a,t),n==="move"?(t.parentNode&&(e.appendChild(t),t.setAttribute(C,"")),{append(){t.parentNode!==e&&(e.appendChild(t),t.setAttribute(C,""))},remove(){a!=null&&a.parentNode&&t.parentNode&&a.parentNode.insertBefore(t,a)},restore(){a!=null&&a.parentNode&&t.parentNode!==i&&a.parentNode.insertBefore(t,a)}}):(t.parentNode&&(e.appendChild(t),t.setAttribute(C,"")),{append(){e.contains(t)||e.appendChild(t)},remove(){t.parentNode&&t.remove()},restore(){a!=null&&a.parentNode&&!t.parentNode&&a.parentNode.insertBefore(t,a)}})}var q=t=>{var e;return(e=t.parentElement)==null?void 0:e.removeChild(t)},B=t=>{t.setAttribute("data-state","invisible"),N({element:t,callback(){q(t)}})},z=(t,e)=>{let n=t;if(n===""||!n)return;let s=document.createElement("div");if(s.setAttribute("aria-hidden","true"),s.setAttribute("data-state","visible"),s.setAttribute("data-fx-offcanvas-overlay",""),s.setAttribute("data-offcanvas-el",e),n==="")return;let a=n.split(" ");return n!==""&&s.classList.add(...a),s},k=(t,e,n)=>{t.setAttribute("aria-hidden",n==="open"?"false":"true"),t.setAttribute("data-state",n),e||F(n)},F=t=>{document.body.style.overflow=t==="open"?"hidden":"",document.body.style.overflowY=t==="open"?"hidden":"auto"},G=(t,e)=>{if(t===e)return;t.setAttribute("aria-hidden","true"),t.setAttribute("data-state","close");let n=b(`[data-fx-offcanvas-overlay][data-offcanvas-el=${t.getAttribute("id")}]`,t.parentElement);n instanceof HTMLElement&&B(n)},R=t=>{let e=u("[data-fx-offcanvas][data-state=open]");if(!(e.length<=0))for(let n of e)G(n,t)},f=class{static initGlobalRegistry(){window.$flexillaInstances||(window.$flexillaInstances={})}static register(e,n,s){return this.initGlobalRegistry(),window.$flexillaInstances[e]||(window.$flexillaInstances[e]=[]),this.getInstance(e,n)||(window.$flexillaInstances[e].push({element:n,instance:s}),s)}static getInstance(e,n){var s,a;return this.initGlobalRegistry(),(a=(s=window.$flexillaInstances[e])==null?void 0:s.find(i=>i.element===n))==null?void 0:a.instance}static removeInstance(e,n){this.initGlobalRegistry(),window.$flexillaInstances[e]&&(window.$flexillaInstances[e]=window.$flexillaInstances[e].filter(s=>s.element!==n))}static setup(e){e.setAttribute("data-fx-component","fx")}static initialized(e){e.setAttribute("data-component-initialized","initialized")}},d=class{constructor(e,n={}){o(this,"offCanvasElement"),o(this,"offCanvasTriggers"),o(this,"offCanvasCloseBtns"),o(this,"offCanvasId",""),o(this,"dispatchEventToDocument"),o(this,"allowBodyScroll"),o(this,"staticBackdrop"),o(this,"backdrop"),o(this,"options"),o(this,"teleporter"),o(this,"moveElOnInit",()=>{M(()=>this.teleporter.append())}),o(this,"closeWhenClickOutSide",l=>{let v=this.offCanvasElement.getAttribute("data-state")==="open",m=!this.offCanvasElement.contains(l.target)&&![...this.offCanvasTriggers].includes(l.target);v&&m&&this.closeOffCanvas()}),o(this,"closeOffCanvas",()=>{var l,v,m,w,g;let y=!1;if(E(this.offCanvasElement,"offcanvas-before-hide",{offcanvasId:this.offCanvasElement.id,setExitAction:T=>{y=T}}),((m=(v=(l=this.options).beforeHide)==null?void 0:v.call(l))==null?void 0:m.cancelAction)||y)return;let x=this.offCanvasElement.getAttribute("id"),p=b(`[data-fx-offcanvas-overlay][data-offcanvas-el=${x}]`);p instanceof HTMLElement&&B(p),this.offCanvasElement.blur(),k(this.offCanvasElement,this.allowBodyScroll,"close"),document.removeEventListener("keydown",this.closeWithEsc),!this.allowBodyScroll&&!p&&document.removeEventListener("click",this.closeWhenClickOutSide),(g=(w=this.options).onHide)==null||g.call(w),E(this.offCanvasElement,"offcanvas-close",{offcanvasId:this.offCanvasElement.id})}),o(this,"closeWithEsc",l=>{l.key==="Escape"&&(l.preventDefault(),this.closeOffCanvas())}),o(this,"closeFromCloseBtn",l=>{l.target.blur(),this.closeOffCanvas()}),o(this,"changeState",()=>{this.offCanvasElement.getAttribute("data-state")==="open"?this.closeOffCanvas():this.openOffCanvas()}),o(this,"open",()=>{this.openOffCanvas()}),o(this,"close",()=>{this.closeOffCanvas()}),o(this,"setOptions",({allowBodyscroll:l})=>{l!==void 0&&(this.allowBodyScroll=l)});let s=typeof e=="string"?b(e):e;if(!(s instanceof HTMLElement))throw new Error("Invalid Offcanvas, the provided Element is not a valid HTMLElement");this.offCanvasElement=s;let a=f.getInstance("offcanvas",s);if(a)return a;f.setup(this.offCanvasElement),this.options=n;let{staticBackdrop:i,allowBodyScroll:r,backdrop:h}=this.options;this.setupAttributes(),this.staticBackdrop=i||s.hasAttribute("data-static-backdrop")&&s.dataset.staticBackdrop!=="false"||!1,this.allowBodyScroll=r||s.hasAttribute("data-allow-body-scroll")&&s.dataset.allowBodyScroll!=="false"||!1;let c=this.offCanvasElement.getAttribute("id");if(!c||c==="")throw new Error("\u274C id is required but missing on element:");this.offCanvasId=c,this.offCanvasTriggers=this.findOffCanvasElements("[data-offcanvas-trigger]",!1,c),this.offCanvasCloseBtns=this.findOffCanvasElements("[data-offcanvas-close]",!0,c,this.offCanvasElement),this.backdrop=h||this.offCanvasElement.dataset.offcanvasBackdrop||"",this.dispatchEventToDocument=this.dispatchEventToDocument=this.options.dispatchEventToDocument||!0,this.teleporter=W(this.offCanvasElement,document.body,"move"),this.setupOffcanvas(),this.moveElOnInit(),f.register("offcanvas",this.offCanvasElement,this),f.initialized(this.offCanvasElement)}findOffCanvasElements(e,n,s,a){return n?u(`${e}`,a):u(`${e}[data-target=${s}]`)}setupAttributes(){this.offCanvasElement.hasAttribute("data-fx-offcanvas")||this.offCanvasElement.setAttribute("data-fx-offcanvas","")}openOffCanvas(){var e,n,s,a;(n=(e=this.options).beforeShow)==null||n.call(e),R(this.offCanvasElement),k(this.offCanvasElement,this.allowBodyScroll,"open");let i=this.offCanvasElement.getAttribute("id"),r=z(this.backdrop,i);r instanceof HTMLElement&&(S({newElement:r,existingElement:this.offCanvasElement}),this.staticBackdrop||r.addEventListener("click",this.closeOffCanvas)),document.addEventListener("keydown",this.closeWithEsc),(a=(s=this.options).onShow)==null||a.call(s),E(this.offCanvasElement,"offcanvas-open",{offcanvasId:this.offCanvasElement.id})}initCloseBtns(){for(let e of this.offCanvasCloseBtns)e.addEventListener("click",this.closeFromCloseBtn)}initTriggers(){for(let e of this.offCanvasTriggers)e.addEventListener("click",this.changeState)}setupOffcanvas(){this.initTriggers(),this.initCloseBtns(),this.dispatchEventToDocument&&document.addEventListener(`sheet:${this.offCanvasId}:open`,this.open),this.dispatchEventToDocument&&document.addEventListener(`sheet:${this.offCanvasId}:close`,this.close)}cleanup(){for(let e of this.offCanvasTriggers)e.removeEventListener("click",this.changeState);for(let e of this.offCanvasCloseBtns)e.removeEventListener("click",this.closeOffCanvas);document.removeEventListener("keydown",this.closeWithEsc),this.allowBodyScroll||document.removeEventListener("click",this.closeWhenClickOutSide),this.dispatchEventToDocument&&document.removeEventListener(`sheet:${this.offCanvasId}:open`,this.open),this.dispatchEventToDocument&&document.removeEventListener(`sheet:${this.offCanvasId}:close`,this.close),f.removeInstance("offcanvas",this.offCanvasElement)}};o(d,"autoInit",(t="[data-fx-offcanvas]")=>{let e=u(t);for(let n of e)new d(n)}),o(d,"init",(t,e={})=>new d(t,e));var I=d;function j(t){t.directive("offcanvas",(e,{},{cleanup:n})=>{let s=e.getAttribute("id");if(!s){console.error("\u274C id is required but missing on element:",e);return}let a=new I(e);t.store("sheets")||t.store("sheets",{}),t.store("sheets")[s]=a;let i=()=>a.open(),r=()=>a.close();document.addEventListener(`sheet:${s}:open`,i),document.addEventListener(`sheet:${s}:close`,r),n(()=>{document.removeEventListener(`sheet:${s}:open`,i),document.removeEventListener(`sheet:${s}:close`,r),a.cleanup(),delete t.store("sheets")[s]})}),t.magic("offcanvas",e=>n=>t.store("sheets")?t.store("sheets")[n]?t.store("sheets")[n]:(console.warn(`\u26A0\uFE0F No offcanvas instance found for ID: ${n}`),null):(console.warn("\u26A0\uFE0F Alpine store for Offcanvas is not initialized."),null))}var O=j;document.addEventListener("alpine:init",()=>{O(window.Alpine)});})();