vrembem 1.36.1 → 1.40.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.
@@ -106,6 +106,28 @@ class FocusTrap {
106
106
  this.target = null;
107
107
  }
108
108
 
109
+ refresh() {
110
+ // Check if a target has been set
111
+ if (!this.target) return; // Remove existing events
112
+
113
+ this.target.removeEventListener('keydown', this.__handlerFocusTrap);
114
+ this.target.removeEventListener('keydown', this.handlerFocusLock); // Get the focusable elements
115
+
116
+ this.focusable = this.getFocusable(); // Setup the focus handlers based on focusable length
117
+
118
+ if (this.focusable.length) {
119
+ // If there are focusable elements, setup focus trap
120
+ this.focusableFirst = this.focusable[0];
121
+ this.focusableLast = this.focusable[this.focusable.length - 1];
122
+ this.target.addEventListener('keydown', this.__handlerFocusTrap);
123
+ } else {
124
+ // If there are no focusable elements, setup focus lock
125
+ this.focusableFirst = null;
126
+ this.focusableLast = null;
127
+ this.target.addEventListener('keydown', this.handlerFocusLock);
128
+ }
129
+ }
130
+
109
131
  handlerFocusTrap(event) {
110
132
  const isTab = event.key === 'Tab' || event.keyCode === 9;
111
133
  if (!isTab) return;
@@ -307,14 +329,6 @@ const closeTransition = (el, settings) => {
307
329
  });
308
330
  };
309
331
 
310
- const breakpoints = {
311
- xs: '480px',
312
- sm: '620px',
313
- md: '760px',
314
- lg: '990px',
315
- xl: '1380px'
316
- };
317
-
318
332
  var index = {
319
333
  __proto__: null,
320
334
  setInert: setInert,
@@ -332,8 +346,7 @@ var index = {
332
346
  removeClass: removeClass,
333
347
  toggleClass: toggleClass,
334
348
  openTransition: openTransition,
335
- closeTransition: closeTransition,
336
- breakpoints: breakpoints
349
+ closeTransition: closeTransition
337
350
  };
338
351
 
339
352
  function _extends() {
@@ -434,7 +447,7 @@ var defaults$2 = {
434
447
  selectorInert: null,
435
448
  selectorOverflow: null,
436
449
  // Feature toggles
437
- breakpoints: breakpoints,
450
+ breakpoints: null,
438
451
  customEventPrefix: 'drawer:',
439
452
  eventListeners: true,
440
453
  stateSave: true,
@@ -488,6 +501,7 @@ class Breakpoint {
488
501
  constructor(parent) {
489
502
  this.mediaQueryLists = [];
490
503
  this.parent = parent;
504
+ this.prefix = this.getVariablePrefix();
491
505
  this.__check = this.check.bind(this);
492
506
  }
493
507
 
@@ -496,7 +510,7 @@ class Breakpoint {
496
510
  drawers.forEach(drawer => {
497
511
  const id = drawer.getAttribute(`data-${this.parent.settings.dataDrawer}`);
498
512
  const key = drawer.getAttribute(`data-${this.parent.settings.dataBreakpoint}`);
499
- const bp = this.parent.settings.breakpoints[key] ? this.parent.settings.breakpoints[key] : key;
513
+ const bp = this.getBreakpoint(key);
500
514
  const mql = window.matchMedia('(min-width:' + bp + ')');
501
515
  this.match(mql, drawer);
502
516
  mql.addEventListener('change', this.__check);
@@ -541,6 +555,25 @@ class Breakpoint {
541
555
  }
542
556
  }
543
557
 
558
+ getBreakpoint(key) {
559
+ let breakpoint = key;
560
+
561
+ if (this.parent.settings.breakpoints && this.parent.settings.breakpoints[key]) {
562
+ breakpoint = this.parent.settings.breakpoints[key];
563
+ } else if (getComputedStyle(document.body).getPropertyValue(this.prefix + key)) {
564
+ breakpoint = getComputedStyle(document.body).getPropertyValue(this.prefix + key);
565
+ }
566
+
567
+ return breakpoint;
568
+ }
569
+
570
+ getVariablePrefix() {
571
+ let prefix = '--';
572
+ prefix += getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix');
573
+ prefix += 'breakpoint-';
574
+ return prefix;
575
+ }
576
+
544
577
  }
545
578
 
546
579
  function handlerClick$2(event) {
@@ -792,6 +825,7 @@ class Drawer {
792
825
 
793
826
  focusTarget(drawer, this.settings);
794
827
  drawer.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'opened', {
828
+ detail: this,
795
829
  bubbles: true
796
830
  }));
797
831
  this.working = false;
@@ -819,6 +853,7 @@ class Drawer {
819
853
  focusTrigger(this);
820
854
  this.focusTrap.destroy();
821
855
  drawer.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'closed', {
856
+ detail: this,
822
857
  bubbles: true
823
858
  }));
824
859
  this.working = false;
@@ -1012,6 +1047,7 @@ class Modal {
1012
1047
  focusTarget(modal, this.settings);
1013
1048
  setInert(true, this.settings.selectorInert);
1014
1049
  modal.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'opened', {
1050
+ detail: this,
1015
1051
  bubbles: true
1016
1052
  }));
1017
1053
  this.working = false;
@@ -1032,6 +1068,7 @@ class Modal {
1032
1068
  if (returnFocus) focusTrigger(this);
1033
1069
  this.focusTrap.destroy();
1034
1070
  modal.dispatchEvent(new CustomEvent(this.settings.customEventPrefix + 'closed', {
1071
+ detail: this,
1035
1072
  bubbles: true
1036
1073
  }));
1037
1074
  this.working = false;
@@ -1075,7 +1112,12 @@ function hide$2(popover, obj) {
1075
1112
  const index = obj.collection.findIndex(item => {
1076
1113
  return item.target === popover.target;
1077
1114
  });
1078
- obj.collection[index].state = 'hide'; // Return the popover
1115
+ obj.collection[index].state = 'hide'; // Clear the memory if popover trigger matches the ones saved in memory
1116
+
1117
+ if (popover.trigger === obj.memory.trigger) {
1118
+ obj.memory.trigger = null;
1119
+ } // Return the popover
1120
+
1079
1121
 
1080
1122
  return popover;
1081
1123
  }
@@ -1089,7 +1131,9 @@ function hideAll(obj) {
1089
1131
  return obj.collection;
1090
1132
  }
1091
1133
  function hideCheck(popover, obj) {
1092
- // Needed to correctly check which element is currently being focused
1134
+ // Only run hideCheck if provided popover is currently open
1135
+ if (popover.state != 'show') return; // Needed to correctly check which element is currently being focused
1136
+
1093
1137
  setTimeout(() => {
1094
1138
  // Check if trigger or target are being hovered
1095
1139
  const isHovered = popover.target.closest(':hover') === popover.target || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or target are being focused
@@ -1121,7 +1165,8 @@ function getConfig(el, settings) {
1121
1165
 
1122
1166
  for (const prop in config) {
1123
1167
  // Get the CSS variable property values
1124
- const val = styles.getPropertyValue(`--popover-${prop}`).trim(); // If a value was found, replace the default in config obj
1168
+ const prefix = getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix');
1169
+ const val = styles.getPropertyValue(`--${prefix}popover-${prop}`).trim(); // If a value was found, replace the default in config obj
1125
1170
 
1126
1171
  if (val) {
1127
1172
  config[prop] = val;
@@ -1254,13 +1299,29 @@ function handlerClick(popover) {
1254
1299
  if (popover.target.classList.contains(this.settings.stateActive)) {
1255
1300
  hide$2(popover, this);
1256
1301
  } else {
1302
+ this.memory.trigger = popover.trigger;
1257
1303
  show(popover, this);
1258
1304
  documentClick(popover, this);
1259
1305
  }
1260
1306
  }
1261
1307
  function handlerKeydown(event) {
1262
- if (event.key === 'Escape') {
1263
- hideAll(this);
1308
+ switch (event.key) {
1309
+ case 'Escape':
1310
+ if (this.memory.trigger) {
1311
+ this.memory.trigger.focus();
1312
+ }
1313
+
1314
+ hideAll(this);
1315
+ return;
1316
+
1317
+ case 'Tab':
1318
+ this.collection.forEach(popover => {
1319
+ hideCheck(popover, this);
1320
+ });
1321
+ return;
1322
+
1323
+ default:
1324
+ return;
1264
1325
  }
1265
1326
  }
1266
1327
  function documentClick(popover, obj) {
@@ -1438,17 +1499,42 @@ function getBasePlacement(placement) {
1438
1499
  return placement.split('-')[0];
1439
1500
  }
1440
1501
 
1441
- function getBoundingClientRect(element) {
1502
+ var max = Math.max;
1503
+ var min = Math.min;
1504
+ var round = Math.round;
1505
+
1506
+ function getBoundingClientRect(element, includeScale) {
1507
+ if (includeScale === void 0) {
1508
+ includeScale = false;
1509
+ }
1510
+
1442
1511
  var rect = element.getBoundingClientRect();
1512
+ var scaleX = 1;
1513
+ var scaleY = 1;
1514
+
1515
+ if (isHTMLElement(element) && includeScale) {
1516
+ var offsetHeight = element.offsetHeight;
1517
+ var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
1518
+ // Fallback to 1 in case both values are `0`
1519
+
1520
+ if (offsetWidth > 0) {
1521
+ scaleX = round(rect.width) / offsetWidth || 1;
1522
+ }
1523
+
1524
+ if (offsetHeight > 0) {
1525
+ scaleY = round(rect.height) / offsetHeight || 1;
1526
+ }
1527
+ }
1528
+
1443
1529
  return {
1444
- width: rect.width,
1445
- height: rect.height,
1446
- top: rect.top,
1447
- right: rect.right,
1448
- bottom: rect.bottom,
1449
- left: rect.left,
1450
- x: rect.left,
1451
- y: rect.top
1530
+ width: rect.width / scaleX,
1531
+ height: rect.height / scaleY,
1532
+ top: rect.top / scaleY,
1533
+ right: rect.right / scaleX,
1534
+ bottom: rect.bottom / scaleY,
1535
+ left: rect.left / scaleX,
1536
+ x: rect.left / scaleX,
1537
+ y: rect.top / scaleY
1452
1538
  };
1453
1539
  }
1454
1540
 
@@ -1593,13 +1679,13 @@ function getMainAxisFromPlacement(placement) {
1593
1679
  return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
1594
1680
  }
1595
1681
 
1596
- var max = Math.max;
1597
- var min = Math.min;
1598
- var round = Math.round;
1599
-
1600
1682
  function within(min$1, value, max$1) {
1601
1683
  return max(min$1, min(value, max$1));
1602
1684
  }
1685
+ function withinMaxClamp(min, value, max) {
1686
+ var v = within(min, value, max);
1687
+ return v > max ? max : v;
1688
+ }
1603
1689
 
1604
1690
  function getFreshSideObject() {
1605
1691
  return {
@@ -1703,6 +1789,10 @@ var arrow$1 = {
1703
1789
  requiresIfExists: ['preventOverflow']
1704
1790
  };
1705
1791
 
1792
+ function getVariation(placement) {
1793
+ return placement.split('-')[1];
1794
+ }
1795
+
1706
1796
  var unsetSides = {
1707
1797
  top: 'auto',
1708
1798
  right: 'auto',
@@ -1718,8 +1808,8 @@ function roundOffsetsByDPR(_ref) {
1718
1808
  var win = window;
1719
1809
  var dpr = win.devicePixelRatio || 1;
1720
1810
  return {
1721
- x: round(round(x * dpr) / dpr) || 0,
1722
- y: round(round(y * dpr) / dpr) || 0
1811
+ x: round(x * dpr) / dpr || 0,
1812
+ y: round(y * dpr) / dpr || 0
1723
1813
  };
1724
1814
  }
1725
1815
 
@@ -1729,18 +1819,28 @@ function mapToStyles(_ref2) {
1729
1819
  var popper = _ref2.popper,
1730
1820
  popperRect = _ref2.popperRect,
1731
1821
  placement = _ref2.placement,
1822
+ variation = _ref2.variation,
1732
1823
  offsets = _ref2.offsets,
1733
1824
  position = _ref2.position,
1734
1825
  gpuAcceleration = _ref2.gpuAcceleration,
1735
1826
  adaptive = _ref2.adaptive,
1736
- roundOffsets = _ref2.roundOffsets;
1737
-
1738
- var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
1739
- _ref3$x = _ref3.x,
1740
- x = _ref3$x === void 0 ? 0 : _ref3$x,
1741
- _ref3$y = _ref3.y,
1742
- y = _ref3$y === void 0 ? 0 : _ref3$y;
1827
+ roundOffsets = _ref2.roundOffsets,
1828
+ isFixed = _ref2.isFixed;
1829
+ var _offsets$x = offsets.x,
1830
+ x = _offsets$x === void 0 ? 0 : _offsets$x,
1831
+ _offsets$y = offsets.y,
1832
+ y = _offsets$y === void 0 ? 0 : _offsets$y;
1833
+
1834
+ var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
1835
+ x: x,
1836
+ y: y
1837
+ }) : {
1838
+ x: x,
1839
+ y: y
1840
+ };
1743
1841
 
1842
+ x = _ref3.x;
1843
+ y = _ref3.y;
1744
1844
  var hasX = offsets.hasOwnProperty('x');
1745
1845
  var hasY = offsets.hasOwnProperty('y');
1746
1846
  var sideX = left;
@@ -1755,7 +1855,7 @@ function mapToStyles(_ref2) {
1755
1855
  if (offsetParent === getWindow(popper)) {
1756
1856
  offsetParent = getDocumentElement(popper);
1757
1857
 
1758
- if (getComputedStyle$1(offsetParent).position !== 'static') {
1858
+ if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') {
1759
1859
  heightProp = 'scrollHeight';
1760
1860
  widthProp = 'scrollWidth';
1761
1861
  }
@@ -1764,17 +1864,19 @@ function mapToStyles(_ref2) {
1764
1864
 
1765
1865
  offsetParent = offsetParent;
1766
1866
 
1767
- if (placement === top) {
1768
- sideY = bottom; // $FlowFixMe[prop-missing]
1769
-
1770
- y -= offsetParent[heightProp] - popperRect.height;
1867
+ if (placement === top || (placement === left || placement === right) && variation === end) {
1868
+ sideY = bottom;
1869
+ var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
1870
+ offsetParent[heightProp];
1871
+ y -= offsetY - popperRect.height;
1771
1872
  y *= gpuAcceleration ? 1 : -1;
1772
1873
  }
1773
1874
 
1774
- if (placement === left) {
1775
- sideX = right; // $FlowFixMe[prop-missing]
1776
-
1777
- x -= offsetParent[widthProp] - popperRect.width;
1875
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
1876
+ sideX = right;
1877
+ var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
1878
+ offsetParent[widthProp];
1879
+ x -= offsetX - popperRect.width;
1778
1880
  x *= gpuAcceleration ? 1 : -1;
1779
1881
  }
1780
1882
  }
@@ -1783,18 +1885,29 @@ function mapToStyles(_ref2) {
1783
1885
  position: position
1784
1886
  }, adaptive && unsetSides);
1785
1887
 
1888
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
1889
+ x: x,
1890
+ y: y
1891
+ }) : {
1892
+ x: x,
1893
+ y: y
1894
+ };
1895
+
1896
+ x = _ref4.x;
1897
+ y = _ref4.y;
1898
+
1786
1899
  if (gpuAcceleration) {
1787
1900
  var _Object$assign;
1788
1901
 
1789
- 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));
1902
+ 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));
1790
1903
  }
1791
1904
 
1792
1905
  return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
1793
1906
  }
1794
1907
 
1795
- function computeStyles(_ref4) {
1796
- var state = _ref4.state,
1797
- options = _ref4.options;
1908
+ function computeStyles(_ref5) {
1909
+ var state = _ref5.state,
1910
+ options = _ref5.options;
1798
1911
  var _options$gpuAccelerat = options.gpuAcceleration,
1799
1912
  gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
1800
1913
  _options$adaptive = options.adaptive,
@@ -1804,9 +1917,11 @@ function computeStyles(_ref4) {
1804
1917
 
1805
1918
  var commonStyles = {
1806
1919
  placement: getBasePlacement(state.placement),
1920
+ variation: getVariation(state.placement),
1807
1921
  popper: state.elements.popper,
1808
1922
  popperRect: state.rects.popper,
1809
- gpuAcceleration: gpuAcceleration
1923
+ gpuAcceleration: gpuAcceleration,
1924
+ isFixed: state.options.strategy === 'fixed'
1810
1925
  };
1811
1926
 
1812
1927
  if (state.modifiersData.popperOffsets != null) {
@@ -2064,7 +2179,7 @@ function getInnerBoundingClientRect(element) {
2064
2179
  }
2065
2180
 
2066
2181
  function getClientRectFromMixedType(element, clippingParent) {
2067
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2182
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2068
2183
  } // A "clipping parent" is an overflowable container with the characteristic of
2069
2184
  // clipping (or hiding) overflowing elements with a position different from
2070
2185
  // `initial`
@@ -2106,10 +2221,6 @@ function getClippingRect(element, boundary, rootBoundary) {
2106
2221
  return clippingRect;
2107
2222
  }
2108
2223
 
2109
- function getVariation(placement) {
2110
- return placement.split('-')[1];
2111
- }
2112
-
2113
2224
  function computeOffsets(_ref) {
2114
2225
  var reference = _ref.reference,
2115
2226
  element = _ref.element,
@@ -2195,11 +2306,10 @@ function detectOverflow(state, options) {
2195
2306
  padding = _options$padding === void 0 ? 0 : _options$padding;
2196
2307
  var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
2197
2308
  var altContext = elementContext === popper ? reference : popper;
2198
- var referenceElement = state.elements.reference;
2199
2309
  var popperRect = state.rects.popper;
2200
2310
  var element = state.elements[altBoundary ? altContext : elementContext];
2201
2311
  var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
2202
- var referenceClientRect = getBoundingClientRect(referenceElement);
2312
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
2203
2313
  var popperOffsets = computeOffsets({
2204
2314
  reference: referenceClientRect,
2205
2315
  element: popperRect,
@@ -2582,6 +2692,14 @@ function preventOverflow(_ref) {
2582
2692
  var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
2583
2693
  placement: state.placement
2584
2694
  })) : tetherOffset;
2695
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
2696
+ mainAxis: tetherOffsetValue,
2697
+ altAxis: tetherOffsetValue
2698
+ } : Object.assign({
2699
+ mainAxis: 0,
2700
+ altAxis: 0
2701
+ }, tetherOffsetValue);
2702
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
2585
2703
  var data = {
2586
2704
  x: 0,
2587
2705
  y: 0
@@ -2591,13 +2709,15 @@ function preventOverflow(_ref) {
2591
2709
  return;
2592
2710
  }
2593
2711
 
2594
- if (checkMainAxis || checkAltAxis) {
2712
+ if (checkMainAxis) {
2713
+ var _offsetModifierState$;
2714
+
2595
2715
  var mainSide = mainAxis === 'y' ? top : left;
2596
2716
  var altSide = mainAxis === 'y' ? bottom : right;
2597
2717
  var len = mainAxis === 'y' ? 'height' : 'width';
2598
2718
  var offset = popperOffsets[mainAxis];
2599
- var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
2600
- var max$1 = popperOffsets[mainAxis] - overflow[altSide];
2719
+ var min$1 = offset + overflow[mainSide];
2720
+ var max$1 = offset - overflow[altSide];
2601
2721
  var additive = tether ? -popperRect[len] / 2 : 0;
2602
2722
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
2603
2723
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
@@ -2617,36 +2737,45 @@ function preventOverflow(_ref) {
2617
2737
  // width or height)
2618
2738
 
2619
2739
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
2620
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
2621
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
2740
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
2741
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
2622
2742
  var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
2623
2743
  var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
2624
- var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
2625
- var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
2626
- var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
2744
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
2745
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
2746
+ var tetherMax = offset + maxOffset - offsetModifierValue;
2747
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
2748
+ popperOffsets[mainAxis] = preventedOffset;
2749
+ data[mainAxis] = preventedOffset - offset;
2750
+ }
2627
2751
 
2628
- if (checkMainAxis) {
2629
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
2630
- popperOffsets[mainAxis] = preventedOffset;
2631
- data[mainAxis] = preventedOffset - offset;
2632
- }
2752
+ if (checkAltAxis) {
2753
+ var _offsetModifierState$2;
2633
2754
 
2634
- if (checkAltAxis) {
2635
- var _mainSide = mainAxis === 'x' ? top : left;
2755
+ var _mainSide = mainAxis === 'x' ? top : left;
2636
2756
 
2637
- var _altSide = mainAxis === 'x' ? bottom : right;
2757
+ var _altSide = mainAxis === 'x' ? bottom : right;
2638
2758
 
2639
- var _offset = popperOffsets[altAxis];
2759
+ var _offset = popperOffsets[altAxis];
2640
2760
 
2641
- var _min = _offset + overflow[_mainSide];
2761
+ var _len = altAxis === 'y' ? 'height' : 'width';
2642
2762
 
2643
- var _max = _offset - overflow[_altSide];
2763
+ var _min = _offset + overflow[_mainSide];
2644
2764
 
2645
- var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
2765
+ var _max = _offset - overflow[_altSide];
2646
2766
 
2647
- popperOffsets[altAxis] = _preventedOffset;
2648
- data[altAxis] = _preventedOffset - _offset;
2649
- }
2767
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
2768
+
2769
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
2770
+
2771
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
2772
+
2773
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
2774
+
2775
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
2776
+
2777
+ popperOffsets[altAxis] = _preventedOffset;
2778
+ data[altAxis] = _preventedOffset - _offset;
2650
2779
  }
2651
2780
 
2652
2781
  state.modifiersData[name] = data;
@@ -2676,16 +2805,24 @@ function getNodeScroll(node) {
2676
2805
  }
2677
2806
  }
2678
2807
 
2808
+ function isElementScaled(element) {
2809
+ var rect = element.getBoundingClientRect();
2810
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
2811
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
2812
+ return scaleX !== 1 || scaleY !== 1;
2813
+ } // Returns the composite rect of an element relative to its offsetParent.
2679
2814
  // Composite means it takes into account transforms as well as layout.
2680
2815
 
2816
+
2681
2817
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2682
2818
  if (isFixed === void 0) {
2683
2819
  isFixed = false;
2684
2820
  }
2685
2821
 
2686
- var documentElement = getDocumentElement(offsetParent);
2687
- var rect = getBoundingClientRect(elementOrVirtualElement);
2688
2822
  var isOffsetParentAnElement = isHTMLElement(offsetParent);
2823
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2824
+ var documentElement = getDocumentElement(offsetParent);
2825
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
2689
2826
  var scroll = {
2690
2827
  scrollLeft: 0,
2691
2828
  scrollTop: 0
@@ -2702,7 +2839,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2702
2839
  }
2703
2840
 
2704
2841
  if (isHTMLElement(offsetParent)) {
2705
- offsets = getBoundingClientRect(offsetParent);
2842
+ offsets = getBoundingClientRect(offsetParent, true);
2706
2843
  offsets.x += offsetParent.clientLeft;
2707
2844
  offsets.y += offsetParent.clientTop;
2708
2845
  } else if (documentElement) {
@@ -2839,7 +2976,8 @@ function popperGenerator(generatorOptions) {
2839
2976
  var isDestroyed = false;
2840
2977
  var instance = {
2841
2978
  state: state,
2842
- setOptions: function setOptions(options) {
2979
+ setOptions: function setOptions(setOptionsAction) {
2980
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
2843
2981
  cleanupModifierEffects();
2844
2982
  state.options = Object.assign({}, defaultOptions, state.options, options);
2845
2983
  state.scrollParents = {
@@ -3151,6 +3289,9 @@ class Popover {
3151
3289
  this.defaults = defaults;
3152
3290
  this.settings = _extends({}, this.defaults, options);
3153
3291
  this.collection = [];
3292
+ this.memory = {
3293
+ trigger: null
3294
+ };
3154
3295
  this.__handlerKeydown = handlerKeydown.bind(this);
3155
3296
  if (this.settings.autoInit) this.init();
3156
3297
  }