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.
@@ -1627,29 +1627,32 @@
1627
1627
  return placement.split('-')[0];
1628
1628
  }
1629
1629
 
1630
- // import { isHTMLElement } from './instanceOf';
1631
- function getBoundingClientRect(element, // eslint-disable-next-line unused-imports/no-unused-vars
1632
- includeScale) {
1630
+ var max = Math.max;
1631
+ var min = Math.min;
1632
+ var round = Math.round;
1633
+
1634
+ function getBoundingClientRect(element, includeScale) {
1635
+ if (includeScale === void 0) {
1636
+ includeScale = false;
1637
+ }
1633
1638
 
1634
1639
  var rect = element.getBoundingClientRect();
1635
1640
  var scaleX = 1;
1636
- var scaleY = 1; // FIXME:
1637
- // `offsetWidth` returns an integer while `getBoundingClientRect`
1638
- // returns a float. This results in `scaleX` or `scaleY` being
1639
- // non-1 when it should be for elements that aren't a full pixel in
1640
- // width or height.
1641
- // if (isHTMLElement(element) && includeScale) {
1642
- // const offsetHeight = element.offsetHeight;
1643
- // const offsetWidth = element.offsetWidth;
1644
- // // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
1645
- // // Fallback to 1 in case both values are `0`
1646
- // if (offsetWidth > 0) {
1647
- // scaleX = rect.width / offsetWidth || 1;
1648
- // }
1649
- // if (offsetHeight > 0) {
1650
- // scaleY = rect.height / offsetHeight || 1;
1651
- // }
1652
- // }
1641
+ var scaleY = 1;
1642
+
1643
+ if (isHTMLElement(element) && includeScale) {
1644
+ var offsetHeight = element.offsetHeight;
1645
+ var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
1646
+ // Fallback to 1 in case both values are `0`
1647
+
1648
+ if (offsetWidth > 0) {
1649
+ scaleX = round(rect.width) / offsetWidth || 1;
1650
+ }
1651
+
1652
+ if (offsetHeight > 0) {
1653
+ scaleY = round(rect.height) / offsetHeight || 1;
1654
+ }
1655
+ }
1653
1656
 
1654
1657
  return {
1655
1658
  width: rect.width / scaleX,
@@ -1804,13 +1807,13 @@
1804
1807
  return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
1805
1808
  }
1806
1809
 
1807
- var max = Math.max;
1808
- var min = Math.min;
1809
- var round = Math.round;
1810
-
1811
1810
  function within(min$1, value, max$1) {
1812
1811
  return max(min$1, min(value, max$1));
1813
1812
  }
1813
+ function withinMaxClamp(min, value, max) {
1814
+ var v = within(min, value, max);
1815
+ return v > max ? max : v;
1816
+ }
1814
1817
 
1815
1818
  function getFreshSideObject() {
1816
1819
  return {
@@ -1933,8 +1936,8 @@
1933
1936
  var win = window;
1934
1937
  var dpr = win.devicePixelRatio || 1;
1935
1938
  return {
1936
- x: round(round(x * dpr) / dpr) || 0,
1937
- y: round(round(y * dpr) / dpr) || 0
1939
+ x: round(x * dpr) / dpr || 0,
1940
+ y: round(y * dpr) / dpr || 0
1938
1941
  };
1939
1942
  }
1940
1943
 
@@ -1949,14 +1952,23 @@
1949
1952
  position = _ref2.position,
1950
1953
  gpuAcceleration = _ref2.gpuAcceleration,
1951
1954
  adaptive = _ref2.adaptive,
1952
- roundOffsets = _ref2.roundOffsets;
1953
-
1954
- var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
1955
- _ref3$x = _ref3.x,
1956
- x = _ref3$x === void 0 ? 0 : _ref3$x,
1957
- _ref3$y = _ref3.y,
1958
- y = _ref3$y === void 0 ? 0 : _ref3$y;
1955
+ roundOffsets = _ref2.roundOffsets,
1956
+ isFixed = _ref2.isFixed;
1957
+ var _offsets$x = offsets.x,
1958
+ x = _offsets$x === void 0 ? 0 : _offsets$x,
1959
+ _offsets$y = offsets.y,
1960
+ y = _offsets$y === void 0 ? 0 : _offsets$y;
1961
+
1962
+ var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
1963
+ x: x,
1964
+ y: y
1965
+ }) : {
1966
+ x: x,
1967
+ y: y
1968
+ };
1959
1969
 
1970
+ x = _ref3.x;
1971
+ y = _ref3.y;
1960
1972
  var hasX = offsets.hasOwnProperty('x');
1961
1973
  var hasY = offsets.hasOwnProperty('y');
1962
1974
  var sideX = left;
@@ -1981,16 +1993,18 @@
1981
1993
  offsetParent = offsetParent;
1982
1994
 
1983
1995
  if (placement === top || (placement === left || placement === right) && variation === end) {
1984
- sideY = bottom; // $FlowFixMe[prop-missing]
1985
-
1986
- y -= offsetParent[heightProp] - popperRect.height;
1996
+ sideY = bottom;
1997
+ var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
1998
+ offsetParent[heightProp];
1999
+ y -= offsetY - popperRect.height;
1987
2000
  y *= gpuAcceleration ? 1 : -1;
1988
2001
  }
1989
2002
 
1990
2003
  if (placement === left || (placement === top || placement === bottom) && variation === end) {
1991
- sideX = right; // $FlowFixMe[prop-missing]
1992
-
1993
- x -= offsetParent[widthProp] - popperRect.width;
2004
+ sideX = right;
2005
+ var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
2006
+ offsetParent[widthProp];
2007
+ x -= offsetX - popperRect.width;
1994
2008
  x *= gpuAcceleration ? 1 : -1;
1995
2009
  }
1996
2010
  }
@@ -1999,6 +2013,17 @@
1999
2013
  position: position
2000
2014
  }, adaptive && unsetSides);
2001
2015
 
2016
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
2017
+ x: x,
2018
+ y: y
2019
+ }) : {
2020
+ x: x,
2021
+ y: y
2022
+ };
2023
+
2024
+ x = _ref4.x;
2025
+ y = _ref4.y;
2026
+
2002
2027
  if (gpuAcceleration) {
2003
2028
  var _Object$assign;
2004
2029
 
@@ -2008,9 +2033,9 @@
2008
2033
  return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
2009
2034
  }
2010
2035
 
2011
- function computeStyles(_ref4) {
2012
- var state = _ref4.state,
2013
- options = _ref4.options;
2036
+ function computeStyles(_ref5) {
2037
+ var state = _ref5.state,
2038
+ options = _ref5.options;
2014
2039
  var _options$gpuAccelerat = options.gpuAcceleration,
2015
2040
  gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
2016
2041
  _options$adaptive = options.adaptive,
@@ -2023,7 +2048,8 @@
2023
2048
  variation: getVariation(state.placement),
2024
2049
  popper: state.elements.popper,
2025
2050
  popperRect: state.rects.popper,
2026
- gpuAcceleration: gpuAcceleration
2051
+ gpuAcceleration: gpuAcceleration,
2052
+ isFixed: state.options.strategy === 'fixed'
2027
2053
  };
2028
2054
 
2029
2055
  if (state.modifiersData.popperOffsets != null) {
@@ -2281,7 +2307,7 @@
2281
2307
  }
2282
2308
 
2283
2309
  function getClientRectFromMixedType(element, clippingParent) {
2284
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2310
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2285
2311
  } // A "clipping parent" is an overflowable container with the characteristic of
2286
2312
  // clipping (or hiding) overflowing elements with a position different from
2287
2313
  // `initial`
@@ -2794,6 +2820,14 @@
2794
2820
  var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
2795
2821
  placement: state.placement
2796
2822
  })) : tetherOffset;
2823
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
2824
+ mainAxis: tetherOffsetValue,
2825
+ altAxis: tetherOffsetValue
2826
+ } : Object.assign({
2827
+ mainAxis: 0,
2828
+ altAxis: 0
2829
+ }, tetherOffsetValue);
2830
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
2797
2831
  var data = {
2798
2832
  x: 0,
2799
2833
  y: 0
@@ -2803,13 +2837,15 @@
2803
2837
  return;
2804
2838
  }
2805
2839
 
2806
- if (checkMainAxis || checkAltAxis) {
2840
+ if (checkMainAxis) {
2841
+ var _offsetModifierState$;
2842
+
2807
2843
  var mainSide = mainAxis === 'y' ? top : left;
2808
2844
  var altSide = mainAxis === 'y' ? bottom : right;
2809
2845
  var len = mainAxis === 'y' ? 'height' : 'width';
2810
2846
  var offset = popperOffsets[mainAxis];
2811
- var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
2812
- var max$1 = popperOffsets[mainAxis] - overflow[altSide];
2847
+ var min$1 = offset + overflow[mainSide];
2848
+ var max$1 = offset - overflow[altSide];
2813
2849
  var additive = tether ? -popperRect[len] / 2 : 0;
2814
2850
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
2815
2851
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
@@ -2829,36 +2865,45 @@
2829
2865
  // width or height)
2830
2866
 
2831
2867
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
2832
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
2833
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
2868
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
2869
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
2834
2870
  var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
2835
2871
  var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
2836
- var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
2837
- var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
2838
- var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
2872
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
2873
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
2874
+ var tetherMax = offset + maxOffset - offsetModifierValue;
2875
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
2876
+ popperOffsets[mainAxis] = preventedOffset;
2877
+ data[mainAxis] = preventedOffset - offset;
2878
+ }
2839
2879
 
2840
- if (checkMainAxis) {
2841
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
2842
- popperOffsets[mainAxis] = preventedOffset;
2843
- data[mainAxis] = preventedOffset - offset;
2844
- }
2880
+ if (checkAltAxis) {
2881
+ var _offsetModifierState$2;
2845
2882
 
2846
- if (checkAltAxis) {
2847
- var _mainSide = mainAxis === 'x' ? top : left;
2883
+ var _mainSide = mainAxis === 'x' ? top : left;
2848
2884
 
2849
- var _altSide = mainAxis === 'x' ? bottom : right;
2885
+ var _altSide = mainAxis === 'x' ? bottom : right;
2850
2886
 
2851
- var _offset = popperOffsets[altAxis];
2887
+ var _offset = popperOffsets[altAxis];
2852
2888
 
2853
- var _min = _offset + overflow[_mainSide];
2889
+ var _len = altAxis === 'y' ? 'height' : 'width';
2854
2890
 
2855
- var _max = _offset - overflow[_altSide];
2891
+ var _min = _offset + overflow[_mainSide];
2856
2892
 
2857
- var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
2893
+ var _max = _offset - overflow[_altSide];
2858
2894
 
2859
- popperOffsets[altAxis] = _preventedOffset;
2860
- data[altAxis] = _preventedOffset - _offset;
2861
- }
2895
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
2896
+
2897
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
2898
+
2899
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
2900
+
2901
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
2902
+
2903
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
2904
+
2905
+ popperOffsets[altAxis] = _preventedOffset;
2906
+ data[altAxis] = _preventedOffset - _offset;
2862
2907
  }
2863
2908
 
2864
2909
  state.modifiersData[name] = data;
@@ -2890,8 +2935,8 @@
2890
2935
 
2891
2936
  function isElementScaled(element) {
2892
2937
  var rect = element.getBoundingClientRect();
2893
- var scaleX = rect.width / element.offsetWidth || 1;
2894
- var scaleY = rect.height / element.offsetHeight || 1;
2938
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
2939
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
2895
2940
  return scaleX !== 1 || scaleY !== 1;
2896
2941
  } // Returns the composite rect of an element relative to its offsetParent.
2897
2942
  // Composite means it takes into account transforms as well as layout.
@@ -2903,9 +2948,9 @@
2903
2948
  }
2904
2949
 
2905
2950
  var isOffsetParentAnElement = isHTMLElement(offsetParent);
2906
- isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2951
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2907
2952
  var documentElement = getDocumentElement(offsetParent);
2908
- var rect = getBoundingClientRect(elementOrVirtualElement);
2953
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
2909
2954
  var scroll = {
2910
2955
  scrollLeft: 0,
2911
2956
  scrollTop: 0
@@ -2922,7 +2967,7 @@
2922
2967
  }
2923
2968
 
2924
2969
  if (isHTMLElement(offsetParent)) {
2925
- offsets = getBoundingClientRect(offsetParent);
2970
+ offsets = getBoundingClientRect(offsetParent, true);
2926
2971
  offsets.x += offsetParent.clientLeft;
2927
2972
  offsets.y += offsetParent.clientTop;
2928
2973
  } else if (documentElement) {