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