vanilla-drawers 1.0.8 → 1.0.10

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