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.
package/dev/scripts.js CHANGED
@@ -1622,29 +1622,32 @@ function getBasePlacement(placement) {
1622
1622
  return placement.split('-')[0];
1623
1623
  }
1624
1624
 
1625
- // import { isHTMLElement } from './instanceOf';
1626
- function getBoundingClientRect(element, // eslint-disable-next-line unused-imports/no-unused-vars
1627
- includeScale) {
1625
+ var max = Math.max;
1626
+ var min = Math.min;
1627
+ var round = Math.round;
1628
+
1629
+ function getBoundingClientRect(element, includeScale) {
1630
+ if (includeScale === void 0) {
1631
+ includeScale = false;
1632
+ }
1628
1633
 
1629
1634
  var rect = element.getBoundingClientRect();
1630
1635
  var scaleX = 1;
1631
- var scaleY = 1; // FIXME:
1632
- // `offsetWidth` returns an integer while `getBoundingClientRect`
1633
- // returns a float. This results in `scaleX` or `scaleY` being
1634
- // non-1 when it should be for elements that aren't a full pixel in
1635
- // width or height.
1636
- // if (isHTMLElement(element) && includeScale) {
1637
- // const offsetHeight = element.offsetHeight;
1638
- // const offsetWidth = element.offsetWidth;
1639
- // // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
1640
- // // Fallback to 1 in case both values are `0`
1641
- // if (offsetWidth > 0) {
1642
- // scaleX = rect.width / offsetWidth || 1;
1643
- // }
1644
- // if (offsetHeight > 0) {
1645
- // scaleY = rect.height / offsetHeight || 1;
1646
- // }
1647
- // }
1636
+ var scaleY = 1;
1637
+
1638
+ if (isHTMLElement(element) && includeScale) {
1639
+ var offsetHeight = element.offsetHeight;
1640
+ var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
1641
+ // Fallback to 1 in case both values are `0`
1642
+
1643
+ if (offsetWidth > 0) {
1644
+ scaleX = round(rect.width) / offsetWidth || 1;
1645
+ }
1646
+
1647
+ if (offsetHeight > 0) {
1648
+ scaleY = round(rect.height) / offsetHeight || 1;
1649
+ }
1650
+ }
1648
1651
 
1649
1652
  return {
1650
1653
  width: rect.width / scaleX,
@@ -1799,13 +1802,13 @@ function getMainAxisFromPlacement(placement) {
1799
1802
  return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
1800
1803
  }
1801
1804
 
1802
- var max = Math.max;
1803
- var min = Math.min;
1804
- var round = Math.round;
1805
-
1806
1805
  function within(min$1, value, max$1) {
1807
1806
  return max(min$1, min(value, max$1));
1808
1807
  }
1808
+ function withinMaxClamp(min, value, max) {
1809
+ var v = within(min, value, max);
1810
+ return v > max ? max : v;
1811
+ }
1809
1812
 
1810
1813
  function getFreshSideObject() {
1811
1814
  return {
@@ -1928,8 +1931,8 @@ function roundOffsetsByDPR(_ref) {
1928
1931
  var win = window;
1929
1932
  var dpr = win.devicePixelRatio || 1;
1930
1933
  return {
1931
- x: round(round(x * dpr) / dpr) || 0,
1932
- y: round(round(y * dpr) / dpr) || 0
1934
+ x: round(x * dpr) / dpr || 0,
1935
+ y: round(y * dpr) / dpr || 0
1933
1936
  };
1934
1937
  }
1935
1938
 
@@ -1944,14 +1947,23 @@ function mapToStyles(_ref2) {
1944
1947
  position = _ref2.position,
1945
1948
  gpuAcceleration = _ref2.gpuAcceleration,
1946
1949
  adaptive = _ref2.adaptive,
1947
- roundOffsets = _ref2.roundOffsets;
1948
-
1949
- var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
1950
- _ref3$x = _ref3.x,
1951
- x = _ref3$x === void 0 ? 0 : _ref3$x,
1952
- _ref3$y = _ref3.y,
1953
- y = _ref3$y === void 0 ? 0 : _ref3$y;
1950
+ roundOffsets = _ref2.roundOffsets,
1951
+ isFixed = _ref2.isFixed;
1952
+ var _offsets$x = offsets.x,
1953
+ x = _offsets$x === void 0 ? 0 : _offsets$x,
1954
+ _offsets$y = offsets.y,
1955
+ y = _offsets$y === void 0 ? 0 : _offsets$y;
1956
+
1957
+ var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
1958
+ x: x,
1959
+ y: y
1960
+ }) : {
1961
+ x: x,
1962
+ y: y
1963
+ };
1954
1964
 
1965
+ x = _ref3.x;
1966
+ y = _ref3.y;
1955
1967
  var hasX = offsets.hasOwnProperty('x');
1956
1968
  var hasY = offsets.hasOwnProperty('y');
1957
1969
  var sideX = left;
@@ -1976,16 +1988,18 @@ function mapToStyles(_ref2) {
1976
1988
  offsetParent = offsetParent;
1977
1989
 
1978
1990
  if (placement === top || (placement === left || placement === right) && variation === end) {
1979
- sideY = bottom; // $FlowFixMe[prop-missing]
1980
-
1981
- y -= offsetParent[heightProp] - popperRect.height;
1991
+ sideY = bottom;
1992
+ var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
1993
+ offsetParent[heightProp];
1994
+ y -= offsetY - popperRect.height;
1982
1995
  y *= gpuAcceleration ? 1 : -1;
1983
1996
  }
1984
1997
 
1985
1998
  if (placement === left || (placement === top || placement === bottom) && variation === end) {
1986
- sideX = right; // $FlowFixMe[prop-missing]
1987
-
1988
- x -= offsetParent[widthProp] - popperRect.width;
1999
+ sideX = right;
2000
+ var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
2001
+ offsetParent[widthProp];
2002
+ x -= offsetX - popperRect.width;
1989
2003
  x *= gpuAcceleration ? 1 : -1;
1990
2004
  }
1991
2005
  }
@@ -1994,6 +2008,17 @@ function mapToStyles(_ref2) {
1994
2008
  position: position
1995
2009
  }, adaptive && unsetSides);
1996
2010
 
2011
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
2012
+ x: x,
2013
+ y: y
2014
+ }) : {
2015
+ x: x,
2016
+ y: y
2017
+ };
2018
+
2019
+ x = _ref4.x;
2020
+ y = _ref4.y;
2021
+
1997
2022
  if (gpuAcceleration) {
1998
2023
  var _Object$assign;
1999
2024
 
@@ -2003,9 +2028,9 @@ function mapToStyles(_ref2) {
2003
2028
  return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
2004
2029
  }
2005
2030
 
2006
- function computeStyles(_ref4) {
2007
- var state = _ref4.state,
2008
- options = _ref4.options;
2031
+ function computeStyles(_ref5) {
2032
+ var state = _ref5.state,
2033
+ options = _ref5.options;
2009
2034
  var _options$gpuAccelerat = options.gpuAcceleration,
2010
2035
  gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
2011
2036
  _options$adaptive = options.adaptive,
@@ -2018,7 +2043,8 @@ function computeStyles(_ref4) {
2018
2043
  variation: getVariation(state.placement),
2019
2044
  popper: state.elements.popper,
2020
2045
  popperRect: state.rects.popper,
2021
- gpuAcceleration: gpuAcceleration
2046
+ gpuAcceleration: gpuAcceleration,
2047
+ isFixed: state.options.strategy === 'fixed'
2022
2048
  };
2023
2049
 
2024
2050
  if (state.modifiersData.popperOffsets != null) {
@@ -2276,7 +2302,7 @@ function getInnerBoundingClientRect(element) {
2276
2302
  }
2277
2303
 
2278
2304
  function getClientRectFromMixedType(element, clippingParent) {
2279
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2305
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2280
2306
  } // A "clipping parent" is an overflowable container with the characteristic of
2281
2307
  // clipping (or hiding) overflowing elements with a position different from
2282
2308
  // `initial`
@@ -2789,6 +2815,14 @@ function preventOverflow(_ref) {
2789
2815
  var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
2790
2816
  placement: state.placement
2791
2817
  })) : tetherOffset;
2818
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
2819
+ mainAxis: tetherOffsetValue,
2820
+ altAxis: tetherOffsetValue
2821
+ } : Object.assign({
2822
+ mainAxis: 0,
2823
+ altAxis: 0
2824
+ }, tetherOffsetValue);
2825
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
2792
2826
  var data = {
2793
2827
  x: 0,
2794
2828
  y: 0
@@ -2798,13 +2832,15 @@ function preventOverflow(_ref) {
2798
2832
  return;
2799
2833
  }
2800
2834
 
2801
- if (checkMainAxis || checkAltAxis) {
2835
+ if (checkMainAxis) {
2836
+ var _offsetModifierState$;
2837
+
2802
2838
  var mainSide = mainAxis === 'y' ? top : left;
2803
2839
  var altSide = mainAxis === 'y' ? bottom : right;
2804
2840
  var len = mainAxis === 'y' ? 'height' : 'width';
2805
2841
  var offset = popperOffsets[mainAxis];
2806
- var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
2807
- var max$1 = popperOffsets[mainAxis] - overflow[altSide];
2842
+ var min$1 = offset + overflow[mainSide];
2843
+ var max$1 = offset - overflow[altSide];
2808
2844
  var additive = tether ? -popperRect[len] / 2 : 0;
2809
2845
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
2810
2846
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
@@ -2824,36 +2860,45 @@ function preventOverflow(_ref) {
2824
2860
  // width or height)
2825
2861
 
2826
2862
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
2827
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
2828
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
2863
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
2864
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
2829
2865
  var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
2830
2866
  var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
2831
- var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
2832
- var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
2833
- var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
2867
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
2868
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
2869
+ var tetherMax = offset + maxOffset - offsetModifierValue;
2870
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
2871
+ popperOffsets[mainAxis] = preventedOffset;
2872
+ data[mainAxis] = preventedOffset - offset;
2873
+ }
2834
2874
 
2835
- if (checkMainAxis) {
2836
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
2837
- popperOffsets[mainAxis] = preventedOffset;
2838
- data[mainAxis] = preventedOffset - offset;
2839
- }
2875
+ if (checkAltAxis) {
2876
+ var _offsetModifierState$2;
2840
2877
 
2841
- if (checkAltAxis) {
2842
- var _mainSide = mainAxis === 'x' ? top : left;
2878
+ var _mainSide = mainAxis === 'x' ? top : left;
2843
2879
 
2844
- var _altSide = mainAxis === 'x' ? bottom : right;
2880
+ var _altSide = mainAxis === 'x' ? bottom : right;
2845
2881
 
2846
- var _offset = popperOffsets[altAxis];
2882
+ var _offset = popperOffsets[altAxis];
2847
2883
 
2848
- var _min = _offset + overflow[_mainSide];
2884
+ var _len = altAxis === 'y' ? 'height' : 'width';
2849
2885
 
2850
- var _max = _offset - overflow[_altSide];
2886
+ var _min = _offset + overflow[_mainSide];
2851
2887
 
2852
- var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
2888
+ var _max = _offset - overflow[_altSide];
2853
2889
 
2854
- popperOffsets[altAxis] = _preventedOffset;
2855
- data[altAxis] = _preventedOffset - _offset;
2856
- }
2890
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
2891
+
2892
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
2893
+
2894
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
2895
+
2896
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
2897
+
2898
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
2899
+
2900
+ popperOffsets[altAxis] = _preventedOffset;
2901
+ data[altAxis] = _preventedOffset - _offset;
2857
2902
  }
2858
2903
 
2859
2904
  state.modifiersData[name] = data;
@@ -2885,8 +2930,8 @@ function getNodeScroll(node) {
2885
2930
 
2886
2931
  function isElementScaled(element) {
2887
2932
  var rect = element.getBoundingClientRect();
2888
- var scaleX = rect.width / element.offsetWidth || 1;
2889
- var scaleY = rect.height / element.offsetHeight || 1;
2933
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
2934
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
2890
2935
  return scaleX !== 1 || scaleY !== 1;
2891
2936
  } // Returns the composite rect of an element relative to its offsetParent.
2892
2937
  // Composite means it takes into account transforms as well as layout.
@@ -2898,9 +2943,9 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2898
2943
  }
2899
2944
 
2900
2945
  var isOffsetParentAnElement = isHTMLElement(offsetParent);
2901
- isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2946
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2902
2947
  var documentElement = getDocumentElement(offsetParent);
2903
- var rect = getBoundingClientRect(elementOrVirtualElement);
2948
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
2904
2949
  var scroll = {
2905
2950
  scrollLeft: 0,
2906
2951
  scrollTop: 0
@@ -2917,7 +2962,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2917
2962
  }
2918
2963
 
2919
2964
  if (isHTMLElement(offsetParent)) {
2920
- offsets = getBoundingClientRect(offsetParent);
2965
+ offsets = getBoundingClientRect(offsetParent, true);
2921
2966
  offsets.x += offsetParent.clientLeft;
2922
2967
  offsets.y += offsetParent.clientTop;
2923
2968
  } else if (documentElement) {