vrembem 1.40.1 → 1.40.2
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/dev/scripts.esm.js +407 -366
- package/dev/scripts.esm.js.map +1 -1
- package/dev/scripts.js +407 -366
- package/dev/scripts.js.map +1 -1
- package/dev/scripts.modern.js +328 -299
- package/dev/scripts.modern.js.map +1 -1
- package/dev/scripts.umd.js +407 -366
- 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.js
CHANGED
|
@@ -495,55 +495,6 @@ var defaults$2 = {
|
|
|
495
495
|
transition: true
|
|
496
496
|
};
|
|
497
497
|
|
|
498
|
-
var switchToDefault = function switchToDefault(drawerKey, obj) {
|
|
499
|
-
try {
|
|
500
|
-
// Initial guards
|
|
501
|
-
var drawer = obj.getDrawer(drawerKey);
|
|
502
|
-
if (!drawer) return Promise.resolve(obj.drawerNotFound(drawerKey));
|
|
503
|
-
if (!hasClass(drawer, obj.settings.classModal)) return Promise.resolve(); // Tear down modal state
|
|
504
|
-
|
|
505
|
-
setInert(false, obj.settings.selectorInert);
|
|
506
|
-
setOverflowHidden(false, obj.settings.selectorOverflow);
|
|
507
|
-
removeClass(drawer, obj.settings.classModal);
|
|
508
|
-
obj.focusTrap.destroy(); // Restore drawers saved state
|
|
509
|
-
|
|
510
|
-
drawerKey = drawer.getAttribute("data-" + obj.settings.dataDrawer);
|
|
511
|
-
var drawerState = obj.state[drawerKey];
|
|
512
|
-
|
|
513
|
-
if (drawerState == obj.settings.stateOpened) {
|
|
514
|
-
addClass(drawer, obj.settings.stateOpened);
|
|
515
|
-
removeClass(drawer, obj.settings.stateClosed);
|
|
516
|
-
} // Dispatch custom event
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
drawer.dispatchEvent(new CustomEvent(obj.settings.customEventPrefix + 'toDefault', {
|
|
520
|
-
bubbles: true
|
|
521
|
-
}));
|
|
522
|
-
return Promise.resolve(drawer);
|
|
523
|
-
} catch (e) {
|
|
524
|
-
return Promise.reject(e);
|
|
525
|
-
}
|
|
526
|
-
};
|
|
527
|
-
var switchToModal = function switchToModal(drawerKey, obj) {
|
|
528
|
-
try {
|
|
529
|
-
// Initial guards
|
|
530
|
-
var drawer = obj.getDrawer(drawerKey);
|
|
531
|
-
if (!drawer) return Promise.resolve(obj.drawerNotFound(drawerKey));
|
|
532
|
-
if (hasClass(drawer, obj.settings.classModal)) return Promise.resolve(); // Enable modal state
|
|
533
|
-
|
|
534
|
-
addClass(drawer, obj.settings.classModal);
|
|
535
|
-
addClass(drawer, obj.settings.stateClosed);
|
|
536
|
-
removeClass(drawer, obj.settings.stateOpened); // Dispatch custom event
|
|
537
|
-
|
|
538
|
-
drawer.dispatchEvent(new CustomEvent(obj.settings.customEventPrefix + 'toModal', {
|
|
539
|
-
bubbles: true
|
|
540
|
-
}));
|
|
541
|
-
return Promise.resolve(drawer);
|
|
542
|
-
} catch (e) {
|
|
543
|
-
return Promise.reject(e);
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
|
|
547
498
|
var Breakpoint = /*#__PURE__*/function () {
|
|
548
499
|
function Breakpoint(parent) {
|
|
549
500
|
this.mediaQueryLists = [];
|
|
@@ -613,9 +564,9 @@ var Breakpoint = /*#__PURE__*/function () {
|
|
|
613
564
|
|
|
614
565
|
_proto.match = function match(mql, drawer) {
|
|
615
566
|
if (mql.matches) {
|
|
616
|
-
switchToDefault(drawer
|
|
567
|
+
this.parent.switchToDefault(drawer);
|
|
617
568
|
} else {
|
|
618
|
-
switchToModal(drawer
|
|
569
|
+
this.parent.switchToModal(drawer);
|
|
619
570
|
}
|
|
620
571
|
};
|
|
621
572
|
|
|
@@ -641,6 +592,52 @@ var Breakpoint = /*#__PURE__*/function () {
|
|
|
641
592
|
return Breakpoint;
|
|
642
593
|
}();
|
|
643
594
|
|
|
595
|
+
function getDrawer(drawerKey) {
|
|
596
|
+
if (typeof drawerKey !== 'string') return drawerKey;
|
|
597
|
+
return document.querySelector("[data-" + this.settings.dataDrawer + "=\"" + drawerKey + "\"]");
|
|
598
|
+
}
|
|
599
|
+
function drawerNotFound(key) {
|
|
600
|
+
return Promise.reject(new Error("Did not find drawer with key: \"" + key + "\""));
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
var close$2 = function close(drawerKey) {
|
|
604
|
+
try {
|
|
605
|
+
var _this2 = this;
|
|
606
|
+
|
|
607
|
+
var drawer = _this2.getDrawer(drawerKey);
|
|
608
|
+
|
|
609
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
610
|
+
|
|
611
|
+
if (hasClass(drawer, _this2.settings.stateOpened)) {
|
|
612
|
+
_this2.working = true;
|
|
613
|
+
|
|
614
|
+
if (hasClass(drawer, _this2.settings.classModal)) {
|
|
615
|
+
setInert(false, _this2.settings.selectorInert);
|
|
616
|
+
setOverflowHidden(false, _this2.settings.selectorOverflow);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
return Promise.resolve(closeTransition(drawer, _this2.settings)).then(function () {
|
|
620
|
+
_this2.stateSave(drawer);
|
|
621
|
+
|
|
622
|
+
focusTrigger(_this2);
|
|
623
|
+
|
|
624
|
+
_this2.focusTrap.destroy();
|
|
625
|
+
|
|
626
|
+
drawer.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'closed', {
|
|
627
|
+
detail: _this2,
|
|
628
|
+
bubbles: true
|
|
629
|
+
}));
|
|
630
|
+
_this2.working = false;
|
|
631
|
+
return drawer;
|
|
632
|
+
});
|
|
633
|
+
} else {
|
|
634
|
+
return Promise.resolve(drawer);
|
|
635
|
+
}
|
|
636
|
+
} catch (e) {
|
|
637
|
+
return Promise.reject(e);
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
|
|
644
641
|
function handlerClick$2(event) {
|
|
645
642
|
// Working catch
|
|
646
643
|
if (this.working) return; // Toggle data trigger
|
|
@@ -704,6 +701,48 @@ function handlerKeydown$2(event) {
|
|
|
704
701
|
}
|
|
705
702
|
}
|
|
706
703
|
|
|
704
|
+
var open$2 = function open(drawerKey) {
|
|
705
|
+
try {
|
|
706
|
+
var _this2 = this;
|
|
707
|
+
|
|
708
|
+
var drawer = _this2.getDrawer(drawerKey);
|
|
709
|
+
|
|
710
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
711
|
+
|
|
712
|
+
if (!hasClass(drawer, _this2.settings.stateOpened)) {
|
|
713
|
+
_this2.working = true;
|
|
714
|
+
var isModal = hasClass(drawer, _this2.settings.classModal);
|
|
715
|
+
|
|
716
|
+
if (isModal) {
|
|
717
|
+
setOverflowHidden(true, _this2.settings.selectorOverflow);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
return Promise.resolve(openTransition(drawer, _this2.settings)).then(function () {
|
|
721
|
+
_this2.stateSave(drawer);
|
|
722
|
+
|
|
723
|
+
if (isModal) {
|
|
724
|
+
_this2.focusTrap.init(drawer);
|
|
725
|
+
|
|
726
|
+
setInert(true, _this2.settings.selectorInert);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
focusTarget(drawer, _this2.settings);
|
|
730
|
+
drawer.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'opened', {
|
|
731
|
+
detail: _this2,
|
|
732
|
+
bubbles: true
|
|
733
|
+
}));
|
|
734
|
+
_this2.working = false;
|
|
735
|
+
return drawer;
|
|
736
|
+
});
|
|
737
|
+
} else {
|
|
738
|
+
focusTarget(drawer, _this2.settings);
|
|
739
|
+
return Promise.resolve(drawer);
|
|
740
|
+
}
|
|
741
|
+
} catch (e) {
|
|
742
|
+
return Promise.reject(e);
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
|
|
707
746
|
function stateSet(settings) {
|
|
708
747
|
// If save state is disabled
|
|
709
748
|
if (!settings.stateSave) return stateClear(settings); // If there isn't an existing state to set
|
|
@@ -748,6 +787,82 @@ function stateClear(settings) {
|
|
|
748
787
|
return {};
|
|
749
788
|
}
|
|
750
789
|
|
|
790
|
+
var switchToDefault = function switchToDefault(drawerKey) {
|
|
791
|
+
try {
|
|
792
|
+
var _this4 = this;
|
|
793
|
+
|
|
794
|
+
// Initial guards
|
|
795
|
+
var drawer = _this4.getDrawer(drawerKey);
|
|
796
|
+
|
|
797
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
798
|
+
if (!hasClass(drawer, _this4.settings.classModal)) return Promise.resolve(); // Tear down modal state
|
|
799
|
+
|
|
800
|
+
setInert(false, _this4.settings.selectorInert);
|
|
801
|
+
setOverflowHidden(false, _this4.settings.selectorOverflow);
|
|
802
|
+
removeClass(drawer, _this4.settings.classModal);
|
|
803
|
+
|
|
804
|
+
_this4.focusTrap.destroy(); // Restore drawers saved state
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
drawerKey = drawer.getAttribute("data-" + _this4.settings.dataDrawer);
|
|
808
|
+
var drawerState = _this4.state[drawerKey];
|
|
809
|
+
|
|
810
|
+
if (drawerState == _this4.settings.stateOpened) {
|
|
811
|
+
addClass(drawer, _this4.settings.stateOpened);
|
|
812
|
+
removeClass(drawer, _this4.settings.stateClosed);
|
|
813
|
+
} // Dispatch custom event
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
drawer.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'toDefault', {
|
|
817
|
+
bubbles: true
|
|
818
|
+
}));
|
|
819
|
+
return Promise.resolve(drawer);
|
|
820
|
+
} catch (e) {
|
|
821
|
+
return Promise.reject(e);
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
var switchToModal = function switchToModal(drawerKey) {
|
|
825
|
+
try {
|
|
826
|
+
var _this2 = this;
|
|
827
|
+
|
|
828
|
+
// Initial guards
|
|
829
|
+
var drawer = _this2.getDrawer(drawerKey);
|
|
830
|
+
|
|
831
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
832
|
+
if (hasClass(drawer, _this2.settings.classModal)) return Promise.resolve(); // Enable modal state
|
|
833
|
+
|
|
834
|
+
addClass(drawer, _this2.settings.classModal);
|
|
835
|
+
addClass(drawer, _this2.settings.stateClosed);
|
|
836
|
+
removeClass(drawer, _this2.settings.stateOpened); // Dispatch custom event
|
|
837
|
+
|
|
838
|
+
drawer.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'toModal', {
|
|
839
|
+
bubbles: true
|
|
840
|
+
}));
|
|
841
|
+
return Promise.resolve(drawer);
|
|
842
|
+
} catch (e) {
|
|
843
|
+
return Promise.reject(e);
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
var toggle = function toggle(drawerKey) {
|
|
848
|
+
try {
|
|
849
|
+
var _this2 = this;
|
|
850
|
+
|
|
851
|
+
var drawer = _this2.getDrawer(drawerKey);
|
|
852
|
+
|
|
853
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
854
|
+
var isClosed = !hasClass(drawer, _this2.settings.stateOpened);
|
|
855
|
+
|
|
856
|
+
if (isClosed) {
|
|
857
|
+
return Promise.resolve(_this2.open(drawer));
|
|
858
|
+
} else {
|
|
859
|
+
return Promise.resolve(_this2.close(drawer));
|
|
860
|
+
}
|
|
861
|
+
} catch (e) {
|
|
862
|
+
return Promise.reject(e);
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
|
|
751
866
|
var Drawer = /*#__PURE__*/function () {
|
|
752
867
|
function Drawer(options) {
|
|
753
868
|
this.defaults = defaults$2;
|
|
@@ -814,19 +929,12 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
814
929
|
*/
|
|
815
930
|
;
|
|
816
931
|
|
|
817
|
-
_proto.getDrawer = function getDrawer(drawerKey) {
|
|
818
|
-
|
|
819
|
-
return document.querySelector("[data-" + this.settings.dataDrawer + "=\"" + drawerKey + "\"]");
|
|
820
|
-
};
|
|
821
|
-
|
|
822
|
-
_proto.drawerNotFound = function drawerNotFound(key) {
|
|
823
|
-
return Promise.reject(new Error("Did not find drawer with key: \"" + key + "\""));
|
|
932
|
+
_proto.getDrawer = function getDrawer$1(drawerKey) {
|
|
933
|
+
return getDrawer.call(this, drawerKey);
|
|
824
934
|
};
|
|
825
935
|
|
|
826
936
|
_proto.setTabindex = function setTabindex$1() {
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
setTabindex(selectorTabindex);
|
|
937
|
+
return setTabindex("\n [data-" + this.settings.dataDrawer + "]\n [data-" + this.settings.dataDialog + "]\n ");
|
|
830
938
|
}
|
|
831
939
|
/**
|
|
832
940
|
* Save state functionality
|
|
@@ -854,114 +962,27 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
854
962
|
;
|
|
855
963
|
|
|
856
964
|
_proto.switchToDefault = function switchToDefault$1(drawerKey) {
|
|
857
|
-
return switchToDefault(
|
|
965
|
+
return switchToDefault.call(this, drawerKey);
|
|
858
966
|
};
|
|
859
967
|
|
|
860
968
|
_proto.switchToModal = function switchToModal$1(drawerKey) {
|
|
861
|
-
return switchToModal(
|
|
969
|
+
return switchToModal.call(this, drawerKey);
|
|
862
970
|
}
|
|
863
971
|
/**
|
|
864
972
|
* Change state functionality
|
|
865
973
|
*/
|
|
866
974
|
;
|
|
867
975
|
|
|
868
|
-
_proto.toggle = function toggle(drawerKey) {
|
|
869
|
-
|
|
870
|
-
var _this2 = this;
|
|
871
|
-
|
|
872
|
-
var drawer = _this2.getDrawer(drawerKey);
|
|
873
|
-
|
|
874
|
-
if (!drawer) return Promise.resolve(_this2.drawerNotFound(drawerKey));
|
|
875
|
-
var isClosed = !hasClass(drawer, _this2.settings.stateOpened);
|
|
876
|
-
|
|
877
|
-
if (isClosed) {
|
|
878
|
-
return Promise.resolve(_this2.open(drawer));
|
|
879
|
-
} else {
|
|
880
|
-
return Promise.resolve(_this2.close(drawer));
|
|
881
|
-
}
|
|
882
|
-
} catch (e) {
|
|
883
|
-
return Promise.reject(e);
|
|
884
|
-
}
|
|
976
|
+
_proto.toggle = function toggle$1(drawerKey) {
|
|
977
|
+
return toggle.call(this, drawerKey);
|
|
885
978
|
};
|
|
886
979
|
|
|
887
980
|
_proto.open = function open(drawerKey) {
|
|
888
|
-
|
|
889
|
-
var _this4 = this;
|
|
890
|
-
|
|
891
|
-
var drawer = _this4.getDrawer(drawerKey);
|
|
892
|
-
|
|
893
|
-
if (!drawer) return Promise.resolve(_this4.drawerNotFound(drawerKey));
|
|
894
|
-
|
|
895
|
-
if (!hasClass(drawer, _this4.settings.stateOpened)) {
|
|
896
|
-
_this4.working = true;
|
|
897
|
-
var isModal = hasClass(drawer, _this4.settings.classModal);
|
|
898
|
-
|
|
899
|
-
if (isModal) {
|
|
900
|
-
setOverflowHidden(true, _this4.settings.selectorOverflow);
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
return Promise.resolve(openTransition(drawer, _this4.settings)).then(function () {
|
|
904
|
-
_this4.stateSave(drawer);
|
|
905
|
-
|
|
906
|
-
if (isModal) {
|
|
907
|
-
_this4.focusTrap.init(drawer);
|
|
908
|
-
|
|
909
|
-
setInert(true, _this4.settings.selectorInert);
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
focusTarget(drawer, _this4.settings);
|
|
913
|
-
drawer.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'opened', {
|
|
914
|
-
detail: _this4,
|
|
915
|
-
bubbles: true
|
|
916
|
-
}));
|
|
917
|
-
_this4.working = false;
|
|
918
|
-
return drawer;
|
|
919
|
-
});
|
|
920
|
-
} else {
|
|
921
|
-
focusTarget(drawer, _this4.settings);
|
|
922
|
-
return Promise.resolve(drawer);
|
|
923
|
-
}
|
|
924
|
-
} catch (e) {
|
|
925
|
-
return Promise.reject(e);
|
|
926
|
-
}
|
|
981
|
+
return open$2.call(this, drawerKey);
|
|
927
982
|
};
|
|
928
983
|
|
|
929
984
|
_proto.close = function close(drawerKey) {
|
|
930
|
-
|
|
931
|
-
var _this6 = this;
|
|
932
|
-
|
|
933
|
-
var drawer = _this6.getDrawer(drawerKey);
|
|
934
|
-
|
|
935
|
-
if (!drawer) return Promise.resolve(_this6.drawerNotFound(drawerKey));
|
|
936
|
-
|
|
937
|
-
if (hasClass(drawer, _this6.settings.stateOpened)) {
|
|
938
|
-
_this6.working = true;
|
|
939
|
-
|
|
940
|
-
if (hasClass(drawer, _this6.settings.classModal)) {
|
|
941
|
-
setInert(false, _this6.settings.selectorInert);
|
|
942
|
-
setOverflowHidden(false, _this6.settings.selectorOverflow);
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
return Promise.resolve(closeTransition(drawer, _this6.settings)).then(function () {
|
|
946
|
-
_this6.stateSave(drawer);
|
|
947
|
-
|
|
948
|
-
focusTrigger(_this6);
|
|
949
|
-
|
|
950
|
-
_this6.focusTrap.destroy();
|
|
951
|
-
|
|
952
|
-
drawer.dispatchEvent(new CustomEvent(_this6.settings.customEventPrefix + 'closed', {
|
|
953
|
-
detail: _this6,
|
|
954
|
-
bubbles: true
|
|
955
|
-
}));
|
|
956
|
-
_this6.working = false;
|
|
957
|
-
return drawer;
|
|
958
|
-
});
|
|
959
|
-
} else {
|
|
960
|
-
return Promise.resolve(drawer);
|
|
961
|
-
}
|
|
962
|
-
} catch (e) {
|
|
963
|
-
return Promise.reject(e);
|
|
964
|
-
}
|
|
985
|
+
return close$2.call(this, drawerKey);
|
|
965
986
|
};
|
|
966
987
|
|
|
967
988
|
return Drawer;
|
|
@@ -995,6 +1016,40 @@ var defaults$1 = {
|
|
|
995
1016
|
transition: true
|
|
996
1017
|
};
|
|
997
1018
|
|
|
1019
|
+
var close$1 = function close(returnFocus) {
|
|
1020
|
+
if (returnFocus === void 0) {
|
|
1021
|
+
returnFocus = true;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
try {
|
|
1025
|
+
var _this2 = this;
|
|
1026
|
+
|
|
1027
|
+
var modal = document.querySelector("[data-" + _this2.settings.dataModal + "]." + _this2.settings.stateOpened);
|
|
1028
|
+
|
|
1029
|
+
if (modal) {
|
|
1030
|
+
_this2.working = true;
|
|
1031
|
+
setInert(false, _this2.settings.selectorInert);
|
|
1032
|
+
setOverflowHidden(false, _this2.settings.selectorOverflow);
|
|
1033
|
+
return Promise.resolve(closeTransition(modal, _this2.settings)).then(function () {
|
|
1034
|
+
if (returnFocus) focusTrigger(_this2);
|
|
1035
|
+
|
|
1036
|
+
_this2.focusTrap.destroy();
|
|
1037
|
+
|
|
1038
|
+
modal.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'closed', {
|
|
1039
|
+
detail: _this2,
|
|
1040
|
+
bubbles: true
|
|
1041
|
+
}));
|
|
1042
|
+
_this2.working = false;
|
|
1043
|
+
return modal;
|
|
1044
|
+
});
|
|
1045
|
+
} else {
|
|
1046
|
+
return Promise.resolve(modal);
|
|
1047
|
+
}
|
|
1048
|
+
} catch (e) {
|
|
1049
|
+
return Promise.reject(e);
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
|
|
998
1053
|
var handlerClick$1 = function handlerClick(event) {
|
|
999
1054
|
try {
|
|
1000
1055
|
var _temp3 = function _temp3(_result) {
|
|
@@ -1056,21 +1111,76 @@ function handlerKeydown$1(event) {
|
|
|
1056
1111
|
}
|
|
1057
1112
|
}
|
|
1058
1113
|
|
|
1059
|
-
function
|
|
1060
|
-
|
|
1114
|
+
function getModal(modalKey) {
|
|
1115
|
+
if (typeof modalKey !== 'string') return modalKey;
|
|
1116
|
+
return document.querySelector("[data-" + this.settings.dataModal + "=\"" + modalKey + "\"]");
|
|
1117
|
+
}
|
|
1118
|
+
function modalNotFound(key) {
|
|
1119
|
+
return Promise.reject(new Error("Did not find modal with key: \"" + key + "\""));
|
|
1120
|
+
}
|
|
1121
|
+
function moveModals(type, ref) {
|
|
1122
|
+
if (type === void 0) {
|
|
1123
|
+
type = this.settings.moveModals.type;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
if (ref === void 0) {
|
|
1127
|
+
ref = this.settings.moveModals.ref;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
var modals = document.querySelectorAll("[data-" + this.settings.dataModal + "]");
|
|
1131
|
+
if (modals.length) moveElement(modals, type, ref);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
function setInitialState() {
|
|
1135
|
+
var _this = this;
|
|
1136
|
+
|
|
1137
|
+
var modals = document.querySelectorAll("[data-" + this.settings.dataModal + "]");
|
|
1061
1138
|
modals.forEach(function (el) {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1139
|
+
// Remove opened state setup
|
|
1140
|
+
if (el.classList.contains(_this.settings.stateOpened)) {
|
|
1141
|
+
setInert(false, _this.settings.selectorInert);
|
|
1142
|
+
setOverflowHidden(false, _this.settings.selectorOverflow);
|
|
1143
|
+
focusTrigger(_this);
|
|
1144
|
+
|
|
1145
|
+
_this.focusTrap.destroy();
|
|
1146
|
+
} // Remove all state classes and add the default state (closed)
|
|
1068
1147
|
|
|
1069
|
-
|
|
1070
|
-
|
|
1148
|
+
|
|
1149
|
+
removeClass(el, _this.settings.stateOpened, _this.settings.stateOpening, _this.settings.stateClosing);
|
|
1150
|
+
addClass(el, _this.settings.stateClosed);
|
|
1071
1151
|
});
|
|
1072
1152
|
}
|
|
1073
1153
|
|
|
1154
|
+
var open$1 = function open(modalKey) {
|
|
1155
|
+
try {
|
|
1156
|
+
var _this2 = this;
|
|
1157
|
+
|
|
1158
|
+
var modal = getModal.call(_this2, modalKey);
|
|
1159
|
+
if (!modal) return Promise.resolve(modalNotFound(modalKey));
|
|
1160
|
+
|
|
1161
|
+
if (hasClass(modal, _this2.settings.stateClosed)) {
|
|
1162
|
+
_this2.working = true;
|
|
1163
|
+
setOverflowHidden(true, _this2.settings.selectorOverflow);
|
|
1164
|
+
return Promise.resolve(openTransition(modal, _this2.settings)).then(function () {
|
|
1165
|
+
_this2.focusTrap.init(modal);
|
|
1166
|
+
|
|
1167
|
+
focusTarget(modal, _this2.settings);
|
|
1168
|
+
setInert(true, _this2.settings.selectorInert);
|
|
1169
|
+
modal.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'opened', {
|
|
1170
|
+
detail: _this2,
|
|
1171
|
+
bubbles: true
|
|
1172
|
+
}));
|
|
1173
|
+
_this2.working = false;
|
|
1174
|
+
return modal;
|
|
1175
|
+
});
|
|
1176
|
+
} else {
|
|
1177
|
+
return Promise.resolve(modal);
|
|
1178
|
+
}
|
|
1179
|
+
} catch (e) {
|
|
1180
|
+
return Promise.reject(e);
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
|
|
1074
1184
|
var Modal = /*#__PURE__*/function () {
|
|
1075
1185
|
function Modal(options) {
|
|
1076
1186
|
this.defaults = defaults$1;
|
|
@@ -1092,13 +1202,12 @@ var Modal = /*#__PURE__*/function () {
|
|
|
1092
1202
|
|
|
1093
1203
|
if (options) this.settings = _extends({}, this.settings, options);
|
|
1094
1204
|
this.moveModals();
|
|
1205
|
+
this.setInitialState();
|
|
1095
1206
|
|
|
1096
1207
|
if (this.settings.setTabindex) {
|
|
1097
1208
|
this.setTabindex();
|
|
1098
1209
|
}
|
|
1099
1210
|
|
|
1100
|
-
this.setInitialState();
|
|
1101
|
-
|
|
1102
1211
|
if (this.settings.eventListeners) {
|
|
1103
1212
|
this.initEventListeners();
|
|
1104
1213
|
}
|
|
@@ -1132,36 +1241,20 @@ var Modal = /*#__PURE__*/function () {
|
|
|
1132
1241
|
*/
|
|
1133
1242
|
;
|
|
1134
1243
|
|
|
1135
|
-
_proto.getModal = function getModal(modalKey) {
|
|
1136
|
-
|
|
1137
|
-
return document.querySelector("[data-" + this.settings.dataModal + "=\"" + modalKey + "\"]");
|
|
1138
|
-
};
|
|
1139
|
-
|
|
1140
|
-
_proto.modalNotFound = function modalNotFound(key) {
|
|
1141
|
-
return Promise.reject(new Error("Did not find modal with key: \"" + key + "\""));
|
|
1244
|
+
_proto.getModal = function getModal$1(modalKey) {
|
|
1245
|
+
return getModal.call(this, modalKey);
|
|
1142
1246
|
};
|
|
1143
1247
|
|
|
1144
1248
|
_proto.setTabindex = function setTabindex$1() {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
setTabindex(selectorTabindex);
|
|
1249
|
+
return setTabindex("\n [data-" + this.settings.dataModal + "]\n [data-" + this.settings.dataDialog + "]\n ");
|
|
1148
1250
|
};
|
|
1149
1251
|
|
|
1150
1252
|
_proto.setInitialState = function setInitialState$1() {
|
|
1151
|
-
setInitialState(this);
|
|
1253
|
+
return setInitialState.call(this);
|
|
1152
1254
|
};
|
|
1153
1255
|
|
|
1154
|
-
_proto.moveModals = function moveModals(type, ref) {
|
|
1155
|
-
|
|
1156
|
-
type = this.settings.moveModals.type;
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
if (ref === void 0) {
|
|
1160
|
-
ref = this.settings.moveModals.ref;
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
var modals = document.querySelectorAll("[data-" + this.settings.dataModal + "]");
|
|
1164
|
-
if (modals.length) moveElement(modals, type, ref);
|
|
1256
|
+
_proto.moveModals = function moveModals$1(type, ref) {
|
|
1257
|
+
return moveModals.call(this, type, ref);
|
|
1165
1258
|
}
|
|
1166
1259
|
/**
|
|
1167
1260
|
* Change state functionality
|
|
@@ -1169,68 +1262,11 @@ var Modal = /*#__PURE__*/function () {
|
|
|
1169
1262
|
;
|
|
1170
1263
|
|
|
1171
1264
|
_proto.open = function open(modalKey) {
|
|
1172
|
-
|
|
1173
|
-
var _this2 = this;
|
|
1174
|
-
|
|
1175
|
-
var modal = _this2.getModal(modalKey);
|
|
1176
|
-
|
|
1177
|
-
if (!modal) return Promise.resolve(_this2.modalNotFound(modalKey));
|
|
1178
|
-
|
|
1179
|
-
if (hasClass(modal, _this2.settings.stateClosed)) {
|
|
1180
|
-
_this2.working = true;
|
|
1181
|
-
setOverflowHidden(true, _this2.settings.selectorOverflow);
|
|
1182
|
-
return Promise.resolve(openTransition(modal, _this2.settings)).then(function () {
|
|
1183
|
-
_this2.focusTrap.init(modal);
|
|
1184
|
-
|
|
1185
|
-
focusTarget(modal, _this2.settings);
|
|
1186
|
-
setInert(true, _this2.settings.selectorInert);
|
|
1187
|
-
modal.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'opened', {
|
|
1188
|
-
detail: _this2,
|
|
1189
|
-
bubbles: true
|
|
1190
|
-
}));
|
|
1191
|
-
_this2.working = false;
|
|
1192
|
-
return modal;
|
|
1193
|
-
});
|
|
1194
|
-
} else {
|
|
1195
|
-
return Promise.resolve(modal);
|
|
1196
|
-
}
|
|
1197
|
-
} catch (e) {
|
|
1198
|
-
return Promise.reject(e);
|
|
1199
|
-
}
|
|
1265
|
+
return open$1.call(this, modalKey);
|
|
1200
1266
|
};
|
|
1201
1267
|
|
|
1202
1268
|
_proto.close = function close(returnFocus) {
|
|
1203
|
-
|
|
1204
|
-
returnFocus = true;
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
try {
|
|
1208
|
-
var _this4 = this;
|
|
1209
|
-
|
|
1210
|
-
var modal = document.querySelector("[data-" + _this4.settings.dataModal + "]." + _this4.settings.stateOpened);
|
|
1211
|
-
|
|
1212
|
-
if (modal) {
|
|
1213
|
-
_this4.working = true;
|
|
1214
|
-
setInert(false, _this4.settings.selectorInert);
|
|
1215
|
-
setOverflowHidden(false, _this4.settings.selectorOverflow);
|
|
1216
|
-
return Promise.resolve(closeTransition(modal, _this4.settings)).then(function () {
|
|
1217
|
-
if (returnFocus) focusTrigger(_this4);
|
|
1218
|
-
|
|
1219
|
-
_this4.focusTrap.destroy();
|
|
1220
|
-
|
|
1221
|
-
modal.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'closed', {
|
|
1222
|
-
detail: _this4,
|
|
1223
|
-
bubbles: true
|
|
1224
|
-
}));
|
|
1225
|
-
_this4.working = false;
|
|
1226
|
-
return modal;
|
|
1227
|
-
});
|
|
1228
|
-
} else {
|
|
1229
|
-
return Promise.resolve(modal);
|
|
1230
|
-
}
|
|
1231
|
-
} catch (e) {
|
|
1232
|
-
return Promise.reject(e);
|
|
1233
|
-
}
|
|
1269
|
+
return close$1.call(this, returnFocus);
|
|
1234
1270
|
};
|
|
1235
1271
|
|
|
1236
1272
|
return Modal;
|
|
@@ -1252,9 +1288,9 @@ var defaults = {
|
|
|
1252
1288
|
placement: 'bottom-start'
|
|
1253
1289
|
};
|
|
1254
1290
|
|
|
1255
|
-
function
|
|
1291
|
+
function close(popover) {
|
|
1256
1292
|
// Update state class
|
|
1257
|
-
popover.target.classList.remove(
|
|
1293
|
+
popover.target.classList.remove(this.settings.stateActive); // Update a11y attributes
|
|
1258
1294
|
|
|
1259
1295
|
popover.trigger.setAttribute('aria-expanded', 'false'); // Disable popper event listeners
|
|
1260
1296
|
|
|
@@ -1265,39 +1301,43 @@ function hide$2(popover, obj) {
|
|
|
1265
1301
|
}]
|
|
1266
1302
|
}); // Update collection status with new state
|
|
1267
1303
|
|
|
1268
|
-
var index =
|
|
1304
|
+
var index = this.collection.findIndex(function (item) {
|
|
1269
1305
|
return item.target === popover.target;
|
|
1270
1306
|
});
|
|
1271
|
-
|
|
1307
|
+
this.collection[index].state = 'closed'; // Clear the memory if popover trigger matches the ones saved in memory
|
|
1272
1308
|
|
|
1273
|
-
if (popover.trigger ===
|
|
1274
|
-
|
|
1309
|
+
if (popover.trigger === this.memory.trigger) {
|
|
1310
|
+
this.memory.trigger = null;
|
|
1275
1311
|
} // Return the popover
|
|
1276
1312
|
|
|
1277
1313
|
|
|
1278
1314
|
return popover;
|
|
1279
1315
|
}
|
|
1280
|
-
function
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1316
|
+
function closeAll() {
|
|
1317
|
+
var _this = this;
|
|
1318
|
+
|
|
1319
|
+
this.collection.forEach(function (popover) {
|
|
1320
|
+
if (popover.state === 'opened') {
|
|
1321
|
+
_this.close(popover);
|
|
1284
1322
|
}
|
|
1285
1323
|
}); // Return the collection
|
|
1286
1324
|
|
|
1287
|
-
return
|
|
1325
|
+
return this.collection;
|
|
1288
1326
|
}
|
|
1289
|
-
function
|
|
1290
|
-
|
|
1291
|
-
|
|
1327
|
+
function closeCheck(popover) {
|
|
1328
|
+
var _this2 = this;
|
|
1329
|
+
|
|
1330
|
+
// Only run closeCheck if provided popover is currently open
|
|
1331
|
+
if (popover.state != 'opened') return; // Needed to correctly check which element is currently being focused
|
|
1292
1332
|
|
|
1293
1333
|
setTimeout(function () {
|
|
1294
1334
|
// Check if trigger or target are being hovered
|
|
1295
1335
|
var isHovered = popover.target.closest(':hover') === popover.target || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or target are being focused
|
|
1296
1336
|
|
|
1297
|
-
var isFocused = document.activeElement.closest("[data-" +
|
|
1337
|
+
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
|
|
1298
1338
|
|
|
1299
1339
|
if (!isHovered && !isFocused) {
|
|
1300
|
-
|
|
1340
|
+
_this2.close(popover);
|
|
1301
1341
|
} // Return the popover
|
|
1302
1342
|
|
|
1303
1343
|
|
|
@@ -1305,6 +1345,57 @@ function hideCheck(popover, obj) {
|
|
|
1305
1345
|
}, 1);
|
|
1306
1346
|
}
|
|
1307
1347
|
|
|
1348
|
+
function handlerClick(popover) {
|
|
1349
|
+
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
1350
|
+
this.close(popover);
|
|
1351
|
+
} else {
|
|
1352
|
+
this.memory.trigger = popover.trigger;
|
|
1353
|
+
this.open(popover);
|
|
1354
|
+
documentClick.call(this, popover);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
function handlerKeydown(event) {
|
|
1358
|
+
var _this = this;
|
|
1359
|
+
|
|
1360
|
+
switch (event.key) {
|
|
1361
|
+
case 'Escape':
|
|
1362
|
+
if (this.memory.trigger) {
|
|
1363
|
+
this.memory.trigger.focus();
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
this.closeAll();
|
|
1367
|
+
return;
|
|
1368
|
+
|
|
1369
|
+
case 'Tab':
|
|
1370
|
+
this.collection.forEach(function (popover) {
|
|
1371
|
+
closeCheck.call(_this, popover);
|
|
1372
|
+
});
|
|
1373
|
+
return;
|
|
1374
|
+
|
|
1375
|
+
default:
|
|
1376
|
+
return;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
function documentClick(popover) {
|
|
1380
|
+
var obj = this;
|
|
1381
|
+
document.addEventListener('click', function _f(event) {
|
|
1382
|
+
var result = event.target.closest("[data-" + obj.settings.dataPopover + "], [data-" + obj.settings.dataTrigger + "]");
|
|
1383
|
+
var match = result === popover.target || result === popover.trigger;
|
|
1384
|
+
|
|
1385
|
+
if (!match) {
|
|
1386
|
+
if (popover.target.classList.contains(obj.settings.stateActive)) {
|
|
1387
|
+
obj.close(popover);
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
this.removeEventListener('click', _f);
|
|
1391
|
+
} else {
|
|
1392
|
+
if (!popover.target.classList.contains(obj.settings.stateActive)) {
|
|
1393
|
+
this.removeEventListener('click', _f);
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1308
1399
|
function getConfig(el, settings) {
|
|
1309
1400
|
// Get the computed styles of the popover
|
|
1310
1401
|
var styles = getComputedStyle(el); // Setup the config obj with default values
|
|
@@ -1429,16 +1520,16 @@ function getPopover(trigger, settings) {
|
|
|
1429
1520
|
}
|
|
1430
1521
|
}
|
|
1431
1522
|
|
|
1432
|
-
function
|
|
1523
|
+
function open(popover) {
|
|
1433
1524
|
// Update state class
|
|
1434
|
-
popover.target.classList.add(
|
|
1525
|
+
popover.target.classList.add(this.settings.stateActive); // Update a11y attributes
|
|
1435
1526
|
|
|
1436
1527
|
popover.trigger.setAttribute('aria-expanded', 'true'); // Update popover config
|
|
1437
1528
|
|
|
1438
|
-
popover.config = getConfig(popover.target,
|
|
1529
|
+
popover.config = getConfig(popover.target, this.settings); // Enable popper event listeners and set placement/modifiers
|
|
1439
1530
|
|
|
1440
1531
|
popover.popper.setOptions({
|
|
1441
|
-
placement: getData(popover.target,
|
|
1532
|
+
placement: getData(popover.target, this.settings.dataPlacement, popover.config['placement']),
|
|
1442
1533
|
modifiers: [{
|
|
1443
1534
|
name: 'eventListeners',
|
|
1444
1535
|
enabled: true
|
|
@@ -1447,64 +1538,14 @@ function show(popover, obj) {
|
|
|
1447
1538
|
|
|
1448
1539
|
popover.popper.update(); // Update collection status with new state
|
|
1449
1540
|
|
|
1450
|
-
var index =
|
|
1541
|
+
var index = this.collection.findIndex(function (item) {
|
|
1451
1542
|
return item.target === popover.target;
|
|
1452
1543
|
});
|
|
1453
|
-
|
|
1544
|
+
this.collection[index].state = 'opened'; // Return the popover
|
|
1454
1545
|
|
|
1455
1546
|
return popover;
|
|
1456
1547
|
}
|
|
1457
1548
|
|
|
1458
|
-
function handlerClick(popover) {
|
|
1459
|
-
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
1460
|
-
hide$2(popover, this);
|
|
1461
|
-
} else {
|
|
1462
|
-
this.memory.trigger = popover.trigger;
|
|
1463
|
-
show(popover, this);
|
|
1464
|
-
documentClick(popover, this);
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
function handlerKeydown(event) {
|
|
1468
|
-
var _this = this;
|
|
1469
|
-
|
|
1470
|
-
switch (event.key) {
|
|
1471
|
-
case 'Escape':
|
|
1472
|
-
if (this.memory.trigger) {
|
|
1473
|
-
this.memory.trigger.focus();
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
hideAll(this);
|
|
1477
|
-
return;
|
|
1478
|
-
|
|
1479
|
-
case 'Tab':
|
|
1480
|
-
this.collection.forEach(function (popover) {
|
|
1481
|
-
hideCheck(popover, _this);
|
|
1482
|
-
});
|
|
1483
|
-
return;
|
|
1484
|
-
|
|
1485
|
-
default:
|
|
1486
|
-
return;
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
function documentClick(popover, obj) {
|
|
1490
|
-
document.addEventListener('click', function _f(event) {
|
|
1491
|
-
var result = event.target.closest("[data-" + obj.settings.dataPopover + "], [data-" + obj.settings.dataTrigger + "]");
|
|
1492
|
-
var match = result === popover.target || result === popover.trigger;
|
|
1493
|
-
|
|
1494
|
-
if (!match) {
|
|
1495
|
-
if (popover.target.classList.contains(obj.settings.stateActive)) {
|
|
1496
|
-
hide$2(popover, obj);
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
this.removeEventListener('click', _f);
|
|
1500
|
-
} else {
|
|
1501
|
-
if (!popover.target.classList.contains(obj.settings.stateActive)) {
|
|
1502
|
-
this.removeEventListener('click', _f);
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
});
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
1549
|
var top = 'top';
|
|
1509
1550
|
var bottom = 'bottom';
|
|
1510
1551
|
var right = 'right';
|
|
@@ -3288,11 +3329,11 @@ var createPopper = /*#__PURE__*/popperGenerator({
|
|
|
3288
3329
|
defaultModifiers: defaultModifiers
|
|
3289
3330
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
3290
3331
|
|
|
3291
|
-
function register(trigger, target
|
|
3332
|
+
function register(trigger, target) {
|
|
3292
3333
|
// If no target is passed
|
|
3293
3334
|
if (!target) {
|
|
3294
3335
|
// Try and get the target
|
|
3295
|
-
target = getPopover(trigger,
|
|
3336
|
+
target = getPopover(trigger, this.settings); // If still no target is returned, log an error and return false
|
|
3296
3337
|
|
|
3297
3338
|
if (!target) {
|
|
3298
3339
|
console.error('No popover associated with the provided trigger:', trigger);
|
|
@@ -3301,7 +3342,7 @@ function register(trigger, target, obj) {
|
|
|
3301
3342
|
} // Check if this item has already been registered in the collection
|
|
3302
3343
|
|
|
3303
3344
|
|
|
3304
|
-
var index =
|
|
3345
|
+
var index = this.collection.findIndex(function (item) {
|
|
3305
3346
|
return item.trigger === trigger && item.target === target;
|
|
3306
3347
|
}); // Initiate popover variable
|
|
3307
3348
|
|
|
@@ -3309,45 +3350,45 @@ function register(trigger, target, obj) {
|
|
|
3309
3350
|
|
|
3310
3351
|
if (index >= 0) {
|
|
3311
3352
|
// Set popover as item from collection
|
|
3312
|
-
popover =
|
|
3353
|
+
popover = this.collection[index];
|
|
3313
3354
|
} else {
|
|
3314
3355
|
// Create popper instance
|
|
3315
3356
|
var popperInstance = createPopper(trigger, target); // Build popover object and push to collection array
|
|
3316
3357
|
|
|
3317
3358
|
popover = {
|
|
3318
|
-
state: '
|
|
3359
|
+
state: 'closed',
|
|
3319
3360
|
trigger: trigger,
|
|
3320
3361
|
target: target,
|
|
3321
3362
|
popper: popperInstance,
|
|
3322
|
-
config: getConfig(target,
|
|
3363
|
+
config: getConfig(target, this.settings)
|
|
3323
3364
|
}; // Add item to collection
|
|
3324
3365
|
|
|
3325
|
-
|
|
3366
|
+
this.collection.push(popover);
|
|
3326
3367
|
} // Setup event listeners
|
|
3327
3368
|
|
|
3328
3369
|
|
|
3329
|
-
registerEventListeners(
|
|
3370
|
+
registerEventListeners.call(this, popover); // Set initial state of popover
|
|
3330
3371
|
|
|
3331
|
-
if (popover.target.classList.contains(
|
|
3332
|
-
|
|
3333
|
-
documentClick(
|
|
3372
|
+
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
3373
|
+
this.open(popover);
|
|
3374
|
+
documentClick.call(this, popover);
|
|
3334
3375
|
} else {
|
|
3335
|
-
|
|
3376
|
+
this.close(popover);
|
|
3336
3377
|
} // Return the popover object
|
|
3337
3378
|
|
|
3338
3379
|
|
|
3339
3380
|
return popover;
|
|
3340
3381
|
}
|
|
3341
|
-
function deregister(popover
|
|
3382
|
+
function deregister(popover) {
|
|
3342
3383
|
// Check if this item has been registered in the collection
|
|
3343
|
-
var index =
|
|
3384
|
+
var index = this.collection.findIndex(function (item) {
|
|
3344
3385
|
return item.trigger === popover.trigger && item.target === popover.target;
|
|
3345
3386
|
}); // If the item exists in the collection
|
|
3346
3387
|
|
|
3347
3388
|
if (index >= 0) {
|
|
3348
|
-
//
|
|
3349
|
-
if (popover.state === '
|
|
3350
|
-
|
|
3389
|
+
// Close the popover
|
|
3390
|
+
if (popover.state === 'opened') {
|
|
3391
|
+
this.close(popover);
|
|
3351
3392
|
} // Clean up the popper instance
|
|
3352
3393
|
|
|
3353
3394
|
|
|
@@ -3355,28 +3396,28 @@ function deregister(popover, obj) {
|
|
|
3355
3396
|
|
|
3356
3397
|
deregisterEventListeners(popover); // Remove item from collection
|
|
3357
3398
|
|
|
3358
|
-
|
|
3399
|
+
this.collection.splice(index, 1);
|
|
3359
3400
|
} // Return the new collection
|
|
3360
3401
|
|
|
3361
3402
|
|
|
3362
|
-
return
|
|
3403
|
+
return this.collection;
|
|
3363
3404
|
}
|
|
3364
|
-
function registerEventListeners(popover
|
|
3405
|
+
function registerEventListeners(popover) {
|
|
3365
3406
|
// If event listeners aren't already setup
|
|
3366
3407
|
if (!popover.__eventListeners) {
|
|
3367
3408
|
// Add event listeners based on event type
|
|
3368
|
-
var eventType = getData(popover.target,
|
|
3409
|
+
var eventType = getData(popover.target, this.settings.dataEventType, popover.config['event']);
|
|
3369
3410
|
|
|
3370
3411
|
if (eventType === 'hover') {
|
|
3371
3412
|
// Setup event listeners object for hover
|
|
3372
3413
|
popover.__eventListeners = [{
|
|
3373
3414
|
el: ['trigger'],
|
|
3374
3415
|
type: ['mouseenter', 'focus'],
|
|
3375
|
-
listener:
|
|
3416
|
+
listener: open.bind(this, popover)
|
|
3376
3417
|
}, {
|
|
3377
3418
|
el: ['trigger', 'target'],
|
|
3378
3419
|
type: ['mouseleave', 'focusout'],
|
|
3379
|
-
listener:
|
|
3420
|
+
listener: closeCheck.bind(this, popover)
|
|
3380
3421
|
}]; // Loop through listeners and apply to appropriate elements
|
|
3381
3422
|
|
|
3382
3423
|
popover.__eventListeners.forEach(function (evObj) {
|
|
@@ -3391,7 +3432,7 @@ function registerEventListeners(popover, obj) {
|
|
|
3391
3432
|
popover.__eventListeners = [{
|
|
3392
3433
|
el: ['trigger'],
|
|
3393
3434
|
type: ['click'],
|
|
3394
|
-
listener: handlerClick.bind(
|
|
3435
|
+
listener: handlerClick.bind(this, popover)
|
|
3395
3436
|
}]; // Loop through listeners and apply to appropriate elements
|
|
3396
3437
|
|
|
3397
3438
|
popover.__eventListeners.forEach(function (evObj) {
|
|
@@ -3426,24 +3467,26 @@ function deregisterEventListeners(popover) {
|
|
|
3426
3467
|
|
|
3427
3468
|
return popover;
|
|
3428
3469
|
}
|
|
3429
|
-
function registerCollection(
|
|
3470
|
+
function registerCollection() {
|
|
3471
|
+
var _this = this;
|
|
3472
|
+
|
|
3430
3473
|
// Get all the triggers
|
|
3431
|
-
var triggers = document.querySelectorAll("[data-" +
|
|
3474
|
+
var triggers = document.querySelectorAll("[data-" + this.settings.dataTrigger + "]");
|
|
3432
3475
|
triggers.forEach(function (trigger) {
|
|
3433
3476
|
// Register the popover and save to collection array
|
|
3434
|
-
register(trigger, false
|
|
3477
|
+
_this.register(trigger, false);
|
|
3435
3478
|
}); // Return the popover collection
|
|
3436
3479
|
|
|
3437
|
-
return
|
|
3480
|
+
return this.collection;
|
|
3438
3481
|
}
|
|
3439
|
-
function deregisterCollection(
|
|
3482
|
+
function deregisterCollection() {
|
|
3440
3483
|
// Loop through all items within the collection and pass them to deregister()
|
|
3441
|
-
while (
|
|
3442
|
-
deregister(
|
|
3484
|
+
while (this.collection.length > 0) {
|
|
3485
|
+
this.deregister(this.collection[0]);
|
|
3443
3486
|
} // Return the popover collection
|
|
3444
3487
|
|
|
3445
3488
|
|
|
3446
|
-
return
|
|
3489
|
+
return this.collection;
|
|
3447
3490
|
}
|
|
3448
3491
|
|
|
3449
3492
|
var Popover = /*#__PURE__*/function () {
|
|
@@ -3468,8 +3511,7 @@ var Popover = /*#__PURE__*/function () {
|
|
|
3468
3511
|
// Update settings with passed options
|
|
3469
3512
|
if (options) this.settings = _extends({}, this.settings, options); // Build the collections array with popover instances
|
|
3470
3513
|
|
|
3471
|
-
registerCollection(
|
|
3472
|
-
|
|
3514
|
+
this.registerCollection(); // If eventListeners is enabled
|
|
3473
3515
|
|
|
3474
3516
|
if (this.settings.eventListeners) {
|
|
3475
3517
|
// Pass false to initEventListeners() since registerCollection()
|
|
@@ -3480,8 +3522,7 @@ var Popover = /*#__PURE__*/function () {
|
|
|
3480
3522
|
|
|
3481
3523
|
_proto.destroy = function destroy() {
|
|
3482
3524
|
// Deregister all popovers from collection
|
|
3483
|
-
deregisterCollection(
|
|
3484
|
-
|
|
3525
|
+
this.deregisterCollection(); // If eventListeners is enabled
|
|
3485
3526
|
|
|
3486
3527
|
if (this.settings.eventListeners) {
|
|
3487
3528
|
// Pass false to destroyEventListeners() since deregisterCollection()
|
|
@@ -3504,7 +3545,7 @@ var Popover = /*#__PURE__*/function () {
|
|
|
3504
3545
|
if (processCollection) {
|
|
3505
3546
|
// Loop through collection and setup event listeners
|
|
3506
3547
|
this.collection.forEach(function (popover) {
|
|
3507
|
-
registerEventListeners(
|
|
3548
|
+
registerEventListeners.call(_this, popover);
|
|
3508
3549
|
});
|
|
3509
3550
|
} // Add keydown global event listener
|
|
3510
3551
|
|
|
@@ -3537,35 +3578,35 @@ var Popover = /*#__PURE__*/function () {
|
|
|
3537
3578
|
target = false;
|
|
3538
3579
|
}
|
|
3539
3580
|
|
|
3540
|
-
return register(trigger, target
|
|
3581
|
+
return register.call(this, trigger, target);
|
|
3541
3582
|
};
|
|
3542
3583
|
|
|
3543
3584
|
_proto.deregister = function deregister$1(popover) {
|
|
3544
|
-
return deregister(
|
|
3585
|
+
return deregister.call(this, popover);
|
|
3545
3586
|
};
|
|
3546
3587
|
|
|
3547
3588
|
_proto.registerCollection = function registerCollection$1() {
|
|
3548
|
-
return registerCollection(this);
|
|
3589
|
+
return registerCollection.call(this);
|
|
3549
3590
|
};
|
|
3550
3591
|
|
|
3551
3592
|
_proto.deregisterCollection = function deregisterCollection$1() {
|
|
3552
|
-
return deregisterCollection(this);
|
|
3593
|
+
return deregisterCollection.call(this);
|
|
3553
3594
|
}
|
|
3554
3595
|
/**
|
|
3555
3596
|
* Change state functionality
|
|
3556
3597
|
*/
|
|
3557
3598
|
;
|
|
3558
3599
|
|
|
3559
|
-
_proto.
|
|
3560
|
-
return
|
|
3600
|
+
_proto.open = function open$1(popover) {
|
|
3601
|
+
return open.call(this, popover);
|
|
3561
3602
|
};
|
|
3562
3603
|
|
|
3563
|
-
_proto.
|
|
3564
|
-
return
|
|
3604
|
+
_proto.close = function close$1(popover) {
|
|
3605
|
+
return close.call(this, popover);
|
|
3565
3606
|
};
|
|
3566
3607
|
|
|
3567
|
-
_proto.
|
|
3568
|
-
return
|
|
3608
|
+
_proto.closeAll = function closeAll$1() {
|
|
3609
|
+
return closeAll.call(this);
|
|
3569
3610
|
};
|
|
3570
3611
|
|
|
3571
3612
|
return Popover;
|