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.esm.js
CHANGED
|
@@ -1,75 +1,52 @@
|
|
|
1
|
-
function
|
|
2
|
-
if ("
|
|
3
|
-
|
|
4
|
-
if (void 0 !== e) {
|
|
5
|
-
var i = e.call(t, r || "default");
|
|
6
|
-
if ("object" != typeof i) return i;
|
|
7
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
8
|
-
}
|
|
9
|
-
return ("string" === r ? String : Number)(t);
|
|
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;
|
|
10
4
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return "
|
|
5
|
+
var id = 0;
|
|
6
|
+
function _classPrivateFieldLooseKey(e) {
|
|
7
|
+
return "__private_" + id++ + "_" + e;
|
|
14
8
|
}
|
|
15
|
-
function _defineProperties(
|
|
16
|
-
for (var
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
descriptor.configurable = true;
|
|
20
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
21
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
9
|
+
function _defineProperties(e, r) {
|
|
10
|
+
for (var t = 0; t < r.length; t++) {
|
|
11
|
+
var o = r[t];
|
|
12
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
22
13
|
}
|
|
23
14
|
}
|
|
24
|
-
function _createClass(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
writable: false
|
|
29
|
-
});
|
|
30
|
-
return Constructor;
|
|
15
|
+
function _createClass(e, r, t) {
|
|
16
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
17
|
+
writable: !1
|
|
18
|
+
}), e;
|
|
31
19
|
}
|
|
32
20
|
function _extends() {
|
|
33
|
-
_extends = Object.assign ? Object.assign.bind() : function (
|
|
34
|
-
for (var
|
|
35
|
-
var
|
|
36
|
-
for (var
|
|
37
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
38
|
-
target[key] = source[key];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
21
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
22
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
23
|
+
var t = arguments[e];
|
|
24
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
41
25
|
}
|
|
42
|
-
return
|
|
43
|
-
};
|
|
44
|
-
return _extends.apply(this, arguments);
|
|
26
|
+
return n;
|
|
27
|
+
}, _extends.apply(null, arguments);
|
|
45
28
|
}
|
|
46
|
-
function _inheritsLoose(
|
|
47
|
-
|
|
48
|
-
subClass.prototype.constructor = subClass;
|
|
49
|
-
_setPrototypeOf(subClass, superClass);
|
|
29
|
+
function _inheritsLoose(t, o) {
|
|
30
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
50
31
|
}
|
|
51
|
-
function _setPrototypeOf(
|
|
52
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
return _setPrototypeOf(o, p);
|
|
32
|
+
function _setPrototypeOf(t, e) {
|
|
33
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
34
|
+
return t.__proto__ = e, t;
|
|
35
|
+
}, _setPrototypeOf(t, e);
|
|
57
36
|
}
|
|
58
|
-
function
|
|
59
|
-
if (
|
|
60
|
-
|
|
37
|
+
function _toPrimitive(t, r) {
|
|
38
|
+
if ("object" != typeof t || !t) return t;
|
|
39
|
+
var e = t[Symbol.toPrimitive];
|
|
40
|
+
if (void 0 !== e) {
|
|
41
|
+
var i = e.call(t, r || "default");
|
|
42
|
+
if ("object" != typeof i) return i;
|
|
43
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
61
44
|
}
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
var id = 0;
|
|
65
|
-
function _classPrivateFieldLooseKey(name) {
|
|
66
|
-
return "__private_" + id++ + "_" + name;
|
|
45
|
+
return ("string" === r ? String : Number)(t);
|
|
67
46
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
return receiver;
|
|
47
|
+
function _toPropertyKey(t) {
|
|
48
|
+
var i = _toPrimitive(t, "string");
|
|
49
|
+
return "symbol" == typeof i ? i : i + "";
|
|
73
50
|
}
|
|
74
51
|
|
|
75
52
|
var _handler = /*#__PURE__*/_classPrivateFieldLooseKey("handler");
|
|
@@ -96,8 +73,8 @@ var Breakpoint = /*#__PURE__*/function () {
|
|
|
96
73
|
this.mql = window.matchMedia("(min-width: " + this.value + ")");
|
|
97
74
|
|
|
98
75
|
// Conditionally use addListener() for IE11 support.
|
|
99
|
-
if (typeof this.mql.addEventListener ===
|
|
100
|
-
this.mql.addEventListener(
|
|
76
|
+
if (typeof this.mql.addEventListener === "function") {
|
|
77
|
+
this.mql.addEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]);
|
|
101
78
|
} else {
|
|
102
79
|
this.mql.addListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
|
|
103
80
|
}
|
|
@@ -111,8 +88,8 @@ var Breakpoint = /*#__PURE__*/function () {
|
|
|
111
88
|
if (!this.mql) return this;
|
|
112
89
|
|
|
113
90
|
// Conditionally use removeListener() for IE11 support.
|
|
114
|
-
if (typeof this.mql.removeEventListener ===
|
|
115
|
-
this.mql.removeEventListener(
|
|
91
|
+
if (typeof this.mql.removeEventListener === "function") {
|
|
92
|
+
this.mql.removeEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]);
|
|
116
93
|
} else {
|
|
117
94
|
this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
|
|
118
95
|
}
|
|
@@ -123,7 +100,7 @@ var Breakpoint = /*#__PURE__*/function () {
|
|
|
123
100
|
this.mql = null;
|
|
124
101
|
return this;
|
|
125
102
|
};
|
|
126
|
-
_createClass(Breakpoint, [{
|
|
103
|
+
return _createClass(Breakpoint, [{
|
|
127
104
|
key: "handler",
|
|
128
105
|
get: function get() {
|
|
129
106
|
return _classPrivateFieldLooseBase(this, _handler)[_handler];
|
|
@@ -134,8 +111,8 @@ var Breakpoint = /*#__PURE__*/function () {
|
|
|
134
111
|
set: function set(func) {
|
|
135
112
|
if (this.mql) {
|
|
136
113
|
// Conditionally use removeListener() for IE11 support.
|
|
137
|
-
if (typeof this.mql.removeEventListener ===
|
|
138
|
-
this.mql.removeEventListener(
|
|
114
|
+
if (typeof this.mql.removeEventListener === "function") {
|
|
115
|
+
this.mql.removeEventListener("change", _classPrivateFieldLooseBase(this, _handler)[_handler]);
|
|
139
116
|
} else {
|
|
140
117
|
this.mql.removeListener(_classPrivateFieldLooseBase(this, _handler)[_handler]);
|
|
141
118
|
}
|
|
@@ -143,7 +120,6 @@ var Breakpoint = /*#__PURE__*/function () {
|
|
|
143
120
|
_classPrivateFieldLooseBase(this, _handler)[_handler] = func;
|
|
144
121
|
}
|
|
145
122
|
}]);
|
|
146
|
-
return Breakpoint;
|
|
147
123
|
}();
|
|
148
124
|
|
|
149
125
|
function _settle(pact, state, value) {
|
|
@@ -359,7 +335,7 @@ var Collection = /*#__PURE__*/function () {
|
|
|
359
335
|
};
|
|
360
336
|
_proto.get = function get(value, key) {
|
|
361
337
|
if (key === void 0) {
|
|
362
|
-
key =
|
|
338
|
+
key = "id";
|
|
363
339
|
}
|
|
364
340
|
return this.collection.find(function (item) {
|
|
365
341
|
return item[key] === value;
|
|
@@ -368,31 +344,6 @@ var Collection = /*#__PURE__*/function () {
|
|
|
368
344
|
return Collection;
|
|
369
345
|
}();
|
|
370
346
|
|
|
371
|
-
const not = {
|
|
372
|
-
inert: ':not([inert]):not([inert] *)',
|
|
373
|
-
negTabIndex: ':not([tabindex^="-"])',
|
|
374
|
-
disabled: ':not(:disabled)',
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
var e = [
|
|
378
|
-
`a[href]${not.inert}${not.negTabIndex}`,
|
|
379
|
-
`area[href]${not.inert}${not.negTabIndex}`,
|
|
380
|
-
`input:not([type="hidden"]):not([type="radio"])${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
381
|
-
`input[type="radio"]${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
382
|
-
`select${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
383
|
-
`textarea${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
384
|
-
`button${not.inert}${not.negTabIndex}${not.disabled}`,
|
|
385
|
-
`details${not.inert} > summary:first-of-type${not.negTabIndex}`,
|
|
386
|
-
// Discard until Firefox supports `:has()`
|
|
387
|
-
// See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
|
|
388
|
-
// `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
|
|
389
|
-
`iframe${not.inert}${not.negTabIndex}`,
|
|
390
|
-
`audio[controls]${not.inert}${not.negTabIndex}`,
|
|
391
|
-
`video[controls]${not.inert}${not.negTabIndex}`,
|
|
392
|
-
`[contenteditable]${not.inert}${not.negTabIndex}`,
|
|
393
|
-
`[tabindex]${not.inert}${not.negTabIndex}`,
|
|
394
|
-
];
|
|
395
|
-
|
|
396
347
|
var _focusable = /*#__PURE__*/_classPrivateFieldLooseKey("focusable");
|
|
397
348
|
var _handleFocusTrap = /*#__PURE__*/_classPrivateFieldLooseKey("handleFocusTrap");
|
|
398
349
|
var _handleFocusLock = /*#__PURE__*/_classPrivateFieldLooseKey("handleFocusLock");
|
|
@@ -402,7 +353,7 @@ var FocusTrap = /*#__PURE__*/function () {
|
|
|
402
353
|
el = null;
|
|
403
354
|
}
|
|
404
355
|
if (selectorFocus === void 0) {
|
|
405
|
-
selectorFocus =
|
|
356
|
+
selectorFocus = "[data-focus]";
|
|
406
357
|
}
|
|
407
358
|
Object.defineProperty(this, _focusable, {
|
|
408
359
|
writable: true,
|
|
@@ -441,8 +392,8 @@ var FocusTrap = /*#__PURE__*/function () {
|
|
|
441
392
|
this.focusable = [];
|
|
442
393
|
|
|
443
394
|
// Remove event listeners
|
|
444
|
-
document.removeEventListener(
|
|
445
|
-
document.removeEventListener(
|
|
395
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]);
|
|
396
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);
|
|
446
397
|
};
|
|
447
398
|
_proto.focus = function focus(el, selectorFocus) {
|
|
448
399
|
if (el === void 0) {
|
|
@@ -468,7 +419,8 @@ var FocusTrap = /*#__PURE__*/function () {
|
|
|
468
419
|
var initScrollTop = el.scrollTop;
|
|
469
420
|
|
|
470
421
|
// Query for all the focusable elements.
|
|
471
|
-
var
|
|
422
|
+
var selector = focusableSelectors.join(",");
|
|
423
|
+
var els = el.querySelectorAll(selector);
|
|
472
424
|
|
|
473
425
|
// Loop through all focusable elements.
|
|
474
426
|
els.forEach(function (el) {
|
|
@@ -488,7 +440,7 @@ var FocusTrap = /*#__PURE__*/function () {
|
|
|
488
440
|
// Return the focusable array.
|
|
489
441
|
return focusable;
|
|
490
442
|
};
|
|
491
|
-
_createClass(FocusTrap, [{
|
|
443
|
+
return _createClass(FocusTrap, [{
|
|
492
444
|
key: "focusable",
|
|
493
445
|
get: function get() {
|
|
494
446
|
return _classPrivateFieldLooseBase(this, _focusable)[_focusable];
|
|
@@ -499,11 +451,11 @@ var FocusTrap = /*#__PURE__*/function () {
|
|
|
499
451
|
|
|
500
452
|
// Apply event listeners based on new focusable array length.
|
|
501
453
|
if (_classPrivateFieldLooseBase(this, _focusable)[_focusable].length) {
|
|
502
|
-
document.removeEventListener(
|
|
503
|
-
document.addEventListener(
|
|
454
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);
|
|
455
|
+
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]);
|
|
504
456
|
} else {
|
|
505
|
-
document.removeEventListener(
|
|
506
|
-
document.addEventListener(
|
|
457
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusTrap)[_handleFocusTrap]);
|
|
458
|
+
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleFocusLock)[_handleFocusLock]);
|
|
507
459
|
}
|
|
508
460
|
}
|
|
509
461
|
}, {
|
|
@@ -517,11 +469,17 @@ var FocusTrap = /*#__PURE__*/function () {
|
|
|
517
469
|
return this.focusable[this.focusable.length - 1];
|
|
518
470
|
}
|
|
519
471
|
}]);
|
|
520
|
-
return FocusTrap;
|
|
521
472
|
}();
|
|
473
|
+
|
|
474
|
+
// This has been copied over from focusable-selectors package and modified.
|
|
475
|
+
// https://github.com/KittyGiraudel/focusable-selectors
|
|
476
|
+
var notInert = ":not([inert])"; // Previously `:not([inert]):not([inert] *)`
|
|
477
|
+
var notNegTabIndex = ":not([tabindex^=\"-\"])";
|
|
478
|
+
var notDisabled = ":not(:disabled)";
|
|
479
|
+
var 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];
|
|
522
480
|
function handleFocusTrap(event) {
|
|
523
481
|
// Check if the click was a tab and return if not.
|
|
524
|
-
var isTab = event.key ===
|
|
482
|
+
var isTab = event.key === "Tab" || event.keyCode === 9;
|
|
525
483
|
if (!isTab) return;
|
|
526
484
|
|
|
527
485
|
// If the shift key is pressed.
|
|
@@ -543,18 +501,18 @@ function handleFocusTrap(event) {
|
|
|
543
501
|
}
|
|
544
502
|
function handleFocusLock(event) {
|
|
545
503
|
// Ignore the tab key by preventing default.
|
|
546
|
-
var isTab = event.key ===
|
|
504
|
+
var isTab = event.key === "Tab" || event.keyCode === 9;
|
|
547
505
|
if (isTab) event.preventDefault();
|
|
548
506
|
}
|
|
549
507
|
|
|
550
508
|
function getConfig$1(el, dataConfig) {
|
|
551
|
-
var string = el.getAttribute("data-" + dataConfig) ||
|
|
552
|
-
var json = string.replace(/'/g,
|
|
509
|
+
var string = el.getAttribute("data-" + dataConfig) || "";
|
|
510
|
+
var json = string.replace(/'/g, "\"");
|
|
553
511
|
return json ? JSON.parse(json) : {};
|
|
554
512
|
}
|
|
555
513
|
|
|
556
514
|
function getPrefix() {
|
|
557
|
-
return getComputedStyle(document.body).getPropertyValue(
|
|
515
|
+
return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim();
|
|
558
516
|
}
|
|
559
517
|
|
|
560
518
|
function localStore(key, enable) {
|
|
@@ -599,18 +557,18 @@ function teleport(what, where, how) {
|
|
|
599
557
|
where = isComment || isElement ? where : document.querySelector(where);
|
|
600
558
|
|
|
601
559
|
// If ref is a comment, set teleport type to 'after'.
|
|
602
|
-
if (isComment) how =
|
|
560
|
+
if (isComment) how = "after";
|
|
603
561
|
|
|
604
562
|
// Must be a valid reference element and method.
|
|
605
563
|
if (!where) throw new Error("Not a valid teleport reference: '" + where + "'");
|
|
606
|
-
if (typeof where[how] !=
|
|
564
|
+
if (typeof where[how] != "function") throw new Error("Not a valid teleport method: '" + how + "'");
|
|
607
565
|
|
|
608
566
|
// Initial return ref is null.
|
|
609
567
|
var returnRef = null;
|
|
610
568
|
|
|
611
569
|
// If ref is not a comment, set a return reference comment.
|
|
612
570
|
if (!isComment) {
|
|
613
|
-
returnRef = document.createComment(
|
|
571
|
+
returnRef = document.createComment("teleported #" + what.id);
|
|
614
572
|
what.before(returnRef);
|
|
615
573
|
}
|
|
616
574
|
|
|
@@ -636,7 +594,7 @@ var openTransition = function openTransition(el, settings) {
|
|
|
636
594
|
el.classList.add(settings.stateOpening);
|
|
637
595
|
|
|
638
596
|
// Add event listener for when the transition is finished.
|
|
639
|
-
el.addEventListener(
|
|
597
|
+
el.addEventListener("transitionend", function _f(event) {
|
|
640
598
|
// Prevent child transition bubbling from firing this event.
|
|
641
599
|
if (event.target != el) return;
|
|
642
600
|
|
|
@@ -646,7 +604,7 @@ var openTransition = function openTransition(el, settings) {
|
|
|
646
604
|
|
|
647
605
|
// Resolve the promise and remove the event listener.
|
|
648
606
|
resolve(el);
|
|
649
|
-
this.removeEventListener(
|
|
607
|
+
this.removeEventListener("transitionend", _f);
|
|
650
608
|
});
|
|
651
609
|
} else {
|
|
652
610
|
// Toggle final opened state classes and resolve the promise.
|
|
@@ -665,7 +623,7 @@ var closeTransition = function closeTransition(el, settings) {
|
|
|
665
623
|
el.classList.remove(settings.stateOpened);
|
|
666
624
|
|
|
667
625
|
// Add event listener for when the transition is finished.
|
|
668
|
-
el.addEventListener(
|
|
626
|
+
el.addEventListener("transitionend", function _f(event) {
|
|
669
627
|
// Prevent child transition bubbling from firing this event.
|
|
670
628
|
if (event.target != el) return;
|
|
671
629
|
|
|
@@ -675,7 +633,7 @@ var closeTransition = function closeTransition(el, settings) {
|
|
|
675
633
|
|
|
676
634
|
// Resolve the promise and remove the event listener.
|
|
677
635
|
resolve(el);
|
|
678
|
-
this.removeEventListener(
|
|
636
|
+
this.removeEventListener("transitionend", _f);
|
|
679
637
|
});
|
|
680
638
|
} else {
|
|
681
639
|
// Toggle final closed state classes and resolve the promise.
|
|
@@ -691,24 +649,17 @@ function setOverflowHidden(state, selector) {
|
|
|
691
649
|
var els = document.querySelectorAll(selector);
|
|
692
650
|
els.forEach(function (el) {
|
|
693
651
|
if (state) {
|
|
694
|
-
el.style.overflow =
|
|
652
|
+
el.style.overflow = "hidden";
|
|
695
653
|
} else {
|
|
696
|
-
el.style.removeProperty(
|
|
654
|
+
el.style.removeProperty("overflow");
|
|
697
655
|
}
|
|
698
656
|
});
|
|
699
657
|
}
|
|
700
658
|
}
|
|
701
659
|
function setInert(state, selector) {
|
|
702
660
|
if (selector) {
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
if (state) {
|
|
706
|
-
el.inert = true;
|
|
707
|
-
el.setAttribute('aria-hidden', true);
|
|
708
|
-
} else {
|
|
709
|
-
el.inert = null;
|
|
710
|
-
el.removeAttribute('aria-hidden');
|
|
711
|
-
}
|
|
661
|
+
document.querySelectorAll(selector).forEach(function (el) {
|
|
662
|
+
el.inert = state;
|
|
712
663
|
});
|
|
713
664
|
}
|
|
714
665
|
}
|
|
@@ -736,8 +687,8 @@ var index = {
|
|
|
736
687
|
|
|
737
688
|
var defaults$3 = {
|
|
738
689
|
autoInit: false,
|
|
739
|
-
stateAttr:
|
|
740
|
-
stateValue:
|
|
690
|
+
stateAttr: "aria-checked",
|
|
691
|
+
stateValue: "mixed"
|
|
741
692
|
};
|
|
742
693
|
|
|
743
694
|
var Checkbox = /*#__PURE__*/function () {
|
|
@@ -756,10 +707,10 @@ var Checkbox = /*#__PURE__*/function () {
|
|
|
756
707
|
var selector = "[" + this.settings.stateAttr + "=\"" + this.settings.stateValue + "\"]";
|
|
757
708
|
var mixed = document.querySelectorAll(selector);
|
|
758
709
|
this.setIndeterminate(mixed);
|
|
759
|
-
document.addEventListener(
|
|
710
|
+
document.addEventListener("click", this.__handlerClick, false);
|
|
760
711
|
};
|
|
761
712
|
_proto.destroy = function destroy() {
|
|
762
|
-
document.removeEventListener(
|
|
713
|
+
document.removeEventListener("click", this.__handlerClick, false);
|
|
763
714
|
};
|
|
764
715
|
_proto.handlerClick = function handlerClick(event) {
|
|
765
716
|
var selector = "[" + this.settings.stateAttr + "=\"" + this.settings.stateValue + "\"]";
|
|
@@ -802,30 +753,30 @@ var Checkbox = /*#__PURE__*/function () {
|
|
|
802
753
|
var defaults$2 = {
|
|
803
754
|
autoInit: false,
|
|
804
755
|
// Data attributes
|
|
805
|
-
dataOpen:
|
|
806
|
-
dataClose:
|
|
807
|
-
dataToggle:
|
|
808
|
-
dataBreakpoint:
|
|
809
|
-
dataConfig:
|
|
756
|
+
dataOpen: "drawer-open",
|
|
757
|
+
dataClose: "drawer-close",
|
|
758
|
+
dataToggle: "drawer-toggle",
|
|
759
|
+
dataBreakpoint: "drawer-breakpoint",
|
|
760
|
+
dataConfig: "drawer-config",
|
|
810
761
|
// Selectors
|
|
811
|
-
selectorDrawer:
|
|
812
|
-
selectorDialog:
|
|
813
|
-
selectorFocus:
|
|
762
|
+
selectorDrawer: ".drawer",
|
|
763
|
+
selectorDialog: ".drawer__dialog",
|
|
764
|
+
selectorFocus: "[data-focus]",
|
|
814
765
|
selectorInert: null,
|
|
815
|
-
selectorOverflow:
|
|
766
|
+
selectorOverflow: "body",
|
|
816
767
|
// State classes
|
|
817
|
-
stateOpened:
|
|
818
|
-
stateOpening:
|
|
819
|
-
stateClosing:
|
|
820
|
-
stateClosed:
|
|
768
|
+
stateOpened: "is-opened",
|
|
769
|
+
stateOpening: "is-opening",
|
|
770
|
+
stateClosing: "is-closing",
|
|
771
|
+
stateClosed: "is-closed",
|
|
821
772
|
// Classes
|
|
822
|
-
classModal:
|
|
773
|
+
classModal: "drawer_modal",
|
|
823
774
|
// Feature toggles
|
|
824
775
|
breakpoints: null,
|
|
825
|
-
customEventPrefix:
|
|
776
|
+
customEventPrefix: "drawer:",
|
|
826
777
|
eventListeners: true,
|
|
827
778
|
store: true,
|
|
828
|
-
storeKey:
|
|
779
|
+
storeKey: "VB:DrawerState",
|
|
829
780
|
setTabindex: true,
|
|
830
781
|
transition: true
|
|
831
782
|
};
|
|
@@ -840,7 +791,7 @@ function handleClick$2(event) {
|
|
|
840
791
|
|
|
841
792
|
// If it's a toggle trigger...
|
|
842
793
|
if (trigger.matches("[data-" + this.settings.dataToggle + "]")) {
|
|
843
|
-
var selectors = trigger.getAttribute("data-" + this.settings.dataToggle).trim().split(
|
|
794
|
+
var selectors = trigger.getAttribute("data-" + this.settings.dataToggle).trim().split(" ");
|
|
844
795
|
selectors.forEach(function (selector) {
|
|
845
796
|
// Get the entry from collection using the attribute value.
|
|
846
797
|
var entry = _this.get(selector);
|
|
@@ -853,7 +804,7 @@ function handleClick$2(event) {
|
|
|
853
804
|
|
|
854
805
|
// If it's a open trigger...
|
|
855
806
|
if (trigger.matches("[data-" + this.settings.dataOpen + "]")) {
|
|
856
|
-
var _selectors = trigger.getAttribute("data-" + this.settings.dataOpen).trim().split(
|
|
807
|
+
var _selectors = trigger.getAttribute("data-" + this.settings.dataOpen).trim().split(" ");
|
|
857
808
|
_selectors.forEach(function (selector) {
|
|
858
809
|
// Get the entry from collection using the attribute value.
|
|
859
810
|
var entry = _this.get(selector);
|
|
@@ -866,7 +817,7 @@ function handleClick$2(event) {
|
|
|
866
817
|
|
|
867
818
|
// If it's a close trigger...
|
|
868
819
|
if (trigger.matches("[data-" + this.settings.dataClose + "]")) {
|
|
869
|
-
var _selectors2 = trigger.getAttribute("data-" + this.settings.dataClose).trim().split(
|
|
820
|
+
var _selectors2 = trigger.getAttribute("data-" + this.settings.dataClose).trim().split(" ");
|
|
870
821
|
_selectors2.forEach(function (selector) {
|
|
871
822
|
if (selector) {
|
|
872
823
|
// Get the entry from collection using the attribute value.
|
|
@@ -893,7 +844,7 @@ function handleClick$2(event) {
|
|
|
893
844
|
}
|
|
894
845
|
}
|
|
895
846
|
function handleKeydown$2(event) {
|
|
896
|
-
if (event.key ===
|
|
847
|
+
if (event.key === "Escape") {
|
|
897
848
|
var modal = this.activeModal;
|
|
898
849
|
if (modal) this.close(modal);
|
|
899
850
|
}
|
|
@@ -920,27 +871,27 @@ var deregister$2 = function deregister(obj, close) {
|
|
|
920
871
|
if (index >= 0) {
|
|
921
872
|
var _temp2 = function _temp2() {
|
|
922
873
|
// Remove entry from local store.
|
|
923
|
-
_this.store.set(
|
|
874
|
+
_this.store.set(entry.id);
|
|
924
875
|
|
|
925
876
|
// Unmount the MatchMedia functionality.
|
|
926
|
-
|
|
877
|
+
entry.unmountBreakpoint();
|
|
927
878
|
|
|
928
879
|
// Delete properties from collection entry.
|
|
929
|
-
Object.getOwnPropertyNames(
|
|
930
|
-
delete
|
|
880
|
+
Object.getOwnPropertyNames(entry).forEach(function (prop) {
|
|
881
|
+
delete entry[prop];
|
|
931
882
|
});
|
|
932
883
|
|
|
933
884
|
// Remove entry from collection.
|
|
934
885
|
_this.collection.splice(index, 1);
|
|
935
886
|
};
|
|
936
887
|
// Get the collection entry.
|
|
937
|
-
var
|
|
888
|
+
var entry = _this.collection[index];
|
|
938
889
|
|
|
939
890
|
// If entry is in the opened state.
|
|
940
891
|
var _temp = function () {
|
|
941
|
-
if (close &&
|
|
892
|
+
if (close && entry.state === "opened") {
|
|
942
893
|
// Close the drawer.
|
|
943
|
-
return Promise.resolve(
|
|
894
|
+
return Promise.resolve(entry.close(false)).then(function () {});
|
|
944
895
|
}
|
|
945
896
|
}();
|
|
946
897
|
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
|
@@ -952,12 +903,12 @@ var deregister$2 = function deregister(obj, close) {
|
|
|
952
903
|
}
|
|
953
904
|
};
|
|
954
905
|
|
|
955
|
-
function
|
|
906
|
+
function P() {
|
|
956
907
|
return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim();
|
|
957
908
|
}
|
|
958
909
|
|
|
959
910
|
function getBreakpoint(drawer) {
|
|
960
|
-
var prefix =
|
|
911
|
+
var prefix = P();
|
|
961
912
|
var bp = drawer.getAttribute("data-" + this.settings.dataBreakpoint);
|
|
962
913
|
if (this.settings.breakpoints && this.settings.breakpoints[bp]) {
|
|
963
914
|
return this.settings.breakpoints[bp];
|
|
@@ -970,7 +921,7 @@ function getBreakpoint(drawer) {
|
|
|
970
921
|
|
|
971
922
|
function getDrawer(query) {
|
|
972
923
|
// Get the entry from collection.
|
|
973
|
-
var entry = typeof query ===
|
|
924
|
+
var entry = typeof query === "string" ? this.get(query) : this.get(query.id);
|
|
974
925
|
|
|
975
926
|
// Return entry if it was resolved, otherwise throw error.
|
|
976
927
|
if (entry) {
|
|
@@ -982,12 +933,12 @@ function getDrawer(query) {
|
|
|
982
933
|
|
|
983
934
|
function getDrawerID(obj) {
|
|
984
935
|
// If it's a string, return the string.
|
|
985
|
-
if (typeof obj ===
|
|
936
|
+
if (typeof obj === "string") {
|
|
986
937
|
return obj;
|
|
987
938
|
}
|
|
988
939
|
|
|
989
940
|
// If it's an HTML element.
|
|
990
|
-
else if (typeof obj.hasAttribute ===
|
|
941
|
+
else if (typeof obj.hasAttribute === "function") {
|
|
991
942
|
// If it's a drawer open trigger, return data value.
|
|
992
943
|
if (obj.hasAttribute("data-" + this.settings.dataOpen)) {
|
|
993
944
|
return obj.getAttribute("data-" + this.settings.dataOpen);
|
|
@@ -1033,7 +984,7 @@ function getDrawerElements(query) {
|
|
|
1033
984
|
};
|
|
1034
985
|
} else if (!dialog) {
|
|
1035
986
|
return {
|
|
1036
|
-
error: new Error(
|
|
987
|
+
error: new Error("Drawer is missing dialog element.")
|
|
1037
988
|
};
|
|
1038
989
|
} else {
|
|
1039
990
|
return {
|
|
@@ -1043,7 +994,7 @@ function getDrawerElements(query) {
|
|
|
1043
994
|
}
|
|
1044
995
|
} else {
|
|
1045
996
|
return {
|
|
1046
|
-
error: new Error(
|
|
997
|
+
error: new Error("Could not resolve the drawer ID.")
|
|
1047
998
|
};
|
|
1048
999
|
}
|
|
1049
1000
|
}
|
|
@@ -1054,7 +1005,7 @@ var initialState = function initialState(entry) {
|
|
|
1054
1005
|
var _temp2 = function () {
|
|
1055
1006
|
if (_this.store.get(entry.id)) {
|
|
1056
1007
|
var _temp = function () {
|
|
1057
|
-
if (_this.store.get(entry.id) ===
|
|
1008
|
+
if (_this.store.get(entry.id) === "opened") {
|
|
1058
1009
|
return Promise.resolve(entry.open(false, false)).then(function () {});
|
|
1059
1010
|
} else {
|
|
1060
1011
|
return Promise.resolve(entry.close(false, false)).then(function () {});
|
|
@@ -1063,7 +1014,7 @@ var initialState = function initialState(entry) {
|
|
|
1063
1014
|
if (_temp && _temp.then) return _temp.then(function () {});
|
|
1064
1015
|
} else if (entry.el.classList.contains(_this.settings.stateOpened)) {
|
|
1065
1016
|
// Update drawer state.
|
|
1066
|
-
entry.state =
|
|
1017
|
+
entry.state = "opened";
|
|
1067
1018
|
} else {
|
|
1068
1019
|
// Remove transition state classes.
|
|
1069
1020
|
entry.el.classList.remove(_this.settings.stateOpening);
|
|
@@ -1084,9 +1035,9 @@ var initialState = function initialState(entry) {
|
|
|
1084
1035
|
|
|
1085
1036
|
function updateFocusState$1(entry) {
|
|
1086
1037
|
// Check if there's an active modal
|
|
1087
|
-
if (entry.state ===
|
|
1038
|
+
if (entry.state === "opened") {
|
|
1088
1039
|
// Mount the focus trap on the opened drawer.
|
|
1089
|
-
if (entry.mode ===
|
|
1040
|
+
if (entry.mode === "modal") {
|
|
1090
1041
|
this.focusTrap.mount(entry.dialog, this.settings.selectorFocus);
|
|
1091
1042
|
} else {
|
|
1092
1043
|
this.focusTrap.focus(entry.dialog, this.settings.selectorFocus);
|
|
@@ -1113,7 +1064,7 @@ var open$2 = function open(query, transition, focus) {
|
|
|
1113
1064
|
}
|
|
1114
1065
|
|
|
1115
1066
|
// Dispatch custom opened event.
|
|
1116
|
-
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix +
|
|
1067
|
+
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "opened", {
|
|
1117
1068
|
detail: _this,
|
|
1118
1069
|
bubbles: true
|
|
1119
1070
|
}));
|
|
@@ -1133,17 +1084,17 @@ var open$2 = function open(query, transition, focus) {
|
|
|
1133
1084
|
|
|
1134
1085
|
// If drawer is closed.
|
|
1135
1086
|
var _temp = function () {
|
|
1136
|
-
if (drawer.state ===
|
|
1087
|
+
if (drawer.state === "closed") {
|
|
1137
1088
|
// Update drawer state.
|
|
1138
|
-
drawer.state =
|
|
1089
|
+
drawer.state = "opening";
|
|
1139
1090
|
|
|
1140
1091
|
// Run the open transition.
|
|
1141
1092
|
return Promise.resolve(openTransition(drawer.el, config)).then(function () {
|
|
1142
1093
|
// Update the global state if mode is modal.
|
|
1143
|
-
if (drawer.mode ===
|
|
1094
|
+
if (drawer.mode === "modal") updateGlobalState(true, config);
|
|
1144
1095
|
|
|
1145
1096
|
// Update drawer state.
|
|
1146
|
-
drawer.state =
|
|
1097
|
+
drawer.state = "opened";
|
|
1147
1098
|
});
|
|
1148
1099
|
}
|
|
1149
1100
|
}();
|
|
@@ -1170,9 +1121,9 @@ var close$2 = function close(query, transition, focus) {
|
|
|
1170
1121
|
|
|
1171
1122
|
// If drawer is opened.
|
|
1172
1123
|
var _temp = function () {
|
|
1173
|
-
if (drawer.state ===
|
|
1124
|
+
if (drawer.state === "opened") {
|
|
1174
1125
|
// Update drawer state.
|
|
1175
|
-
drawer.state =
|
|
1126
|
+
drawer.state = "closing";
|
|
1176
1127
|
|
|
1177
1128
|
// Remove focus from active element.
|
|
1178
1129
|
document.activeElement.blur();
|
|
@@ -1180,7 +1131,7 @@ var close$2 = function close(query, transition, focus) {
|
|
|
1180
1131
|
// Run the close transition.
|
|
1181
1132
|
return Promise.resolve(closeTransition(drawer.el, config)).then(function () {
|
|
1182
1133
|
// Update the global state if mode is modal.
|
|
1183
|
-
if (drawer.mode ===
|
|
1134
|
+
if (drawer.mode === "modal") updateGlobalState(false, config);
|
|
1184
1135
|
|
|
1185
1136
|
// Set focus to the trigger element if the focus param is true.
|
|
1186
1137
|
if (focus) {
|
|
@@ -1188,10 +1139,10 @@ var close$2 = function close(query, transition, focus) {
|
|
|
1188
1139
|
}
|
|
1189
1140
|
|
|
1190
1141
|
// Update drawer state.
|
|
1191
|
-
drawer.state =
|
|
1142
|
+
drawer.state = "closed";
|
|
1192
1143
|
|
|
1193
1144
|
// Dispatch custom closed event.
|
|
1194
|
-
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix +
|
|
1145
|
+
drawer.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "closed", {
|
|
1195
1146
|
detail: _this,
|
|
1196
1147
|
bubbles: true
|
|
1197
1148
|
}));
|
|
@@ -1214,7 +1165,7 @@ var toggle = function toggle(query, transition, focus) {
|
|
|
1214
1165
|
var drawer = getDrawer.call(_this, query);
|
|
1215
1166
|
|
|
1216
1167
|
// Open or close the drawer based on its current state.
|
|
1217
|
-
if (drawer.state ===
|
|
1168
|
+
if (drawer.state === "closed") {
|
|
1218
1169
|
return Promise.resolve(open$2.call(_this, drawer, transition, focus));
|
|
1219
1170
|
} else {
|
|
1220
1171
|
return Promise.resolve(close$2.call(_this, drawer, transition, focus));
|
|
@@ -1230,21 +1181,21 @@ var toModal = function toModal(entry) {
|
|
|
1230
1181
|
// Get the drawer configuration.
|
|
1231
1182
|
|
|
1232
1183
|
// Add the modal class.
|
|
1233
|
-
entry.el.classList.add(entry.getSetting(
|
|
1184
|
+
entry.el.classList.add(entry.getSetting("classModal"));
|
|
1234
1185
|
|
|
1235
1186
|
// Set aria-modal attribute to true.
|
|
1236
|
-
entry.dialog.setAttribute(
|
|
1187
|
+
entry.dialog.setAttribute("aria-modal", "true");
|
|
1237
1188
|
|
|
1238
1189
|
// If there isn't a stored state but also has the opened state class...
|
|
1239
|
-
if (!_this2.store.get(entry.id) && entry.el.classList.contains(entry.getSetting(
|
|
1190
|
+
if (!_this2.store.get(entry.id) && entry.el.classList.contains(entry.getSetting("stateOpened"))) {
|
|
1240
1191
|
// Save the opened state in local store.
|
|
1241
|
-
_this2.store.set(entry.id,
|
|
1192
|
+
_this2.store.set(entry.id, "opened");
|
|
1242
1193
|
}
|
|
1243
1194
|
|
|
1244
1195
|
// Modal drawer defaults to closed state.
|
|
1245
1196
|
return Promise.resolve(close$2.call(_this2, entry, false, false)).then(function () {
|
|
1246
1197
|
// Dispatch custom switch event.
|
|
1247
|
-
entry.el.dispatchEvent(new CustomEvent(entry.getSetting(
|
|
1198
|
+
entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "switchMode", {
|
|
1248
1199
|
detail: _this2,
|
|
1249
1200
|
bubbles: true
|
|
1250
1201
|
}));
|
|
@@ -1260,10 +1211,10 @@ var toInline = function toInline(entry) {
|
|
|
1260
1211
|
try {
|
|
1261
1212
|
var _this = this;
|
|
1262
1213
|
// Remove the modal class.
|
|
1263
|
-
entry.el.classList.remove(entry.getSetting(
|
|
1214
|
+
entry.el.classList.remove(entry.getSetting("classModal"));
|
|
1264
1215
|
|
|
1265
1216
|
// Remove the aria-modal attribute.
|
|
1266
|
-
entry.dialog.removeAttribute(
|
|
1217
|
+
entry.dialog.removeAttribute("aria-modal");
|
|
1267
1218
|
|
|
1268
1219
|
// Update the global state.
|
|
1269
1220
|
updateGlobalState(false, _extends({}, _this.settings, entry.settings));
|
|
@@ -1274,7 +1225,7 @@ var toInline = function toInline(entry) {
|
|
|
1274
1225
|
// Setup initial state.
|
|
1275
1226
|
return Promise.resolve(initialState.call(_this, entry)).then(function () {
|
|
1276
1227
|
// Dispatch custom switch event.
|
|
1277
|
-
entry.el.dispatchEvent(new CustomEvent(entry.getSetting(
|
|
1228
|
+
entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "switchMode", {
|
|
1278
1229
|
detail: _this,
|
|
1279
1230
|
bubbles: true
|
|
1280
1231
|
}));
|
|
@@ -1288,9 +1239,9 @@ var toInline = function toInline(entry) {
|
|
|
1288
1239
|
};
|
|
1289
1240
|
function switchMode(entry) {
|
|
1290
1241
|
switch (entry.mode) {
|
|
1291
|
-
case
|
|
1242
|
+
case "inline":
|
|
1292
1243
|
return toInline.call(this, entry);
|
|
1293
|
-
case
|
|
1244
|
+
case "modal":
|
|
1294
1245
|
return toModal.call(this, entry);
|
|
1295
1246
|
default:
|
|
1296
1247
|
throw new Error("\"" + entry.mode + "\" is not a valid drawer mode.");
|
|
@@ -1333,7 +1284,7 @@ var register$2 = function register(el, dialog) {
|
|
|
1333
1284
|
return this;
|
|
1334
1285
|
},
|
|
1335
1286
|
handleBreakpoint: function handleBreakpoint(event) {
|
|
1336
|
-
this.mode = event.matches ?
|
|
1287
|
+
this.mode = event.matches ? "inline" : "modal";
|
|
1337
1288
|
return this;
|
|
1338
1289
|
},
|
|
1339
1290
|
getSetting: function getSetting(key) {
|
|
@@ -1357,8 +1308,8 @@ var register$2 = function register(el, dialog) {
|
|
|
1357
1308
|
set state(value) {
|
|
1358
1309
|
__state = value;
|
|
1359
1310
|
// Save 'opened' and 'closed' states to store if mode is inline.
|
|
1360
|
-
if (value ===
|
|
1361
|
-
if (this.mode ===
|
|
1311
|
+
if (value === "opened" || value === "closed") {
|
|
1312
|
+
if (this.mode === "inline") root.store.set(this.id, this.state);
|
|
1362
1313
|
}
|
|
1363
1314
|
},
|
|
1364
1315
|
get mode() {
|
|
@@ -1371,23 +1322,23 @@ var register$2 = function register(el, dialog) {
|
|
|
1371
1322
|
}, methods);
|
|
1372
1323
|
|
|
1373
1324
|
// Create the state var with the initial state.
|
|
1374
|
-
var __state = el.classList.contains(entry.getSetting(
|
|
1325
|
+
var __state = el.classList.contains(entry.getSetting("stateOpened")) ? "opened" : "closed";
|
|
1375
1326
|
|
|
1376
1327
|
// Create the mode var with the initial mode.
|
|
1377
|
-
var __mode = el.classList.contains(entry.getSetting(
|
|
1328
|
+
var __mode = el.classList.contains(entry.getSetting("classModal")) ? "modal" : "inline";
|
|
1378
1329
|
|
|
1379
1330
|
// Setup mode specific attributes.
|
|
1380
|
-
if (entry.mode ===
|
|
1331
|
+
if (entry.mode === "modal") {
|
|
1381
1332
|
// Set aria-modal attribute to true.
|
|
1382
|
-
entry.dialog.setAttribute(
|
|
1333
|
+
entry.dialog.setAttribute("aria-modal", "true");
|
|
1383
1334
|
} else {
|
|
1384
1335
|
// Remove the aria-modal attribute.
|
|
1385
|
-
entry.dialog.removeAttribute(
|
|
1336
|
+
entry.dialog.removeAttribute("aria-modal");
|
|
1386
1337
|
}
|
|
1387
1338
|
|
|
1388
1339
|
// Set tabindex="-1" so dialog is focusable via JS or click.
|
|
1389
|
-
if (entry.getSetting(
|
|
1390
|
-
entry.dialog.setAttribute(
|
|
1340
|
+
if (entry.getSetting("setTabindex")) {
|
|
1341
|
+
entry.dialog.setAttribute("tabindex", "-1");
|
|
1391
1342
|
}
|
|
1392
1343
|
|
|
1393
1344
|
// Add entry to collection.
|
|
@@ -1416,15 +1367,14 @@ var register$2 = function register(el, dialog) {
|
|
|
1416
1367
|
var _handleClick$1 = /*#__PURE__*/_classPrivateFieldLooseKey("handleClick");
|
|
1417
1368
|
var _handleKeydown$2 = /*#__PURE__*/_classPrivateFieldLooseKey("handleKeydown");
|
|
1418
1369
|
var Drawer = /*#__PURE__*/function (_Collection) {
|
|
1419
|
-
_inheritsLoose(Drawer, _Collection);
|
|
1420
1370
|
function Drawer(options) {
|
|
1421
1371
|
var _this;
|
|
1422
1372
|
_this = _Collection.call(this) || this;
|
|
1423
|
-
Object.defineProperty(
|
|
1373
|
+
Object.defineProperty(_this, _handleClick$1, {
|
|
1424
1374
|
writable: true,
|
|
1425
1375
|
value: void 0
|
|
1426
1376
|
});
|
|
1427
|
-
Object.defineProperty(
|
|
1377
|
+
Object.defineProperty(_this, _handleKeydown$2, {
|
|
1428
1378
|
writable: true,
|
|
1429
1379
|
value: void 0
|
|
1430
1380
|
});
|
|
@@ -1434,11 +1384,12 @@ var Drawer = /*#__PURE__*/function (_Collection) {
|
|
|
1434
1384
|
|
|
1435
1385
|
// Setup local store for inline drawer state management.
|
|
1436
1386
|
_this.store = localStore(_this.settings.storeKey, _this.settings.store);
|
|
1437
|
-
_classPrivateFieldLooseBase(
|
|
1438
|
-
_classPrivateFieldLooseBase(
|
|
1387
|
+
_classPrivateFieldLooseBase(_this, _handleClick$1)[_handleClick$1] = handleClick$2.bind(_this);
|
|
1388
|
+
_classPrivateFieldLooseBase(_this, _handleKeydown$2)[_handleKeydown$2] = handleKeydown$2.bind(_this);
|
|
1439
1389
|
if (_this.settings.autoInit) _this.init();
|
|
1440
1390
|
return _this;
|
|
1441
1391
|
}
|
|
1392
|
+
_inheritsLoose(Drawer, _Collection);
|
|
1442
1393
|
var _proto = Drawer.prototype;
|
|
1443
1394
|
_proto.init = function init(options) {
|
|
1444
1395
|
if (options === void 0) {
|
|
@@ -1480,12 +1431,12 @@ var Drawer = /*#__PURE__*/function (_Collection) {
|
|
|
1480
1431
|
}
|
|
1481
1432
|
};
|
|
1482
1433
|
_proto.initEventListeners = function initEventListeners() {
|
|
1483
|
-
document.addEventListener(
|
|
1484
|
-
document.addEventListener(
|
|
1434
|
+
document.addEventListener("click", _classPrivateFieldLooseBase(this, _handleClick$1)[_handleClick$1], false);
|
|
1435
|
+
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleKeydown$2)[_handleKeydown$2], false);
|
|
1485
1436
|
};
|
|
1486
1437
|
_proto.destroyEventListeners = function destroyEventListeners() {
|
|
1487
|
-
document.removeEventListener(
|
|
1488
|
-
document.removeEventListener(
|
|
1438
|
+
document.removeEventListener("click", _classPrivateFieldLooseBase(this, _handleClick$1)[_handleClick$1], false);
|
|
1439
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleKeydown$2)[_handleKeydown$2], false);
|
|
1489
1440
|
};
|
|
1490
1441
|
_proto.register = function register(query) {
|
|
1491
1442
|
var els = getDrawerElements.call(this, query);
|
|
@@ -1505,48 +1456,47 @@ var Drawer = /*#__PURE__*/function (_Collection) {
|
|
|
1505
1456
|
_proto.toggle = function toggle$1(id, transition, focus) {
|
|
1506
1457
|
return toggle.call(this, id, transition, focus);
|
|
1507
1458
|
};
|
|
1508
|
-
_createClass(Drawer, [{
|
|
1459
|
+
return _createClass(Drawer, [{
|
|
1509
1460
|
key: "activeModal",
|
|
1510
1461
|
get: function get() {
|
|
1511
1462
|
return this.collection.find(function (entry) {
|
|
1512
|
-
return entry.state ===
|
|
1463
|
+
return entry.state === "opened" && entry.mode === "modal";
|
|
1513
1464
|
});
|
|
1514
1465
|
}
|
|
1515
1466
|
}]);
|
|
1516
|
-
return Drawer;
|
|
1517
1467
|
}(Collection);
|
|
1518
1468
|
|
|
1519
1469
|
var defaults$1 = {
|
|
1520
1470
|
autoInit: false,
|
|
1521
1471
|
// Data attributes
|
|
1522
|
-
dataOpen:
|
|
1523
|
-
dataClose:
|
|
1524
|
-
dataReplace:
|
|
1525
|
-
dataConfig:
|
|
1472
|
+
dataOpen: "modal-open",
|
|
1473
|
+
dataClose: "modal-close",
|
|
1474
|
+
dataReplace: "modal-replace",
|
|
1475
|
+
dataConfig: "modal-config",
|
|
1526
1476
|
// Selectors
|
|
1527
|
-
selectorModal:
|
|
1528
|
-
selectorDialog:
|
|
1529
|
-
selectorRequired:
|
|
1530
|
-
selectorFocus:
|
|
1477
|
+
selectorModal: ".modal",
|
|
1478
|
+
selectorDialog: ".modal__dialog",
|
|
1479
|
+
selectorRequired: "[role=\"alertdialog\"]",
|
|
1480
|
+
selectorFocus: "[data-focus]",
|
|
1531
1481
|
selectorInert: null,
|
|
1532
|
-
selectorOverflow:
|
|
1482
|
+
selectorOverflow: "body",
|
|
1533
1483
|
// State classes
|
|
1534
|
-
stateOpened:
|
|
1535
|
-
stateOpening:
|
|
1536
|
-
stateClosing:
|
|
1537
|
-
stateClosed:
|
|
1484
|
+
stateOpened: "is-opened",
|
|
1485
|
+
stateOpening: "is-opening",
|
|
1486
|
+
stateClosing: "is-closing",
|
|
1487
|
+
stateClosed: "is-closed",
|
|
1538
1488
|
// Feature settings
|
|
1539
|
-
customEventPrefix:
|
|
1489
|
+
customEventPrefix: "modal:",
|
|
1540
1490
|
eventListeners: true,
|
|
1541
1491
|
teleport: null,
|
|
1542
|
-
teleportMethod:
|
|
1492
|
+
teleportMethod: "append",
|
|
1543
1493
|
setTabindex: true,
|
|
1544
1494
|
transition: true
|
|
1545
1495
|
};
|
|
1546
1496
|
|
|
1547
1497
|
function getModal(query) {
|
|
1548
1498
|
// Get the entry from collection.
|
|
1549
|
-
var entry = typeof query ===
|
|
1499
|
+
var entry = typeof query === "string" ? this.get(query) : this.get(query.id);
|
|
1550
1500
|
|
|
1551
1501
|
// Return entry if it was resolved, otherwise throw error.
|
|
1552
1502
|
if (entry) {
|
|
@@ -1558,12 +1508,12 @@ function getModal(query) {
|
|
|
1558
1508
|
|
|
1559
1509
|
function getModalID(obj) {
|
|
1560
1510
|
// If it's a string, return the string.
|
|
1561
|
-
if (typeof obj ===
|
|
1511
|
+
if (typeof obj === "string") {
|
|
1562
1512
|
return obj;
|
|
1563
1513
|
}
|
|
1564
1514
|
|
|
1565
1515
|
// If it's an HTML element.
|
|
1566
|
-
else if (typeof obj.hasAttribute ===
|
|
1516
|
+
else if (typeof obj.hasAttribute === "function") {
|
|
1567
1517
|
// If it's a modal open trigger, return data value.
|
|
1568
1518
|
if (obj.hasAttribute("data-" + this.settings.dataOpen)) {
|
|
1569
1519
|
return obj.getAttribute("data-" + this.settings.dataOpen);
|
|
@@ -1609,7 +1559,7 @@ function getModalElements(query) {
|
|
|
1609
1559
|
};
|
|
1610
1560
|
} else if (!dialog) {
|
|
1611
1561
|
return {
|
|
1612
|
-
error: new Error(
|
|
1562
|
+
error: new Error("Modal is missing dialog element.")
|
|
1613
1563
|
};
|
|
1614
1564
|
} else {
|
|
1615
1565
|
return {
|
|
@@ -1619,7 +1569,7 @@ function getModalElements(query) {
|
|
|
1619
1569
|
}
|
|
1620
1570
|
} else {
|
|
1621
1571
|
return {
|
|
1622
|
-
error: new Error(
|
|
1572
|
+
error: new Error("Could not resolve the modal ID.")
|
|
1623
1573
|
};
|
|
1624
1574
|
}
|
|
1625
1575
|
}
|
|
@@ -1662,7 +1612,7 @@ var handleClick$1 = function handleClick(event) {
|
|
|
1662
1612
|
// Get the value of the data attribute.
|
|
1663
1613
|
var value = trigger.getAttribute("data-" + _this.settings.dataClose);
|
|
1664
1614
|
// Close all if * wildcard is passed, otherwise close a single modal.
|
|
1665
|
-
return Promise.resolve(value ===
|
|
1615
|
+
return Promise.resolve(value === "*" ? _this.closeAll() : _this.close(value));
|
|
1666
1616
|
}
|
|
1667
1617
|
|
|
1668
1618
|
// If the modal screen was clicked, close the modal.
|
|
@@ -1676,7 +1626,7 @@ var handleClick$1 = function handleClick(event) {
|
|
|
1676
1626
|
};
|
|
1677
1627
|
function handleKeydown$1(event) {
|
|
1678
1628
|
// If escape key was pressed.
|
|
1679
|
-
if (event.key ===
|
|
1629
|
+
if (event.key === "Escape") {
|
|
1680
1630
|
// If a modal is opened and not required, close the modal.
|
|
1681
1631
|
if (this.active && !this.active.dialog.matches(this.settings.selectorRequired)) {
|
|
1682
1632
|
return this.close();
|
|
@@ -1705,28 +1655,28 @@ var deregister$1 = function deregister(obj, close) {
|
|
|
1705
1655
|
if (index >= 0) {
|
|
1706
1656
|
var _temp2 = function _temp2() {
|
|
1707
1657
|
// Return teleported modal if a reference has been set.
|
|
1708
|
-
if (
|
|
1709
|
-
|
|
1658
|
+
if (entry.getSetting("teleport")) {
|
|
1659
|
+
entry.teleportReturn();
|
|
1710
1660
|
}
|
|
1711
1661
|
|
|
1712
1662
|
// Delete properties from collection entry.
|
|
1713
|
-
Object.getOwnPropertyNames(
|
|
1714
|
-
delete
|
|
1663
|
+
Object.getOwnPropertyNames(entry).forEach(function (prop) {
|
|
1664
|
+
delete entry[prop];
|
|
1715
1665
|
});
|
|
1716
1666
|
|
|
1717
1667
|
// Remove entry from collection.
|
|
1718
1668
|
_this.collection.splice(index, 1);
|
|
1719
1669
|
};
|
|
1720
1670
|
// Get the collection entry.
|
|
1721
|
-
var
|
|
1671
|
+
var entry = _this.collection[index];
|
|
1722
1672
|
|
|
1723
1673
|
// If entry is in the opened state, close it.
|
|
1724
1674
|
var _temp = function () {
|
|
1725
|
-
if (close &&
|
|
1726
|
-
return Promise.resolve(
|
|
1675
|
+
if (close && entry.state === "opened") {
|
|
1676
|
+
return Promise.resolve(entry.close(false)).then(function () {});
|
|
1727
1677
|
} else {
|
|
1728
1678
|
// Remove modal from stack.
|
|
1729
|
-
_this.stack.remove(
|
|
1679
|
+
_this.stack.remove(entry);
|
|
1730
1680
|
}
|
|
1731
1681
|
}();
|
|
1732
1682
|
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
|
@@ -1750,7 +1700,7 @@ var open$1 = function open(query, transition, focus) {
|
|
|
1750
1700
|
}
|
|
1751
1701
|
|
|
1752
1702
|
// Dispatch custom opened event.
|
|
1753
|
-
modal.el.dispatchEvent(new CustomEvent(config.customEventPrefix +
|
|
1703
|
+
modal.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "opened", {
|
|
1754
1704
|
detail: _this,
|
|
1755
1705
|
bubbles: true
|
|
1756
1706
|
}));
|
|
@@ -1773,9 +1723,9 @@ var open$1 = function open(query, transition, focus) {
|
|
|
1773
1723
|
|
|
1774
1724
|
// If modal is closed.
|
|
1775
1725
|
var _temp = function () {
|
|
1776
|
-
if (modal.state ===
|
|
1726
|
+
if (modal.state === "closed") {
|
|
1777
1727
|
// Update modal state.
|
|
1778
|
-
modal.state =
|
|
1728
|
+
modal.state = "opening";
|
|
1779
1729
|
|
|
1780
1730
|
// Add modal to stack.
|
|
1781
1731
|
_this.stack.add(modal);
|
|
@@ -1783,7 +1733,7 @@ var open$1 = function open(query, transition, focus) {
|
|
|
1783
1733
|
// Run the open transition.
|
|
1784
1734
|
return Promise.resolve(openTransition(modal.el, config)).then(function () {
|
|
1785
1735
|
// Update modal state.
|
|
1786
|
-
modal.state =
|
|
1736
|
+
modal.state = "opened";
|
|
1787
1737
|
});
|
|
1788
1738
|
}
|
|
1789
1739
|
}();
|
|
@@ -1804,9 +1754,9 @@ var close$1 = function close(query, transition, focus) {
|
|
|
1804
1754
|
|
|
1805
1755
|
// If a modal exists and its state is opened.
|
|
1806
1756
|
var _temp = function () {
|
|
1807
|
-
if (modal && modal.state ===
|
|
1757
|
+
if (modal && modal.state === "opened") {
|
|
1808
1758
|
// Update modal state.
|
|
1809
|
-
modal.state =
|
|
1759
|
+
modal.state = "closing";
|
|
1810
1760
|
|
|
1811
1761
|
// Get the modal configuration.
|
|
1812
1762
|
var config = _extends({}, _this.settings, modal.settings);
|
|
@@ -1828,10 +1778,10 @@ var close$1 = function close(query, transition, focus) {
|
|
|
1828
1778
|
}
|
|
1829
1779
|
|
|
1830
1780
|
// Update modal state.
|
|
1831
|
-
modal.state =
|
|
1781
|
+
modal.state = "closed";
|
|
1832
1782
|
|
|
1833
1783
|
// Dispatch custom closed event.
|
|
1834
|
-
modal.el.dispatchEvent(new CustomEvent(config.customEventPrefix +
|
|
1784
|
+
modal.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "closed", {
|
|
1835
1785
|
detail: _this,
|
|
1836
1786
|
bubbles: true
|
|
1837
1787
|
}));
|
|
@@ -1902,7 +1852,7 @@ var replace = function replace(query, transition, focus) {
|
|
|
1902
1852
|
// Setup results for return.
|
|
1903
1853
|
var resultOpened, resultClosed;
|
|
1904
1854
|
var _temp = function () {
|
|
1905
|
-
if (modal.state ===
|
|
1855
|
+
if (modal.state === "opened") {
|
|
1906
1856
|
// If modal is open, close all modals except for replacement.
|
|
1907
1857
|
resultOpened = modal;
|
|
1908
1858
|
return Promise.resolve(closeAll$1.call(_this, modal.id, transition)).then(function (_closeAll$call) {
|
|
@@ -1945,16 +1895,16 @@ var register$1 = function register(el, dialog) {
|
|
|
1945
1895
|
},
|
|
1946
1896
|
teleport: function teleport$1(ref, method) {
|
|
1947
1897
|
if (ref === void 0) {
|
|
1948
|
-
ref = this.getSetting(
|
|
1898
|
+
ref = this.getSetting("teleport");
|
|
1949
1899
|
}
|
|
1950
1900
|
if (method === void 0) {
|
|
1951
|
-
method = this.getSetting(
|
|
1901
|
+
method = this.getSetting("teleportMethod");
|
|
1952
1902
|
}
|
|
1953
1903
|
if (!this.returnRef) {
|
|
1954
1904
|
this.returnRef = teleport(this.el, ref, method);
|
|
1955
1905
|
return this.el;
|
|
1956
1906
|
} else {
|
|
1957
|
-
console.error(
|
|
1907
|
+
console.error("Element has already been teleported:", this.el);
|
|
1958
1908
|
return false;
|
|
1959
1909
|
}
|
|
1960
1910
|
},
|
|
@@ -1963,7 +1913,7 @@ var register$1 = function register(el, dialog) {
|
|
|
1963
1913
|
this.returnRef = teleport(this.el, this.returnRef);
|
|
1964
1914
|
return this.el;
|
|
1965
1915
|
} else {
|
|
1966
|
-
console.error(
|
|
1916
|
+
console.error("No return reference found:", this.el);
|
|
1967
1917
|
return false;
|
|
1968
1918
|
}
|
|
1969
1919
|
},
|
|
@@ -1975,7 +1925,7 @@ var register$1 = function register(el, dialog) {
|
|
|
1975
1925
|
// Setup the modal object.
|
|
1976
1926
|
var entry = _extends({
|
|
1977
1927
|
id: el.id,
|
|
1978
|
-
state:
|
|
1928
|
+
state: "closed",
|
|
1979
1929
|
el: el,
|
|
1980
1930
|
dialog: dialog,
|
|
1981
1931
|
returnRef: null,
|
|
@@ -1983,20 +1933,20 @@ var register$1 = function register(el, dialog) {
|
|
|
1983
1933
|
}, methods);
|
|
1984
1934
|
|
|
1985
1935
|
// Set aria-modal attribute to true.
|
|
1986
|
-
entry.dialog.setAttribute(
|
|
1936
|
+
entry.dialog.setAttribute("aria-modal", "true");
|
|
1987
1937
|
|
|
1988
1938
|
// If a role attribute is not set, set it to "dialog" as the default.
|
|
1989
|
-
if (!entry.dialog.hasAttribute(
|
|
1990
|
-
entry.dialog.setAttribute(
|
|
1939
|
+
if (!entry.dialog.hasAttribute("role")) {
|
|
1940
|
+
entry.dialog.setAttribute("role", "dialog");
|
|
1991
1941
|
}
|
|
1992
1942
|
|
|
1993
1943
|
// Set tabindex="-1" so dialog is focusable via JS or click.
|
|
1994
|
-
if (entry.getSetting(
|
|
1995
|
-
entry.dialog.setAttribute(
|
|
1944
|
+
if (entry.getSetting("setTabindex")) {
|
|
1945
|
+
entry.dialog.setAttribute("tabindex", "-1");
|
|
1996
1946
|
}
|
|
1997
1947
|
|
|
1998
1948
|
// Teleport modal if a reference has been set.
|
|
1999
|
-
if (entry.getSetting(
|
|
1949
|
+
if (entry.getSetting("teleport")) {
|
|
2000
1950
|
entry.teleport();
|
|
2001
1951
|
}
|
|
2002
1952
|
|
|
@@ -2038,7 +1988,7 @@ function stack(settings) {
|
|
|
2038
1988
|
updateIndex: function updateIndex() {
|
|
2039
1989
|
stackArray.forEach(function (entry, index) {
|
|
2040
1990
|
entry.el.style.zIndex = null;
|
|
2041
|
-
var value = getComputedStyle(entry.el)[
|
|
1991
|
+
var value = getComputedStyle(entry.el)["z-index"];
|
|
2042
1992
|
entry.el.style.zIndex = parseInt(value) + index + 1;
|
|
2043
1993
|
});
|
|
2044
1994
|
},
|
|
@@ -2049,7 +1999,7 @@ function stack(settings) {
|
|
|
2049
1999
|
add: function add(entry) {
|
|
2050
2000
|
// Apply z-index styles based on stack length.
|
|
2051
2001
|
entry.el.style.zIndex = null;
|
|
2052
|
-
var value = getComputedStyle(entry.el)[
|
|
2002
|
+
var value = getComputedStyle(entry.el)["z-index"];
|
|
2053
2003
|
entry.el.style.zIndex = parseInt(value) + stackArray.length + 1;
|
|
2054
2004
|
|
|
2055
2005
|
// Move back to end of stack.
|
|
@@ -2097,15 +2047,14 @@ function stack(settings) {
|
|
|
2097
2047
|
var _handleClick = /*#__PURE__*/_classPrivateFieldLooseKey("handleClick");
|
|
2098
2048
|
var _handleKeydown$1 = /*#__PURE__*/_classPrivateFieldLooseKey("handleKeydown");
|
|
2099
2049
|
var Modal = /*#__PURE__*/function (_Collection) {
|
|
2100
|
-
_inheritsLoose(Modal, _Collection);
|
|
2101
2050
|
function Modal(options) {
|
|
2102
2051
|
var _this;
|
|
2103
2052
|
_this = _Collection.call(this) || this;
|
|
2104
|
-
Object.defineProperty(
|
|
2053
|
+
Object.defineProperty(_this, _handleClick, {
|
|
2105
2054
|
writable: true,
|
|
2106
2055
|
value: void 0
|
|
2107
2056
|
});
|
|
2108
|
-
Object.defineProperty(
|
|
2057
|
+
Object.defineProperty(_this, _handleKeydown$1, {
|
|
2109
2058
|
writable: true,
|
|
2110
2059
|
value: void 0
|
|
2111
2060
|
});
|
|
@@ -2116,11 +2065,12 @@ var Modal = /*#__PURE__*/function (_Collection) {
|
|
|
2116
2065
|
|
|
2117
2066
|
// Setup stack module.
|
|
2118
2067
|
_this.stack = stack(_this.settings);
|
|
2119
|
-
_classPrivateFieldLooseBase(
|
|
2120
|
-
_classPrivateFieldLooseBase(
|
|
2068
|
+
_classPrivateFieldLooseBase(_this, _handleClick)[_handleClick] = handleClick$1.bind(_this);
|
|
2069
|
+
_classPrivateFieldLooseBase(_this, _handleKeydown$1)[_handleKeydown$1] = handleKeydown$1.bind(_this);
|
|
2121
2070
|
if (_this.settings.autoInit) _this.init();
|
|
2122
2071
|
return _this;
|
|
2123
2072
|
}
|
|
2073
|
+
_inheritsLoose(Modal, _Collection);
|
|
2124
2074
|
var _proto = Modal.prototype;
|
|
2125
2075
|
_proto.init = function init(options) {
|
|
2126
2076
|
try {
|
|
@@ -2162,12 +2112,12 @@ var Modal = /*#__PURE__*/function (_Collection) {
|
|
|
2162
2112
|
}
|
|
2163
2113
|
};
|
|
2164
2114
|
_proto.initEventListeners = function initEventListeners() {
|
|
2165
|
-
document.addEventListener(
|
|
2166
|
-
document.addEventListener(
|
|
2115
|
+
document.addEventListener("click", _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
|
|
2116
|
+
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleKeydown$1)[_handleKeydown$1], false);
|
|
2167
2117
|
};
|
|
2168
2118
|
_proto.destroyEventListeners = function destroyEventListeners() {
|
|
2169
|
-
document.removeEventListener(
|
|
2170
|
-
document.removeEventListener(
|
|
2119
|
+
document.removeEventListener("click", _classPrivateFieldLooseBase(this, _handleClick)[_handleClick], false);
|
|
2120
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleKeydown$1)[_handleKeydown$1], false);
|
|
2171
2121
|
};
|
|
2172
2122
|
_proto.register = function register(query) {
|
|
2173
2123
|
var els = getModalElements.call(this, query);
|
|
@@ -2207,26 +2157,25 @@ var Modal = /*#__PURE__*/function (_Collection) {
|
|
|
2207
2157
|
return Promise.reject(e);
|
|
2208
2158
|
}
|
|
2209
2159
|
};
|
|
2210
|
-
_createClass(Modal, [{
|
|
2160
|
+
return _createClass(Modal, [{
|
|
2211
2161
|
key: "active",
|
|
2212
2162
|
get: function get() {
|
|
2213
2163
|
return this.stack.top;
|
|
2214
2164
|
}
|
|
2215
2165
|
}]);
|
|
2216
|
-
return Modal;
|
|
2217
2166
|
}(Collection);
|
|
2218
2167
|
|
|
2219
2168
|
var defaults = {
|
|
2220
2169
|
autoInit: false,
|
|
2221
2170
|
// Selectors
|
|
2222
|
-
selectorPopover:
|
|
2223
|
-
selectorArrow:
|
|
2171
|
+
selectorPopover: ".popover",
|
|
2172
|
+
selectorArrow: ".popover__arrow",
|
|
2224
2173
|
// State classes
|
|
2225
|
-
stateActive:
|
|
2174
|
+
stateActive: "is-active",
|
|
2226
2175
|
// Feature settings
|
|
2227
2176
|
eventListeners: true,
|
|
2228
|
-
eventType:
|
|
2229
|
-
placement:
|
|
2177
|
+
eventType: "click",
|
|
2178
|
+
placement: "bottom"
|
|
2230
2179
|
};
|
|
2231
2180
|
|
|
2232
2181
|
function getConfig(el, settings) {
|
|
@@ -2235,19 +2184,19 @@ function getConfig(el, settings) {
|
|
|
2235
2184
|
|
|
2236
2185
|
// Setup the config obj with default values.
|
|
2237
2186
|
var config = {
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2187
|
+
"placement": settings.placement,
|
|
2188
|
+
"event": settings.eventType,
|
|
2189
|
+
"offset": 0,
|
|
2190
|
+
"overflow-padding": 0,
|
|
2191
|
+
"flip-padding": 0,
|
|
2192
|
+
"arrow-element": settings.selectorArrow,
|
|
2193
|
+
"arrow-padding": 0
|
|
2245
2194
|
};
|
|
2246
2195
|
|
|
2247
2196
|
// Loop through config obj.
|
|
2248
2197
|
for (var prop in config) {
|
|
2249
2198
|
// Get the CSS variable property values.
|
|
2250
|
-
var prefix =
|
|
2199
|
+
var prefix = P();
|
|
2251
2200
|
var value = styles.getPropertyValue("--" + prefix + "popover-" + prop).trim();
|
|
2252
2201
|
|
|
2253
2202
|
// If a value was found, replace the default in config obj.
|
|
@@ -2264,7 +2213,7 @@ function getPadding(value) {
|
|
|
2264
2213
|
var padding;
|
|
2265
2214
|
|
|
2266
2215
|
// Split the value by spaces if it's a string.
|
|
2267
|
-
var array = typeof value ===
|
|
2216
|
+
var array = typeof value === "string" ? value.trim().split(" ") : [value];
|
|
2268
2217
|
|
|
2269
2218
|
// Convert individual values to integers.
|
|
2270
2219
|
array.forEach(function (item, index) {
|
|
@@ -2311,32 +2260,32 @@ function getPadding(value) {
|
|
|
2311
2260
|
|
|
2312
2261
|
function getModifiers(options) {
|
|
2313
2262
|
return [{
|
|
2314
|
-
name:
|
|
2263
|
+
name: "offset",
|
|
2315
2264
|
options: {
|
|
2316
|
-
offset: [0, parseInt(options[
|
|
2265
|
+
offset: [0, parseInt(options["offset"], 10)]
|
|
2317
2266
|
}
|
|
2318
2267
|
}, {
|
|
2319
|
-
name:
|
|
2268
|
+
name: "preventOverflow",
|
|
2320
2269
|
options: {
|
|
2321
|
-
padding: getPadding(options[
|
|
2270
|
+
padding: getPadding(options["overflow-padding"])
|
|
2322
2271
|
}
|
|
2323
2272
|
}, {
|
|
2324
|
-
name:
|
|
2273
|
+
name: "flip",
|
|
2325
2274
|
options: {
|
|
2326
|
-
padding: getPadding(options[
|
|
2275
|
+
padding: getPadding(options["flip-padding"])
|
|
2327
2276
|
}
|
|
2328
2277
|
}, {
|
|
2329
|
-
name:
|
|
2278
|
+
name: "arrow",
|
|
2330
2279
|
options: {
|
|
2331
|
-
element: options[
|
|
2332
|
-
padding: getPadding(options[
|
|
2280
|
+
element: options["arrow-element"],
|
|
2281
|
+
padding: getPadding(options["arrow-padding"])
|
|
2333
2282
|
}
|
|
2334
2283
|
}];
|
|
2335
2284
|
}
|
|
2336
2285
|
|
|
2337
2286
|
function getPopover(query) {
|
|
2338
2287
|
// Get the entry from collection.
|
|
2339
|
-
var entry = typeof query ===
|
|
2288
|
+
var entry = typeof query === "string" ? this.get(query) : this.get(query.id);
|
|
2340
2289
|
|
|
2341
2290
|
// Return entry if it was resolved, otherwise throw error.
|
|
2342
2291
|
if (entry) {
|
|
@@ -2348,12 +2297,12 @@ function getPopover(query) {
|
|
|
2348
2297
|
|
|
2349
2298
|
function getPopoverID(obj) {
|
|
2350
2299
|
// If it's a string, return the string.
|
|
2351
|
-
if (typeof obj ===
|
|
2300
|
+
if (typeof obj === "string") {
|
|
2352
2301
|
return obj;
|
|
2353
2302
|
}
|
|
2354
2303
|
|
|
2355
2304
|
// If it's an HTML element.
|
|
2356
|
-
else if (typeof obj.hasAttribute ===
|
|
2305
|
+
else if (typeof obj.hasAttribute === "function") {
|
|
2357
2306
|
// If it's a popover element, return the id.
|
|
2358
2307
|
if (obj.closest(this.settings.selectorPopover)) {
|
|
2359
2308
|
obj = obj.closest(this.settings.selectorPopover);
|
|
@@ -2361,13 +2310,13 @@ function getPopoverID(obj) {
|
|
|
2361
2310
|
}
|
|
2362
2311
|
|
|
2363
2312
|
// If it's a popover trigger, return value of aria-controls.
|
|
2364
|
-
else if (obj.hasAttribute(
|
|
2365
|
-
return obj.getAttribute(
|
|
2313
|
+
else if (obj.hasAttribute("aria-controls")) {
|
|
2314
|
+
return obj.getAttribute("aria-controls");
|
|
2366
2315
|
}
|
|
2367
2316
|
|
|
2368
2317
|
// If it's a popover tooltip trigger, return the value of aria-describedby.
|
|
2369
|
-
else if (obj.hasAttribute(
|
|
2370
|
-
return obj.getAttribute(
|
|
2318
|
+
else if (obj.hasAttribute("aria-describedby")) {
|
|
2319
|
+
return obj.getAttribute("aria-describedby");
|
|
2371
2320
|
}
|
|
2372
2321
|
|
|
2373
2322
|
// Return false if no id was found.
|
|
@@ -2394,11 +2343,11 @@ function getPopoverElements(query) {
|
|
|
2394
2343
|
};
|
|
2395
2344
|
} else if (!trigger) {
|
|
2396
2345
|
return {
|
|
2397
|
-
error: new Error(
|
|
2346
|
+
error: new Error("No popover trigger associated with the provided popover.")
|
|
2398
2347
|
};
|
|
2399
2348
|
} else if (!popover) {
|
|
2400
2349
|
return {
|
|
2401
|
-
error: new Error(
|
|
2350
|
+
error: new Error("No popover associated with the provided popover trigger.")
|
|
2402
2351
|
};
|
|
2403
2352
|
} else {
|
|
2404
2353
|
return {
|
|
@@ -2408,7 +2357,7 @@ function getPopoverElements(query) {
|
|
|
2408
2357
|
}
|
|
2409
2358
|
} else {
|
|
2410
2359
|
return {
|
|
2411
|
-
error: new Error(
|
|
2360
|
+
error: new Error("Could not resolve the popover ID.")
|
|
2412
2361
|
};
|
|
2413
2362
|
}
|
|
2414
2363
|
}
|
|
@@ -2420,7 +2369,7 @@ var closeAll = function closeAll() {
|
|
|
2420
2369
|
return Promise.resolve(Promise.all(_this2.collection.map(function (popover) {
|
|
2421
2370
|
try {
|
|
2422
2371
|
var _temp2 = function () {
|
|
2423
|
-
if (popover.state ===
|
|
2372
|
+
if (popover.state === "opened") {
|
|
2424
2373
|
var _push = result.push;
|
|
2425
2374
|
return Promise.resolve(close.call(_this2, popover)).then(function (_close$call) {
|
|
2426
2375
|
_push.call(result, _close$call);
|
|
@@ -2442,25 +2391,25 @@ var close = function close(query) {
|
|
|
2442
2391
|
try {
|
|
2443
2392
|
var _temp = function _temp(popover) {
|
|
2444
2393
|
// If a modal exists and its state is opened.
|
|
2445
|
-
if (popover && popover.state ===
|
|
2394
|
+
if (popover && popover.state === "opened") {
|
|
2446
2395
|
// Update state class.
|
|
2447
2396
|
popover.el.classList.remove(_this.settings.stateActive);
|
|
2448
2397
|
|
|
2449
2398
|
// Update accessibility attribute(s).
|
|
2450
|
-
if (popover.trigger.hasAttribute(
|
|
2451
|
-
popover.trigger.setAttribute(
|
|
2399
|
+
if (popover.trigger.hasAttribute("aria-controls")) {
|
|
2400
|
+
popover.trigger.setAttribute("aria-expanded", "false");
|
|
2452
2401
|
}
|
|
2453
2402
|
|
|
2454
2403
|
// Disable popper event listeners.
|
|
2455
2404
|
popover.popper.setOptions({
|
|
2456
2405
|
modifiers: [{
|
|
2457
|
-
name:
|
|
2406
|
+
name: "eventListeners",
|
|
2458
2407
|
enabled: false
|
|
2459
2408
|
}]
|
|
2460
2409
|
});
|
|
2461
2410
|
|
|
2462
2411
|
// Update popover state.
|
|
2463
|
-
popover.state =
|
|
2412
|
+
popover.state = "closed";
|
|
2464
2413
|
|
|
2465
2414
|
// Clear root trigger if popover trigger matches.
|
|
2466
2415
|
if (popover.trigger === _this.trigger) {
|
|
@@ -2480,12 +2429,12 @@ var close = function close(query) {
|
|
|
2480
2429
|
};
|
|
2481
2430
|
function closeCheck(popover) {
|
|
2482
2431
|
// Only run closeCheck if provided popover is currently open.
|
|
2483
|
-
if (popover.state !=
|
|
2432
|
+
if (popover.state != "opened") return;
|
|
2484
2433
|
|
|
2485
2434
|
// Needed to correctly check which element is currently being focused.
|
|
2486
2435
|
setTimeout(function () {
|
|
2487
2436
|
// Check if trigger or element are being hovered.
|
|
2488
|
-
var isHovered = popover.el.closest(
|
|
2437
|
+
var isHovered = popover.el.closest(":hover") === popover.el || popover.trigger.closest(":hover") === popover.trigger;
|
|
2489
2438
|
|
|
2490
2439
|
// Check if trigger or element are being focused.
|
|
2491
2440
|
var isFocused = document.activeElement.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"], [aria-describedby=\"" + popover.id + "\"]");
|
|
@@ -2501,7 +2450,7 @@ function closeCheck(popover) {
|
|
|
2501
2450
|
}
|
|
2502
2451
|
|
|
2503
2452
|
function handleClick(popover) {
|
|
2504
|
-
if (popover.state ===
|
|
2453
|
+
if (popover.state === "opened") {
|
|
2505
2454
|
popover.close();
|
|
2506
2455
|
} else {
|
|
2507
2456
|
this.trigger = popover.trigger;
|
|
@@ -2512,13 +2461,13 @@ function handleClick(popover) {
|
|
|
2512
2461
|
function handleKeydown(event) {
|
|
2513
2462
|
var _this = this;
|
|
2514
2463
|
switch (event.key) {
|
|
2515
|
-
case
|
|
2464
|
+
case "Escape":
|
|
2516
2465
|
if (this.trigger) {
|
|
2517
2466
|
this.trigger.focus();
|
|
2518
2467
|
}
|
|
2519
2468
|
closeAll.call(this);
|
|
2520
2469
|
return;
|
|
2521
|
-
case
|
|
2470
|
+
case "Tab":
|
|
2522
2471
|
this.collection.forEach(function (popover) {
|
|
2523
2472
|
closeCheck.call(_this, popover);
|
|
2524
2473
|
});
|
|
@@ -2529,7 +2478,7 @@ function handleKeydown(event) {
|
|
|
2529
2478
|
}
|
|
2530
2479
|
function handleDocumentClick(popover) {
|
|
2531
2480
|
var root = this;
|
|
2532
|
-
document.addEventListener(
|
|
2481
|
+
document.addEventListener("click", function _f(event) {
|
|
2533
2482
|
// Check if a popover or its trigger was clicked.
|
|
2534
2483
|
var wasClicked = event.target.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"], [aria-describedby=\"" + popover.id + "\"]");
|
|
2535
2484
|
|
|
@@ -2537,14 +2486,14 @@ function handleDocumentClick(popover) {
|
|
|
2537
2486
|
if (wasClicked) {
|
|
2538
2487
|
// If popover element exists and is not active...
|
|
2539
2488
|
if (popover.el && !popover.el.classList.contains(root.settings.stateActive)) {
|
|
2540
|
-
this.removeEventListener(
|
|
2489
|
+
this.removeEventListener("click", _f);
|
|
2541
2490
|
}
|
|
2542
2491
|
} else {
|
|
2543
2492
|
// If popover element exists and is active...
|
|
2544
2493
|
if (popover.el && popover.el.classList.contains(root.settings.stateActive)) {
|
|
2545
2494
|
popover.close();
|
|
2546
2495
|
}
|
|
2547
|
-
this.removeEventListener(
|
|
2496
|
+
this.removeEventListener("click", _f);
|
|
2548
2497
|
}
|
|
2549
2498
|
});
|
|
2550
2499
|
}
|
|
@@ -4355,7 +4304,7 @@ var deregister = function deregister(obj) {
|
|
|
4355
4304
|
var entry = _this.collection[index];
|
|
4356
4305
|
|
|
4357
4306
|
// If entry is in the opened state, close it.
|
|
4358
|
-
if (entry.state ===
|
|
4307
|
+
if (entry.state === "opened") {
|
|
4359
4308
|
entry.close();
|
|
4360
4309
|
}
|
|
4361
4310
|
|
|
@@ -4410,8 +4359,8 @@ var open = function open(query) {
|
|
|
4410
4359
|
popover.el.classList.add(_this.settings.stateActive);
|
|
4411
4360
|
|
|
4412
4361
|
// Update accessibility attribute(s).
|
|
4413
|
-
if (popover.trigger.hasAttribute(
|
|
4414
|
-
popover.trigger.setAttribute(
|
|
4362
|
+
if (popover.trigger.hasAttribute("aria-controls")) {
|
|
4363
|
+
popover.trigger.setAttribute("aria-expanded", "true");
|
|
4415
4364
|
}
|
|
4416
4365
|
|
|
4417
4366
|
// Update popover config.
|
|
@@ -4419,9 +4368,9 @@ var open = function open(query) {
|
|
|
4419
4368
|
|
|
4420
4369
|
// Enable popper event listeners and set placement/modifiers.
|
|
4421
4370
|
popover.popper.setOptions({
|
|
4422
|
-
placement: popover.config[
|
|
4371
|
+
placement: popover.config["placement"],
|
|
4423
4372
|
modifiers: [{
|
|
4424
|
-
name:
|
|
4373
|
+
name: "eventListeners",
|
|
4425
4374
|
enabled: true
|
|
4426
4375
|
}].concat(getModifiers(popover.config))
|
|
4427
4376
|
});
|
|
@@ -4430,7 +4379,7 @@ var open = function open(query) {
|
|
|
4430
4379
|
popover.popper.update();
|
|
4431
4380
|
|
|
4432
4381
|
// Update popover state.
|
|
4433
|
-
popover.state =
|
|
4382
|
+
popover.state = "opened";
|
|
4434
4383
|
|
|
4435
4384
|
// Return the popover.
|
|
4436
4385
|
return Promise.resolve(popover);
|
|
@@ -4464,7 +4413,7 @@ var register = function register(el, trigger) {
|
|
|
4464
4413
|
// Setup the popover object.
|
|
4465
4414
|
var entry = _extends({
|
|
4466
4415
|
id: el.id,
|
|
4467
|
-
state:
|
|
4416
|
+
state: "closed",
|
|
4468
4417
|
el: el,
|
|
4469
4418
|
trigger: trigger,
|
|
4470
4419
|
popper: createPopper(trigger, el),
|
|
@@ -4472,8 +4421,8 @@ var register = function register(el, trigger) {
|
|
|
4472
4421
|
}, methods);
|
|
4473
4422
|
|
|
4474
4423
|
// Set aria-expanded to false if trigger has aria-controls attribute.
|
|
4475
|
-
if (entry.trigger.hasAttribute(
|
|
4476
|
-
entry.trigger.setAttribute(
|
|
4424
|
+
if (entry.trigger.hasAttribute("aria-controls")) {
|
|
4425
|
+
entry.trigger.setAttribute("aria-expanded", "false");
|
|
4477
4426
|
}
|
|
4478
4427
|
|
|
4479
4428
|
// Setup event listeners.
|
|
@@ -4502,18 +4451,18 @@ function registerEventListeners(entry) {
|
|
|
4502
4451
|
// If event listeners aren't already setup.
|
|
4503
4452
|
if (!entry.__eventListeners) {
|
|
4504
4453
|
// Add event listeners based on event type.
|
|
4505
|
-
var eventType = entry.config[
|
|
4454
|
+
var eventType = entry.config["event"];
|
|
4506
4455
|
|
|
4507
4456
|
// If the event type is hover.
|
|
4508
|
-
if (eventType ===
|
|
4457
|
+
if (eventType === "hover") {
|
|
4509
4458
|
// Setup event listeners object for hover.
|
|
4510
4459
|
entry.__eventListeners = [{
|
|
4511
|
-
el: [
|
|
4512
|
-
type: [
|
|
4460
|
+
el: ["trigger"],
|
|
4461
|
+
type: ["mouseenter", "focus"],
|
|
4513
4462
|
listener: open.bind(this, entry)
|
|
4514
4463
|
}, {
|
|
4515
|
-
el: [
|
|
4516
|
-
type: [
|
|
4464
|
+
el: ["el", "trigger"],
|
|
4465
|
+
type: ["mouseleave", "focusout"],
|
|
4517
4466
|
listener: closeCheck.bind(this, entry)
|
|
4518
4467
|
}];
|
|
4519
4468
|
|
|
@@ -4531,8 +4480,8 @@ function registerEventListeners(entry) {
|
|
|
4531
4480
|
else {
|
|
4532
4481
|
// Setup event listeners object for click.
|
|
4533
4482
|
entry.__eventListeners = [{
|
|
4534
|
-
el: [
|
|
4535
|
-
type: [
|
|
4483
|
+
el: ["trigger"],
|
|
4484
|
+
type: ["click"],
|
|
4536
4485
|
listener: handleClick.bind(this, entry)
|
|
4537
4486
|
}];
|
|
4538
4487
|
|
|
@@ -4553,21 +4502,21 @@ function registerEventListeners(entry) {
|
|
|
4553
4502
|
|
|
4554
4503
|
var _handleKeydown = /*#__PURE__*/_classPrivateFieldLooseKey("handleKeydown");
|
|
4555
4504
|
var Popover = /*#__PURE__*/function (_Collection) {
|
|
4556
|
-
_inheritsLoose(Popover, _Collection);
|
|
4557
4505
|
function Popover(options) {
|
|
4558
4506
|
var _this;
|
|
4559
4507
|
_this = _Collection.call(this) || this;
|
|
4560
|
-
Object.defineProperty(
|
|
4508
|
+
Object.defineProperty(_this, _handleKeydown, {
|
|
4561
4509
|
writable: true,
|
|
4562
4510
|
value: void 0
|
|
4563
4511
|
});
|
|
4564
4512
|
_this.defaults = defaults;
|
|
4565
4513
|
_this.settings = _extends({}, _this.defaults, options);
|
|
4566
4514
|
_this.trigger = null;
|
|
4567
|
-
_classPrivateFieldLooseBase(
|
|
4515
|
+
_classPrivateFieldLooseBase(_this, _handleKeydown)[_handleKeydown] = handleKeydown.bind(_this);
|
|
4568
4516
|
if (_this.settings.autoInit) _this.init();
|
|
4569
4517
|
return _this;
|
|
4570
4518
|
}
|
|
4519
|
+
_inheritsLoose(Popover, _Collection);
|
|
4571
4520
|
var _proto = Popover.prototype;
|
|
4572
4521
|
_proto.init = function init(options) {
|
|
4573
4522
|
try {
|
|
@@ -4625,7 +4574,7 @@ var Popover = /*#__PURE__*/function (_Collection) {
|
|
|
4625
4574
|
}
|
|
4626
4575
|
|
|
4627
4576
|
// Add keydown global event listener.
|
|
4628
|
-
document.addEventListener(
|
|
4577
|
+
document.addEventListener("keydown", _classPrivateFieldLooseBase(this, _handleKeydown)[_handleKeydown], false);
|
|
4629
4578
|
};
|
|
4630
4579
|
_proto.destroyEventListeners = function destroyEventListeners(processCollection) {
|
|
4631
4580
|
if (processCollection === void 0) {
|
|
@@ -4639,7 +4588,7 @@ var Popover = /*#__PURE__*/function (_Collection) {
|
|
|
4639
4588
|
}
|
|
4640
4589
|
|
|
4641
4590
|
// Remove keydown global event listener.
|
|
4642
|
-
document.removeEventListener(
|
|
4591
|
+
document.removeEventListener("keydown", _classPrivateFieldLooseBase(this, _handleKeydown)[_handleKeydown], false);
|
|
4643
4592
|
};
|
|
4644
4593
|
_proto.register = function register$1(query) {
|
|
4645
4594
|
var els = getPopoverElements.call(this, query);
|