vanilla-drawers 1.1.21 → 1.1.23

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.
@@ -1,62 +1,62 @@
1
- var X = (n, t, e) => {
1
+ var Z = (n, t, e) => {
2
2
  if (!t.has(n))
3
3
  throw TypeError("Cannot " + e);
4
4
  };
5
- var s = (n, t, e) => (X(n, t, "read from private field"), e ? e.call(n) : t.get(n)), m = (n, t, e) => {
5
+ var r = (n, t, e) => (Z(n, t, "read from private field"), e ? e.call(n) : t.get(n)), A = (n, t, e) => {
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, l) => (X(n, t, "write to private field"), l ? l.call(n, e) : t.set(n, e), e);
10
- function ne(n) {
9
+ }, O = (n, t, e, o) => (Z(n, t, "write to private field"), o ? o.call(n, e) : t.set(n, e), e);
10
+ function oe(n) {
11
11
  return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
12
12
  }
13
- var se = { exports: {} };
13
+ var ie = { exports: {} };
14
14
  (function(n) {
15
15
  var t = Object.prototype.hasOwnProperty, e = "~";
16
- function l() {
16
+ function o() {
17
17
  }
18
- Object.create && (l.prototype = /* @__PURE__ */ Object.create(null), new l().__proto__ || (e = !1));
19
- function a(o, i, c) {
20
- this.fn = o, this.context = i, this.once = c || !1;
18
+ Object.create && (o.prototype = /* @__PURE__ */ Object.create(null), new o().__proto__ || (e = !1));
19
+ function l(i, a, c) {
20
+ this.fn = i, this.context = a, this.once = c || !1;
21
21
  }
22
- function g(o, i, c, h, b) {
22
+ function g(i, a, c, h, y) {
23
23
  if (typeof c != "function")
24
24
  throw new TypeError("The listener must be a function");
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;
25
+ var v = new l(c, h || i, y), p = e ? e + a : a;
26
+ return i._events[p] ? i._events[p].fn ? i._events[p] = [i._events[p], v] : i._events[p].push(v) : (i._events[p] = v, i._eventsCount++), i;
27
27
  }
28
- function p(o, i) {
29
- --o._eventsCount === 0 ? o._events = new l() : delete o._events[i];
28
+ function w(i, a) {
29
+ --i._eventsCount === 0 ? i._events = new o() : delete i._events[a];
30
30
  }
31
- function r() {
32
- this._events = new l(), this._eventsCount = 0;
31
+ function s() {
32
+ this._events = new o(), this._eventsCount = 0;
33
33
  }
34
- r.prototype.eventNames = function() {
35
- var i = [], c, h;
34
+ s.prototype.eventNames = function() {
35
+ var a = [], c, h;
36
36
  if (this._eventsCount === 0)
37
- return i;
37
+ return a;
38
38
  for (h in c = this._events)
39
- t.call(c, h) && i.push(e ? h.slice(1) : h);
40
- return Object.getOwnPropertySymbols ? i.concat(Object.getOwnPropertySymbols(c)) : i;
41
- }, r.prototype.listeners = function(i) {
42
- var c = e ? e + i : i, h = this._events[c];
39
+ t.call(c, h) && a.push(e ? h.slice(1) : h);
40
+ return Object.getOwnPropertySymbols ? a.concat(Object.getOwnPropertySymbols(c)) : a;
41
+ }, s.prototype.listeners = function(a) {
42
+ var c = e ? e + a : a, h = this._events[c];
43
43
  if (!h)
44
44
  return [];
45
45
  if (h.fn)
46
46
  return [h.fn];
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
- }, r.prototype.listenerCount = function(i) {
51
- var c = e ? e + i : i, h = this._events[c];
47
+ for (var y = 0, v = h.length, p = new Array(v); y < v; y++)
48
+ p[y] = h[y].fn;
49
+ return p;
50
+ }, s.prototype.listenerCount = function(a) {
51
+ var c = e ? e + a : a, h = this._events[c];
52
52
  return h ? h.fn ? 1 : h.length : 0;
53
- }, r.prototype.emit = function(i, c, h, b, y, f) {
54
- var _ = e ? e + i : i;
55
- if (!this._events[_])
53
+ }, s.prototype.emit = function(a, c, h, y, v, p) {
54
+ var C = e ? e + a : a;
55
+ if (!this._events[C])
56
56
  return !1;
57
- var u = this._events[_], L = arguments.length, S, w;
57
+ var u = this._events[C], E = arguments.length, S, m;
58
58
  if (u.fn) {
59
- switch (u.once && this.removeListener(i, u.fn, void 0, !0), L) {
59
+ switch (u.once && this.removeListener(a, u.fn, void 0, !0), E) {
60
60
  case 1:
61
61
  return u.fn.call(u.context), !0;
62
62
  case 2:
@@ -64,156 +64,164 @@ var se = { exports: {} };
64
64
  case 3:
65
65
  return u.fn.call(u.context, c, h), !0;
66
66
  case 4:
67
- return u.fn.call(u.context, c, h, b), !0;
67
+ return u.fn.call(u.context, c, h, y), !0;
68
68
  case 5:
69
- return u.fn.call(u.context, c, h, b, y), !0;
69
+ return u.fn.call(u.context, c, h, y, v), !0;
70
70
  case 6:
71
- return u.fn.call(u.context, c, h, b, y, f), !0;
71
+ return u.fn.call(u.context, c, h, y, v, p), !0;
72
72
  }
73
- for (w = 1, S = new Array(L - 1); w < L; w++)
74
- S[w - 1] = arguments[w];
73
+ for (m = 1, S = new Array(E - 1); m < E; m++)
74
+ S[m - 1] = arguments[m];
75
75
  u.fn.apply(u.context, S);
76
76
  } else {
77
- var oe = u.length, N;
78
- for (w = 0; w < oe; w++)
79
- switch (u[w].once && this.removeListener(i, u[w].fn, void 0, !0), L) {
77
+ var he = u.length, G;
78
+ for (m = 0; m < he; m++)
79
+ switch (u[m].once && this.removeListener(a, u[m].fn, void 0, !0), E) {
80
80
  case 1:
81
- u[w].fn.call(u[w].context);
81
+ u[m].fn.call(u[m].context);
82
82
  break;
83
83
  case 2:
84
- u[w].fn.call(u[w].context, c);
84
+ u[m].fn.call(u[m].context, c);
85
85
  break;
86
86
  case 3:
87
- u[w].fn.call(u[w].context, c, h);
87
+ u[m].fn.call(u[m].context, c, h);
88
88
  break;
89
89
  case 4:
90
- u[w].fn.call(u[w].context, c, h, b);
90
+ u[m].fn.call(u[m].context, c, h, y);
91
91
  break;
92
92
  default:
93
93
  if (!S)
94
- for (N = 1, S = new Array(L - 1); N < L; N++)
95
- S[N - 1] = arguments[N];
96
- u[w].fn.apply(u[w].context, S);
94
+ for (G = 1, S = new Array(E - 1); G < E; G++)
95
+ S[G - 1] = arguments[G];
96
+ u[m].fn.apply(u[m].context, S);
97
97
  }
98
98
  }
99
99
  return !0;
100
- }, r.prototype.on = function(i, c, h) {
101
- return g(this, i, c, h, !1);
102
- }, r.prototype.once = function(i, c, h) {
103
- return g(this, i, c, h, !0);
104
- }, r.prototype.removeListener = function(i, c, h, b) {
105
- var y = e ? e + i : i;
106
- if (!this._events[y])
100
+ }, s.prototype.on = function(a, c, h) {
101
+ return g(this, a, c, h, !1);
102
+ }, s.prototype.once = function(a, c, h) {
103
+ return g(this, a, c, h, !0);
104
+ }, s.prototype.removeListener = function(a, c, h, y) {
105
+ var v = e ? e + a : a;
106
+ if (!this._events[v])
107
107
  return this;
108
108
  if (!c)
109
- return p(this, y), this;
110
- var f = this._events[y];
111
- if (f.fn)
112
- f.fn === c && (!b || f.once) && (!h || f.context === h) && p(this, y);
109
+ return w(this, v), this;
110
+ var p = this._events[v];
111
+ if (p.fn)
112
+ p.fn === c && (!y || p.once) && (!h || p.context === h) && w(this, v);
113
113
  else {
114
- for (var _ = 0, u = [], L = f.length; _ < L; _++)
115
- (f[_].fn !== c || b && !f[_].once || h && f[_].context !== h) && u.push(f[_]);
116
- u.length ? this._events[y] = u.length === 1 ? u[0] : u : p(this, y);
114
+ for (var C = 0, u = [], E = p.length; C < E; C++)
115
+ (p[C].fn !== c || y && !p[C].once || h && p[C].context !== h) && u.push(p[C]);
116
+ u.length ? this._events[v] = u.length === 1 ? u[0] : u : w(this, v);
117
117
  }
118
118
  return this;
119
- }, r.prototype.removeAllListeners = function(i) {
119
+ }, s.prototype.removeAllListeners = function(a) {
120
120
  var c;
121
- return i ? (c = e ? e + i : i, this._events[c] && p(this, c)) : (this._events = new l(), this._eventsCount = 0), this;
122
- }, r.prototype.off = r.prototype.removeListener, r.prototype.addListener = r.prototype.on, r.prefixed = e, r.EventEmitter = r, n.exports = r;
123
- })(se);
124
- var ie = se.exports;
125
- const ae = /* @__PURE__ */ ne(ie);
126
- var le = function(t) {
127
- return ce(t) && !he(t);
121
+ return a ? (c = e ? e + a : a, this._events[c] && w(this, c)) : (this._events = new o(), this._eventsCount = 0), this;
122
+ }, s.prototype.off = s.prototype.removeListener, s.prototype.addListener = s.prototype.on, s.prefixed = e, s.EventEmitter = s, n.exports = s;
123
+ })(ie);
124
+ var ue = ie.exports;
125
+ const de = /* @__PURE__ */ oe(ue);
126
+ var fe = function(t) {
127
+ return pe(t) && !we(t);
128
128
  };
129
- function ce(n) {
129
+ function pe(n) {
130
130
  return !!n && typeof n == "object";
131
131
  }
132
- function he(n) {
132
+ function we(n) {
133
133
  var t = Object.prototype.toString.call(n);
134
- return t === "[object RegExp]" || t === "[object Date]" || fe(n);
134
+ return t === "[object RegExp]" || t === "[object Date]" || ge(n);
135
135
  }
136
- var ue = typeof Symbol == "function" && Symbol.for, de = ue ? Symbol.for("react.element") : 60103;
137
- function fe(n) {
138
- return n.$$typeof === de;
136
+ var me = typeof Symbol == "function" && Symbol.for, ye = me ? Symbol.for("react.element") : 60103;
137
+ function ge(n) {
138
+ return n.$$typeof === ye;
139
139
  }
140
- function pe(n) {
140
+ function ve(n) {
141
141
  return Array.isArray(n) ? [] : {};
142
142
  }
143
- function R(n, t) {
144
- return t.clone !== !1 && t.isMergeableObject(n) ? U(pe(n), n, t) : n;
143
+ function q(n, t) {
144
+ return t.clone !== !1 && t.isMergeableObject(n) ? z(ve(n), n, t) : n;
145
145
  }
146
- function we(n, t, e) {
147
- return n.concat(t).map(function(l) {
148
- return R(l, e);
146
+ function be(n, t, e) {
147
+ return n.concat(t).map(function(o) {
148
+ return q(o, e);
149
149
  });
150
150
  }
151
- function me(n, t) {
151
+ function Oe(n, t) {
152
152
  if (!t.customMerge)
153
- return U;
153
+ return z;
154
154
  var e = t.customMerge(n);
155
- return typeof e == "function" ? e : U;
155
+ return typeof e == "function" ? e : z;
156
156
  }
157
- function be(n) {
157
+ function Ae(n) {
158
158
  return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(n).filter(function(t) {
159
159
  return Object.propertyIsEnumerable.call(n, t);
160
160
  }) : [];
161
161
  }
162
- function Z(n) {
163
- return Object.keys(n).concat(be(n));
162
+ function ee(n) {
163
+ return Object.keys(n).concat(Ae(n));
164
164
  }
165
- function re(n, t) {
165
+ function ae(n, t) {
166
166
  try {
167
167
  return t in n;
168
168
  } catch {
169
169
  return !1;
170
170
  }
171
171
  }
172
- function ge(n, t) {
173
- return re(n, t) && !(Object.hasOwnProperty.call(n, t) && Object.propertyIsEnumerable.call(n, t));
172
+ function _e(n, t) {
173
+ return ae(n, t) && !(Object.hasOwnProperty.call(n, t) && Object.propertyIsEnumerable.call(n, t));
174
174
  }
175
- function ye(n, t, e) {
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;
175
+ function Ce(n, t, e) {
176
+ var o = {};
177
+ return e.isMergeableObject(n) && ee(n).forEach(function(l) {
178
+ o[l] = q(n[l], e);
179
+ }), ee(t).forEach(function(l) {
180
+ _e(n, l) || (ae(n, l) && e.isMergeableObject(t[l]) ? o[l] = Oe(l, e)(n[l], t[l], e) : o[l] = q(t[l], e));
181
+ }), o;
182
182
  }
183
- function U(n, 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);
183
+ function z(n, t, e) {
184
+ e = e || {}, e.arrayMerge = e.arrayMerge || be, e.isMergeableObject = e.isMergeableObject || fe, e.cloneUnlessOtherwiseSpecified = q;
185
+ var o = Array.isArray(t), l = Array.isArray(n), g = o === l;
186
+ return g ? o ? e.arrayMerge(n, t, e) : Ce(n, t, e) : q(t, e);
187
187
  }
188
- U.all = function(t, e) {
188
+ z.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(l, a) {
192
- return U(l, a, e);
191
+ return t.reduce(function(o, l) {
192
+ return z(o, l, e);
193
193
  }, {});
194
194
  };
195
- var ve = U, Oe = ve;
196
- const Ae = /* @__PURE__ */ ne(Oe);
195
+ var Ee = z, ke = Ee;
196
+ const Le = /* @__PURE__ */ oe(ke);
197
197
  /*!
198
198
  * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
199
199
  *
200
200
  * Copyright (c) 2014-2017, Jon Schlinkert.
201
201
  * Released under the MIT License.
202
202
  */
203
- function ee(n) {
203
+ function te(n) {
204
204
  return Object.prototype.toString.call(n) === "[object Object]";
205
205
  }
206
- function Ee(n) {
206
+ function Se(n) {
207
207
  var t, e;
208
- return ee(n) === !1 ? !1 : (t = n.constructor, t === void 0 ? !0 : (e = t.prototype, !(ee(e) === !1 || e.hasOwnProperty("isPrototypeOf") === !1)));
208
+ return te(n) === !1 ? !1 : (t = n.constructor, t === void 0 ? !0 : (e = t.prototype, !(te(e) === !1 || e.hasOwnProperty("isPrototypeOf") === !1)));
209
209
  }
210
- function W(n) {
210
+ function X(n) {
211
211
  return n instanceof Element ? n : document.querySelector(n);
212
212
  }
213
213
  async function V(n) {
214
214
  return await new Promise((t) => setTimeout(t, n));
215
215
  }
216
- const Ce = '[data-elem="drawer.panel"]', F = "data-drawers-group", _e = [
216
+ var le = (n, t, e) => {
217
+ if (!t.has(n))
218
+ throw TypeError("Cannot " + e);
219
+ }, f = (n, t, e) => (le(n, t, "read from private field"), e ? e.call(n) : t.get(n)), M = (n, t, e) => {
220
+ if (t.has(n))
221
+ throw TypeError("Cannot add the same private member more than once");
222
+ t instanceof WeakSet ? t.add(n) : t.set(n, e);
223
+ }, ne = (n, t, e, o) => (le(n, t, "write to private field"), o ? o.call(n, e) : t.set(n, e), e), T, k, L, N, P, W, $;
224
+ const Me = '[data-elem="drawer.panel"]', K = "data-drawers-group", De = [
217
225
  "a[href]",
218
226
  "area[href]",
219
227
  'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',
@@ -243,78 +251,81 @@ const Ce = '[data-elem="drawer.panel"]', F = "data-drawers-group", _e = [
243
251
  openingClass: "drawer_opening",
244
252
  openAnimationDuration: 0,
245
253
  closeAnimationDuration: 0,
246
- lockPageScroll: !0
254
+ lockPageScroll: !0,
255
+ lockScroll: {
256
+ unlockDelay: 300
257
+ }
247
258
  };
248
- function te(n) {
249
- return Ae.all(n, {
250
- isMergeableObject: Ee
259
+ function re(n) {
260
+ return Le.all(n, {
261
+ isMergeableObject: Se
251
262
  });
252
263
  }
253
- var A, O, P, B;
264
+ var _, b, I, R;
254
265
  class Y {
255
- constructor({ target: t, type: e, owner: l }) {
256
- m(this, A, void 0);
257
- m(this, O, void 0);
258
- m(this, P, void 0);
259
- m(this, B, !1);
260
- const a = W(t);
261
- if (!a)
262
- throw new Error("Trigger element cannot be found");
266
+ constructor({ target: t, type: e, owner: o }) {
267
+ A(this, _, void 0);
268
+ A(this, b, void 0);
269
+ A(this, I, void 0);
270
+ A(this, R, !1);
271
+ const l = X(t);
263
272
  if (!l)
273
+ throw new Error("Trigger element cannot be found");
274
+ if (!o)
264
275
  throw new Error("Owning drawer instance hasn't been provided");
265
- v(this, A, a), v(this, O, l), v(this, P, e), this.init();
276
+ O(this, _, l), O(this, b, o), O(this, I, e), this.init();
266
277
  }
267
278
  // Accessors
268
279
  get isActive() {
269
- return s(this, B);
280
+ return r(this, R);
270
281
  }
271
282
  get owner() {
272
- return s(this, O);
283
+ return r(this, b);
273
284
  }
274
285
  // Methods
275
286
  init() {
276
- s(this, A).addEventListener("click", (t) => this.clickHandler(t)), s(this, O).on("open", () => this.setActive(!0)), s(this, O).on("close", () => this.setActive(!1));
287
+ r(this, _).addEventListener("click", (t) => this.clickHandler(t)), r(this, b).on("open", () => this.setActive(!0)), r(this, b).on("close", () => this.setActive(!1));
277
288
  }
278
289
  clickHandler(t) {
279
- t.__drawerTrigger = this, s(this, P) === "open" ? s(this, O).isOpen || s(this, O).open(s(this, A)) : s(this, P) === "close" ? s(this, O).isOpen && s(this, O).close(s(this, A)) : s(this, O).isOpen ? s(this, O).close(s(this, A)) : s(this, O).open(s(this, A));
290
+ t.__drawerTrigger = this, r(this, I) === "open" ? r(this, b).isOpen || r(this, b).open(r(this, _)) : r(this, I) === "close" ? r(this, b).isOpen && r(this, b).close(r(this, _)) : r(this, b).isOpen ? r(this, b).close(r(this, _)) : r(this, b).open(r(this, _));
280
291
  }
281
292
  setActive(t) {
282
- v(this, B, t), t ? s(this, A).classList.add("drawer-trigger_active") : s(this, A).classList.remove("drawer-trigger_active");
293
+ O(this, R, t), t ? r(this, _).classList.add("drawer-trigger_active") : r(this, _).classList.remove("drawer-trigger_active");
283
294
  }
284
295
  }
285
- A = new WeakMap(), O = new WeakMap(), P = new WeakMap(), B = new WeakMap();
286
- var d, K, j, H, T;
287
- class Le extends ae {
288
- constructor({ target: e, options: l }) {
296
+ _ = new WeakMap(), b = new WeakMap(), I = new WeakMap(), R = new WeakMap();
297
+ var d, B, D, H, U;
298
+ class xe extends de {
299
+ constructor({ target: e, options: o }) {
289
300
  super();
290
- m(this, d, void 0);
291
- m(this, K, void 0);
292
- m(this, j, void 0);
293
- m(this, H, void 0);
294
- m(this, T, void 0);
295
- this.handleDocumentClick = async (r) => {
301
+ A(this, d, void 0);
302
+ A(this, B, void 0);
303
+ A(this, D, void 0);
304
+ A(this, H, void 0);
305
+ A(this, U, void 0);
306
+ this.handleDocumentClick = async (s) => {
296
307
  var c;
297
- if (((c = r.__drawerTrigger) == null ? void 0 : c.owner) === this)
308
+ if (((c = s.__drawerTrigger) == null ? void 0 : c.owner) === this)
298
309
  return;
299
- const o = r.target;
300
- if (r.composedPath(), this.dom.panel.contains(o))
310
+ const i = s.target;
311
+ if (s.composedPath(), this.dom.panel.contains(i))
301
312
  return;
302
- const i = o == null ? void 0 : o.closest("[data-drawer]");
303
- i ? i.getAttribute("data-drawer") === s(this, T) ? this.handleUnderlayClick(r) : this.handleOtherDrawerClick(r) : this.handleOutsideClick(r);
304
- }, this.handleKeydown = (r) => {
305
- s(this, d).closeOnEsc && r.key === "Escape" && this.close();
313
+ const a = i == null ? void 0 : i.closest("[data-drawer]");
314
+ a ? a.getAttribute("data-drawer") === r(this, U) ? this.handleUnderlayClick(s) : this.handleOtherDrawerClick(s) : this.handleOutsideClick(s);
315
+ }, this.handleKeydown = (s) => {
316
+ r(this, d).closeOnEsc && s.key === "Escape" && this.close();
306
317
  };
307
- const a = te(l ? [J, l] : [J]), g = W(e);
318
+ const l = re(o ? [J, o] : [J]), g = X(e);
308
319
  if (g === null)
309
320
  throw new Error("Drawer's root cannot be found");
310
- v(this, T, g.getAttribute("data-drawer"));
311
- const p = g.querySelector(Ce);
312
- if (p === null)
313
- throw new Error(`Drawer's panel cannot be found. Alias: ${s(this, T)}`);
321
+ O(this, U, g.getAttribute("data-drawer"));
322
+ const w = g.querySelector(Me);
323
+ if (w === null)
324
+ throw new Error(`Drawer's panel cannot be found. Alias: ${r(this, U)}`);
314
325
  this.dom = {
315
326
  root: g,
316
- panel: p
317
- }, this.setOptions(a), this.dom.panel.setAttribute("tabindex", "-1"), this.dom.root.classList.add("drawer_initialized");
327
+ panel: w
328
+ }, this.setOptions(l), this.dom.panel.setAttribute("tabindex", "-1"), this.dom.root.classList.add("drawer_initialized");
318
329
  }
319
330
  addEventListeners() {
320
331
  this.dom.root.addEventListener("keydown", this.handleKeydown), document.addEventListener("click", this.handleDocumentClick);
@@ -322,189 +333,191 @@ class Le extends ae {
322
333
  removeEventListeners() {
323
334
  this.dom.root.removeEventListener("keydown", this.handleKeydown), document.removeEventListener("click", this.handleDocumentClick);
324
335
  }
336
+ get scrollUnlockDelay() {
337
+ var e;
338
+ return ((e = r(this, d).lockScroll) == null ? void 0 : e.unlockDelay) || 0;
339
+ }
325
340
  // Accessors
326
341
  get isOpen() {
327
- return s(this, j);
342
+ return r(this, D);
328
343
  }
329
344
  get isModal() {
330
- return s(this, d).modal;
345
+ return r(this, d).modal;
331
346
  }
332
347
  set isModal(e) {
333
348
  this.dom.root.classList[e ? "add" : "remove"]("drawer_modal");
334
349
  }
335
350
  get willLockScroll() {
336
- return s(this, d).lockPageScroll;
351
+ return r(this, d).lockPageScroll;
337
352
  }
338
353
  set zIndex(e) {
339
- this.dom.root.style.setProperty("--z-index", String(e)), v(this, K, e);
354
+ this.dom.root.style.setProperty("--z-index", String(e)), O(this, B, e);
340
355
  }
341
356
  get zIndex() {
342
- return s(this, K);
357
+ return r(this, B);
343
358
  }
344
359
  // Methods
345
360
  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, 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());
361
+ await V(0), !r(this, D) && (this.emit("beforeOpen", { drawer: this, trigger: e }), O(this, D, !0), this.dom.root.classList.add(r(this, d).openingClass), this.emit("open", { drawer: this, trigger: e }), typeof r(this, d).openAnimationDuration == "number" && await V(r(this, d).openAnimationDuration), this.dom.root.classList.remove(r(this, d).openingClass), this.dom.root.classList.add(r(this, d).openClass), this.emit("openAnimationEnd", { drawer: this, trigger: e }), this.focus(), this.addEventListeners());
347
362
  }
348
363
  async close(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 }));
364
+ r(this, d).onCloseConfirm && !r(this, d).onCloseConfirm(this, e) || (this.emit("beforeClose", { drawer: this, trigger: e }), this.removeEventListeners(), O(this, D, !1), this.dom.root.classList.remove(r(this, d).openClass), this.dom.root.classList.add(r(this, d).closingClass), this.emit("close", { drawer: this, trigger: e }), typeof r(this, d).closeAnimationDuration == "number" && await V(r(this, d).closeAnimationDuration), this.dom.root.classList.remove(r(this, d).closingClass), this.emit("closeAnimationEnd", { drawer: this, trigger: e }));
350
365
  }
351
366
  handleOtherDrawerClick(e) {
352
367
  }
353
368
  handleOutsideClick(e) {
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());
369
+ r(this, d).closeOnOutsideClick && (typeof r(this, d).closeOnOutsideClick == "object" && r(this, d).closeOnOutsideClick.hasOwnProperty("checkTarget") ? r(this, d).closeOnOutsideClick.checkTarget(e.target) && this.close() : this.close());
355
370
  }
356
371
  handleUnderlayClick(e) {
357
- s(this, d).closeOnOutsideClick && this.close();
372
+ r(this, d).closeOnOutsideClick && this.close();
358
373
  }
359
374
  focus() {
360
- s(this, d).focusOnChild && this.focusChild() || this.focusSelf();
375
+ r(this, d).focusOnChild && this.focusChild() || this.focusSelf();
361
376
  }
362
377
  focusSelf() {
363
378
  this.dom.panel.focus();
364
379
  }
365
380
  focusChild() {
366
- const e = this.dom.panel.querySelector(_e.join(","));
381
+ const e = this.dom.panel.querySelector(De.join(","));
367
382
  return e ? (e.focus(), !0) : !1;
368
383
  }
369
384
  setOptions(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);
385
+ var o;
386
+ e.hasOwnProperty("modal") && ((o = r(this, d)) == null ? void 0 : o.modal) !== e.modal && (this.isModal = e.modal), O(this, d, r(this, d) ? re([r(this, d), e]) : e);
372
387
  }
373
388
  assignGroup(e) {
374
- v(this, H, e);
389
+ O(this, H, e);
375
390
  }
376
391
  }
377
- d = new WeakMap(), K = new WeakMap(), j = new WeakMap(), H = new WeakMap(), T = new WeakMap();
378
- var M;
379
- class ke {
392
+ d = new WeakMap(), B = new WeakMap(), D = new WeakMap(), H = new WeakMap(), U = new WeakMap();
393
+ var x, j;
394
+ class je {
380
395
  constructor() {
381
- m(this, M, /* @__PURE__ */ new Map());
396
+ A(this, x, null);
397
+ A(this, j, /* @__PURE__ */ new Map());
382
398
  }
383
399
  lock(t, e) {
384
- s(this, M).has(t) || s(this, M).set(t, /* @__PURE__ */ new Set());
385
- const l = s(this, M).get(t);
386
- l.size === 0 && t.classList.add("scroll-lock-by-drawer"), l.add(e);
400
+ r(this, x) !== null && (clearTimeout(r(this, x)), O(this, x, null)), r(this, j).has(t) || r(this, j).set(t, /* @__PURE__ */ new Set());
401
+ const o = r(this, j).get(t);
402
+ o.size === 0 && t.classList.add("scroll-lock-by-drawer"), o.add(e);
387
403
  }
388
404
  unlock(t, e) {
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");
405
+ const o = r(this, j).get(t);
406
+ o == null || o.delete(e), (!o || o.size === 0) && O(this, x, setTimeout(() => t.classList.remove("scroll-lock-by-drawer"), e.scrollUnlockDelay));
391
407
  }
392
408
  }
393
- M = new WeakMap();
394
- var x, E, C, D, k;
395
- const $ = class $ {
409
+ x = new WeakMap(), j = new WeakMap();
410
+ const ce = class Q {
396
411
  constructor(t) {
397
- m(this, x, void 0);
398
- m(this, E, void 0);
399
- m(this, C, void 0);
400
- m(this, D, void 0);
401
- m(this, k, void 0);
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
- p.pop();
408
- s(this, k).delete(a), this.unlockScroll(a);
412
+ M(this, T, void 0), M(this, k, []), M(this, L, []), M(this, N, void 0), M(this, P, /* @__PURE__ */ new Map()), this.onBeforeOpen = ({ drawer: l, trigger: g }) => {
413
+ l.isModal ? (f(this, P).set(l, f(this, k).length), f(this, k).push(l), l.zIndex = f(this, L).length + f(this, k).length) : (f(this, P).set(l, f(this, L).length), f(this, L).push(l), l.zIndex = f(this, L).length, f(this, k).length > 0 && f(this, k).forEach((w, s) => w.zIndex = f(this, L).length + s + 1)), l.willLockScroll && this.lockScroll(l);
414
+ }, this.onCloseAnimationEnd = ({ drawer: l, trigger: g }) => {
415
+ const w = l.isModal ? f(this, k) : f(this, L);
416
+ for (delete w[f(this, P).get(l)]; w.length && !w.at(-1); )
417
+ w.pop();
418
+ f(this, P).delete(l), this.unlockScroll(l);
409
419
  };
410
- const e = W(t);
420
+ const e = X(t);
411
421
  if (e === null)
412
422
  throw new Error("Drawer's group root cannot be found");
413
- v(this, x, e);
414
- const l = s(this, x).closest("[data-scrollable], html") || s(this, x).matches("[data-scrollable], html") && s(this, x);
415
- if (l === null)
423
+ ne(this, T, e);
424
+ const o = f(this, T).closest("[data-scrollable], html") || f(this, T).matches("[data-scrollable], html") && f(this, T);
425
+ if (o === null)
416
426
  throw new Error("Scrollable container for group root cannot be found");
417
- v(this, D, l);
427
+ ne(this, N, o);
418
428
  }
419
429
  add(t) {
420
430
  t.on("beforeOpen", this.onBeforeOpen), t.on("closeAnimationEnd", this.onCloseAnimationEnd), t.assignGroup(this);
421
431
  }
422
432
  lockScroll(t) {
423
- $.scrollLock.lock(s(this, D), t);
433
+ Q.scrollLock.lock(f(this, N), t);
424
434
  }
425
435
  unlockScroll(t) {
426
- $.scrollLock.unlock(s(this, D), t);
436
+ Q.scrollLock.unlock(f(this, N), t);
427
437
  }
428
438
  };
429
- x = new WeakMap(), E = new WeakMap(), C = new WeakMap(), D = new WeakMap(), k = new WeakMap(), $.scrollLock = new ke();
430
- let G = $;
431
- var I, z;
432
- const q = class q {
439
+ T = /* @__PURE__ */ new WeakMap();
440
+ k = /* @__PURE__ */ new WeakMap();
441
+ L = /* @__PURE__ */ new WeakMap();
442
+ N = /* @__PURE__ */ new WeakMap();
443
+ P = /* @__PURE__ */ new WeakMap();
444
+ ce.scrollLock = new je();
445
+ let se = ce;
446
+ const Te = class F {
433
447
  constructor() {
434
- m(this, I, /* @__PURE__ */ new Map());
435
- m(this, z, /* @__PURE__ */ new Map());
436
- if (q.instance)
437
- return q.instance;
438
- q.instance = this;
448
+ if (M(this, W, /* @__PURE__ */ new Map()), M(this, $, /* @__PURE__ */ new Map()), F.instance)
449
+ return F.instance;
450
+ F.instance = this;
439
451
  }
440
452
  init(t = J) {
441
- document.querySelectorAll(`[${F}]`).forEach((r) => {
442
- const o = r.getAttribute(F);
443
- typeof o == "string" && s(this, z).set(o, new G(r));
444
- }), s(this, z).set("default", new G(document.documentElement)), document.querySelectorAll("[data-drawer]").forEach((r) => {
445
- var b;
446
- const o = r.getAttribute("data-drawer");
447
- if (typeof o != "string")
453
+ document.querySelectorAll(`[${K}]`).forEach((s) => {
454
+ const i = s.getAttribute(K);
455
+ typeof i == "string" && f(this, $).set(i, new se(s));
456
+ }), f(this, $).set("default", new se(document.documentElement)), document.querySelectorAll("[data-drawer]").forEach((s) => {
457
+ var y;
458
+ const i = s.getAttribute("data-drawer");
459
+ if (typeof i != "string")
448
460
  return;
449
- const i = new Le({ target: r, options: { ...t, modal: r.matches("[data-modal]") ? r.matches(':not([data-modal="false"]') : t.modal } });
450
- s(this, I).set(o, i);
451
- const c = r.closest(`[${F}]`), h = c ? c.getAttribute(F) : "default";
461
+ const a = new xe({ target: s, options: { ...t, modal: s.matches("[data-modal]") ? s.matches(':not([data-modal="false"]') : t.modal } });
462
+ f(this, W).set(i, a);
463
+ const c = s.closest(`[${K}]`), h = c ? c.getAttribute(K) : "default";
452
464
  if (typeof h != "string")
453
465
  throw new Error("Group doesn't have alias set correctly");
454
- (b = s(this, z).get(h)) == null || b.add(i);
455
- }), document.querySelectorAll("[data-drawer-open], [data-drawer-close], [data-drawer-toggle]").forEach((r) => {
456
- if (r.hasAttribute("data-drawer-open")) {
457
- const o = r.getAttribute("data-drawer-open");
458
- g(r, o);
459
- const i = this.get(o);
460
- p(r, i, o), new Y({ target: r, type: "open", owner: i });
461
- } else if (r.hasAttribute("data-drawer-close")) {
462
- const o = r.getAttribute("data-drawer-close");
463
- g(r, o);
464
- const i = this.get(o);
465
- p(r, i, o), new Y({ target: r, type: "close", owner: i });
466
+ (y = f(this, $).get(h)) == null || y.add(a);
467
+ }), document.querySelectorAll("[data-drawer-open], [data-drawer-close], [data-drawer-toggle]").forEach((s) => {
468
+ if (s.hasAttribute("data-drawer-open")) {
469
+ const i = s.getAttribute("data-drawer-open");
470
+ g(s, i);
471
+ const a = this.get(i);
472
+ w(s, a, i), new Y({ target: s, type: "open", owner: a });
473
+ } else if (s.hasAttribute("data-drawer-close")) {
474
+ const i = s.getAttribute("data-drawer-close");
475
+ g(s, i);
476
+ const a = this.get(i);
477
+ w(s, a, i), new Y({ target: s, type: "close", owner: a });
466
478
  } else {
467
- const o = r.getAttribute("data-drawer-toggle");
468
- g(r, o);
469
- const i = this.get(o);
470
- p(r, i, o), new Y({ target: r, type: "toggle", owner: i });
479
+ const i = s.getAttribute("data-drawer-toggle");
480
+ g(s, i);
481
+ const a = this.get(i);
482
+ w(s, a, i), new Y({ target: s, type: "toggle", owner: a });
471
483
  }
472
484
  });
473
- function g(r, o) {
474
- if (!o)
475
- throw new Error(`Drawer alias should be specified in the trigger attribute. Trigger elem: ${r}`);
485
+ function g(s, i) {
486
+ if (!i)
487
+ throw new Error(`Drawer alias should be specified in the trigger attribute. Trigger elem: ${s}`);
476
488
  }
477
- function p(r, o, i) {
478
- if (!o)
479
- throw new Error(`Drawer hasn't been found for the trigger elem: ${r}. Alias: ${i}`);
489
+ function w(s, i, a) {
490
+ if (!i)
491
+ throw new Error(`Drawer hasn't been found for the trigger elem: ${s}. Alias: ${a}`);
480
492
  }
481
493
  }
482
- open(t, { trigger: e, options: l } = {}) {
483
- var a;
484
- (a = this.get(t)) == null || a.open(e);
494
+ open(t, { trigger: e, options: o } = {}) {
495
+ var l;
496
+ (l = this.get(t)) == null || l.open(e);
485
497
  }
486
- close(t, { trigger: e, options: l } = {}) {
487
- var a;
488
- (a = this.get(t)) == null || a.close(e);
498
+ close(t, { trigger: e, options: o } = {}) {
499
+ var l;
500
+ (l = this.get(t)) == null || l.close(e);
489
501
  }
490
502
  get(t) {
491
- return typeof t == "string" && s(this, I).get(t) || null;
503
+ return typeof t == "string" && f(this, W).get(t) || null;
492
504
  }
493
- on(t, e, l) {
494
- var a;
505
+ on(t, e, o) {
506
+ var l;
495
507
  if (t)
496
- (a = this.get(t)) == null || a.on(e, l);
508
+ (l = this.get(t)) == null || l.on(e, o);
497
509
  else
498
- for (const [g, p] of s(this, I))
499
- p.on(e, l);
510
+ for (const [g, w] of f(this, W))
511
+ w.on(e, o);
500
512
  }
501
513
  };
502
- I = new WeakMap(), z = new WeakMap();
503
- let Q = q;
504
- typeof window < "u" && (window.hasOwnProperty("app") || (window.app = {}), window.app.drawers = new Q());
514
+ W = /* @__PURE__ */ new WeakMap();
515
+ $ = /* @__PURE__ */ new WeakMap();
516
+ let Pe = Te;
517
+ typeof window < "u" && (window.hasOwnProperty("app") || (window.app = {}), window.app.drawers = new Pe());
505
518
  export {
506
- Le as Drawer,
507
- G as DrawersGroup,
519
+ xe as Drawer,
520
+ se as DrawersGroup,
508
521
  Y as Trigger,
509
- Q as default
522
+ Pe as default
510
523
  };
@@ -1,6 +1,6 @@
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);/*!
1
+ var fe=(p,g,A)=>{if(!g.has(p))throw TypeError("Cannot "+A)};var r=(p,g,A)=>(fe(p,g,"read from private field"),A?A.call(p):g.get(p)),E=(p,g,A)=>{if(g.has(p))throw TypeError("Cannot add the same private member more than once");g instanceof WeakSet?g.add(p):g.set(p,A)},C=(p,g,A,$)=>(fe(p,g,"write to private field"),$?$.call(p,A):g.set(p,A),A);(function(p,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(p=typeof globalThis<"u"?globalThis:p||self,g(p.Drawers={}))})(this,function(p){var k,_,N,F,d,H,T,Q,W,x,P;"use strict";const g="";function A(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var $={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function l(){}Object.create&&(l.prototype=Object.create(null),new l().__proto__||(e=!1));function a(o,i,c){this.fn=o,this.context=i,this.once=c||!1}function b(o,i,c,h,v){if(typeof c!="function")throw new TypeError("The listener must be a function");var O=new a(c,h||o,v),w=e?e+i:i;return o._events[w]?o._events[w].fn?o._events[w]=[o._events[w],O]:o._events[w].push(O):(o._events[w]=O,o._eventsCount++),o}function m(o,i){--o._eventsCount===0?o._events=new l:delete o._events[i]}function s(){this._events=new l,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 v=0,O=h.length,w=new Array(O);v<O;v++)w[v]=h[v].fn;return w},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,v,O,w){var S=e?e+i:i;if(!this._events[S])return!1;var u=this._events[S],D=arguments.length,I,y;if(u.fn){switch(u.once&&this.removeListener(i,u.fn,void 0,!0),D){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,v),!0;case 5:return u.fn.call(u.context,c,h,v,O),!0;case 6:return u.fn.call(u.context,c,h,v,O,w),!0}for(y=1,I=new Array(D-1);y<D;y++)I[y-1]=arguments[y];u.fn.apply(u.context,I)}else{var Ue=u.length,V;for(y=0;y<Ue;y++)switch(u[y].once&&this.removeListener(i,u[y].fn,void 0,!0),D){case 1:u[y].fn.call(u[y].context);break;case 2:u[y].fn.call(u[y].context,c);break;case 3:u[y].fn.call(u[y].context,c,h);break;case 4:u[y].fn.call(u[y].context,c,h,v);break;default:if(!I)for(V=1,I=new Array(D-1);V<D;V++)I[V-1]=arguments[V];u[y].fn.apply(u[y].context,I)}}return!0},s.prototype.on=function(i,c,h){return b(this,i,c,h,!1)},s.prototype.once=function(i,c,h){return b(this,i,c,h,!0)},s.prototype.removeListener=function(i,c,h,v){var O=e?e+i:i;if(!this._events[O])return this;if(!c)return m(this,O),this;var w=this._events[O];if(w.fn)w.fn===c&&(!v||w.once)&&(!h||w.context===h)&&m(this,O);else{for(var S=0,u=[],D=w.length;S<D;S++)(w[S].fn!==c||v&&!w[S].once||h&&w[S].context!==h)&&u.push(w[S]);u.length?this._events[O]=u.length===1?u[0]:u:m(this,O)}return this},s.prototype.removeAllListeners=function(i){var c;return i?(c=e?e+i:i,this._events[c]&&m(this,c)):(this._events=new l,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=e,s.EventEmitter=s,n.exports=s})($);var pe=$.exports;const we=A(pe);var me=function(t){return ye(t)&&!ge(t)};function ye(n){return!!n&&typeof n=="object"}function ge(n){var t=Object.prototype.toString.call(n);return t==="[object RegExp]"||t==="[object Date]"||Oe(n)}var ve=typeof Symbol=="function"&&Symbol.for,be=ve?Symbol.for("react.element"):60103;function Oe(n){return n.$$typeof===be}function _e(n){return Array.isArray(n)?[]:{}}function q(n,t){return t.clone!==!1&&t.isMergeableObject(n)?U(_e(n),n,t):n}function Ae(n,t,e){return n.concat(t).map(function(l){return q(l,e)})}function Ce(n,t){if(!t.customMerge)return U;var e=t.customMerge(n);return typeof e=="function"?e:U}function Ee(n){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(n).filter(function(t){return Object.propertyIsEnumerable.call(n,t)}):[]}function se(n){return Object.keys(n).concat(Ee(n))}function oe(n,t){try{return t in n}catch{return!1}}function ke(n,t){return oe(n,t)&&!(Object.hasOwnProperty.call(n,t)&&Object.propertyIsEnumerable.call(n,t))}function Se(n,t,e){var l={};return e.isMergeableObject(n)&&se(n).forEach(function(a){l[a]=q(n[a],e)}),se(t).forEach(function(a){ke(n,a)||(oe(n,a)&&e.isMergeableObject(t[a])?l[a]=Ce(a,e)(n[a],t[a],e):l[a]=q(t[a],e))}),l}function U(n,t,e){e=e||{},e.arrayMerge=e.arrayMerge||Ae,e.isMergeableObject=e.isMergeableObject||me,e.cloneUnlessOtherwiseSpecified=q;var l=Array.isArray(t),a=Array.isArray(n),b=l===a;return b?l?e.arrayMerge(n,t,e):Se(n,t,e):q(t,e)}U.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(l,a){return U(l,a,e)},{})};var Le=U,Me=Le;const De=A(Me);/*!
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 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("[data-modal]")?r.matches(':not([data-modal="false"]'):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"}})});
6
+ */function ie(n){return Object.prototype.toString.call(n)==="[object Object]"}function je(n){var t,e;return ie(n)===!1?!1:(t=n.constructor,t===void 0?!0:(e=t.prototype,!(ie(e)===!1||e.hasOwnProperty("isPrototypeOf")===!1)))}function Z(n){return n instanceof Element?n:document.querySelector(n)}async function ee(n){return await new Promise(t=>setTimeout(t,n))}var ae=(n,t,e)=>{if(!t.has(n))throw TypeError("Cannot "+e)},f=(n,t,e)=>(ae(n,t,"read from private field"),e?e.call(n):t.get(n)),j=(n,t,e)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,e)},le=(n,t,e,l)=>(ae(n,t,"write to private field"),l?l.call(n,e):t.set(n,e),e),z,L,M,R,G,B,K;const Te='[data-elem="drawer.panel"]',Y="data-drawers-group",xe=["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,lockScroll:{unlockDelay:300}};function ce(n){return De.all(n,{isMergeableObject:je})}class J{constructor({target:t,type:e,owner:l}){E(this,k,void 0);E(this,_,void 0);E(this,N,void 0);E(this,F,!1);const a=Z(t);if(!a)throw new Error("Trigger element cannot be found");if(!l)throw new Error("Owning drawer instance hasn't been provided");C(this,k,a),C(this,_,l),C(this,N,e),this.init()}get isActive(){return r(this,F)}get owner(){return r(this,_)}init(){r(this,k).addEventListener("click",t=>this.clickHandler(t)),r(this,_).on("open",()=>this.setActive(!0)),r(this,_).on("close",()=>this.setActive(!1))}clickHandler(t){t.__drawerTrigger=this,r(this,N)==="open"?r(this,_).isOpen||r(this,_).open(r(this,k)):r(this,N)==="close"?r(this,_).isOpen&&r(this,_).close(r(this,k)):r(this,_).isOpen?r(this,_).close(r(this,k)):r(this,_).open(r(this,k))}setActive(t){C(this,F,t),t?r(this,k).classList.add("drawer-trigger_active"):r(this,k).classList.remove("drawer-trigger_active")}}k=new WeakMap,_=new WeakMap,N=new WeakMap,F=new WeakMap;class he extends we{constructor({target:e,options:l}){super();E(this,d,void 0);E(this,H,void 0);E(this,T,void 0);E(this,Q,void 0);E(this,W,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")===r(this,W)?this.handleUnderlayClick(s):this.handleOtherDrawerClick(s):this.handleOutsideClick(s)},this.handleKeydown=s=>{r(this,d).closeOnEsc&&s.key==="Escape"&&this.close()};const a=ce(l?[te,l]:[te]),b=Z(e);if(b===null)throw new Error("Drawer's root cannot be found");C(this,W,b.getAttribute("data-drawer"));const m=b.querySelector(Te);if(m===null)throw new Error(`Drawer's panel cannot be found. Alias: ${r(this,W)}`);this.dom={root:b,panel:m},this.setOptions(a),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 scrollUnlockDelay(){var e;return((e=r(this,d).lockScroll)==null?void 0:e.unlockDelay)||0}get isOpen(){return r(this,T)}get isModal(){return r(this,d).modal}set isModal(e){this.dom.root.classList[e?"add":"remove"]("drawer_modal")}get willLockScroll(){return r(this,d).lockPageScroll}set zIndex(e){this.dom.root.style.setProperty("--z-index",String(e)),C(this,H,e)}get zIndex(){return r(this,H)}async open(e){await ee(0),!r(this,T)&&(this.emit("beforeOpen",{drawer:this,trigger:e}),C(this,T,!0),this.dom.root.classList.add(r(this,d).openingClass),this.emit("open",{drawer:this,trigger:e}),typeof r(this,d).openAnimationDuration=="number"&&await ee(r(this,d).openAnimationDuration),this.dom.root.classList.remove(r(this,d).openingClass),this.dom.root.classList.add(r(this,d).openClass),this.emit("openAnimationEnd",{drawer:this,trigger:e}),this.focus(),this.addEventListeners())}async close(e){r(this,d).onCloseConfirm&&!r(this,d).onCloseConfirm(this,e)||(this.emit("beforeClose",{drawer:this,trigger:e}),this.removeEventListeners(),C(this,T,!1),this.dom.root.classList.remove(r(this,d).openClass),this.dom.root.classList.add(r(this,d).closingClass),this.emit("close",{drawer:this,trigger:e}),typeof r(this,d).closeAnimationDuration=="number"&&await ee(r(this,d).closeAnimationDuration),this.dom.root.classList.remove(r(this,d).closingClass),this.emit("closeAnimationEnd",{drawer:this,trigger:e}))}handleOtherDrawerClick(e){}handleOutsideClick(e){r(this,d).closeOnOutsideClick&&(typeof r(this,d).closeOnOutsideClick=="object"&&r(this,d).closeOnOutsideClick.hasOwnProperty("checkTarget")?r(this,d).closeOnOutsideClick.checkTarget(e.target)&&this.close():this.close())}handleUnderlayClick(e){r(this,d).closeOnOutsideClick&&this.close()}focus(){r(this,d).focusOnChild&&this.focusChild()||this.focusSelf()}focusSelf(){this.dom.panel.focus()}focusChild(){const e=this.dom.panel.querySelector(xe.join(","));return e?(e.focus(),!0):!1}setOptions(e){var l;e.hasOwnProperty("modal")&&((l=r(this,d))==null?void 0:l.modal)!==e.modal&&(this.isModal=e.modal),C(this,d,r(this,d)?ce([r(this,d),e]):e)}assignGroup(e){C(this,Q,e)}}d=new WeakMap,H=new WeakMap,T=new WeakMap,Q=new WeakMap,W=new WeakMap;class Pe{constructor(){E(this,x,null);E(this,P,new Map)}lock(t,e){r(this,x)!==null&&(clearTimeout(r(this,x)),C(this,x,null)),r(this,P).has(t)||r(this,P).set(t,new Set);const l=r(this,P).get(t);l.size===0&&t.classList.add("scroll-lock-by-drawer"),l.add(e)}unlock(t,e){const l=r(this,P).get(t);l==null||l.delete(e),(!l||l.size===0)&&C(this,x,setTimeout(()=>t.classList.remove("scroll-lock-by-drawer"),e.scrollUnlockDelay))}}x=new WeakMap,P=new WeakMap;const ue=class re{constructor(t){j(this,z,void 0),j(this,L,[]),j(this,M,[]),j(this,R,void 0),j(this,G,new Map),this.onBeforeOpen=({drawer:a,trigger:b})=>{a.isModal?(f(this,G).set(a,f(this,L).length),f(this,L).push(a),a.zIndex=f(this,M).length+f(this,L).length):(f(this,G).set(a,f(this,M).length),f(this,M).push(a),a.zIndex=f(this,M).length,f(this,L).length>0&&f(this,L).forEach((m,s)=>m.zIndex=f(this,M).length+s+1)),a.willLockScroll&&this.lockScroll(a)},this.onCloseAnimationEnd=({drawer:a,trigger:b})=>{const m=a.isModal?f(this,L):f(this,M);for(delete m[f(this,G).get(a)];m.length&&!m.at(-1);)m.pop();f(this,G).delete(a),this.unlockScroll(a)};const e=Z(t);if(e===null)throw new Error("Drawer's group root cannot be found");le(this,z,e);const l=f(this,z).closest("[data-scrollable], html")||f(this,z).matches("[data-scrollable], html")&&f(this,z);if(l===null)throw new Error("Scrollable container for group root cannot be found");le(this,R,l)}add(t){t.on("beforeOpen",this.onBeforeOpen),t.on("closeAnimationEnd",this.onCloseAnimationEnd),t.assignGroup(this)}lockScroll(t){re.scrollLock.lock(f(this,R),t)}unlockScroll(t){re.scrollLock.unlock(f(this,R),t)}};z=new WeakMap,L=new WeakMap,M=new WeakMap,R=new WeakMap,G=new WeakMap,ue.scrollLock=new Pe;let ne=ue;const Ie=class X{constructor(){if(j(this,B,new Map),j(this,K,new Map),X.instance)return X.instance;X.instance=this}init(t=te){document.querySelectorAll(`[${Y}]`).forEach(s=>{const o=s.getAttribute(Y);typeof o=="string"&&f(this,K).set(o,new ne(s))}),f(this,K).set("default",new ne(document.documentElement)),document.querySelectorAll("[data-drawer]").forEach(s=>{var v;const o=s.getAttribute("data-drawer");if(typeof o!="string")return;const i=new he({target:s,options:{...t,modal:s.matches("[data-modal]")?s.matches(':not([data-modal="false"]'):t.modal}});f(this,B).set(o,i);const c=s.closest(`[${Y}]`),h=c?c.getAttribute(Y):"default";if(typeof h!="string")throw new Error("Group doesn't have alias set correctly");(v=f(this,K).get(h))==null||v.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");b(s,o);const i=this.get(o);m(s,i,o),new J({target:s,type:"open",owner:i})}else if(s.hasAttribute("data-drawer-close")){const o=s.getAttribute("data-drawer-close");b(s,o);const i=this.get(o);m(s,i,o),new J({target:s,type:"close",owner:i})}else{const o=s.getAttribute("data-drawer-toggle");b(s,o);const i=this.get(o);m(s,i,o),new J({target:s,type:"toggle",owner:i})}});function b(s,o){if(!o)throw new Error(`Drawer alias should be specified in the trigger attribute. Trigger elem: ${s}`)}function m(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:l}={}){var a;(a=this.get(t))==null||a.open(e)}close(t,{trigger:e,options:l}={}){var a;(a=this.get(t))==null||a.close(e)}get(t){return typeof t=="string"&&f(this,B).get(t)||null}on(t,e,l){var a;if(t)(a=this.get(t))==null||a.on(e,l);else for(const[b,m]of f(this,B))m.on(e,l)}};B=new WeakMap,K=new WeakMap;let de=Ie;typeof window<"u"&&(window.hasOwnProperty("app")||(window.app={}),window.app.drawers=new de),p.Drawer=he,p.DrawersGroup=ne,p.Trigger=J,p.default=de,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "vanilla-drawers",
3
- "version": "1.1.21",
3
+ "version": "1.1.23",
4
4
  "description": "Drawers controller.",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
8
8
  "main": "./dist/drawers.umd.js",
9
- "module": "./dist/drawers.js",
9
+ "module": "./dist/drawers.umd.js",
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
- "import": "./dist/drawers.js",
14
- "require": "./dist/drawers.umd.js"
13
+ "import": "./dist/drawers.umd.js",
14
+ "require": "./dist/drawers.es.js"
15
15
  }
16
16
  },
17
17
  "scripts": {