vrembem 1.37.0 → 1.38.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.
@@ -1464,29 +1464,32 @@ function getBasePlacement(placement) {
1464
1464
  return placement.split('-')[0];
1465
1465
  }
1466
1466
 
1467
- // import { isHTMLElement } from './instanceOf';
1468
- function getBoundingClientRect(element, // eslint-disable-next-line unused-imports/no-unused-vars
1469
- includeScale) {
1467
+ var max = Math.max;
1468
+ var min = Math.min;
1469
+ var round = Math.round;
1470
+
1471
+ function getBoundingClientRect(element, includeScale) {
1472
+ if (includeScale === void 0) {
1473
+ includeScale = false;
1474
+ }
1470
1475
 
1471
1476
  var rect = element.getBoundingClientRect();
1472
1477
  var scaleX = 1;
1473
- var scaleY = 1; // FIXME:
1474
- // `offsetWidth` returns an integer while `getBoundingClientRect`
1475
- // returns a float. This results in `scaleX` or `scaleY` being
1476
- // non-1 when it should be for elements that aren't a full pixel in
1477
- // width or height.
1478
- // if (isHTMLElement(element) && includeScale) {
1479
- // const offsetHeight = element.offsetHeight;
1480
- // const offsetWidth = element.offsetWidth;
1481
- // // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
1482
- // // Fallback to 1 in case both values are `0`
1483
- // if (offsetWidth > 0) {
1484
- // scaleX = rect.width / offsetWidth || 1;
1485
- // }
1486
- // if (offsetHeight > 0) {
1487
- // scaleY = rect.height / offsetHeight || 1;
1488
- // }
1489
- // }
1478
+ var scaleY = 1;
1479
+
1480
+ if (isHTMLElement(element) && includeScale) {
1481
+ var offsetHeight = element.offsetHeight;
1482
+ var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
1483
+ // Fallback to 1 in case both values are `0`
1484
+
1485
+ if (offsetWidth > 0) {
1486
+ scaleX = round(rect.width) / offsetWidth || 1;
1487
+ }
1488
+
1489
+ if (offsetHeight > 0) {
1490
+ scaleY = round(rect.height) / offsetHeight || 1;
1491
+ }
1492
+ }
1490
1493
 
1491
1494
  return {
1492
1495
  width: rect.width / scaleX,
@@ -1641,13 +1644,13 @@ function getMainAxisFromPlacement(placement) {
1641
1644
  return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
1642
1645
  }
1643
1646
 
1644
- var max = Math.max;
1645
- var min = Math.min;
1646
- var round = Math.round;
1647
-
1648
1647
  function within(min$1, value, max$1) {
1649
1648
  return max(min$1, min(value, max$1));
1650
1649
  }
1650
+ function withinMaxClamp(min, value, max) {
1651
+ var v = within(min, value, max);
1652
+ return v > max ? max : v;
1653
+ }
1651
1654
 
1652
1655
  function getFreshSideObject() {
1653
1656
  return {
@@ -1770,8 +1773,8 @@ function roundOffsetsByDPR(_ref) {
1770
1773
  var win = window;
1771
1774
  var dpr = win.devicePixelRatio || 1;
1772
1775
  return {
1773
- x: round(round(x * dpr) / dpr) || 0,
1774
- y: round(round(y * dpr) / dpr) || 0
1776
+ x: round(x * dpr) / dpr || 0,
1777
+ y: round(y * dpr) / dpr || 0
1775
1778
  };
1776
1779
  }
1777
1780
 
@@ -1786,14 +1789,23 @@ function mapToStyles(_ref2) {
1786
1789
  position = _ref2.position,
1787
1790
  gpuAcceleration = _ref2.gpuAcceleration,
1788
1791
  adaptive = _ref2.adaptive,
1789
- roundOffsets = _ref2.roundOffsets;
1790
-
1791
- var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
1792
- _ref3$x = _ref3.x,
1793
- x = _ref3$x === void 0 ? 0 : _ref3$x,
1794
- _ref3$y = _ref3.y,
1795
- y = _ref3$y === void 0 ? 0 : _ref3$y;
1792
+ roundOffsets = _ref2.roundOffsets,
1793
+ isFixed = _ref2.isFixed;
1794
+ var _offsets$x = offsets.x,
1795
+ x = _offsets$x === void 0 ? 0 : _offsets$x,
1796
+ _offsets$y = offsets.y,
1797
+ y = _offsets$y === void 0 ? 0 : _offsets$y;
1798
+
1799
+ var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
1800
+ x: x,
1801
+ y: y
1802
+ }) : {
1803
+ x: x,
1804
+ y: y
1805
+ };
1796
1806
 
1807
+ x = _ref3.x;
1808
+ y = _ref3.y;
1797
1809
  var hasX = offsets.hasOwnProperty('x');
1798
1810
  var hasY = offsets.hasOwnProperty('y');
1799
1811
  var sideX = left;
@@ -1818,16 +1830,18 @@ function mapToStyles(_ref2) {
1818
1830
  offsetParent = offsetParent;
1819
1831
 
1820
1832
  if (placement === top || (placement === left || placement === right) && variation === end) {
1821
- sideY = bottom; // $FlowFixMe[prop-missing]
1822
-
1823
- y -= offsetParent[heightProp] - popperRect.height;
1833
+ sideY = bottom;
1834
+ var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
1835
+ offsetParent[heightProp];
1836
+ y -= offsetY - popperRect.height;
1824
1837
  y *= gpuAcceleration ? 1 : -1;
1825
1838
  }
1826
1839
 
1827
1840
  if (placement === left || (placement === top || placement === bottom) && variation === end) {
1828
- sideX = right; // $FlowFixMe[prop-missing]
1829
-
1830
- x -= offsetParent[widthProp] - popperRect.width;
1841
+ sideX = right;
1842
+ var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
1843
+ offsetParent[widthProp];
1844
+ x -= offsetX - popperRect.width;
1831
1845
  x *= gpuAcceleration ? 1 : -1;
1832
1846
  }
1833
1847
  }
@@ -1836,6 +1850,17 @@ function mapToStyles(_ref2) {
1836
1850
  position: position
1837
1851
  }, adaptive && unsetSides);
1838
1852
 
1853
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
1854
+ x: x,
1855
+ y: y
1856
+ }) : {
1857
+ x: x,
1858
+ y: y
1859
+ };
1860
+
1861
+ x = _ref4.x;
1862
+ y = _ref4.y;
1863
+
1839
1864
  if (gpuAcceleration) {
1840
1865
  var _Object$assign;
1841
1866
 
@@ -1845,9 +1870,9 @@ function mapToStyles(_ref2) {
1845
1870
  return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
1846
1871
  }
1847
1872
 
1848
- function computeStyles(_ref4) {
1849
- var state = _ref4.state,
1850
- options = _ref4.options;
1873
+ function computeStyles(_ref5) {
1874
+ var state = _ref5.state,
1875
+ options = _ref5.options;
1851
1876
  var _options$gpuAccelerat = options.gpuAcceleration,
1852
1877
  gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
1853
1878
  _options$adaptive = options.adaptive,
@@ -1860,7 +1885,8 @@ function computeStyles(_ref4) {
1860
1885
  variation: getVariation(state.placement),
1861
1886
  popper: state.elements.popper,
1862
1887
  popperRect: state.rects.popper,
1863
- gpuAcceleration: gpuAcceleration
1888
+ gpuAcceleration: gpuAcceleration,
1889
+ isFixed: state.options.strategy === 'fixed'
1864
1890
  };
1865
1891
 
1866
1892
  if (state.modifiersData.popperOffsets != null) {
@@ -2118,7 +2144,7 @@ function getInnerBoundingClientRect(element) {
2118
2144
  }
2119
2145
 
2120
2146
  function getClientRectFromMixedType(element, clippingParent) {
2121
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2147
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2122
2148
  } // A "clipping parent" is an overflowable container with the characteristic of
2123
2149
  // clipping (or hiding) overflowing elements with a position different from
2124
2150
  // `initial`
@@ -2631,6 +2657,14 @@ function preventOverflow(_ref) {
2631
2657
  var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
2632
2658
  placement: state.placement
2633
2659
  })) : tetherOffset;
2660
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
2661
+ mainAxis: tetherOffsetValue,
2662
+ altAxis: tetherOffsetValue
2663
+ } : Object.assign({
2664
+ mainAxis: 0,
2665
+ altAxis: 0
2666
+ }, tetherOffsetValue);
2667
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
2634
2668
  var data = {
2635
2669
  x: 0,
2636
2670
  y: 0
@@ -2640,13 +2674,15 @@ function preventOverflow(_ref) {
2640
2674
  return;
2641
2675
  }
2642
2676
 
2643
- if (checkMainAxis || checkAltAxis) {
2677
+ if (checkMainAxis) {
2678
+ var _offsetModifierState$;
2679
+
2644
2680
  var mainSide = mainAxis === 'y' ? top : left;
2645
2681
  var altSide = mainAxis === 'y' ? bottom : right;
2646
2682
  var len = mainAxis === 'y' ? 'height' : 'width';
2647
2683
  var offset = popperOffsets[mainAxis];
2648
- var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
2649
- var max$1 = popperOffsets[mainAxis] - overflow[altSide];
2684
+ var min$1 = offset + overflow[mainSide];
2685
+ var max$1 = offset - overflow[altSide];
2650
2686
  var additive = tether ? -popperRect[len] / 2 : 0;
2651
2687
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
2652
2688
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
@@ -2666,36 +2702,45 @@ function preventOverflow(_ref) {
2666
2702
  // width or height)
2667
2703
 
2668
2704
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
2669
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
2670
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
2705
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
2706
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
2671
2707
  var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
2672
2708
  var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
2673
- var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
2674
- var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
2675
- var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
2709
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
2710
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
2711
+ var tetherMax = offset + maxOffset - offsetModifierValue;
2712
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
2713
+ popperOffsets[mainAxis] = preventedOffset;
2714
+ data[mainAxis] = preventedOffset - offset;
2715
+ }
2676
2716
 
2677
- if (checkMainAxis) {
2678
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
2679
- popperOffsets[mainAxis] = preventedOffset;
2680
- data[mainAxis] = preventedOffset - offset;
2681
- }
2717
+ if (checkAltAxis) {
2718
+ var _offsetModifierState$2;
2682
2719
 
2683
- if (checkAltAxis) {
2684
- var _mainSide = mainAxis === 'x' ? top : left;
2720
+ var _mainSide = mainAxis === 'x' ? top : left;
2685
2721
 
2686
- var _altSide = mainAxis === 'x' ? bottom : right;
2722
+ var _altSide = mainAxis === 'x' ? bottom : right;
2687
2723
 
2688
- var _offset = popperOffsets[altAxis];
2724
+ var _offset = popperOffsets[altAxis];
2689
2725
 
2690
- var _min = _offset + overflow[_mainSide];
2726
+ var _len = altAxis === 'y' ? 'height' : 'width';
2691
2727
 
2692
- var _max = _offset - overflow[_altSide];
2728
+ var _min = _offset + overflow[_mainSide];
2693
2729
 
2694
- var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
2730
+ var _max = _offset - overflow[_altSide];
2695
2731
 
2696
- popperOffsets[altAxis] = _preventedOffset;
2697
- data[altAxis] = _preventedOffset - _offset;
2698
- }
2732
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
2733
+
2734
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
2735
+
2736
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
2737
+
2738
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
2739
+
2740
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
2741
+
2742
+ popperOffsets[altAxis] = _preventedOffset;
2743
+ data[altAxis] = _preventedOffset - _offset;
2699
2744
  }
2700
2745
 
2701
2746
  state.modifiersData[name] = data;
@@ -2727,8 +2772,8 @@ function getNodeScroll(node) {
2727
2772
 
2728
2773
  function isElementScaled(element) {
2729
2774
  var rect = element.getBoundingClientRect();
2730
- var scaleX = rect.width / element.offsetWidth || 1;
2731
- var scaleY = rect.height / element.offsetHeight || 1;
2775
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
2776
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
2732
2777
  return scaleX !== 1 || scaleY !== 1;
2733
2778
  } // Returns the composite rect of an element relative to its offsetParent.
2734
2779
  // Composite means it takes into account transforms as well as layout.
@@ -2740,9 +2785,9 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2740
2785
  }
2741
2786
 
2742
2787
  var isOffsetParentAnElement = isHTMLElement(offsetParent);
2743
- isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2788
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2744
2789
  var documentElement = getDocumentElement(offsetParent);
2745
- var rect = getBoundingClientRect(elementOrVirtualElement);
2790
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
2746
2791
  var scroll = {
2747
2792
  scrollLeft: 0,
2748
2793
  scrollTop: 0
@@ -2759,7 +2804,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2759
2804
  }
2760
2805
 
2761
2806
  if (isHTMLElement(offsetParent)) {
2762
- offsets = getBoundingClientRect(offsetParent);
2807
+ offsets = getBoundingClientRect(offsetParent, true);
2763
2808
  offsets.x += offsetParent.clientLeft;
2764
2809
  offsets.y += offsetParent.clientTop;
2765
2810
  } else if (documentElement) {