vrembem 1.35.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
@@ -61,6 +61,8 @@ var camelCase = function camelCase(str) {
61
61
  });
62
62
  };
63
63
 
64
+ var focusableSelectors = ['a[href]:not([tabindex^="-"])', 'area[href]:not([tabindex^="-"])', 'input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])', 'input[type="radio"]:not([disabled]):not([tabindex^="-"])', 'select:not([disabled]):not([tabindex^="-"])', 'textarea:not([disabled]):not([tabindex^="-"])', 'button:not([disabled]):not([tabindex^="-"])', 'iframe:not([tabindex^="-"])', 'audio[controls]:not([tabindex^="-"])', 'video[controls]:not([tabindex^="-"])', '[contenteditable]:not([tabindex^="-"])', '[tabindex]:not([tabindex^="-"])'];
65
+
64
66
  var focusTarget = function focusTarget(target, settings) {
65
67
  var innerFocus = target.querySelector("[data-" + settings.dataFocus + "]");
66
68
 
@@ -113,6 +115,28 @@ var FocusTrap = /*#__PURE__*/function () {
113
115
  this.target = null;
114
116
  };
115
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
+
116
140
  _proto.handlerFocusTrap = function handlerFocusTrap(event) {
117
141
  var isTab = event.key === 'Tab' || event.keyCode === 9;
118
142
  if (!isTab) return;
@@ -139,7 +163,7 @@ var FocusTrap = /*#__PURE__*/function () {
139
163
  var focusable = [];
140
164
  var initFocus = document.activeElement;
141
165
  var initScrollTop = this.inner ? this.inner.scrollTop : 0;
142
- this.target.querySelectorAll('a[href]:not([disabled]),button:not([disabled]),textarea:not([disabled]),input[type="text"]:not([disabled]),input[type="radio"]:not([disabled]),input[type="checkbox"]:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])').forEach(function (el) {
166
+ this.target.querySelectorAll(focusableSelectors.join(',')).forEach(function (el) {
143
167
  el.focus();
144
168
 
145
169
  if (el === document.activeElement) {
@@ -874,6 +898,7 @@ var Drawer = /*#__PURE__*/function () {
874
898
 
875
899
  focusTarget(drawer, _this4.settings);
876
900
  drawer.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'opened', {
901
+ detail: _this4,
877
902
  bubbles: true
878
903
  }));
879
904
  _this4.working = false;
@@ -912,6 +937,7 @@ var Drawer = /*#__PURE__*/function () {
912
937
  _this6.focusTrap.destroy();
913
938
 
914
939
  drawer.dispatchEvent(new CustomEvent(_this6.settings.customEventPrefix + 'closed', {
940
+ detail: _this6,
915
941
  bubbles: true
916
942
  }));
917
943
  _this6.working = false;
@@ -958,10 +984,6 @@ var defaults$1 = {
958
984
 
959
985
  var handlerClick$1 = function handlerClick(event) {
960
986
  try {
961
- var _exit2;
962
-
963
- var _this2 = this;
964
-
965
987
  var _temp3 = function _temp3(_result) {
966
988
  if (_exit2) return _result;
967
989
 
@@ -980,6 +1002,10 @@ var handlerClick$1 = function handlerClick(event) {
980
1002
  }
981
1003
  };
982
1004
 
1005
+ var _exit2;
1006
+
1007
+ var _this2 = this;
1008
+
983
1009
  // Working catch
984
1010
  if (_this2.working) return Promise.resolve(); // Trigger click
985
1011
 
@@ -1146,6 +1172,7 @@ var Modal = /*#__PURE__*/function () {
1146
1172
  focusTarget(modal, _this2.settings);
1147
1173
  setInert(true, _this2.settings.selectorInert);
1148
1174
  modal.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'opened', {
1175
+ detail: _this2,
1149
1176
  bubbles: true
1150
1177
  }));
1151
1178
  _this2.working = false;
@@ -1179,6 +1206,7 @@ var Modal = /*#__PURE__*/function () {
1179
1206
  _this4.focusTrap.destroy();
1180
1207
 
1181
1208
  modal.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'closed', {
1209
+ detail: _this4,
1182
1210
  bubbles: true
1183
1211
  }));
1184
1212
  _this4.working = false;
@@ -1594,17 +1622,39 @@ function getBasePlacement(placement) {
1594
1622
  return placement.split('-')[0];
1595
1623
  }
1596
1624
 
1597
- function getBoundingClientRect(element) {
1625
+ // import { isHTMLElement } from './instanceOf';
1626
+ function getBoundingClientRect(element, // eslint-disable-next-line unused-imports/no-unused-vars
1627
+ includeScale) {
1628
+
1598
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
+
1599
1649
  return {
1600
- width: rect.width,
1601
- height: rect.height,
1602
- top: rect.top,
1603
- right: rect.right,
1604
- bottom: rect.bottom,
1605
- left: rect.left,
1606
- x: rect.left,
1607
- 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
1608
1658
  };
1609
1659
  }
1610
1660
 
@@ -1859,6 +1909,10 @@ var arrow$1 = {
1859
1909
  requiresIfExists: ['preventOverflow']
1860
1910
  };
1861
1911
 
1912
+ function getVariation(placement) {
1913
+ return placement.split('-')[1];
1914
+ }
1915
+
1862
1916
  var unsetSides = {
1863
1917
  top: 'auto',
1864
1918
  right: 'auto',
@@ -1885,6 +1939,7 @@ function mapToStyles(_ref2) {
1885
1939
  var popper = _ref2.popper,
1886
1940
  popperRect = _ref2.popperRect,
1887
1941
  placement = _ref2.placement,
1942
+ variation = _ref2.variation,
1888
1943
  offsets = _ref2.offsets,
1889
1944
  position = _ref2.position,
1890
1945
  gpuAcceleration = _ref2.gpuAcceleration,
@@ -1911,7 +1966,7 @@ function mapToStyles(_ref2) {
1911
1966
  if (offsetParent === getWindow(popper)) {
1912
1967
  offsetParent = getDocumentElement(popper);
1913
1968
 
1914
- if (getComputedStyle$1(offsetParent).position !== 'static') {
1969
+ if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
1915
1970
  heightProp = 'scrollHeight';
1916
1971
  widthProp = 'scrollWidth';
1917
1972
  }
@@ -1920,14 +1975,14 @@ function mapToStyles(_ref2) {
1920
1975
 
1921
1976
  offsetParent = offsetParent;
1922
1977
 
1923
- if (placement === top) {
1978
+ if (placement === top || (placement === left || placement === right) && variation === end) {
1924
1979
  sideY = bottom; // $FlowFixMe[prop-missing]
1925
1980
 
1926
1981
  y -= offsetParent[heightProp] - popperRect.height;
1927
1982
  y *= gpuAcceleration ? 1 : -1;
1928
1983
  }
1929
1984
 
1930
- if (placement === left) {
1985
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
1931
1986
  sideX = right; // $FlowFixMe[prop-missing]
1932
1987
 
1933
1988
  x -= offsetParent[widthProp] - popperRect.width;
@@ -1942,7 +1997,7 @@ function mapToStyles(_ref2) {
1942
1997
  if (gpuAcceleration) {
1943
1998
  var _Object$assign;
1944
1999
 
1945
- 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));
1946
2001
  }
1947
2002
 
1948
2003
  return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
@@ -1960,6 +2015,7 @@ function computeStyles(_ref4) {
1960
2015
 
1961
2016
  var commonStyles = {
1962
2017
  placement: getBasePlacement(state.placement),
2018
+ variation: getVariation(state.placement),
1963
2019
  popper: state.elements.popper,
1964
2020
  popperRect: state.rects.popper,
1965
2021
  gpuAcceleration: gpuAcceleration
@@ -2262,10 +2318,6 @@ function getClippingRect(element, boundary, rootBoundary) {
2262
2318
  return clippingRect;
2263
2319
  }
2264
2320
 
2265
- function getVariation(placement) {
2266
- return placement.split('-')[1];
2267
- }
2268
-
2269
2321
  function computeOffsets(_ref) {
2270
2322
  var reference = _ref.reference,
2271
2323
  element = _ref.element,
@@ -2351,11 +2403,10 @@ function detectOverflow(state, options) {
2351
2403
  padding = _options$padding === void 0 ? 0 : _options$padding;
2352
2404
  var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
2353
2405
  var altContext = elementContext === popper ? reference : popper;
2354
- var referenceElement = state.elements.reference;
2355
2406
  var popperRect = state.rects.popper;
2356
2407
  var element = state.elements[altBoundary ? altContext : elementContext];
2357
2408
  var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
2358
- var referenceClientRect = getBoundingClientRect(referenceElement);
2409
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
2359
2410
  var popperOffsets = computeOffsets({
2360
2411
  reference: referenceClientRect,
2361
2412
  element: popperRect,
@@ -2832,16 +2883,24 @@ function getNodeScroll(node) {
2832
2883
  }
2833
2884
  }
2834
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.
2835
2892
  // Composite means it takes into account transforms as well as layout.
2836
2893
 
2894
+
2837
2895
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2838
2896
  if (isFixed === void 0) {
2839
2897
  isFixed = false;
2840
2898
  }
2841
2899
 
2900
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
2901
+ isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2842
2902
  var documentElement = getDocumentElement(offsetParent);
2843
2903
  var rect = getBoundingClientRect(elementOrVirtualElement);
2844
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
2845
2904
  var scroll = {
2846
2905
  scrollLeft: 0,
2847
2906
  scrollTop: 0
@@ -2995,7 +3054,8 @@ function popperGenerator(generatorOptions) {
2995
3054
  var isDestroyed = false;
2996
3055
  var instance = {
2997
3056
  state: state,
2998
- setOptions: function setOptions(options) {
3057
+ setOptions: function setOptions(setOptionsAction) {
3058
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
2999
3059
  cleanupModifierEffects();
3000
3060
  state.options = Object.assign({}, defaultOptions, state.options, options);
3001
3061
  state.scrollParents = {