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.
@@ -120,6 +120,28 @@
120
120
  this.target = null;
121
121
  };
122
122
 
123
+ _proto.refresh = function refresh() {
124
+ // Check if a target has been set
125
+ if (!this.target) return; // Remove existing events
126
+
127
+ this.target.removeEventListener('keydown', this.__handlerFocusTrap);
128
+ this.target.removeEventListener('keydown', this.handlerFocusLock); // Get the focusable elements
129
+
130
+ this.focusable = this.getFocusable(); // Setup the focus handlers based on focusable length
131
+
132
+ if (this.focusable.length) {
133
+ // If there are focusable elements, setup focus trap
134
+ this.focusableFirst = this.focusable[0];
135
+ this.focusableLast = this.focusable[this.focusable.length - 1];
136
+ this.target.addEventListener('keydown', this.__handlerFocusTrap);
137
+ } else {
138
+ // If there are no focusable elements, setup focus lock
139
+ this.focusableFirst = null;
140
+ this.focusableLast = null;
141
+ this.target.addEventListener('keydown', this.handlerFocusLock);
142
+ }
143
+ };
144
+
123
145
  _proto.handlerFocusTrap = function handlerFocusTrap(event) {
124
146
  var isTab = event.key === 'Tab' || event.keyCode === 9;
125
147
  if (!isTab) return;
@@ -881,6 +903,7 @@
881
903
 
882
904
  focusTarget(drawer, _this4.settings);
883
905
  drawer.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'opened', {
906
+ detail: _this4,
884
907
  bubbles: true
885
908
  }));
886
909
  _this4.working = false;
@@ -919,6 +942,7 @@
919
942
  _this6.focusTrap.destroy();
920
943
 
921
944
  drawer.dispatchEvent(new CustomEvent(_this6.settings.customEventPrefix + 'closed', {
945
+ detail: _this6,
922
946
  bubbles: true
923
947
  }));
924
948
  _this6.working = false;
@@ -965,10 +989,6 @@
965
989
 
966
990
  var handlerClick$1 = function handlerClick(event) {
967
991
  try {
968
- var _exit2;
969
-
970
- var _this2 = this;
971
-
972
992
  var _temp3 = function _temp3(_result) {
973
993
  if (_exit2) return _result;
974
994
 
@@ -987,6 +1007,10 @@
987
1007
  }
988
1008
  };
989
1009
 
1010
+ var _exit2;
1011
+
1012
+ var _this2 = this;
1013
+
990
1014
  // Working catch
991
1015
  if (_this2.working) return Promise.resolve(); // Trigger click
992
1016
 
@@ -1153,6 +1177,7 @@
1153
1177
  focusTarget(modal, _this2.settings);
1154
1178
  setInert(true, _this2.settings.selectorInert);
1155
1179
  modal.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'opened', {
1180
+ detail: _this2,
1156
1181
  bubbles: true
1157
1182
  }));
1158
1183
  _this2.working = false;
@@ -1186,6 +1211,7 @@
1186
1211
  _this4.focusTrap.destroy();
1187
1212
 
1188
1213
  modal.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'closed', {
1214
+ detail: _this4,
1189
1215
  bubbles: true
1190
1216
  }));
1191
1217
  _this4.working = false;
@@ -1601,17 +1627,39 @@
1601
1627
  return placement.split('-')[0];
1602
1628
  }
1603
1629
 
1604
- function getBoundingClientRect(element) {
1630
+ // import { isHTMLElement } from './instanceOf';
1631
+ function getBoundingClientRect(element, // eslint-disable-next-line unused-imports/no-unused-vars
1632
+ includeScale) {
1633
+
1605
1634
  var rect = element.getBoundingClientRect();
1635
+ 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
+ // }
1653
+
1606
1654
  return {
1607
- width: rect.width,
1608
- height: rect.height,
1609
- top: rect.top,
1610
- right: rect.right,
1611
- bottom: rect.bottom,
1612
- left: rect.left,
1613
- x: rect.left,
1614
- y: rect.top
1655
+ width: rect.width / scaleX,
1656
+ height: rect.height / scaleY,
1657
+ top: rect.top / scaleY,
1658
+ right: rect.right / scaleX,
1659
+ bottom: rect.bottom / scaleY,
1660
+ left: rect.left / scaleX,
1661
+ x: rect.left / scaleX,
1662
+ y: rect.top / scaleY
1615
1663
  };
1616
1664
  }
1617
1665
 
@@ -1866,6 +1914,10 @@
1866
1914
  requiresIfExists: ['preventOverflow']
1867
1915
  };
1868
1916
 
1917
+ function getVariation(placement) {
1918
+ return placement.split('-')[1];
1919
+ }
1920
+
1869
1921
  var unsetSides = {
1870
1922
  top: 'auto',
1871
1923
  right: 'auto',
@@ -1892,6 +1944,7 @@
1892
1944
  var popper = _ref2.popper,
1893
1945
  popperRect = _ref2.popperRect,
1894
1946
  placement = _ref2.placement,
1947
+ variation = _ref2.variation,
1895
1948
  offsets = _ref2.offsets,
1896
1949
  position = _ref2.position,
1897
1950
  gpuAcceleration = _ref2.gpuAcceleration,
@@ -1918,7 +1971,7 @@
1918
1971
  if (offsetParent === getWindow(popper)) {
1919
1972
  offsetParent = getDocumentElement(popper);
1920
1973
 
1921
- if (getComputedStyle$1(offsetParent).position !== 'static') {
1974
+ if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
1922
1975
  heightProp = 'scrollHeight';
1923
1976
  widthProp = 'scrollWidth';
1924
1977
  }
@@ -1927,14 +1980,14 @@
1927
1980
 
1928
1981
  offsetParent = offsetParent;
1929
1982
 
1930
- if (placement === top) {
1983
+ if (placement === top || (placement === left || placement === right) && variation === end) {
1931
1984
  sideY = bottom; // $FlowFixMe[prop-missing]
1932
1985
 
1933
1986
  y -= offsetParent[heightProp] - popperRect.height;
1934
1987
  y *= gpuAcceleration ? 1 : -1;
1935
1988
  }
1936
1989
 
1937
- if (placement === left) {
1990
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
1938
1991
  sideX = right; // $FlowFixMe[prop-missing]
1939
1992
 
1940
1993
  x -= offsetParent[widthProp] - popperRect.width;
@@ -1949,7 +2002,7 @@
1949
2002
  if (gpuAcceleration) {
1950
2003
  var _Object$assign;
1951
2004
 
1952
- 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));
2005
+ 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));
1953
2006
  }
1954
2007
 
1955
2008
  return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
@@ -1967,6 +2020,7 @@
1967
2020
 
1968
2021
  var commonStyles = {
1969
2022
  placement: getBasePlacement(state.placement),
2023
+ variation: getVariation(state.placement),
1970
2024
  popper: state.elements.popper,
1971
2025
  popperRect: state.rects.popper,
1972
2026
  gpuAcceleration: gpuAcceleration
@@ -2269,10 +2323,6 @@
2269
2323
  return clippingRect;
2270
2324
  }
2271
2325
 
2272
- function getVariation(placement) {
2273
- return placement.split('-')[1];
2274
- }
2275
-
2276
2326
  function computeOffsets(_ref) {
2277
2327
  var reference = _ref.reference,
2278
2328
  element = _ref.element,
@@ -2358,11 +2408,10 @@
2358
2408
  padding = _options$padding === void 0 ? 0 : _options$padding;
2359
2409
  var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
2360
2410
  var altContext = elementContext === popper ? reference : popper;
2361
- var referenceElement = state.elements.reference;
2362
2411
  var popperRect = state.rects.popper;
2363
2412
  var element = state.elements[altBoundary ? altContext : elementContext];
2364
2413
  var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
2365
- var referenceClientRect = getBoundingClientRect(referenceElement);
2414
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
2366
2415
  var popperOffsets = computeOffsets({
2367
2416
  reference: referenceClientRect,
2368
2417
  element: popperRect,
@@ -2839,16 +2888,24 @@
2839
2888
  }
2840
2889
  }
2841
2890
 
2891
+ function isElementScaled(element) {
2892
+ var rect = element.getBoundingClientRect();
2893
+ var scaleX = rect.width / element.offsetWidth || 1;
2894
+ var scaleY = rect.height / element.offsetHeight || 1;
2895
+ return scaleX !== 1 || scaleY !== 1;
2896
+ } // Returns the composite rect of an element relative to its offsetParent.
2842
2897
  // Composite means it takes into account transforms as well as layout.
2843
2898
 
2899
+
2844
2900
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2845
2901
  if (isFixed === void 0) {
2846
2902
  isFixed = false;
2847
2903
  }
2848
2904
 
2905
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
2906
+ isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2849
2907
  var documentElement = getDocumentElement(offsetParent);
2850
2908
  var rect = getBoundingClientRect(elementOrVirtualElement);
2851
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
2852
2909
  var scroll = {
2853
2910
  scrollLeft: 0,
2854
2911
  scrollTop: 0
@@ -3002,7 +3059,8 @@
3002
3059
  var isDestroyed = false;
3003
3060
  var instance = {
3004
3061
  state: state,
3005
- setOptions: function setOptions(options) {
3062
+ setOptions: function setOptions(setOptionsAction) {
3063
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
3006
3064
  cleanupModifierEffects();
3007
3065
  state.options = Object.assign({}, defaultOptions, state.options, options);
3008
3066
  state.scrollParents = {