vrembem 3.0.5 → 3.0.8
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 +101 -88
- package/dev/scripts.esm.js.map +1 -1
- package/dev/scripts.js +101 -88
- package/dev/scripts.js.map +1 -1
- package/dev/scripts.modern.js +105 -84
- package/dev/scripts.modern.js.map +1 -1
- package/dev/scripts.umd.js +101 -88
- package/dev/scripts.umd.js.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/package.json +26 -26
package/dev/scripts.esm.js
CHANGED
|
@@ -606,27 +606,23 @@ function localStore(key, enable) {
|
|
|
606
606
|
enable = true;
|
|
607
607
|
}
|
|
608
608
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
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
|
-
target[property] = value;
|
|
621
|
-
if (enable) setStore(target);
|
|
622
|
-
return true;
|
|
609
|
+
var local = localStorage.getItem(key);
|
|
610
|
+
var store = local ? JSON.parse(local) : {};
|
|
611
|
+
return {
|
|
612
|
+
get: function get(prop) {
|
|
613
|
+
return prop ? store[prop] : store;
|
|
623
614
|
},
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
615
|
+
set: function set(prop, value) {
|
|
616
|
+
if (value) {
|
|
617
|
+
store[prop] = value;
|
|
618
|
+
} else {
|
|
619
|
+
delete store[prop];
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (enable) localStorage.setItem(key, JSON.stringify(store));
|
|
623
|
+
return store;
|
|
628
624
|
}
|
|
629
|
-
}
|
|
625
|
+
};
|
|
630
626
|
}
|
|
631
627
|
|
|
632
628
|
/**
|
|
@@ -966,7 +962,8 @@ var deregister$2 = function deregister(obj, close) {
|
|
|
966
962
|
if (index >= 0) {
|
|
967
963
|
var _temp7 = function _temp7() {
|
|
968
964
|
// Remove entry from local store.
|
|
969
|
-
|
|
965
|
+
_this2.store.set(_entry.id); // Unmount the MatchMedia functionality.
|
|
966
|
+
|
|
970
967
|
|
|
971
968
|
_entry.unmountBreakpoint(); // Delete properties from collection entry.
|
|
972
969
|
|
|
@@ -998,12 +995,12 @@ var deregister$2 = function deregister(obj, close) {
|
|
|
998
995
|
}
|
|
999
996
|
};
|
|
1000
997
|
|
|
1001
|
-
function
|
|
998
|
+
function g() {
|
|
1002
999
|
return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim();
|
|
1003
1000
|
}
|
|
1004
1001
|
|
|
1005
1002
|
function getBreakpoint(drawer) {
|
|
1006
|
-
var prefix =
|
|
1003
|
+
var prefix = g();
|
|
1007
1004
|
var bp = drawer.getAttribute("data-" + this.settings.dataBreakpoint);
|
|
1008
1005
|
|
|
1009
1006
|
if (this.settings.breakpoints && this.settings.breakpoints[bp]) {
|
|
@@ -1087,9 +1084,9 @@ var initialState = function initialState(entry) {
|
|
|
1087
1084
|
var _this2 = this;
|
|
1088
1085
|
|
|
1089
1086
|
var _temp3 = function () {
|
|
1090
|
-
if (_this2.store
|
|
1087
|
+
if (_this2.store.get(entry.id)) {
|
|
1091
1088
|
var _temp4 = function () {
|
|
1092
|
-
if (_this2.store
|
|
1089
|
+
if (_this2.store.get(entry.id) === 'opened') {
|
|
1093
1090
|
return Promise.resolve(entry.open(false, false)).then(function () {});
|
|
1094
1091
|
} else {
|
|
1095
1092
|
return Promise.resolve(entry.close(false, false)).then(function () {});
|
|
@@ -1268,9 +1265,9 @@ var toModal = function toModal(entry) {
|
|
|
1268
1265
|
|
|
1269
1266
|
entry.dialog.setAttribute('aria-modal', 'true'); // If there isn't a stored state but also has the opened state class...
|
|
1270
1267
|
|
|
1271
|
-
if (!_this4.store
|
|
1268
|
+
if (!_this4.store.get(entry.id) && entry.el.classList.contains(entry.getSetting('stateOpened'))) {
|
|
1272
1269
|
// Save the opened state in local store.
|
|
1273
|
-
_this4.store
|
|
1270
|
+
_this4.store.set(entry.id, 'opened');
|
|
1274
1271
|
} // Modal drawer defaults to closed state.
|
|
1275
1272
|
|
|
1276
1273
|
|
|
@@ -1391,7 +1388,7 @@ var register$2 = function register(el, dialog) {
|
|
|
1391
1388
|
__state = value; // Save 'opened' and 'closed' states to store if mode is inline.
|
|
1392
1389
|
|
|
1393
1390
|
if (value === 'opened' || value === 'closed') {
|
|
1394
|
-
if (this.mode === 'inline') root.store
|
|
1391
|
+
if (this.mode === 'inline') root.store.set(this.id, this.state);
|
|
1395
1392
|
}
|
|
1396
1393
|
},
|
|
1397
1394
|
|
|
@@ -1684,14 +1681,6 @@ function updateFocusState() {
|
|
|
1684
1681
|
}
|
|
1685
1682
|
}
|
|
1686
1683
|
|
|
1687
|
-
function updateStackIndex(stack) {
|
|
1688
|
-
stack.forEach(function (entry, index) {
|
|
1689
|
-
entry.el.style.zIndex = null;
|
|
1690
|
-
var value = getComputedStyle(entry.el)['z-index'];
|
|
1691
|
-
entry.el.style.zIndex = parseInt(value) + index + 1;
|
|
1692
|
-
});
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
1684
|
var handleClick$1 = function handleClick(event) {
|
|
1696
1685
|
try {
|
|
1697
1686
|
var _this2 = this;
|
|
@@ -1785,15 +1774,8 @@ var deregister$1 = function deregister(obj, close) {
|
|
|
1785
1774
|
if (close && _entry.state === 'opened') {
|
|
1786
1775
|
return Promise.resolve(_entry.close(false)).then(function () {});
|
|
1787
1776
|
} else {
|
|
1788
|
-
//
|
|
1789
|
-
|
|
1790
|
-
return item.id === _entry.id;
|
|
1791
|
-
}); // Remove modal from stack array.
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
if (stackIndex >= 0) {
|
|
1795
|
-
_this2.stack.splice(stackIndex, 1);
|
|
1796
|
-
}
|
|
1777
|
+
// Remove modal from stack.
|
|
1778
|
+
_this2.stack.remove(_entry);
|
|
1797
1779
|
}
|
|
1798
1780
|
}();
|
|
1799
1781
|
|
|
@@ -1836,32 +1818,17 @@ var open$1 = function open(query, transition, focus) {
|
|
|
1836
1818
|
var config = _extends({}, _this2.settings, modal.settings); // Add transition parameter to configuration.
|
|
1837
1819
|
|
|
1838
1820
|
|
|
1839
|
-
if (transition !== undefined) config.transition = transition; //
|
|
1840
|
-
|
|
1841
|
-
var index = _this2.stack.findIndex(function (entry) {
|
|
1842
|
-
return entry.id === modal.id;
|
|
1843
|
-
}); // If modal is already open.
|
|
1821
|
+
if (transition !== undefined) config.transition = transition; // Maybe add modal to top of stack.
|
|
1844
1822
|
|
|
1845
|
-
|
|
1846
|
-
if (index >= 0) {
|
|
1847
|
-
// Remove modal from stack array.
|
|
1848
|
-
_this2.stack.splice(index, 1); // Move back to end of stack.
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
_this2.stack.push(modal);
|
|
1852
|
-
} // If modal is closed.
|
|
1823
|
+
_this2.stack.moveToTop(modal); // If modal is closed.
|
|
1853
1824
|
|
|
1854
1825
|
|
|
1855
1826
|
var _temp4 = function () {
|
|
1856
1827
|
if (modal.state === 'closed') {
|
|
1857
1828
|
// Update modal state.
|
|
1858
|
-
modal.state = 'opening'; //
|
|
1859
|
-
|
|
1860
|
-
modal.el.style.zIndex = null;
|
|
1861
|
-
var value = getComputedStyle(modal.el)['z-index'];
|
|
1862
|
-
modal.el.style.zIndex = parseInt(value) + _this2.stack.length + 1; // Store modal in stack array.
|
|
1829
|
+
modal.state = 'opening'; // Add modal to stack.
|
|
1863
1830
|
|
|
1864
|
-
_this2.stack.
|
|
1831
|
+
_this2.stack.add(modal); // Run the open transition.
|
|
1865
1832
|
|
|
1866
1833
|
|
|
1867
1834
|
return Promise.resolve(openTransition(modal.el, config)).then(function () {
|
|
@@ -1901,15 +1868,8 @@ var close$1 = function close(query, transition, focus) {
|
|
|
1901
1868
|
document.activeElement.blur(); // Run the close transition.
|
|
1902
1869
|
|
|
1903
1870
|
return Promise.resolve(closeTransition(modal.el, config)).then(function () {
|
|
1904
|
-
// Remove
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
var index = _this2.stack.findIndex(function (entry) {
|
|
1908
|
-
return entry.id === modal.id;
|
|
1909
|
-
}); // Remove modal from stack array.
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
_this2.stack.splice(index, 1); // Update focus if the focus param is true.
|
|
1871
|
+
// Remove modal from stack.
|
|
1872
|
+
_this2.stack.remove(modal); // Update focus if the focus param is true.
|
|
1913
1873
|
|
|
1914
1874
|
|
|
1915
1875
|
if (focus) {
|
|
@@ -1941,7 +1901,7 @@ var closeAll$1 = function closeAll(exclude, transition) {
|
|
|
1941
1901
|
var _this2 = this;
|
|
1942
1902
|
|
|
1943
1903
|
var result = [];
|
|
1944
|
-
return Promise.resolve(Promise.all(_this2.stack.map(function (modal) {
|
|
1904
|
+
return Promise.resolve(Promise.all(_this2.stack.value.map(function (modal) {
|
|
1945
1905
|
try {
|
|
1946
1906
|
var _temp3 = function _temp3() {
|
|
1947
1907
|
modal.trigger = null;
|
|
@@ -2123,6 +2083,70 @@ var register$1 = function register(el, dialog) {
|
|
|
2123
2083
|
}
|
|
2124
2084
|
};
|
|
2125
2085
|
|
|
2086
|
+
function stack(settings) {
|
|
2087
|
+
var stackArray = [];
|
|
2088
|
+
return {
|
|
2089
|
+
get value() {
|
|
2090
|
+
return [].concat(stackArray);
|
|
2091
|
+
},
|
|
2092
|
+
|
|
2093
|
+
get top() {
|
|
2094
|
+
return stackArray[stackArray.length - 1];
|
|
2095
|
+
},
|
|
2096
|
+
|
|
2097
|
+
updateIndex: function updateIndex() {
|
|
2098
|
+
stackArray.forEach(function (entry, index) {
|
|
2099
|
+
entry.el.style.zIndex = null;
|
|
2100
|
+
var value = getComputedStyle(entry.el)['z-index'];
|
|
2101
|
+
entry.el.style.zIndex = parseInt(value) + index + 1;
|
|
2102
|
+
});
|
|
2103
|
+
},
|
|
2104
|
+
updateGlobalState: function updateGlobalState$1() {
|
|
2105
|
+
updateGlobalState(this.top, settings);
|
|
2106
|
+
|
|
2107
|
+
this.updateIndex();
|
|
2108
|
+
},
|
|
2109
|
+
add: function add(entry) {
|
|
2110
|
+
// Apply z-index styles based on stack length.
|
|
2111
|
+
entry.el.style.zIndex = null;
|
|
2112
|
+
var value = getComputedStyle(entry.el)['z-index'];
|
|
2113
|
+
entry.el.style.zIndex = parseInt(value) + stackArray.length + 1; // Move back to end of stack.
|
|
2114
|
+
|
|
2115
|
+
stackArray.push(entry); // Update the global state.
|
|
2116
|
+
|
|
2117
|
+
this.updateGlobalState();
|
|
2118
|
+
},
|
|
2119
|
+
remove: function remove(entry) {
|
|
2120
|
+
// Get the index of the entry.
|
|
2121
|
+
var index = stackArray.findIndex(function (item) {
|
|
2122
|
+
return item.id === entry.id;
|
|
2123
|
+
}); // If entry is in stack...
|
|
2124
|
+
|
|
2125
|
+
if (index >= 0) {
|
|
2126
|
+
// Remove z-index styles.
|
|
2127
|
+
entry.el.style.zIndex = null; // Remove entry from stack array.
|
|
2128
|
+
|
|
2129
|
+
stackArray.splice(index, 1); // Update the global state.
|
|
2130
|
+
|
|
2131
|
+
this.updateGlobalState();
|
|
2132
|
+
}
|
|
2133
|
+
},
|
|
2134
|
+
moveToTop: function moveToTop(entry) {
|
|
2135
|
+
// Get the index of the entry.
|
|
2136
|
+
var index = stackArray.findIndex(function (item) {
|
|
2137
|
+
return item.id === entry.id;
|
|
2138
|
+
}); // If entry is in stack...
|
|
2139
|
+
|
|
2140
|
+
if (index >= 0) {
|
|
2141
|
+
// Remove entry from stack array.
|
|
2142
|
+
stackArray.splice(index, 1); // Add entry back to top of stack.
|
|
2143
|
+
|
|
2144
|
+
this.add(entry);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2126
2150
|
var _handleClick = /*#__PURE__*/_classPrivateFieldLooseKey("handleClick");
|
|
2127
2151
|
|
|
2128
2152
|
var _handleKeydown$1 = /*#__PURE__*/_classPrivateFieldLooseKey("handleKeydown");
|
|
@@ -2145,20 +2169,9 @@ var Modal = /*#__PURE__*/function (_Collection) {
|
|
|
2145
2169
|
_this.defaults = defaults$1;
|
|
2146
2170
|
_this.settings = _extends({}, _this.defaults, options);
|
|
2147
2171
|
_this.trigger = null;
|
|
2148
|
-
_this.focusTrap = new FocusTrap(); // Setup
|
|
2149
|
-
|
|
2150
|
-
_this.stack = new Proxy([], {
|
|
2151
|
-
set: function set(target, property, value) {
|
|
2152
|
-
target[property] = value; // Update global state if stack length changed.
|
|
2153
|
-
|
|
2154
|
-
if (property === 'length') {
|
|
2155
|
-
updateGlobalState(_this.active, _this.settings);
|
|
2156
|
-
updateStackIndex(_this.stack);
|
|
2157
|
-
}
|
|
2172
|
+
_this.focusTrap = new FocusTrap(); // Setup stack module.
|
|
2158
2173
|
|
|
2159
|
-
|
|
2160
|
-
}
|
|
2161
|
-
});
|
|
2174
|
+
_this.stack = stack(_this.settings);
|
|
2162
2175
|
_classPrivateFieldLooseBase(_assertThisInitialized(_this), _handleClick)[_handleClick] = handleClick$1.bind(_assertThisInitialized(_this));
|
|
2163
2176
|
_classPrivateFieldLooseBase(_assertThisInitialized(_this), _handleKeydown$1)[_handleKeydown$1] = handleKeydown$1.bind(_assertThisInitialized(_this));
|
|
2164
2177
|
if (_this.settings.autoInit) _this.init();
|
|
@@ -2272,7 +2285,7 @@ var Modal = /*#__PURE__*/function (_Collection) {
|
|
|
2272
2285
|
_createClass(Modal, [{
|
|
2273
2286
|
key: "active",
|
|
2274
2287
|
get: function get() {
|
|
2275
|
-
return this.stack
|
|
2288
|
+
return this.stack.top;
|
|
2276
2289
|
}
|
|
2277
2290
|
}]);
|
|
2278
2291
|
|
|
@@ -2308,7 +2321,7 @@ function getConfig(el, settings) {
|
|
|
2308
2321
|
|
|
2309
2322
|
for (var prop in config) {
|
|
2310
2323
|
// Get the CSS variable property values.
|
|
2311
|
-
var prefix =
|
|
2324
|
+
var prefix = g();
|
|
2312
2325
|
var value = styles.getPropertyValue("--" + prefix + "popover-" + prop).trim(); // If a value was found, replace the default in config obj.
|
|
2313
2326
|
|
|
2314
2327
|
if (value) {
|