vanilla-drawers 1.1.18 → 1.1.19

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,30 +6,30 @@ var s = (n, t, e) => (X(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
- }, v = (n, t, e, a) => (X(n, t, "write to private field"), a ? a.call(n, e) : t.set(n, e), e);
9
+ }, v = (n, t, e, l) => (X(n, t, "write to private field"), l ? l.call(n, e) : t.set(n, e), e);
10
10
  function ne(n) {
11
11
  return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
12
12
  }
13
13
  var se = { 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));
19
- function l(o, i, c) {
18
+ Object.create && (l.prototype = /* @__PURE__ */ Object.create(null), new l().__proto__ || (e = !1));
19
+ function a(o, i, c) {
20
20
  this.fn = o, this.context = i, this.once = c || !1;
21
21
  }
22
22
  function g(o, i, c, h, b) {
23
23
  if (typeof c != "function")
24
24
  throw new TypeError("The listener must be a function");
25
- var y = new l(c, h || o, b), d = e ? e + i : i;
26
- return o._events[d] ? o._events[d].fn ? o._events[d] = [o._events[d], y] : o._events[d].push(y) : (o._events[d] = y, o._eventsCount++), o;
25
+ var y = new a(c, h || o, b), f = e ? e + i : i;
26
+ return o._events[f] ? o._events[f].fn ? o._events[f] = [o._events[f], y] : o._events[f].push(y) : (o._events[f] = y, o._eventsCount++), o;
27
27
  }
28
28
  function p(o, i) {
29
- --o._eventsCount === 0 ? o._events = new a() : delete o._events[i];
29
+ --o._eventsCount === 0 ? o._events = new l() : delete o._events[i];
30
30
  }
31
31
  function r() {
32
- this._events = new a(), this._eventsCount = 0;
32
+ this._events = new l(), this._eventsCount = 0;
33
33
  }
34
34
  r.prototype.eventNames = function() {
35
35
  var i = [], c, h;
@@ -44,13 +44,13 @@ var se = { exports: {} };
44
44
  return [];
45
45
  if (h.fn)
46
46
  return [h.fn];
47
- for (var b = 0, y = h.length, d = new Array(y); b < y; b++)
48
- d[b] = h[b].fn;
49
- return d;
47
+ for (var b = 0, y = h.length, f = new Array(y); b < y; b++)
48
+ f[b] = h[b].fn;
49
+ return f;
50
50
  }, r.prototype.listenerCount = function(i) {
51
51
  var c = e ? e + i : i, h = this._events[c];
52
52
  return h ? h.fn ? 1 : h.length : 0;
53
- }, r.prototype.emit = function(i, c, h, b, y, d) {
53
+ }, r.prototype.emit = function(i, c, h, b, y, f) {
54
54
  var _ = e ? e + i : i;
55
55
  if (!this._events[_])
56
56
  return !1;
@@ -68,7 +68,7 @@ var se = { exports: {} };
68
68
  case 5:
69
69
  return u.fn.call(u.context, c, h, b, y), !0;
70
70
  case 6:
71
- return u.fn.call(u.context, c, h, b, y, d), !0;
71
+ return u.fn.call(u.context, c, h, b, y, f), !0;
72
72
  }
73
73
  for (w = 1, S = new Array(L - 1); w < L; w++)
74
74
  S[w - 1] = arguments[w];
@@ -107,23 +107,23 @@ var se = { exports: {} };
107
107
  return this;
108
108
  if (!c)
109
109
  return p(this, y), this;
110
- var d = this._events[y];
111
- if (d.fn)
112
- d.fn === c && (!b || d.once) && (!h || d.context === h) && p(this, y);
110
+ var f = this._events[y];
111
+ if (f.fn)
112
+ f.fn === c && (!b || f.once) && (!h || f.context === h) && p(this, y);
113
113
  else {
114
- for (var _ = 0, u = [], L = d.length; _ < L; _++)
115
- (d[_].fn !== c || b && !d[_].once || h && d[_].context !== h) && u.push(d[_]);
114
+ for (var _ = 0, u = [], L = f.length; _ < L; _++)
115
+ (f[_].fn !== c || b && !f[_].once || h && f[_].context !== h) && u.push(f[_]);
116
116
  u.length ? this._events[y] = u.length === 1 ? u[0] : u : p(this, y);
117
117
  }
118
118
  return this;
119
119
  }, r.prototype.removeAllListeners = function(i) {
120
120
  var c;
121
- return i ? (c = e ? e + i : i, this._events[c] && p(this, c)) : (this._events = new a(), this._eventsCount = 0), this;
121
+ return i ? (c = e ? e + i : i, this._events[c] && p(this, c)) : (this._events = new l(), this._eventsCount = 0), this;
122
122
  }, r.prototype.off = r.prototype.removeListener, r.prototype.addListener = r.prototype.on, r.prefixed = e, r.EventEmitter = r, n.exports = r;
123
123
  })(se);
124
124
  var ie = se.exports;
125
- const le = /* @__PURE__ */ ne(ie);
126
- var ae = function(t) {
125
+ const ae = /* @__PURE__ */ ne(ie);
126
+ var le = function(t) {
127
127
  return ce(t) && !he(t);
128
128
  };
129
129
  function ce(n) {
@@ -131,11 +131,11 @@ function ce(n) {
131
131
  }
132
132
  function he(n) {
133
133
  var t = Object.prototype.toString.call(n);
134
- return t === "[object RegExp]" || t === "[object Date]" || de(n);
134
+ return t === "[object RegExp]" || t === "[object Date]" || fe(n);
135
135
  }
136
- var ue = typeof Symbol == "function" && Symbol.for, fe = ue ? Symbol.for("react.element") : 60103;
137
- function de(n) {
138
- return n.$$typeof === fe;
136
+ var ue = typeof Symbol == "function" && Symbol.for, de = ue ? Symbol.for("react.element") : 60103;
137
+ function fe(n) {
138
+ return n.$$typeof === de;
139
139
  }
140
140
  function pe(n) {
141
141
  return Array.isArray(n) ? [] : {};
@@ -144,8 +144,8 @@ function R(n, t) {
144
144
  return t.clone !== !1 && t.isMergeableObject(n) ? U(pe(n), n, t) : n;
145
145
  }
146
146
  function we(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 me(n, t) {
@@ -173,23 +173,23 @@ function ge(n, t) {
173
173
  return re(n, t) && !(Object.hasOwnProperty.call(n, t) && Object.propertyIsEnumerable.call(n, t));
174
174
  }
175
175
  function ye(n, t, e) {
176
- var a = {};
177
- return e.isMergeableObject(n) && Z(n).forEach(function(l) {
178
- a[l] = R(n[l], e);
179
- }), Z(t).forEach(function(l) {
180
- ge(n, l) || (re(n, l) && e.isMergeableObject(t[l]) ? a[l] = me(l, e)(n[l], t[l], e) : a[l] = R(t[l], e));
181
- }), a;
176
+ var l = {};
177
+ return e.isMergeableObject(n) && Z(n).forEach(function(a) {
178
+ l[a] = R(n[a], e);
179
+ }), Z(t).forEach(function(a) {
180
+ ge(n, a) || (re(n, a) && e.isMergeableObject(t[a]) ? l[a] = me(a, e)(n[a], t[a], e) : l[a] = R(t[a], e));
181
+ }), l;
182
182
  }
183
183
  function U(n, t, e) {
184
- e = e || {}, e.arrayMerge = e.arrayMerge || we, e.isMergeableObject = e.isMergeableObject || ae, e.cloneUnlessOtherwiseSpecified = R;
185
- var a = Array.isArray(t), l = Array.isArray(n), g = a === l;
186
- return g ? a ? e.arrayMerge(n, t, e) : ye(n, t, e) : R(t, e);
184
+ e = e || {}, e.arrayMerge = e.arrayMerge || we, e.isMergeableObject = e.isMergeableObject || le, e.cloneUnlessOtherwiseSpecified = R;
185
+ var l = Array.isArray(t), a = Array.isArray(n), g = l === a;
186
+ return g ? l ? e.arrayMerge(n, t, e) : ye(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, l) {
192
- return U(a, l, e);
191
+ return t.reduce(function(l, a) {
192
+ return U(l, a, e);
193
193
  }, {});
194
194
  };
195
195
  var ve = U, Oe = ve;
@@ -252,17 +252,17 @@ function te(n) {
252
252
  }
253
253
  var A, O, P, B;
254
254
  class Y {
255
- constructor({ target: t, type: e, owner: a }) {
255
+ constructor({ target: t, type: e, owner: l }) {
256
256
  m(this, A, void 0);
257
257
  m(this, O, void 0);
258
258
  m(this, P, void 0);
259
259
  m(this, B, !1);
260
- const l = W(t);
261
- if (!l)
262
- throw new Error("Trigger element cannot be found");
260
+ const a = W(t);
263
261
  if (!a)
262
+ throw new Error("Trigger element cannot be found");
263
+ if (!l)
264
264
  throw new Error("Owning drawer instance hasn't been provided");
265
- v(this, A, l), v(this, O, a), v(this, P, e), this.init();
265
+ v(this, A, a), v(this, O, l), v(this, P, e), this.init();
266
266
  }
267
267
  // Accessors
268
268
  get isActive() {
@@ -283,11 +283,11 @@ class Y {
283
283
  }
284
284
  }
285
285
  A = new WeakMap(), O = new WeakMap(), P = new WeakMap(), B = new WeakMap();
286
- var f, K, j, H, T;
287
- class Le extends le {
288
- constructor({ target: e, options: a }) {
286
+ var d, K, j, H, T;
287
+ class Le extends ae {
288
+ constructor({ target: e, options: l }) {
289
289
  super();
290
- m(this, f, void 0);
290
+ m(this, d, void 0);
291
291
  m(this, K, void 0);
292
292
  m(this, j, void 0);
293
293
  m(this, H, void 0);
@@ -302,9 +302,9 @@ class Le extends le {
302
302
  const i = o == null ? void 0 : o.closest("[data-drawer]");
303
303
  i ? i.getAttribute("data-drawer") === s(this, T) ? this.handleUnderlayClick(r) : this.handleOtherDrawerClick(r) : this.handleOutsideClick(r);
304
304
  }, this.handleKeydown = (r) => {
305
- s(this, f).closeOnEsc && r.key === "Escape" && this.close();
305
+ s(this, d).closeOnEsc && r.key === "Escape" && this.close();
306
306
  };
307
- const l = te(a ? [J, a] : [J]), g = W(e);
307
+ const a = te(l ? [J, l] : [J]), g = W(e);
308
308
  if (g === null)
309
309
  throw new Error("Drawer's root cannot be found");
310
310
  v(this, T, g.getAttribute("data-drawer"));
@@ -314,7 +314,7 @@ class Le extends le {
314
314
  this.dom = {
315
315
  root: g,
316
316
  panel: p
317
- }, this.setOptions(l), this.dom.panel.setAttribute("tabindex", "-1"), this.dom.root.classList.add("drawer_initialized");
317
+ }, this.setOptions(a), this.dom.panel.setAttribute("tabindex", "-1"), this.dom.root.classList.add("drawer_initialized");
318
318
  }
319
319
  addEventListeners() {
320
320
  this.dom.root.addEventListener("keydown", this.handleKeydown), document.addEventListener("click", this.handleDocumentClick);
@@ -327,13 +327,13 @@ class Le extends le {
327
327
  return s(this, j);
328
328
  }
329
329
  get isModal() {
330
- return s(this, f).modal;
330
+ return s(this, d).modal;
331
331
  }
332
332
  set isModal(e) {
333
333
  this.dom.root.classList[e ? "add" : "remove"]("drawer_modal");
334
334
  }
335
335
  get willLockScroll() {
336
- return s(this, f).lockPageScroll;
336
+ return s(this, d).lockPageScroll;
337
337
  }
338
338
  set zIndex(e) {
339
339
  this.dom.root.style.setProperty("--z-index", String(e)), v(this, K, e);
@@ -343,21 +343,21 @@ class Le extends le {
343
343
  }
344
344
  // Methods
345
345
  async open(e) {
346
- await V(0), !s(this, j) && (this.emit("beforeOpen", { drawer: this, trigger: e }), v(this, j, !0), this.dom.root.classList.add(s(this, f).openingClass), this.emit("open", { drawer: this, trigger: e }), typeof s(this, f).openAnimationDuration == "number" && await V(s(this, f).openAnimationDuration), this.dom.root.classList.remove(s(this, f).openingClass), this.dom.root.classList.add(s(this, f).openClass), this.emit("openAnimationEnd", { drawer: this, trigger: e }), this.focus(), this.addEventListeners());
346
+ await V(0), !s(this, j) && (this.emit("beforeOpen", { drawer: this, trigger: e }), v(this, j, !0), this.dom.root.classList.add(s(this, d).openingClass), this.emit("open", { drawer: this, trigger: e }), typeof s(this, d).openAnimationDuration == "number" && await V(s(this, d).openAnimationDuration), this.dom.root.classList.remove(s(this, d).openingClass), this.dom.root.classList.add(s(this, d).openClass), this.emit("openAnimationEnd", { drawer: this, trigger: e }), this.focus(), this.addEventListeners());
347
347
  }
348
348
  async close(e) {
349
- s(this, f).onCloseConfirm && !s(this, f).onCloseConfirm(this, e) || (this.emit("beforeClose", { drawer: this, trigger: e }), this.removeEventListeners(), v(this, j, !1), this.dom.root.classList.remove(s(this, f).openClass), this.dom.root.classList.add(s(this, f).closingClass), this.emit("close", { drawer: this, trigger: e }), typeof s(this, f).closeAnimationDuration == "number" && await V(s(this, f).closeAnimationDuration), this.dom.root.classList.remove(s(this, f).closingClass), this.emit("closeAnimationEnd", { drawer: this, trigger: e }));
349
+ s(this, d).onCloseConfirm && !s(this, d).onCloseConfirm(this, e) || (this.emit("beforeClose", { drawer: this, trigger: e }), this.removeEventListeners(), v(this, j, !1), this.dom.root.classList.remove(s(this, d).openClass), this.dom.root.classList.add(s(this, d).closingClass), this.emit("close", { drawer: this, trigger: e }), typeof s(this, d).closeAnimationDuration == "number" && await V(s(this, d).closeAnimationDuration), this.dom.root.classList.remove(s(this, d).closingClass), this.emit("closeAnimationEnd", { drawer: this, trigger: e }));
350
350
  }
351
351
  handleOtherDrawerClick(e) {
352
352
  }
353
353
  handleOutsideClick(e) {
354
- s(this, f).closeOnOutsideClick && (typeof s(this, f).closeOnOutsideClick == "object" && s(this, f).closeOnOutsideClick.hasOwnProperty("checkTarget") ? s(this, f).closeOnOutsideClick.checkTarget(e.target) && this.close() : this.close());
354
+ s(this, d).closeOnOutsideClick && (typeof s(this, d).closeOnOutsideClick == "object" && s(this, d).closeOnOutsideClick.hasOwnProperty("checkTarget") ? s(this, d).closeOnOutsideClick.checkTarget(e.target) && this.close() : this.close());
355
355
  }
356
356
  handleUnderlayClick(e) {
357
- s(this, f).closeOnOutsideClick && this.close();
357
+ s(this, d).closeOnOutsideClick && this.close();
358
358
  }
359
359
  focus() {
360
- s(this, f).focusOnChild && this.focusChild() || this.focusSelf();
360
+ s(this, d).focusOnChild && this.focusChild() || this.focusSelf();
361
361
  }
362
362
  focusSelf() {
363
363
  this.dom.panel.focus();
@@ -367,14 +367,14 @@ class Le extends le {
367
367
  return e ? (e.focus(), !0) : !1;
368
368
  }
369
369
  setOptions(e) {
370
- var a;
371
- e.hasOwnProperty("modal") && ((a = s(this, f)) == null ? void 0 : a.modal) !== e.modal && (this.isModal = e.modal), v(this, f, s(this, f) ? te([s(this, f), e]) : e);
370
+ var l;
371
+ e.hasOwnProperty("modal") && ((l = s(this, d)) == null ? void 0 : l.modal) !== e.modal && (this.isModal = e.modal), v(this, d, s(this, d) ? te([s(this, d), e]) : e);
372
372
  }
373
373
  assignGroup(e) {
374
374
  v(this, H, e);
375
375
  }
376
376
  }
377
- f = new WeakMap(), K = new WeakMap(), j = new WeakMap(), H = new WeakMap(), T = new WeakMap();
377
+ d = new WeakMap(), K = new WeakMap(), j = new WeakMap(), H = new WeakMap(), T = new WeakMap();
378
378
  var M;
379
379
  class ke {
380
380
  constructor() {
@@ -382,12 +382,12 @@ class ke {
382
382
  }
383
383
  lock(t, e) {
384
384
  s(this, M).has(t) || s(this, M).set(t, /* @__PURE__ */ new Set());
385
- const a = s(this, M).get(t);
386
- a.size === 0 && t.classList.add("scroll-lock-by-drawer"), a.add(e);
385
+ const l = s(this, M).get(t);
386
+ l.size === 0 && t.classList.add("scroll-lock-by-drawer"), l.add(e);
387
387
  }
388
388
  unlock(t, e) {
389
- const a = s(this, M).get(t);
390
- a == null || a.delete(e), (!a || a.size === 0) && t.classList.remove("scroll-lock-by-drawer");
389
+ const l = s(this, M).get(t);
390
+ l == null || l.delete(e), (!l || l.size === 0) && t.classList.remove("scroll-lock-by-drawer");
391
391
  }
392
392
  }
393
393
  M = new WeakMap();
@@ -399,22 +399,22 @@ const $ = class $ {
399
399
  m(this, C, void 0);
400
400
  m(this, D, void 0);
401
401
  m(this, k, void 0);
402
- v(this, E, []), v(this, C, []), v(this, k, /* @__PURE__ */ new Map()), this.onBeforeOpen = ({ drawer: l, trigger: g }) => {
403
- l.isModal ? (s(this, k).set(l, s(this, E).length), s(this, E).push(l), l.zIndex = s(this, C).length + s(this, E).length) : (s(this, k).set(l, s(this, C).length), s(this, C).push(l), l.zIndex = s(this, C).length, s(this, E).length > 0 && s(this, E).forEach((p, r) => p.zIndex = s(this, C).length + r + 1)), l.willLockScroll && this.lockScroll(l);
404
- }, this.onCloseAnimationEnd = ({ drawer: l, trigger: g }) => {
405
- const p = l.isModal ? s(this, E) : s(this, C);
406
- for (delete p[s(this, k).get(l)]; p.length && !p.at(-1); )
402
+ v(this, E, []), v(this, C, []), v(this, k, /* @__PURE__ */ new Map()), this.onBeforeOpen = ({ drawer: a, trigger: g }) => {
403
+ a.isModal ? (s(this, k).set(a, s(this, E).length), s(this, E).push(a), a.zIndex = s(this, C).length + s(this, E).length) : (s(this, k).set(a, s(this, C).length), s(this, C).push(a), a.zIndex = s(this, C).length, s(this, E).length > 0 && s(this, E).forEach((p, r) => p.zIndex = s(this, C).length + r + 1)), a.willLockScroll && this.lockScroll(a);
404
+ }, this.onCloseAnimationEnd = ({ drawer: a, trigger: g }) => {
405
+ const p = a.isModal ? s(this, E) : s(this, C);
406
+ for (delete p[s(this, k).get(a)]; p.length && !p.at(-1); )
407
407
  p.pop();
408
- s(this, k).delete(l), this.unlockScroll(l);
408
+ s(this, k).delete(a), this.unlockScroll(a);
409
409
  };
410
410
  const e = W(t);
411
411
  if (e === null)
412
412
  throw new Error("Drawer's group root cannot be found");
413
413
  v(this, x, e);
414
- const a = s(this, x).closest("[data-scrollable], html") || s(this, x).matches("[data-scrollable], html") && s(this, x);
415
- if (a === null)
414
+ const l = s(this, x).closest("[data-scrollable], html") || s(this, x).matches("[data-scrollable], html") && s(this, x);
415
+ if (l === null)
416
416
  throw new Error("Scrollable container for group root cannot be found");
417
- v(this, D, a);
417
+ v(this, D, l);
418
418
  }
419
419
  add(t) {
420
420
  t.on("beforeOpen", this.onBeforeOpen), t.on("closeAnimationEnd", this.onCloseAnimationEnd), t.assignGroup(this);
@@ -446,7 +446,7 @@ const q = class q {
446
446
  const o = r.getAttribute("data-drawer");
447
447
  if (typeof o != "string")
448
448
  return;
449
- const i = new Le({ target: r, options: { ...t, modal: r.matches('*:not([data-modal="false"])') } });
449
+ const i = new Le({ target: r, options: { ...t, modal: r.matches('*:not([data-modal="false"])') || !r.matches("[data-modal]") && t.modal } });
450
450
  s(this, I).set(o, i);
451
451
  const c = r.closest(`[${F}]`), h = c ? c.getAttribute(F) : "default";
452
452
  if (typeof h != "string")
@@ -479,24 +479,24 @@ const q = class q {
479
479
  throw new Error(`Drawer hasn't been found for the trigger elem: ${r}. Alias: ${i}`);
480
480
  }
481
481
  }
482
- open(t, { trigger: e, options: a } = {}) {
483
- var l;
484
- (l = this.get(t)) == null || l.open(e);
482
+ open(t, { trigger: e, options: l } = {}) {
483
+ var a;
484
+ (a = this.get(t)) == null || a.open(e);
485
485
  }
486
- close(t, { trigger: e, options: a } = {}) {
487
- var l;
488
- (l = this.get(t)) == null || l.close(e);
486
+ close(t, { trigger: e, options: l } = {}) {
487
+ var a;
488
+ (a = this.get(t)) == null || a.close(e);
489
489
  }
490
490
  get(t) {
491
491
  return typeof t == "string" && s(this, I).get(t) || null;
492
492
  }
493
- on(t, e, a) {
494
- var l;
493
+ on(t, e, l) {
494
+ var a;
495
495
  if (t)
496
- (l = this.get(t)) == null || l.on(e, a);
496
+ (a = this.get(t)) == null || a.on(e, l);
497
497
  else
498
498
  for (const [g, p] of s(this, I))
499
- p.on(e, a);
499
+ p.on(e, l);
500
500
  }
501
501
  };
502
502
  I = new WeakMap(), z = new WeakMap();
@@ -1,6 +1,6 @@
1
- (function(d,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(d=typeof globalThis<"u"?globalThis:d||self,g(d.Drawers={}))})(this,function(d){"use strict";var le=(d,g,C)=>{if(!g.has(d))throw TypeError("Cannot "+C)};var n=(d,g,C)=>(le(d,g,"read from private field"),C?C.call(d):g.get(d)),b=(d,g,C)=>{if(g.has(d))throw TypeError("Cannot add the same private member more than once");g instanceof WeakSet?g.add(d):g.set(d,C)},A=(d,g,C,Y)=>(le(d,g,"write to private field"),Y?Y.call(d,C):g.set(d,C),C);var _,E,z,K,f,F,x,X,U,T,P,L,k,N,j,$,q;function g(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var C={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function a(){}Object.create&&(a.prototype=Object.create(null),new a().__proto__||(e=!1));function l(o,i,c){this.fn=o,this.context=i,this.once=c||!1}function v(o,i,c,h,y){if(typeof c!="function")throw new TypeError("The listener must be a function");var O=new l(c,h||o,y),p=e?e+i:i;return o._events[p]?o._events[p].fn?o._events[p]=[o._events[p],O]:o._events[p].push(O):(o._events[p]=O,o._eventsCount++),o}function w(o,i){--o._eventsCount===0?o._events=new a:delete o._events[i]}function s(){this._events=new a,this._eventsCount=0}s.prototype.eventNames=function(){var i=[],c,h;if(this._eventsCount===0)return i;for(h in c=this._events)t.call(c,h)&&i.push(e?h.slice(1):h);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(c)):i},s.prototype.listeners=function(i){var c=e?e+i:i,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var y=0,O=h.length,p=new Array(O);y<O;y++)p[y]=h[y].fn;return p},s.prototype.listenerCount=function(i){var c=e?e+i:i,h=this._events[c];return h?h.fn?1:h.length:0},s.prototype.emit=function(i,c,h,y,O,p){var S=e?e+i:i;if(!this._events[S])return!1;var u=this._events[S],M=arguments.length,D,m;if(u.fn){switch(u.once&&this.removeListener(i,u.fn,void 0,!0),M){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,c),!0;case 3:return u.fn.call(u.context,c,h),!0;case 4:return u.fn.call(u.context,c,h,y),!0;case 5:return u.fn.call(u.context,c,h,y,O),!0;case 6:return u.fn.call(u.context,c,h,y,O,p),!0}for(m=1,D=new Array(M-1);m<M;m++)D[m-1]=arguments[m];u.fn.apply(u.context,D)}else{var Se=u.length,V;for(m=0;m<Se;m++)switch(u[m].once&&this.removeListener(i,u[m].fn,void 0,!0),M){case 1:u[m].fn.call(u[m].context);break;case 2:u[m].fn.call(u[m].context,c);break;case 3:u[m].fn.call(u[m].context,c,h);break;case 4:u[m].fn.call(u[m].context,c,h,y);break;default:if(!D)for(V=1,D=new Array(M-1);V<M;V++)D[V-1]=arguments[V];u[m].fn.apply(u[m].context,D)}}return!0},s.prototype.on=function(i,c,h){return v(this,i,c,h,!1)},s.prototype.once=function(i,c,h){return v(this,i,c,h,!0)},s.prototype.removeListener=function(i,c,h,y){var O=e?e+i:i;if(!this._events[O])return this;if(!c)return w(this,O),this;var p=this._events[O];if(p.fn)p.fn===c&&(!y||p.once)&&(!h||p.context===h)&&w(this,O);else{for(var S=0,u=[],M=p.length;S<M;S++)(p[S].fn!==c||y&&!p[S].once||h&&p[S].context!==h)&&u.push(p[S]);u.length?this._events[O]=u.length===1?u[0]:u:w(this,O)}return this},s.prototype.removeAllListeners=function(i){var c;return i?(c=e?e+i:i,this._events[c]&&w(this,c)):(this._events=new a,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=e,s.EventEmitter=s,r.exports=s})(C);var Y=C.exports;const ae=g(Y);var ce=function(t){return he(t)&&!ue(t)};function he(r){return!!r&&typeof r=="object"}function ue(r){var t=Object.prototype.toString.call(r);return t==="[object RegExp]"||t==="[object Date]"||pe(r)}var fe=typeof Symbol=="function"&&Symbol.for,de=fe?Symbol.for("react.element"):60103;function pe(r){return r.$$typeof===de}function we(r){return Array.isArray(r)?[]:{}}function R(r,t){return t.clone!==!1&&t.isMergeableObject(r)?I(we(r),r,t):r}function me(r,t,e){return r.concat(t).map(function(a){return R(a,e)})}function ge(r,t){if(!t.customMerge)return I;var e=t.customMerge(r);return typeof e=="function"?e:I}function be(r){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(r).filter(function(t){return Object.propertyIsEnumerable.call(r,t)}):[]}function ne(r){return Object.keys(r).concat(be(r))}function re(r,t){try{return t in r}catch{return!1}}function ye(r,t){return re(r,t)&&!(Object.hasOwnProperty.call(r,t)&&Object.propertyIsEnumerable.call(r,t))}function ve(r,t,e){var a={};return e.isMergeableObject(r)&&ne(r).forEach(function(l){a[l]=R(r[l],e)}),ne(t).forEach(function(l){ye(r,l)||(re(r,l)&&e.isMergeableObject(t[l])?a[l]=ge(l,e)(r[l],t[l],e):a[l]=R(t[l],e))}),a}function I(r,t,e){e=e||{},e.arrayMerge=e.arrayMerge||me,e.isMergeableObject=e.isMergeableObject||ce,e.cloneUnlessOtherwiseSpecified=R;var a=Array.isArray(t),l=Array.isArray(r),v=a===l;return v?a?e.arrayMerge(r,t,e):ve(r,t,e):R(t,e)}I.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(a,l){return I(a,l,e)},{})};var Oe=I,Ae=Oe;const Ee=g(Ae);/*!
1
+ (function(f,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(f=typeof globalThis<"u"?globalThis:f||self,g(f.Drawers={}))})(this,function(f){"use strict";var le=(f,g,C)=>{if(!g.has(f))throw TypeError("Cannot "+C)};var n=(f,g,C)=>(le(f,g,"read from private field"),C?C.call(f):g.get(f)),b=(f,g,C)=>{if(g.has(f))throw TypeError("Cannot add the same private member more than once");g instanceof WeakSet?g.add(f):g.set(f,C)},A=(f,g,C,Y)=>(le(f,g,"write to private field"),Y?Y.call(f,C):g.set(f,C),C);var _,E,z,K,d,F,x,X,U,T,P,L,k,N,j,$,q;function g(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var C={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function a(){}Object.create&&(a.prototype=Object.create(null),new a().__proto__||(e=!1));function l(o,i,c){this.fn=o,this.context=i,this.once=c||!1}function v(o,i,c,h,y){if(typeof c!="function")throw new TypeError("The listener must be a function");var O=new l(c,h||o,y),p=e?e+i:i;return o._events[p]?o._events[p].fn?o._events[p]=[o._events[p],O]:o._events[p].push(O):(o._events[p]=O,o._eventsCount++),o}function w(o,i){--o._eventsCount===0?o._events=new a:delete o._events[i]}function r(){this._events=new a,this._eventsCount=0}r.prototype.eventNames=function(){var i=[],c,h;if(this._eventsCount===0)return i;for(h in c=this._events)t.call(c,h)&&i.push(e?h.slice(1):h);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(c)):i},r.prototype.listeners=function(i){var c=e?e+i:i,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var y=0,O=h.length,p=new Array(O);y<O;y++)p[y]=h[y].fn;return p},r.prototype.listenerCount=function(i){var c=e?e+i:i,h=this._events[c];return h?h.fn?1:h.length:0},r.prototype.emit=function(i,c,h,y,O,p){var S=e?e+i:i;if(!this._events[S])return!1;var u=this._events[S],M=arguments.length,D,m;if(u.fn){switch(u.once&&this.removeListener(i,u.fn,void 0,!0),M){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,c),!0;case 3:return u.fn.call(u.context,c,h),!0;case 4:return u.fn.call(u.context,c,h,y),!0;case 5:return u.fn.call(u.context,c,h,y,O),!0;case 6:return u.fn.call(u.context,c,h,y,O,p),!0}for(m=1,D=new Array(M-1);m<M;m++)D[m-1]=arguments[m];u.fn.apply(u.context,D)}else{var Se=u.length,V;for(m=0;m<Se;m++)switch(u[m].once&&this.removeListener(i,u[m].fn,void 0,!0),M){case 1:u[m].fn.call(u[m].context);break;case 2:u[m].fn.call(u[m].context,c);break;case 3:u[m].fn.call(u[m].context,c,h);break;case 4:u[m].fn.call(u[m].context,c,h,y);break;default:if(!D)for(V=1,D=new Array(M-1);V<M;V++)D[V-1]=arguments[V];u[m].fn.apply(u[m].context,D)}}return!0},r.prototype.on=function(i,c,h){return v(this,i,c,h,!1)},r.prototype.once=function(i,c,h){return v(this,i,c,h,!0)},r.prototype.removeListener=function(i,c,h,y){var O=e?e+i:i;if(!this._events[O])return this;if(!c)return w(this,O),this;var p=this._events[O];if(p.fn)p.fn===c&&(!y||p.once)&&(!h||p.context===h)&&w(this,O);else{for(var S=0,u=[],M=p.length;S<M;S++)(p[S].fn!==c||y&&!p[S].once||h&&p[S].context!==h)&&u.push(p[S]);u.length?this._events[O]=u.length===1?u[0]:u:w(this,O)}return this},r.prototype.removeAllListeners=function(i){var c;return i?(c=e?e+i:i,this._events[c]&&w(this,c)):(this._events=new a,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=e,r.EventEmitter=r,s.exports=r})(C);var Y=C.exports;const ae=g(Y);var ce=function(t){return he(t)&&!ue(t)};function he(s){return!!s&&typeof s=="object"}function ue(s){var t=Object.prototype.toString.call(s);return t==="[object RegExp]"||t==="[object Date]"||pe(s)}var de=typeof Symbol=="function"&&Symbol.for,fe=de?Symbol.for("react.element"):60103;function pe(s){return s.$$typeof===fe}function we(s){return Array.isArray(s)?[]:{}}function R(s,t){return t.clone!==!1&&t.isMergeableObject(s)?I(we(s),s,t):s}function me(s,t,e){return s.concat(t).map(function(a){return R(a,e)})}function ge(s,t){if(!t.customMerge)return I;var e=t.customMerge(s);return typeof e=="function"?e:I}function be(s){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(s).filter(function(t){return Object.propertyIsEnumerable.call(s,t)}):[]}function ne(s){return Object.keys(s).concat(be(s))}function se(s,t){try{return t in s}catch{return!1}}function ye(s,t){return se(s,t)&&!(Object.hasOwnProperty.call(s,t)&&Object.propertyIsEnumerable.call(s,t))}function ve(s,t,e){var a={};return e.isMergeableObject(s)&&ne(s).forEach(function(l){a[l]=R(s[l],e)}),ne(t).forEach(function(l){ye(s,l)||(se(s,l)&&e.isMergeableObject(t[l])?a[l]=ge(l,e)(s[l],t[l],e):a[l]=R(t[l],e))}),a}function I(s,t,e){e=e||{},e.arrayMerge=e.arrayMerge||me,e.isMergeableObject=e.isMergeableObject||ce,e.cloneUnlessOtherwiseSpecified=R;var a=Array.isArray(t),l=Array.isArray(s),v=a===l;return v?a?e.arrayMerge(s,t,e):ve(s,t,e):R(t,e)}I.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(a,l){return I(a,l,e)},{})};var Oe=I,Ae=Oe;const Ee=g(Ae);/*!
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 se(r){return Object.prototype.toString.call(r)==="[object Object]"}function Ce(r){var t,e;return se(r)===!1?!1:(t=r.constructor,t===void 0?!0:(e=t.prototype,!(se(e)===!1||e.hasOwnProperty("isPrototypeOf")===!1)))}function Z(r){return r instanceof Element?r:document.querySelector(r)}async function ee(r){return await new Promise(t=>setTimeout(t,r))}const _e='[data-elem="drawer.panel"]',J="data-drawers-group",Le=["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^="-"])'],te={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",closingClass:"drawer_closing",openingClass:"drawer_opening",openAnimationDuration:0,closeAnimationDuration:0,lockPageScroll:!0};function oe(r){return Ee.all(r,{isMergeableObject:Ce})}class Q{constructor({target:t,type:e,owner:a}){b(this,_,void 0);b(this,E,void 0);b(this,z,void 0);b(this,K,!1);const l=Z(t);if(!l)throw new Error("Trigger element cannot be found");if(!a)throw new Error("Owning drawer instance hasn't been provided");A(this,_,l),A(this,E,a),A(this,z,e),this.init()}get isActive(){return n(this,K)}get owner(){return n(this,E)}init(){n(this,_).addEventListener("click",t=>this.clickHandler(t)),n(this,E).on("open",()=>this.setActive(!0)),n(this,E).on("close",()=>this.setActive(!1))}clickHandler(t){t.__drawerTrigger=this,n(this,z)==="open"?n(this,E).isOpen||n(this,E).open(n(this,_)):n(this,z)==="close"?n(this,E).isOpen&&n(this,E).close(n(this,_)):n(this,E).isOpen?n(this,E).close(n(this,_)):n(this,E).open(n(this,_))}setActive(t){A(this,K,t),t?n(this,_).classList.add("drawer-trigger_active"):n(this,_).classList.remove("drawer-trigger_active")}}_=new WeakMap,E=new WeakMap,z=new WeakMap,K=new WeakMap;class ie extends ae{constructor({target:e,options:a}){super();b(this,f,void 0);b(this,F,void 0);b(this,x,void 0);b(this,X,void 0);b(this,U,void 0);this.handleDocumentClick=async s=>{var c;if(((c=s.__drawerTrigger)==null?void 0:c.owner)===this)return;const o=s.target;if(s.composedPath(),this.dom.panel.contains(o))return;const i=o==null?void 0:o.closest("[data-drawer]");i?i.getAttribute("data-drawer")===n(this,U)?this.handleUnderlayClick(s):this.handleOtherDrawerClick(s):this.handleOutsideClick(s)},this.handleKeydown=s=>{n(this,f).closeOnEsc&&s.key==="Escape"&&this.close()};const l=oe(a?[te,a]:[te]),v=Z(e);if(v===null)throw new Error("Drawer's root cannot be found");A(this,U,v.getAttribute("data-drawer"));const w=v.querySelector(_e);if(w===null)throw new Error(`Drawer's panel cannot be found. Alias: ${n(this,U)}`);this.dom={root:v,panel:w},this.setOptions(l),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 n(this,x)}get isModal(){return n(this,f).modal}set isModal(e){this.dom.root.classList[e?"add":"remove"]("drawer_modal")}get willLockScroll(){return n(this,f).lockPageScroll}set zIndex(e){this.dom.root.style.setProperty("--z-index",String(e)),A(this,F,e)}get zIndex(){return n(this,F)}async open(e){await ee(0),!n(this,x)&&(this.emit("beforeOpen",{drawer:this,trigger:e}),A(this,x,!0),this.dom.root.classList.add(n(this,f).openingClass),this.emit("open",{drawer:this,trigger:e}),typeof n(this,f).openAnimationDuration=="number"&&await ee(n(this,f).openAnimationDuration),this.dom.root.classList.remove(n(this,f).openingClass),this.dom.root.classList.add(n(this,f).openClass),this.emit("openAnimationEnd",{drawer:this,trigger:e}),this.focus(),this.addEventListeners())}async close(e){n(this,f).onCloseConfirm&&!n(this,f).onCloseConfirm(this,e)||(this.emit("beforeClose",{drawer:this,trigger:e}),this.removeEventListeners(),A(this,x,!1),this.dom.root.classList.remove(n(this,f).openClass),this.dom.root.classList.add(n(this,f).closingClass),this.emit("close",{drawer:this,trigger:e}),typeof n(this,f).closeAnimationDuration=="number"&&await ee(n(this,f).closeAnimationDuration),this.dom.root.classList.remove(n(this,f).closingClass),this.emit("closeAnimationEnd",{drawer:this,trigger:e}))}handleOtherDrawerClick(e){}handleOutsideClick(e){n(this,f).closeOnOutsideClick&&(typeof n(this,f).closeOnOutsideClick=="object"&&n(this,f).closeOnOutsideClick.hasOwnProperty("checkTarget")?n(this,f).closeOnOutsideClick.checkTarget(e.target)&&this.close():this.close())}handleUnderlayClick(e){n(this,f).closeOnOutsideClick&&this.close()}focus(){n(this,f).focusOnChild&&this.focusChild()||this.focusSelf()}focusSelf(){this.dom.panel.focus()}focusChild(){const e=this.dom.panel.querySelector(Le.join(","));return e?(e.focus(),!0):!1}setOptions(e){var a;e.hasOwnProperty("modal")&&((a=n(this,f))==null?void 0:a.modal)!==e.modal&&(this.isModal=e.modal),A(this,f,n(this,f)?oe([n(this,f),e]):e)}assignGroup(e){A(this,X,e)}}f=new WeakMap,F=new WeakMap,x=new WeakMap,X=new WeakMap,U=new WeakMap;class ke{constructor(){b(this,T,new Map)}lock(t,e){n(this,T).has(t)||n(this,T).set(t,new Set);const a=n(this,T).get(t);a.size===0&&t.classList.add("scroll-lock-by-drawer"),a.add(e)}unlock(t,e){const a=n(this,T).get(t);a==null||a.delete(e),(!a||a.size===0)&&t.classList.remove("scroll-lock-by-drawer")}}T=new WeakMap;const G=class G{constructor(t){b(this,P,void 0);b(this,L,void 0);b(this,k,void 0);b(this,N,void 0);b(this,j,void 0);A(this,L,[]),A(this,k,[]),A(this,j,new Map),this.onBeforeOpen=({drawer:l,trigger:v})=>{l.isModal?(n(this,j).set(l,n(this,L).length),n(this,L).push(l),l.zIndex=n(this,k).length+n(this,L).length):(n(this,j).set(l,n(this,k).length),n(this,k).push(l),l.zIndex=n(this,k).length,n(this,L).length>0&&n(this,L).forEach((w,s)=>w.zIndex=n(this,k).length+s+1)),l.willLockScroll&&this.lockScroll(l)},this.onCloseAnimationEnd=({drawer:l,trigger:v})=>{const w=l.isModal?n(this,L):n(this,k);for(delete w[n(this,j).get(l)];w.length&&!w.at(-1);)w.pop();n(this,j).delete(l),this.unlockScroll(l)};const e=Z(t);if(e===null)throw new Error("Drawer's group root cannot be found");A(this,P,e);const a=n(this,P).closest("[data-scrollable], html")||n(this,P).matches("[data-scrollable], html")&&n(this,P);if(a===null)throw new Error("Scrollable container for group root cannot be found");A(this,N,a)}add(t){t.on("beforeOpen",this.onBeforeOpen),t.on("closeAnimationEnd",this.onCloseAnimationEnd),t.assignGroup(this)}lockScroll(t){G.scrollLock.lock(n(this,N),t)}unlockScroll(t){G.scrollLock.unlock(n(this,N),t)}};P=new WeakMap,L=new WeakMap,k=new WeakMap,N=new WeakMap,j=new WeakMap,G.scrollLock=new ke;let B=G;const H=class H{constructor(){b(this,$,new Map);b(this,q,new Map);if(H.instance)return H.instance;H.instance=this}init(t=te){document.querySelectorAll(`[${J}]`).forEach(s=>{const o=s.getAttribute(J);typeof o=="string"&&n(this,q).set(o,new B(s))}),n(this,q).set("default",new B(document.documentElement)),document.querySelectorAll("[data-drawer]").forEach(s=>{var y;const o=s.getAttribute("data-drawer");if(typeof o!="string")return;const i=new ie({target:s,options:{...t,modal:s.matches('*:not([data-modal="false"])')}});n(this,$).set(o,i);const c=s.closest(`[${J}]`),h=c?c.getAttribute(J):"default";if(typeof h!="string")throw new Error("Group doesn't have alias set correctly");(y=n(this,q).get(h))==null||y.add(i)}),document.querySelectorAll("[data-drawer-open], [data-drawer-close], [data-drawer-toggle]").forEach(s=>{if(s.hasAttribute("data-drawer-open")){const o=s.getAttribute("data-drawer-open");v(s,o);const i=this.get(o);w(s,i,o),new Q({target:s,type:"open",owner:i})}else if(s.hasAttribute("data-drawer-close")){const o=s.getAttribute("data-drawer-close");v(s,o);const i=this.get(o);w(s,i,o),new Q({target:s,type:"close",owner:i})}else{const o=s.getAttribute("data-drawer-toggle");v(s,o);const i=this.get(o);w(s,i,o),new Q({target:s,type:"toggle",owner:i})}});function v(s,o){if(!o)throw new Error(`Drawer alias should be specified in the trigger attribute. Trigger elem: ${s}`)}function w(s,o,i){if(!o)throw new Error(`Drawer hasn't been found for the trigger elem: ${s}. Alias: ${i}`)}}open(t,{trigger:e,options:a}={}){var l;(l=this.get(t))==null||l.open(e)}close(t,{trigger:e,options:a}={}){var l;(l=this.get(t))==null||l.close(e)}get(t){return typeof t=="string"&&n(this,$).get(t)||null}on(t,e,a){var l;if(t)(l=this.get(t))==null||l.on(e,a);else for(const[v,w]of n(this,$))w.on(e,a)}};$=new WeakMap,q=new WeakMap;let W=H;typeof window<"u"&&(window.hasOwnProperty("app")||(window.app={}),window.app.drawers=new W),d.Drawer=ie,d.DrawersGroup=B,d.Trigger=Q,d.default=W,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
6
+ */function re(s){return Object.prototype.toString.call(s)==="[object Object]"}function Ce(s){var t,e;return re(s)===!1?!1:(t=s.constructor,t===void 0?!0:(e=t.prototype,!(re(e)===!1||e.hasOwnProperty("isPrototypeOf")===!1)))}function Z(s){return s instanceof Element?s:document.querySelector(s)}async function ee(s){return await new Promise(t=>setTimeout(t,s))}const _e='[data-elem="drawer.panel"]',J="data-drawers-group",Le=["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^="-"])'],te={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",closingClass:"drawer_closing",openingClass:"drawer_opening",openAnimationDuration:0,closeAnimationDuration:0,lockPageScroll:!0};function oe(s){return Ee.all(s,{isMergeableObject:Ce})}class Q{constructor({target:t,type:e,owner:a}){b(this,_,void 0);b(this,E,void 0);b(this,z,void 0);b(this,K,!1);const l=Z(t);if(!l)throw new Error("Trigger element cannot be found");if(!a)throw new Error("Owning drawer instance hasn't been provided");A(this,_,l),A(this,E,a),A(this,z,e),this.init()}get isActive(){return n(this,K)}get owner(){return n(this,E)}init(){n(this,_).addEventListener("click",t=>this.clickHandler(t)),n(this,E).on("open",()=>this.setActive(!0)),n(this,E).on("close",()=>this.setActive(!1))}clickHandler(t){t.__drawerTrigger=this,n(this,z)==="open"?n(this,E).isOpen||n(this,E).open(n(this,_)):n(this,z)==="close"?n(this,E).isOpen&&n(this,E).close(n(this,_)):n(this,E).isOpen?n(this,E).close(n(this,_)):n(this,E).open(n(this,_))}setActive(t){A(this,K,t),t?n(this,_).classList.add("drawer-trigger_active"):n(this,_).classList.remove("drawer-trigger_active")}}_=new WeakMap,E=new WeakMap,z=new WeakMap,K=new WeakMap;class ie extends ae{constructor({target:e,options:a}){super();b(this,d,void 0);b(this,F,void 0);b(this,x,void 0);b(this,X,void 0);b(this,U,void 0);this.handleDocumentClick=async r=>{var c;if(((c=r.__drawerTrigger)==null?void 0:c.owner)===this)return;const o=r.target;if(r.composedPath(),this.dom.panel.contains(o))return;const i=o==null?void 0:o.closest("[data-drawer]");i?i.getAttribute("data-drawer")===n(this,U)?this.handleUnderlayClick(r):this.handleOtherDrawerClick(r):this.handleOutsideClick(r)},this.handleKeydown=r=>{n(this,d).closeOnEsc&&r.key==="Escape"&&this.close()};const l=oe(a?[te,a]:[te]),v=Z(e);if(v===null)throw new Error("Drawer's root cannot be found");A(this,U,v.getAttribute("data-drawer"));const w=v.querySelector(_e);if(w===null)throw new Error(`Drawer's panel cannot be found. Alias: ${n(this,U)}`);this.dom={root:v,panel:w},this.setOptions(l),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 n(this,x)}get isModal(){return n(this,d).modal}set isModal(e){this.dom.root.classList[e?"add":"remove"]("drawer_modal")}get willLockScroll(){return n(this,d).lockPageScroll}set zIndex(e){this.dom.root.style.setProperty("--z-index",String(e)),A(this,F,e)}get zIndex(){return n(this,F)}async open(e){await ee(0),!n(this,x)&&(this.emit("beforeOpen",{drawer:this,trigger:e}),A(this,x,!0),this.dom.root.classList.add(n(this,d).openingClass),this.emit("open",{drawer:this,trigger:e}),typeof n(this,d).openAnimationDuration=="number"&&await ee(n(this,d).openAnimationDuration),this.dom.root.classList.remove(n(this,d).openingClass),this.dom.root.classList.add(n(this,d).openClass),this.emit("openAnimationEnd",{drawer:this,trigger:e}),this.focus(),this.addEventListeners())}async close(e){n(this,d).onCloseConfirm&&!n(this,d).onCloseConfirm(this,e)||(this.emit("beforeClose",{drawer:this,trigger:e}),this.removeEventListeners(),A(this,x,!1),this.dom.root.classList.remove(n(this,d).openClass),this.dom.root.classList.add(n(this,d).closingClass),this.emit("close",{drawer:this,trigger:e}),typeof n(this,d).closeAnimationDuration=="number"&&await ee(n(this,d).closeAnimationDuration),this.dom.root.classList.remove(n(this,d).closingClass),this.emit("closeAnimationEnd",{drawer:this,trigger:e}))}handleOtherDrawerClick(e){}handleOutsideClick(e){n(this,d).closeOnOutsideClick&&(typeof n(this,d).closeOnOutsideClick=="object"&&n(this,d).closeOnOutsideClick.hasOwnProperty("checkTarget")?n(this,d).closeOnOutsideClick.checkTarget(e.target)&&this.close():this.close())}handleUnderlayClick(e){n(this,d).closeOnOutsideClick&&this.close()}focus(){n(this,d).focusOnChild&&this.focusChild()||this.focusSelf()}focusSelf(){this.dom.panel.focus()}focusChild(){const e=this.dom.panel.querySelector(Le.join(","));return e?(e.focus(),!0):!1}setOptions(e){var a;e.hasOwnProperty("modal")&&((a=n(this,d))==null?void 0:a.modal)!==e.modal&&(this.isModal=e.modal),A(this,d,n(this,d)?oe([n(this,d),e]):e)}assignGroup(e){A(this,X,e)}}d=new WeakMap,F=new WeakMap,x=new WeakMap,X=new WeakMap,U=new WeakMap;class ke{constructor(){b(this,T,new Map)}lock(t,e){n(this,T).has(t)||n(this,T).set(t,new Set);const a=n(this,T).get(t);a.size===0&&t.classList.add("scroll-lock-by-drawer"),a.add(e)}unlock(t,e){const a=n(this,T).get(t);a==null||a.delete(e),(!a||a.size===0)&&t.classList.remove("scroll-lock-by-drawer")}}T=new WeakMap;const G=class G{constructor(t){b(this,P,void 0);b(this,L,void 0);b(this,k,void 0);b(this,N,void 0);b(this,j,void 0);A(this,L,[]),A(this,k,[]),A(this,j,new Map),this.onBeforeOpen=({drawer:l,trigger:v})=>{l.isModal?(n(this,j).set(l,n(this,L).length),n(this,L).push(l),l.zIndex=n(this,k).length+n(this,L).length):(n(this,j).set(l,n(this,k).length),n(this,k).push(l),l.zIndex=n(this,k).length,n(this,L).length>0&&n(this,L).forEach((w,r)=>w.zIndex=n(this,k).length+r+1)),l.willLockScroll&&this.lockScroll(l)},this.onCloseAnimationEnd=({drawer:l,trigger:v})=>{const w=l.isModal?n(this,L):n(this,k);for(delete w[n(this,j).get(l)];w.length&&!w.at(-1);)w.pop();n(this,j).delete(l),this.unlockScroll(l)};const e=Z(t);if(e===null)throw new Error("Drawer's group root cannot be found");A(this,P,e);const a=n(this,P).closest("[data-scrollable], html")||n(this,P).matches("[data-scrollable], html")&&n(this,P);if(a===null)throw new Error("Scrollable container for group root cannot be found");A(this,N,a)}add(t){t.on("beforeOpen",this.onBeforeOpen),t.on("closeAnimationEnd",this.onCloseAnimationEnd),t.assignGroup(this)}lockScroll(t){G.scrollLock.lock(n(this,N),t)}unlockScroll(t){G.scrollLock.unlock(n(this,N),t)}};P=new WeakMap,L=new WeakMap,k=new WeakMap,N=new WeakMap,j=new WeakMap,G.scrollLock=new ke;let B=G;const H=class H{constructor(){b(this,$,new Map);b(this,q,new Map);if(H.instance)return H.instance;H.instance=this}init(t=te){document.querySelectorAll(`[${J}]`).forEach(r=>{const o=r.getAttribute(J);typeof o=="string"&&n(this,q).set(o,new B(r))}),n(this,q).set("default",new B(document.documentElement)),document.querySelectorAll("[data-drawer]").forEach(r=>{var y;const o=r.getAttribute("data-drawer");if(typeof o!="string")return;const i=new ie({target:r,options:{...t,modal:r.matches('*:not([data-modal="false"])')||!r.matches("[data-modal]")&&t.modal}});n(this,$).set(o,i);const c=r.closest(`[${J}]`),h=c?c.getAttribute(J):"default";if(typeof h!="string")throw new Error("Group doesn't have alias set correctly");(y=n(this,q).get(h))==null||y.add(i)}),document.querySelectorAll("[data-drawer-open], [data-drawer-close], [data-drawer-toggle]").forEach(r=>{if(r.hasAttribute("data-drawer-open")){const o=r.getAttribute("data-drawer-open");v(r,o);const i=this.get(o);w(r,i,o),new Q({target:r,type:"open",owner:i})}else if(r.hasAttribute("data-drawer-close")){const o=r.getAttribute("data-drawer-close");v(r,o);const i=this.get(o);w(r,i,o),new Q({target:r,type:"close",owner:i})}else{const o=r.getAttribute("data-drawer-toggle");v(r,o);const i=this.get(o);w(r,i,o),new Q({target:r,type:"toggle",owner:i})}});function v(r,o){if(!o)throw new Error(`Drawer alias should be specified in the trigger attribute. Trigger elem: ${r}`)}function w(r,o,i){if(!o)throw new Error(`Drawer hasn't been found for the trigger elem: ${r}. Alias: ${i}`)}}open(t,{trigger:e,options:a}={}){var l;(l=this.get(t))==null||l.open(e)}close(t,{trigger:e,options:a}={}){var l;(l=this.get(t))==null||l.close(e)}get(t){return typeof t=="string"&&n(this,$).get(t)||null}on(t,e,a){var l;if(t)(l=this.get(t))==null||l.on(e,a);else for(const[v,w]of n(this,$))w.on(e,a)}};$=new WeakMap,q=new WeakMap;let W=H;typeof window<"u"&&(window.hasOwnProperty("app")||(window.app={}),window.app.drawers=new W),f.Drawer=ie,f.DrawersGroup=B,f.Trigger=Q,f.default=W,Object.defineProperties(f,{__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.1.18",
3
+ "version": "1.1.19",
4
4
  "description": "Drawers controller.",
5
5
  "files": [
6
6
  "dist"