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.
@@ -58,6 +58,8 @@ const camelCase = str => {
58
58
  });
59
59
  };
60
60
 
61
+ 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^="-"])'];
62
+
61
63
  const focusTarget = (target, settings) => {
62
64
  const innerFocus = target.querySelector(`[data-${settings.dataFocus}]`);
63
65
 
@@ -104,6 +106,28 @@ class FocusTrap {
104
106
  this.target = null;
105
107
  }
106
108
 
109
+ refresh() {
110
+ // Check if a target has been set
111
+ if (!this.target) return; // Remove existing events
112
+
113
+ this.target.removeEventListener('keydown', this.__handlerFocusTrap);
114
+ this.target.removeEventListener('keydown', this.handlerFocusLock); // Get the focusable elements
115
+
116
+ this.focusable = this.getFocusable(); // Setup the focus handlers based on focusable length
117
+
118
+ if (this.focusable.length) {
119
+ // If there are focusable elements, setup focus trap
120
+ this.focusableFirst = this.focusable[0];
121
+ this.focusableLast = this.focusable[this.focusable.length - 1];
122
+ this.target.addEventListener('keydown', this.__handlerFocusTrap);
123
+ } else {
124
+ // If there are no focusable elements, setup focus lock
125
+ this.focusableFirst = null;
126
+ this.focusableLast = null;
127
+ this.target.addEventListener('keydown', this.handlerFocusLock);
128
+ }
129
+ }
130
+
107
131
  handlerFocusTrap(event) {
108
132
  const isTab = event.key === 'Tab' || event.keyCode === 9;
109
133
  if (!isTab) return;
@@ -130,7 +154,7 @@ class FocusTrap {
130
154
  const focusable = [];
131
155
  const initFocus = document.activeElement;
132
156
  const initScrollTop = this.inner ? this.inner.scrollTop : 0;
133
- this.target.querySelectorAll('a[href]:not([disabled]),button:not([disabled]),textarea:not([disabled]),input[type="text"]:not([disabled]),input[type="radio"]:not([disabled]),input[type="checkbox"]:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])').forEach(el => {
157
+ this.target.querySelectorAll(focusableSelectors.join(',')).forEach(el => {
134
158
  el.focus();
135
159
 
136
160
  if (el === document.activeElement) {
@@ -305,14 +329,6 @@ const closeTransition = (el, settings) => {
305
329
  });
306
330
  };
307
331
 
308
- const breakpoints = {
309
- xs: '480px',
310
- sm: '620px',
311
- md: '760px',
312
- lg: '990px',
313
- xl: '1380px'
314
- };
315
-
316
332
  var index = {
317
333
  __proto__: null,
318
334
  setInert: setInert,
@@ -330,8 +346,7 @@ var index = {
330
346
  removeClass: removeClass,
331
347
  toggleClass: toggleClass,
332
348
  openTransition: openTransition,
333
- closeTransition: closeTransition,
334
- breakpoints: breakpoints
349
+ closeTransition: closeTransition
335
350
  };
336
351
 
337
352
  function _extends() {
@@ -432,7 +447,7 @@ var defaults$2 = {
432
447
  selectorInert: null,
433
448
  selectorOverflow: null,
434
449
  // Feature toggles
435
- breakpoints: breakpoints,
450
+ breakpoints: null,
436
451
  customEventPrefix: 'drawer:',
437
452
  eventListeners: true,
438
453
  stateSave: true,
@@ -486,6 +501,7 @@ class Breakpoint {
486
501
  constructor(parent) {
487
502
  this.mediaQueryLists = [];
488
503
  this.parent = parent;
504
+ this.prefix = this.getVariablePrefix();
489
505
  this.__check = this.check.bind(this);
490
506
  }
491
507
 
@@ -494,7 +510,7 @@ class Breakpoint {
494
510
  drawers.forEach(drawer => {
495
511
  const id = drawer.getAttribute(`data-${this.parent.settings.dataDrawer}`);
496
512
  const key = drawer.getAttribute(`data-${this.parent.settings.dataBreakpoint}`);
497
- const bp = this.parent.settings.breakpoints[key] ? this.parent.settings.breakpoints[key] : key;
513
+ const bp = this.getBreakpoint(key);
498
514
  const mql = window.matchMedia('(min-width:' + bp + ')');
499
515
  this.match(mql, drawer);
500
516
  mql.addEventListener('change', this.__check);
@@ -539,6 +555,25 @@ class Breakpoint {
539
555
  }
540
556
  }
541
557
 
558
+ getBreakpoint(key) {
559
+ let breakpoint = key;
560
+
561
+ if (this.parent.settings.breakpoints && this.parent.settings.breakpoints[key]) {
562
+ breakpoint = this.parent.settings.breakpoints[key];
563
+ } else if (getComputedStyle(document.body).getPropertyValue(this.prefix + key)) {
564
+ breakpoint = getComputedStyle(document.body).getPropertyValue(this.prefix + key);
565
+ }
566
+
567
+ return breakpoint;
568
+ }
569
+
570
+ getVariablePrefix() {
571
+ let prefix = '--';
572
+ prefix += getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix');
573
+ prefix += 'breakpoint-';
574
+ return prefix;
575
+ }
576
+
542
577
  }
543
578
 
544
579
  function handlerClick$2(event) {
@@ -790,6 +825,7 @@ class Drawer {
790
825
 
791
826
  focusTarget(drawer, this.settings);
792
827
  drawer.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'opened', {
828
+ detail: this,
793
829
  bubbles: true
794
830
  }));
795
831
  this.working = false;
@@ -817,6 +853,7 @@ class Drawer {
817
853
  focusTrigger(this);
818
854
  this.focusTrap.destroy();
819
855
  drawer.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'closed', {
856
+ detail: this,
820
857
  bubbles: true
821
858
  }));
822
859
  this.working = false;
@@ -1010,6 +1047,7 @@ class Modal {
1010
1047
  focusTarget(modal, this.settings);
1011
1048
  setInert(true, this.settings.selectorInert);
1012
1049
  modal.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'opened', {
1050
+ detail: this,
1013
1051
  bubbles: true
1014
1052
  }));
1015
1053
  this.working = false;
@@ -1030,6 +1068,7 @@ class Modal {
1030
1068
  if (returnFocus) focusTrigger(this);
1031
1069
  this.focusTrap.destroy();
1032
1070
  modal.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'closed', {
1071
+ detail: this,
1033
1072
  bubbles: true
1034
1073
  }));
1035
1074
  this.working = false;
@@ -1119,7 +1158,8 @@ function getConfig(el, settings) {
1119
1158
 
1120
1159
  for (const prop in config) {
1121
1160
  // Get the CSS variable property values
1122
- const val = styles.getPropertyValue(`--popover-${prop}`).trim(); // If a value was found, replace the default in config obj
1161
+ const prefix = getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix');
1162
+ const val = styles.getPropertyValue(`--${prefix}popover-${prop}`).trim(); // If a value was found, replace the default in config obj
1123
1163
 
1124
1164
  if (val) {
1125
1165
  config[prop] = val;
@@ -1436,17 +1476,42 @@ function getBasePlacement(placement) {
1436
1476
  return placement.split('-')[0];
1437
1477
  }
1438
1478
 
1439
- function getBoundingClientRect(element) {
1479
+ var max = Math.max;
1480
+ var min = Math.min;
1481
+ var round = Math.round;
1482
+
1483
+ function getBoundingClientRect(element, includeScale) {
1484
+ if (includeScale === void 0) {
1485
+ includeScale = false;
1486
+ }
1487
+
1440
1488
  var rect = element.getBoundingClientRect();
1489
+ var scaleX = 1;
1490
+ var scaleY = 1;
1491
+
1492
+ if (isHTMLElement(element) && includeScale) {
1493
+ var offsetHeight = element.offsetHeight;
1494
+ var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
1495
+ // Fallback to 1 in case both values are `0`
1496
+
1497
+ if (offsetWidth > 0) {
1498
+ scaleX = round(rect.width) / offsetWidth || 1;
1499
+ }
1500
+
1501
+ if (offsetHeight > 0) {
1502
+ scaleY = round(rect.height) / offsetHeight || 1;
1503
+ }
1504
+ }
1505
+
1441
1506
  return {
1442
- width: rect.width,
1443
- height: rect.height,
1444
- top: rect.top,
1445
- right: rect.right,
1446
- bottom: rect.bottom,
1447
- left: rect.left,
1448
- x: rect.left,
1449
- y: rect.top
1507
+ width: rect.width / scaleX,
1508
+ height: rect.height / scaleY,
1509
+ top: rect.top / scaleY,
1510
+ right: rect.right / scaleX,
1511
+ bottom: rect.bottom / scaleY,
1512
+ left: rect.left / scaleX,
1513
+ x: rect.left / scaleX,
1514
+ y: rect.top / scaleY
1450
1515
  };
1451
1516
  }
1452
1517
 
@@ -1591,13 +1656,13 @@ function getMainAxisFromPlacement(placement) {
1591
1656
  return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
1592
1657
  }
1593
1658
 
1594
- var max = Math.max;
1595
- var min = Math.min;
1596
- var round = Math.round;
1597
-
1598
1659
  function within(min$1, value, max$1) {
1599
1660
  return max(min$1, min(value, max$1));
1600
1661
  }
1662
+ function withinMaxClamp(min, value, max) {
1663
+ var v = within(min, value, max);
1664
+ return v > max ? max : v;
1665
+ }
1601
1666
 
1602
1667
  function getFreshSideObject() {
1603
1668
  return {
@@ -1701,6 +1766,10 @@ var arrow$1 = {
1701
1766
  requiresIfExists: ['preventOverflow']
1702
1767
  };
1703
1768
 
1769
+ function getVariation(placement) {
1770
+ return placement.split('-')[1];
1771
+ }
1772
+
1704
1773
  var unsetSides = {
1705
1774
  top: 'auto',
1706
1775
  right: 'auto',
@@ -1716,8 +1785,8 @@ function roundOffsetsByDPR(_ref) {
1716
1785
  var win = window;
1717
1786
  var dpr = win.devicePixelRatio || 1;
1718
1787
  return {
1719
- x: round(round(x * dpr) / dpr) || 0,
1720
- y: round(round(y * dpr) / dpr) || 0
1788
+ x: round(x * dpr) / dpr || 0,
1789
+ y: round(y * dpr) / dpr || 0
1721
1790
  };
1722
1791
  }
1723
1792
 
@@ -1727,18 +1796,28 @@ function mapToStyles(_ref2) {
1727
1796
  var popper = _ref2.popper,
1728
1797
  popperRect = _ref2.popperRect,
1729
1798
  placement = _ref2.placement,
1799
+ variation = _ref2.variation,
1730
1800
  offsets = _ref2.offsets,
1731
1801
  position = _ref2.position,
1732
1802
  gpuAcceleration = _ref2.gpuAcceleration,
1733
1803
  adaptive = _ref2.adaptive,
1734
- roundOffsets = _ref2.roundOffsets;
1735
-
1736
- var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
1737
- _ref3$x = _ref3.x,
1738
- x = _ref3$x === void 0 ? 0 : _ref3$x,
1739
- _ref3$y = _ref3.y,
1740
- y = _ref3$y === void 0 ? 0 : _ref3$y;
1804
+ roundOffsets = _ref2.roundOffsets,
1805
+ isFixed = _ref2.isFixed;
1806
+ var _offsets$x = offsets.x,
1807
+ x = _offsets$x === void 0 ? 0 : _offsets$x,
1808
+ _offsets$y = offsets.y,
1809
+ y = _offsets$y === void 0 ? 0 : _offsets$y;
1810
+
1811
+ var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
1812
+ x: x,
1813
+ y: y
1814
+ }) : {
1815
+ x: x,
1816
+ y: y
1817
+ };
1741
1818
 
1819
+ x = _ref3.x;
1820
+ y = _ref3.y;
1742
1821
  var hasX = offsets.hasOwnProperty('x');
1743
1822
  var hasY = offsets.hasOwnProperty('y');
1744
1823
  var sideX = left;
@@ -1753,7 +1832,7 @@ function mapToStyles(_ref2) {
1753
1832
  if (offsetParent === getWindow(popper)) {
1754
1833
  offsetParent = getDocumentElement(popper);
1755
1834
 
1756
- if (getComputedStyle$1(offsetParent).position !== 'static') {
1835
+ if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
1757
1836
  heightProp = 'scrollHeight';
1758
1837
  widthProp = 'scrollWidth';
1759
1838
  }
@@ -1762,17 +1841,19 @@ function mapToStyles(_ref2) {
1762
1841
 
1763
1842
  offsetParent = offsetParent;
1764
1843
 
1765
- if (placement === top) {
1766
- sideY = bottom; // $FlowFixMe[prop-missing]
1767
-
1768
- y -= offsetParent[heightProp] - popperRect.height;
1844
+ if (placement === top || (placement === left || placement === right) && variation === end) {
1845
+ sideY = bottom;
1846
+ var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
1847
+ offsetParent[heightProp];
1848
+ y -= offsetY - popperRect.height;
1769
1849
  y *= gpuAcceleration ? 1 : -1;
1770
1850
  }
1771
1851
 
1772
- if (placement === left) {
1773
- sideX = right; // $FlowFixMe[prop-missing]
1774
-
1775
- x -= offsetParent[widthProp] - popperRect.width;
1852
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
1853
+ sideX = right;
1854
+ var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
1855
+ offsetParent[widthProp];
1856
+ x -= offsetX - popperRect.width;
1776
1857
  x *= gpuAcceleration ? 1 : -1;
1777
1858
  }
1778
1859
  }
@@ -1781,18 +1862,29 @@ function mapToStyles(_ref2) {
1781
1862
  position: position
1782
1863
  }, adaptive && unsetSides);
1783
1864
 
1865
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
1866
+ x: x,
1867
+ y: y
1868
+ }) : {
1869
+ x: x,
1870
+ y: y
1871
+ };
1872
+
1873
+ x = _ref4.x;
1874
+ y = _ref4.y;
1875
+
1784
1876
  if (gpuAcceleration) {
1785
1877
  var _Object$assign;
1786
1878
 
1787
- return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
1879
+ 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));
1788
1880
  }
1789
1881
 
1790
1882
  return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
1791
1883
  }
1792
1884
 
1793
- function computeStyles(_ref4) {
1794
- var state = _ref4.state,
1795
- options = _ref4.options;
1885
+ function computeStyles(_ref5) {
1886
+ var state = _ref5.state,
1887
+ options = _ref5.options;
1796
1888
  var _options$gpuAccelerat = options.gpuAcceleration,
1797
1889
  gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
1798
1890
  _options$adaptive = options.adaptive,
@@ -1802,9 +1894,11 @@ function computeStyles(_ref4) {
1802
1894
 
1803
1895
  var commonStyles = {
1804
1896
  placement: getBasePlacement(state.placement),
1897
+ variation: getVariation(state.placement),
1805
1898
  popper: state.elements.popper,
1806
1899
  popperRect: state.rects.popper,
1807
- gpuAcceleration: gpuAcceleration
1900
+ gpuAcceleration: gpuAcceleration,
1901
+ isFixed: state.options.strategy === 'fixed'
1808
1902
  };
1809
1903
 
1810
1904
  if (state.modifiersData.popperOffsets != null) {
@@ -2062,7 +2156,7 @@ function getInnerBoundingClientRect(element) {
2062
2156
  }
2063
2157
 
2064
2158
  function getClientRectFromMixedType(element, clippingParent) {
2065
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2159
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2066
2160
  } // A "clipping parent" is an overflowable container with the characteristic of
2067
2161
  // clipping (or hiding) overflowing elements with a position different from
2068
2162
  // `initial`
@@ -2104,10 +2198,6 @@ function getClippingRect(element, boundary, rootBoundary) {
2104
2198
  return clippingRect;
2105
2199
  }
2106
2200
 
2107
- function getVariation(placement) {
2108
- return placement.split('-')[1];
2109
- }
2110
-
2111
2201
  function computeOffsets(_ref) {
2112
2202
  var reference = _ref.reference,
2113
2203
  element = _ref.element,
@@ -2193,11 +2283,10 @@ function detectOverflow(state, options) {
2193
2283
  padding = _options$padding === void 0 ? 0 : _options$padding;
2194
2284
  var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
2195
2285
  var altContext = elementContext === popper ? reference : popper;
2196
- var referenceElement = state.elements.reference;
2197
2286
  var popperRect = state.rects.popper;
2198
2287
  var element = state.elements[altBoundary ? altContext : elementContext];
2199
2288
  var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
2200
- var referenceClientRect = getBoundingClientRect(referenceElement);
2289
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
2201
2290
  var popperOffsets = computeOffsets({
2202
2291
  reference: referenceClientRect,
2203
2292
  element: popperRect,
@@ -2580,6 +2669,14 @@ function preventOverflow(_ref) {
2580
2669
  var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
2581
2670
  placement: state.placement
2582
2671
  })) : tetherOffset;
2672
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
2673
+ mainAxis: tetherOffsetValue,
2674
+ altAxis: tetherOffsetValue
2675
+ } : Object.assign({
2676
+ mainAxis: 0,
2677
+ altAxis: 0
2678
+ }, tetherOffsetValue);
2679
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
2583
2680
  var data = {
2584
2681
  x: 0,
2585
2682
  y: 0
@@ -2589,13 +2686,15 @@ function preventOverflow(_ref) {
2589
2686
  return;
2590
2687
  }
2591
2688
 
2592
- if (checkMainAxis || checkAltAxis) {
2689
+ if (checkMainAxis) {
2690
+ var _offsetModifierState$;
2691
+
2593
2692
  var mainSide = mainAxis === 'y' ? top : left;
2594
2693
  var altSide = mainAxis === 'y' ? bottom : right;
2595
2694
  var len = mainAxis === 'y' ? 'height' : 'width';
2596
2695
  var offset = popperOffsets[mainAxis];
2597
- var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
2598
- var max$1 = popperOffsets[mainAxis] - overflow[altSide];
2696
+ var min$1 = offset + overflow[mainSide];
2697
+ var max$1 = offset - overflow[altSide];
2599
2698
  var additive = tether ? -popperRect[len] / 2 : 0;
2600
2699
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
2601
2700
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
@@ -2615,36 +2714,45 @@ function preventOverflow(_ref) {
2615
2714
  // width or height)
2616
2715
 
2617
2716
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
2618
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
2619
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
2717
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
2718
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
2620
2719
  var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
2621
2720
  var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
2622
- var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
2623
- var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
2624
- var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
2721
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
2722
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
2723
+ var tetherMax = offset + maxOffset - offsetModifierValue;
2724
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
2725
+ popperOffsets[mainAxis] = preventedOffset;
2726
+ data[mainAxis] = preventedOffset - offset;
2727
+ }
2625
2728
 
2626
- if (checkMainAxis) {
2627
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
2628
- popperOffsets[mainAxis] = preventedOffset;
2629
- data[mainAxis] = preventedOffset - offset;
2630
- }
2729
+ if (checkAltAxis) {
2730
+ var _offsetModifierState$2;
2631
2731
 
2632
- if (checkAltAxis) {
2633
- var _mainSide = mainAxis === 'x' ? top : left;
2732
+ var _mainSide = mainAxis === 'x' ? top : left;
2634
2733
 
2635
- var _altSide = mainAxis === 'x' ? bottom : right;
2734
+ var _altSide = mainAxis === 'x' ? bottom : right;
2636
2735
 
2637
- var _offset = popperOffsets[altAxis];
2736
+ var _offset = popperOffsets[altAxis];
2638
2737
 
2639
- var _min = _offset + overflow[_mainSide];
2738
+ var _len = altAxis === 'y' ? 'height' : 'width';
2640
2739
 
2641
- var _max = _offset - overflow[_altSide];
2740
+ var _min = _offset + overflow[_mainSide];
2642
2741
 
2643
- var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
2742
+ var _max = _offset - overflow[_altSide];
2644
2743
 
2645
- popperOffsets[altAxis] = _preventedOffset;
2646
- data[altAxis] = _preventedOffset - _offset;
2647
- }
2744
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
2745
+
2746
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
2747
+
2748
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
2749
+
2750
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
2751
+
2752
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
2753
+
2754
+ popperOffsets[altAxis] = _preventedOffset;
2755
+ data[altAxis] = _preventedOffset - _offset;
2648
2756
  }
2649
2757
 
2650
2758
  state.modifiersData[name] = data;
@@ -2674,16 +2782,24 @@ function getNodeScroll(node) {
2674
2782
  }
2675
2783
  }
2676
2784
 
2785
+ function isElementScaled(element) {
2786
+ var rect = element.getBoundingClientRect();
2787
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
2788
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
2789
+ return scaleX !== 1 || scaleY !== 1;
2790
+ } // Returns the composite rect of an element relative to its offsetParent.
2677
2791
  // Composite means it takes into account transforms as well as layout.
2678
2792
 
2793
+
2679
2794
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2680
2795
  if (isFixed === void 0) {
2681
2796
  isFixed = false;
2682
2797
  }
2683
2798
 
2684
- var documentElement = getDocumentElement(offsetParent);
2685
- var rect = getBoundingClientRect(elementOrVirtualElement);
2686
2799
  var isOffsetParentAnElement = isHTMLElement(offsetParent);
2800
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2801
+ var documentElement = getDocumentElement(offsetParent);
2802
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
2687
2803
  var scroll = {
2688
2804
  scrollLeft: 0,
2689
2805
  scrollTop: 0
@@ -2700,7 +2816,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2700
2816
  }
2701
2817
 
2702
2818
  if (isHTMLElement(offsetParent)) {
2703
- offsets = getBoundingClientRect(offsetParent);
2819
+ offsets = getBoundingClientRect(offsetParent, true);
2704
2820
  offsets.x += offsetParent.clientLeft;
2705
2821
  offsets.y += offsetParent.clientTop;
2706
2822
  } else if (documentElement) {
@@ -2837,7 +2953,8 @@ function popperGenerator(generatorOptions) {
2837
2953
  var isDestroyed = false;
2838
2954
  var instance = {
2839
2955
  state: state,
2840
- setOptions: function setOptions(options) {
2956
+ setOptions: function setOptions(setOptionsAction) {
2957
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
2841
2958
  cleanupModifierEffects();
2842
2959
  state.options = Object.assign({}, defaultOptions, state.options, options);
2843
2960
  state.scrollParents = {