vrembem 1.36.0 → 1.39.0
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 +207 -88
- package/dev/scripts.esm.js.map +1 -1
- package/dev/scripts.js +207 -88
- package/dev/scripts.js.map +1 -1
- package/dev/scripts.modern.js +201 -84
- package/dev/scripts.modern.js.map +1 -1
- package/dev/scripts.umd.js +207 -88
- package/dev/scripts.umd.js.map +1 -1
- package/dev/styles.css +54 -203
- 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 +1 -1
- package/dist/styles.css.map +1 -1
- package/index.scss +0 -1
- package/package.json +26 -27
package/dev/scripts.esm.js
CHANGED
|
@@ -61,6 +61,8 @@ var camelCase = function camelCase(str) {
|
|
|
61
61
|
});
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
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^="-"])'];
|
|
65
|
+
|
|
64
66
|
var focusTarget = function focusTarget(target, settings) {
|
|
65
67
|
var innerFocus = target.querySelector("[data-" + settings.dataFocus + "]");
|
|
66
68
|
|
|
@@ -113,6 +115,28 @@ var FocusTrap = /*#__PURE__*/function () {
|
|
|
113
115
|
this.target = null;
|
|
114
116
|
};
|
|
115
117
|
|
|
118
|
+
_proto.refresh = function refresh() {
|
|
119
|
+
// Check if a target has been set
|
|
120
|
+
if (!this.target) return; // Remove existing events
|
|
121
|
+
|
|
122
|
+
this.target.removeEventListener('keydown', this.__handlerFocusTrap);
|
|
123
|
+
this.target.removeEventListener('keydown', this.handlerFocusLock); // Get the focusable elements
|
|
124
|
+
|
|
125
|
+
this.focusable = this.getFocusable(); // Setup the focus handlers based on focusable length
|
|
126
|
+
|
|
127
|
+
if (this.focusable.length) {
|
|
128
|
+
// If there are focusable elements, setup focus trap
|
|
129
|
+
this.focusableFirst = this.focusable[0];
|
|
130
|
+
this.focusableLast = this.focusable[this.focusable.length - 1];
|
|
131
|
+
this.target.addEventListener('keydown', this.__handlerFocusTrap);
|
|
132
|
+
} else {
|
|
133
|
+
// If there are no focusable elements, setup focus lock
|
|
134
|
+
this.focusableFirst = null;
|
|
135
|
+
this.focusableLast = null;
|
|
136
|
+
this.target.addEventListener('keydown', this.handlerFocusLock);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
116
140
|
_proto.handlerFocusTrap = function handlerFocusTrap(event) {
|
|
117
141
|
var isTab = event.key === 'Tab' || event.keyCode === 9;
|
|
118
142
|
if (!isTab) return;
|
|
@@ -139,7 +163,7 @@ var FocusTrap = /*#__PURE__*/function () {
|
|
|
139
163
|
var focusable = [];
|
|
140
164
|
var initFocus = document.activeElement;
|
|
141
165
|
var initScrollTop = this.inner ? this.inner.scrollTop : 0;
|
|
142
|
-
this.target.querySelectorAll('
|
|
166
|
+
this.target.querySelectorAll(focusableSelectors.join(',')).forEach(function (el) {
|
|
143
167
|
el.focus();
|
|
144
168
|
|
|
145
169
|
if (el === document.activeElement) {
|
|
@@ -327,14 +351,6 @@ var closeTransition = function closeTransition(el, settings) {
|
|
|
327
351
|
});
|
|
328
352
|
};
|
|
329
353
|
|
|
330
|
-
var breakpoints = {
|
|
331
|
-
xs: '480px',
|
|
332
|
-
sm: '620px',
|
|
333
|
-
md: '760px',
|
|
334
|
-
lg: '990px',
|
|
335
|
-
xl: '1380px'
|
|
336
|
-
};
|
|
337
|
-
|
|
338
354
|
var index = {
|
|
339
355
|
__proto__: null,
|
|
340
356
|
setInert: setInert,
|
|
@@ -352,8 +368,7 @@ var index = {
|
|
|
352
368
|
removeClass: removeClass,
|
|
353
369
|
toggleClass: toggleClass,
|
|
354
370
|
openTransition: openTransition,
|
|
355
|
-
closeTransition: closeTransition
|
|
356
|
-
breakpoints: breakpoints
|
|
371
|
+
closeTransition: closeTransition
|
|
357
372
|
};
|
|
358
373
|
|
|
359
374
|
function _extends() {
|
|
@@ -471,7 +486,7 @@ var defaults$2 = {
|
|
|
471
486
|
selectorInert: null,
|
|
472
487
|
selectorOverflow: null,
|
|
473
488
|
// Feature toggles
|
|
474
|
-
breakpoints:
|
|
489
|
+
breakpoints: null,
|
|
475
490
|
customEventPrefix: 'drawer:',
|
|
476
491
|
eventListeners: true,
|
|
477
492
|
stateSave: true,
|
|
@@ -533,6 +548,7 @@ var Breakpoint = /*#__PURE__*/function () {
|
|
|
533
548
|
function Breakpoint(parent) {
|
|
534
549
|
this.mediaQueryLists = [];
|
|
535
550
|
this.parent = parent;
|
|
551
|
+
this.prefix = this.getVariablePrefix();
|
|
536
552
|
this.__check = this.check.bind(this);
|
|
537
553
|
}
|
|
538
554
|
|
|
@@ -545,7 +561,9 @@ var Breakpoint = /*#__PURE__*/function () {
|
|
|
545
561
|
drawers.forEach(function (drawer) {
|
|
546
562
|
var id = drawer.getAttribute("data-" + _this.parent.settings.dataDrawer);
|
|
547
563
|
var key = drawer.getAttribute("data-" + _this.parent.settings.dataBreakpoint);
|
|
548
|
-
|
|
564
|
+
|
|
565
|
+
var bp = _this.getBreakpoint(key);
|
|
566
|
+
|
|
549
567
|
var mql = window.matchMedia('(min-width:' + bp + ')');
|
|
550
568
|
|
|
551
569
|
_this.match(mql, drawer);
|
|
@@ -601,6 +619,25 @@ var Breakpoint = /*#__PURE__*/function () {
|
|
|
601
619
|
}
|
|
602
620
|
};
|
|
603
621
|
|
|
622
|
+
_proto.getBreakpoint = function getBreakpoint(key) {
|
|
623
|
+
var breakpoint = key;
|
|
624
|
+
|
|
625
|
+
if (this.parent.settings.breakpoints && this.parent.settings.breakpoints[key]) {
|
|
626
|
+
breakpoint = this.parent.settings.breakpoints[key];
|
|
627
|
+
} else if (getComputedStyle(document.body).getPropertyValue(this.prefix + key)) {
|
|
628
|
+
breakpoint = getComputedStyle(document.body).getPropertyValue(this.prefix + key);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
return breakpoint;
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
_proto.getVariablePrefix = function getVariablePrefix() {
|
|
635
|
+
var prefix = '--';
|
|
636
|
+
prefix += getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix');
|
|
637
|
+
prefix += 'breakpoint-';
|
|
638
|
+
return prefix;
|
|
639
|
+
};
|
|
640
|
+
|
|
604
641
|
return Breakpoint;
|
|
605
642
|
}();
|
|
606
643
|
|
|
@@ -874,6 +911,7 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
874
911
|
|
|
875
912
|
focusTarget(drawer, _this4.settings);
|
|
876
913
|
drawer.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'opened', {
|
|
914
|
+
detail: _this4,
|
|
877
915
|
bubbles: true
|
|
878
916
|
}));
|
|
879
917
|
_this4.working = false;
|
|
@@ -912,6 +950,7 @@ var Drawer = /*#__PURE__*/function () {
|
|
|
912
950
|
_this6.focusTrap.destroy();
|
|
913
951
|
|
|
914
952
|
drawer.dispatchEvent(new CustomEvent(_this6.settings.customEventPrefix + 'closed', {
|
|
953
|
+
detail: _this6,
|
|
915
954
|
bubbles: true
|
|
916
955
|
}));
|
|
917
956
|
_this6.working = false;
|
|
@@ -958,10 +997,6 @@ var defaults$1 = {
|
|
|
958
997
|
|
|
959
998
|
var handlerClick$1 = function handlerClick(event) {
|
|
960
999
|
try {
|
|
961
|
-
var _exit2;
|
|
962
|
-
|
|
963
|
-
var _this2 = this;
|
|
964
|
-
|
|
965
1000
|
var _temp3 = function _temp3(_result) {
|
|
966
1001
|
if (_exit2) return _result;
|
|
967
1002
|
|
|
@@ -980,6 +1015,10 @@ var handlerClick$1 = function handlerClick(event) {
|
|
|
980
1015
|
}
|
|
981
1016
|
};
|
|
982
1017
|
|
|
1018
|
+
var _exit2;
|
|
1019
|
+
|
|
1020
|
+
var _this2 = this;
|
|
1021
|
+
|
|
983
1022
|
// Working catch
|
|
984
1023
|
if (_this2.working) return Promise.resolve(); // Trigger click
|
|
985
1024
|
|
|
@@ -1146,6 +1185,7 @@ var Modal = /*#__PURE__*/function () {
|
|
|
1146
1185
|
focusTarget(modal, _this2.settings);
|
|
1147
1186
|
setInert(true, _this2.settings.selectorInert);
|
|
1148
1187
|
modal.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'opened', {
|
|
1188
|
+
detail: _this2,
|
|
1149
1189
|
bubbles: true
|
|
1150
1190
|
}));
|
|
1151
1191
|
_this2.working = false;
|
|
@@ -1179,6 +1219,7 @@ var Modal = /*#__PURE__*/function () {
|
|
|
1179
1219
|
_this4.focusTrap.destroy();
|
|
1180
1220
|
|
|
1181
1221
|
modal.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'closed', {
|
|
1222
|
+
detail: _this4,
|
|
1182
1223
|
bubbles: true
|
|
1183
1224
|
}));
|
|
1184
1225
|
_this4.working = false;
|
|
@@ -1273,7 +1314,8 @@ function getConfig(el, settings) {
|
|
|
1273
1314
|
|
|
1274
1315
|
for (var prop in config) {
|
|
1275
1316
|
// Get the CSS variable property values
|
|
1276
|
-
var
|
|
1317
|
+
var prefix = getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix');
|
|
1318
|
+
var val = styles.getPropertyValue("--" + prefix + "popover-" + prop).trim(); // If a value was found, replace the default in config obj
|
|
1277
1319
|
|
|
1278
1320
|
if (val) {
|
|
1279
1321
|
config[prop] = val;
|
|
@@ -1594,17 +1636,42 @@ function getBasePlacement(placement) {
|
|
|
1594
1636
|
return placement.split('-')[0];
|
|
1595
1637
|
}
|
|
1596
1638
|
|
|
1597
|
-
|
|
1639
|
+
var max = Math.max;
|
|
1640
|
+
var min = Math.min;
|
|
1641
|
+
var round = Math.round;
|
|
1642
|
+
|
|
1643
|
+
function getBoundingClientRect(element, includeScale) {
|
|
1644
|
+
if (includeScale === void 0) {
|
|
1645
|
+
includeScale = false;
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1598
1648
|
var rect = element.getBoundingClientRect();
|
|
1649
|
+
var scaleX = 1;
|
|
1650
|
+
var scaleY = 1;
|
|
1651
|
+
|
|
1652
|
+
if (isHTMLElement(element) && includeScale) {
|
|
1653
|
+
var offsetHeight = element.offsetHeight;
|
|
1654
|
+
var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
|
|
1655
|
+
// Fallback to 1 in case both values are `0`
|
|
1656
|
+
|
|
1657
|
+
if (offsetWidth > 0) {
|
|
1658
|
+
scaleX = round(rect.width) / offsetWidth || 1;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
if (offsetHeight > 0) {
|
|
1662
|
+
scaleY = round(rect.height) / offsetHeight || 1;
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1599
1666
|
return {
|
|
1600
|
-
width: rect.width,
|
|
1601
|
-
height: rect.height,
|
|
1602
|
-
top: rect.top,
|
|
1603
|
-
right: rect.right,
|
|
1604
|
-
bottom: rect.bottom,
|
|
1605
|
-
left: rect.left,
|
|
1606
|
-
x: rect.left,
|
|
1607
|
-
y: rect.top
|
|
1667
|
+
width: rect.width / scaleX,
|
|
1668
|
+
height: rect.height / scaleY,
|
|
1669
|
+
top: rect.top / scaleY,
|
|
1670
|
+
right: rect.right / scaleX,
|
|
1671
|
+
bottom: rect.bottom / scaleY,
|
|
1672
|
+
left: rect.left / scaleX,
|
|
1673
|
+
x: rect.left / scaleX,
|
|
1674
|
+
y: rect.top / scaleY
|
|
1608
1675
|
};
|
|
1609
1676
|
}
|
|
1610
1677
|
|
|
@@ -1749,13 +1816,13 @@ function getMainAxisFromPlacement(placement) {
|
|
|
1749
1816
|
return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
|
|
1750
1817
|
}
|
|
1751
1818
|
|
|
1752
|
-
var max = Math.max;
|
|
1753
|
-
var min = Math.min;
|
|
1754
|
-
var round = Math.round;
|
|
1755
|
-
|
|
1756
1819
|
function within(min$1, value, max$1) {
|
|
1757
1820
|
return max(min$1, min(value, max$1));
|
|
1758
1821
|
}
|
|
1822
|
+
function withinMaxClamp(min, value, max) {
|
|
1823
|
+
var v = within(min, value, max);
|
|
1824
|
+
return v > max ? max : v;
|
|
1825
|
+
}
|
|
1759
1826
|
|
|
1760
1827
|
function getFreshSideObject() {
|
|
1761
1828
|
return {
|
|
@@ -1859,6 +1926,10 @@ var arrow$1 = {
|
|
|
1859
1926
|
requiresIfExists: ['preventOverflow']
|
|
1860
1927
|
};
|
|
1861
1928
|
|
|
1929
|
+
function getVariation(placement) {
|
|
1930
|
+
return placement.split('-')[1];
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1862
1933
|
var unsetSides = {
|
|
1863
1934
|
top: 'auto',
|
|
1864
1935
|
right: 'auto',
|
|
@@ -1874,8 +1945,8 @@ function roundOffsetsByDPR(_ref) {
|
|
|
1874
1945
|
var win = window;
|
|
1875
1946
|
var dpr = win.devicePixelRatio || 1;
|
|
1876
1947
|
return {
|
|
1877
|
-
x: round(
|
|
1878
|
-
y: round(
|
|
1948
|
+
x: round(x * dpr) / dpr || 0,
|
|
1949
|
+
y: round(y * dpr) / dpr || 0
|
|
1879
1950
|
};
|
|
1880
1951
|
}
|
|
1881
1952
|
|
|
@@ -1885,18 +1956,28 @@ function mapToStyles(_ref2) {
|
|
|
1885
1956
|
var popper = _ref2.popper,
|
|
1886
1957
|
popperRect = _ref2.popperRect,
|
|
1887
1958
|
placement = _ref2.placement,
|
|
1959
|
+
variation = _ref2.variation,
|
|
1888
1960
|
offsets = _ref2.offsets,
|
|
1889
1961
|
position = _ref2.position,
|
|
1890
1962
|
gpuAcceleration = _ref2.gpuAcceleration,
|
|
1891
1963
|
adaptive = _ref2.adaptive,
|
|
1892
|
-
roundOffsets = _ref2.roundOffsets
|
|
1893
|
-
|
|
1894
|
-
var
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1964
|
+
roundOffsets = _ref2.roundOffsets,
|
|
1965
|
+
isFixed = _ref2.isFixed;
|
|
1966
|
+
var _offsets$x = offsets.x,
|
|
1967
|
+
x = _offsets$x === void 0 ? 0 : _offsets$x,
|
|
1968
|
+
_offsets$y = offsets.y,
|
|
1969
|
+
y = _offsets$y === void 0 ? 0 : _offsets$y;
|
|
1970
|
+
|
|
1971
|
+
var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
|
|
1972
|
+
x: x,
|
|
1973
|
+
y: y
|
|
1974
|
+
}) : {
|
|
1975
|
+
x: x,
|
|
1976
|
+
y: y
|
|
1977
|
+
};
|
|
1899
1978
|
|
|
1979
|
+
x = _ref3.x;
|
|
1980
|
+
y = _ref3.y;
|
|
1900
1981
|
var hasX = offsets.hasOwnProperty('x');
|
|
1901
1982
|
var hasY = offsets.hasOwnProperty('y');
|
|
1902
1983
|
var sideX = left;
|
|
@@ -1911,7 +1992,7 @@ function mapToStyles(_ref2) {
|
|
|
1911
1992
|
if (offsetParent === getWindow(popper)) {
|
|
1912
1993
|
offsetParent = getDocumentElement(popper);
|
|
1913
1994
|
|
|
1914
|
-
if (getComputedStyle$1(offsetParent).position !== 'static') {
|
|
1995
|
+
if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
|
|
1915
1996
|
heightProp = 'scrollHeight';
|
|
1916
1997
|
widthProp = 'scrollWidth';
|
|
1917
1998
|
}
|
|
@@ -1920,17 +2001,19 @@ function mapToStyles(_ref2) {
|
|
|
1920
2001
|
|
|
1921
2002
|
offsetParent = offsetParent;
|
|
1922
2003
|
|
|
1923
|
-
if (placement === top) {
|
|
1924
|
-
sideY = bottom;
|
|
1925
|
-
|
|
1926
|
-
|
|
2004
|
+
if (placement === top || (placement === left || placement === right) && variation === end) {
|
|
2005
|
+
sideY = bottom;
|
|
2006
|
+
var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
|
|
2007
|
+
offsetParent[heightProp];
|
|
2008
|
+
y -= offsetY - popperRect.height;
|
|
1927
2009
|
y *= gpuAcceleration ? 1 : -1;
|
|
1928
2010
|
}
|
|
1929
2011
|
|
|
1930
|
-
if (placement === left) {
|
|
1931
|
-
sideX = right;
|
|
1932
|
-
|
|
1933
|
-
|
|
2012
|
+
if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
|
2013
|
+
sideX = right;
|
|
2014
|
+
var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
|
|
2015
|
+
offsetParent[widthProp];
|
|
2016
|
+
x -= offsetX - popperRect.width;
|
|
1934
2017
|
x *= gpuAcceleration ? 1 : -1;
|
|
1935
2018
|
}
|
|
1936
2019
|
}
|
|
@@ -1939,18 +2022,29 @@ function mapToStyles(_ref2) {
|
|
|
1939
2022
|
position: position
|
|
1940
2023
|
}, adaptive && unsetSides);
|
|
1941
2024
|
|
|
2025
|
+
var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
|
2026
|
+
x: x,
|
|
2027
|
+
y: y
|
|
2028
|
+
}) : {
|
|
2029
|
+
x: x,
|
|
2030
|
+
y: y
|
|
2031
|
+
};
|
|
2032
|
+
|
|
2033
|
+
x = _ref4.x;
|
|
2034
|
+
y = _ref4.y;
|
|
2035
|
+
|
|
1942
2036
|
if (gpuAcceleration) {
|
|
1943
2037
|
var _Object$assign;
|
|
1944
2038
|
|
|
1945
|
-
return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1)
|
|
2039
|
+
return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
|
1946
2040
|
}
|
|
1947
2041
|
|
|
1948
2042
|
return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
|
|
1949
2043
|
}
|
|
1950
2044
|
|
|
1951
|
-
function computeStyles(
|
|
1952
|
-
var state =
|
|
1953
|
-
options =
|
|
2045
|
+
function computeStyles(_ref5) {
|
|
2046
|
+
var state = _ref5.state,
|
|
2047
|
+
options = _ref5.options;
|
|
1954
2048
|
var _options$gpuAccelerat = options.gpuAcceleration,
|
|
1955
2049
|
gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
|
|
1956
2050
|
_options$adaptive = options.adaptive,
|
|
@@ -1960,9 +2054,11 @@ function computeStyles(_ref4) {
|
|
|
1960
2054
|
|
|
1961
2055
|
var commonStyles = {
|
|
1962
2056
|
placement: getBasePlacement(state.placement),
|
|
2057
|
+
variation: getVariation(state.placement),
|
|
1963
2058
|
popper: state.elements.popper,
|
|
1964
2059
|
popperRect: state.rects.popper,
|
|
1965
|
-
gpuAcceleration: gpuAcceleration
|
|
2060
|
+
gpuAcceleration: gpuAcceleration,
|
|
2061
|
+
isFixed: state.options.strategy === 'fixed'
|
|
1966
2062
|
};
|
|
1967
2063
|
|
|
1968
2064
|
if (state.modifiersData.popperOffsets != null) {
|
|
@@ -2220,7 +2316,7 @@ function getInnerBoundingClientRect(element) {
|
|
|
2220
2316
|
}
|
|
2221
2317
|
|
|
2222
2318
|
function getClientRectFromMixedType(element, clippingParent) {
|
|
2223
|
-
return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) :
|
|
2319
|
+
return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
2224
2320
|
} // A "clipping parent" is an overflowable container with the characteristic of
|
|
2225
2321
|
// clipping (or hiding) overflowing elements with a position different from
|
|
2226
2322
|
// `initial`
|
|
@@ -2262,10 +2358,6 @@ function getClippingRect(element, boundary, rootBoundary) {
|
|
|
2262
2358
|
return clippingRect;
|
|
2263
2359
|
}
|
|
2264
2360
|
|
|
2265
|
-
function getVariation(placement) {
|
|
2266
|
-
return placement.split('-')[1];
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
2361
|
function computeOffsets(_ref) {
|
|
2270
2362
|
var reference = _ref.reference,
|
|
2271
2363
|
element = _ref.element,
|
|
@@ -2351,11 +2443,10 @@ function detectOverflow(state, options) {
|
|
|
2351
2443
|
padding = _options$padding === void 0 ? 0 : _options$padding;
|
|
2352
2444
|
var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
|
2353
2445
|
var altContext = elementContext === popper ? reference : popper;
|
|
2354
|
-
var referenceElement = state.elements.reference;
|
|
2355
2446
|
var popperRect = state.rects.popper;
|
|
2356
2447
|
var element = state.elements[altBoundary ? altContext : elementContext];
|
|
2357
2448
|
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
|
|
2358
|
-
var referenceClientRect = getBoundingClientRect(
|
|
2449
|
+
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
|
2359
2450
|
var popperOffsets = computeOffsets({
|
|
2360
2451
|
reference: referenceClientRect,
|
|
2361
2452
|
element: popperRect,
|
|
@@ -2738,6 +2829,14 @@ function preventOverflow(_ref) {
|
|
|
2738
2829
|
var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
|
|
2739
2830
|
placement: state.placement
|
|
2740
2831
|
})) : tetherOffset;
|
|
2832
|
+
var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
|
|
2833
|
+
mainAxis: tetherOffsetValue,
|
|
2834
|
+
altAxis: tetherOffsetValue
|
|
2835
|
+
} : Object.assign({
|
|
2836
|
+
mainAxis: 0,
|
|
2837
|
+
altAxis: 0
|
|
2838
|
+
}, tetherOffsetValue);
|
|
2839
|
+
var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
|
|
2741
2840
|
var data = {
|
|
2742
2841
|
x: 0,
|
|
2743
2842
|
y: 0
|
|
@@ -2747,13 +2846,15 @@ function preventOverflow(_ref) {
|
|
|
2747
2846
|
return;
|
|
2748
2847
|
}
|
|
2749
2848
|
|
|
2750
|
-
if (checkMainAxis
|
|
2849
|
+
if (checkMainAxis) {
|
|
2850
|
+
var _offsetModifierState$;
|
|
2851
|
+
|
|
2751
2852
|
var mainSide = mainAxis === 'y' ? top : left;
|
|
2752
2853
|
var altSide = mainAxis === 'y' ? bottom : right;
|
|
2753
2854
|
var len = mainAxis === 'y' ? 'height' : 'width';
|
|
2754
2855
|
var offset = popperOffsets[mainAxis];
|
|
2755
|
-
var min$1 =
|
|
2756
|
-
var max$1 =
|
|
2856
|
+
var min$1 = offset + overflow[mainSide];
|
|
2857
|
+
var max$1 = offset - overflow[altSide];
|
|
2757
2858
|
var additive = tether ? -popperRect[len] / 2 : 0;
|
|
2758
2859
|
var minLen = variation === start ? referenceRect[len] : popperRect[len];
|
|
2759
2860
|
var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
|
|
@@ -2773,36 +2874,45 @@ function preventOverflow(_ref) {
|
|
|
2773
2874
|
// width or height)
|
|
2774
2875
|
|
|
2775
2876
|
var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
|
2776
|
-
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin -
|
|
2777
|
-
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax +
|
|
2877
|
+
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
|
|
2878
|
+
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
|
|
2778
2879
|
var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
|
2779
2880
|
var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
|
2780
|
-
var offsetModifierValue =
|
|
2781
|
-
var tetherMin =
|
|
2782
|
-
var tetherMax =
|
|
2881
|
+
var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
|
|
2882
|
+
var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
|
|
2883
|
+
var tetherMax = offset + maxOffset - offsetModifierValue;
|
|
2884
|
+
var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
|
|
2885
|
+
popperOffsets[mainAxis] = preventedOffset;
|
|
2886
|
+
data[mainAxis] = preventedOffset - offset;
|
|
2887
|
+
}
|
|
2783
2888
|
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
popperOffsets[mainAxis] = preventedOffset;
|
|
2787
|
-
data[mainAxis] = preventedOffset - offset;
|
|
2788
|
-
}
|
|
2889
|
+
if (checkAltAxis) {
|
|
2890
|
+
var _offsetModifierState$2;
|
|
2789
2891
|
|
|
2790
|
-
|
|
2791
|
-
var _mainSide = mainAxis === 'x' ? top : left;
|
|
2892
|
+
var _mainSide = mainAxis === 'x' ? top : left;
|
|
2792
2893
|
|
|
2793
|
-
|
|
2894
|
+
var _altSide = mainAxis === 'x' ? bottom : right;
|
|
2794
2895
|
|
|
2795
|
-
|
|
2896
|
+
var _offset = popperOffsets[altAxis];
|
|
2796
2897
|
|
|
2797
|
-
|
|
2898
|
+
var _len = altAxis === 'y' ? 'height' : 'width';
|
|
2798
2899
|
|
|
2799
|
-
|
|
2900
|
+
var _min = _offset + overflow[_mainSide];
|
|
2800
2901
|
|
|
2801
|
-
|
|
2902
|
+
var _max = _offset - overflow[_altSide];
|
|
2802
2903
|
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2904
|
+
var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
|
|
2905
|
+
|
|
2906
|
+
var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
|
|
2907
|
+
|
|
2908
|
+
var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
|
|
2909
|
+
|
|
2910
|
+
var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
|
|
2911
|
+
|
|
2912
|
+
var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
|
|
2913
|
+
|
|
2914
|
+
popperOffsets[altAxis] = _preventedOffset;
|
|
2915
|
+
data[altAxis] = _preventedOffset - _offset;
|
|
2806
2916
|
}
|
|
2807
2917
|
|
|
2808
2918
|
state.modifiersData[name] = data;
|
|
@@ -2832,16 +2942,24 @@ function getNodeScroll(node) {
|
|
|
2832
2942
|
}
|
|
2833
2943
|
}
|
|
2834
2944
|
|
|
2945
|
+
function isElementScaled(element) {
|
|
2946
|
+
var rect = element.getBoundingClientRect();
|
|
2947
|
+
var scaleX = round(rect.width) / element.offsetWidth || 1;
|
|
2948
|
+
var scaleY = round(rect.height) / element.offsetHeight || 1;
|
|
2949
|
+
return scaleX !== 1 || scaleY !== 1;
|
|
2950
|
+
} // Returns the composite rect of an element relative to its offsetParent.
|
|
2835
2951
|
// Composite means it takes into account transforms as well as layout.
|
|
2836
2952
|
|
|
2953
|
+
|
|
2837
2954
|
function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
2838
2955
|
if (isFixed === void 0) {
|
|
2839
2956
|
isFixed = false;
|
|
2840
2957
|
}
|
|
2841
2958
|
|
|
2842
|
-
var documentElement = getDocumentElement(offsetParent);
|
|
2843
|
-
var rect = getBoundingClientRect(elementOrVirtualElement);
|
|
2844
2959
|
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2960
|
+
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
|
2961
|
+
var documentElement = getDocumentElement(offsetParent);
|
|
2962
|
+
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
|
|
2845
2963
|
var scroll = {
|
|
2846
2964
|
scrollLeft: 0,
|
|
2847
2965
|
scrollTop: 0
|
|
@@ -2858,7 +2976,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
|
2858
2976
|
}
|
|
2859
2977
|
|
|
2860
2978
|
if (isHTMLElement(offsetParent)) {
|
|
2861
|
-
offsets = getBoundingClientRect(offsetParent);
|
|
2979
|
+
offsets = getBoundingClientRect(offsetParent, true);
|
|
2862
2980
|
offsets.x += offsetParent.clientLeft;
|
|
2863
2981
|
offsets.y += offsetParent.clientTop;
|
|
2864
2982
|
} else if (documentElement) {
|
|
@@ -2995,7 +3113,8 @@ function popperGenerator(generatorOptions) {
|
|
|
2995
3113
|
var isDestroyed = false;
|
|
2996
3114
|
var instance = {
|
|
2997
3115
|
state: state,
|
|
2998
|
-
setOptions: function setOptions(
|
|
3116
|
+
setOptions: function setOptions(setOptionsAction) {
|
|
3117
|
+
var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
|
|
2999
3118
|
cleanupModifierEffects();
|
|
3000
3119
|
state.options = Object.assign({}, defaultOptions, state.options, options);
|
|
3001
3120
|
state.scrollParents = {
|