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