vrembem 1.40.0 → 1.40.3
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 +451 -409
- package/dev/scripts.esm.js.map +1 -1
- package/dev/scripts.js +451 -409
- package/dev/scripts.js.map +1 -1
- package/dev/scripts.modern.js +374 -342
- package/dev/scripts.modern.js.map +1 -1
- package/dev/scripts.umd.js +451 -409
- package/dev/scripts.umd.js.map +1 -1
- 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.js +1 -1
- package/dist/scripts.modern.js.map +1 -1
- package/dist/scripts.umd.js +1 -1
- package/dist/scripts.umd.js.map +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +26 -26
package/dev/scripts.umd.js
CHANGED
|
@@ -39,10 +39,9 @@
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Adds a class or classes to
|
|
43
|
-
*
|
|
44
|
-
* @param
|
|
45
|
-
* @param {String || Array} cl - Class(es) to add
|
|
42
|
+
* Adds a class or classes to a Node or NodeList.
|
|
43
|
+
* @param {Node || NodeList} el - Element(s) to add class(es) to.
|
|
44
|
+
* @param {String || Array} cl - Class(es) to add.
|
|
46
45
|
*/
|
|
47
46
|
var addClass = function addClass(el) {
|
|
48
47
|
var _arguments = arguments;
|
|
@@ -55,10 +54,9 @@
|
|
|
55
54
|
};
|
|
56
55
|
|
|
57
56
|
/**
|
|
58
|
-
* Takes a hyphen cased string and converts it to camel case
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
* @returns {Boolean} - returns a camel cased string
|
|
57
|
+
* Takes a hyphen cased string and converts it to camel case.
|
|
58
|
+
* @param {String } str - the string to convert to camel case.
|
|
59
|
+
* @returns {Boolean} - returns a camel cased string.
|
|
62
60
|
*/
|
|
63
61
|
var camelCase = function camelCase(str) {
|
|
64
62
|
return str.replace(/-([a-z])/g, function (g) {
|
|
@@ -184,27 +182,25 @@
|
|
|
184
182
|
}();
|
|
185
183
|
|
|
186
184
|
/**
|
|
187
|
-
* Get an element(s) from a selector or return value if not a string
|
|
188
|
-
*
|
|
189
|
-
* @param {
|
|
190
|
-
* @param {Boolean} single - Whether to return a single or all matches
|
|
185
|
+
* Get an element(s) from a selector or return value if not a string.
|
|
186
|
+
* @param {String} selector - Selector to query.
|
|
187
|
+
* @param {Boolean} single - Whether to return a single or all matches.
|
|
191
188
|
*/
|
|
192
189
|
var getElement = function getElement(selector, single) {
|
|
193
190
|
if (single === void 0) {
|
|
194
191
|
single = 0;
|
|
195
192
|
}
|
|
196
193
|
|
|
197
|
-
if (typeof selector
|
|
194
|
+
if (typeof selector !== 'string') return selector;
|
|
198
195
|
return single ? document.querySelector(selector) : document.querySelectorAll(selector);
|
|
199
196
|
};
|
|
200
197
|
|
|
201
198
|
/**
|
|
202
|
-
* Checks an element or NodeList whether they contain a class or classes
|
|
199
|
+
* Checks an element or NodeList whether they contain a class or classes.
|
|
203
200
|
* Ref: https://davidwalsh.name/nodelist-array
|
|
204
|
-
*
|
|
205
|
-
* @param {
|
|
206
|
-
* @
|
|
207
|
-
* @returns {Boolean} - Returns true if class exists, otherwise false
|
|
201
|
+
* @param {Node} el - Element(s) to check class(es) on.
|
|
202
|
+
* @param {String || Array} c - Class(es) to check.
|
|
203
|
+
* @returns {Boolean} - Returns true if class exists, otherwise false.
|
|
208
204
|
*/
|
|
209
205
|
var hasClass = function hasClass(el) {
|
|
210
206
|
el = el.forEach ? el : [el];
|
|
@@ -217,10 +213,9 @@
|
|
|
217
213
|
};
|
|
218
214
|
|
|
219
215
|
/**
|
|
220
|
-
* Takes a camel cased string and converts it to hyphen case
|
|
221
|
-
*
|
|
222
|
-
* @
|
|
223
|
-
* @returns {Boolean} - returns a hyphen cased string
|
|
216
|
+
* Takes a camel cased string and converts it to hyphen case.
|
|
217
|
+
* @param {String } str - the string to convert to hyphen case.
|
|
218
|
+
* @returns {Boolean} - returns a hyphen cased string.
|
|
224
219
|
*/
|
|
225
220
|
var hyphenCase = function hyphenCase(str) {
|
|
226
221
|
return str.replace(/([a-z][A-Z])/g, function (g) {
|
|
@@ -229,11 +224,10 @@
|
|
|
229
224
|
};
|
|
230
225
|
|
|
231
226
|
/**
|
|
232
|
-
* Moves element(s) in the DOM based on a reference and move type
|
|
233
|
-
*
|
|
234
|
-
* @param {String}
|
|
235
|
-
* @param {String}
|
|
236
|
-
* @param {String} reference - The reference element the move is relative to
|
|
227
|
+
* Moves element(s) in the DOM based on a reference and move type.
|
|
228
|
+
* @param {String} target - The element(s) to move.
|
|
229
|
+
* @param {String} type - Move type can be 'after', 'before', 'append' or 'prepend'.
|
|
230
|
+
* @param {String} reference - The reference element the move is relative to.
|
|
237
231
|
*/
|
|
238
232
|
|
|
239
233
|
function moveElement(target, type, reference) {
|
|
@@ -288,10 +282,9 @@
|
|
|
288
282
|
}
|
|
289
283
|
|
|
290
284
|
/**
|
|
291
|
-
* Remove a class or classes from an element or NodeList
|
|
292
|
-
*
|
|
293
|
-
* @param {
|
|
294
|
-
* @param {String || Array} cl - Class(es) to remove
|
|
285
|
+
* Remove a class or classes from an element or NodeList.
|
|
286
|
+
* @param {Node || NodeList} el - Element(s) to remove class(es) from.
|
|
287
|
+
* @param {String || Array} cl - Class(es) to remove.
|
|
295
288
|
*/
|
|
296
289
|
var removeClass = function removeClass(el) {
|
|
297
290
|
var _arguments = arguments;
|
|
@@ -304,10 +297,9 @@
|
|
|
304
297
|
};
|
|
305
298
|
|
|
306
299
|
/**
|
|
307
|
-
* Toggle a class or classes on an element or NodeList
|
|
308
|
-
*
|
|
309
|
-
* @param {
|
|
310
|
-
* @param {String || Array} cl - Class(es) to toggle
|
|
300
|
+
* Toggle a class or classes on an element or NodeList.
|
|
301
|
+
* @param {Node || NodeList} el - Element(s) to toggle class(es) on.
|
|
302
|
+
* @param {String || Array} cl - Class(es) to toggle.
|
|
311
303
|
*/
|
|
312
304
|
var toggleClass = function toggleClass(el) {
|
|
313
305
|
var _arguments = arguments;
|
|
@@ -394,13 +386,15 @@
|
|
|
394
386
|
return _extends.apply(this, arguments);
|
|
395
387
|
}
|
|
396
388
|
|
|
389
|
+
var defaults$3 = {
|
|
390
|
+
autoInit: false,
|
|
391
|
+
stateAttr: 'aria-checked',
|
|
392
|
+
stateValue: 'mixed'
|
|
393
|
+
};
|
|
394
|
+
|
|
397
395
|
var Checkbox = /*#__PURE__*/function () {
|
|
398
396
|
function Checkbox(options) {
|
|
399
|
-
this.defaults =
|
|
400
|
-
autoInit: false,
|
|
401
|
-
stateAttr: 'aria-checked',
|
|
402
|
-
stateValue: 'mixed'
|
|
403
|
-
};
|
|
397
|
+
this.defaults = defaults$3;
|
|
404
398
|
this.settings = _extends({}, this.defaults, options);
|
|
405
399
|
this.__handlerClick = this.handlerClick.bind(this);
|
|
406
400
|
if (this.settings.autoInit) this.init();
|
|
@@ -500,55 +494,6 @@
|
|
|
500
494
|
transition: true
|
|
501
495
|
};
|
|
502
496
|
|
|
503
|
-
var switchToDefault = function switchToDefault(drawerKey, obj) {
|
|
504
|
-
try {
|
|
505
|
-
// Initial guards
|
|
506
|
-
var drawer = obj.getDrawer(drawerKey);
|
|
507
|
-
if (!drawer) return Promise.resolve(obj.drawerNotFound(drawerKey));
|
|
508
|
-
if (!hasClass(drawer, obj.settings.classModal)) return Promise.resolve(); // Tear down modal state
|
|
509
|
-
|
|
510
|
-
setInert(false, obj.settings.selectorInert);
|
|
511
|
-
setOverflowHidden(false, obj.settings.selectorOverflow);
|
|
512
|
-
removeClass(drawer, obj.settings.classModal);
|
|
513
|
-
obj.focusTrap.destroy(); // Restore drawers saved state
|
|
514
|
-
|
|
515
|
-
drawerKey = drawer.getAttribute("data-" + obj.settings.dataDrawer);
|
|
516
|
-
var drawerState = obj.state[drawerKey];
|
|
517
|
-
|
|
518
|
-
if (drawerState == obj.settings.stateOpened) {
|
|
519
|
-
addClass(drawer, obj.settings.stateOpened);
|
|
520
|
-
removeClass(drawer, obj.settings.stateClosed);
|
|
521
|
-
} // Dispatch custom event
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
drawer.dispatchEvent(new CustomEvent(obj.settings.customEventPrefix + 'toDefault', {
|
|
525
|
-
bubbles: true
|
|
526
|
-
}));
|
|
527
|
-
return Promise.resolve(drawer);
|
|
528
|
-
} catch (e) {
|
|
529
|
-
return Promise.reject(e);
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
var switchToModal = function switchToModal(drawerKey, obj) {
|
|
533
|
-
try {
|
|
534
|
-
// Initial guards
|
|
535
|
-
var drawer = obj.getDrawer(drawerKey);
|
|
536
|
-
if (!drawer) return Promise.resolve(obj.drawerNotFound(drawerKey));
|
|
537
|
-
if (hasClass(drawer, obj.settings.classModal)) return Promise.resolve(); // Enable modal state
|
|
538
|
-
|
|
539
|
-
addClass(drawer, obj.settings.classModal);
|
|
540
|
-
addClass(drawer, obj.settings.stateClosed);
|
|
541
|
-
removeClass(drawer, obj.settings.stateOpened); // Dispatch custom event
|
|
542
|
-
|
|
543
|
-
drawer.dispatchEvent(new CustomEvent(obj.settings.customEventPrefix + 'toModal', {
|
|
544
|
-
bubbles: true
|
|
545
|
-
}));
|
|
546
|
-
return Promise.resolve(drawer);
|
|
547
|
-
} catch (e) {
|
|
548
|
-
return Promise.reject(e);
|
|
549
|
-
}
|
|
550
|
-
};
|
|
551
|
-
|
|
552
497
|
var Breakpoint = /*#__PURE__*/function () {
|
|
553
498
|
function Breakpoint(parent) {
|
|
554
499
|
this.mediaQueryLists = [];
|
|
@@ -564,16 +509,23 @@
|
|
|
564
509
|
|
|
565
510
|
var drawers = document.querySelectorAll("[data-" + this.parent.settings.dataBreakpoint + "]");
|
|
566
511
|
drawers.forEach(function (drawer) {
|
|
512
|
+
// Setup mediaQueryList object
|
|
567
513
|
var id = drawer.getAttribute("data-" + _this.parent.settings.dataDrawer);
|
|
568
514
|
var key = drawer.getAttribute("data-" + _this.parent.settings.dataBreakpoint);
|
|
569
515
|
|
|
570
516
|
var bp = _this.getBreakpoint(key);
|
|
571
517
|
|
|
572
|
-
var mql = window.matchMedia('(min-width:' + bp + ')');
|
|
518
|
+
var mql = window.matchMedia('(min-width:' + bp + ')'); // Run match check
|
|
573
519
|
|
|
574
|
-
_this.match(mql, drawer);
|
|
520
|
+
_this.match(mql, drawer); // Conditionally use addListner() for IE11 support
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
if (typeof mql.addEventListener === 'function') {
|
|
524
|
+
mql.addEventListener('change', _this.__check);
|
|
525
|
+
} else {
|
|
526
|
+
mql.addListener(_this.__check);
|
|
527
|
+
} // Push to mediaQueryLists array along with drawer ID
|
|
575
528
|
|
|
576
|
-
mql.addEventListener('change', _this.__check);
|
|
577
529
|
|
|
578
530
|
_this.mediaQueryLists.push({
|
|
579
531
|
'mql': mql,
|
|
@@ -618,9 +570,9 @@
|
|
|
618
570
|
|
|
619
571
|
_proto.match = function match(mql, drawer) {
|
|
620
572
|
if (mql.matches) {
|
|
621
|
-
switchToDefault(drawer
|
|
573
|
+
this.parent.switchToDefault(drawer);
|
|
622
574
|
} else {
|
|
623
|
-
switchToModal(drawer
|
|
575
|
+
this.parent.switchToModal(drawer);
|
|
624
576
|
}
|
|
625
577
|
};
|
|
626
578
|
|
|
@@ -646,6 +598,52 @@
|
|
|
646
598
|
return Breakpoint;
|
|
647
599
|
}();
|
|
648
600
|
|
|
601
|
+
function getDrawer(drawerKey) {
|
|
602
|
+
if (typeof drawerKey !== 'string') return drawerKey;
|
|
603
|
+
return document.querySelector("[data-" + this.settings.dataDrawer + "=\"" + drawerKey + "\"]");
|
|
604
|
+
}
|
|
605
|
+
function drawerNotFound(key) {
|
|
606
|
+
return Promise.reject(new Error("Did not find drawer with key: \"" + key + "\""));
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
var close$2 = function close(drawerKey) {
|
|
610
|
+
try {
|
|
611
|
+
var _this2 = this;
|
|
612
|
+
|
|
613
|
+
var drawer = _this2.getDrawer(drawerKey);
|
|
614
|
+
|
|
615
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
616
|
+
|
|
617
|
+
if (hasClass(drawer, _this2.settings.stateOpened)) {
|
|
618
|
+
_this2.working = true;
|
|
619
|
+
|
|
620
|
+
if (hasClass(drawer, _this2.settings.classModal)) {
|
|
621
|
+
setInert(false, _this2.settings.selectorInert);
|
|
622
|
+
setOverflowHidden(false, _this2.settings.selectorOverflow);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
return Promise.resolve(closeTransition(drawer, _this2.settings)).then(function () {
|
|
626
|
+
_this2.stateSave(drawer);
|
|
627
|
+
|
|
628
|
+
focusTrigger(_this2);
|
|
629
|
+
|
|
630
|
+
_this2.focusTrap.destroy();
|
|
631
|
+
|
|
632
|
+
drawer.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'closed', {
|
|
633
|
+
detail: _this2,
|
|
634
|
+
bubbles: true
|
|
635
|
+
}));
|
|
636
|
+
_this2.working = false;
|
|
637
|
+
return drawer;
|
|
638
|
+
});
|
|
639
|
+
} else {
|
|
640
|
+
return Promise.resolve(drawer);
|
|
641
|
+
}
|
|
642
|
+
} catch (e) {
|
|
643
|
+
return Promise.reject(e);
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
|
|
649
647
|
function handlerClick$2(event) {
|
|
650
648
|
// Working catch
|
|
651
649
|
if (this.working) return; // Toggle data trigger
|
|
@@ -709,6 +707,48 @@
|
|
|
709
707
|
}
|
|
710
708
|
}
|
|
711
709
|
|
|
710
|
+
var open$2 = function open(drawerKey) {
|
|
711
|
+
try {
|
|
712
|
+
var _this2 = this;
|
|
713
|
+
|
|
714
|
+
var drawer = _this2.getDrawer(drawerKey);
|
|
715
|
+
|
|
716
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
717
|
+
|
|
718
|
+
if (!hasClass(drawer, _this2.settings.stateOpened)) {
|
|
719
|
+
_this2.working = true;
|
|
720
|
+
var isModal = hasClass(drawer, _this2.settings.classModal);
|
|
721
|
+
|
|
722
|
+
if (isModal) {
|
|
723
|
+
setOverflowHidden(true, _this2.settings.selectorOverflow);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
return Promise.resolve(openTransition(drawer, _this2.settings)).then(function () {
|
|
727
|
+
_this2.stateSave(drawer);
|
|
728
|
+
|
|
729
|
+
if (isModal) {
|
|
730
|
+
_this2.focusTrap.init(drawer);
|
|
731
|
+
|
|
732
|
+
setInert(true, _this2.settings.selectorInert);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
focusTarget(drawer, _this2.settings);
|
|
736
|
+
drawer.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'opened', {
|
|
737
|
+
detail: _this2,
|
|
738
|
+
bubbles: true
|
|
739
|
+
}));
|
|
740
|
+
_this2.working = false;
|
|
741
|
+
return drawer;
|
|
742
|
+
});
|
|
743
|
+
} else {
|
|
744
|
+
focusTarget(drawer, _this2.settings);
|
|
745
|
+
return Promise.resolve(drawer);
|
|
746
|
+
}
|
|
747
|
+
} catch (e) {
|
|
748
|
+
return Promise.reject(e);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
|
|
712
752
|
function stateSet(settings) {
|
|
713
753
|
// If save state is disabled
|
|
714
754
|
if (!settings.stateSave) return stateClear(settings); // If there isn't an existing state to set
|
|
@@ -753,6 +793,82 @@
|
|
|
753
793
|
return {};
|
|
754
794
|
}
|
|
755
795
|
|
|
796
|
+
var switchToDefault = function switchToDefault(drawerKey) {
|
|
797
|
+
try {
|
|
798
|
+
var _this4 = this;
|
|
799
|
+
|
|
800
|
+
// Initial guards
|
|
801
|
+
var drawer = _this4.getDrawer(drawerKey);
|
|
802
|
+
|
|
803
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
804
|
+
if (!hasClass(drawer, _this4.settings.classModal)) return Promise.resolve(); // Tear down modal state
|
|
805
|
+
|
|
806
|
+
setInert(false, _this4.settings.selectorInert);
|
|
807
|
+
setOverflowHidden(false, _this4.settings.selectorOverflow);
|
|
808
|
+
removeClass(drawer, _this4.settings.classModal);
|
|
809
|
+
|
|
810
|
+
_this4.focusTrap.destroy(); // Restore drawers saved state
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
drawerKey = drawer.getAttribute("data-" + _this4.settings.dataDrawer);
|
|
814
|
+
var drawerState = _this4.state[drawerKey];
|
|
815
|
+
|
|
816
|
+
if (drawerState == _this4.settings.stateOpened) {
|
|
817
|
+
addClass(drawer, _this4.settings.stateOpened);
|
|
818
|
+
removeClass(drawer, _this4.settings.stateClosed);
|
|
819
|
+
} // Dispatch custom event
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
drawer.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'toDefault', {
|
|
823
|
+
bubbles: true
|
|
824
|
+
}));
|
|
825
|
+
return Promise.resolve(drawer);
|
|
826
|
+
} catch (e) {
|
|
827
|
+
return Promise.reject(e);
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
var switchToModal = function switchToModal(drawerKey) {
|
|
831
|
+
try {
|
|
832
|
+
var _this2 = this;
|
|
833
|
+
|
|
834
|
+
// Initial guards
|
|
835
|
+
var drawer = _this2.getDrawer(drawerKey);
|
|
836
|
+
|
|
837
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
838
|
+
if (hasClass(drawer, _this2.settings.classModal)) return Promise.resolve(); // Enable modal state
|
|
839
|
+
|
|
840
|
+
addClass(drawer, _this2.settings.classModal);
|
|
841
|
+
addClass(drawer, _this2.settings.stateClosed);
|
|
842
|
+
removeClass(drawer, _this2.settings.stateOpened); // Dispatch custom event
|
|
843
|
+
|
|
844
|
+
drawer.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'toModal', {
|
|
845
|
+
bubbles: true
|
|
846
|
+
}));
|
|
847
|
+
return Promise.resolve(drawer);
|
|
848
|
+
} catch (e) {
|
|
849
|
+
return Promise.reject(e);
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
var toggle = function toggle(drawerKey) {
|
|
854
|
+
try {
|
|
855
|
+
var _this2 = this;
|
|
856
|
+
|
|
857
|
+
var drawer = _this2.getDrawer(drawerKey);
|
|
858
|
+
|
|
859
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
860
|
+
var isClosed = !hasClass(drawer, _this2.settings.stateOpened);
|
|
861
|
+
|
|
862
|
+
if (isClosed) {
|
|
863
|
+
return Promise.resolve(_this2.open(drawer));
|
|
864
|
+
} else {
|
|
865
|
+
return Promise.resolve(_this2.close(drawer));
|
|
866
|
+
}
|
|
867
|
+
} catch (e) {
|
|
868
|
+
return Promise.reject(e);
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
|
|
756
872
|
var Drawer = /*#__PURE__*/function () {
|
|
757
873
|
function Drawer(options) {
|
|
758
874
|
this.defaults = defaults$2;
|
|
@@ -819,19 +935,12 @@
|
|
|
819
935
|
*/
|
|
820
936
|
;
|
|
821
937
|
|
|
822
|
-
_proto.getDrawer = function getDrawer(drawerKey) {
|
|
823
|
-
|
|
824
|
-
return document.querySelector("[data-" + this.settings.dataDrawer + "=\"" + drawerKey + "\"]");
|
|
825
|
-
};
|
|
826
|
-
|
|
827
|
-
_proto.drawerNotFound = function drawerNotFound(key) {
|
|
828
|
-
return Promise.reject(new Error("Did not find drawer with key: \"" + key + "\""));
|
|
938
|
+
_proto.getDrawer = function getDrawer$1(drawerKey) {
|
|
939
|
+
return getDrawer.call(this, drawerKey);
|
|
829
940
|
};
|
|
830
941
|
|
|
831
942
|
_proto.setTabindex = function setTabindex$1() {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
setTabindex(selectorTabindex);
|
|
943
|
+
return setTabindex("\n [data-" + this.settings.dataDrawer + "]\n [data-" + this.settings.dataDialog + "]\n ");
|
|
835
944
|
}
|
|
836
945
|
/**
|
|
837
946
|
* Save state functionality
|
|
@@ -859,114 +968,27 @@
|
|
|
859
968
|
;
|
|
860
969
|
|
|
861
970
|
_proto.switchToDefault = function switchToDefault$1(drawerKey) {
|
|
862
|
-
return switchToDefault(
|
|
971
|
+
return switchToDefault.call(this, drawerKey);
|
|
863
972
|
};
|
|
864
973
|
|
|
865
974
|
_proto.switchToModal = function switchToModal$1(drawerKey) {
|
|
866
|
-
return switchToModal(
|
|
975
|
+
return switchToModal.call(this, drawerKey);
|
|
867
976
|
}
|
|
868
977
|
/**
|
|
869
978
|
* Change state functionality
|
|
870
979
|
*/
|
|
871
980
|
;
|
|
872
981
|
|
|
873
|
-
_proto.toggle = function toggle(drawerKey) {
|
|
874
|
-
|
|
875
|
-
var _this2 = this;
|
|
876
|
-
|
|
877
|
-
var drawer = _this2.getDrawer(drawerKey);
|
|
878
|
-
|
|
879
|
-
if (!drawer) return Promise.resolve(_this2.drawerNotFound(drawerKey));
|
|
880
|
-
var isClosed = !hasClass(drawer, _this2.settings.stateOpened);
|
|
881
|
-
|
|
882
|
-
if (isClosed) {
|
|
883
|
-
return Promise.resolve(_this2.open(drawer));
|
|
884
|
-
} else {
|
|
885
|
-
return Promise.resolve(_this2.close(drawer));
|
|
886
|
-
}
|
|
887
|
-
} catch (e) {
|
|
888
|
-
return Promise.reject(e);
|
|
889
|
-
}
|
|
982
|
+
_proto.toggle = function toggle$1(drawerKey) {
|
|
983
|
+
return toggle.call(this, drawerKey);
|
|
890
984
|
};
|
|
891
985
|
|
|
892
986
|
_proto.open = function open(drawerKey) {
|
|
893
|
-
|
|
894
|
-
var _this4 = this;
|
|
895
|
-
|
|
896
|
-
var drawer = _this4.getDrawer(drawerKey);
|
|
897
|
-
|
|
898
|
-
if (!drawer) return Promise.resolve(_this4.drawerNotFound(drawerKey));
|
|
899
|
-
|
|
900
|
-
if (!hasClass(drawer, _this4.settings.stateOpened)) {
|
|
901
|
-
_this4.working = true;
|
|
902
|
-
var isModal = hasClass(drawer, _this4.settings.classModal);
|
|
903
|
-
|
|
904
|
-
if (isModal) {
|
|
905
|
-
setOverflowHidden(true, _this4.settings.selectorOverflow);
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
return Promise.resolve(openTransition(drawer, _this4.settings)).then(function () {
|
|
909
|
-
_this4.stateSave(drawer);
|
|
910
|
-
|
|
911
|
-
if (isModal) {
|
|
912
|
-
_this4.focusTrap.init(drawer);
|
|
913
|
-
|
|
914
|
-
setInert(true, _this4.settings.selectorInert);
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
focusTarget(drawer, _this4.settings);
|
|
918
|
-
drawer.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'opened', {
|
|
919
|
-
detail: _this4,
|
|
920
|
-
bubbles: true
|
|
921
|
-
}));
|
|
922
|
-
_this4.working = false;
|
|
923
|
-
return drawer;
|
|
924
|
-
});
|
|
925
|
-
} else {
|
|
926
|
-
focusTarget(drawer, _this4.settings);
|
|
927
|
-
return Promise.resolve(drawer);
|
|
928
|
-
}
|
|
929
|
-
} catch (e) {
|
|
930
|
-
return Promise.reject(e);
|
|
931
|
-
}
|
|
987
|
+
return open$2.call(this, drawerKey);
|
|
932
988
|
};
|
|
933
989
|
|
|
934
990
|
_proto.close = function close(drawerKey) {
|
|
935
|
-
|
|
936
|
-
var _this6 = this;
|
|
937
|
-
|
|
938
|
-
var drawer = _this6.getDrawer(drawerKey);
|
|
939
|
-
|
|
940
|
-
if (!drawer) return Promise.resolve(_this6.drawerNotFound(drawerKey));
|
|
941
|
-
|
|
942
|
-
if (hasClass(drawer, _this6.settings.stateOpened)) {
|
|
943
|
-
_this6.working = true;
|
|
944
|
-
|
|
945
|
-
if (hasClass(drawer, _this6.settings.classModal)) {
|
|
946
|
-
setInert(false, _this6.settings.selectorInert);
|
|
947
|
-
setOverflowHidden(false, _this6.settings.selectorOverflow);
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
return Promise.resolve(closeTransition(drawer, _this6.settings)).then(function () {
|
|
951
|
-
_this6.stateSave(drawer);
|
|
952
|
-
|
|
953
|
-
focusTrigger(_this6);
|
|
954
|
-
|
|
955
|
-
_this6.focusTrap.destroy();
|
|
956
|
-
|
|
957
|
-
drawer.dispatchEvent(new CustomEvent(_this6.settings.customEventPrefix + 'closed', {
|
|
958
|
-
detail: _this6,
|
|
959
|
-
bubbles: true
|
|
960
|
-
}));
|
|
961
|
-
_this6.working = false;
|
|
962
|
-
return drawer;
|
|
963
|
-
});
|
|
964
|
-
} else {
|
|
965
|
-
return Promise.resolve(drawer);
|
|
966
|
-
}
|
|
967
|
-
} catch (e) {
|
|
968
|
-
return Promise.reject(e);
|
|
969
|
-
}
|
|
991
|
+
return close$2.call(this, drawerKey);
|
|
970
992
|
};
|
|
971
993
|
|
|
972
994
|
return Drawer;
|
|
@@ -1000,6 +1022,40 @@
|
|
|
1000
1022
|
transition: true
|
|
1001
1023
|
};
|
|
1002
1024
|
|
|
1025
|
+
var close$1 = function close(returnFocus) {
|
|
1026
|
+
if (returnFocus === void 0) {
|
|
1027
|
+
returnFocus = true;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
try {
|
|
1031
|
+
var _this2 = this;
|
|
1032
|
+
|
|
1033
|
+
var modal = document.querySelector("[data-" + _this2.settings.dataModal + "]." + _this2.settings.stateOpened);
|
|
1034
|
+
|
|
1035
|
+
if (modal) {
|
|
1036
|
+
_this2.working = true;
|
|
1037
|
+
setInert(false, _this2.settings.selectorInert);
|
|
1038
|
+
setOverflowHidden(false, _this2.settings.selectorOverflow);
|
|
1039
|
+
return Promise.resolve(closeTransition(modal, _this2.settings)).then(function () {
|
|
1040
|
+
if (returnFocus) focusTrigger(_this2);
|
|
1041
|
+
|
|
1042
|
+
_this2.focusTrap.destroy();
|
|
1043
|
+
|
|
1044
|
+
modal.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'closed', {
|
|
1045
|
+
detail: _this2,
|
|
1046
|
+
bubbles: true
|
|
1047
|
+
}));
|
|
1048
|
+
_this2.working = false;
|
|
1049
|
+
return modal;
|
|
1050
|
+
});
|
|
1051
|
+
} else {
|
|
1052
|
+
return Promise.resolve(modal);
|
|
1053
|
+
}
|
|
1054
|
+
} catch (e) {
|
|
1055
|
+
return Promise.reject(e);
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1003
1059
|
var handlerClick$1 = function handlerClick(event) {
|
|
1004
1060
|
try {
|
|
1005
1061
|
var _temp3 = function _temp3(_result) {
|
|
@@ -1061,21 +1117,76 @@
|
|
|
1061
1117
|
}
|
|
1062
1118
|
}
|
|
1063
1119
|
|
|
1064
|
-
function
|
|
1065
|
-
|
|
1120
|
+
function getModal(modalKey) {
|
|
1121
|
+
if (typeof modalKey !== 'string') return modalKey;
|
|
1122
|
+
return document.querySelector("[data-" + this.settings.dataModal + "=\"" + modalKey + "\"]");
|
|
1123
|
+
}
|
|
1124
|
+
function modalNotFound(key) {
|
|
1125
|
+
return Promise.reject(new Error("Did not find modal with key: \"" + key + "\""));
|
|
1126
|
+
}
|
|
1127
|
+
function moveModals(type, ref) {
|
|
1128
|
+
if (type === void 0) {
|
|
1129
|
+
type = this.settings.moveModals.type;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
if (ref === void 0) {
|
|
1133
|
+
ref = this.settings.moveModals.ref;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
var modals = document.querySelectorAll("[data-" + this.settings.dataModal + "]");
|
|
1137
|
+
if (modals.length) moveElement(modals, type, ref);
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
function setInitialState() {
|
|
1141
|
+
var _this = this;
|
|
1142
|
+
|
|
1143
|
+
var modals = document.querySelectorAll("[data-" + this.settings.dataModal + "]");
|
|
1066
1144
|
modals.forEach(function (el) {
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
}
|
|
1145
|
+
// Remove opened state setup
|
|
1146
|
+
if (el.classList.contains(_this.settings.stateOpened)) {
|
|
1147
|
+
setInert(false, _this.settings.selectorInert);
|
|
1148
|
+
setOverflowHidden(false, _this.settings.selectorOverflow);
|
|
1149
|
+
focusTrigger(_this);
|
|
1073
1150
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1151
|
+
_this.focusTrap.destroy();
|
|
1152
|
+
} // Remove all state classes and add the default state (closed)
|
|
1153
|
+
|
|
1154
|
+
|
|
1155
|
+
removeClass(el, _this.settings.stateOpened, _this.settings.stateOpening, _this.settings.stateClosing);
|
|
1156
|
+
addClass(el, _this.settings.stateClosed);
|
|
1076
1157
|
});
|
|
1077
1158
|
}
|
|
1078
1159
|
|
|
1160
|
+
var open$1 = function open(modalKey) {
|
|
1161
|
+
try {
|
|
1162
|
+
var _this2 = this;
|
|
1163
|
+
|
|
1164
|
+
var modal = getModal.call(_this2, modalKey);
|
|
1165
|
+
if (!modal) return Promise.resolve(modalNotFound(modalKey));
|
|
1166
|
+
|
|
1167
|
+
if (hasClass(modal, _this2.settings.stateClosed)) {
|
|
1168
|
+
_this2.working = true;
|
|
1169
|
+
setOverflowHidden(true, _this2.settings.selectorOverflow);
|
|
1170
|
+
return Promise.resolve(openTransition(modal, _this2.settings)).then(function () {
|
|
1171
|
+
_this2.focusTrap.init(modal);
|
|
1172
|
+
|
|
1173
|
+
focusTarget(modal, _this2.settings);
|
|
1174
|
+
setInert(true, _this2.settings.selectorInert);
|
|
1175
|
+
modal.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'opened', {
|
|
1176
|
+
detail: _this2,
|
|
1177
|
+
bubbles: true
|
|
1178
|
+
}));
|
|
1179
|
+
_this2.working = false;
|
|
1180
|
+
return modal;
|
|
1181
|
+
});
|
|
1182
|
+
} else {
|
|
1183
|
+
return Promise.resolve(modal);
|
|
1184
|
+
}
|
|
1185
|
+
} catch (e) {
|
|
1186
|
+
return Promise.reject(e);
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1079
1190
|
var Modal = /*#__PURE__*/function () {
|
|
1080
1191
|
function Modal(options) {
|
|
1081
1192
|
this.defaults = defaults$1;
|
|
@@ -1097,13 +1208,12 @@
|
|
|
1097
1208
|
|
|
1098
1209
|
if (options) this.settings = _extends({}, this.settings, options);
|
|
1099
1210
|
this.moveModals();
|
|
1211
|
+
this.setInitialState();
|
|
1100
1212
|
|
|
1101
1213
|
if (this.settings.setTabindex) {
|
|
1102
1214
|
this.setTabindex();
|
|
1103
1215
|
}
|
|
1104
1216
|
|
|
1105
|
-
this.setInitialState();
|
|
1106
|
-
|
|
1107
1217
|
if (this.settings.eventListeners) {
|
|
1108
1218
|
this.initEventListeners();
|
|
1109
1219
|
}
|
|
@@ -1137,36 +1247,20 @@
|
|
|
1137
1247
|
*/
|
|
1138
1248
|
;
|
|
1139
1249
|
|
|
1140
|
-
_proto.getModal = function getModal(modalKey) {
|
|
1141
|
-
|
|
1142
|
-
return document.querySelector("[data-" + this.settings.dataModal + "=\"" + modalKey + "\"]");
|
|
1143
|
-
};
|
|
1144
|
-
|
|
1145
|
-
_proto.modalNotFound = function modalNotFound(key) {
|
|
1146
|
-
return Promise.reject(new Error("Did not find modal with key: \"" + key + "\""));
|
|
1250
|
+
_proto.getModal = function getModal$1(modalKey) {
|
|
1251
|
+
return getModal.call(this, modalKey);
|
|
1147
1252
|
};
|
|
1148
1253
|
|
|
1149
1254
|
_proto.setTabindex = function setTabindex$1() {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
setTabindex(selectorTabindex);
|
|
1255
|
+
return setTabindex("\n [data-" + this.settings.dataModal + "]\n [data-" + this.settings.dataDialog + "]\n ");
|
|
1153
1256
|
};
|
|
1154
1257
|
|
|
1155
1258
|
_proto.setInitialState = function setInitialState$1() {
|
|
1156
|
-
setInitialState(this);
|
|
1259
|
+
return setInitialState.call(this);
|
|
1157
1260
|
};
|
|
1158
1261
|
|
|
1159
|
-
_proto.moveModals = function moveModals(type, ref) {
|
|
1160
|
-
|
|
1161
|
-
type = this.settings.moveModals.type;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
if (ref === void 0) {
|
|
1165
|
-
ref = this.settings.moveModals.ref;
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
var modals = document.querySelectorAll("[data-" + this.settings.dataModal + "]");
|
|
1169
|
-
if (modals.length) moveElement(modals, type, ref);
|
|
1262
|
+
_proto.moveModals = function moveModals$1(type, ref) {
|
|
1263
|
+
return moveModals.call(this, type, ref);
|
|
1170
1264
|
}
|
|
1171
1265
|
/**
|
|
1172
1266
|
* Change state functionality
|
|
@@ -1174,68 +1268,11 @@
|
|
|
1174
1268
|
;
|
|
1175
1269
|
|
|
1176
1270
|
_proto.open = function open(modalKey) {
|
|
1177
|
-
|
|
1178
|
-
var _this2 = this;
|
|
1179
|
-
|
|
1180
|
-
var modal = _this2.getModal(modalKey);
|
|
1181
|
-
|
|
1182
|
-
if (!modal) return Promise.resolve(_this2.modalNotFound(modalKey));
|
|
1183
|
-
|
|
1184
|
-
if (hasClass(modal, _this2.settings.stateClosed)) {
|
|
1185
|
-
_this2.working = true;
|
|
1186
|
-
setOverflowHidden(true, _this2.settings.selectorOverflow);
|
|
1187
|
-
return Promise.resolve(openTransition(modal, _this2.settings)).then(function () {
|
|
1188
|
-
_this2.focusTrap.init(modal);
|
|
1189
|
-
|
|
1190
|
-
focusTarget(modal, _this2.settings);
|
|
1191
|
-
setInert(true, _this2.settings.selectorInert);
|
|
1192
|
-
modal.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'opened', {
|
|
1193
|
-
detail: _this2,
|
|
1194
|
-
bubbles: true
|
|
1195
|
-
}));
|
|
1196
|
-
_this2.working = false;
|
|
1197
|
-
return modal;
|
|
1198
|
-
});
|
|
1199
|
-
} else {
|
|
1200
|
-
return Promise.resolve(modal);
|
|
1201
|
-
}
|
|
1202
|
-
} catch (e) {
|
|
1203
|
-
return Promise.reject(e);
|
|
1204
|
-
}
|
|
1271
|
+
return open$1.call(this, modalKey);
|
|
1205
1272
|
};
|
|
1206
1273
|
|
|
1207
1274
|
_proto.close = function close(returnFocus) {
|
|
1208
|
-
|
|
1209
|
-
returnFocus = true;
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
try {
|
|
1213
|
-
var _this4 = this;
|
|
1214
|
-
|
|
1215
|
-
var modal = document.querySelector("[data-" + _this4.settings.dataModal + "]." + _this4.settings.stateOpened);
|
|
1216
|
-
|
|
1217
|
-
if (modal) {
|
|
1218
|
-
_this4.working = true;
|
|
1219
|
-
setInert(false, _this4.settings.selectorInert);
|
|
1220
|
-
setOverflowHidden(false, _this4.settings.selectorOverflow);
|
|
1221
|
-
return Promise.resolve(closeTransition(modal, _this4.settings)).then(function () {
|
|
1222
|
-
if (returnFocus) focusTrigger(_this4);
|
|
1223
|
-
|
|
1224
|
-
_this4.focusTrap.destroy();
|
|
1225
|
-
|
|
1226
|
-
modal.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'closed', {
|
|
1227
|
-
detail: _this4,
|
|
1228
|
-
bubbles: true
|
|
1229
|
-
}));
|
|
1230
|
-
_this4.working = false;
|
|
1231
|
-
return modal;
|
|
1232
|
-
});
|
|
1233
|
-
} else {
|
|
1234
|
-
return Promise.resolve(modal);
|
|
1235
|
-
}
|
|
1236
|
-
} catch (e) {
|
|
1237
|
-
return Promise.reject(e);
|
|
1238
|
-
}
|
|
1275
|
+
return close$1.call(this, returnFocus);
|
|
1239
1276
|
};
|
|
1240
1277
|
|
|
1241
1278
|
return Modal;
|
|
@@ -1257,9 +1294,9 @@
|
|
|
1257
1294
|
placement: 'bottom-start'
|
|
1258
1295
|
};
|
|
1259
1296
|
|
|
1260
|
-
function
|
|
1297
|
+
function close(popover) {
|
|
1261
1298
|
// Update state class
|
|
1262
|
-
popover.target.classList.remove(
|
|
1299
|
+
popover.target.classList.remove(this.settings.stateActive); // Update a11y attributes
|
|
1263
1300
|
|
|
1264
1301
|
popover.trigger.setAttribute('aria-expanded', 'false'); // Disable popper event listeners
|
|
1265
1302
|
|
|
@@ -1270,39 +1307,43 @@
|
|
|
1270
1307
|
}]
|
|
1271
1308
|
}); // Update collection status with new state
|
|
1272
1309
|
|
|
1273
|
-
var index =
|
|
1310
|
+
var index = this.collection.findIndex(function (item) {
|
|
1274
1311
|
return item.target === popover.target;
|
|
1275
1312
|
});
|
|
1276
|
-
|
|
1313
|
+
this.collection[index].state = 'closed'; // Clear the memory if popover trigger matches the ones saved in memory
|
|
1277
1314
|
|
|
1278
|
-
if (popover.trigger ===
|
|
1279
|
-
|
|
1315
|
+
if (popover.trigger === this.memory.trigger) {
|
|
1316
|
+
this.memory.trigger = null;
|
|
1280
1317
|
} // Return the popover
|
|
1281
1318
|
|
|
1282
1319
|
|
|
1283
1320
|
return popover;
|
|
1284
1321
|
}
|
|
1285
|
-
function
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1322
|
+
function closeAll() {
|
|
1323
|
+
var _this = this;
|
|
1324
|
+
|
|
1325
|
+
this.collection.forEach(function (popover) {
|
|
1326
|
+
if (popover.state === 'opened') {
|
|
1327
|
+
_this.close(popover);
|
|
1289
1328
|
}
|
|
1290
1329
|
}); // Return the collection
|
|
1291
1330
|
|
|
1292
|
-
return
|
|
1331
|
+
return this.collection;
|
|
1293
1332
|
}
|
|
1294
|
-
function
|
|
1295
|
-
|
|
1296
|
-
|
|
1333
|
+
function closeCheck(popover) {
|
|
1334
|
+
var _this2 = this;
|
|
1335
|
+
|
|
1336
|
+
// Only run closeCheck if provided popover is currently open
|
|
1337
|
+
if (popover.state != 'opened') return; // Needed to correctly check which element is currently being focused
|
|
1297
1338
|
|
|
1298
1339
|
setTimeout(function () {
|
|
1299
1340
|
// Check if trigger or target are being hovered
|
|
1300
1341
|
var isHovered = popover.target.closest(':hover') === popover.target || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or target are being focused
|
|
1301
1342
|
|
|
1302
|
-
var isFocused = document.activeElement.closest("[data-" +
|
|
1343
|
+
var isFocused = document.activeElement.closest("[data-" + _this2.settings.dataPopover + "]") === popover.target || document.activeElement.closest("[data-" + _this2.settings.dataTrigger + "]") === popover.trigger; // Close if the trigger and target are not currently hovered or focused
|
|
1303
1344
|
|
|
1304
1345
|
if (!isHovered && !isFocused) {
|
|
1305
|
-
|
|
1346
|
+
_this2.close(popover);
|
|
1306
1347
|
} // Return the popover
|
|
1307
1348
|
|
|
1308
1349
|
|
|
@@ -1310,6 +1351,57 @@
|
|
|
1310
1351
|
}, 1);
|
|
1311
1352
|
}
|
|
1312
1353
|
|
|
1354
|
+
function handlerClick(popover) {
|
|
1355
|
+
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
1356
|
+
this.close(popover);
|
|
1357
|
+
} else {
|
|
1358
|
+
this.memory.trigger = popover.trigger;
|
|
1359
|
+
this.open(popover);
|
|
1360
|
+
documentClick.call(this, popover);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
function handlerKeydown(event) {
|
|
1364
|
+
var _this = this;
|
|
1365
|
+
|
|
1366
|
+
switch (event.key) {
|
|
1367
|
+
case 'Escape':
|
|
1368
|
+
if (this.memory.trigger) {
|
|
1369
|
+
this.memory.trigger.focus();
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
this.closeAll();
|
|
1373
|
+
return;
|
|
1374
|
+
|
|
1375
|
+
case 'Tab':
|
|
1376
|
+
this.collection.forEach(function (popover) {
|
|
1377
|
+
closeCheck.call(_this, popover);
|
|
1378
|
+
});
|
|
1379
|
+
return;
|
|
1380
|
+
|
|
1381
|
+
default:
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
function documentClick(popover) {
|
|
1386
|
+
var obj = this;
|
|
1387
|
+
document.addEventListener('click', function _f(event) {
|
|
1388
|
+
var result = event.target.closest("[data-" + obj.settings.dataPopover + "], [data-" + obj.settings.dataTrigger + "]");
|
|
1389
|
+
var match = result === popover.target || result === popover.trigger;
|
|
1390
|
+
|
|
1391
|
+
if (!match) {
|
|
1392
|
+
if (popover.target.classList.contains(obj.settings.stateActive)) {
|
|
1393
|
+
obj.close(popover);
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
this.removeEventListener('click', _f);
|
|
1397
|
+
} else {
|
|
1398
|
+
if (!popover.target.classList.contains(obj.settings.stateActive)) {
|
|
1399
|
+
this.removeEventListener('click', _f);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1313
1405
|
function getConfig(el, settings) {
|
|
1314
1406
|
// Get the computed styles of the popover
|
|
1315
1407
|
var styles = getComputedStyle(el); // Setup the config obj with default values
|
|
@@ -1434,16 +1526,16 @@
|
|
|
1434
1526
|
}
|
|
1435
1527
|
}
|
|
1436
1528
|
|
|
1437
|
-
function
|
|
1529
|
+
function open(popover) {
|
|
1438
1530
|
// Update state class
|
|
1439
|
-
popover.target.classList.add(
|
|
1531
|
+
popover.target.classList.add(this.settings.stateActive); // Update a11y attributes
|
|
1440
1532
|
|
|
1441
1533
|
popover.trigger.setAttribute('aria-expanded', 'true'); // Update popover config
|
|
1442
1534
|
|
|
1443
|
-
popover.config = getConfig(popover.target,
|
|
1535
|
+
popover.config = getConfig(popover.target, this.settings); // Enable popper event listeners and set placement/modifiers
|
|
1444
1536
|
|
|
1445
1537
|
popover.popper.setOptions({
|
|
1446
|
-
placement: getData(popover.target,
|
|
1538
|
+
placement: getData(popover.target, this.settings.dataPlacement, popover.config['placement']),
|
|
1447
1539
|
modifiers: [{
|
|
1448
1540
|
name: 'eventListeners',
|
|
1449
1541
|
enabled: true
|
|
@@ -1452,64 +1544,14 @@
|
|
|
1452
1544
|
|
|
1453
1545
|
popover.popper.update(); // Update collection status with new state
|
|
1454
1546
|
|
|
1455
|
-
var index =
|
|
1547
|
+
var index = this.collection.findIndex(function (item) {
|
|
1456
1548
|
return item.target === popover.target;
|
|
1457
1549
|
});
|
|
1458
|
-
|
|
1550
|
+
this.collection[index].state = 'opened'; // Return the popover
|
|
1459
1551
|
|
|
1460
1552
|
return popover;
|
|
1461
1553
|
}
|
|
1462
1554
|
|
|
1463
|
-
function handlerClick(popover) {
|
|
1464
|
-
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
1465
|
-
hide$2(popover, this);
|
|
1466
|
-
} else {
|
|
1467
|
-
this.memory.trigger = popover.trigger;
|
|
1468
|
-
show(popover, this);
|
|
1469
|
-
documentClick(popover, this);
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
function handlerKeydown(event) {
|
|
1473
|
-
var _this = this;
|
|
1474
|
-
|
|
1475
|
-
switch (event.key) {
|
|
1476
|
-
case 'Escape':
|
|
1477
|
-
if (this.memory.trigger) {
|
|
1478
|
-
this.memory.trigger.focus();
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
hideAll(this);
|
|
1482
|
-
return;
|
|
1483
|
-
|
|
1484
|
-
case 'Tab':
|
|
1485
|
-
this.collection.forEach(function (popover) {
|
|
1486
|
-
hideCheck(popover, _this);
|
|
1487
|
-
});
|
|
1488
|
-
return;
|
|
1489
|
-
|
|
1490
|
-
default:
|
|
1491
|
-
return;
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
function documentClick(popover, obj) {
|
|
1495
|
-
document.addEventListener('click', function _f(event) {
|
|
1496
|
-
var result = event.target.closest("[data-" + obj.settings.dataPopover + "], [data-" + obj.settings.dataTrigger + "]");
|
|
1497
|
-
var match = result === popover.target || result === popover.trigger;
|
|
1498
|
-
|
|
1499
|
-
if (!match) {
|
|
1500
|
-
if (popover.target.classList.contains(obj.settings.stateActive)) {
|
|
1501
|
-
hide$2(popover, obj);
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
this.removeEventListener('click', _f);
|
|
1505
|
-
} else {
|
|
1506
|
-
if (!popover.target.classList.contains(obj.settings.stateActive)) {
|
|
1507
|
-
this.removeEventListener('click', _f);
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
});
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
1555
|
var top = 'top';
|
|
1514
1556
|
var bottom = 'bottom';
|
|
1515
1557
|
var right = 'right';
|
|
@@ -3293,11 +3335,11 @@
|
|
|
3293
3335
|
defaultModifiers: defaultModifiers
|
|
3294
3336
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
3295
3337
|
|
|
3296
|
-
function register(trigger, target
|
|
3338
|
+
function register(trigger, target) {
|
|
3297
3339
|
// If no target is passed
|
|
3298
3340
|
if (!target) {
|
|
3299
3341
|
// Try and get the target
|
|
3300
|
-
target = getPopover(trigger,
|
|
3342
|
+
target = getPopover(trigger, this.settings); // If still no target is returned, log an error and return false
|
|
3301
3343
|
|
|
3302
3344
|
if (!target) {
|
|
3303
3345
|
console.error('No popover associated with the provided trigger:', trigger);
|
|
@@ -3306,7 +3348,7 @@
|
|
|
3306
3348
|
} // Check if this item has already been registered in the collection
|
|
3307
3349
|
|
|
3308
3350
|
|
|
3309
|
-
var index =
|
|
3351
|
+
var index = this.collection.findIndex(function (item) {
|
|
3310
3352
|
return item.trigger === trigger && item.target === target;
|
|
3311
3353
|
}); // Initiate popover variable
|
|
3312
3354
|
|
|
@@ -3314,45 +3356,45 @@
|
|
|
3314
3356
|
|
|
3315
3357
|
if (index >= 0) {
|
|
3316
3358
|
// Set popover as item from collection
|
|
3317
|
-
popover =
|
|
3359
|
+
popover = this.collection[index];
|
|
3318
3360
|
} else {
|
|
3319
3361
|
// Create popper instance
|
|
3320
3362
|
var popperInstance = createPopper(trigger, target); // Build popover object and push to collection array
|
|
3321
3363
|
|
|
3322
3364
|
popover = {
|
|
3323
|
-
state: '
|
|
3365
|
+
state: 'closed',
|
|
3324
3366
|
trigger: trigger,
|
|
3325
3367
|
target: target,
|
|
3326
3368
|
popper: popperInstance,
|
|
3327
|
-
config: getConfig(target,
|
|
3369
|
+
config: getConfig(target, this.settings)
|
|
3328
3370
|
}; // Add item to collection
|
|
3329
3371
|
|
|
3330
|
-
|
|
3372
|
+
this.collection.push(popover);
|
|
3331
3373
|
} // Setup event listeners
|
|
3332
3374
|
|
|
3333
3375
|
|
|
3334
|
-
registerEventListeners(
|
|
3376
|
+
registerEventListeners.call(this, popover); // Set initial state of popover
|
|
3335
3377
|
|
|
3336
|
-
if (popover.target.classList.contains(
|
|
3337
|
-
|
|
3338
|
-
documentClick(
|
|
3378
|
+
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
3379
|
+
this.open(popover);
|
|
3380
|
+
documentClick.call(this, popover);
|
|
3339
3381
|
} else {
|
|
3340
|
-
|
|
3382
|
+
this.close(popover);
|
|
3341
3383
|
} // Return the popover object
|
|
3342
3384
|
|
|
3343
3385
|
|
|
3344
3386
|
return popover;
|
|
3345
3387
|
}
|
|
3346
|
-
function deregister(popover
|
|
3388
|
+
function deregister(popover) {
|
|
3347
3389
|
// Check if this item has been registered in the collection
|
|
3348
|
-
var index =
|
|
3390
|
+
var index = this.collection.findIndex(function (item) {
|
|
3349
3391
|
return item.trigger === popover.trigger && item.target === popover.target;
|
|
3350
3392
|
}); // If the item exists in the collection
|
|
3351
3393
|
|
|
3352
3394
|
if (index >= 0) {
|
|
3353
|
-
//
|
|
3354
|
-
if (popover.state === '
|
|
3355
|
-
|
|
3395
|
+
// Close the popover
|
|
3396
|
+
if (popover.state === 'opened') {
|
|
3397
|
+
this.close(popover);
|
|
3356
3398
|
} // Clean up the popper instance
|
|
3357
3399
|
|
|
3358
3400
|
|
|
@@ -3360,28 +3402,28 @@
|
|
|
3360
3402
|
|
|
3361
3403
|
deregisterEventListeners(popover); // Remove item from collection
|
|
3362
3404
|
|
|
3363
|
-
|
|
3405
|
+
this.collection.splice(index, 1);
|
|
3364
3406
|
} // Return the new collection
|
|
3365
3407
|
|
|
3366
3408
|
|
|
3367
|
-
return
|
|
3409
|
+
return this.collection;
|
|
3368
3410
|
}
|
|
3369
|
-
function registerEventListeners(popover
|
|
3411
|
+
function registerEventListeners(popover) {
|
|
3370
3412
|
// If event listeners aren't already setup
|
|
3371
3413
|
if (!popover.__eventListeners) {
|
|
3372
3414
|
// Add event listeners based on event type
|
|
3373
|
-
var eventType = getData(popover.target,
|
|
3415
|
+
var eventType = getData(popover.target, this.settings.dataEventType, popover.config['event']);
|
|
3374
3416
|
|
|
3375
3417
|
if (eventType === 'hover') {
|
|
3376
3418
|
// Setup event listeners object for hover
|
|
3377
3419
|
popover.__eventListeners = [{
|
|
3378
3420
|
el: ['trigger'],
|
|
3379
3421
|
type: ['mouseenter', 'focus'],
|
|
3380
|
-
listener:
|
|
3422
|
+
listener: open.bind(this, popover)
|
|
3381
3423
|
}, {
|
|
3382
3424
|
el: ['trigger', 'target'],
|
|
3383
3425
|
type: ['mouseleave', 'focusout'],
|
|
3384
|
-
listener:
|
|
3426
|
+
listener: closeCheck.bind(this, popover)
|
|
3385
3427
|
}]; // Loop through listeners and apply to appropriate elements
|
|
3386
3428
|
|
|
3387
3429
|
popover.__eventListeners.forEach(function (evObj) {
|
|
@@ -3396,7 +3438,7 @@
|
|
|
3396
3438
|
popover.__eventListeners = [{
|
|
3397
3439
|
el: ['trigger'],
|
|
3398
3440
|
type: ['click'],
|
|
3399
|
-
listener: handlerClick.bind(
|
|
3441
|
+
listener: handlerClick.bind(this, popover)
|
|
3400
3442
|
}]; // Loop through listeners and apply to appropriate elements
|
|
3401
3443
|
|
|
3402
3444
|
popover.__eventListeners.forEach(function (evObj) {
|
|
@@ -3431,24 +3473,26 @@
|
|
|
3431
3473
|
|
|
3432
3474
|
return popover;
|
|
3433
3475
|
}
|
|
3434
|
-
function registerCollection(
|
|
3476
|
+
function registerCollection() {
|
|
3477
|
+
var _this = this;
|
|
3478
|
+
|
|
3435
3479
|
// Get all the triggers
|
|
3436
|
-
var triggers = document.querySelectorAll("[data-" +
|
|
3480
|
+
var triggers = document.querySelectorAll("[data-" + this.settings.dataTrigger + "]");
|
|
3437
3481
|
triggers.forEach(function (trigger) {
|
|
3438
3482
|
// Register the popover and save to collection array
|
|
3439
|
-
register(trigger, false
|
|
3483
|
+
_this.register(trigger, false);
|
|
3440
3484
|
}); // Return the popover collection
|
|
3441
3485
|
|
|
3442
|
-
return
|
|
3486
|
+
return this.collection;
|
|
3443
3487
|
}
|
|
3444
|
-
function deregisterCollection(
|
|
3488
|
+
function deregisterCollection() {
|
|
3445
3489
|
// Loop through all items within the collection and pass them to deregister()
|
|
3446
|
-
while (
|
|
3447
|
-
deregister(
|
|
3490
|
+
while (this.collection.length > 0) {
|
|
3491
|
+
this.deregister(this.collection[0]);
|
|
3448
3492
|
} // Return the popover collection
|
|
3449
3493
|
|
|
3450
3494
|
|
|
3451
|
-
return
|
|
3495
|
+
return this.collection;
|
|
3452
3496
|
}
|
|
3453
3497
|
|
|
3454
3498
|
var Popover = /*#__PURE__*/function () {
|
|
@@ -3473,8 +3517,7 @@
|
|
|
3473
3517
|
// Update settings with passed options
|
|
3474
3518
|
if (options) this.settings = _extends({}, this.settings, options); // Build the collections array with popover instances
|
|
3475
3519
|
|
|
3476
|
-
registerCollection(
|
|
3477
|
-
|
|
3520
|
+
this.registerCollection(); // If eventListeners is enabled
|
|
3478
3521
|
|
|
3479
3522
|
if (this.settings.eventListeners) {
|
|
3480
3523
|
// Pass false to initEventListeners() since registerCollection()
|
|
@@ -3485,8 +3528,7 @@
|
|
|
3485
3528
|
|
|
3486
3529
|
_proto.destroy = function destroy() {
|
|
3487
3530
|
// Deregister all popovers from collection
|
|
3488
|
-
deregisterCollection(
|
|
3489
|
-
|
|
3531
|
+
this.deregisterCollection(); // If eventListeners is enabled
|
|
3490
3532
|
|
|
3491
3533
|
if (this.settings.eventListeners) {
|
|
3492
3534
|
// Pass false to destroyEventListeners() since deregisterCollection()
|
|
@@ -3509,7 +3551,7 @@
|
|
|
3509
3551
|
if (processCollection) {
|
|
3510
3552
|
// Loop through collection and setup event listeners
|
|
3511
3553
|
this.collection.forEach(function (popover) {
|
|
3512
|
-
registerEventListeners(
|
|
3554
|
+
registerEventListeners.call(_this, popover);
|
|
3513
3555
|
});
|
|
3514
3556
|
} // Add keydown global event listener
|
|
3515
3557
|
|
|
@@ -3542,35 +3584,35 @@
|
|
|
3542
3584
|
target = false;
|
|
3543
3585
|
}
|
|
3544
3586
|
|
|
3545
|
-
return register(trigger, target
|
|
3587
|
+
return register.call(this, trigger, target);
|
|
3546
3588
|
};
|
|
3547
3589
|
|
|
3548
3590
|
_proto.deregister = function deregister$1(popover) {
|
|
3549
|
-
return deregister(
|
|
3591
|
+
return deregister.call(this, popover);
|
|
3550
3592
|
};
|
|
3551
3593
|
|
|
3552
3594
|
_proto.registerCollection = function registerCollection$1() {
|
|
3553
|
-
return registerCollection(this);
|
|
3595
|
+
return registerCollection.call(this);
|
|
3554
3596
|
};
|
|
3555
3597
|
|
|
3556
3598
|
_proto.deregisterCollection = function deregisterCollection$1() {
|
|
3557
|
-
return deregisterCollection(this);
|
|
3599
|
+
return deregisterCollection.call(this);
|
|
3558
3600
|
}
|
|
3559
3601
|
/**
|
|
3560
3602
|
* Change state functionality
|
|
3561
3603
|
*/
|
|
3562
3604
|
;
|
|
3563
3605
|
|
|
3564
|
-
_proto.
|
|
3565
|
-
return
|
|
3606
|
+
_proto.open = function open$1(popover) {
|
|
3607
|
+
return open.call(this, popover);
|
|
3566
3608
|
};
|
|
3567
3609
|
|
|
3568
|
-
_proto.
|
|
3569
|
-
return
|
|
3610
|
+
_proto.close = function close$1(popover) {
|
|
3611
|
+
return close.call(this, popover);
|
|
3570
3612
|
};
|
|
3571
3613
|
|
|
3572
|
-
_proto.
|
|
3573
|
-
return
|
|
3614
|
+
_proto.closeAll = function closeAll$1() {
|
|
3615
|
+
return closeAll.call(this);
|
|
3574
3616
|
};
|
|
3575
3617
|
|
|
3576
3618
|
return Popover;
|