vrembem 1.36.1 → 1.37.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
@@ -115,6 +115,28 @@ var FocusTrap = /*#__PURE__*/function () {
115
115
  this.target = null;
116
116
  };
117
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
+
118
140
  _proto.handlerFocusTrap = function handlerFocusTrap(event) {
119
141
  var isTab = event.key === 'Tab' || event.keyCode === 9;
120
142
  if (!isTab) return;
@@ -876,6 +898,7 @@ var Drawer = /*#__PURE__*/function () {
876
898
 
877
899
  focusTarget(drawer, _this4.settings);
878
900
  drawer.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'opened', {
901
+ detail: _this4,
879
902
  bubbles: true
880
903
  }));
881
904
  _this4.working = false;
@@ -914,6 +937,7 @@ var Drawer = /*#__PURE__*/function () {
914
937
  _this6.focusTrap.destroy();
915
938
 
916
939
  drawer.dispatchEvent(new CustomEvent(_this6.settings.customEventPrefix + 'closed', {
940
+ detail: _this6,
917
941
  bubbles: true
918
942
  }));
919
943
  _this6.working = false;
@@ -960,10 +984,6 @@ var defaults$1 = {
960
984
 
961
985
  var handlerClick$1 = function handlerClick(event) {
962
986
  try {
963
- var _exit2;
964
-
965
- var _this2 = this;
966
-
967
987
  var _temp3 = function _temp3(_result) {
968
988
  if (_exit2) return _result;
969
989
 
@@ -982,6 +1002,10 @@ var handlerClick$1 = function handlerClick(event) {
982
1002
  }
983
1003
  };
984
1004
 
1005
+ var _exit2;
1006
+
1007
+ var _this2 = this;
1008
+
985
1009
  // Working catch
986
1010
  if (_this2.working) return Promise.resolve(); // Trigger click
987
1011
 
@@ -1148,6 +1172,7 @@ var Modal = /*#__PURE__*/function () {
1148
1172
  focusTarget(modal, _this2.settings);
1149
1173
  setInert(true, _this2.settings.selectorInert);
1150
1174
  modal.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'opened', {
1175
+ detail: _this2,
1151
1176
  bubbles: true
1152
1177
  }));
1153
1178
  _this2.working = false;
@@ -1181,6 +1206,7 @@ var Modal = /*#__PURE__*/function () {
1181
1206
  _this4.focusTrap.destroy();
1182
1207
 
1183
1208
  modal.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'closed', {
1209
+ detail: _this4,
1184
1210
  bubbles: true
1185
1211
  }));
1186
1212
  _this4.working = false;
@@ -1596,17 +1622,39 @@ function getBasePlacement(placement) {
1596
1622
  return placement.split('-')[0];
1597
1623
  }
1598
1624
 
1599
- function getBoundingClientRect(element) {
1625
+ // import { isHTMLElement } from './instanceOf';
1626
+ function getBoundingClientRect(element, // eslint-disable-next-line unused-imports/no-unused-vars
1627
+ includeScale) {
1628
+
1600
1629
  var rect = element.getBoundingClientRect();
1630
+ 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
+ // }
1648
+
1601
1649
  return {
1602
- width: rect.width,
1603
- height: rect.height,
1604
- top: rect.top,
1605
- right: rect.right,
1606
- bottom: rect.bottom,
1607
- left: rect.left,
1608
- x: rect.left,
1609
- y: rect.top
1650
+ width: rect.width / scaleX,
1651
+ height: rect.height / scaleY,
1652
+ top: rect.top / scaleY,
1653
+ right: rect.right / scaleX,
1654
+ bottom: rect.bottom / scaleY,
1655
+ left: rect.left / scaleX,
1656
+ x: rect.left / scaleX,
1657
+ y: rect.top / scaleY
1610
1658
  };
1611
1659
  }
1612
1660
 
@@ -1861,6 +1909,10 @@ var arrow$1 = {
1861
1909
  requiresIfExists: ['preventOverflow']
1862
1910
  };
1863
1911
 
1912
+ function getVariation(placement) {
1913
+ return placement.split('-')[1];
1914
+ }
1915
+
1864
1916
  var unsetSides = {
1865
1917
  top: 'auto',
1866
1918
  right: 'auto',
@@ -1887,6 +1939,7 @@ function mapToStyles(_ref2) {
1887
1939
  var popper = _ref2.popper,
1888
1940
  popperRect = _ref2.popperRect,
1889
1941
  placement = _ref2.placement,
1942
+ variation = _ref2.variation,
1890
1943
  offsets = _ref2.offsets,
1891
1944
  position = _ref2.position,
1892
1945
  gpuAcceleration = _ref2.gpuAcceleration,
@@ -1913,7 +1966,7 @@ function mapToStyles(_ref2) {
1913
1966
  if (offsetParent === getWindow(popper)) {
1914
1967
  offsetParent = getDocumentElement(popper);
1915
1968
 
1916
- if (getComputedStyle$1(offsetParent).position !== 'static') {
1969
+ if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
1917
1970
  heightProp = 'scrollHeight';
1918
1971
  widthProp = 'scrollWidth';
1919
1972
  }
@@ -1922,14 +1975,14 @@ function mapToStyles(_ref2) {
1922
1975
 
1923
1976
  offsetParent = offsetParent;
1924
1977
 
1925
- if (placement === top) {
1978
+ if (placement === top || (placement === left || placement === right) && variation === end) {
1926
1979
  sideY = bottom; // $FlowFixMe[prop-missing]
1927
1980
 
1928
1981
  y -= offsetParent[heightProp] - popperRect.height;
1929
1982
  y *= gpuAcceleration ? 1 : -1;
1930
1983
  }
1931
1984
 
1932
- if (placement === left) {
1985
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
1933
1986
  sideX = right; // $FlowFixMe[prop-missing]
1934
1987
 
1935
1988
  x -= offsetParent[widthProp] - popperRect.width;
@@ -1944,7 +1997,7 @@ function mapToStyles(_ref2) {
1944
1997
  if (gpuAcceleration) {
1945
1998
  var _Object$assign;
1946
1999
 
1947
- 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));
2000
+ 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));
1948
2001
  }
1949
2002
 
1950
2003
  return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
@@ -1962,6 +2015,7 @@ function computeStyles(_ref4) {
1962
2015
 
1963
2016
  var commonStyles = {
1964
2017
  placement: getBasePlacement(state.placement),
2018
+ variation: getVariation(state.placement),
1965
2019
  popper: state.elements.popper,
1966
2020
  popperRect: state.rects.popper,
1967
2021
  gpuAcceleration: gpuAcceleration
@@ -2264,10 +2318,6 @@ function getClippingRect(element, boundary, rootBoundary) {
2264
2318
  return clippingRect;
2265
2319
  }
2266
2320
 
2267
- function getVariation(placement) {
2268
- return placement.split('-')[1];
2269
- }
2270
-
2271
2321
  function computeOffsets(_ref) {
2272
2322
  var reference = _ref.reference,
2273
2323
  element = _ref.element,
@@ -2353,11 +2403,10 @@ function detectOverflow(state, options) {
2353
2403
  padding = _options$padding === void 0 ? 0 : _options$padding;
2354
2404
  var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
2355
2405
  var altContext = elementContext === popper ? reference : popper;
2356
- var referenceElement = state.elements.reference;
2357
2406
  var popperRect = state.rects.popper;
2358
2407
  var element = state.elements[altBoundary ? altContext : elementContext];
2359
2408
  var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
2360
- var referenceClientRect = getBoundingClientRect(referenceElement);
2409
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
2361
2410
  var popperOffsets = computeOffsets({
2362
2411
  reference: referenceClientRect,
2363
2412
  element: popperRect,
@@ -2834,16 +2883,24 @@ function getNodeScroll(node) {
2834
2883
  }
2835
2884
  }
2836
2885
 
2886
+ function isElementScaled(element) {
2887
+ var rect = element.getBoundingClientRect();
2888
+ var scaleX = rect.width / element.offsetWidth || 1;
2889
+ var scaleY = rect.height / element.offsetHeight || 1;
2890
+ return scaleX !== 1 || scaleY !== 1;
2891
+ } // Returns the composite rect of an element relative to its offsetParent.
2837
2892
  // Composite means it takes into account transforms as well as layout.
2838
2893
 
2894
+
2839
2895
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2840
2896
  if (isFixed === void 0) {
2841
2897
  isFixed = false;
2842
2898
  }
2843
2899
 
2900
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
2901
+ isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2844
2902
  var documentElement = getDocumentElement(offsetParent);
2845
2903
  var rect = getBoundingClientRect(elementOrVirtualElement);
2846
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
2847
2904
  var scroll = {
2848
2905
  scrollLeft: 0,
2849
2906
  scrollTop: 0
@@ -2997,7 +3054,8 @@ function popperGenerator(generatorOptions) {
2997
3054
  var isDestroyed = false;
2998
3055
  var instance = {
2999
3056
  state: state,
3000
- setOptions: function setOptions(options) {
3057
+ setOptions: function setOptions(setOptionsAction) {
3058
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
3001
3059
  cleanupModifierEffects();
3002
3060
  state.options = Object.assign({}, defaultOptions, state.options, options);
3003
3061
  state.scrollParents = {