locize 4.0.6 → 4.0.7

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.
@@ -14,24 +14,24 @@
14
14
  }, _typeof(o);
15
15
  }
16
16
 
17
- function _toPrimitive(input, hint) {
18
- if (_typeof(input) !== "object" || input === null) return input;
19
- var prim = input[Symbol.toPrimitive];
20
- if (prim !== undefined) {
21
- var res = prim.call(input, hint || "default");
22
- if (_typeof(res) !== "object") return res;
17
+ function toPrimitive(t, r) {
18
+ if ("object" != _typeof(t) || !t) return t;
19
+ var e = t[Symbol.toPrimitive];
20
+ if (void 0 !== e) {
21
+ var i = e.call(t, r || "default");
22
+ if ("object" != _typeof(i)) return i;
23
23
  throw new TypeError("@@toPrimitive must return a primitive value.");
24
24
  }
25
- return (hint === "string" ? String : Number)(input);
25
+ return ("string" === r ? String : Number)(t);
26
26
  }
27
27
 
28
- function _toPropertyKey(arg) {
29
- var key = _toPrimitive(arg, "string");
30
- return _typeof(key) === "symbol" ? key : String(key);
28
+ function toPropertyKey(t) {
29
+ var i = toPrimitive(t, "string");
30
+ return "symbol" == _typeof(i) ? i : String(i);
31
31
  }
32
32
 
33
33
  function _defineProperty(obj, key, value) {
34
- key = _toPropertyKey(key);
34
+ key = toPropertyKey(key);
35
35
  if (key in obj) {
36
36
  Object.defineProperty(obj, key, {
37
37
  value: value,
@@ -1056,6 +1056,14 @@
1056
1056
  return box;
1057
1057
  }
1058
1058
 
1059
+ /**
1060
+ * Custom positioning reference element.
1061
+ * @see https://floating-ui.com/docs/virtual-elements
1062
+ */
1063
+
1064
+ const sides = ['top', 'right', 'bottom', 'left'];
1065
+ const alignments = ['start', 'end'];
1066
+ const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
1059
1067
  const min = Math.min;
1060
1068
  const max = Math.max;
1061
1069
  const round = Math.round;
@@ -1166,12 +1174,21 @@
1166
1174
  };
1167
1175
  }
1168
1176
  function rectToClientRect(rect) {
1177
+ const {
1178
+ x,
1179
+ y,
1180
+ width,
1181
+ height
1182
+ } = rect;
1169
1183
  return {
1170
- ...rect,
1171
- top: rect.y,
1172
- left: rect.x,
1173
- right: rect.x + rect.width,
1174
- bottom: rect.y + rect.height
1184
+ width,
1185
+ height,
1186
+ top: y,
1187
+ left: x,
1188
+ right: x + width,
1189
+ bottom: y + height,
1190
+ x,
1191
+ y
1175
1192
  };
1176
1193
  }
1177
1194
 
@@ -1233,7 +1250,7 @@
1233
1250
 
1234
1251
  /**
1235
1252
  * Computes the `x` and `y` coordinates that will place the floating element
1236
- * next to a reference element when it is given a certain positioning strategy.
1253
+ * next to a given reference element.
1237
1254
  *
1238
1255
  * This export does not have any `platform` interface logic. You will need to
1239
1256
  * write one for the platform you are using Floating UI with.
@@ -1311,7 +1328,6 @@
1311
1328
  } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1312
1329
  }
1313
1330
  i = -1;
1314
- continue;
1315
1331
  }
1316
1332
  }
1317
1333
  return {
@@ -1361,9 +1377,10 @@
1361
1377
  strategy
1362
1378
  }));
1363
1379
  const rect = elementContext === 'floating' ? {
1364
- ...rects.floating,
1365
1380
  x,
1366
- y
1381
+ y,
1382
+ width: rects.floating.width,
1383
+ height: rects.floating.height
1367
1384
  } : rects.reference;
1368
1385
  const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1369
1386
  const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
@@ -1374,6 +1391,7 @@
1374
1391
  y: 1
1375
1392
  };
1376
1393
  const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1394
+ elements,
1377
1395
  rect,
1378
1396
  offsetParent,
1379
1397
  strategy
@@ -1391,7 +1409,7 @@
1391
1409
  * appears centered to the reference element.
1392
1410
  * @see https://floating-ui.com/docs/arrow
1393
1411
  */
1394
- const arrow = options => ({
1412
+ const arrow$1 = options => ({
1395
1413
  name: 'arrow',
1396
1414
  options,
1397
1415
  async fn(state) {
@@ -1452,7 +1470,7 @@
1452
1470
  // to point to nothing for an aligned placement, adjust the offset of the
1453
1471
  // floating element itself. To ensure `shift()` continues to take action,
1454
1472
  // a single reset is performed when this is true.
1455
- const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1473
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1456
1474
  const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
1457
1475
  return {
1458
1476
  [axis]: coords[axis] + alignmentOffset,
@@ -1468,13 +1486,116 @@
1468
1486
  }
1469
1487
  });
1470
1488
 
1489
+ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
1490
+ const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
1491
+ return allowedPlacementsSortedByAlignment.filter(placement => {
1492
+ if (alignment) {
1493
+ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
1494
+ }
1495
+ return true;
1496
+ });
1497
+ }
1498
+ /**
1499
+ * Optimizes the visibility of the floating element by choosing the placement
1500
+ * that has the most space available automatically, without needing to specify a
1501
+ * preferred placement. Alternative to `flip`.
1502
+ * @see https://floating-ui.com/docs/autoPlacement
1503
+ */
1504
+ const autoPlacement = function (options) {
1505
+ if (options === void 0) {
1506
+ options = {};
1507
+ }
1508
+ return {
1509
+ name: 'autoPlacement',
1510
+ options,
1511
+ async fn(state) {
1512
+ var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
1513
+ const {
1514
+ rects,
1515
+ middlewareData,
1516
+ placement,
1517
+ platform,
1518
+ elements
1519
+ } = state;
1520
+ const {
1521
+ crossAxis = false,
1522
+ alignment,
1523
+ allowedPlacements = placements,
1524
+ autoAlignment = true,
1525
+ ...detectOverflowOptions
1526
+ } = evaluate(options, state);
1527
+ const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
1528
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1529
+ const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
1530
+ const currentPlacement = placements$1[currentIndex];
1531
+ if (currentPlacement == null) {
1532
+ return {};
1533
+ }
1534
+ const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1535
+
1536
+ // Make `computeCoords` start from the right place.
1537
+ if (placement !== currentPlacement) {
1538
+ return {
1539
+ reset: {
1540
+ placement: placements$1[0]
1541
+ }
1542
+ };
1543
+ }
1544
+ const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
1545
+ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
1546
+ placement: currentPlacement,
1547
+ overflows: currentOverflows
1548
+ }];
1549
+ const nextPlacement = placements$1[currentIndex + 1];
1550
+
1551
+ // There are more placements to check.
1552
+ if (nextPlacement) {
1553
+ return {
1554
+ data: {
1555
+ index: currentIndex + 1,
1556
+ overflows: allOverflows
1557
+ },
1558
+ reset: {
1559
+ placement: nextPlacement
1560
+ }
1561
+ };
1562
+ }
1563
+ const placementsSortedByMostSpace = allOverflows.map(d => {
1564
+ const alignment = getAlignment(d.placement);
1565
+ return [d.placement, alignment && crossAxis ?
1566
+ // Check along the mainAxis and main crossAxis side.
1567
+ d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
1568
+ // Check only the mainAxis.
1569
+ d.overflows[0], d.overflows];
1570
+ }).sort((a, b) => a[1] - b[1]);
1571
+ const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
1572
+ // Aligned placements should not check their opposite crossAxis
1573
+ // side.
1574
+ getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
1575
+ const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
1576
+ if (resetPlacement !== placement) {
1577
+ return {
1578
+ data: {
1579
+ index: currentIndex + 1,
1580
+ overflows: allOverflows
1581
+ },
1582
+ reset: {
1583
+ placement: resetPlacement
1584
+ }
1585
+ };
1586
+ }
1587
+ return {};
1588
+ }
1589
+ };
1590
+ };
1591
+
1471
1592
  /**
1472
1593
  * Optimizes the visibility of the floating element by flipping the `placement`
1473
1594
  * in order to keep it in view when the preferred placement(s) will overflow the
1474
1595
  * clipping boundary. Alternative to `autoPlacement`.
1475
1596
  * @see https://floating-ui.com/docs/flip
1476
1597
  */
1477
- const flip = function (options) {
1598
+ const flip$1 = function (options) {
1478
1599
  if (options === void 0) {
1479
1600
  options = {};
1480
1601
  }
@@ -1509,10 +1630,12 @@
1509
1630
  return {};
1510
1631
  }
1511
1632
  const side = getSide(placement);
1633
+ const initialSideAxis = getSideAxis(initialPlacement);
1512
1634
  const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1513
1635
  const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1514
1636
  const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1515
- if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
1637
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
1638
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
1516
1639
  fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1517
1640
  }
1518
1641
  const placements = [initialPlacement, ...fallbackPlacements];
@@ -1558,8 +1681,17 @@
1558
1681
  switch (fallbackStrategy) {
1559
1682
  case 'bestFit':
1560
1683
  {
1561
- var _overflowsData$map$so;
1562
- const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
1684
+ var _overflowsData$filter2;
1685
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
1686
+ if (hasFallbackAxisSideDirection) {
1687
+ const currentSideAxis = getSideAxis(d.placement);
1688
+ return currentSideAxis === initialSideAxis ||
1689
+ // Create a bias to the `y` side axis due to horizontal
1690
+ // reading directions favoring greater width.
1691
+ currentSideAxis === 'y';
1692
+ }
1693
+ return true;
1694
+ }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
1563
1695
  if (placement) {
1564
1696
  resetPlacement = placement;
1565
1697
  }
@@ -1583,8 +1715,209 @@
1583
1715
  };
1584
1716
  };
1585
1717
 
1718
+ function getSideOffsets(overflow, rect) {
1719
+ return {
1720
+ top: overflow.top - rect.height,
1721
+ right: overflow.right - rect.width,
1722
+ bottom: overflow.bottom - rect.height,
1723
+ left: overflow.left - rect.width
1724
+ };
1725
+ }
1726
+ function isAnySideFullyClipped(overflow) {
1727
+ return sides.some(side => overflow[side] >= 0);
1728
+ }
1729
+ /**
1730
+ * Provides data to hide the floating element in applicable situations, such as
1731
+ * when it is not in the same clipping context as the reference element.
1732
+ * @see https://floating-ui.com/docs/hide
1733
+ */
1734
+ const hide = function (options) {
1735
+ if (options === void 0) {
1736
+ options = {};
1737
+ }
1738
+ return {
1739
+ name: 'hide',
1740
+ options,
1741
+ async fn(state) {
1742
+ const {
1743
+ rects
1744
+ } = state;
1745
+ const {
1746
+ strategy = 'referenceHidden',
1747
+ ...detectOverflowOptions
1748
+ } = evaluate(options, state);
1749
+ switch (strategy) {
1750
+ case 'referenceHidden':
1751
+ {
1752
+ const overflow = await detectOverflow(state, {
1753
+ ...detectOverflowOptions,
1754
+ elementContext: 'reference'
1755
+ });
1756
+ const offsets = getSideOffsets(overflow, rects.reference);
1757
+ return {
1758
+ data: {
1759
+ referenceHiddenOffsets: offsets,
1760
+ referenceHidden: isAnySideFullyClipped(offsets)
1761
+ }
1762
+ };
1763
+ }
1764
+ case 'escaped':
1765
+ {
1766
+ const overflow = await detectOverflow(state, {
1767
+ ...detectOverflowOptions,
1768
+ altBoundary: true
1769
+ });
1770
+ const offsets = getSideOffsets(overflow, rects.floating);
1771
+ return {
1772
+ data: {
1773
+ escapedOffsets: offsets,
1774
+ escaped: isAnySideFullyClipped(offsets)
1775
+ }
1776
+ };
1777
+ }
1778
+ default:
1779
+ {
1780
+ return {};
1781
+ }
1782
+ }
1783
+ }
1784
+ };
1785
+ };
1786
+
1787
+ function getBoundingRect(rects) {
1788
+ const minX = min(...rects.map(rect => rect.left));
1789
+ const minY = min(...rects.map(rect => rect.top));
1790
+ const maxX = max(...rects.map(rect => rect.right));
1791
+ const maxY = max(...rects.map(rect => rect.bottom));
1792
+ return {
1793
+ x: minX,
1794
+ y: minY,
1795
+ width: maxX - minX,
1796
+ height: maxY - minY
1797
+ };
1798
+ }
1799
+ function getRectsByLine(rects) {
1800
+ const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
1801
+ const groups = [];
1802
+ let prevRect = null;
1803
+ for (let i = 0; i < sortedRects.length; i++) {
1804
+ const rect = sortedRects[i];
1805
+ if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
1806
+ groups.push([rect]);
1807
+ } else {
1808
+ groups[groups.length - 1].push(rect);
1809
+ }
1810
+ prevRect = rect;
1811
+ }
1812
+ return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
1813
+ }
1814
+ /**
1815
+ * Provides improved positioning for inline reference elements that can span
1816
+ * over multiple lines, such as hyperlinks or range selections.
1817
+ * @see https://floating-ui.com/docs/inline
1818
+ */
1819
+ const inline = function (options) {
1820
+ if (options === void 0) {
1821
+ options = {};
1822
+ }
1823
+ return {
1824
+ name: 'inline',
1825
+ options,
1826
+ async fn(state) {
1827
+ const {
1828
+ placement,
1829
+ elements,
1830
+ rects,
1831
+ platform,
1832
+ strategy
1833
+ } = state;
1834
+ // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
1835
+ // ClientRect's bounds, despite the event listener being triggered. A
1836
+ // padding of 2 seems to handle this issue.
1837
+ const {
1838
+ padding = 2,
1839
+ x,
1840
+ y
1841
+ } = evaluate(options, state);
1842
+ const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
1843
+ const clientRects = getRectsByLine(nativeClientRects);
1844
+ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
1845
+ const paddingObject = getPaddingObject(padding);
1846
+ function getBoundingClientRect() {
1847
+ // There are two rects and they are disjoined.
1848
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
1849
+ // Find the first rect in which the point is fully inside.
1850
+ return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
1851
+ }
1852
+
1853
+ // There are 2 or more connected rects.
1854
+ if (clientRects.length >= 2) {
1855
+ if (getSideAxis(placement) === 'y') {
1856
+ const firstRect = clientRects[0];
1857
+ const lastRect = clientRects[clientRects.length - 1];
1858
+ const isTop = getSide(placement) === 'top';
1859
+ const top = firstRect.top;
1860
+ const bottom = lastRect.bottom;
1861
+ const left = isTop ? firstRect.left : lastRect.left;
1862
+ const right = isTop ? firstRect.right : lastRect.right;
1863
+ const width = right - left;
1864
+ const height = bottom - top;
1865
+ return {
1866
+ top,
1867
+ bottom,
1868
+ left,
1869
+ right,
1870
+ width,
1871
+ height,
1872
+ x: left,
1873
+ y: top
1874
+ };
1875
+ }
1876
+ const isLeftSide = getSide(placement) === 'left';
1877
+ const maxRight = max(...clientRects.map(rect => rect.right));
1878
+ const minLeft = min(...clientRects.map(rect => rect.left));
1879
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
1880
+ const top = measureRects[0].top;
1881
+ const bottom = measureRects[measureRects.length - 1].bottom;
1882
+ const left = minLeft;
1883
+ const right = maxRight;
1884
+ const width = right - left;
1885
+ const height = bottom - top;
1886
+ return {
1887
+ top,
1888
+ bottom,
1889
+ left,
1890
+ right,
1891
+ width,
1892
+ height,
1893
+ x: left,
1894
+ y: top
1895
+ };
1896
+ }
1897
+ return fallback;
1898
+ }
1899
+ const resetRects = await platform.getElementRects({
1900
+ reference: {
1901
+ getBoundingClientRect
1902
+ },
1903
+ floating: elements.floating,
1904
+ strategy
1905
+ });
1906
+ if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
1907
+ return {
1908
+ reset: {
1909
+ rects: resetRects
1910
+ }
1911
+ };
1912
+ }
1913
+ return {};
1914
+ }
1915
+ };
1916
+ };
1917
+
1586
1918
  // For type backwards-compatibility, the `OffsetOptions` type was also
1587
1919
  // Derivable.
1920
+
1588
1921
  async function convertValueToCoords(state, options) {
1589
1922
  const {
1590
1923
  placement,
@@ -1609,10 +1942,9 @@
1609
1942
  crossAxis: 0,
1610
1943
  alignmentAxis: null
1611
1944
  } : {
1612
- mainAxis: 0,
1613
- crossAxis: 0,
1614
- alignmentAxis: null,
1615
- ...rawValue
1945
+ mainAxis: rawValue.mainAxis || 0,
1946
+ crossAxis: rawValue.crossAxis || 0,
1947
+ alignmentAxis: rawValue.alignmentAxis
1616
1948
  };
1617
1949
  if (alignment && typeof alignmentAxis === 'number') {
1618
1950
  crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
@@ -1633,7 +1965,7 @@
1633
1965
  * object may be passed.
1634
1966
  * @see https://floating-ui.com/docs/offset
1635
1967
  */
1636
- const offset = function (options) {
1968
+ const offset$1 = function (options) {
1637
1969
  if (options === void 0) {
1638
1970
  options = 0;
1639
1971
  }
@@ -1641,15 +1973,27 @@
1641
1973
  name: 'offset',
1642
1974
  options,
1643
1975
  async fn(state) {
1976
+ var _middlewareData$offse, _middlewareData$arrow;
1644
1977
  const {
1645
1978
  x,
1646
- y
1979
+ y,
1980
+ placement,
1981
+ middlewareData
1647
1982
  } = state;
1648
1983
  const diffCoords = await convertValueToCoords(state, options);
1984
+
1985
+ // If the placement is the same and the arrow caused an alignment offset
1986
+ // then we don't need to change the positioning coordinates.
1987
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1988
+ return {};
1989
+ }
1649
1990
  return {
1650
1991
  x: x + diffCoords.x,
1651
1992
  y: y + diffCoords.y,
1652
- data: diffCoords
1993
+ data: {
1994
+ ...diffCoords,
1995
+ placement
1996
+ }
1653
1997
  };
1654
1998
  }
1655
1999
  };
@@ -1660,7 +2004,7 @@
1660
2004
  * keep it in view when it will overflow the clipping boundary.
1661
2005
  * @see https://floating-ui.com/docs/shift
1662
2006
  */
1663
- const shift = function (options) {
2007
+ const shift$1 = function (options) {
1664
2008
  if (options === void 0) {
1665
2009
  options = {};
1666
2010
  }
@@ -1722,13 +2066,172 @@
1722
2066
  ...limitedCoords,
1723
2067
  data: {
1724
2068
  x: limitedCoords.x - x,
1725
- y: limitedCoords.y - y
2069
+ y: limitedCoords.y - y,
2070
+ enabled: {
2071
+ [mainAxis]: checkMainAxis,
2072
+ [crossAxis]: checkCrossAxis
2073
+ }
1726
2074
  }
1727
2075
  };
1728
2076
  }
1729
2077
  };
1730
2078
  };
2079
+ /**
2080
+ * Built-in `limiter` that will stop `shift()` at a certain point.
2081
+ */
2082
+ const limitShift = function (options) {
2083
+ if (options === void 0) {
2084
+ options = {};
2085
+ }
2086
+ return {
2087
+ options,
2088
+ fn(state) {
2089
+ const {
2090
+ x,
2091
+ y,
2092
+ placement,
2093
+ rects,
2094
+ middlewareData
2095
+ } = state;
2096
+ const {
2097
+ offset = 0,
2098
+ mainAxis: checkMainAxis = true,
2099
+ crossAxis: checkCrossAxis = true
2100
+ } = evaluate(options, state);
2101
+ const coords = {
2102
+ x,
2103
+ y
2104
+ };
2105
+ const crossAxis = getSideAxis(placement);
2106
+ const mainAxis = getOppositeAxis(crossAxis);
2107
+ let mainAxisCoord = coords[mainAxis];
2108
+ let crossAxisCoord = coords[crossAxis];
2109
+ const rawOffset = evaluate(offset, state);
2110
+ const computedOffset = typeof rawOffset === 'number' ? {
2111
+ mainAxis: rawOffset,
2112
+ crossAxis: 0
2113
+ } : {
2114
+ mainAxis: 0,
2115
+ crossAxis: 0,
2116
+ ...rawOffset
2117
+ };
2118
+ if (checkMainAxis) {
2119
+ const len = mainAxis === 'y' ? 'height' : 'width';
2120
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
2121
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
2122
+ if (mainAxisCoord < limitMin) {
2123
+ mainAxisCoord = limitMin;
2124
+ } else if (mainAxisCoord > limitMax) {
2125
+ mainAxisCoord = limitMax;
2126
+ }
2127
+ }
2128
+ if (checkCrossAxis) {
2129
+ var _middlewareData$offse, _middlewareData$offse2;
2130
+ const len = mainAxis === 'y' ? 'width' : 'height';
2131
+ const isOriginSide = ['top', 'left'].includes(getSide(placement));
2132
+ const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
2133
+ const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
2134
+ if (crossAxisCoord < limitMin) {
2135
+ crossAxisCoord = limitMin;
2136
+ } else if (crossAxisCoord > limitMax) {
2137
+ crossAxisCoord = limitMax;
2138
+ }
2139
+ }
2140
+ return {
2141
+ [mainAxis]: mainAxisCoord,
2142
+ [crossAxis]: crossAxisCoord
2143
+ };
2144
+ }
2145
+ };
2146
+ };
1731
2147
 
2148
+ /**
2149
+ * Provides data that allows you to change the size of the floating element —
2150
+ * for instance, prevent it from overflowing the clipping boundary or match the
2151
+ * width of the reference element.
2152
+ * @see https://floating-ui.com/docs/size
2153
+ */
2154
+ const size = function (options) {
2155
+ if (options === void 0) {
2156
+ options = {};
2157
+ }
2158
+ return {
2159
+ name: 'size',
2160
+ options,
2161
+ async fn(state) {
2162
+ var _state$middlewareData, _state$middlewareData2;
2163
+ const {
2164
+ placement,
2165
+ rects,
2166
+ platform,
2167
+ elements
2168
+ } = state;
2169
+ const {
2170
+ apply = () => {},
2171
+ ...detectOverflowOptions
2172
+ } = evaluate(options, state);
2173
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2174
+ const side = getSide(placement);
2175
+ const alignment = getAlignment(placement);
2176
+ const isYAxis = getSideAxis(placement) === 'y';
2177
+ const {
2178
+ width,
2179
+ height
2180
+ } = rects.floating;
2181
+ let heightSide;
2182
+ let widthSide;
2183
+ if (side === 'top' || side === 'bottom') {
2184
+ heightSide = side;
2185
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
2186
+ } else {
2187
+ widthSide = side;
2188
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
2189
+ }
2190
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
2191
+ const maximumClippingWidth = width - overflow.left - overflow.right;
2192
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
2193
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
2194
+ const noShift = !state.middlewareData.shift;
2195
+ let availableHeight = overflowAvailableHeight;
2196
+ let availableWidth = overflowAvailableWidth;
2197
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
2198
+ availableWidth = maximumClippingWidth;
2199
+ }
2200
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
2201
+ availableHeight = maximumClippingHeight;
2202
+ }
2203
+ if (noShift && !alignment) {
2204
+ const xMin = max(overflow.left, 0);
2205
+ const xMax = max(overflow.right, 0);
2206
+ const yMin = max(overflow.top, 0);
2207
+ const yMax = max(overflow.bottom, 0);
2208
+ if (isYAxis) {
2209
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
2210
+ } else {
2211
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
2212
+ }
2213
+ }
2214
+ await apply({
2215
+ ...state,
2216
+ availableWidth,
2217
+ availableHeight
2218
+ });
2219
+ const nextDimensions = await platform.getDimensions(elements.floating);
2220
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
2221
+ return {
2222
+ reset: {
2223
+ rects: true
2224
+ }
2225
+ };
2226
+ }
2227
+ return {};
2228
+ }
2229
+ };
2230
+ };
2231
+
2232
+ function hasWindow() {
2233
+ return typeof window !== 'undefined';
2234
+ }
1732
2235
  function getNodeName(node) {
1733
2236
  if (isNode(node)) {
1734
2237
  return (node.nodeName || '').toLowerCase();
@@ -1740,24 +2243,32 @@
1740
2243
  }
1741
2244
  function getWindow(node) {
1742
2245
  var _node$ownerDocument;
1743
- return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2246
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1744
2247
  }
1745
2248
  function getDocumentElement(node) {
1746
2249
  var _ref;
1747
2250
  return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1748
2251
  }
1749
2252
  function isNode(value) {
2253
+ if (!hasWindow()) {
2254
+ return false;
2255
+ }
1750
2256
  return value instanceof Node || value instanceof getWindow(value).Node;
1751
2257
  }
1752
2258
  function isElement(value) {
2259
+ if (!hasWindow()) {
2260
+ return false;
2261
+ }
1753
2262
  return value instanceof Element || value instanceof getWindow(value).Element;
1754
2263
  }
1755
2264
  function isHTMLElement(value) {
2265
+ if (!hasWindow()) {
2266
+ return false;
2267
+ }
1756
2268
  return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1757
2269
  }
1758
2270
  function isShadowRoot(value) {
1759
- // Browsers without `ShadowRoot` support.
1760
- if (typeof ShadowRoot === 'undefined') {
2271
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
1761
2272
  return false;
1762
2273
  }
1763
2274
  return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
@@ -1774,21 +2285,32 @@
1774
2285
  function isTableElement(element) {
1775
2286
  return ['table', 'td', 'th'].includes(getNodeName(element));
1776
2287
  }
1777
- function isContainingBlock(element) {
2288
+ function isTopLayer(element) {
2289
+ return [':popover-open', ':modal'].some(selector => {
2290
+ try {
2291
+ return element.matches(selector);
2292
+ } catch (e) {
2293
+ return false;
2294
+ }
2295
+ });
2296
+ }
2297
+ function isContainingBlock(elementOrCss) {
1778
2298
  const webkit = isWebKit();
1779
- const css = getComputedStyle(element);
2299
+ const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
1780
2300
 
1781
2301
  // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1782
- return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
2302
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
2303
+ return ['transform', 'translate', 'scale', 'rotate', 'perspective'].some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
1783
2304
  }
1784
2305
  function getContainingBlock(element) {
1785
2306
  let currentNode = getParentNode(element);
1786
2307
  while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1787
2308
  if (isContainingBlock(currentNode)) {
1788
2309
  return currentNode;
1789
- } else {
1790
- currentNode = getParentNode(currentNode);
2310
+ } else if (isTopLayer(currentNode)) {
2311
+ return null;
1791
2312
  }
2313
+ currentNode = getParentNode(currentNode);
1792
2314
  }
1793
2315
  return null;
1794
2316
  }
@@ -1810,8 +2332,8 @@
1810
2332
  };
1811
2333
  }
1812
2334
  return {
1813
- scrollLeft: element.pageXOffset,
1814
- scrollTop: element.pageYOffset
2335
+ scrollLeft: element.scrollX,
2336
+ scrollTop: element.scrollY
1815
2337
  };
1816
2338
  }
1817
2339
  function getParentNode(node) {
@@ -1851,10 +2373,14 @@
1851
2373
  const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1852
2374
  const win = getWindow(scrollableAncestor);
1853
2375
  if (isBody) {
1854
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
2376
+ const frameElement = getFrameElement(win);
2377
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1855
2378
  }
1856
2379
  return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1857
2380
  }
2381
+ function getFrameElement(win) {
2382
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2383
+ }
1858
2384
 
1859
2385
  function getCssDimensions(element) {
1860
2386
  const css = getComputedStyle(element);
@@ -1957,8 +2483,9 @@
1957
2483
  if (domElement) {
1958
2484
  const win = getWindow(domElement);
1959
2485
  const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1960
- let currentIFrame = win.frameElement;
1961
- while (currentIFrame && offsetParent && offsetWin !== win) {
2486
+ let currentWin = win;
2487
+ let currentIFrame = getFrameElement(currentWin);
2488
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1962
2489
  const iframeScale = getScale(currentIFrame);
1963
2490
  const iframeRect = currentIFrame.getBoundingClientRect();
1964
2491
  const css = getComputedStyle(currentIFrame);
@@ -1970,7 +2497,8 @@
1970
2497
  height *= iframeScale.y;
1971
2498
  x += left;
1972
2499
  y += top;
1973
- currentIFrame = getWindow(currentIFrame).frameElement;
2500
+ currentWin = getWindow(currentIFrame);
2501
+ currentIFrame = getFrameElement(currentWin);
1974
2502
  }
1975
2503
  }
1976
2504
  return rectToClientRect({
@@ -1981,15 +2509,42 @@
1981
2509
  });
1982
2510
  }
1983
2511
 
2512
+ // If <html> has a CSS width greater than the viewport, then this will be
2513
+ // incorrect for RTL.
2514
+ function getWindowScrollBarX(element, rect) {
2515
+ const leftScroll = getNodeScroll(element).scrollLeft;
2516
+ if (!rect) {
2517
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
2518
+ }
2519
+ return rect.left + leftScroll;
2520
+ }
2521
+
2522
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
2523
+ if (ignoreScrollbarX === void 0) {
2524
+ ignoreScrollbarX = false;
2525
+ }
2526
+ const htmlRect = documentElement.getBoundingClientRect();
2527
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
2528
+ // RTL <body> scrollbar.
2529
+ getWindowScrollBarX(documentElement, htmlRect));
2530
+ const y = htmlRect.top + scroll.scrollTop;
2531
+ return {
2532
+ x,
2533
+ y
2534
+ };
2535
+ }
2536
+
1984
2537
  function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1985
2538
  let {
2539
+ elements,
1986
2540
  rect,
1987
2541
  offsetParent,
1988
2542
  strategy
1989
2543
  } = _ref;
1990
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
2544
+ const isFixed = strategy === 'fixed';
1991
2545
  const documentElement = getDocumentElement(offsetParent);
1992
- if (offsetParent === documentElement) {
2546
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
2547
+ if (offsetParent === documentElement || topLayer && isFixed) {
1993
2548
  return rect;
1994
2549
  }
1995
2550
  let scroll = {
@@ -1998,7 +2553,8 @@
1998
2553
  };
1999
2554
  let scale = createCoords(1);
2000
2555
  const offsets = createCoords(0);
2001
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
2556
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2557
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2002
2558
  if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2003
2559
  scroll = getNodeScroll(offsetParent);
2004
2560
  }
@@ -2009,11 +2565,12 @@
2009
2565
  offsets.y = offsetRect.y + offsetParent.clientTop;
2010
2566
  }
2011
2567
  }
2568
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
2012
2569
  return {
2013
2570
  width: rect.width * scale.x,
2014
2571
  height: rect.height * scale.y,
2015
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
2016
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
2572
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
2573
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
2017
2574
  };
2018
2575
  }
2019
2576
 
@@ -2021,12 +2578,6 @@
2021
2578
  return Array.from(element.getClientRects());
2022
2579
  }
2023
2580
 
2024
- function getWindowScrollBarX(element) {
2025
- // If <html> has a CSS width greater than the viewport, then this will be
2026
- // incorrect for RTL.
2027
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
2028
- }
2029
-
2030
2581
  // Gets the entire size of the scrollable document area, even extending outside
2031
2582
  // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
2032
2583
  function getDocumentRect(element) {
@@ -2101,9 +2652,10 @@
2101
2652
  } else {
2102
2653
  const visualOffsets = getVisualOffsets(element);
2103
2654
  rect = {
2104
- ...clippingAncestor,
2105
2655
  x: clippingAncestor.x - visualOffsets.x,
2106
- y: clippingAncestor.y - visualOffsets.y
2656
+ y: clippingAncestor.y - visualOffsets.y,
2657
+ width: clippingAncestor.width,
2658
+ height: clippingAncestor.height
2107
2659
  };
2108
2660
  }
2109
2661
  return rectToClientRect(rect);
@@ -2159,7 +2711,7 @@
2159
2711
  rootBoundary,
2160
2712
  strategy
2161
2713
  } = _ref;
2162
- const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
2714
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
2163
2715
  const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2164
2716
  const firstClippingAncestor = clippingAncestors[0];
2165
2717
  const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
@@ -2179,7 +2731,14 @@
2179
2731
  }
2180
2732
 
2181
2733
  function getDimensions(element) {
2182
- return getCssDimensions(element);
2734
+ const {
2735
+ width,
2736
+ height
2737
+ } = getCssDimensions(element);
2738
+ return {
2739
+ width,
2740
+ height
2741
+ };
2183
2742
  }
2184
2743
 
2185
2744
  function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
@@ -2201,17 +2760,26 @@
2201
2760
  offsets.x = offsetRect.x + offsetParent.clientLeft;
2202
2761
  offsets.y = offsetRect.y + offsetParent.clientTop;
2203
2762
  } else if (documentElement) {
2763
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
2764
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
2204
2765
  offsets.x = getWindowScrollBarX(documentElement);
2205
2766
  }
2206
2767
  }
2768
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
2769
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
2770
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
2207
2771
  return {
2208
- x: rect.left + scroll.scrollLeft - offsets.x,
2209
- y: rect.top + scroll.scrollTop - offsets.y,
2772
+ x,
2773
+ y,
2210
2774
  width: rect.width,
2211
2775
  height: rect.height
2212
2776
  };
2213
2777
  }
2214
2778
 
2779
+ function isStaticPositioned(element) {
2780
+ return getComputedStyle(element).position === 'static';
2781
+ }
2782
+
2215
2783
  function getTrueOffsetParent(element, polyfill) {
2216
2784
  if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
2217
2785
  return null;
@@ -2219,40 +2787,56 @@
2219
2787
  if (polyfill) {
2220
2788
  return polyfill(element);
2221
2789
  }
2222
- return element.offsetParent;
2790
+ let rawOffsetParent = element.offsetParent;
2791
+
2792
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
2793
+ // while Chrome and Safari return the <body> element. The <body> element must
2794
+ // be used to perform the correct calculations even if the <html> element is
2795
+ // non-static.
2796
+ if (getDocumentElement(element) === rawOffsetParent) {
2797
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
2798
+ }
2799
+ return rawOffsetParent;
2223
2800
  }
2224
2801
 
2225
2802
  // Gets the closest ancestor positioned element. Handles some edge cases,
2226
2803
  // such as table ancestors and cross browser bugs.
2227
2804
  function getOffsetParent(element, polyfill) {
2228
- const window = getWindow(element);
2805
+ const win = getWindow(element);
2806
+ if (isTopLayer(element)) {
2807
+ return win;
2808
+ }
2229
2809
  if (!isHTMLElement(element)) {
2230
- return window;
2810
+ let svgOffsetParent = getParentNode(element);
2811
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
2812
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
2813
+ return svgOffsetParent;
2814
+ }
2815
+ svgOffsetParent = getParentNode(svgOffsetParent);
2816
+ }
2817
+ return win;
2231
2818
  }
2232
2819
  let offsetParent = getTrueOffsetParent(element, polyfill);
2233
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
2820
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
2234
2821
  offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2235
2822
  }
2236
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
2237
- return window;
2823
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
2824
+ return win;
2238
2825
  }
2239
- return offsetParent || getContainingBlock(element) || window;
2826
+ return offsetParent || getContainingBlock(element) || win;
2240
2827
  }
2241
2828
 
2242
- const getElementRects = async function (_ref) {
2243
- let {
2244
- reference,
2245
- floating,
2246
- strategy
2247
- } = _ref;
2829
+ const getElementRects = async function (data) {
2248
2830
  const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2249
2831
  const getDimensionsFn = this.getDimensions;
2832
+ const floatingDimensions = await getDimensionsFn(data.floating);
2250
2833
  return {
2251
- reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
2834
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
2252
2835
  floating: {
2253
2836
  x: 0,
2254
2837
  y: 0,
2255
- ...(await getDimensionsFn(floating))
2838
+ width: floatingDimensions.width,
2839
+ height: floatingDimensions.height
2256
2840
  }
2257
2841
  };
2258
2842
  };
@@ -2274,10 +2858,75 @@
2274
2858
  isRTL
2275
2859
  };
2276
2860
 
2861
+ /**
2862
+ * Modifies the placement by translating the floating element along the
2863
+ * specified axes.
2864
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
2865
+ * object may be passed.
2866
+ * @see https://floating-ui.com/docs/offset
2867
+ */
2868
+ const offset = offset$1;
2869
+
2870
+ /**
2871
+ * Optimizes the visibility of the floating element by choosing the placement
2872
+ * that has the most space available automatically, without needing to specify a
2873
+ * preferred placement. Alternative to `flip`.
2874
+ * @see https://floating-ui.com/docs/autoPlacement
2875
+ */
2876
+ autoPlacement;
2877
+
2878
+ /**
2879
+ * Optimizes the visibility of the floating element by shifting it in order to
2880
+ * keep it in view when it will overflow the clipping boundary.
2881
+ * @see https://floating-ui.com/docs/shift
2882
+ */
2883
+ const shift = shift$1;
2884
+
2885
+ /**
2886
+ * Optimizes the visibility of the floating element by flipping the `placement`
2887
+ * in order to keep it in view when the preferred placement(s) will overflow the
2888
+ * clipping boundary. Alternative to `autoPlacement`.
2889
+ * @see https://floating-ui.com/docs/flip
2890
+ */
2891
+ const flip = flip$1;
2892
+
2893
+ /**
2894
+ * Provides data that allows you to change the size of the floating element —
2895
+ * for instance, prevent it from overflowing the clipping boundary or match the
2896
+ * width of the reference element.
2897
+ * @see https://floating-ui.com/docs/size
2898
+ */
2899
+ size;
2900
+
2901
+ /**
2902
+ * Provides data to hide the floating element in applicable situations, such as
2903
+ * when it is not in the same clipping context as the reference element.
2904
+ * @see https://floating-ui.com/docs/hide
2905
+ */
2906
+ hide;
2907
+
2908
+ /**
2909
+ * Provides data to position an inner element of the floating element so that it
2910
+ * appears centered to the reference element.
2911
+ * @see https://floating-ui.com/docs/arrow
2912
+ */
2913
+ const arrow = arrow$1;
2914
+
2915
+ /**
2916
+ * Provides improved positioning for inline reference elements that can span
2917
+ * over multiple lines, such as hyperlinks or range selections.
2918
+ * @see https://floating-ui.com/docs/inline
2919
+ */
2920
+ inline;
2921
+
2922
+ /**
2923
+ * Built-in `limiter` that will stop `shift()` at a certain point.
2924
+ */
2925
+ limitShift;
2926
+
2277
2927
  /**
2278
2928
  * Computes the `x` and `y` coordinates that will place the floating element
2279
- * next to a reference element when it is given a certain CSS positioning
2280
- * strategy.
2929
+ * next to a given reference element.
2281
2930
  */
2282
2931
  const computePosition = (reference, floating, options) => {
2283
2932
  // This caches the expensive `getClippingElementAncestors` function so that
@@ -2319,7 +2968,7 @@
2319
2968
  }), shift(), offset(function (_ref) {
2320
2969
  var placement = _ref.placement,
2321
2970
  rects = _ref.rects;
2322
- if (placement === 'bottom') return rects.r;
2971
+ if (placement === 'bottom') return -rects.reference.height / 2 - rects.floating.height / 2;
2323
2972
  return 35;
2324
2973
  }), arrow({
2325
2974
  element: arrowEle