vrembem 3.0.6 → 3.0.9

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.
@@ -18,7 +18,7 @@ function _createClass(Constructor, protoProps, staticProps) {
18
18
  }
19
19
 
20
20
  function _extends() {
21
- _extends = Object.assign || function (target) {
21
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
22
22
  for (var i = 1; i < arguments.length; i++) {
23
23
  var source = arguments[i];
24
24
 
@@ -31,7 +31,6 @@ function _extends() {
31
31
 
32
32
  return target;
33
33
  };
34
-
35
34
  return _extends.apply(this, arguments);
36
35
  }
37
36
 
@@ -43,11 +42,10 @@ function _inheritsLoose(subClass, superClass) {
43
42
  }
44
43
 
45
44
  function _setPrototypeOf(o, p) {
46
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
45
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
47
46
  o.__proto__ = p;
48
47
  return o;
49
48
  };
50
-
51
49
  return _setPrototypeOf(o, p);
52
50
  }
53
51
 
@@ -429,7 +427,20 @@ var Collection = /*#__PURE__*/function () {
429
427
  return Collection;
430
428
  }();
431
429
 
432
- var focusableSelectors = ['a[href]:not([tabindex^="-"])', 'area[href]:not([tabindex^="-"])', 'input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])', 'input[type="radio"]:not([disabled]):not([tabindex^="-"])', 'select:not([disabled]):not([tabindex^="-"])', 'textarea:not([disabled]):not([tabindex^="-"])', 'button:not([disabled]):not([tabindex^="-"])', 'iframe:not([tabindex^="-"])', 'audio[controls]:not([tabindex^="-"])', 'video[controls]:not([tabindex^="-"])', '[contenteditable]:not([tabindex^="-"])', '[tabindex]:not([tabindex^="-"])'];
430
+ var focusableSelectors = [
431
+ 'a[href]:not([tabindex^="-"])',
432
+ 'area[href]:not([tabindex^="-"])',
433
+ 'input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])',
434
+ 'input[type="radio"]:not([disabled]):not([tabindex^="-"])',
435
+ 'select:not([disabled]):not([tabindex^="-"])',
436
+ 'textarea:not([disabled]):not([tabindex^="-"])',
437
+ 'button:not([disabled]):not([tabindex^="-"])',
438
+ 'iframe:not([tabindex^="-"])',
439
+ 'audio[controls]:not([tabindex^="-"])',
440
+ 'video[controls]:not([tabindex^="-"])',
441
+ '[contenteditable]:not([tabindex^="-"])',
442
+ '[tabindex]:not([tabindex^="-"])',
443
+ ];
433
444
 
434
445
  var _focusable = /*#__PURE__*/_classPrivateFieldLooseKey("focusable");
435
446
 
@@ -606,29 +617,23 @@ function localStore(key, enable) {
606
617
  enable = true;
607
618
  }
608
619
 
609
- function getStore() {
610
- var value = localStorage.getItem(key);
611
- return value ? JSON.parse(value) : {};
612
- }
613
-
614
- function setStore(obj) {
615
- localStorage.setItem(key, JSON.stringify(obj));
616
- }
617
-
618
- return new Proxy(getStore(), {
619
- set: function set(target, property, value) {
620
- console.log('localStore() => set');
621
-
622
- if (value === undefined) {
623
- delete target[property];
620
+ var local = localStorage.getItem(key);
621
+ var store = local ? JSON.parse(local) : {};
622
+ return {
623
+ get: function get(prop) {
624
+ return prop ? store[prop] : store;
625
+ },
626
+ set: function set(prop, value) {
627
+ if (value) {
628
+ store[prop] = value;
624
629
  } else {
625
- target[property] = value;
630
+ delete store[prop];
626
631
  }
627
632
 
628
- if (enable) setStore(target);
629
- return true;
633
+ if (enable) localStorage.setItem(key, JSON.stringify(store));
634
+ return store;
630
635
  }
631
- });
636
+ };
632
637
  }
633
638
 
634
639
  /**
@@ -968,7 +973,8 @@ var deregister$2 = function deregister(obj, close) {
968
973
  if (index >= 0) {
969
974
  var _temp7 = function _temp7() {
970
975
  // Remove entry from local store.
971
- _this2.store[_entry.id] = undefined; // Unmount the MatchMedia functionality.
976
+ _this2.store.set(_entry.id); // Unmount the MatchMedia functionality.
977
+
972
978
 
973
979
  _entry.unmountBreakpoint(); // Delete properties from collection entry.
974
980
 
@@ -1089,9 +1095,9 @@ var initialState = function initialState(entry) {
1089
1095
  var _this2 = this;
1090
1096
 
1091
1097
  var _temp3 = function () {
1092
- if (_this2.store[entry.id]) {
1098
+ if (_this2.store.get(entry.id)) {
1093
1099
  var _temp4 = function () {
1094
- if (_this2.store[entry.id] === 'opened') {
1100
+ if (_this2.store.get(entry.id) === 'opened') {
1095
1101
  return Promise.resolve(entry.open(false, false)).then(function () {});
1096
1102
  } else {
1097
1103
  return Promise.resolve(entry.close(false, false)).then(function () {});
@@ -1270,9 +1276,9 @@ var toModal = function toModal(entry) {
1270
1276
 
1271
1277
  entry.dialog.setAttribute('aria-modal', 'true'); // If there isn't a stored state but also has the opened state class...
1272
1278
 
1273
- if (!_this4.store[entry.id] && entry.el.classList.contains(entry.getSetting('stateOpened'))) {
1279
+ if (!_this4.store.get(entry.id) && entry.el.classList.contains(entry.getSetting('stateOpened'))) {
1274
1280
  // Save the opened state in local store.
1275
- _this4.store[entry.id] = 'opened';
1281
+ _this4.store.set(entry.id, 'opened');
1276
1282
  } // Modal drawer defaults to closed state.
1277
1283
 
1278
1284
 
@@ -1393,7 +1399,7 @@ var register$2 = function register(el, dialog) {
1393
1399
  __state = value; // Save 'opened' and 'closed' states to store if mode is inline.
1394
1400
 
1395
1401
  if (value === 'opened' || value === 'closed') {
1396
- if (this.mode === 'inline') root.store[this.id] = this.state;
1402
+ if (this.mode === 'inline') root.store.set(this.id, this.state);
1397
1403
  }
1398
1404
  },
1399
1405
 
@@ -1686,14 +1692,6 @@ function updateFocusState() {
1686
1692
  }
1687
1693
  }
1688
1694
 
1689
- function updateStackIndex(stack) {
1690
- stack.forEach(function (entry, index) {
1691
- entry.el.style.zIndex = null;
1692
- var value = getComputedStyle(entry.el)['z-index'];
1693
- entry.el.style.zIndex = parseInt(value) + index + 1;
1694
- });
1695
- }
1696
-
1697
1695
  var handleClick$1 = function handleClick(event) {
1698
1696
  try {
1699
1697
  var _this2 = this;
@@ -1787,15 +1785,8 @@ var deregister$1 = function deregister(obj, close) {
1787
1785
  if (close && _entry.state === 'opened') {
1788
1786
  return Promise.resolve(_entry.close(false)).then(function () {});
1789
1787
  } else {
1790
- // Get index of modal in stack array.
1791
- var stackIndex = _this2.stack.findIndex(function (item) {
1792
- return item.id === _entry.id;
1793
- }); // Remove modal from stack array.
1794
-
1795
-
1796
- if (stackIndex >= 0) {
1797
- _this2.stack.splice(stackIndex, 1);
1798
- }
1788
+ // Remove modal from stack.
1789
+ _this2.stack.remove(_entry);
1799
1790
  }
1800
1791
  }();
1801
1792
 
@@ -1838,32 +1829,17 @@ var open$1 = function open(query, transition, focus) {
1838
1829
  var config = _extends({}, _this2.settings, modal.settings); // Add transition parameter to configuration.
1839
1830
 
1840
1831
 
1841
- if (transition !== undefined) config.transition = transition; // Check if modal is already in the stack.
1842
-
1843
- var index = _this2.stack.findIndex(function (entry) {
1844
- return entry.id === modal.id;
1845
- }); // If modal is already open.
1846
-
1847
-
1848
- if (index >= 0) {
1849
- // Remove modal from stack array.
1850
- _this2.stack.splice(index, 1); // Move back to end of stack.
1832
+ if (transition !== undefined) config.transition = transition; // Maybe add modal to top of stack.
1851
1833
 
1852
-
1853
- _this2.stack.push(modal);
1854
- } // If modal is closed.
1834
+ _this2.stack.moveToTop(modal); // If modal is closed.
1855
1835
 
1856
1836
 
1857
1837
  var _temp4 = function () {
1858
1838
  if (modal.state === 'closed') {
1859
1839
  // Update modal state.
1860
- modal.state = 'opening'; // Apply z-index styles based on stack length.
1861
-
1862
- modal.el.style.zIndex = null;
1863
- var value = getComputedStyle(modal.el)['z-index'];
1864
- modal.el.style.zIndex = parseInt(value) + _this2.stack.length + 1; // Store modal in stack array.
1840
+ modal.state = 'opening'; // Add modal to stack.
1865
1841
 
1866
- _this2.stack.push(modal); // Run the open transition.
1842
+ _this2.stack.add(modal); // Run the open transition.
1867
1843
 
1868
1844
 
1869
1845
  return Promise.resolve(openTransition(modal.el, config)).then(function () {
@@ -1903,15 +1879,8 @@ var close$1 = function close(query, transition, focus) {
1903
1879
  document.activeElement.blur(); // Run the close transition.
1904
1880
 
1905
1881
  return Promise.resolve(closeTransition(modal.el, config)).then(function () {
1906
- // Remove z-index styles.
1907
- modal.el.style.zIndex = null; // Get index of modal in stack array.
1908
-
1909
- var index = _this2.stack.findIndex(function (entry) {
1910
- return entry.id === modal.id;
1911
- }); // Remove modal from stack array.
1912
-
1913
-
1914
- _this2.stack.splice(index, 1); // Update focus if the focus param is true.
1882
+ // Remove modal from stack.
1883
+ _this2.stack.remove(modal); // Update focus if the focus param is true.
1915
1884
 
1916
1885
 
1917
1886
  if (focus) {
@@ -1943,7 +1912,7 @@ var closeAll$1 = function closeAll(exclude, transition) {
1943
1912
  var _this2 = this;
1944
1913
 
1945
1914
  var result = [];
1946
- return Promise.resolve(Promise.all(_this2.stack.map(function (modal) {
1915
+ return Promise.resolve(Promise.all(_this2.stack.value.map(function (modal) {
1947
1916
  try {
1948
1917
  var _temp3 = function _temp3() {
1949
1918
  modal.trigger = null;
@@ -2125,6 +2094,70 @@ var register$1 = function register(el, dialog) {
2125
2094
  }
2126
2095
  };
2127
2096
 
2097
+ function stack(settings) {
2098
+ var stackArray = [];
2099
+ return {
2100
+ get value() {
2101
+ return [].concat(stackArray);
2102
+ },
2103
+
2104
+ get top() {
2105
+ return stackArray[stackArray.length - 1];
2106
+ },
2107
+
2108
+ updateIndex: function updateIndex() {
2109
+ stackArray.forEach(function (entry, index) {
2110
+ entry.el.style.zIndex = null;
2111
+ var value = getComputedStyle(entry.el)['z-index'];
2112
+ entry.el.style.zIndex = parseInt(value) + index + 1;
2113
+ });
2114
+ },
2115
+ updateGlobalState: function updateGlobalState$1() {
2116
+ updateGlobalState(this.top, settings);
2117
+
2118
+ this.updateIndex();
2119
+ },
2120
+ add: function add(entry) {
2121
+ // Apply z-index styles based on stack length.
2122
+ entry.el.style.zIndex = null;
2123
+ var value = getComputedStyle(entry.el)['z-index'];
2124
+ entry.el.style.zIndex = parseInt(value) + stackArray.length + 1; // Move back to end of stack.
2125
+
2126
+ stackArray.push(entry); // Update the global state.
2127
+
2128
+ this.updateGlobalState();
2129
+ },
2130
+ remove: function remove(entry) {
2131
+ // Get the index of the entry.
2132
+ var index = stackArray.findIndex(function (item) {
2133
+ return item.id === entry.id;
2134
+ }); // If entry is in stack...
2135
+
2136
+ if (index >= 0) {
2137
+ // Remove z-index styles.
2138
+ entry.el.style.zIndex = null; // Remove entry from stack array.
2139
+
2140
+ stackArray.splice(index, 1); // Update the global state.
2141
+
2142
+ this.updateGlobalState();
2143
+ }
2144
+ },
2145
+ moveToTop: function moveToTop(entry) {
2146
+ // Get the index of the entry.
2147
+ var index = stackArray.findIndex(function (item) {
2148
+ return item.id === entry.id;
2149
+ }); // If entry is in stack...
2150
+
2151
+ if (index >= 0) {
2152
+ // Remove entry from stack array.
2153
+ stackArray.splice(index, 1); // Add entry back to top of stack.
2154
+
2155
+ this.add(entry);
2156
+ }
2157
+ }
2158
+ };
2159
+ }
2160
+
2128
2161
  var _handleClick = /*#__PURE__*/_classPrivateFieldLooseKey("handleClick");
2129
2162
 
2130
2163
  var _handleKeydown$1 = /*#__PURE__*/_classPrivateFieldLooseKey("handleKeydown");
@@ -2147,20 +2180,9 @@ var Modal = /*#__PURE__*/function (_Collection) {
2147
2180
  _this.defaults = defaults$1;
2148
2181
  _this.settings = _extends({}, _this.defaults, options);
2149
2182
  _this.trigger = null;
2150
- _this.focusTrap = new FocusTrap(); // Setup a proxy for stack array.
2151
-
2152
- _this.stack = new Proxy([], {
2153
- set: function set(target, property, value) {
2154
- target[property] = value; // Update global state if stack length changed.
2183
+ _this.focusTrap = new FocusTrap(); // Setup stack module.
2155
2184
 
2156
- if (property === 'length') {
2157
- updateGlobalState(_this.active, _this.settings);
2158
- updateStackIndex(_this.stack);
2159
- }
2160
-
2161
- return true;
2162
- }
2163
- });
2185
+ _this.stack = stack(_this.settings);
2164
2186
  _classPrivateFieldLooseBase(_assertThisInitialized(_this), _handleClick)[_handleClick] = handleClick$1.bind(_assertThisInitialized(_this));
2165
2187
  _classPrivateFieldLooseBase(_assertThisInitialized(_this), _handleKeydown$1)[_handleKeydown$1] = handleKeydown$1.bind(_assertThisInitialized(_this));
2166
2188
  if (_this.settings.autoInit) _this.init();
@@ -2274,7 +2296,7 @@ var Modal = /*#__PURE__*/function (_Collection) {
2274
2296
  _createClass(Modal, [{
2275
2297
  key: "active",
2276
2298
  get: function get() {
2277
- return this.stack[this.stack.length - 1];
2299
+ return this.stack.top;
2278
2300
  }
2279
2301
  }]);
2280
2302
 
@@ -2830,17 +2852,17 @@ function contains(parent, child) {
2830
2852
  return true;
2831
2853
  } // then fallback to custom implementation with Shadow DOM support
2832
2854
  else if (rootNode && isShadowRoot(rootNode)) {
2833
- var next = child;
2855
+ var next = child;
2834
2856
 
2835
- do {
2836
- if (next && parent.isSameNode(next)) {
2837
- return true;
2838
- } // $FlowFixMe[prop-missing]: need a better way to handle this...
2857
+ do {
2858
+ if (next && parent.isSameNode(next)) {
2859
+ return true;
2860
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
2839
2861
 
2840
2862
 
2841
- next = next.parentNode || next.host;
2842
- } while (next);
2843
- } // Give up, the result is false
2863
+ next = next.parentNode || next.host;
2864
+ } while (next);
2865
+ } // Give up, the result is false
2844
2866
 
2845
2867
 
2846
2868
  return false;
@@ -3897,11 +3919,11 @@ var offset$1 = {
3897
3919
 
3898
3920
  function popperOffsets(_ref) {
3899
3921
  var state = _ref.state,
3900
- name = _ref.name; // Offsets are the actual position the popper needs to have to be
3922
+ name = _ref.name;
3923
+ // Offsets are the actual position the popper needs to have to be
3901
3924
  // properly positioned near its reference element
3902
3925
  // This is the most basic placement, and will be adjusted by
3903
3926
  // the modifiers in the next step
3904
-
3905
3927
  state.modifiersData[name] = computeOffsets({
3906
3928
  reference: state.rects.reference,
3907
3929
  element: state.rects.popper,