vanilla-drawers 1.0.13 → 1.0.15

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.
@@ -6,16 +6,16 @@ var r = (n, t, e) => (J(n, t, "read from private field"), e ? e.call(n) : t.get(
6
6
  if (t.has(n))
7
7
  throw TypeError("Cannot add the same private member more than once");
8
8
  t instanceof WeakSet ? t.add(n) : t.set(n, e);
9
- }, b = (n, t, e, a) => (J(n, t, "write to private field"), a ? a.call(n, e) : t.set(n, e), e);
9
+ }, b = (n, t, e, l) => (J(n, t, "write to private field"), l ? l.call(n, e) : t.set(n, e), e);
10
10
  function te(n) {
11
11
  return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
12
12
  }
13
13
  var ne = { exports: {} };
14
14
  (function(n) {
15
15
  var t = Object.prototype.hasOwnProperty, e = "~";
16
- function a() {
16
+ function l() {
17
17
  }
18
- Object.create && (a.prototype = /* @__PURE__ */ Object.create(null), new a().__proto__ || (e = !1));
18
+ Object.create && (l.prototype = /* @__PURE__ */ Object.create(null), new l().__proto__ || (e = !1));
19
19
  function s(h, i, o) {
20
20
  this.fn = h, this.context = i, this.once = o || !1;
21
21
  }
@@ -26,10 +26,10 @@ var ne = { exports: {} };
26
26
  return h._events[w] ? h._events[w].fn ? h._events[w] = [h._events[w], g] : h._events[w].push(g) : (h._events[w] = g, h._eventsCount++), h;
27
27
  }
28
28
  function d(h, i) {
29
- --h._eventsCount === 0 ? h._events = new a() : delete h._events[i];
29
+ --h._eventsCount === 0 ? h._events = new l() : delete h._events[i];
30
30
  }
31
31
  function u() {
32
- this._events = new a(), this._eventsCount = 0;
32
+ this._events = new l(), this._eventsCount = 0;
33
33
  }
34
34
  u.prototype.eventNames = function() {
35
35
  var i = [], o, c;
@@ -54,46 +54,46 @@ var ne = { exports: {} };
54
54
  var _ = e ? e + i : i;
55
55
  if (!this._events[_])
56
56
  return !1;
57
- var l = this._events[_], j = arguments.length, M, m;
58
- if (l.fn) {
59
- switch (l.once && this.removeListener(i, l.fn, void 0, !0), j) {
57
+ var a = this._events[_], S = arguments.length, k, m;
58
+ if (a.fn) {
59
+ switch (a.once && this.removeListener(i, a.fn, void 0, !0), S) {
60
60
  case 1:
61
- return l.fn.call(l.context), !0;
61
+ return a.fn.call(a.context), !0;
62
62
  case 2:
63
- return l.fn.call(l.context, o), !0;
63
+ return a.fn.call(a.context, o), !0;
64
64
  case 3:
65
- return l.fn.call(l.context, o, c), !0;
65
+ return a.fn.call(a.context, o, c), !0;
66
66
  case 4:
67
- return l.fn.call(l.context, o, c, O), !0;
67
+ return a.fn.call(a.context, o, c, O), !0;
68
68
  case 5:
69
- return l.fn.call(l.context, o, c, O, g), !0;
69
+ return a.fn.call(a.context, o, c, O, g), !0;
70
70
  case 6:
71
- return l.fn.call(l.context, o, c, O, g, w), !0;
71
+ return a.fn.call(a.context, o, c, O, g, w), !0;
72
72
  }
73
- for (m = 1, M = new Array(j - 1); m < j; m++)
74
- M[m - 1] = arguments[m];
75
- l.fn.apply(l.context, M);
73
+ for (m = 1, k = new Array(S - 1); m < S; m++)
74
+ k[m - 1] = arguments[m];
75
+ a.fn.apply(a.context, k);
76
76
  } else {
77
- var se = l.length, N;
77
+ var se = a.length, N;
78
78
  for (m = 0; m < se; m++)
79
- switch (l[m].once && this.removeListener(i, l[m].fn, void 0, !0), j) {
79
+ switch (a[m].once && this.removeListener(i, a[m].fn, void 0, !0), S) {
80
80
  case 1:
81
- l[m].fn.call(l[m].context);
81
+ a[m].fn.call(a[m].context);
82
82
  break;
83
83
  case 2:
84
- l[m].fn.call(l[m].context, o);
84
+ a[m].fn.call(a[m].context, o);
85
85
  break;
86
86
  case 3:
87
- l[m].fn.call(l[m].context, o, c);
87
+ a[m].fn.call(a[m].context, o, c);
88
88
  break;
89
89
  case 4:
90
- l[m].fn.call(l[m].context, o, c, O);
90
+ a[m].fn.call(a[m].context, o, c, O);
91
91
  break;
92
92
  default:
93
- if (!M)
94
- for (N = 1, M = new Array(j - 1); N < j; N++)
95
- M[N - 1] = arguments[N];
96
- l[m].fn.apply(l[m].context, M);
93
+ if (!k)
94
+ for (N = 1, k = new Array(S - 1); N < S; N++)
95
+ k[N - 1] = arguments[N];
96
+ a[m].fn.apply(a[m].context, k);
97
97
  }
98
98
  }
99
99
  return !0;
@@ -111,22 +111,22 @@ var ne = { exports: {} };
111
111
  if (w.fn)
112
112
  w.fn === o && (!O || w.once) && (!c || w.context === c) && d(this, g);
113
113
  else {
114
- for (var _ = 0, l = [], j = w.length; _ < j; _++)
115
- (w[_].fn !== o || O && !w[_].once || c && w[_].context !== c) && l.push(w[_]);
116
- l.length ? this._events[g] = l.length === 1 ? l[0] : l : d(this, g);
114
+ for (var _ = 0, a = [], S = w.length; _ < S; _++)
115
+ (w[_].fn !== o || O && !w[_].once || c && w[_].context !== c) && a.push(w[_]);
116
+ a.length ? this._events[g] = a.length === 1 ? a[0] : a : d(this, g);
117
117
  }
118
118
  return this;
119
119
  }, u.prototype.removeAllListeners = function(i) {
120
120
  var o;
121
- return i ? (o = e ? e + i : i, this._events[o] && d(this, o)) : (this._events = new a(), this._eventsCount = 0), this;
121
+ return i ? (o = e ? e + i : i, this._events[o] && d(this, o)) : (this._events = new l(), this._eventsCount = 0), this;
122
122
  }, u.prototype.off = u.prototype.removeListener, u.prototype.addListener = u.prototype.on, u.prefixed = e, u.EventEmitter = u, n.exports = u;
123
123
  })(ne);
124
124
  var ie = ne.exports;
125
125
  const oe = /* @__PURE__ */ te(ie);
126
- var ae = function(t) {
127
- return le(t) && !ce(t);
126
+ var le = function(t) {
127
+ return ae(t) && !ce(t);
128
128
  };
129
- function le(n) {
129
+ function ae(n) {
130
130
  return !!n && typeof n == "object";
131
131
  }
132
132
  function ce(n) {
@@ -144,8 +144,8 @@ function R(n, t) {
144
144
  return t.clone !== !1 && t.isMergeableObject(n) ? U(de(n), n, t) : n;
145
145
  }
146
146
  function pe(n, t, e) {
147
- return n.concat(t).map(function(a) {
148
- return R(a, e);
147
+ return n.concat(t).map(function(l) {
148
+ return R(l, e);
149
149
  });
150
150
  }
151
151
  function we(n, t) {
@@ -173,23 +173,23 @@ function ye(n, t) {
173
173
  return re(n, t) && !(Object.hasOwnProperty.call(n, t) && Object.propertyIsEnumerable.call(n, t));
174
174
  }
175
175
  function be(n, t, e) {
176
- var a = {};
176
+ var l = {};
177
177
  return e.isMergeableObject(n) && Q(n).forEach(function(s) {
178
- a[s] = R(n[s], e);
178
+ l[s] = R(n[s], e);
179
179
  }), Q(t).forEach(function(s) {
180
- ye(n, s) || (re(n, s) && e.isMergeableObject(t[s]) ? a[s] = we(s, e)(n[s], t[s], e) : a[s] = R(t[s], e));
181
- }), a;
180
+ ye(n, s) || (re(n, s) && e.isMergeableObject(t[s]) ? l[s] = we(s, e)(n[s], t[s], e) : l[s] = R(t[s], e));
181
+ }), l;
182
182
  }
183
183
  function U(n, t, e) {
184
- e = e || {}, e.arrayMerge = e.arrayMerge || pe, e.isMergeableObject = e.isMergeableObject || ae, e.cloneUnlessOtherwiseSpecified = R;
185
- var a = Array.isArray(t), s = Array.isArray(n), f = a === s;
186
- return f ? a ? e.arrayMerge(n, t, e) : be(n, t, e) : R(t, e);
184
+ e = e || {}, e.arrayMerge = e.arrayMerge || pe, e.isMergeableObject = e.isMergeableObject || le, e.cloneUnlessOtherwiseSpecified = R;
185
+ var l = Array.isArray(t), s = Array.isArray(n), f = l === s;
186
+ return f ? l ? e.arrayMerge(n, t, e) : be(n, t, e) : R(t, e);
187
187
  }
188
188
  U.all = function(t, e) {
189
189
  if (!Array.isArray(t))
190
190
  throw new Error("first argument should be an array");
191
- return t.reduce(function(a, s) {
192
- return U(a, s, e);
191
+ return t.reduce(function(l, s) {
192
+ return U(l, s, e);
193
193
  }, {});
194
194
  };
195
195
  var ge = U, Oe = ge;
@@ -250,7 +250,7 @@ function Z(n) {
250
250
  }
251
251
  var E, v, P, B;
252
252
  class H {
253
- constructor({ target: t, type: e, owner: a }) {
253
+ constructor({ target: t, type: e, owner: l }) {
254
254
  y(this, E, void 0);
255
255
  y(this, v, void 0);
256
256
  y(this, P, void 0);
@@ -258,7 +258,7 @@ class H {
258
258
  const s = Y(t);
259
259
  if (!s)
260
260
  throw new Error("Trigger element cannot be found");
261
- b(this, E, s), b(this, v, a), b(this, P, e), this.init();
261
+ b(this, E, s), b(this, v, l), b(this, P, e), this.init();
262
262
  }
263
263
  // Accessors
264
264
  get isActive() {
@@ -279,13 +279,13 @@ class H {
279
279
  }
280
280
  }
281
281
  E = new WeakMap(), v = new WeakMap(), P = new WeakMap(), B = new WeakMap();
282
- var p, G, k, K, T;
282
+ var p, G, M, K, T;
283
283
  class _e extends oe {
284
- constructor({ target: e, options: a }) {
284
+ constructor({ target: e, options: l }) {
285
285
  super();
286
286
  y(this, p, void 0);
287
287
  y(this, G, void 0);
288
- y(this, k, void 0);
288
+ y(this, M, void 0);
289
289
  y(this, K, void 0);
290
290
  y(this, T, void 0);
291
291
  this.handleDocumentClick = async (u) => {
@@ -300,7 +300,7 @@ class _e extends oe {
300
300
  }, this.handleKeydown = (u) => {
301
301
  r(this, p).closeOnEsc && u.key === "Escape" && this.close();
302
302
  };
303
- const s = Z(a ? [X, a] : [X]), f = Y(e);
303
+ const s = Z(l ? [X, l] : [X]), f = Y(e);
304
304
  if (f === null)
305
305
  throw new Error("Drawer's root cannot be found");
306
306
  b(this, T, f.getAttribute("data-drawer"));
@@ -320,7 +320,7 @@ class _e extends oe {
320
320
  }
321
321
  // Accessors
322
322
  get isOpen() {
323
- return r(this, k);
323
+ return r(this, M);
324
324
  }
325
325
  get isModal() {
326
326
  return r(this, p).modal;
@@ -328,6 +328,9 @@ class _e extends oe {
328
328
  set isModal(e) {
329
329
  this.dom.root.classList[e ? "add" : "remove"]("drawer_modal");
330
330
  }
331
+ get willLockScroll() {
332
+ return r(this, p).lockPageScroll;
333
+ }
331
334
  set zIndex(e) {
332
335
  this.dom.root.style.setProperty("--z-index", String(e)), b(this, G, e);
333
336
  }
@@ -336,10 +339,10 @@ class _e extends oe {
336
339
  }
337
340
  // Methods
338
341
  async open(e) {
339
- await F(0), !r(this, k) && (this.emit("beforeOpen", { drawer: this, trigger: e }), b(this, k, !0), this.dom.root.classList.add(r(this, p).openClass), this.emit("open", { drawer: this, trigger: e }), typeof r(this, p).openAnimationDuration == "number" && await F(r(this, p).openAnimationDuration), this.emit("openAnimationEnd", { drawer: this, trigger: e }), this.focus(), this.addEventListeners());
342
+ await F(0), !r(this, M) && (this.emit("beforeOpen", { drawer: this, trigger: e }), b(this, M, !0), this.dom.root.classList.add(r(this, p).openClass), this.emit("open", { drawer: this, trigger: e }), typeof r(this, p).openAnimationDuration == "number" && await F(r(this, p).openAnimationDuration), this.emit("openAnimationEnd", { drawer: this, trigger: e }), this.focus(), this.addEventListeners());
340
343
  }
341
344
  async close(e) {
342
- r(this, p).onCloseConfirm && !r(this, p).onCloseConfirm(this, e) || (this.emit("beforeClose", { drawer: this, trigger: e }), this.removeEventListeners(), b(this, k, !1), this.dom.root.classList.remove(r(this, p).openClass), this.emit("close", { drawer: this, trigger: e }), typeof r(this, p).closeAnimationDuration == "number" && await F(r(this, p).closeAnimationDuration), this.emit("closeAnimationEnd", { drawer: this, trigger: e }));
345
+ r(this, p).onCloseConfirm && !r(this, p).onCloseConfirm(this, e) || (this.emit("beforeClose", { drawer: this, trigger: e }), this.removeEventListeners(), b(this, M, !1), this.dom.root.classList.remove(r(this, p).openClass), this.emit("close", { drawer: this, trigger: e }), typeof r(this, p).closeAnimationDuration == "number" && await F(r(this, p).closeAnimationDuration), this.emit("closeAnimationEnd", { drawer: this, trigger: e }));
343
346
  }
344
347
  handleOtherDrawerClick(e) {
345
348
  }
@@ -360,51 +363,51 @@ class _e extends oe {
360
363
  return e ? (e.focus(), !0) : !1;
361
364
  }
362
365
  setOptions(e) {
363
- var a;
364
- e.hasOwnProperty("modal") && ((a = r(this, p)) == null ? void 0 : a.modal) !== e.modal && (this.isModal = e.modal), b(this, p, r(this, p) ? Z([r(this, p), e]) : e);
366
+ var l;
367
+ e.hasOwnProperty("modal") && ((l = r(this, p)) == null ? void 0 : l.modal) !== e.modal && (this.isModal = e.modal), b(this, p, r(this, p) ? Z([r(this, p), e]) : e);
365
368
  }
366
369
  assignGroup(e) {
367
370
  b(this, K, e);
368
371
  }
369
372
  }
370
- p = new WeakMap(), G = new WeakMap(), k = new WeakMap(), K = new WeakMap(), T = new WeakMap();
371
- var x, A, C, D, S, L;
373
+ p = new WeakMap(), G = new WeakMap(), M = new WeakMap(), K = new WeakMap(), T = new WeakMap();
374
+ var x, A, C, D, L, j;
372
375
  class ee {
373
376
  constructor(t) {
374
377
  y(this, x, void 0);
375
378
  y(this, A, void 0);
376
379
  y(this, C, void 0);
377
380
  y(this, D, void 0);
378
- y(this, S, void 0);
379
381
  y(this, L, void 0);
380
- b(this, A, []), b(this, C, []), b(this, S, /* @__PURE__ */ new Set()), b(this, L, /* @__PURE__ */ new Map()), this.onBeforeOpen = ({ drawer: s, trigger: f }) => {
381
- s.isModal ? (r(this, L).set(s, r(this, A).length), r(this, A).push(s), s.zIndex = r(this, C).length + r(this, A).length) : (r(this, L).set(s, r(this, C).length), r(this, C).push(s), s.zIndex = r(this, C).length, r(this, A).length > 0 && r(this, A).forEach((d, u) => d.zIndex = r(this, C).length + u + 1)), this.lockScroll(s);
382
+ y(this, j, void 0);
383
+ b(this, A, []), b(this, C, []), b(this, L, /* @__PURE__ */ new Set()), b(this, j, /* @__PURE__ */ new Map()), this.onBeforeOpen = ({ drawer: s, trigger: f }) => {
384
+ s.isModal ? (r(this, j).set(s, r(this, A).length), r(this, A).push(s), s.zIndex = r(this, C).length + r(this, A).length) : (r(this, j).set(s, r(this, C).length), r(this, C).push(s), s.zIndex = r(this, C).length, r(this, A).length > 0 && r(this, A).forEach((d, u) => d.zIndex = r(this, C).length + u + 1)), s.willLockScroll && this.lockScroll(s);
382
385
  }, this.onCloseAnimationEnd = ({ drawer: s, trigger: f }) => {
383
386
  const d = s.isModal ? r(this, A) : r(this, C);
384
- for (delete d[r(this, L).get(s)]; d.length && !d.at(-1); )
387
+ for (delete d[r(this, j).get(s)]; d.length && !d.at(-1); )
385
388
  d.pop();
386
- r(this, L).delete(s), this.unlockScroll(s);
389
+ r(this, j).delete(s), this.unlockScroll(s);
387
390
  };
388
391
  const e = Y(t);
389
392
  if (e === null)
390
393
  throw new Error("Drawer's group root cannot be found");
391
394
  b(this, x, e);
392
- const a = r(this, x).closest("[data-scrollable], html") || r(this, x).matches("[data-scrollable], html") && r(this, x);
393
- if (a === null)
395
+ const l = r(this, x).closest("[data-scrollable], html") || r(this, x).matches("[data-scrollable], html") && r(this, x);
396
+ if (l === null)
394
397
  throw new Error("Scrollable container for group root cannot be found");
395
- b(this, D, a);
398
+ b(this, D, l);
396
399
  }
397
400
  add(t) {
398
401
  t.on("beforeOpen", this.onBeforeOpen), t.on("closeAnimationEnd", this.onCloseAnimationEnd), t.assignGroup(this);
399
402
  }
400
403
  lockScroll(t) {
401
- r(this, S).size === 0 && r(this, D).classList.add("scroll-lock-by-drawer"), r(this, S).add(t);
404
+ r(this, L).size === 0 && r(this, D).classList.add("scroll-lock-by-drawer"), r(this, L).add(t);
402
405
  }
403
406
  unlockScroll(t) {
404
- r(this, S).delete(t), r(this, S).size === 0 && r(this, D).classList.remove("scroll-lock-by-drawer");
407
+ r(this, L).delete(t), r(this, L).size === 0 && r(this, D).classList.remove("scroll-lock-by-drawer");
405
408
  }
406
409
  }
407
- x = new WeakMap(), A = new WeakMap(), C = new WeakMap(), D = new WeakMap(), S = new WeakMap(), L = new WeakMap();
410
+ x = new WeakMap(), A = new WeakMap(), C = new WeakMap(), D = new WeakMap(), L = new WeakMap(), j = new WeakMap();
408
411
  var I, z;
409
412
  const q = class q {
410
413
  constructor() {
@@ -442,24 +445,24 @@ const q = class q {
442
445
  }
443
446
  });
444
447
  }
445
- open(t, { trigger: e, options: a } = {}) {
448
+ open(t, { trigger: e, options: l } = {}) {
446
449
  var s;
447
450
  (s = this.get(t)) == null || s.open(e);
448
451
  }
449
- close(t, { trigger: e, options: a } = {}) {
452
+ close(t, { trigger: e, options: l } = {}) {
450
453
  var s;
451
454
  (s = this.get(t)) == null || s.close(e);
452
455
  }
453
456
  get(t) {
454
457
  return typeof t == "string" && r(this, I).get(t) || null;
455
458
  }
456
- on(t, e, a) {
459
+ on(t, e, l) {
457
460
  var s;
458
461
  if (t)
459
- (s = this.get(t)) == null || s.on(e, a);
462
+ (s = this.get(t)) == null || s.on(e, l);
460
463
  else
461
464
  for (const [f, d] of r(this, I))
462
- d.on(e, a);
465
+ d.on(e, l);
463
466
  }
464
467
  };
465
468
  I = new WeakMap(), z = new WeakMap();
@@ -1,6 +1,6 @@
1
- (function(p,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(p=typeof globalThis<"u"?globalThis:p||self,b(p.Drawers={}))})(this,function(p){"use strict";var oe=(p,b,C)=>{if(!b.has(p))throw TypeError("Cannot "+C)};var t=(p,b,C)=>(oe(p,b,"read from private field"),C?C.call(p):b.get(p)),g=(p,b,C)=>{if(b.has(p))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(p):b.set(p,C)},O=(p,b,C,H)=>(oe(p,b,"write to private field"),H?H.call(p,C):b.set(p,C),C);var _,E,z,B,w,$,T,Q,U,P,j,S,N,M,k,q,G;function b(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var C={exports:{}};(function(r){var n=Object.prototype.hasOwnProperty,e="~";function l(){}Object.create&&(l.prototype=Object.create(null),new l().__proto__||(e=!1));function s(u,i,o){this.fn=u,this.context=i,this.once=o||!1}function f(u,i,o,c,A){if(typeof o!="function")throw new TypeError("The listener must be a function");var v=new s(o,c||u,A),m=e?e+i:i;return u._events[m]?u._events[m].fn?u._events[m]=[u._events[m],v]:u._events[m].push(v):(u._events[m]=v,u._eventsCount++),u}function d(u,i){--u._eventsCount===0?u._events=new l:delete u._events[i]}function h(){this._events=new l,this._eventsCount=0}h.prototype.eventNames=function(){var i=[],o,c;if(this._eventsCount===0)return i;for(c in o=this._events)n.call(o,c)&&i.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(o)):i},h.prototype.listeners=function(i){var o=e?e+i:i,c=this._events[o];if(!c)return[];if(c.fn)return[c.fn];for(var A=0,v=c.length,m=new Array(v);A<v;A++)m[A]=c[A].fn;return m},h.prototype.listenerCount=function(i){var o=e?e+i:i,c=this._events[o];return c?c.fn?1:c.length:0},h.prototype.emit=function(i,o,c,A,v,m){var L=e?e+i:i;if(!this._events[L])return!1;var a=this._events[L],x=arguments.length,D,y;if(a.fn){switch(a.once&&this.removeListener(i,a.fn,void 0,!0),x){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,o),!0;case 3:return a.fn.call(a.context,o,c),!0;case 4:return a.fn.call(a.context,o,c,A),!0;case 5:return a.fn.call(a.context,o,c,A,v),!0;case 6:return a.fn.call(a.context,o,c,A,v,m),!0}for(y=1,D=new Array(x-1);y<x;y++)D[y-1]=arguments[y];a.fn.apply(a.context,D)}else{var je=a.length,F;for(y=0;y<je;y++)switch(a[y].once&&this.removeListener(i,a[y].fn,void 0,!0),x){case 1:a[y].fn.call(a[y].context);break;case 2:a[y].fn.call(a[y].context,o);break;case 3:a[y].fn.call(a[y].context,o,c);break;case 4:a[y].fn.call(a[y].context,o,c,A);break;default:if(!D)for(F=1,D=new Array(x-1);F<x;F++)D[F-1]=arguments[F];a[y].fn.apply(a[y].context,D)}}return!0},h.prototype.on=function(i,o,c){return f(this,i,o,c,!1)},h.prototype.once=function(i,o,c){return f(this,i,o,c,!0)},h.prototype.removeListener=function(i,o,c,A){var v=e?e+i:i;if(!this._events[v])return this;if(!o)return d(this,v),this;var m=this._events[v];if(m.fn)m.fn===o&&(!A||m.once)&&(!c||m.context===c)&&d(this,v);else{for(var L=0,a=[],x=m.length;L<x;L++)(m[L].fn!==o||A&&!m[L].once||c&&m[L].context!==c)&&a.push(m[L]);a.length?this._events[v]=a.length===1?a[0]:a:d(this,v)}return this},h.prototype.removeAllListeners=function(i){var o;return i?(o=e?e+i:i,this._events[o]&&d(this,o)):(this._events=new l,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=e,h.EventEmitter=h,r.exports=h})(C);var H=C.exports;const ae=b(H);var le=function(n){return ce(n)&&!ue(n)};function ce(r){return!!r&&typeof r=="object"}function ue(r){var n=Object.prototype.toString.call(r);return n==="[object RegExp]"||n==="[object Date]"||de(r)}var he=typeof Symbol=="function"&&Symbol.for,fe=he?Symbol.for("react.element"):60103;function de(r){return r.$$typeof===fe}function pe(r){return Array.isArray(r)?[]:{}}function R(r,n){return n.clone!==!1&&n.isMergeableObject(r)?I(pe(r),r,n):r}function we(r,n,e){return r.concat(n).map(function(l){return R(l,e)})}function me(r,n){if(!n.customMerge)return I;var e=n.customMerge(r);return typeof e=="function"?e:I}function ye(r){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(r).filter(function(n){return Object.propertyIsEnumerable.call(r,n)}):[]}function ee(r){return Object.keys(r).concat(ye(r))}function te(r,n){try{return n in r}catch{return!1}}function be(r,n){return te(r,n)&&!(Object.hasOwnProperty.call(r,n)&&Object.propertyIsEnumerable.call(r,n))}function ge(r,n,e){var l={};return e.isMergeableObject(r)&&ee(r).forEach(function(s){l[s]=R(r[s],e)}),ee(n).forEach(function(s){be(r,s)||(te(r,s)&&e.isMergeableObject(n[s])?l[s]=me(s,e)(r[s],n[s],e):l[s]=R(n[s],e))}),l}function I(r,n,e){e=e||{},e.arrayMerge=e.arrayMerge||we,e.isMergeableObject=e.isMergeableObject||le,e.cloneUnlessOtherwiseSpecified=R;var l=Array.isArray(n),s=Array.isArray(r),f=l===s;return f?l?e.arrayMerge(r,n,e):ge(r,n,e):R(n,e)}I.all=function(n,e){if(!Array.isArray(n))throw new Error("first argument should be an array");return n.reduce(function(l,s){return I(l,s,e)},{})};var Oe=I,ve=Oe;const Ee=b(ve);/*!
1
+ (function(w,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(w=typeof globalThis<"u"?globalThis:w||self,b(w.Drawers={}))})(this,function(w){"use strict";var oe=(w,b,C)=>{if(!b.has(w))throw TypeError("Cannot "+C)};var t=(w,b,C)=>(oe(w,b,"read from private field"),C?C.call(w):b.get(w)),g=(w,b,C)=>{if(b.has(w))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(w):b.set(w,C)},O=(w,b,C,H)=>(oe(w,b,"write to private field"),H?H.call(w,C):b.set(w,C),C);var _,E,z,B,p,$,T,Q,U,P,S,j,N,M,k,q,G;function b(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var C={exports:{}};(function(r){var n=Object.prototype.hasOwnProperty,e="~";function a(){}Object.create&&(a.prototype=Object.create(null),new a().__proto__||(e=!1));function s(u,i,o){this.fn=u,this.context=i,this.once=o||!1}function f(u,i,o,c,A){if(typeof o!="function")throw new TypeError("The listener must be a function");var v=new s(o,c||u,A),m=e?e+i:i;return u._events[m]?u._events[m].fn?u._events[m]=[u._events[m],v]:u._events[m].push(v):(u._events[m]=v,u._eventsCount++),u}function d(u,i){--u._eventsCount===0?u._events=new a:delete u._events[i]}function h(){this._events=new a,this._eventsCount=0}h.prototype.eventNames=function(){var i=[],o,c;if(this._eventsCount===0)return i;for(c in o=this._events)n.call(o,c)&&i.push(e?c.slice(1):c);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(o)):i},h.prototype.listeners=function(i){var o=e?e+i:i,c=this._events[o];if(!c)return[];if(c.fn)return[c.fn];for(var A=0,v=c.length,m=new Array(v);A<v;A++)m[A]=c[A].fn;return m},h.prototype.listenerCount=function(i){var o=e?e+i:i,c=this._events[o];return c?c.fn?1:c.length:0},h.prototype.emit=function(i,o,c,A,v,m){var L=e?e+i:i;if(!this._events[L])return!1;var l=this._events[L],x=arguments.length,D,y;if(l.fn){switch(l.once&&this.removeListener(i,l.fn,void 0,!0),x){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,o),!0;case 3:return l.fn.call(l.context,o,c),!0;case 4:return l.fn.call(l.context,o,c,A),!0;case 5:return l.fn.call(l.context,o,c,A,v),!0;case 6:return l.fn.call(l.context,o,c,A,v,m),!0}for(y=1,D=new Array(x-1);y<x;y++)D[y-1]=arguments[y];l.fn.apply(l.context,D)}else{var Se=l.length,F;for(y=0;y<Se;y++)switch(l[y].once&&this.removeListener(i,l[y].fn,void 0,!0),x){case 1:l[y].fn.call(l[y].context);break;case 2:l[y].fn.call(l[y].context,o);break;case 3:l[y].fn.call(l[y].context,o,c);break;case 4:l[y].fn.call(l[y].context,o,c,A);break;default:if(!D)for(F=1,D=new Array(x-1);F<x;F++)D[F-1]=arguments[F];l[y].fn.apply(l[y].context,D)}}return!0},h.prototype.on=function(i,o,c){return f(this,i,o,c,!1)},h.prototype.once=function(i,o,c){return f(this,i,o,c,!0)},h.prototype.removeListener=function(i,o,c,A){var v=e?e+i:i;if(!this._events[v])return this;if(!o)return d(this,v),this;var m=this._events[v];if(m.fn)m.fn===o&&(!A||m.once)&&(!c||m.context===c)&&d(this,v);else{for(var L=0,l=[],x=m.length;L<x;L++)(m[L].fn!==o||A&&!m[L].once||c&&m[L].context!==c)&&l.push(m[L]);l.length?this._events[v]=l.length===1?l[0]:l:d(this,v)}return this},h.prototype.removeAllListeners=function(i){var o;return i?(o=e?e+i:i,this._events[o]&&d(this,o)):(this._events=new a,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=e,h.EventEmitter=h,r.exports=h})(C);var H=C.exports;const le=b(H);var ae=function(n){return ce(n)&&!ue(n)};function ce(r){return!!r&&typeof r=="object"}function ue(r){var n=Object.prototype.toString.call(r);return n==="[object RegExp]"||n==="[object Date]"||de(r)}var he=typeof Symbol=="function"&&Symbol.for,fe=he?Symbol.for("react.element"):60103;function de(r){return r.$$typeof===fe}function pe(r){return Array.isArray(r)?[]:{}}function R(r,n){return n.clone!==!1&&n.isMergeableObject(r)?I(pe(r),r,n):r}function we(r,n,e){return r.concat(n).map(function(a){return R(a,e)})}function me(r,n){if(!n.customMerge)return I;var e=n.customMerge(r);return typeof e=="function"?e:I}function ye(r){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(r).filter(function(n){return Object.propertyIsEnumerable.call(r,n)}):[]}function ee(r){return Object.keys(r).concat(ye(r))}function te(r,n){try{return n in r}catch{return!1}}function be(r,n){return te(r,n)&&!(Object.hasOwnProperty.call(r,n)&&Object.propertyIsEnumerable.call(r,n))}function ge(r,n,e){var a={};return e.isMergeableObject(r)&&ee(r).forEach(function(s){a[s]=R(r[s],e)}),ee(n).forEach(function(s){be(r,s)||(te(r,s)&&e.isMergeableObject(n[s])?a[s]=me(s,e)(r[s],n[s],e):a[s]=R(n[s],e))}),a}function I(r,n,e){e=e||{},e.arrayMerge=e.arrayMerge||we,e.isMergeableObject=e.isMergeableObject||ae,e.cloneUnlessOtherwiseSpecified=R;var a=Array.isArray(n),s=Array.isArray(r),f=a===s;return f?a?e.arrayMerge(r,n,e):ge(r,n,e):R(n,e)}I.all=function(n,e){if(!Array.isArray(n))throw new Error("first argument should be an array");return n.reduce(function(a,s){return I(a,s,e)},{})};var Oe=I,ve=Oe;const Ee=b(ve);/*!
2
2
  * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
3
3
  *
4
4
  * Copyright (c) 2014-2017, Jon Schlinkert.
5
5
  * Released under the MIT License.
6
- */function ne(r){return Object.prototype.toString.call(r)==="[object Object]"}function Ae(r){var n,e;return ne(r)===!1?!1:(n=r.constructor,n===void 0?!0:(e=n.prototype,!(ne(e)===!1||e.hasOwnProperty("isPrototypeOf")===!1)))}function W(r){return r instanceof Element?r:document.querySelector(r)}async function X(r){return await new Promise(n=>setTimeout(n,r))}const Ce='[data-elem="drawer.panel"]',V="data-drawers-group",_e=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'],re={modal:!0,focusOnChild:!0,closeOnEsc:!0,closeOnOutsideClick:!0,closeOnUnderlayClick:!0,onCloseConfirm:()=>!0,onBeforeClose:null,onClose:null,onCloseAnimationEnd:null,onBeforeOpen:null,onOpen:null,onOpenAnimationEnd:null,openClass:"drawer_open",openAnimationDuration:0,closeAnimationDuration:0,lockPageScroll:!0};function se(r){return Ee.all(r,{isMergeableObject:Ae})}class Y{constructor({target:n,type:e,owner:l}){g(this,_,void 0);g(this,E,void 0);g(this,z,void 0);g(this,B,!1);const s=W(n);if(!s)throw new Error("Trigger element cannot be found");O(this,_,s),O(this,E,l),O(this,z,e),this.init()}get isActive(){return t(this,B)}get owner(){return t(this,E)}init(){t(this,_).addEventListener("click",n=>this.clickHandler(n)),t(this,E).on("open",()=>this.setActive(!0)),t(this,E).on("close",()=>this.setActive(!1))}clickHandler(n){n.__drawerTrigger=this,t(this,z)==="open"?t(this,E).isOpen||t(this,E).open(t(this,_)):t(this,z)==="close"?t(this,E).isOpen&&t(this,E).close(t(this,_)):t(this,E).isOpen?t(this,E).close(t(this,_)):t(this,E).open(t(this,_))}setActive(n){O(this,B,n),n?t(this,_).classList.add("drawer-trigger_active"):t(this,_).classList.remove("drawer-trigger_active")}}_=new WeakMap,E=new WeakMap,z=new WeakMap,B=new WeakMap;class ie extends ae{constructor({target:e,options:l}){super();g(this,w,void 0);g(this,$,void 0);g(this,T,void 0);g(this,Q,void 0);g(this,U,void 0);this.handleDocumentClick=async h=>{var o;if(((o=h.__drawerTrigger)==null?void 0:o.owner)===this)return;const u=h.target;if(h.composedPath(),this.dom.panel.contains(u))return;const i=u==null?void 0:u.closest("[data-drawer]");i?i.getAttribute("data-drawer")===t(this,U)?this.handleUnderlayClick(h):this.handleOtherDrawerClick(h):this.handleOutsideClick(h)},this.handleKeydown=h=>{t(this,w).closeOnEsc&&h.key==="Escape"&&this.close()};const s=se(l?[re,l]:[re]),f=W(e);if(f===null)throw new Error("Drawer's root cannot be found");O(this,U,f.getAttribute("data-drawer"));const d=f.querySelector(Ce);if(d===null)throw new Error(`Drawer's panel cannot be found. Alias: ${t(this,U)}`);this.dom={root:f,panel:d},this.setOptions(s),this.dom.panel.setAttribute("tabindex","-1"),this.dom.root.classList.add("drawer_initialized")}addEventListeners(){this.dom.root.addEventListener("keydown",this.handleKeydown),document.addEventListener("click",this.handleDocumentClick)}removeEventListeners(){this.dom.root.removeEventListener("keydown",this.handleKeydown),document.removeEventListener("click",this.handleDocumentClick)}get isOpen(){return t(this,T)}get isModal(){return t(this,w).modal}set isModal(e){this.dom.root.classList[e?"add":"remove"]("drawer_modal")}set zIndex(e){this.dom.root.style.setProperty("--z-index",String(e)),O(this,$,e)}get zIndex(){return t(this,$)}async open(e){await X(0),!t(this,T)&&(this.emit("beforeOpen",{drawer:this,trigger:e}),O(this,T,!0),this.dom.root.classList.add(t(this,w).openClass),this.emit("open",{drawer:this,trigger:e}),typeof t(this,w).openAnimationDuration=="number"&&await X(t(this,w).openAnimationDuration),this.emit("openAnimationEnd",{drawer:this,trigger:e}),this.focus(),this.addEventListeners())}async close(e){t(this,w).onCloseConfirm&&!t(this,w).onCloseConfirm(this,e)||(this.emit("beforeClose",{drawer:this,trigger:e}),this.removeEventListeners(),O(this,T,!1),this.dom.root.classList.remove(t(this,w).openClass),this.emit("close",{drawer:this,trigger:e}),typeof t(this,w).closeAnimationDuration=="number"&&await X(t(this,w).closeAnimationDuration),this.emit("closeAnimationEnd",{drawer:this,trigger:e}))}handleOtherDrawerClick(e){}handleOutsideClick(e){t(this,w).closeOnOutsideClick&&(typeof t(this,w).closeOnOutsideClick=="object"&&t(this,w).closeOnOutsideClick.hasOwnProperty("checkTarget")?t(this,w).closeOnOutsideClick.checkTarget(e.target)&&this.close():this.close())}handleUnderlayClick(e){t(this,w).closeOnOutsideClick&&this.close()}focus(){t(this,w).focusOnChild&&this.focusChild()||this.focusSelf()}focusSelf(){this.dom.panel.focus()}focusChild(){const e=this.dom.panel.querySelector(_e.join(","));return e?(e.focus(),!0):!1}setOptions(e){var l;e.hasOwnProperty("modal")&&((l=t(this,w))==null?void 0:l.modal)!==e.modal&&(this.isModal=e.modal),O(this,w,t(this,w)?se([t(this,w),e]):e)}assignGroup(e){O(this,Q,e)}}w=new WeakMap,$=new WeakMap,T=new WeakMap,Q=new WeakMap,U=new WeakMap;class Z{constructor(n){g(this,P,void 0);g(this,j,void 0);g(this,S,void 0);g(this,N,void 0);g(this,M,void 0);g(this,k,void 0);O(this,j,[]),O(this,S,[]),O(this,M,new Set),O(this,k,new Map),this.onBeforeOpen=({drawer:s,trigger:f})=>{s.isModal?(t(this,k).set(s,t(this,j).length),t(this,j).push(s),s.zIndex=t(this,S).length+t(this,j).length):(t(this,k).set(s,t(this,S).length),t(this,S).push(s),s.zIndex=t(this,S).length,t(this,j).length>0&&t(this,j).forEach((d,h)=>d.zIndex=t(this,S).length+h+1)),this.lockScroll(s)},this.onCloseAnimationEnd=({drawer:s,trigger:f})=>{const d=s.isModal?t(this,j):t(this,S);for(delete d[t(this,k).get(s)];d.length&&!d.at(-1);)d.pop();t(this,k).delete(s),this.unlockScroll(s)};const e=W(n);if(e===null)throw new Error("Drawer's group root cannot be found");O(this,P,e);const l=t(this,P).closest("[data-scrollable], html")||t(this,P).matches("[data-scrollable], html")&&t(this,P);if(l===null)throw new Error("Scrollable container for group root cannot be found");O(this,N,l)}add(n){n.on("beforeOpen",this.onBeforeOpen),n.on("closeAnimationEnd",this.onCloseAnimationEnd),n.assignGroup(this)}lockScroll(n){t(this,M).size===0&&t(this,N).classList.add("scroll-lock-by-drawer"),t(this,M).add(n)}unlockScroll(n){t(this,M).delete(n),t(this,M).size===0&&t(this,N).classList.remove("scroll-lock-by-drawer")}}P=new WeakMap,j=new WeakMap,S=new WeakMap,N=new WeakMap,M=new WeakMap,k=new WeakMap;const K=class K{constructor(){g(this,q,new Map);g(this,G,new Map);if(K.instance)return K.instance;K.instance=this}init(n){document.querySelectorAll(`[${V}]`).forEach(f=>{const d=f.getAttribute(V);typeof d=="string"&&t(this,G).set(d,new Z(f))}),t(this,G).set("default",new Z(document.documentElement)),document.querySelectorAll("[data-drawer]").forEach(f=>{var o;const d=f.getAttribute("data-drawer");if(typeof d!="string")return;const h=new ie({target:f,options:n});t(this,q).set(d,h);const u=f.closest(`[${V}]`),i=u?u.getAttribute(V):"default";if(typeof i!="string")throw new Error("Group doesn't have alias set correctly");(o=t(this,G).get(i))==null||o.add(h)}),document.querySelectorAll("[data-drawer-open], [data-drawer-close], [data-drawer-toggle]").forEach(f=>{if(f.hasAttribute("data-drawer-open")){const d=f.getAttribute("data-drawer-open");new Y({target:f,type:"open",owner:this.get(d)})}else if(f.hasAttribute("data-drawer-close")){const d=f.getAttribute("data-drawer-close");new Y({target:f,type:"close",owner:this.get(d)})}else{const d=f.getAttribute("data-drawer-toggle");new Y({target:f,type:"toggle",owner:this.get(d)})}})}open(n,{trigger:e,options:l}={}){var s;(s=this.get(n))==null||s.open(e)}close(n,{trigger:e,options:l}={}){var s;(s=this.get(n))==null||s.close(e)}get(n){return typeof n=="string"&&t(this,q).get(n)||null}on(n,e,l){var s;if(n)(s=this.get(n))==null||s.on(e,l);else for(const[f,d]of t(this,q))d.on(e,l)}};q=new WeakMap,G=new WeakMap;let J=K;typeof window<"u"&&(window.hasOwnProperty("app")||(window.app={}),window.app.drawers=new J),p.Drawer=ie,p.DrawersGroup=Z,p.Trigger=Y,p.default=J,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
6
+ */function ne(r){return Object.prototype.toString.call(r)==="[object Object]"}function Ae(r){var n,e;return ne(r)===!1?!1:(n=r.constructor,n===void 0?!0:(e=n.prototype,!(ne(e)===!1||e.hasOwnProperty("isPrototypeOf")===!1)))}function W(r){return r instanceof Element?r:document.querySelector(r)}async function X(r){return await new Promise(n=>setTimeout(n,r))}const Ce='[data-elem="drawer.panel"]',V="data-drawers-group",_e=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'],re={modal:!0,focusOnChild:!0,closeOnEsc:!0,closeOnOutsideClick:!0,closeOnUnderlayClick:!0,onCloseConfirm:()=>!0,onBeforeClose:null,onClose:null,onCloseAnimationEnd:null,onBeforeOpen:null,onOpen:null,onOpenAnimationEnd:null,openClass:"drawer_open",openAnimationDuration:0,closeAnimationDuration:0,lockPageScroll:!0};function se(r){return Ee.all(r,{isMergeableObject:Ae})}class Y{constructor({target:n,type:e,owner:a}){g(this,_,void 0);g(this,E,void 0);g(this,z,void 0);g(this,B,!1);const s=W(n);if(!s)throw new Error("Trigger element cannot be found");O(this,_,s),O(this,E,a),O(this,z,e),this.init()}get isActive(){return t(this,B)}get owner(){return t(this,E)}init(){t(this,_).addEventListener("click",n=>this.clickHandler(n)),t(this,E).on("open",()=>this.setActive(!0)),t(this,E).on("close",()=>this.setActive(!1))}clickHandler(n){n.__drawerTrigger=this,t(this,z)==="open"?t(this,E).isOpen||t(this,E).open(t(this,_)):t(this,z)==="close"?t(this,E).isOpen&&t(this,E).close(t(this,_)):t(this,E).isOpen?t(this,E).close(t(this,_)):t(this,E).open(t(this,_))}setActive(n){O(this,B,n),n?t(this,_).classList.add("drawer-trigger_active"):t(this,_).classList.remove("drawer-trigger_active")}}_=new WeakMap,E=new WeakMap,z=new WeakMap,B=new WeakMap;class ie extends le{constructor({target:e,options:a}){super();g(this,p,void 0);g(this,$,void 0);g(this,T,void 0);g(this,Q,void 0);g(this,U,void 0);this.handleDocumentClick=async h=>{var o;if(((o=h.__drawerTrigger)==null?void 0:o.owner)===this)return;const u=h.target;if(h.composedPath(),this.dom.panel.contains(u))return;const i=u==null?void 0:u.closest("[data-drawer]");i?i.getAttribute("data-drawer")===t(this,U)?this.handleUnderlayClick(h):this.handleOtherDrawerClick(h):this.handleOutsideClick(h)},this.handleKeydown=h=>{t(this,p).closeOnEsc&&h.key==="Escape"&&this.close()};const s=se(a?[re,a]:[re]),f=W(e);if(f===null)throw new Error("Drawer's root cannot be found");O(this,U,f.getAttribute("data-drawer"));const d=f.querySelector(Ce);if(d===null)throw new Error(`Drawer's panel cannot be found. Alias: ${t(this,U)}`);this.dom={root:f,panel:d},this.setOptions(s),this.dom.panel.setAttribute("tabindex","-1"),this.dom.root.classList.add("drawer_initialized")}addEventListeners(){this.dom.root.addEventListener("keydown",this.handleKeydown),document.addEventListener("click",this.handleDocumentClick)}removeEventListeners(){this.dom.root.removeEventListener("keydown",this.handleKeydown),document.removeEventListener("click",this.handleDocumentClick)}get isOpen(){return t(this,T)}get isModal(){return t(this,p).modal}set isModal(e){this.dom.root.classList[e?"add":"remove"]("drawer_modal")}get willLockScroll(){return t(this,p).lockPageScroll}set zIndex(e){this.dom.root.style.setProperty("--z-index",String(e)),O(this,$,e)}get zIndex(){return t(this,$)}async open(e){await X(0),!t(this,T)&&(this.emit("beforeOpen",{drawer:this,trigger:e}),O(this,T,!0),this.dom.root.classList.add(t(this,p).openClass),this.emit("open",{drawer:this,trigger:e}),typeof t(this,p).openAnimationDuration=="number"&&await X(t(this,p).openAnimationDuration),this.emit("openAnimationEnd",{drawer:this,trigger:e}),this.focus(),this.addEventListeners())}async close(e){t(this,p).onCloseConfirm&&!t(this,p).onCloseConfirm(this,e)||(this.emit("beforeClose",{drawer:this,trigger:e}),this.removeEventListeners(),O(this,T,!1),this.dom.root.classList.remove(t(this,p).openClass),this.emit("close",{drawer:this,trigger:e}),typeof t(this,p).closeAnimationDuration=="number"&&await X(t(this,p).closeAnimationDuration),this.emit("closeAnimationEnd",{drawer:this,trigger:e}))}handleOtherDrawerClick(e){}handleOutsideClick(e){t(this,p).closeOnOutsideClick&&(typeof t(this,p).closeOnOutsideClick=="object"&&t(this,p).closeOnOutsideClick.hasOwnProperty("checkTarget")?t(this,p).closeOnOutsideClick.checkTarget(e.target)&&this.close():this.close())}handleUnderlayClick(e){t(this,p).closeOnOutsideClick&&this.close()}focus(){t(this,p).focusOnChild&&this.focusChild()||this.focusSelf()}focusSelf(){this.dom.panel.focus()}focusChild(){const e=this.dom.panel.querySelector(_e.join(","));return e?(e.focus(),!0):!1}setOptions(e){var a;e.hasOwnProperty("modal")&&((a=t(this,p))==null?void 0:a.modal)!==e.modal&&(this.isModal=e.modal),O(this,p,t(this,p)?se([t(this,p),e]):e)}assignGroup(e){O(this,Q,e)}}p=new WeakMap,$=new WeakMap,T=new WeakMap,Q=new WeakMap,U=new WeakMap;class Z{constructor(n){g(this,P,void 0);g(this,S,void 0);g(this,j,void 0);g(this,N,void 0);g(this,M,void 0);g(this,k,void 0);O(this,S,[]),O(this,j,[]),O(this,M,new Set),O(this,k,new Map),this.onBeforeOpen=({drawer:s,trigger:f})=>{s.isModal?(t(this,k).set(s,t(this,S).length),t(this,S).push(s),s.zIndex=t(this,j).length+t(this,S).length):(t(this,k).set(s,t(this,j).length),t(this,j).push(s),s.zIndex=t(this,j).length,t(this,S).length>0&&t(this,S).forEach((d,h)=>d.zIndex=t(this,j).length+h+1)),s.willLockScroll&&this.lockScroll(s)},this.onCloseAnimationEnd=({drawer:s,trigger:f})=>{const d=s.isModal?t(this,S):t(this,j);for(delete d[t(this,k).get(s)];d.length&&!d.at(-1);)d.pop();t(this,k).delete(s),this.unlockScroll(s)};const e=W(n);if(e===null)throw new Error("Drawer's group root cannot be found");O(this,P,e);const a=t(this,P).closest("[data-scrollable], html")||t(this,P).matches("[data-scrollable], html")&&t(this,P);if(a===null)throw new Error("Scrollable container for group root cannot be found");O(this,N,a)}add(n){n.on("beforeOpen",this.onBeforeOpen),n.on("closeAnimationEnd",this.onCloseAnimationEnd),n.assignGroup(this)}lockScroll(n){t(this,M).size===0&&t(this,N).classList.add("scroll-lock-by-drawer"),t(this,M).add(n)}unlockScroll(n){t(this,M).delete(n),t(this,M).size===0&&t(this,N).classList.remove("scroll-lock-by-drawer")}}P=new WeakMap,S=new WeakMap,j=new WeakMap,N=new WeakMap,M=new WeakMap,k=new WeakMap;const K=class K{constructor(){g(this,q,new Map);g(this,G,new Map);if(K.instance)return K.instance;K.instance=this}init(n){document.querySelectorAll(`[${V}]`).forEach(f=>{const d=f.getAttribute(V);typeof d=="string"&&t(this,G).set(d,new Z(f))}),t(this,G).set("default",new Z(document.documentElement)),document.querySelectorAll("[data-drawer]").forEach(f=>{var o;const d=f.getAttribute("data-drawer");if(typeof d!="string")return;const h=new ie({target:f,options:n});t(this,q).set(d,h);const u=f.closest(`[${V}]`),i=u?u.getAttribute(V):"default";if(typeof i!="string")throw new Error("Group doesn't have alias set correctly");(o=t(this,G).get(i))==null||o.add(h)}),document.querySelectorAll("[data-drawer-open], [data-drawer-close], [data-drawer-toggle]").forEach(f=>{if(f.hasAttribute("data-drawer-open")){const d=f.getAttribute("data-drawer-open");new Y({target:f,type:"open",owner:this.get(d)})}else if(f.hasAttribute("data-drawer-close")){const d=f.getAttribute("data-drawer-close");new Y({target:f,type:"close",owner:this.get(d)})}else{const d=f.getAttribute("data-drawer-toggle");new Y({target:f,type:"toggle",owner:this.get(d)})}})}open(n,{trigger:e,options:a}={}){var s;(s=this.get(n))==null||s.open(e)}close(n,{trigger:e,options:a}={}){var s;(s=this.get(n))==null||s.close(e)}get(n){return typeof n=="string"&&t(this,q).get(n)||null}on(n,e,a){var s;if(n)(s=this.get(n))==null||s.on(e,a);else for(const[f,d]of t(this,q))d.on(e,a)}};q=new WeakMap,G=new WeakMap;let J=K;typeof window<"u"&&(window.hasOwnProperty("app")||(window.app={}),window.app.drawers=new J),w.Drawer=ie,w.DrawersGroup=Z,w.Trigger=Y,w.default=J,Object.defineProperties(w,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanilla-drawers",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Drawers controller.",
5
5
  "files": [
6
6
  "dist"