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.
@@ -34,10 +34,9 @@ const setTabindex = selector => {
34
34
  };
35
35
 
36
36
  /**
37
- * Adds a class or classes to an element or NodeList
38
- * ---
39
- * @param {Node || NodeList} el - Element(s) to add class(es) to
40
- * @param {String || Array} cl - Class(es) to add
37
+ * Adds a class or classes to a Node or NodeList.
38
+ * @param {Node || NodeList} el - Element(s) to add class(es) to.
39
+ * @param {String || Array} cl - Class(es) to add.
41
40
  */
42
41
  const addClass = (el, ...cl) => {
43
42
  el = el.forEach ? el : [el];
@@ -47,10 +46,9 @@ const addClass = (el, ...cl) => {
47
46
  };
48
47
 
49
48
  /**
50
- * Takes a hyphen cased string and converts it to camel case
51
- * ---
52
- * @param {String } str - the string to convert to camel case
53
- * @returns {Boolean} - returns a camel cased string
49
+ * Takes a hyphen cased string and converts it to camel case.
50
+ * @param {String } str - the string to convert to camel case.
51
+ * @returns {Boolean} - returns a camel cased string.
54
52
  */
55
53
  const camelCase = str => {
56
54
  return str.replace(/-([a-z])/g, function (g) {
@@ -169,23 +167,21 @@ class FocusTrap {
169
167
  }
170
168
 
171
169
  /**
172
- * Get an element(s) from a selector or return value if not a string
173
- * ---
174
- * @param {String} selector - Selector to query
175
- * @param {Boolean} single - Whether to return a single or all matches
170
+ * Get an element(s) from a selector or return value if not a string.
171
+ * @param {String} selector - Selector to query.
172
+ * @param {Boolean} single - Whether to return a single or all matches.
176
173
  */
177
174
  const getElement = function getElement(selector, single = 0) {
178
- if (typeof selector != 'string') return selector;
175
+ if (typeof selector !== 'string') return selector;
179
176
  return single ? document.querySelector(selector) : document.querySelectorAll(selector);
180
177
  };
181
178
 
182
179
  /**
183
- * Checks an element or NodeList whether they contain a class or classes
180
+ * Checks an element or NodeList whether they contain a class or classes.
184
181
  * Ref: https://davidwalsh.name/nodelist-array
185
- * ---
186
- * @param {Node} el - Element(s) to check class(es) on
187
- * @param {String || Array} c - Class(es) to check
188
- * @returns {Boolean} - Returns true if class exists, otherwise false
182
+ * @param {Node} el - Element(s) to check class(es) on.
183
+ * @param {String || Array} c - Class(es) to check.
184
+ * @returns {Boolean} - Returns true if class exists, otherwise false.
189
185
  */
190
186
  const hasClass = (el, ...cl) => {
191
187
  el = el.forEach ? el : [el];
@@ -198,10 +194,9 @@ const hasClass = (el, ...cl) => {
198
194
  };
199
195
 
200
196
  /**
201
- * Takes a camel cased string and converts it to hyphen case
202
- * ---
203
- * @param {String } str - the string to convert to hyphen case
204
- * @returns {Boolean} - returns a hyphen cased string
197
+ * Takes a camel cased string and converts it to hyphen case.
198
+ * @param {String } str - the string to convert to hyphen case.
199
+ * @returns {Boolean} - returns a hyphen cased string.
205
200
  */
206
201
  const hyphenCase = str => {
207
202
  return str.replace(/([a-z][A-Z])/g, function (g) {
@@ -210,11 +205,10 @@ const hyphenCase = str => {
210
205
  };
211
206
 
212
207
  /**
213
- * Moves element(s) in the DOM based on a reference and move type
214
- * ---
215
- * @param {String} target - The element(s) to move
216
- * @param {String} type - Move type can be 'after', 'before', 'append' or 'prepend'
217
- * @param {String} reference - The reference element the move is relative to
208
+ * Moves element(s) in the DOM based on a reference and move type.
209
+ * @param {String} target - The element(s) to move.
210
+ * @param {String} type - Move type can be 'after', 'before', 'append' or 'prepend'.
211
+ * @param {String} reference - The reference element the move is relative to.
218
212
  */
219
213
 
220
214
  function moveElement(target, type, reference = false) {
@@ -265,10 +259,9 @@ function moveElement(target, type, reference = false) {
265
259
  }
266
260
 
267
261
  /**
268
- * Remove a class or classes from an element or NodeList
269
- * ---
270
- * @param {Node || NodeList} el - Element(s) to remove class(es) from
271
- * @param {String || Array} cl - Class(es) to remove
262
+ * Remove a class or classes from an element or NodeList.
263
+ * @param {Node || NodeList} el - Element(s) to remove class(es) from.
264
+ * @param {String || Array} cl - Class(es) to remove.
272
265
  */
273
266
  const removeClass = (el, ...cl) => {
274
267
  el = el.forEach ? el : [el];
@@ -278,10 +271,9 @@ const removeClass = (el, ...cl) => {
278
271
  };
279
272
 
280
273
  /**
281
- * Toggle a class or classes on an element or NodeList
282
- * ---
283
- * @param {Node || NodeList} el - Element(s) to toggle class(es) on
284
- * @param {String || Array} cl - Class(es) to toggle
274
+ * Toggle a class or classes on an element or NodeList.
275
+ * @param {Node || NodeList} el - Element(s) to toggle class(es) on.
276
+ * @param {String || Array} cl - Class(es) to toggle.
285
277
  */
286
278
  const toggleClass = (el, ...cl) => {
287
279
  el = el.forEach ? el : [el];
@@ -367,13 +359,15 @@ function _extends() {
367
359
  return _extends.apply(this, arguments);
368
360
  }
369
361
 
362
+ var defaults$3 = {
363
+ autoInit: false,
364
+ stateAttr: 'aria-checked',
365
+ stateValue: 'mixed'
366
+ };
367
+
370
368
  class Checkbox {
371
369
  constructor(options) {
372
- this.defaults = {
373
- autoInit: false,
374
- stateAttr: 'aria-checked',
375
- stateValue: 'mixed'
376
- };
370
+ this.defaults = defaults$3;
377
371
  this.settings = _extends({}, this.defaults, options);
378
372
  this.__handlerClick = this.handlerClick.bind(this);
379
373
  if (this.settings.autoInit) this.init();
@@ -456,47 +450,6 @@ var defaults$2 = {
456
450
  transition: true
457
451
  };
458
452
 
459
- async function switchToModal(drawerKey, obj) {
460
- // Initial guards
461
- const drawer = obj.getDrawer(drawerKey);
462
- if (!drawer) return obj.drawerNotFound(drawerKey);
463
- if (hasClass(drawer, obj.settings.classModal)) return; // Enable modal state
464
-
465
- addClass(drawer, obj.settings.classModal);
466
- addClass(drawer, obj.settings.stateClosed);
467
- removeClass(drawer, obj.settings.stateOpened); // Dispatch custom event
468
-
469
- drawer.dispatchEvent(new CustomEvent(obj.settings.customEventPrefix + 'toModal', {
470
- bubbles: true
471
- }));
472
- return drawer;
473
- }
474
- async function switchToDefault(drawerKey, obj) {
475
- // Initial guards
476
- const drawer = obj.getDrawer(drawerKey);
477
- if (!drawer) return obj.drawerNotFound(drawerKey);
478
- if (!hasClass(drawer, obj.settings.classModal)) return; // Tear down modal state
479
-
480
- setInert(false, obj.settings.selectorInert);
481
- setOverflowHidden(false, obj.settings.selectorOverflow);
482
- removeClass(drawer, obj.settings.classModal);
483
- obj.focusTrap.destroy(); // Restore drawers saved state
484
-
485
- drawerKey = drawer.getAttribute(`data-${obj.settings.dataDrawer}`);
486
- const drawerState = obj.state[drawerKey];
487
-
488
- if (drawerState == obj.settings.stateOpened) {
489
- addClass(drawer, obj.settings.stateOpened);
490
- removeClass(drawer, obj.settings.stateClosed);
491
- } // Dispatch custom event
492
-
493
-
494
- drawer.dispatchEvent(new CustomEvent(obj.settings.customEventPrefix + 'toDefault', {
495
- bubbles: true
496
- }));
497
- return drawer;
498
- }
499
-
500
453
  class Breakpoint {
501
454
  constructor(parent) {
502
455
  this.mediaQueryLists = [];
@@ -508,12 +461,21 @@ class Breakpoint {
508
461
  init() {
509
462
  const drawers = document.querySelectorAll(`[data-${this.parent.settings.dataBreakpoint}]`);
510
463
  drawers.forEach(drawer => {
464
+ // Setup mediaQueryList object
511
465
  const id = drawer.getAttribute(`data-${this.parent.settings.dataDrawer}`);
512
466
  const key = drawer.getAttribute(`data-${this.parent.settings.dataBreakpoint}`);
513
467
  const bp = this.getBreakpoint(key);
514
- const mql = window.matchMedia('(min-width:' + bp + ')');
515
- this.match(mql, drawer);
516
- mql.addEventListener('change', this.__check);
468
+ const mql = window.matchMedia('(min-width:' + bp + ')'); // Run match check
469
+
470
+ this.match(mql, drawer); // Conditionally use addListner() for IE11 support
471
+
472
+ if (typeof mql.addEventListener === 'function') {
473
+ mql.addEventListener('change', this.__check);
474
+ } else {
475
+ mql.addListener(this.__check);
476
+ } // Push to mediaQueryLists array along with drawer ID
477
+
478
+
517
479
  this.mediaQueryLists.push({
518
480
  'mql': mql,
519
481
  'drawer': id
@@ -549,9 +511,9 @@ class Breakpoint {
549
511
 
550
512
  match(mql, drawer) {
551
513
  if (mql.matches) {
552
- switchToDefault(drawer, this.parent);
514
+ this.parent.switchToDefault(drawer);
553
515
  } else {
554
- switchToModal(drawer, this.parent);
516
+ this.parent.switchToModal(drawer);
555
517
  }
556
518
  }
557
519
 
@@ -576,6 +538,41 @@ class Breakpoint {
576
538
 
577
539
  }
578
540
 
541
+ function getDrawer(drawerKey) {
542
+ if (typeof drawerKey !== 'string') return drawerKey;
543
+ return document.querySelector(`[data-${this.settings.dataDrawer}="${drawerKey}"]`);
544
+ }
545
+ function drawerNotFound(key) {
546
+ return Promise.reject(new Error(`Did not find drawer with key: "${key}"`));
547
+ }
548
+
549
+ async function close$2(drawerKey) {
550
+ const drawer = this.getDrawer(drawerKey);
551
+ if (!drawer) return drawerNotFound(drawerKey);
552
+
553
+ if (hasClass(drawer, this.settings.stateOpened)) {
554
+ this.working = true;
555
+
556
+ if (hasClass(drawer, this.settings.classModal)) {
557
+ setInert(false, this.settings.selectorInert);
558
+ setOverflowHidden(false, this.settings.selectorOverflow);
559
+ }
560
+
561
+ await closeTransition(drawer, this.settings);
562
+ this.stateSave(drawer);
563
+ focusTrigger(this);
564
+ this.focusTrap.destroy();
565
+ drawer.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'closed', {
566
+ detail: this,
567
+ bubbles: true
568
+ }));
569
+ this.working = false;
570
+ return drawer;
571
+ } else {
572
+ return drawer;
573
+ }
574
+ }
575
+
579
576
  function handlerClick$2(event) {
580
577
  // Working catch
581
578
  if (this.working) return; // Toggle data trigger
@@ -638,6 +635,39 @@ function handlerKeydown$2(event) {
638
635
  }
639
636
  }
640
637
 
638
+ async function open$2(drawerKey) {
639
+ const drawer = this.getDrawer(drawerKey);
640
+ if (!drawer) return drawerNotFound(drawerKey);
641
+
642
+ if (!hasClass(drawer, this.settings.stateOpened)) {
643
+ this.working = true;
644
+ const isModal = hasClass(drawer, this.settings.classModal);
645
+
646
+ if (isModal) {
647
+ setOverflowHidden(true, this.settings.selectorOverflow);
648
+ }
649
+
650
+ await openTransition(drawer, this.settings);
651
+ this.stateSave(drawer);
652
+
653
+ if (isModal) {
654
+ this.focusTrap.init(drawer);
655
+ setInert(true, this.settings.selectorInert);
656
+ }
657
+
658
+ focusTarget(drawer, this.settings);
659
+ drawer.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'opened', {
660
+ detail: this,
661
+ bubbles: true
662
+ }));
663
+ this.working = false;
664
+ return drawer;
665
+ } else {
666
+ focusTarget(drawer, this.settings);
667
+ return drawer;
668
+ }
669
+ }
670
+
641
671
  function stateSet(settings) {
642
672
  // If save state is disabled
643
673
  if (!settings.stateSave) return stateClear(settings); // If there isn't an existing state to set
@@ -682,6 +712,59 @@ function stateClear(settings) {
682
712
  return {};
683
713
  }
684
714
 
715
+ async function switchToModal(drawerKey) {
716
+ // Initial guards
717
+ const drawer = this.getDrawer(drawerKey);
718
+ if (!drawer) return drawerNotFound(drawerKey);
719
+ if (hasClass(drawer, this.settings.classModal)) return; // Enable modal state
720
+
721
+ addClass(drawer, this.settings.classModal);
722
+ addClass(drawer, this.settings.stateClosed);
723
+ removeClass(drawer, this.settings.stateOpened); // Dispatch custom event
724
+
725
+ drawer.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'toModal', {
726
+ bubbles: true
727
+ }));
728
+ return drawer;
729
+ }
730
+ async function switchToDefault(drawerKey) {
731
+ // Initial guards
732
+ const drawer = this.getDrawer(drawerKey);
733
+ if (!drawer) return drawerNotFound(drawerKey);
734
+ if (!hasClass(drawer, this.settings.classModal)) return; // Tear down modal state
735
+
736
+ setInert(false, this.settings.selectorInert);
737
+ setOverflowHidden(false, this.settings.selectorOverflow);
738
+ removeClass(drawer, this.settings.classModal);
739
+ this.focusTrap.destroy(); // Restore drawers saved state
740
+
741
+ drawerKey = drawer.getAttribute(`data-${this.settings.dataDrawer}`);
742
+ const drawerState = this.state[drawerKey];
743
+
744
+ if (drawerState == this.settings.stateOpened) {
745
+ addClass(drawer, this.settings.stateOpened);
746
+ removeClass(drawer, this.settings.stateClosed);
747
+ } // Dispatch custom event
748
+
749
+
750
+ drawer.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'toDefault', {
751
+ bubbles: true
752
+ }));
753
+ return drawer;
754
+ }
755
+
756
+ async function toggle(drawerKey) {
757
+ const drawer = this.getDrawer(drawerKey);
758
+ if (!drawer) return drawerNotFound(drawerKey);
759
+ const isClosed = !hasClass(drawer, this.settings.stateOpened);
760
+
761
+ if (isClosed) {
762
+ return this.open(drawer);
763
+ } else {
764
+ return this.close(drawer);
765
+ }
766
+ }
767
+
685
768
  class Drawer {
686
769
  constructor(options) {
687
770
  this.defaults = defaults$2;
@@ -743,20 +826,14 @@ class Drawer {
743
826
 
744
827
 
745
828
  getDrawer(drawerKey) {
746
- if (typeof drawerKey !== 'string') return drawerKey;
747
- return document.querySelector(`[data-${this.settings.dataDrawer}="${drawerKey}"]`);
748
- }
749
-
750
- drawerNotFound(key) {
751
- return Promise.reject(new Error(`Did not find drawer with key: "${key}"`));
829
+ return getDrawer.call(this, drawerKey);
752
830
  }
753
831
 
754
832
  setTabindex() {
755
- const selectorTabindex = `
833
+ return setTabindex(`
756
834
  [data-${this.settings.dataDrawer}]
757
835
  [data-${this.settings.dataDialog}]
758
- `;
759
- setTabindex(selectorTabindex);
836
+ `);
760
837
  }
761
838
  /**
762
839
  * Save state functionality
@@ -780,87 +857,27 @@ class Drawer {
780
857
 
781
858
 
782
859
  switchToDefault(drawerKey) {
783
- return switchToDefault(drawerKey, this);
860
+ return switchToDefault.call(this, drawerKey);
784
861
  }
785
862
 
786
863
  switchToModal(drawerKey) {
787
- return switchToModal(drawerKey, this);
864
+ return switchToModal.call(this, drawerKey);
788
865
  }
789
866
  /**
790
867
  * Change state functionality
791
868
  */
792
869
 
793
870
 
794
- async toggle(drawerKey) {
795
- const drawer = this.getDrawer(drawerKey);
796
- if (!drawer) return this.drawerNotFound(drawerKey);
797
- const isClosed = !hasClass(drawer, this.settings.stateOpened);
798
-
799
- if (isClosed) {
800
- return this.open(drawer);
801
- } else {
802
- return this.close(drawer);
803
- }
871
+ toggle(drawerKey) {
872
+ return toggle.call(this, drawerKey);
804
873
  }
805
874
 
806
- async open(drawerKey) {
807
- const drawer = this.getDrawer(drawerKey);
808
- if (!drawer) return this.drawerNotFound(drawerKey);
809
-
810
- if (!hasClass(drawer, this.settings.stateOpened)) {
811
- this.working = true;
812
- const isModal = hasClass(drawer, this.settings.classModal);
813
-
814
- if (isModal) {
815
- setOverflowHidden(true, this.settings.selectorOverflow);
816
- }
817
-
818
- await openTransition(drawer, this.settings);
819
- this.stateSave(drawer);
820
-
821
- if (isModal) {
822
- this.focusTrap.init(drawer);
823
- setInert(true, this.settings.selectorInert);
824
- }
825
-
826
- focusTarget(drawer, this.settings);
827
- drawer.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'opened', {
828
- detail: this,
829
- bubbles: true
830
- }));
831
- this.working = false;
832
- return drawer;
833
- } else {
834
- focusTarget(drawer, this.settings);
835
- return drawer;
836
- }
875
+ open(drawerKey) {
876
+ return open$2.call(this, drawerKey);
837
877
  }
838
878
 
839
- async close(drawerKey) {
840
- const drawer = this.getDrawer(drawerKey);
841
- if (!drawer) return this.drawerNotFound(drawerKey);
842
-
843
- if (hasClass(drawer, this.settings.stateOpened)) {
844
- this.working = true;
845
-
846
- if (hasClass(drawer, this.settings.classModal)) {
847
- setInert(false, this.settings.selectorInert);
848
- setOverflowHidden(false, this.settings.selectorOverflow);
849
- }
850
-
851
- await closeTransition(drawer, this.settings);
852
- this.stateSave(drawer);
853
- focusTrigger(this);
854
- this.focusTrap.destroy();
855
- drawer.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'closed', {
856
- detail: this,
857
- bubbles: true
858
- }));
859
- this.working = false;
860
- return drawer;
861
- } else {
862
- return drawer;
863
- }
879
+ close(drawerKey) {
880
+ return close$2.call(this, drawerKey);
864
881
  }
865
882
 
866
883
  }
@@ -893,6 +910,27 @@ var defaults$1 = {
893
910
  transition: true
894
911
  };
895
912
 
913
+ async function close$1(returnFocus = true) {
914
+ const modal = document.querySelector(`[data-${this.settings.dataModal}].${this.settings.stateOpened}`);
915
+
916
+ if (modal) {
917
+ this.working = true;
918
+ setInert(false, this.settings.selectorInert);
919
+ setOverflowHidden(false, this.settings.selectorOverflow);
920
+ await closeTransition(modal, this.settings);
921
+ if (returnFocus) focusTrigger(this);
922
+ this.focusTrap.destroy();
923
+ modal.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'closed', {
924
+ detail: this,
925
+ bubbles: true
926
+ }));
927
+ this.working = false;
928
+ return modal;
929
+ } else {
930
+ return modal;
931
+ }
932
+ }
933
+
896
934
  async function handlerClick$1(event) {
897
935
  // Working catch
898
936
  if (this.working) return; // Trigger click
@@ -935,21 +973,57 @@ function handlerKeydown$1(event) {
935
973
  }
936
974
  }
937
975
 
938
- function setInitialState(obj) {
939
- const modals = document.querySelectorAll(`[data-${obj.settings.dataModal}]`);
976
+ function getModal(modalKey) {
977
+ if (typeof modalKey !== 'string') return modalKey;
978
+ return document.querySelector(`[data-${this.settings.dataModal}="${modalKey}"]`);
979
+ }
980
+ function modalNotFound(key) {
981
+ return Promise.reject(new Error(`Did not find modal with key: "${key}"`));
982
+ }
983
+ function moveModals(type = this.settings.moveModals.type, ref = this.settings.moveModals.ref) {
984
+ const modals = document.querySelectorAll(`[data-${this.settings.dataModal}]`);
985
+ if (modals.length) moveElement(modals, type, ref);
986
+ }
987
+
988
+ function setInitialState() {
989
+ const modals = document.querySelectorAll(`[data-${this.settings.dataModal}]`);
940
990
  modals.forEach(el => {
941
- if (el.classList.contains(obj.settings.stateOpened)) {
942
- setInert(false, obj.settings.selectorInert);
943
- setOverflowHidden(false, obj.settings.selectorOverflow);
944
- focusTrigger(obj);
945
- obj.focusTrap.destroy();
946
- }
991
+ // Remove opened state setup
992
+ if (el.classList.contains(this.settings.stateOpened)) {
993
+ setInert(false, this.settings.selectorInert);
994
+ setOverflowHidden(false, this.settings.selectorOverflow);
995
+ focusTrigger(this);
996
+ this.focusTrap.destroy();
997
+ } // Remove all state classes and add the default state (closed)
947
998
 
948
- removeClass(el, obj.settings.stateOpened, obj.settings.stateOpening, obj.settings.stateClosing);
949
- addClass(el, obj.settings.stateClosed);
999
+
1000
+ removeClass(el, this.settings.stateOpened, this.settings.stateOpening, this.settings.stateClosing);
1001
+ addClass(el, this.settings.stateClosed);
950
1002
  });
951
1003
  }
952
1004
 
1005
+ async function open$1(modalKey) {
1006
+ const modal = getModal.call(this, modalKey);
1007
+ if (!modal) return modalNotFound(modalKey);
1008
+
1009
+ if (hasClass(modal, this.settings.stateClosed)) {
1010
+ this.working = true;
1011
+ setOverflowHidden(true, this.settings.selectorOverflow);
1012
+ await openTransition(modal, this.settings);
1013
+ this.focusTrap.init(modal);
1014
+ focusTarget(modal, this.settings);
1015
+ setInert(true, this.settings.selectorInert);
1016
+ modal.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'opened', {
1017
+ detail: this,
1018
+ bubbles: true
1019
+ }));
1020
+ this.working = false;
1021
+ return modal;
1022
+ } else {
1023
+ return modal;
1024
+ }
1025
+ }
1026
+
953
1027
  class Modal {
954
1028
  constructor(options) {
955
1029
  this.defaults = defaults$1;
@@ -965,13 +1039,12 @@ class Modal {
965
1039
  init(options = null) {
966
1040
  if (options) this.settings = _extends({}, this.settings, options);
967
1041
  this.moveModals();
1042
+ this.setInitialState();
968
1043
 
969
1044
  if (this.settings.setTabindex) {
970
1045
  this.setTabindex();
971
1046
  }
972
1047
 
973
- this.setInitialState();
974
-
975
1048
  if (this.settings.eventListeners) {
976
1049
  this.initEventListeners();
977
1050
  }
@@ -1006,76 +1079,34 @@ class Modal {
1006
1079
 
1007
1080
 
1008
1081
  getModal(modalKey) {
1009
- if (typeof modalKey !== 'string') return modalKey;
1010
- return document.querySelector(`[data-${this.settings.dataModal}="${modalKey}"]`);
1011
- }
1012
-
1013
- modalNotFound(key) {
1014
- return Promise.reject(new Error(`Did not find modal with key: "${key}"`));
1082
+ return getModal.call(this, modalKey);
1015
1083
  }
1016
1084
 
1017
1085
  setTabindex() {
1018
- const selectorTabindex = `
1086
+ return setTabindex(`
1019
1087
  [data-${this.settings.dataModal}]
1020
1088
  [data-${this.settings.dataDialog}]
1021
- `;
1022
- setTabindex(selectorTabindex);
1089
+ `);
1023
1090
  }
1024
1091
 
1025
1092
  setInitialState() {
1026
- setInitialState(this);
1093
+ return setInitialState.call(this);
1027
1094
  }
1028
1095
 
1029
- moveModals(type = this.settings.moveModals.type, ref = this.settings.moveModals.ref) {
1030
- const modals = document.querySelectorAll(`[data-${this.settings.dataModal}]`);
1031
- if (modals.length) moveElement(modals, type, ref);
1096
+ moveModals(type, ref) {
1097
+ return moveModals.call(this, type, ref);
1032
1098
  }
1033
1099
  /**
1034
1100
  * Change state functionality
1035
1101
  */
1036
1102
 
1037
1103
 
1038
- async open(modalKey) {
1039
- const modal = this.getModal(modalKey);
1040
- if (!modal) return this.modalNotFound(modalKey);
1041
-
1042
- if (hasClass(modal, this.settings.stateClosed)) {
1043
- this.working = true;
1044
- setOverflowHidden(true, this.settings.selectorOverflow);
1045
- await openTransition(modal, this.settings);
1046
- this.focusTrap.init(modal);
1047
- focusTarget(modal, this.settings);
1048
- setInert(true, this.settings.selectorInert);
1049
- modal.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'opened', {
1050
- detail: this,
1051
- bubbles: true
1052
- }));
1053
- this.working = false;
1054
- return modal;
1055
- } else {
1056
- return modal;
1057
- }
1104
+ open(modalKey) {
1105
+ return open$1.call(this, modalKey);
1058
1106
  }
1059
1107
 
1060
- async close(returnFocus = true) {
1061
- const modal = document.querySelector(`[data-${this.settings.dataModal}].${this.settings.stateOpened}`);
1062
-
1063
- if (modal) {
1064
- this.working = true;
1065
- setInert(false, this.settings.selectorInert);
1066
- setOverflowHidden(false, this.settings.selectorOverflow);
1067
- await closeTransition(modal, this.settings);
1068
- if (returnFocus) focusTrigger(this);
1069
- this.focusTrap.destroy();
1070
- modal.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'closed', {
1071
- detail: this,
1072
- bubbles: true
1073
- }));
1074
- this.working = false;
1075
- return modal;
1076
- } else {
1077
- return modal;
1078
- }
1108
+ close(returnFocus) {
1109
+ return close$1.call(this, returnFocus);
1079
1110
  }
1080
1111
 
1081
1112
  }
@@ -1096,9 +1127,9 @@ var defaults = {
1096
1127
  placement: 'bottom-start'
1097
1128
  };
1098
1129
 
1099
- function hide$2(popover, obj) {
1130
+ function close(popover) {
1100
1131
  // Update state class
1101
- popover.target.classList.remove(obj.settings.stateActive); // Update a11y attributes
1132
+ popover.target.classList.remove(this.settings.stateActive); // Update a11y attributes
1102
1133
 
1103
1134
  popover.trigger.setAttribute('aria-expanded', 'false'); // Disable popper event listeners
1104
1135
 
@@ -1109,39 +1140,39 @@ function hide$2(popover, obj) {
1109
1140
  }]
1110
1141
  }); // Update collection status with new state
1111
1142
 
1112
- const index = obj.collection.findIndex(item => {
1143
+ const index = this.collection.findIndex(item => {
1113
1144
  return item.target === popover.target;
1114
1145
  });
1115
- obj.collection[index].state = 'hide'; // Clear the memory if popover trigger matches the ones saved in memory
1146
+ this.collection[index].state = 'closed'; // Clear the memory if popover trigger matches the ones saved in memory
1116
1147
 
1117
- if (popover.trigger === obj.memory.trigger) {
1118
- obj.memory.trigger = null;
1148
+ if (popover.trigger === this.memory.trigger) {
1149
+ this.memory.trigger = null;
1119
1150
  } // Return the popover
1120
1151
 
1121
1152
 
1122
1153
  return popover;
1123
1154
  }
1124
- function hideAll(obj) {
1125
- obj.collection.forEach(popover => {
1126
- if (popover.state === 'show') {
1127
- hide$2(popover, obj);
1155
+ function closeAll() {
1156
+ this.collection.forEach(popover => {
1157
+ if (popover.state === 'opened') {
1158
+ this.close(popover);
1128
1159
  }
1129
1160
  }); // Return the collection
1130
1161
 
1131
- return obj.collection;
1162
+ return this.collection;
1132
1163
  }
1133
- function hideCheck(popover, obj) {
1134
- // Only run hideCheck if provided popover is currently open
1135
- if (popover.state != 'show') return; // Needed to correctly check which element is currently being focused
1164
+ function closeCheck(popover) {
1165
+ // Only run closeCheck if provided popover is currently open
1166
+ if (popover.state != 'opened') return; // Needed to correctly check which element is currently being focused
1136
1167
 
1137
1168
  setTimeout(() => {
1138
1169
  // Check if trigger or target are being hovered
1139
1170
  const isHovered = popover.target.closest(':hover') === popover.target || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or target are being focused
1140
1171
 
1141
- const isFocused = document.activeElement.closest(`[data-${obj.settings.dataPopover}]`) === popover.target || document.activeElement.closest(`[data-${obj.settings.dataTrigger}]`) === popover.trigger; // Hide if the trigger and target are not currently hovered or focused
1172
+ const isFocused = document.activeElement.closest(`[data-${this.settings.dataPopover}]`) === popover.target || document.activeElement.closest(`[data-${this.settings.dataTrigger}]`) === popover.trigger; // Close if the trigger and target are not currently hovered or focused
1142
1173
 
1143
1174
  if (!isHovered && !isFocused) {
1144
- hide$2(popover, obj);
1175
+ this.close(popover);
1145
1176
  } // Return the popover
1146
1177
 
1147
1178
 
@@ -1149,6 +1180,55 @@ function hideCheck(popover, obj) {
1149
1180
  }, 1);
1150
1181
  }
1151
1182
 
1183
+ function handlerClick(popover) {
1184
+ if (popover.target.classList.contains(this.settings.stateActive)) {
1185
+ this.close(popover);
1186
+ } else {
1187
+ this.memory.trigger = popover.trigger;
1188
+ this.open(popover);
1189
+ documentClick.call(this, popover);
1190
+ }
1191
+ }
1192
+ function handlerKeydown(event) {
1193
+ switch (event.key) {
1194
+ case 'Escape':
1195
+ if (this.memory.trigger) {
1196
+ this.memory.trigger.focus();
1197
+ }
1198
+
1199
+ this.closeAll();
1200
+ return;
1201
+
1202
+ case 'Tab':
1203
+ this.collection.forEach(popover => {
1204
+ closeCheck.call(this, popover);
1205
+ });
1206
+ return;
1207
+
1208
+ default:
1209
+ return;
1210
+ }
1211
+ }
1212
+ function documentClick(popover) {
1213
+ const obj = this;
1214
+ document.addEventListener('click', function _f(event) {
1215
+ const result = event.target.closest(`[data-${obj.settings.dataPopover}], [data-${obj.settings.dataTrigger}]`);
1216
+ const match = result === popover.target || result === popover.trigger;
1217
+
1218
+ if (!match) {
1219
+ if (popover.target.classList.contains(obj.settings.stateActive)) {
1220
+ obj.close(popover);
1221
+ }
1222
+
1223
+ this.removeEventListener('click', _f);
1224
+ } else {
1225
+ if (!popover.target.classList.contains(obj.settings.stateActive)) {
1226
+ this.removeEventListener('click', _f);
1227
+ }
1228
+ }
1229
+ });
1230
+ }
1231
+
1152
1232
  function getConfig(el, settings) {
1153
1233
  // Get the computed styles of the popover
1154
1234
  const styles = getComputedStyle(el); // Setup the config obj with default values
@@ -1269,16 +1349,16 @@ function getPopover(trigger, settings) {
1269
1349
  }
1270
1350
  }
1271
1351
 
1272
- function show(popover, obj) {
1352
+ function open(popover) {
1273
1353
  // Update state class
1274
- popover.target.classList.add(obj.settings.stateActive); // Update a11y attributes
1354
+ popover.target.classList.add(this.settings.stateActive); // Update a11y attributes
1275
1355
 
1276
1356
  popover.trigger.setAttribute('aria-expanded', 'true'); // Update popover config
1277
1357
 
1278
- popover.config = getConfig(popover.target, obj.settings); // Enable popper event listeners and set placement/modifiers
1358
+ popover.config = getConfig(popover.target, this.settings); // Enable popper event listeners and set placement/modifiers
1279
1359
 
1280
1360
  popover.popper.setOptions({
1281
- placement: getData(popover.target, obj.settings.dataPlacement, popover.config['placement']),
1361
+ placement: getData(popover.target, this.settings.dataPlacement, popover.config['placement']),
1282
1362
  modifiers: [{
1283
1363
  name: 'eventListeners',
1284
1364
  enabled: true
@@ -1287,62 +1367,14 @@ function show(popover, obj) {
1287
1367
 
1288
1368
  popover.popper.update(); // Update collection status with new state
1289
1369
 
1290
- const index = obj.collection.findIndex(item => {
1370
+ const index = this.collection.findIndex(item => {
1291
1371
  return item.target === popover.target;
1292
1372
  });
1293
- obj.collection[index].state = 'show'; // Return the popover
1373
+ this.collection[index].state = 'opened'; // Return the popover
1294
1374
 
1295
1375
  return popover;
1296
1376
  }
1297
1377
 
1298
- function handlerClick(popover) {
1299
- if (popover.target.classList.contains(this.settings.stateActive)) {
1300
- hide$2(popover, this);
1301
- } else {
1302
- this.memory.trigger = popover.trigger;
1303
- show(popover, this);
1304
- documentClick(popover, this);
1305
- }
1306
- }
1307
- function handlerKeydown(event) {
1308
- switch (event.key) {
1309
- case 'Escape':
1310
- if (this.memory.trigger) {
1311
- this.memory.trigger.focus();
1312
- }
1313
-
1314
- hideAll(this);
1315
- return;
1316
-
1317
- case 'Tab':
1318
- this.collection.forEach(popover => {
1319
- hideCheck(popover, this);
1320
- });
1321
- return;
1322
-
1323
- default:
1324
- return;
1325
- }
1326
- }
1327
- function documentClick(popover, obj) {
1328
- document.addEventListener('click', function _f(event) {
1329
- const result = event.target.closest(`[data-${obj.settings.dataPopover}], [data-${obj.settings.dataTrigger}]`);
1330
- const match = result === popover.target || result === popover.trigger;
1331
-
1332
- if (!match) {
1333
- if (popover.target.classList.contains(obj.settings.stateActive)) {
1334
- hide$2(popover, obj);
1335
- }
1336
-
1337
- this.removeEventListener('click', _f);
1338
- } else {
1339
- if (!popover.target.classList.contains(obj.settings.stateActive)) {
1340
- this.removeEventListener('click', _f);
1341
- }
1342
- }
1343
- });
1344
- }
1345
-
1346
1378
  var top = 'top';
1347
1379
  var bottom = 'bottom';
1348
1380
  var right = 'right';
@@ -3126,11 +3158,11 @@ var createPopper = /*#__PURE__*/popperGenerator({
3126
3158
  defaultModifiers: defaultModifiers
3127
3159
  }); // eslint-disable-next-line import/no-unused-modules
3128
3160
 
3129
- function register(trigger, target, obj) {
3161
+ function register(trigger, target) {
3130
3162
  // If no target is passed
3131
3163
  if (!target) {
3132
3164
  // Try and get the target
3133
- target = getPopover(trigger, obj.settings); // If still no target is returned, log an error and return false
3165
+ target = getPopover(trigger, this.settings); // If still no target is returned, log an error and return false
3134
3166
 
3135
3167
  if (!target) {
3136
3168
  console.error('No popover associated with the provided trigger:', trigger);
@@ -3139,7 +3171,7 @@ function register(trigger, target, obj) {
3139
3171
  } // Check if this item has already been registered in the collection
3140
3172
 
3141
3173
 
3142
- const index = obj.collection.findIndex(item => {
3174
+ const index = this.collection.findIndex(item => {
3143
3175
  return item.trigger === trigger && item.target === target;
3144
3176
  }); // Initiate popover variable
3145
3177
 
@@ -3147,45 +3179,45 @@ function register(trigger, target, obj) {
3147
3179
 
3148
3180
  if (index >= 0) {
3149
3181
  // Set popover as item from collection
3150
- popover = obj.collection[index];
3182
+ popover = this.collection[index];
3151
3183
  } else {
3152
3184
  // Create popper instance
3153
3185
  const popperInstance = createPopper(trigger, target); // Build popover object and push to collection array
3154
3186
 
3155
3187
  popover = {
3156
- state: 'hide',
3188
+ state: 'closed',
3157
3189
  trigger: trigger,
3158
3190
  target: target,
3159
3191
  popper: popperInstance,
3160
- config: getConfig(target, obj.settings)
3192
+ config: getConfig(target, this.settings)
3161
3193
  }; // Add item to collection
3162
3194
 
3163
- obj.collection.push(popover);
3195
+ this.collection.push(popover);
3164
3196
  } // Setup event listeners
3165
3197
 
3166
3198
 
3167
- registerEventListeners(popover, obj); // Set initial state of popover
3199
+ registerEventListeners.call(this, popover); // Set initial state of popover
3168
3200
 
3169
- if (popover.target.classList.contains(obj.settings.stateActive)) {
3170
- show(popover, obj);
3171
- documentClick(popover, obj);
3201
+ if (popover.target.classList.contains(this.settings.stateActive)) {
3202
+ this.open(popover);
3203
+ documentClick.call(this, popover);
3172
3204
  } else {
3173
- hide$2(popover, obj);
3205
+ this.close(popover);
3174
3206
  } // Return the popover object
3175
3207
 
3176
3208
 
3177
3209
  return popover;
3178
3210
  }
3179
- function deregister(popover, obj) {
3211
+ function deregister(popover) {
3180
3212
  // Check if this item has been registered in the collection
3181
- const index = obj.collection.findIndex(item => {
3213
+ const index = this.collection.findIndex(item => {
3182
3214
  return item.trigger === popover.trigger && item.target === popover.target;
3183
3215
  }); // If the item exists in the collection
3184
3216
 
3185
3217
  if (index >= 0) {
3186
- // Hide the popover
3187
- if (popover.state === 'show') {
3188
- hide$2(popover, obj);
3218
+ // Close the popover
3219
+ if (popover.state === 'opened') {
3220
+ this.close(popover);
3189
3221
  } // Clean up the popper instance
3190
3222
 
3191
3223
 
@@ -3193,28 +3225,28 @@ function deregister(popover, obj) {
3193
3225
 
3194
3226
  deregisterEventListeners(popover); // Remove item from collection
3195
3227
 
3196
- obj.collection.splice(index, 1);
3228
+ this.collection.splice(index, 1);
3197
3229
  } // Return the new collection
3198
3230
 
3199
3231
 
3200
- return obj.collection;
3232
+ return this.collection;
3201
3233
  }
3202
- function registerEventListeners(popover, obj) {
3234
+ function registerEventListeners(popover) {
3203
3235
  // If event listeners aren't already setup
3204
3236
  if (!popover.__eventListeners) {
3205
3237
  // Add event listeners based on event type
3206
- const eventType = getData(popover.target, obj.settings.dataEventType, popover.config['event']);
3238
+ const eventType = getData(popover.target, this.settings.dataEventType, popover.config['event']);
3207
3239
 
3208
3240
  if (eventType === 'hover') {
3209
3241
  // Setup event listeners object for hover
3210
3242
  popover.__eventListeners = [{
3211
3243
  el: ['trigger'],
3212
3244
  type: ['mouseenter', 'focus'],
3213
- listener: show.bind(null, popover, obj)
3245
+ listener: open.bind(this, popover)
3214
3246
  }, {
3215
3247
  el: ['trigger', 'target'],
3216
3248
  type: ['mouseleave', 'focusout'],
3217
- listener: hideCheck.bind(null, popover, obj)
3249
+ listener: closeCheck.bind(this, popover)
3218
3250
  }]; // Loop through listeners and apply to appropriate elements
3219
3251
 
3220
3252
  popover.__eventListeners.forEach(evObj => {
@@ -3229,7 +3261,7 @@ function registerEventListeners(popover, obj) {
3229
3261
  popover.__eventListeners = [{
3230
3262
  el: ['trigger'],
3231
3263
  type: ['click'],
3232
- listener: handlerClick.bind(obj, popover)
3264
+ listener: handlerClick.bind(this, popover)
3233
3265
  }]; // Loop through listeners and apply to appropriate elements
3234
3266
 
3235
3267
  popover.__eventListeners.forEach(evObj => {
@@ -3264,24 +3296,24 @@ function deregisterEventListeners(popover) {
3264
3296
 
3265
3297
  return popover;
3266
3298
  }
3267
- function registerCollection(obj) {
3299
+ function registerCollection() {
3268
3300
  // Get all the triggers
3269
- const triggers = document.querySelectorAll(`[data-${obj.settings.dataTrigger}]`);
3301
+ const triggers = document.querySelectorAll(`[data-${this.settings.dataTrigger}]`);
3270
3302
  triggers.forEach(trigger => {
3271
3303
  // Register the popover and save to collection array
3272
- register(trigger, false, obj);
3304
+ this.register(trigger, false);
3273
3305
  }); // Return the popover collection
3274
3306
 
3275
- return obj.collection;
3307
+ return this.collection;
3276
3308
  }
3277
- function deregisterCollection(obj) {
3309
+ function deregisterCollection() {
3278
3310
  // Loop through all items within the collection and pass them to deregister()
3279
- while (obj.collection.length > 0) {
3280
- deregister(obj.collection[0], obj);
3311
+ while (this.collection.length > 0) {
3312
+ this.deregister(this.collection[0]);
3281
3313
  } // Return the popover collection
3282
3314
 
3283
3315
 
3284
- return obj.collection;
3316
+ return this.collection;
3285
3317
  }
3286
3318
 
3287
3319
  class Popover {
@@ -3300,7 +3332,7 @@ class Popover {
3300
3332
  // Update settings with passed options
3301
3333
  if (options) this.settings = _extends({}, this.settings, options); // Build the collections array with popover instances
3302
3334
 
3303
- registerCollection(this); // If eventListeners is enabled
3335
+ this.registerCollection(); // If eventListeners is enabled
3304
3336
 
3305
3337
  if (this.settings.eventListeners) {
3306
3338
  // Pass false to initEventListeners() since registerCollection()
@@ -3311,7 +3343,7 @@ class Popover {
3311
3343
 
3312
3344
  destroy() {
3313
3345
  // Deregister all popovers from collection
3314
- deregisterCollection(this); // If eventListeners is enabled
3346
+ this.deregisterCollection(); // If eventListeners is enabled
3315
3347
 
3316
3348
  if (this.settings.eventListeners) {
3317
3349
  // Pass false to destroyEventListeners() since deregisterCollection()
@@ -3328,7 +3360,7 @@ class Popover {
3328
3360
  if (processCollection) {
3329
3361
  // Loop through collection and setup event listeners
3330
3362
  this.collection.forEach(popover => {
3331
- registerEventListeners(popover, this);
3363
+ registerEventListeners.call(this, popover);
3332
3364
  });
3333
3365
  } // Add keydown global event listener
3334
3366
 
@@ -3353,35 +3385,35 @@ class Popover {
3353
3385
 
3354
3386
 
3355
3387
  register(trigger, target = false) {
3356
- return register(trigger, target, this);
3388
+ return register.call(this, trigger, target);
3357
3389
  }
3358
3390
 
3359
3391
  deregister(popover) {
3360
- return deregister(popover, this);
3392
+ return deregister.call(this, popover);
3361
3393
  }
3362
3394
 
3363
3395
  registerCollection() {
3364
- return registerCollection(this);
3396
+ return registerCollection.call(this);
3365
3397
  }
3366
3398
 
3367
3399
  deregisterCollection() {
3368
- return deregisterCollection(this);
3400
+ return deregisterCollection.call(this);
3369
3401
  }
3370
3402
  /**
3371
3403
  * Change state functionality
3372
3404
  */
3373
3405
 
3374
3406
 
3375
- show(popover) {
3376
- return show(popover, this);
3407
+ open(popover) {
3408
+ return open.call(this, popover);
3377
3409
  }
3378
3410
 
3379
- hide(popover) {
3380
- return hide$2(popover, this);
3411
+ close(popover) {
3412
+ return close.call(this, popover);
3381
3413
  }
3382
3414
 
3383
- hideAll() {
3384
- return hideAll(this);
3415
+ closeAll() {
3416
+ return closeAll.call(this);
3385
3417
  }
3386
3418
 
3387
3419
  }