vrembem 1.42.0 → 1.42.1

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.
@@ -891,6 +891,7 @@ var defaults$1 = {
891
891
  dataClose: 'modal-close',
892
892
  dataFocus: 'modal-focus',
893
893
  dataRequired: 'modal-required',
894
+ dataConfig: 'modal-config',
894
895
  // State classes
895
896
  stateOpened: 'is-opened',
896
897
  stateOpening: 'is-opening',
@@ -910,17 +911,40 @@ var defaults$1 = {
910
911
  transition: true
911
912
  };
912
913
 
914
+ function getModalConfig(modal) {
915
+ const json = modal.getAttribute(`data-${this.settings.dataConfig}`);
916
+
917
+ if (json) {
918
+ const config = JSON.parse(json);
919
+ return _extends({}, this.settings, config);
920
+ } else {
921
+ return this.settings;
922
+ }
923
+ }
924
+ function getModal(modalKey) {
925
+ if (typeof modalKey !== 'string') return modalKey;
926
+ return document.querySelector(`[data-${this.settings.dataModal}="${modalKey}"]`);
927
+ }
928
+ function modalNotFound(key) {
929
+ return Promise.reject(new Error(`Did not find modal with key: "${key}"`));
930
+ }
931
+ function moveModals(type = this.settings.moveModals.type, ref = this.settings.moveModals.ref) {
932
+ const modals = document.querySelectorAll(`[data-${this.settings.dataModal}]`);
933
+ if (modals.length) moveElement(modals, type, ref);
934
+ }
935
+
913
936
  async function close$1(returnFocus = true) {
914
937
  const modal = document.querySelector(`[data-${this.settings.dataModal}].${this.settings.stateOpened}`);
915
938
 
916
939
  if (modal) {
917
940
  this.working = true;
918
- setInert(false, this.settings.selectorInert);
919
- setOverflowHidden(false, this.settings.selectorOverflow);
920
- await closeTransition(modal, this.settings);
941
+ const config = getModalConfig.call(this, modal);
942
+ setInert(false, config.selectorInert);
943
+ setOverflowHidden(false, config.selectorOverflow);
944
+ await closeTransition(modal, config);
921
945
  if (returnFocus) focusTrigger(this);
922
946
  this.focusTrap.destroy();
923
- modal.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'closed', {
947
+ modal.dispatchEvent(new CustomEvent(config.customEventPrefix + 'closed', {
924
948
  detail: this,
925
949
  bubbles: true
926
950
  }));
@@ -973,18 +997,6 @@ function handlerKeydown$1(event) {
973
997
  }
974
998
  }
975
999
 
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
1000
  function setInitialState() {
989
1001
  const modals = document.querySelectorAll(`[data-${this.settings.dataModal}]`);
990
1002
  modals.forEach(el => {
@@ -1005,15 +1017,16 @@ function setInitialState() {
1005
1017
  async function open$1(modalKey) {
1006
1018
  const modal = getModal.call(this, modalKey);
1007
1019
  if (!modal) return modalNotFound(modalKey);
1020
+ const config = getModalConfig.call(this, modal);
1008
1021
 
1009
- if (hasClass(modal, this.settings.stateClosed)) {
1022
+ if (hasClass(modal, config.stateClosed)) {
1010
1023
  this.working = true;
1011
- setOverflowHidden(true, this.settings.selectorOverflow);
1012
- await openTransition(modal, this.settings);
1024
+ setOverflowHidden(true, config.selectorOverflow);
1025
+ await openTransition(modal, config);
1013
1026
  this.focusTrap.init(modal);
1014
- focusTarget(modal, this.settings);
1015
- setInert(true, this.settings.selectorInert);
1016
- modal.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'opened', {
1027
+ focusTarget(modal, config);
1028
+ setInert(true, config.selectorInert);
1029
+ modal.dispatchEvent(new CustomEvent(config.customEventPrefix + 'opened', {
1017
1030
  detail: this,
1018
1031
  bubbles: true
1019
1032
  }));