vrembem 3.0.19 → 3.0.21
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/LICENSE +1 -1
- package/dev/scripts.esm.js +293 -344
- package/dev/scripts.esm.js.map +1 -1
- package/dev/scripts.js +293 -344
- package/dev/scripts.js.map +1 -1
- package/dev/scripts.modern.mjs +239 -270
- package/dev/scripts.modern.mjs.map +1 -1
- package/dev/scripts.umd.js +293 -344
- package/dev/scripts.umd.js.map +1 -1
- package/dev/styles.css +39 -60
- package/dev/styles.css.map +1 -1
- package/dist/scripts.esm.js +1 -1
- package/dist/scripts.esm.js.map +1 -1
- package/dist/scripts.js +1 -1
- package/dist/scripts.js.map +1 -1
- package/dist/scripts.modern.mjs +1 -1
- package/dist/scripts.modern.mjs.map +1 -1
- package/dist/scripts.umd.js +1 -1
- package/dist/scripts.umd.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/index.js +5 -5
- package/package.json +26 -26
package/dev/scripts.modern.mjs
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var source = arguments[i];
|
|
5
|
-
for (var key in source) {
|
|
6
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
-
target[key] = source[key];
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return target;
|
|
12
|
-
};
|
|
13
|
-
return _extends.apply(this, arguments);
|
|
1
|
+
function _classPrivateFieldLooseBase(e, t) {
|
|
2
|
+
if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance");
|
|
3
|
+
return e;
|
|
14
4
|
}
|
|
15
5
|
var id = 0;
|
|
16
|
-
function _classPrivateFieldLooseKey(
|
|
17
|
-
return "__private_" + id++ + "_" +
|
|
6
|
+
function _classPrivateFieldLooseKey(e) {
|
|
7
|
+
return "__private_" + id++ + "_" + e;
|
|
18
8
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
function _extends() {
|
|
10
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
11
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
12
|
+
var t = arguments[e];
|
|
13
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
14
|
+
}
|
|
15
|
+
return n;
|
|
16
|
+
}, _extends.apply(null, arguments);
|
|
24
17
|
}
|
|
25
18
|
|
|
26
19
|
var _handler = /*#__PURE__*/_classPrivateFieldLooseKey("handler");
|
|
@@ -42,8 +35,8 @@ class Breakpoint {
|
|
|
42
35
|
set handler(func) {
|
|
43
36
|
if (this.mql) {
|
|
44
37
|
// Conditionally use removeListener() for IE11 support.
|
|
45
|
-
if (typeof this.mql.removeEventListener ===
|
|
46
|
-
this.mql.removeEventListener(
|
|
38
|
+
if (typeof this.mql.removeEventListener === "function") {
|
|
39
|
+
this.mql.removeEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]);
|
|
47
40
|
} else {
|
|
48
41
|
this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
|
|
49
42
|
}
|
|
@@ -62,8 +55,8 @@ class Breakpoint {
|
|
|
62
55
|
this.mql = window.matchMedia(`(min-width: ${this.value})`);
|
|
63
56
|
|
|
64
57
|
// Conditionally use addListener() for IE11 support.
|
|
65
|
-
if (typeof this.mql.addEventListener ===
|
|
66
|
-
this.mql.addEventListener(
|
|
58
|
+
if (typeof this.mql.addEventListener === "function") {
|
|
59
|
+
this.mql.addEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]);
|
|
67
60
|
} else {
|
|
68
61
|
this.mql.addListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
|
|
69
62
|
}
|
|
@@ -77,8 +70,8 @@ class Breakpoint {
|
|
|
77
70
|
if (!this.mql) return this;
|
|
78
71
|
|
|
79
72
|
// Conditionally use removeListener() for IE11 support.
|
|
80
|
-
if (typeof this.mql.removeEventListener ===
|
|
81
|
-
this.mql.removeEventListener(
|
|
73
|
+
if (typeof this.mql.removeEventListener === "function") {
|
|
74
|
+
this.mql.removeEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]);
|
|
82
75
|
} else {
|
|
83
76
|
this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
|
|
84
77
|
}
|
|
@@ -125,43 +118,18 @@ class Collection {
|
|
|
125
118
|
}
|
|
126
119
|
return this.collection;
|
|
127
120
|
}
|
|
128
|
-
get(value, key =
|
|
121
|
+
get(value, key = "id") {
|
|
129
122
|
return this.collection.find(item => {
|
|
130
123
|
return item[key] === value;
|
|
131
124
|
});
|
|
132
125
|
}
|
|
133
126
|
}
|
|
134
127
|
|
|
135
|
-
const not = {
|
|
136
|
-
inert: ':not([inert]):not([inert] *)',
|
|
137
|
-
negTabIndex: ':not([tabindex^="-"])',
|
|
138
|
-
disabled: ':not(:disabled)',
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
var e = [
|
|
142
|
-
`a[href]${not.inert}${not.negTabIndex}`,
|
|
143
|
-
`area[href]${not.inert}${not.negTabIndex}`,
|
|
144
|
-
`input:not([type="hidden"]):not([type="radio"])${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
145
|
-
`input[type="radio"]${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
146
|
-
`select${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
147
|
-
`textarea${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
148
|
-
`button${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
149
|
-
`details${not.inert} > summary:first-of-type${not.negTabIndex}`,
|
|
150
|
-
// Discard until Firefox supports `:has()`
|
|
151
|
-
// See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
|
|
152
|
-
// `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
|
|
153
|
-
`iframe${not.inert}${not.negTabIndex}`,
|
|
154
|
-
`audio[controls]${not.inert}${not.negTabIndex}`,
|
|
155
|
-
`video[controls]${not.inert}${not.negTabIndex}`,
|
|
156
|
-
`[contenteditable]${not.inert}${not.negTabIndex}`,
|
|
157
|
-
`[tabindex]${not.inert}${not.negTabIndex}`,
|
|
158
|
-
];
|
|
159
|
-
|
|
160
128
|
var _focusable = /*#__PURE__*/_classPrivateFieldLooseKey("focusable");
|
|
161
129
|
var _handleFocusTrap = /*#__PURE__*/_classPrivateFieldLooseKey("handleFocusTrap");
|
|
162
130
|
var _handleFocusLock = /*#__PURE__*/_classPrivateFieldLooseKey("handleFocusLock");
|
|
163
131
|
class FocusTrap {
|
|
164
|
-
constructor(el = null, selectorFocus =
|
|
132
|
+
constructor(el = null, selectorFocus = "[data-focus]") {
|
|
165
133
|
Object.defineProperty(this, _focusable, {
|
|
166
134
|
writable: true,
|
|
167
135
|
value: void 0
|
|
@@ -188,11 +156,11 @@ class FocusTrap {
|
|
|
188
156
|
|
|
189
157
|
// Apply event listeners based on new focusable array length.
|
|
190
158
|
if (_classPrivateFieldLooseBase(this, _focusable)[_focusable].length) {
|
|
191
|
-
document.removeEventListener(
|
|
192
|
-
document.addEventListener(
|
|
159
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);
|
|
160
|
+
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]);
|
|
193
161
|
} else {
|
|
194
|
-
document.removeEventListener(
|
|
195
|
-
document.addEventListener(
|
|
162
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]);
|
|
163
|
+
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);
|
|
196
164
|
}
|
|
197
165
|
}
|
|
198
166
|
get focusableFirst() {
|
|
@@ -220,8 +188,8 @@ class FocusTrap {
|
|
|
220
188
|
this.focusable = [];
|
|
221
189
|
|
|
222
190
|
// Remove event listeners
|
|
223
|
-
document.removeEventListener(
|
|
224
|
-
document.removeEventListener(
|
|
191
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]);
|
|
192
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);
|
|
225
193
|
}
|
|
226
194
|
focus(el = this.el, selectorFocus = this.selectorFocus) {
|
|
227
195
|
// Query for the focus selector, otherwise return this element.
|
|
@@ -238,7 +206,8 @@ class FocusTrap {
|
|
|
238
206
|
const initScrollTop = el.scrollTop;
|
|
239
207
|
|
|
240
208
|
// Query for all the focusable elements.
|
|
241
|
-
const
|
|
209
|
+
const selector = focusableSelectors.join(",");
|
|
210
|
+
const els = el.querySelectorAll(selector);
|
|
242
211
|
|
|
243
212
|
// Loop through all focusable elements.
|
|
244
213
|
els.forEach(el => {
|
|
@@ -259,9 +228,16 @@ class FocusTrap {
|
|
|
259
228
|
return focusable;
|
|
260
229
|
}
|
|
261
230
|
}
|
|
231
|
+
|
|
232
|
+
// This has been copied over from focusable-selectors package and modified.
|
|
233
|
+
// https://github.com/KittyGiraudel/focusable-selectors
|
|
234
|
+
const notInert = ":not([inert])"; // Previously `:not([inert]):not([inert] *)`
|
|
235
|
+
const notNegTabIndex = ":not([tabindex^=\"-\"])";
|
|
236
|
+
const notDisabled = ":not(:disabled)";
|
|
237
|
+
const focusableSelectors = [`a[href]${notInert}${notNegTabIndex}`, `area[href]${notInert}${notNegTabIndex}`, `input:not([type="hidden"]):not([type="radio"])${notInert}${notNegTabIndex}${notDisabled}`, `input[type="radio"]${notInert}${notNegTabIndex}${notDisabled}`, `select${notInert}${notNegTabIndex}${notDisabled}`, `textarea${notInert}${notNegTabIndex}${notDisabled}`, `button${notInert}${notNegTabIndex}${notDisabled}`, `details${notInert} > summary:first-of-type${notNegTabIndex}`, `iframe${notInert}${notNegTabIndex}`, `audio[controls]${notInert}${notNegTabIndex}`, `video[controls]${notInert}${notNegTabIndex}`, `[contenteditable]${notInert}${notNegTabIndex}`, `[tabindex]${notInert}${notNegTabIndex}`];
|
|
262
238
|
function handleFocusTrap(event) {
|
|
263
239
|
// Check if the click was a tab and return if not.
|
|
264
|
-
const isTab = event.key ===
|
|
240
|
+
const isTab = event.key === "Tab" || event.keyCode === 9;
|
|
265
241
|
if (!isTab) return;
|
|
266
242
|
|
|
267
243
|
// If the shift key is pressed.
|
|
@@ -283,18 +259,18 @@ function handleFocusTrap(event) {
|
|
|
283
259
|
}
|
|
284
260
|
function handleFocusLock(event) {
|
|
285
261
|
// Ignore the tab key by preventing default.
|
|
286
|
-
const isTab = event.key ===
|
|
262
|
+
const isTab = event.key === "Tab" || event.keyCode === 9;
|
|
287
263
|
if (isTab) event.preventDefault();
|
|
288
264
|
}
|
|
289
265
|
|
|
290
266
|
function getConfig$1(el, dataConfig) {
|
|
291
|
-
const string = el.getAttribute(`data-${dataConfig}`) ||
|
|
292
|
-
const json = string.replace(/'/g,
|
|
267
|
+
const string = el.getAttribute(`data-${dataConfig}`) || "";
|
|
268
|
+
const json = string.replace(/'/g, "\"");
|
|
293
269
|
return json ? JSON.parse(json) : {};
|
|
294
270
|
}
|
|
295
271
|
|
|
296
272
|
function getPrefix() {
|
|
297
|
-
return getComputedStyle(document.body).getPropertyValue(
|
|
273
|
+
return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim();
|
|
298
274
|
}
|
|
299
275
|
|
|
300
276
|
function localStore(key, enable = true) {
|
|
@@ -336,18 +312,18 @@ function teleport(what, where, how) {
|
|
|
336
312
|
where = isComment || isElement ? where : document.querySelector(where);
|
|
337
313
|
|
|
338
314
|
// If ref is a comment, set teleport type to 'after'.
|
|
339
|
-
if (isComment) how =
|
|
315
|
+
if (isComment) how = "after";
|
|
340
316
|
|
|
341
317
|
// Must be a valid reference element and method.
|
|
342
318
|
if (!where) throw new Error(`Not a valid teleport reference: '${where}'`);
|
|
343
|
-
if (typeof where[how] !=
|
|
319
|
+
if (typeof where[how] != "function") throw new Error(`Not a valid teleport method: '${how}'`);
|
|
344
320
|
|
|
345
321
|
// Initial return ref is null.
|
|
346
322
|
let returnRef = null;
|
|
347
323
|
|
|
348
324
|
// If ref is not a comment, set a return reference comment.
|
|
349
325
|
if (!isComment) {
|
|
350
|
-
returnRef = document.createComment(
|
|
326
|
+
returnRef = document.createComment("teleported #" + what.id);
|
|
351
327
|
what.before(returnRef);
|
|
352
328
|
}
|
|
353
329
|
|
|
@@ -373,7 +349,7 @@ const openTransition = (el, settings) => {
|
|
|
373
349
|
el.classList.add(settings.stateOpening);
|
|
374
350
|
|
|
375
351
|
// Add event listener for when the transition is finished.
|
|
376
|
-
el.addEventListener(
|
|
352
|
+
el.addEventListener("transitionend", function _f(event) {
|
|
377
353
|
// Prevent child transition bubbling from firing this event.
|
|
378
354
|
if (event.target != el) return;
|
|
379
355
|
|
|
@@ -383,7 +359,7 @@ const openTransition = (el, settings) => {
|
|
|
383
359
|
|
|
384
360
|
// Resolve the promise and remove the event listener.
|
|
385
361
|
resolve(el);
|
|
386
|
-
this.removeEventListener(
|
|
362
|
+
this.removeEventListener("transitionend", _f);
|
|
387
363
|
});
|
|
388
364
|
} else {
|
|
389
365
|
// Toggle final opened state classes and resolve the promise.
|
|
@@ -402,7 +378,7 @@ const closeTransition = (el, settings) => {
|
|
|
402
378
|
el.classList.remove(settings.stateOpened);
|
|
403
379
|
|
|
404
380
|
// Add event listener for when the transition is finished.
|
|
405
|
-
el.addEventListener(
|
|
381
|
+
el.addEventListener("transitionend", function _f(event) {
|
|
406
382
|
// Prevent child transition bubbling from firing this event.
|
|
407
383
|
if (event.target != el) return;
|
|
408
384
|
|
|
@@ -412,7 +388,7 @@ const closeTransition = (el, settings) => {
|
|
|
412
388
|
|
|
413
389
|
// Resolve the promise and remove the event listener.
|
|
414
390
|
resolve(el);
|
|
415
|
-
this.removeEventListener(
|
|
391
|
+
this.removeEventListener("transitionend", _f);
|
|
416
392
|
});
|
|
417
393
|
} else {
|
|
418
394
|
// Toggle final closed state classes and resolve the promise.
|
|
@@ -428,24 +404,17 @@ function setOverflowHidden(state, selector) {
|
|
|
428
404
|
const els = document.querySelectorAll(selector);
|
|
429
405
|
els.forEach(el => {
|
|
430
406
|
if (state) {
|
|
431
|
-
el.style.overflow =
|
|
407
|
+
el.style.overflow = "hidden";
|
|
432
408
|
} else {
|
|
433
|
-
el.style.removeProperty(
|
|
409
|
+
el.style.removeProperty("overflow");
|
|
434
410
|
}
|
|
435
411
|
});
|
|
436
412
|
}
|
|
437
413
|
}
|
|
438
414
|
function setInert(state, selector) {
|
|
439
415
|
if (selector) {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
if (state) {
|
|
443
|
-
el.inert = true;
|
|
444
|
-
el.setAttribute('aria-hidden', true);
|
|
445
|
-
} else {
|
|
446
|
-
el.inert = null;
|
|
447
|
-
el.removeAttribute('aria-hidden');
|
|
448
|
-
}
|
|
416
|
+
document.querySelectorAll(selector).forEach(el => {
|
|
417
|
+
el.inert = state;
|
|
449
418
|
});
|
|
450
419
|
}
|
|
451
420
|
}
|
|
@@ -473,8 +442,8 @@ var index = {
|
|
|
473
442
|
|
|
474
443
|
var defaults$3 = {
|
|
475
444
|
autoInit: false,
|
|
476
|
-
stateAttr:
|
|
477
|
-
stateValue:
|
|
445
|
+
stateAttr: "aria-checked",
|
|
446
|
+
stateValue: "mixed"
|
|
478
447
|
};
|
|
479
448
|
|
|
480
449
|
class Checkbox {
|
|
@@ -489,10 +458,10 @@ class Checkbox {
|
|
|
489
458
|
const selector = `[${this.settings.stateAttr}="${this.settings.stateValue}"]`;
|
|
490
459
|
const mixed = document.querySelectorAll(selector);
|
|
491
460
|
this.setIndeterminate(mixed);
|
|
492
|
-
document.addEventListener(
|
|
461
|
+
document.addEventListener("click", this.__handlerClick, false);
|
|
493
462
|
}
|
|
494
463
|
destroy() {
|
|
495
|
-
document.removeEventListener(
|
|
464
|
+
document.removeEventListener("click", this.__handlerClick, false);
|
|
496
465
|
}
|
|
497
466
|
handlerClick(event) {
|
|
498
467
|
const selector = `[${this.settings.stateAttr}="${this.settings.stateValue}"]`;
|
|
@@ -528,30 +497,30 @@ class Checkbox {
|
|
|
528
497
|
var defaults$2 = {
|
|
529
498
|
autoInit: false,
|
|
530
499
|
// Data attributes
|
|
531
|
-
dataOpen:
|
|
532
|
-
dataClose:
|
|
533
|
-
dataToggle:
|
|
534
|
-
dataBreakpoint:
|
|
535
|
-
dataConfig:
|
|
500
|
+
dataOpen: "drawer-open",
|
|
501
|
+
dataClose: "drawer-close",
|
|
502
|
+
dataToggle: "drawer-toggle",
|
|
503
|
+
dataBreakpoint: "drawer-breakpoint",
|
|
504
|
+
dataConfig: "drawer-config",
|
|
536
505
|
// Selectors
|
|
537
|
-
selectorDrawer:
|
|
538
|
-
selectorDialog:
|
|
539
|
-
selectorFocus:
|
|
506
|
+
selectorDrawer: ".drawer",
|
|
507
|
+
selectorDialog: ".drawer__dialog",
|
|
508
|
+
selectorFocus: "[data-focus]",
|
|
540
509
|
selectorInert: null,
|
|
541
|
-
selectorOverflow:
|
|
510
|
+
selectorOverflow: "body",
|
|
542
511
|
// State classes
|
|
543
|
-
stateOpened:
|
|
544
|
-
stateOpening:
|
|
545
|
-
stateClosing:
|
|
546
|
-
stateClosed:
|
|
512
|
+
stateOpened: "is-opened",
|
|
513
|
+
stateOpening: "is-opening",
|
|
514
|
+
stateClosing: "is-closing",
|
|
515
|
+
stateClosed: "is-closed",
|
|
547
516
|
// Classes
|
|
548
|
-
classModal:
|
|
517
|
+
classModal: "drawer_modal",
|
|
549
518
|
// Feature toggles
|
|
550
519
|
breakpoints: null,
|
|
551
|
-
customEventPrefix:
|
|
520
|
+
customEventPrefix: "drawer:",
|
|
552
521
|
eventListeners: true,
|
|
553
522
|
store: true,
|
|
554
|
-
storeKey:
|
|
523
|
+
storeKey: "VB:DrawerState",
|
|
555
524
|
setTabindex: true,
|
|
556
525
|
transition: true
|
|
557
526
|
};
|
|
@@ -569,7 +538,7 @@ function handleClick$2(event) {
|
|
|
569
538
|
|
|
570
539
|
// If it's a toggle trigger...
|
|
571
540
|
if (trigger.matches(`[data-${this.settings.dataToggle}]`)) {
|
|
572
|
-
const selectors = trigger.getAttribute(`data-${this.settings.dataToggle}`).trim().split(
|
|
541
|
+
const selectors = trigger.getAttribute(`data-${this.settings.dataToggle}`).trim().split(" ");
|
|
573
542
|
selectors.forEach(selector => {
|
|
574
543
|
// Get the entry from collection using the attribute value.
|
|
575
544
|
const entry = this.get(selector);
|
|
@@ -582,7 +551,7 @@ function handleClick$2(event) {
|
|
|
582
551
|
|
|
583
552
|
// If it's a open trigger...
|
|
584
553
|
if (trigger.matches(`[data-${this.settings.dataOpen}]`)) {
|
|
585
|
-
const selectors = trigger.getAttribute(`data-${this.settings.dataOpen}`).trim().split(
|
|
554
|
+
const selectors = trigger.getAttribute(`data-${this.settings.dataOpen}`).trim().split(" ");
|
|
586
555
|
selectors.forEach(selector => {
|
|
587
556
|
// Get the entry from collection using the attribute value.
|
|
588
557
|
const entry = this.get(selector);
|
|
@@ -595,7 +564,7 @@ function handleClick$2(event) {
|
|
|
595
564
|
|
|
596
565
|
// If it's a close trigger...
|
|
597
566
|
if (trigger.matches(`[data-${this.settings.dataClose}]`)) {
|
|
598
|
-
const selectors = trigger.getAttribute(`data-${this.settings.dataClose}`).trim().split(
|
|
567
|
+
const selectors = trigger.getAttribute(`data-${this.settings.dataClose}`).trim().split(" ");
|
|
599
568
|
selectors.forEach(selector => {
|
|
600
569
|
if (selector) {
|
|
601
570
|
// Get the entry from collection using the attribute value.
|
|
@@ -622,7 +591,7 @@ function handleClick$2(event) {
|
|
|
622
591
|
}
|
|
623
592
|
}
|
|
624
593
|
function handleKeydown$2(event) {
|
|
625
|
-
if (event.key ===
|
|
594
|
+
if (event.key === "Escape") {
|
|
626
595
|
const modal = this.activeModal;
|
|
627
596
|
if (modal) this.close(modal);
|
|
628
597
|
}
|
|
@@ -641,7 +610,7 @@ async function deregister$2(obj, close = true) {
|
|
|
641
610
|
const entry = this.collection[index];
|
|
642
611
|
|
|
643
612
|
// If entry is in the opened state.
|
|
644
|
-
if (close && entry.state ===
|
|
613
|
+
if (close && entry.state === "opened") {
|
|
645
614
|
// Close the drawer.
|
|
646
615
|
await entry.close(false);
|
|
647
616
|
}
|
|
@@ -665,12 +634,12 @@ async function deregister$2(obj, close = true) {
|
|
|
665
634
|
return this.collection;
|
|
666
635
|
}
|
|
667
636
|
|
|
668
|
-
function
|
|
637
|
+
function P() {
|
|
669
638
|
return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim();
|
|
670
639
|
}
|
|
671
640
|
|
|
672
641
|
function getBreakpoint(drawer) {
|
|
673
|
-
const prefix =
|
|
642
|
+
const prefix = P();
|
|
674
643
|
const bp = drawer.getAttribute(`data-${this.settings.dataBreakpoint}`);
|
|
675
644
|
if (this.settings.breakpoints && this.settings.breakpoints[bp]) {
|
|
676
645
|
return this.settings.breakpoints[bp];
|
|
@@ -683,7 +652,7 @@ function getBreakpoint(drawer) {
|
|
|
683
652
|
|
|
684
653
|
function getDrawer(query) {
|
|
685
654
|
// Get the entry from collection.
|
|
686
|
-
const entry = typeof query ===
|
|
655
|
+
const entry = typeof query === "string" ? this.get(query) : this.get(query.id);
|
|
687
656
|
|
|
688
657
|
// Return entry if it was resolved, otherwise throw error.
|
|
689
658
|
if (entry) {
|
|
@@ -695,12 +664,12 @@ function getDrawer(query) {
|
|
|
695
664
|
|
|
696
665
|
function getDrawerID(obj) {
|
|
697
666
|
// If it's a string, return the string.
|
|
698
|
-
if (typeof obj ===
|
|
667
|
+
if (typeof obj === "string") {
|
|
699
668
|
return obj;
|
|
700
669
|
}
|
|
701
670
|
|
|
702
671
|
// If it's an HTML element.
|
|
703
|
-
else if (typeof obj.hasAttribute ===
|
|
672
|
+
else if (typeof obj.hasAttribute === "function") {
|
|
704
673
|
// If it's a drawer open trigger, return data value.
|
|
705
674
|
if (obj.hasAttribute(`data-${this.settings.dataOpen}`)) {
|
|
706
675
|
return obj.getAttribute(`data-${this.settings.dataOpen}`);
|
|
@@ -746,7 +715,7 @@ function getDrawerElements(query) {
|
|
|
746
715
|
};
|
|
747
716
|
} else if (!dialog) {
|
|
748
717
|
return {
|
|
749
|
-
error: new Error(
|
|
718
|
+
error: new Error("Drawer is missing dialog element.")
|
|
750
719
|
};
|
|
751
720
|
} else {
|
|
752
721
|
return {
|
|
@@ -756,7 +725,7 @@ function getDrawerElements(query) {
|
|
|
756
725
|
}
|
|
757
726
|
} else {
|
|
758
727
|
return {
|
|
759
|
-
error: new Error(
|
|
728
|
+
error: new Error("Could not resolve the drawer ID.")
|
|
760
729
|
};
|
|
761
730
|
}
|
|
762
731
|
}
|
|
@@ -768,14 +737,14 @@ async function initialState(entry) {
|
|
|
768
737
|
// 3. Else, initialize default state.
|
|
769
738
|
if (this.store.get(entry.id)) {
|
|
770
739
|
// Restore drawers to saved inline state.
|
|
771
|
-
if (this.store.get(entry.id) ===
|
|
740
|
+
if (this.store.get(entry.id) === "opened") {
|
|
772
741
|
await entry.open(false, false);
|
|
773
742
|
} else {
|
|
774
743
|
await entry.close(false, false);
|
|
775
744
|
}
|
|
776
745
|
} else if (entry.el.classList.contains(this.settings.stateOpened)) {
|
|
777
746
|
// Update drawer state.
|
|
778
|
-
entry.state =
|
|
747
|
+
entry.state = "opened";
|
|
779
748
|
} else {
|
|
780
749
|
// Remove transition state classes.
|
|
781
750
|
entry.el.classList.remove(this.settings.stateOpening);
|
|
@@ -787,9 +756,9 @@ async function initialState(entry) {
|
|
|
787
756
|
|
|
788
757
|
function updateFocusState$1(entry) {
|
|
789
758
|
// Check if there's an active modal
|
|
790
|
-
if (entry.state ===
|
|
759
|
+
if (entry.state === "opened") {
|
|
791
760
|
// Mount the focus trap on the opened drawer.
|
|
792
|
-
if (entry.mode ===
|
|
761
|
+
if (entry.mode === "modal") {
|
|
793
762
|
this.focusTrap.mount(entry.dialog, this.settings.selectorFocus);
|
|
794
763
|
} else {
|
|
795
764
|
this.focusTrap.focus(entry.dialog, this.settings.selectorFocus);
|
|
@@ -815,18 +784,18 @@ async function open$2(query, transition, focus = true) {
|
|
|
815
784
|
if (transition !== undefined) config.transition = transition;
|
|
816
785
|
|
|
817
786
|
// If drawer is closed.
|
|
818
|
-
if (drawer.state ===
|
|
787
|
+
if (drawer.state === "closed") {
|
|
819
788
|
// Update drawer state.
|
|
820
|
-
drawer.state =
|
|
789
|
+
drawer.state = "opening";
|
|
821
790
|
|
|
822
791
|
// Run the open transition.
|
|
823
792
|
await openTransition(drawer.el, config);
|
|
824
793
|
|
|
825
794
|
// Update the global state if mode is modal.
|
|
826
|
-
if (drawer.mode ===
|
|
795
|
+
if (drawer.mode === "modal") updateGlobalState(true, config);
|
|
827
796
|
|
|
828
797
|
// Update drawer state.
|
|
829
|
-
drawer.state =
|
|
798
|
+
drawer.state = "opened";
|
|
830
799
|
}
|
|
831
800
|
|
|
832
801
|
// Set focus to the drawer element if the focus param is true.
|
|
@@ -835,7 +804,7 @@ async function open$2(query, transition, focus = true) {
|
|
|
835
804
|
}
|
|
836
805
|
|
|
837
806
|
// Dispatch custom opened event.
|
|
838
|
-
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix +
|
|
807
|
+
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "opened", {
|
|
839
808
|
detail: this,
|
|
840
809
|
bubbles: true
|
|
841
810
|
}));
|
|
@@ -855,9 +824,9 @@ async function close$2(query, transition, focus = true) {
|
|
|
855
824
|
if (transition !== undefined) config.transition = transition;
|
|
856
825
|
|
|
857
826
|
// If drawer is opened.
|
|
858
|
-
if (drawer.state ===
|
|
827
|
+
if (drawer.state === "opened") {
|
|
859
828
|
// Update drawer state.
|
|
860
|
-
drawer.state =
|
|
829
|
+
drawer.state = "closing";
|
|
861
830
|
|
|
862
831
|
// Remove focus from active element.
|
|
863
832
|
document.activeElement.blur();
|
|
@@ -866,7 +835,7 @@ async function close$2(query, transition, focus = true) {
|
|
|
866
835
|
await closeTransition(drawer.el, config);
|
|
867
836
|
|
|
868
837
|
// Update the global state if mode is modal.
|
|
869
|
-
if (drawer.mode ===
|
|
838
|
+
if (drawer.mode === "modal") updateGlobalState(false, config);
|
|
870
839
|
|
|
871
840
|
// Set focus to the trigger element if the focus param is true.
|
|
872
841
|
if (focus) {
|
|
@@ -874,10 +843,10 @@ async function close$2(query, transition, focus = true) {
|
|
|
874
843
|
}
|
|
875
844
|
|
|
876
845
|
// Update drawer state.
|
|
877
|
-
drawer.state =
|
|
846
|
+
drawer.state = "closed";
|
|
878
847
|
|
|
879
848
|
// Dispatch custom closed event.
|
|
880
|
-
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix +
|
|
849
|
+
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "closed", {
|
|
881
850
|
detail: this,
|
|
882
851
|
bubbles: true
|
|
883
852
|
}));
|
|
@@ -892,7 +861,7 @@ async function toggle(query, transition, focus) {
|
|
|
892
861
|
const drawer = getDrawer.call(this, query);
|
|
893
862
|
|
|
894
863
|
// Open or close the drawer based on its current state.
|
|
895
|
-
if (drawer.state ===
|
|
864
|
+
if (drawer.state === "closed") {
|
|
896
865
|
return open$2.call(this, drawer, transition, focus);
|
|
897
866
|
} else {
|
|
898
867
|
return close$2.call(this, drawer, transition, focus);
|
|
@@ -901,9 +870,9 @@ async function toggle(query, transition, focus) {
|
|
|
901
870
|
|
|
902
871
|
function switchMode(entry) {
|
|
903
872
|
switch (entry.mode) {
|
|
904
|
-
case
|
|
873
|
+
case "inline":
|
|
905
874
|
return toInline.call(this, entry);
|
|
906
|
-
case
|
|
875
|
+
case "modal":
|
|
907
876
|
return toModal.call(this, entry);
|
|
908
877
|
default:
|
|
909
878
|
throw new Error(`"${entry.mode}" is not a valid drawer mode.`);
|
|
@@ -911,10 +880,10 @@ function switchMode(entry) {
|
|
|
911
880
|
}
|
|
912
881
|
async function toInline(entry) {
|
|
913
882
|
// Remove the modal class.
|
|
914
|
-
entry.el.classList.remove(entry.getSetting(
|
|
883
|
+
entry.el.classList.remove(entry.getSetting("classModal"));
|
|
915
884
|
|
|
916
885
|
// Remove the aria-modal attribute.
|
|
917
|
-
entry.dialog.removeAttribute(
|
|
886
|
+
entry.dialog.removeAttribute("aria-modal");
|
|
918
887
|
|
|
919
888
|
// Update the global state.
|
|
920
889
|
updateGlobalState(false, _extends({}, this.settings, entry.settings));
|
|
@@ -926,7 +895,7 @@ async function toInline(entry) {
|
|
|
926
895
|
await initialState.call(this, entry);
|
|
927
896
|
|
|
928
897
|
// Dispatch custom switch event.
|
|
929
|
-
entry.el.dispatchEvent(new CustomEvent(entry.getSetting(
|
|
898
|
+
entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "switchMode", {
|
|
930
899
|
detail: this,
|
|
931
900
|
bubbles: true
|
|
932
901
|
}));
|
|
@@ -938,22 +907,22 @@ async function toModal(entry) {
|
|
|
938
907
|
// Get the drawer configuration.
|
|
939
908
|
|
|
940
909
|
// Add the modal class.
|
|
941
|
-
entry.el.classList.add(entry.getSetting(
|
|
910
|
+
entry.el.classList.add(entry.getSetting("classModal"));
|
|
942
911
|
|
|
943
912
|
// Set aria-modal attribute to true.
|
|
944
|
-
entry.dialog.setAttribute(
|
|
913
|
+
entry.dialog.setAttribute("aria-modal", "true");
|
|
945
914
|
|
|
946
915
|
// If there isn't a stored state but also has the opened state class...
|
|
947
|
-
if (!this.store.get(entry.id) && entry.el.classList.contains(entry.getSetting(
|
|
916
|
+
if (!this.store.get(entry.id) && entry.el.classList.contains(entry.getSetting("stateOpened"))) {
|
|
948
917
|
// Save the opened state in local store.
|
|
949
|
-
this.store.set(entry.id,
|
|
918
|
+
this.store.set(entry.id, "opened");
|
|
950
919
|
}
|
|
951
920
|
|
|
952
921
|
// Modal drawer defaults to closed state.
|
|
953
922
|
await close$2.call(this, entry, false, false);
|
|
954
923
|
|
|
955
924
|
// Dispatch custom switch event.
|
|
956
|
-
entry.el.dispatchEvent(new CustomEvent(entry.getSetting(
|
|
925
|
+
entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "switchMode", {
|
|
957
926
|
detail: this,
|
|
958
927
|
bubbles: true
|
|
959
928
|
}));
|
|
@@ -997,7 +966,7 @@ async function register$2(el, dialog) {
|
|
|
997
966
|
return this;
|
|
998
967
|
},
|
|
999
968
|
handleBreakpoint(event) {
|
|
1000
|
-
this.mode = event.matches ?
|
|
969
|
+
this.mode = event.matches ? "inline" : "modal";
|
|
1001
970
|
return this;
|
|
1002
971
|
},
|
|
1003
972
|
getSetting(key) {
|
|
@@ -1021,8 +990,8 @@ async function register$2(el, dialog) {
|
|
|
1021
990
|
set state(value) {
|
|
1022
991
|
__state = value;
|
|
1023
992
|
// Save 'opened' and 'closed' states to store if mode is inline.
|
|
1024
|
-
if (value ===
|
|
1025
|
-
if (this.mode ===
|
|
993
|
+
if (value === "opened" || value === "closed") {
|
|
994
|
+
if (this.mode === "inline") root.store.set(this.id, this.state);
|
|
1026
995
|
}
|
|
1027
996
|
},
|
|
1028
997
|
get mode() {
|
|
@@ -1035,23 +1004,23 @@ async function register$2(el, dialog) {
|
|
|
1035
1004
|
}, methods);
|
|
1036
1005
|
|
|
1037
1006
|
// Create the state var with the initial state.
|
|
1038
|
-
let __state = el.classList.contains(entry.getSetting(
|
|
1007
|
+
let __state = el.classList.contains(entry.getSetting("stateOpened")) ? "opened" : "closed";
|
|
1039
1008
|
|
|
1040
1009
|
// Create the mode var with the initial mode.
|
|
1041
|
-
let __mode = el.classList.contains(entry.getSetting(
|
|
1010
|
+
let __mode = el.classList.contains(entry.getSetting("classModal")) ? "modal" : "inline";
|
|
1042
1011
|
|
|
1043
1012
|
// Setup mode specific attributes.
|
|
1044
|
-
if (entry.mode ===
|
|
1013
|
+
if (entry.mode === "modal") {
|
|
1045
1014
|
// Set aria-modal attribute to true.
|
|
1046
|
-
entry.dialog.setAttribute(
|
|
1015
|
+
entry.dialog.setAttribute("aria-modal", "true");
|
|
1047
1016
|
} else {
|
|
1048
1017
|
// Remove the aria-modal attribute.
|
|
1049
|
-
entry.dialog.removeAttribute(
|
|
1018
|
+
entry.dialog.removeAttribute("aria-modal");
|
|
1050
1019
|
}
|
|
1051
1020
|
|
|
1052
1021
|
// Set tabindex="-1" so dialog is focusable via JS or click.
|
|
1053
|
-
if (entry.getSetting(
|
|
1054
|
-
entry.dialog.setAttribute(
|
|
1022
|
+
if (entry.getSetting("setTabindex")) {
|
|
1023
|
+
entry.dialog.setAttribute("tabindex", "-1");
|
|
1055
1024
|
}
|
|
1056
1025
|
|
|
1057
1026
|
// Add entry to collection.
|
|
@@ -1095,7 +1064,7 @@ class Drawer extends Collection {
|
|
|
1095
1064
|
}
|
|
1096
1065
|
get activeModal() {
|
|
1097
1066
|
return this.collection.find(entry => {
|
|
1098
|
-
return entry.state ===
|
|
1067
|
+
return entry.state === "opened" && entry.mode === "modal";
|
|
1099
1068
|
});
|
|
1100
1069
|
}
|
|
1101
1070
|
async init(options = null) {
|
|
@@ -1125,12 +1094,12 @@ class Drawer extends Collection {
|
|
|
1125
1094
|
return this;
|
|
1126
1095
|
}
|
|
1127
1096
|
initEventListeners() {
|
|
1128
|
-
document.addEventListener(
|
|
1129
|
-
document.addEventListener(
|
|
1097
|
+
document.addEventListener("click", _classPrivateFieldLooseBase(this, _handleClick$1)[_handleClick$1], false);
|
|
1098
|
+
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleKeydown$2)[_handleKeydown$2], false);
|
|
1130
1099
|
}
|
|
1131
1100
|
destroyEventListeners() {
|
|
1132
|
-
document.removeEventListener(
|
|
1133
|
-
document.removeEventListener(
|
|
1101
|
+
document.removeEventListener("click", _classPrivateFieldLooseBase(this, _handleClick$1)[_handleClick$1], false);
|
|
1102
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleKeydown$2)[_handleKeydown$2], false);
|
|
1134
1103
|
}
|
|
1135
1104
|
register(query) {
|
|
1136
1105
|
const els = getDrawerElements.call(this, query);
|
|
@@ -1155,34 +1124,34 @@ class Drawer extends Collection {
|
|
|
1155
1124
|
var defaults$1 = {
|
|
1156
1125
|
autoInit: false,
|
|
1157
1126
|
// Data attributes
|
|
1158
|
-
dataOpen:
|
|
1159
|
-
dataClose:
|
|
1160
|
-
dataReplace:
|
|
1161
|
-
dataConfig:
|
|
1127
|
+
dataOpen: "modal-open",
|
|
1128
|
+
dataClose: "modal-close",
|
|
1129
|
+
dataReplace: "modal-replace",
|
|
1130
|
+
dataConfig: "modal-config",
|
|
1162
1131
|
// Selectors
|
|
1163
|
-
selectorModal:
|
|
1164
|
-
selectorDialog:
|
|
1165
|
-
selectorRequired:
|
|
1166
|
-
selectorFocus:
|
|
1132
|
+
selectorModal: ".modal",
|
|
1133
|
+
selectorDialog: ".modal__dialog",
|
|
1134
|
+
selectorRequired: "[role=\"alertdialog\"]",
|
|
1135
|
+
selectorFocus: "[data-focus]",
|
|
1167
1136
|
selectorInert: null,
|
|
1168
|
-
selectorOverflow:
|
|
1137
|
+
selectorOverflow: "body",
|
|
1169
1138
|
// State classes
|
|
1170
|
-
stateOpened:
|
|
1171
|
-
stateOpening:
|
|
1172
|
-
stateClosing:
|
|
1173
|
-
stateClosed:
|
|
1139
|
+
stateOpened: "is-opened",
|
|
1140
|
+
stateOpening: "is-opening",
|
|
1141
|
+
stateClosing: "is-closing",
|
|
1142
|
+
stateClosed: "is-closed",
|
|
1174
1143
|
// Feature settings
|
|
1175
|
-
customEventPrefix:
|
|
1144
|
+
customEventPrefix: "modal:",
|
|
1176
1145
|
eventListeners: true,
|
|
1177
1146
|
teleport: null,
|
|
1178
|
-
teleportMethod:
|
|
1147
|
+
teleportMethod: "append",
|
|
1179
1148
|
setTabindex: true,
|
|
1180
1149
|
transition: true
|
|
1181
1150
|
};
|
|
1182
1151
|
|
|
1183
1152
|
function getModal(query) {
|
|
1184
1153
|
// Get the entry from collection.
|
|
1185
|
-
const entry = typeof query ===
|
|
1154
|
+
const entry = typeof query === "string" ? this.get(query) : this.get(query.id);
|
|
1186
1155
|
|
|
1187
1156
|
// Return entry if it was resolved, otherwise throw error.
|
|
1188
1157
|
if (entry) {
|
|
@@ -1194,12 +1163,12 @@ function getModal(query) {
|
|
|
1194
1163
|
|
|
1195
1164
|
function getModalID(obj) {
|
|
1196
1165
|
// If it's a string, return the string.
|
|
1197
|
-
if (typeof obj ===
|
|
1166
|
+
if (typeof obj === "string") {
|
|
1198
1167
|
return obj;
|
|
1199
1168
|
}
|
|
1200
1169
|
|
|
1201
1170
|
// If it's an HTML element.
|
|
1202
|
-
else if (typeof obj.hasAttribute ===
|
|
1171
|
+
else if (typeof obj.hasAttribute === "function") {
|
|
1203
1172
|
// If it's a modal open trigger, return data value.
|
|
1204
1173
|
if (obj.hasAttribute(`data-${this.settings.dataOpen}`)) {
|
|
1205
1174
|
return obj.getAttribute(`data-${this.settings.dataOpen}`);
|
|
@@ -1245,7 +1214,7 @@ function getModalElements(query) {
|
|
|
1245
1214
|
};
|
|
1246
1215
|
} else if (!dialog) {
|
|
1247
1216
|
return {
|
|
1248
|
-
error: new Error(
|
|
1217
|
+
error: new Error("Modal is missing dialog element.")
|
|
1249
1218
|
};
|
|
1250
1219
|
} else {
|
|
1251
1220
|
return {
|
|
@@ -1255,7 +1224,7 @@ function getModalElements(query) {
|
|
|
1255
1224
|
}
|
|
1256
1225
|
} else {
|
|
1257
1226
|
return {
|
|
1258
|
-
error: new Error(
|
|
1227
|
+
error: new Error("Could not resolve the modal ID.")
|
|
1259
1228
|
};
|
|
1260
1229
|
}
|
|
1261
1230
|
}
|
|
@@ -1296,7 +1265,7 @@ async function handleClick$1(event) {
|
|
|
1296
1265
|
// Get the value of the data attribute.
|
|
1297
1266
|
const value = trigger.getAttribute(`data-${this.settings.dataClose}`);
|
|
1298
1267
|
// Close all if * wildcard is passed, otherwise close a single modal.
|
|
1299
|
-
return value ===
|
|
1268
|
+
return value === "*" ? this.closeAll() : this.close(value);
|
|
1300
1269
|
}
|
|
1301
1270
|
|
|
1302
1271
|
// If the modal screen was clicked, close the modal.
|
|
@@ -1306,7 +1275,7 @@ async function handleClick$1(event) {
|
|
|
1306
1275
|
}
|
|
1307
1276
|
function handleKeydown$1(event) {
|
|
1308
1277
|
// If escape key was pressed.
|
|
1309
|
-
if (event.key ===
|
|
1278
|
+
if (event.key === "Escape") {
|
|
1310
1279
|
// If a modal is opened and not required, close the modal.
|
|
1311
1280
|
if (this.active && !this.active.dialog.matches(this.settings.selectorRequired)) {
|
|
1312
1281
|
return this.close();
|
|
@@ -1327,7 +1296,7 @@ async function deregister$1(obj, close = true) {
|
|
|
1327
1296
|
const entry = this.collection[index];
|
|
1328
1297
|
|
|
1329
1298
|
// If entry is in the opened state, close it.
|
|
1330
|
-
if (close && entry.state ===
|
|
1299
|
+
if (close && entry.state === "opened") {
|
|
1331
1300
|
await entry.close(false);
|
|
1332
1301
|
} else {
|
|
1333
1302
|
// Remove modal from stack.
|
|
@@ -1335,7 +1304,7 @@ async function deregister$1(obj, close = true) {
|
|
|
1335
1304
|
}
|
|
1336
1305
|
|
|
1337
1306
|
// Return teleported modal if a reference has been set.
|
|
1338
|
-
if (entry.getSetting(
|
|
1307
|
+
if (entry.getSetting("teleport")) {
|
|
1339
1308
|
entry.teleportReturn();
|
|
1340
1309
|
}
|
|
1341
1310
|
|
|
@@ -1366,9 +1335,9 @@ async function open$1(query, transition, focus = true) {
|
|
|
1366
1335
|
this.stack.moveToTop(modal);
|
|
1367
1336
|
|
|
1368
1337
|
// If modal is closed.
|
|
1369
|
-
if (modal.state ===
|
|
1338
|
+
if (modal.state === "closed") {
|
|
1370
1339
|
// Update modal state.
|
|
1371
|
-
modal.state =
|
|
1340
|
+
modal.state = "opening";
|
|
1372
1341
|
|
|
1373
1342
|
// Add modal to stack.
|
|
1374
1343
|
this.stack.add(modal);
|
|
@@ -1377,7 +1346,7 @@ async function open$1(query, transition, focus = true) {
|
|
|
1377
1346
|
await openTransition(modal.el, config);
|
|
1378
1347
|
|
|
1379
1348
|
// Update modal state.
|
|
1380
|
-
modal.state =
|
|
1349
|
+
modal.state = "opened";
|
|
1381
1350
|
}
|
|
1382
1351
|
|
|
1383
1352
|
// Update focus if the focus param is true.
|
|
@@ -1386,7 +1355,7 @@ async function open$1(query, transition, focus = true) {
|
|
|
1386
1355
|
}
|
|
1387
1356
|
|
|
1388
1357
|
// Dispatch custom opened event.
|
|
1389
|
-
modal.el.dispatchEvent(new CustomEvent(config.customEventPrefix +
|
|
1358
|
+
modal.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "opened", {
|
|
1390
1359
|
detail: this,
|
|
1391
1360
|
bubbles: true
|
|
1392
1361
|
}));
|
|
@@ -1400,9 +1369,9 @@ async function close$1(query, transition, focus = true) {
|
|
|
1400
1369
|
const modal = query ? getModal.call(this, query) : this.active;
|
|
1401
1370
|
|
|
1402
1371
|
// If a modal exists and its state is opened.
|
|
1403
|
-
if (modal && modal.state ===
|
|
1372
|
+
if (modal && modal.state === "opened") {
|
|
1404
1373
|
// Update modal state.
|
|
1405
|
-
modal.state =
|
|
1374
|
+
modal.state = "closing";
|
|
1406
1375
|
|
|
1407
1376
|
// Get the modal configuration.
|
|
1408
1377
|
const config = _extends({}, this.settings, modal.settings);
|
|
@@ -1425,10 +1394,10 @@ async function close$1(query, transition, focus = true) {
|
|
|
1425
1394
|
}
|
|
1426
1395
|
|
|
1427
1396
|
// Update modal state.
|
|
1428
|
-
modal.state =
|
|
1397
|
+
modal.state = "closed";
|
|
1429
1398
|
|
|
1430
1399
|
// Dispatch custom closed event.
|
|
1431
|
-
modal.el.dispatchEvent(new CustomEvent(config.customEventPrefix +
|
|
1400
|
+
modal.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "closed", {
|
|
1432
1401
|
detail: this,
|
|
1433
1402
|
bubbles: true
|
|
1434
1403
|
}));
|
|
@@ -1457,7 +1426,7 @@ async function replace(query, transition, focus = true) {
|
|
|
1457
1426
|
|
|
1458
1427
|
// Setup results for return.
|
|
1459
1428
|
let resultOpened, resultClosed;
|
|
1460
|
-
if (modal.state ===
|
|
1429
|
+
if (modal.state === "opened") {
|
|
1461
1430
|
// If modal is open, close all modals except for replacement.
|
|
1462
1431
|
resultOpened = modal;
|
|
1463
1432
|
resultClosed = await closeAll$1.call(this, modal.id, transition);
|
|
@@ -1501,12 +1470,12 @@ async function register$1(el, dialog) {
|
|
|
1501
1470
|
deregister() {
|
|
1502
1471
|
return deregister$1.call(root, this);
|
|
1503
1472
|
},
|
|
1504
|
-
teleport(ref = this.getSetting(
|
|
1473
|
+
teleport(ref = this.getSetting("teleport"), method = this.getSetting("teleportMethod")) {
|
|
1505
1474
|
if (!this.returnRef) {
|
|
1506
1475
|
this.returnRef = teleport(this.el, ref, method);
|
|
1507
1476
|
return this.el;
|
|
1508
1477
|
} else {
|
|
1509
|
-
console.error(
|
|
1478
|
+
console.error("Element has already been teleported:", this.el);
|
|
1510
1479
|
return false;
|
|
1511
1480
|
}
|
|
1512
1481
|
},
|
|
@@ -1515,7 +1484,7 @@ async function register$1(el, dialog) {
|
|
|
1515
1484
|
this.returnRef = teleport(this.el, this.returnRef);
|
|
1516
1485
|
return this.el;
|
|
1517
1486
|
} else {
|
|
1518
|
-
console.error(
|
|
1487
|
+
console.error("No return reference found:", this.el);
|
|
1519
1488
|
return false;
|
|
1520
1489
|
}
|
|
1521
1490
|
},
|
|
@@ -1527,7 +1496,7 @@ async function register$1(el, dialog) {
|
|
|
1527
1496
|
// Setup the modal object.
|
|
1528
1497
|
const entry = _extends({
|
|
1529
1498
|
id: el.id,
|
|
1530
|
-
state:
|
|
1499
|
+
state: "closed",
|
|
1531
1500
|
el: el,
|
|
1532
1501
|
dialog: dialog,
|
|
1533
1502
|
returnRef: null,
|
|
@@ -1535,20 +1504,20 @@ async function register$1(el, dialog) {
|
|
|
1535
1504
|
}, methods);
|
|
1536
1505
|
|
|
1537
1506
|
// Set aria-modal attribute to true.
|
|
1538
|
-
entry.dialog.setAttribute(
|
|
1507
|
+
entry.dialog.setAttribute("aria-modal", "true");
|
|
1539
1508
|
|
|
1540
1509
|
// If a role attribute is not set, set it to "dialog" as the default.
|
|
1541
|
-
if (!entry.dialog.hasAttribute(
|
|
1542
|
-
entry.dialog.setAttribute(
|
|
1510
|
+
if (!entry.dialog.hasAttribute("role")) {
|
|
1511
|
+
entry.dialog.setAttribute("role", "dialog");
|
|
1543
1512
|
}
|
|
1544
1513
|
|
|
1545
1514
|
// Set tabindex="-1" so dialog is focusable via JS or click.
|
|
1546
|
-
if (entry.getSetting(
|
|
1547
|
-
entry.dialog.setAttribute(
|
|
1515
|
+
if (entry.getSetting("setTabindex")) {
|
|
1516
|
+
entry.dialog.setAttribute("tabindex", "-1");
|
|
1548
1517
|
}
|
|
1549
1518
|
|
|
1550
1519
|
// Teleport modal if a reference has been set.
|
|
1551
|
-
if (entry.getSetting(
|
|
1520
|
+
if (entry.getSetting("teleport")) {
|
|
1552
1521
|
entry.teleport();
|
|
1553
1522
|
}
|
|
1554
1523
|
|
|
@@ -1583,7 +1552,7 @@ function stack(settings) {
|
|
|
1583
1552
|
updateIndex() {
|
|
1584
1553
|
stackArray.forEach((entry, index) => {
|
|
1585
1554
|
entry.el.style.zIndex = null;
|
|
1586
|
-
const value = getComputedStyle(entry.el)[
|
|
1555
|
+
const value = getComputedStyle(entry.el)["z-index"];
|
|
1587
1556
|
entry.el.style.zIndex = parseInt(value) + index + 1;
|
|
1588
1557
|
});
|
|
1589
1558
|
},
|
|
@@ -1594,7 +1563,7 @@ function stack(settings) {
|
|
|
1594
1563
|
add(entry) {
|
|
1595
1564
|
// Apply z-index styles based on stack length.
|
|
1596
1565
|
entry.el.style.zIndex = null;
|
|
1597
|
-
const value = getComputedStyle(entry.el)[
|
|
1566
|
+
const value = getComputedStyle(entry.el)["z-index"];
|
|
1598
1567
|
entry.el.style.zIndex = parseInt(value) + stackArray.length + 1;
|
|
1599
1568
|
|
|
1600
1569
|
// Move back to end of stack.
|
|
@@ -1696,12 +1665,12 @@ class Modal extends Collection {
|
|
|
1696
1665
|
return this;
|
|
1697
1666
|
}
|
|
1698
1667
|
initEventListeners() {
|
|
1699
|
-
document.addEventListener(
|
|
1700
|
-
document.addEventListener(
|
|
1668
|
+
document.addEventListener("click", _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
|
|
1669
|
+
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleKeydown$1)[_handleKeydown$1], false);
|
|
1701
1670
|
}
|
|
1702
1671
|
destroyEventListeners() {
|
|
1703
|
-
document.removeEventListener(
|
|
1704
|
-
document.removeEventListener(
|
|
1672
|
+
document.removeEventListener("click", _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
|
|
1673
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleKeydown$1)[_handleKeydown$1], false);
|
|
1705
1674
|
}
|
|
1706
1675
|
register(query) {
|
|
1707
1676
|
const els = getModalElements.call(this, query);
|
|
@@ -1734,14 +1703,14 @@ class Modal extends Collection {
|
|
|
1734
1703
|
var defaults = {
|
|
1735
1704
|
autoInit: false,
|
|
1736
1705
|
// Selectors
|
|
1737
|
-
selectorPopover:
|
|
1738
|
-
selectorArrow:
|
|
1706
|
+
selectorPopover: ".popover",
|
|
1707
|
+
selectorArrow: ".popover__arrow",
|
|
1739
1708
|
// State classes
|
|
1740
|
-
stateActive:
|
|
1709
|
+
stateActive: "is-active",
|
|
1741
1710
|
// Feature settings
|
|
1742
1711
|
eventListeners: true,
|
|
1743
|
-
eventType:
|
|
1744
|
-
placement:
|
|
1712
|
+
eventType: "click",
|
|
1713
|
+
placement: "bottom"
|
|
1745
1714
|
};
|
|
1746
1715
|
|
|
1747
1716
|
function getConfig(el, settings) {
|
|
@@ -1750,19 +1719,19 @@ function getConfig(el, settings) {
|
|
|
1750
1719
|
|
|
1751
1720
|
// Setup the config obj with default values.
|
|
1752
1721
|
const config = {
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1722
|
+
"placement": settings.placement,
|
|
1723
|
+
"event": settings.eventType,
|
|
1724
|
+
"offset": 0,
|
|
1725
|
+
"overflow-padding": 0,
|
|
1726
|
+
"flip-padding": 0,
|
|
1727
|
+
"arrow-element": settings.selectorArrow,
|
|
1728
|
+
"arrow-padding": 0
|
|
1760
1729
|
};
|
|
1761
1730
|
|
|
1762
1731
|
// Loop through config obj.
|
|
1763
1732
|
for (const prop in config) {
|
|
1764
1733
|
// Get the CSS variable property values.
|
|
1765
|
-
const prefix =
|
|
1734
|
+
const prefix = P();
|
|
1766
1735
|
const value = styles.getPropertyValue(`--${prefix}popover-${prop}`).trim();
|
|
1767
1736
|
|
|
1768
1737
|
// If a value was found, replace the default in config obj.
|
|
@@ -1779,7 +1748,7 @@ function getPadding(value) {
|
|
|
1779
1748
|
let padding;
|
|
1780
1749
|
|
|
1781
1750
|
// Split the value by spaces if it's a string.
|
|
1782
|
-
const array = typeof value ===
|
|
1751
|
+
const array = typeof value === "string" ? value.trim().split(" ") : [value];
|
|
1783
1752
|
|
|
1784
1753
|
// Convert individual values to integers.
|
|
1785
1754
|
array.forEach(function (item, index) {
|
|
@@ -1826,32 +1795,32 @@ function getPadding(value) {
|
|
|
1826
1795
|
|
|
1827
1796
|
function getModifiers(options) {
|
|
1828
1797
|
return [{
|
|
1829
|
-
name:
|
|
1798
|
+
name: "offset",
|
|
1830
1799
|
options: {
|
|
1831
|
-
offset: [0, parseInt(options[
|
|
1800
|
+
offset: [0, parseInt(options["offset"], 10)]
|
|
1832
1801
|
}
|
|
1833
1802
|
}, {
|
|
1834
|
-
name:
|
|
1803
|
+
name: "preventOverflow",
|
|
1835
1804
|
options: {
|
|
1836
|
-
padding: getPadding(options[
|
|
1805
|
+
padding: getPadding(options["overflow-padding"])
|
|
1837
1806
|
}
|
|
1838
1807
|
}, {
|
|
1839
|
-
name:
|
|
1808
|
+
name: "flip",
|
|
1840
1809
|
options: {
|
|
1841
|
-
padding: getPadding(options[
|
|
1810
|
+
padding: getPadding(options["flip-padding"])
|
|
1842
1811
|
}
|
|
1843
1812
|
}, {
|
|
1844
|
-
name:
|
|
1813
|
+
name: "arrow",
|
|
1845
1814
|
options: {
|
|
1846
|
-
element: options[
|
|
1847
|
-
padding: getPadding(options[
|
|
1815
|
+
element: options["arrow-element"],
|
|
1816
|
+
padding: getPadding(options["arrow-padding"])
|
|
1848
1817
|
}
|
|
1849
1818
|
}];
|
|
1850
1819
|
}
|
|
1851
1820
|
|
|
1852
1821
|
function getPopover(query) {
|
|
1853
1822
|
// Get the entry from collection.
|
|
1854
|
-
const entry = typeof query ===
|
|
1823
|
+
const entry = typeof query === "string" ? this.get(query) : this.get(query.id);
|
|
1855
1824
|
|
|
1856
1825
|
// Return entry if it was resolved, otherwise throw error.
|
|
1857
1826
|
if (entry) {
|
|
@@ -1863,12 +1832,12 @@ function getPopover(query) {
|
|
|
1863
1832
|
|
|
1864
1833
|
function getPopoverID(obj) {
|
|
1865
1834
|
// If it's a string, return the string.
|
|
1866
|
-
if (typeof obj ===
|
|
1835
|
+
if (typeof obj === "string") {
|
|
1867
1836
|
return obj;
|
|
1868
1837
|
}
|
|
1869
1838
|
|
|
1870
1839
|
// If it's an HTML element.
|
|
1871
|
-
else if (typeof obj.hasAttribute ===
|
|
1840
|
+
else if (typeof obj.hasAttribute === "function") {
|
|
1872
1841
|
// If it's a popover element, return the id.
|
|
1873
1842
|
if (obj.closest(this.settings.selectorPopover)) {
|
|
1874
1843
|
obj = obj.closest(this.settings.selectorPopover);
|
|
@@ -1876,13 +1845,13 @@ function getPopoverID(obj) {
|
|
|
1876
1845
|
}
|
|
1877
1846
|
|
|
1878
1847
|
// If it's a popover trigger, return value of aria-controls.
|
|
1879
|
-
else if (obj.hasAttribute(
|
|
1880
|
-
return obj.getAttribute(
|
|
1848
|
+
else if (obj.hasAttribute("aria-controls")) {
|
|
1849
|
+
return obj.getAttribute("aria-controls");
|
|
1881
1850
|
}
|
|
1882
1851
|
|
|
1883
1852
|
// If it's a popover tooltip trigger, return the value of aria-describedby.
|
|
1884
|
-
else if (obj.hasAttribute(
|
|
1885
|
-
return obj.getAttribute(
|
|
1853
|
+
else if (obj.hasAttribute("aria-describedby")) {
|
|
1854
|
+
return obj.getAttribute("aria-describedby");
|
|
1886
1855
|
}
|
|
1887
1856
|
|
|
1888
1857
|
// Return false if no id was found.
|
|
@@ -1909,11 +1878,11 @@ function getPopoverElements(query) {
|
|
|
1909
1878
|
};
|
|
1910
1879
|
} else if (!trigger) {
|
|
1911
1880
|
return {
|
|
1912
|
-
error: new Error(
|
|
1881
|
+
error: new Error("No popover trigger associated with the provided popover.")
|
|
1913
1882
|
};
|
|
1914
1883
|
} else if (!popover) {
|
|
1915
1884
|
return {
|
|
1916
|
-
error: new Error(
|
|
1885
|
+
error: new Error("No popover associated with the provided popover trigger.")
|
|
1917
1886
|
};
|
|
1918
1887
|
} else {
|
|
1919
1888
|
return {
|
|
@@ -1923,7 +1892,7 @@ function getPopoverElements(query) {
|
|
|
1923
1892
|
}
|
|
1924
1893
|
} else {
|
|
1925
1894
|
return {
|
|
1926
|
-
error: new Error(
|
|
1895
|
+
error: new Error("Could not resolve the popover ID.")
|
|
1927
1896
|
};
|
|
1928
1897
|
}
|
|
1929
1898
|
}
|
|
@@ -1933,25 +1902,25 @@ async function close(query) {
|
|
|
1933
1902
|
const popover = query ? getPopover.call(this, query) : await closeAll.call(this);
|
|
1934
1903
|
|
|
1935
1904
|
// If a modal exists and its state is opened.
|
|
1936
|
-
if (popover && popover.state ===
|
|
1905
|
+
if (popover && popover.state === "opened") {
|
|
1937
1906
|
// Update state class.
|
|
1938
1907
|
popover.el.classList.remove(this.settings.stateActive);
|
|
1939
1908
|
|
|
1940
1909
|
// Update accessibility attribute(s).
|
|
1941
|
-
if (popover.trigger.hasAttribute(
|
|
1942
|
-
popover.trigger.setAttribute(
|
|
1910
|
+
if (popover.trigger.hasAttribute("aria-controls")) {
|
|
1911
|
+
popover.trigger.setAttribute("aria-expanded", "false");
|
|
1943
1912
|
}
|
|
1944
1913
|
|
|
1945
1914
|
// Disable popper event listeners.
|
|
1946
1915
|
popover.popper.setOptions({
|
|
1947
1916
|
modifiers: [{
|
|
1948
|
-
name:
|
|
1917
|
+
name: "eventListeners",
|
|
1949
1918
|
enabled: false
|
|
1950
1919
|
}]
|
|
1951
1920
|
});
|
|
1952
1921
|
|
|
1953
1922
|
// Update popover state.
|
|
1954
|
-
popover.state =
|
|
1923
|
+
popover.state = "closed";
|
|
1955
1924
|
|
|
1956
1925
|
// Clear root trigger if popover trigger matches.
|
|
1957
1926
|
if (popover.trigger === this.trigger) {
|
|
@@ -1965,7 +1934,7 @@ async function close(query) {
|
|
|
1965
1934
|
async function closeAll() {
|
|
1966
1935
|
const result = [];
|
|
1967
1936
|
await Promise.all(this.collection.map(async popover => {
|
|
1968
|
-
if (popover.state ===
|
|
1937
|
+
if (popover.state === "opened") {
|
|
1969
1938
|
result.push(await close.call(this, popover));
|
|
1970
1939
|
}
|
|
1971
1940
|
}));
|
|
@@ -1973,12 +1942,12 @@ async function closeAll() {
|
|
|
1973
1942
|
}
|
|
1974
1943
|
function closeCheck(popover) {
|
|
1975
1944
|
// Only run closeCheck if provided popover is currently open.
|
|
1976
|
-
if (popover.state !=
|
|
1945
|
+
if (popover.state != "opened") return;
|
|
1977
1946
|
|
|
1978
1947
|
// Needed to correctly check which element is currently being focused.
|
|
1979
1948
|
setTimeout(() => {
|
|
1980
1949
|
// Check if trigger or element are being hovered.
|
|
1981
|
-
const isHovered = popover.el.closest(
|
|
1950
|
+
const isHovered = popover.el.closest(":hover") === popover.el || popover.trigger.closest(":hover") === popover.trigger;
|
|
1982
1951
|
|
|
1983
1952
|
// Check if trigger or element are being focused.
|
|
1984
1953
|
const isFocused = document.activeElement.closest(`#${popover.id}, [aria-controls="${popover.id}"], [aria-describedby="${popover.id}"]`);
|
|
@@ -1994,7 +1963,7 @@ function closeCheck(popover) {
|
|
|
1994
1963
|
}
|
|
1995
1964
|
|
|
1996
1965
|
function handleClick(popover) {
|
|
1997
|
-
if (popover.state ===
|
|
1966
|
+
if (popover.state === "opened") {
|
|
1998
1967
|
popover.close();
|
|
1999
1968
|
} else {
|
|
2000
1969
|
this.trigger = popover.trigger;
|
|
@@ -2004,13 +1973,13 @@ function handleClick(popover) {
|
|
|
2004
1973
|
}
|
|
2005
1974
|
function handleKeydown(event) {
|
|
2006
1975
|
switch (event.key) {
|
|
2007
|
-
case
|
|
1976
|
+
case "Escape":
|
|
2008
1977
|
if (this.trigger) {
|
|
2009
1978
|
this.trigger.focus();
|
|
2010
1979
|
}
|
|
2011
1980
|
closeAll.call(this);
|
|
2012
1981
|
return;
|
|
2013
|
-
case
|
|
1982
|
+
case "Tab":
|
|
2014
1983
|
this.collection.forEach(popover => {
|
|
2015
1984
|
closeCheck.call(this, popover);
|
|
2016
1985
|
});
|
|
@@ -2021,7 +1990,7 @@ function handleKeydown(event) {
|
|
|
2021
1990
|
}
|
|
2022
1991
|
function handleDocumentClick(popover) {
|
|
2023
1992
|
const root = this;
|
|
2024
|
-
document.addEventListener(
|
|
1993
|
+
document.addEventListener("click", function _f(event) {
|
|
2025
1994
|
// Check if a popover or its trigger was clicked.
|
|
2026
1995
|
const wasClicked = event.target.closest(`#${popover.id}, [aria-controls="${popover.id}"], [aria-describedby="${popover.id}"]`);
|
|
2027
1996
|
|
|
@@ -2029,14 +1998,14 @@ function handleDocumentClick(popover) {
|
|
|
2029
1998
|
if (wasClicked) {
|
|
2030
1999
|
// If popover element exists and is not active...
|
|
2031
2000
|
if (popover.el && !popover.el.classList.contains(root.settings.stateActive)) {
|
|
2032
|
-
this.removeEventListener(
|
|
2001
|
+
this.removeEventListener("click", _f);
|
|
2033
2002
|
}
|
|
2034
2003
|
} else {
|
|
2035
2004
|
// If popover element exists and is active...
|
|
2036
2005
|
if (popover.el && popover.el.classList.contains(root.settings.stateActive)) {
|
|
2037
2006
|
popover.close();
|
|
2038
2007
|
}
|
|
2039
|
-
this.removeEventListener(
|
|
2008
|
+
this.removeEventListener("click", _f);
|
|
2040
2009
|
}
|
|
2041
2010
|
});
|
|
2042
2011
|
}
|
|
@@ -3845,7 +3814,7 @@ async function deregister(obj) {
|
|
|
3845
3814
|
const entry = this.collection[index];
|
|
3846
3815
|
|
|
3847
3816
|
// If entry is in the opened state, close it.
|
|
3848
|
-
if (entry.state ===
|
|
3817
|
+
if (entry.state === "opened") {
|
|
3849
3818
|
entry.close();
|
|
3850
3819
|
}
|
|
3851
3820
|
|
|
@@ -3895,8 +3864,8 @@ async function open(query) {
|
|
|
3895
3864
|
popover.el.classList.add(this.settings.stateActive);
|
|
3896
3865
|
|
|
3897
3866
|
// Update accessibility attribute(s).
|
|
3898
|
-
if (popover.trigger.hasAttribute(
|
|
3899
|
-
popover.trigger.setAttribute(
|
|
3867
|
+
if (popover.trigger.hasAttribute("aria-controls")) {
|
|
3868
|
+
popover.trigger.setAttribute("aria-expanded", "true");
|
|
3900
3869
|
}
|
|
3901
3870
|
|
|
3902
3871
|
// Update popover config.
|
|
@@ -3904,9 +3873,9 @@ async function open(query) {
|
|
|
3904
3873
|
|
|
3905
3874
|
// Enable popper event listeners and set placement/modifiers.
|
|
3906
3875
|
popover.popper.setOptions({
|
|
3907
|
-
placement: popover.config[
|
|
3876
|
+
placement: popover.config["placement"],
|
|
3908
3877
|
modifiers: [{
|
|
3909
|
-
name:
|
|
3878
|
+
name: "eventListeners",
|
|
3910
3879
|
enabled: true
|
|
3911
3880
|
}, ...getModifiers(popover.config)]
|
|
3912
3881
|
});
|
|
@@ -3915,7 +3884,7 @@ async function open(query) {
|
|
|
3915
3884
|
popover.popper.update();
|
|
3916
3885
|
|
|
3917
3886
|
// Update popover state.
|
|
3918
|
-
popover.state =
|
|
3887
|
+
popover.state = "opened";
|
|
3919
3888
|
|
|
3920
3889
|
// Return the popover.
|
|
3921
3890
|
return popover;
|
|
@@ -3944,7 +3913,7 @@ async function register(el, trigger) {
|
|
|
3944
3913
|
// Setup the popover object.
|
|
3945
3914
|
const entry = _extends({
|
|
3946
3915
|
id: el.id,
|
|
3947
|
-
state:
|
|
3916
|
+
state: "closed",
|
|
3948
3917
|
el: el,
|
|
3949
3918
|
trigger: trigger,
|
|
3950
3919
|
popper: createPopper(trigger, el),
|
|
@@ -3952,8 +3921,8 @@ async function register(el, trigger) {
|
|
|
3952
3921
|
}, methods);
|
|
3953
3922
|
|
|
3954
3923
|
// Set aria-expanded to false if trigger has aria-controls attribute.
|
|
3955
|
-
if (entry.trigger.hasAttribute(
|
|
3956
|
-
entry.trigger.setAttribute(
|
|
3924
|
+
if (entry.trigger.hasAttribute("aria-controls")) {
|
|
3925
|
+
entry.trigger.setAttribute("aria-expanded", "false");
|
|
3957
3926
|
}
|
|
3958
3927
|
|
|
3959
3928
|
// Setup event listeners.
|
|
@@ -3975,18 +3944,18 @@ function registerEventListeners(entry) {
|
|
|
3975
3944
|
// If event listeners aren't already setup.
|
|
3976
3945
|
if (!entry.__eventListeners) {
|
|
3977
3946
|
// Add event listeners based on event type.
|
|
3978
|
-
const eventType = entry.config[
|
|
3947
|
+
const eventType = entry.config["event"];
|
|
3979
3948
|
|
|
3980
3949
|
// If the event type is hover.
|
|
3981
|
-
if (eventType ===
|
|
3950
|
+
if (eventType === "hover") {
|
|
3982
3951
|
// Setup event listeners object for hover.
|
|
3983
3952
|
entry.__eventListeners = [{
|
|
3984
|
-
el: [
|
|
3985
|
-
type: [
|
|
3953
|
+
el: ["trigger"],
|
|
3954
|
+
type: ["mouseenter", "focus"],
|
|
3986
3955
|
listener: open.bind(this, entry)
|
|
3987
3956
|
}, {
|
|
3988
|
-
el: [
|
|
3989
|
-
type: [
|
|
3957
|
+
el: ["el", "trigger"],
|
|
3958
|
+
type: ["mouseleave", "focusout"],
|
|
3990
3959
|
listener: closeCheck.bind(this, entry)
|
|
3991
3960
|
}];
|
|
3992
3961
|
|
|
@@ -4004,8 +3973,8 @@ function registerEventListeners(entry) {
|
|
|
4004
3973
|
else {
|
|
4005
3974
|
// Setup event listeners object for click.
|
|
4006
3975
|
entry.__eventListeners = [{
|
|
4007
|
-
el: [
|
|
4008
|
-
type: [
|
|
3976
|
+
el: ["trigger"],
|
|
3977
|
+
type: ["click"],
|
|
4009
3978
|
listener: handleClick.bind(this, entry)
|
|
4010
3979
|
}];
|
|
4011
3980
|
|
|
@@ -4080,7 +4049,7 @@ class Popover extends Collection {
|
|
|
4080
4049
|
}
|
|
4081
4050
|
|
|
4082
4051
|
// Add keydown global event listener.
|
|
4083
|
-
document.addEventListener(
|
|
4052
|
+
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleKeydown)[_handleKeydown], false);
|
|
4084
4053
|
}
|
|
4085
4054
|
destroyEventListeners(processCollection = true) {
|
|
4086
4055
|
if (processCollection) {
|
|
@@ -4091,7 +4060,7 @@ class Popover extends Collection {
|
|
|
4091
4060
|
}
|
|
4092
4061
|
|
|
4093
4062
|
// Remove keydown global event listener.
|
|
4094
|
-
document.removeEventListener(
|
|
4063
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleKeydown)[_handleKeydown], false);
|
|
4095
4064
|
}
|
|
4096
4065
|
register(query) {
|
|
4097
4066
|
const els = getPopoverElements.call(this, query);
|