vanilla-drawers 1.1.16 → 1.1.17

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