locize 4.0.7 → 4.0.8
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/dist/cjs/ui/elements/ribbonBox.js +3 -2
- package/dist/esm/ui/elements/ribbonBox.js +3 -2
- package/dist/umd/locize.js +86 -734
- package/dist/umd/locize.min.js +1 -1
- package/locize.js +86 -734
- package/locize.min.js +1 -1
- package/package.json +1 -1
- package/src/ui/elements/ribbonBox.js +3 -2
package/dist/umd/locize.js
CHANGED
|
@@ -14,24 +14,24 @@
|
|
|
14
14
|
}, _typeof(o);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function
|
|
18
|
-
if ("object"
|
|
19
|
-
var
|
|
20
|
-
if (
|
|
21
|
-
var
|
|
22
|
-
if ("object"
|
|
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;
|
|
23
23
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
24
24
|
}
|
|
25
|
-
return ("string"
|
|
25
|
+
return (hint === "string" ? String : Number)(input);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function
|
|
29
|
-
var
|
|
30
|
-
return "symbol"
|
|
28
|
+
function _toPropertyKey(arg) {
|
|
29
|
+
var key = _toPrimitive(arg, "string");
|
|
30
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function _defineProperty(obj, key, value) {
|
|
34
|
-
key =
|
|
34
|
+
key = _toPropertyKey(key);
|
|
35
35
|
if (key in obj) {
|
|
36
36
|
Object.defineProperty(obj, key, {
|
|
37
37
|
value: value,
|
|
@@ -1009,7 +1009,7 @@
|
|
|
1009
1009
|
}
|
|
1010
1010
|
function RibbonButton(text, attrTitle, onClick) {
|
|
1011
1011
|
var btn = document.createElement('button');
|
|
1012
|
-
btn.style = 'font-family: Arial; position: relative; backdrop-filter: blur(3px); cursor: pointer; padding: 2px 10px 2px 20px; font-size: 15px; font-weight: 300; text-transform: uppercase; color: #fff; background-color: rgba(25, 118, 210, 0.8); border: none; border-radius: 12px;
|
|
1012
|
+
btn.style = 'font-family: Arial; position: relative; backdrop-filter: blur(3px); cursor: pointer; padding: 2px 10px 2px 20px; font-size: 15px; font-weight: 300; text-transform: uppercase; color: #fff; background-color: rgba(25, 118, 210, 0.8); border: none; border-radius: 12px; ';
|
|
1013
1013
|
btn.classList.add('i18next-editor-button');
|
|
1014
1014
|
btn.setAttribute('data-i18next-editor-element', 'true');
|
|
1015
1015
|
btn.setAttribute('title', attrTitle);
|
|
@@ -1026,7 +1026,8 @@
|
|
|
1026
1026
|
function RibbonBox() {
|
|
1027
1027
|
var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1028
1028
|
var box = document.createElement('div');
|
|
1029
|
-
box.
|
|
1029
|
+
box.classList.add('i18next-editor-button-container');
|
|
1030
|
+
box.style = 'position: absolute; top: 0; left: 0; display: flex; align-items: flex-start; justify-content: center; filter: drop-shadow(0px 0px 20px #aaa ); z-index: 99999;';
|
|
1030
1031
|
box.setAttribute('data-i18next-editor-element', 'true');
|
|
1031
1032
|
var arrow = document.createElement('div');
|
|
1032
1033
|
arrow.style = "\n position: absolute;\n width: 0;\n height: 0;\n border-top-width: 7px;\n border-bottom-width: 7px;\n border-left-width: 10px;\n border-right-width: 10px;\n border-style: solid;\n border-color: transparent ".concat(colors.highlight, " transparent\n transparent;\n ");
|
|
@@ -1056,14 +1057,6 @@
|
|
|
1056
1057
|
return box;
|
|
1057
1058
|
}
|
|
1058
1059
|
|
|
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]), []);
|
|
1067
1060
|
const min = Math.min;
|
|
1068
1061
|
const max = Math.max;
|
|
1069
1062
|
const round = Math.round;
|
|
@@ -1174,21 +1167,12 @@
|
|
|
1174
1167
|
};
|
|
1175
1168
|
}
|
|
1176
1169
|
function rectToClientRect(rect) {
|
|
1177
|
-
const {
|
|
1178
|
-
x,
|
|
1179
|
-
y,
|
|
1180
|
-
width,
|
|
1181
|
-
height
|
|
1182
|
-
} = rect;
|
|
1183
1170
|
return {
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
bottom: y + height,
|
|
1190
|
-
x,
|
|
1191
|
-
y
|
|
1171
|
+
...rect,
|
|
1172
|
+
top: rect.y,
|
|
1173
|
+
left: rect.x,
|
|
1174
|
+
right: rect.x + rect.width,
|
|
1175
|
+
bottom: rect.y + rect.height
|
|
1192
1176
|
};
|
|
1193
1177
|
}
|
|
1194
1178
|
|
|
@@ -1250,7 +1234,7 @@
|
|
|
1250
1234
|
|
|
1251
1235
|
/**
|
|
1252
1236
|
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1253
|
-
* next to a given
|
|
1237
|
+
* next to a reference element when it is given a certain positioning strategy.
|
|
1254
1238
|
*
|
|
1255
1239
|
* This export does not have any `platform` interface logic. You will need to
|
|
1256
1240
|
* write one for the platform you are using Floating UI with.
|
|
@@ -1328,6 +1312,7 @@
|
|
|
1328
1312
|
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
1329
1313
|
}
|
|
1330
1314
|
i = -1;
|
|
1315
|
+
continue;
|
|
1331
1316
|
}
|
|
1332
1317
|
}
|
|
1333
1318
|
return {
|
|
@@ -1377,10 +1362,9 @@
|
|
|
1377
1362
|
strategy
|
|
1378
1363
|
}));
|
|
1379
1364
|
const rect = elementContext === 'floating' ? {
|
|
1365
|
+
...rects.floating,
|
|
1380
1366
|
x,
|
|
1381
|
-
y
|
|
1382
|
-
width: rects.floating.width,
|
|
1383
|
-
height: rects.floating.height
|
|
1367
|
+
y
|
|
1384
1368
|
} : rects.reference;
|
|
1385
1369
|
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
1386
1370
|
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
@@ -1391,7 +1375,6 @@
|
|
|
1391
1375
|
y: 1
|
|
1392
1376
|
};
|
|
1393
1377
|
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
1394
|
-
elements,
|
|
1395
1378
|
rect,
|
|
1396
1379
|
offsetParent,
|
|
1397
1380
|
strategy
|
|
@@ -1409,7 +1392,7 @@
|
|
|
1409
1392
|
* appears centered to the reference element.
|
|
1410
1393
|
* @see https://floating-ui.com/docs/arrow
|
|
1411
1394
|
*/
|
|
1412
|
-
const arrow
|
|
1395
|
+
const arrow = options => ({
|
|
1413
1396
|
name: 'arrow',
|
|
1414
1397
|
options,
|
|
1415
1398
|
async fn(state) {
|
|
@@ -1470,7 +1453,7 @@
|
|
|
1470
1453
|
// to point to nothing for an aligned placement, adjust the offset of the
|
|
1471
1454
|
// floating element itself. To ensure `shift()` continues to take action,
|
|
1472
1455
|
// a single reset is performed when this is true.
|
|
1473
|
-
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center
|
|
1456
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
1474
1457
|
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
1475
1458
|
return {
|
|
1476
1459
|
[axis]: coords[axis] + alignmentOffset,
|
|
@@ -1486,116 +1469,13 @@
|
|
|
1486
1469
|
}
|
|
1487
1470
|
});
|
|
1488
1471
|
|
|
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
|
-
|
|
1592
1472
|
/**
|
|
1593
1473
|
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
1594
1474
|
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
1595
1475
|
* clipping boundary. Alternative to `autoPlacement`.
|
|
1596
1476
|
* @see https://floating-ui.com/docs/flip
|
|
1597
1477
|
*/
|
|
1598
|
-
const flip
|
|
1478
|
+
const flip = function (options) {
|
|
1599
1479
|
if (options === void 0) {
|
|
1600
1480
|
options = {};
|
|
1601
1481
|
}
|
|
@@ -1630,12 +1510,10 @@
|
|
|
1630
1510
|
return {};
|
|
1631
1511
|
}
|
|
1632
1512
|
const side = getSide(placement);
|
|
1633
|
-
const initialSideAxis = getSideAxis(initialPlacement);
|
|
1634
1513
|
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
1635
1514
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1636
1515
|
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
1637
|
-
|
|
1638
|
-
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
1516
|
+
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
|
|
1639
1517
|
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
1640
1518
|
}
|
|
1641
1519
|
const placements = [initialPlacement, ...fallbackPlacements];
|
|
@@ -1681,17 +1559,8 @@
|
|
|
1681
1559
|
switch (fallbackStrategy) {
|
|
1682
1560
|
case 'bestFit':
|
|
1683
1561
|
{
|
|
1684
|
-
var _overflowsData$
|
|
1685
|
-
const placement = (_overflowsData$
|
|
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];
|
|
1562
|
+
var _overflowsData$map$so;
|
|
1563
|
+
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];
|
|
1695
1564
|
if (placement) {
|
|
1696
1565
|
resetPlacement = placement;
|
|
1697
1566
|
}
|
|
@@ -1715,209 +1584,8 @@
|
|
|
1715
1584
|
};
|
|
1716
1585
|
};
|
|
1717
1586
|
|
|
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
|
-
|
|
1918
1587
|
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
1919
1588
|
// Derivable.
|
|
1920
|
-
|
|
1921
1589
|
async function convertValueToCoords(state, options) {
|
|
1922
1590
|
const {
|
|
1923
1591
|
placement,
|
|
@@ -1942,9 +1610,10 @@
|
|
|
1942
1610
|
crossAxis: 0,
|
|
1943
1611
|
alignmentAxis: null
|
|
1944
1612
|
} : {
|
|
1945
|
-
mainAxis:
|
|
1946
|
-
crossAxis:
|
|
1947
|
-
alignmentAxis:
|
|
1613
|
+
mainAxis: 0,
|
|
1614
|
+
crossAxis: 0,
|
|
1615
|
+
alignmentAxis: null,
|
|
1616
|
+
...rawValue
|
|
1948
1617
|
};
|
|
1949
1618
|
if (alignment && typeof alignmentAxis === 'number') {
|
|
1950
1619
|
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
@@ -1965,7 +1634,7 @@
|
|
|
1965
1634
|
* object may be passed.
|
|
1966
1635
|
* @see https://floating-ui.com/docs/offset
|
|
1967
1636
|
*/
|
|
1968
|
-
const offset
|
|
1637
|
+
const offset = function (options) {
|
|
1969
1638
|
if (options === void 0) {
|
|
1970
1639
|
options = 0;
|
|
1971
1640
|
}
|
|
@@ -1973,27 +1642,15 @@
|
|
|
1973
1642
|
name: 'offset',
|
|
1974
1643
|
options,
|
|
1975
1644
|
async fn(state) {
|
|
1976
|
-
var _middlewareData$offse, _middlewareData$arrow;
|
|
1977
1645
|
const {
|
|
1978
1646
|
x,
|
|
1979
|
-
y
|
|
1980
|
-
placement,
|
|
1981
|
-
middlewareData
|
|
1647
|
+
y
|
|
1982
1648
|
} = state;
|
|
1983
1649
|
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
|
-
}
|
|
1990
1650
|
return {
|
|
1991
1651
|
x: x + diffCoords.x,
|
|
1992
1652
|
y: y + diffCoords.y,
|
|
1993
|
-
data:
|
|
1994
|
-
...diffCoords,
|
|
1995
|
-
placement
|
|
1996
|
-
}
|
|
1653
|
+
data: diffCoords
|
|
1997
1654
|
};
|
|
1998
1655
|
}
|
|
1999
1656
|
};
|
|
@@ -2004,7 +1661,7 @@
|
|
|
2004
1661
|
* keep it in view when it will overflow the clipping boundary.
|
|
2005
1662
|
* @see https://floating-ui.com/docs/shift
|
|
2006
1663
|
*/
|
|
2007
|
-
const shift
|
|
1664
|
+
const shift = function (options) {
|
|
2008
1665
|
if (options === void 0) {
|
|
2009
1666
|
options = {};
|
|
2010
1667
|
}
|
|
@@ -2066,172 +1723,13 @@
|
|
|
2066
1723
|
...limitedCoords,
|
|
2067
1724
|
data: {
|
|
2068
1725
|
x: limitedCoords.x - x,
|
|
2069
|
-
y: limitedCoords.y - y
|
|
2070
|
-
enabled: {
|
|
2071
|
-
[mainAxis]: checkMainAxis,
|
|
2072
|
-
[crossAxis]: checkCrossAxis
|
|
2073
|
-
}
|
|
1726
|
+
y: limitedCoords.y - y
|
|
2074
1727
|
}
|
|
2075
1728
|
};
|
|
2076
1729
|
}
|
|
2077
1730
|
};
|
|
2078
1731
|
};
|
|
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
|
-
};
|
|
2147
1732
|
|
|
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
|
-
}
|
|
2235
1733
|
function getNodeName(node) {
|
|
2236
1734
|
if (isNode(node)) {
|
|
2237
1735
|
return (node.nodeName || '').toLowerCase();
|
|
@@ -2243,32 +1741,24 @@
|
|
|
2243
1741
|
}
|
|
2244
1742
|
function getWindow(node) {
|
|
2245
1743
|
var _node$ownerDocument;
|
|
2246
|
-
return (node == null
|
|
1744
|
+
return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
2247
1745
|
}
|
|
2248
1746
|
function getDocumentElement(node) {
|
|
2249
1747
|
var _ref;
|
|
2250
1748
|
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
2251
1749
|
}
|
|
2252
1750
|
function isNode(value) {
|
|
2253
|
-
if (!hasWindow()) {
|
|
2254
|
-
return false;
|
|
2255
|
-
}
|
|
2256
1751
|
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
2257
1752
|
}
|
|
2258
1753
|
function isElement(value) {
|
|
2259
|
-
if (!hasWindow()) {
|
|
2260
|
-
return false;
|
|
2261
|
-
}
|
|
2262
1754
|
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
2263
1755
|
}
|
|
2264
1756
|
function isHTMLElement(value) {
|
|
2265
|
-
if (!hasWindow()) {
|
|
2266
|
-
return false;
|
|
2267
|
-
}
|
|
2268
1757
|
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
2269
1758
|
}
|
|
2270
1759
|
function isShadowRoot(value) {
|
|
2271
|
-
|
|
1760
|
+
// Browsers without `ShadowRoot` support.
|
|
1761
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
2272
1762
|
return false;
|
|
2273
1763
|
}
|
|
2274
1764
|
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
@@ -2285,32 +1775,21 @@
|
|
|
2285
1775
|
function isTableElement(element) {
|
|
2286
1776
|
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
2287
1777
|
}
|
|
2288
|
-
function
|
|
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
|
+
function isContainingBlock(element) {
|
|
2298
1779
|
const webkit = isWebKit();
|
|
2299
|
-
const css =
|
|
1780
|
+
const css = getComputedStyle(element);
|
|
2300
1781
|
|
|
2301
1782
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
2302
|
-
|
|
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
|
+
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));
|
|
2304
1784
|
}
|
|
2305
1785
|
function getContainingBlock(element) {
|
|
2306
1786
|
let currentNode = getParentNode(element);
|
|
2307
1787
|
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
2308
1788
|
if (isContainingBlock(currentNode)) {
|
|
2309
1789
|
return currentNode;
|
|
2310
|
-
} else
|
|
2311
|
-
|
|
1790
|
+
} else {
|
|
1791
|
+
currentNode = getParentNode(currentNode);
|
|
2312
1792
|
}
|
|
2313
|
-
currentNode = getParentNode(currentNode);
|
|
2314
1793
|
}
|
|
2315
1794
|
return null;
|
|
2316
1795
|
}
|
|
@@ -2332,8 +1811,8 @@
|
|
|
2332
1811
|
};
|
|
2333
1812
|
}
|
|
2334
1813
|
return {
|
|
2335
|
-
scrollLeft: element.
|
|
2336
|
-
scrollTop: element.
|
|
1814
|
+
scrollLeft: element.pageXOffset,
|
|
1815
|
+
scrollTop: element.pageYOffset
|
|
2337
1816
|
};
|
|
2338
1817
|
}
|
|
2339
1818
|
function getParentNode(node) {
|
|
@@ -2373,14 +1852,10 @@
|
|
|
2373
1852
|
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
2374
1853
|
const win = getWindow(scrollableAncestor);
|
|
2375
1854
|
if (isBody) {
|
|
2376
|
-
|
|
2377
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
1855
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
|
|
2378
1856
|
}
|
|
2379
1857
|
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
2380
1858
|
}
|
|
2381
|
-
function getFrameElement(win) {
|
|
2382
|
-
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
2383
|
-
}
|
|
2384
1859
|
|
|
2385
1860
|
function getCssDimensions(element) {
|
|
2386
1861
|
const css = getComputedStyle(element);
|
|
@@ -2483,9 +1958,8 @@
|
|
|
2483
1958
|
if (domElement) {
|
|
2484
1959
|
const win = getWindow(domElement);
|
|
2485
1960
|
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
2486
|
-
let
|
|
2487
|
-
|
|
2488
|
-
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
1961
|
+
let currentIFrame = win.frameElement;
|
|
1962
|
+
while (currentIFrame && offsetParent && offsetWin !== win) {
|
|
2489
1963
|
const iframeScale = getScale(currentIFrame);
|
|
2490
1964
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
2491
1965
|
const css = getComputedStyle(currentIFrame);
|
|
@@ -2497,8 +1971,7 @@
|
|
|
2497
1971
|
height *= iframeScale.y;
|
|
2498
1972
|
x += left;
|
|
2499
1973
|
y += top;
|
|
2500
|
-
|
|
2501
|
-
currentIFrame = getFrameElement(currentWin);
|
|
1974
|
+
currentIFrame = getWindow(currentIFrame).frameElement;
|
|
2502
1975
|
}
|
|
2503
1976
|
}
|
|
2504
1977
|
return rectToClientRect({
|
|
@@ -2509,42 +1982,15 @@
|
|
|
2509
1982
|
});
|
|
2510
1983
|
}
|
|
2511
1984
|
|
|
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
|
-
|
|
2537
1985
|
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
2538
1986
|
let {
|
|
2539
|
-
elements,
|
|
2540
1987
|
rect,
|
|
2541
1988
|
offsetParent,
|
|
2542
1989
|
strategy
|
|
2543
1990
|
} = _ref;
|
|
2544
|
-
const
|
|
1991
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2545
1992
|
const documentElement = getDocumentElement(offsetParent);
|
|
2546
|
-
|
|
2547
|
-
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
1993
|
+
if (offsetParent === documentElement) {
|
|
2548
1994
|
return rect;
|
|
2549
1995
|
}
|
|
2550
1996
|
let scroll = {
|
|
@@ -2553,8 +1999,7 @@
|
|
|
2553
1999
|
};
|
|
2554
2000
|
let scale = createCoords(1);
|
|
2555
2001
|
const offsets = createCoords(0);
|
|
2556
|
-
|
|
2557
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
2002
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
2558
2003
|
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
2559
2004
|
scroll = getNodeScroll(offsetParent);
|
|
2560
2005
|
}
|
|
@@ -2565,12 +2010,11 @@
|
|
|
2565
2010
|
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2566
2011
|
}
|
|
2567
2012
|
}
|
|
2568
|
-
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
|
|
2569
2013
|
return {
|
|
2570
2014
|
width: rect.width * scale.x,
|
|
2571
2015
|
height: rect.height * scale.y,
|
|
2572
|
-
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x
|
|
2573
|
-
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
|
|
2016
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
|
|
2017
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
|
|
2574
2018
|
};
|
|
2575
2019
|
}
|
|
2576
2020
|
|
|
@@ -2578,6 +2022,12 @@
|
|
|
2578
2022
|
return Array.from(element.getClientRects());
|
|
2579
2023
|
}
|
|
2580
2024
|
|
|
2025
|
+
function getWindowScrollBarX(element) {
|
|
2026
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
2027
|
+
// incorrect for RTL.
|
|
2028
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2581
2031
|
// Gets the entire size of the scrollable document area, even extending outside
|
|
2582
2032
|
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
2583
2033
|
function getDocumentRect(element) {
|
|
@@ -2652,10 +2102,9 @@
|
|
|
2652
2102
|
} else {
|
|
2653
2103
|
const visualOffsets = getVisualOffsets(element);
|
|
2654
2104
|
rect = {
|
|
2105
|
+
...clippingAncestor,
|
|
2655
2106
|
x: clippingAncestor.x - visualOffsets.x,
|
|
2656
|
-
y: clippingAncestor.y - visualOffsets.y
|
|
2657
|
-
width: clippingAncestor.width,
|
|
2658
|
-
height: clippingAncestor.height
|
|
2107
|
+
y: clippingAncestor.y - visualOffsets.y
|
|
2659
2108
|
};
|
|
2660
2109
|
}
|
|
2661
2110
|
return rectToClientRect(rect);
|
|
@@ -2711,7 +2160,7 @@
|
|
|
2711
2160
|
rootBoundary,
|
|
2712
2161
|
strategy
|
|
2713
2162
|
} = _ref;
|
|
2714
|
-
const elementClippingAncestors = boundary === 'clippingAncestors' ?
|
|
2163
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
2715
2164
|
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
2716
2165
|
const firstClippingAncestor = clippingAncestors[0];
|
|
2717
2166
|
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
@@ -2731,14 +2180,7 @@
|
|
|
2731
2180
|
}
|
|
2732
2181
|
|
|
2733
2182
|
function getDimensions(element) {
|
|
2734
|
-
|
|
2735
|
-
width,
|
|
2736
|
-
height
|
|
2737
|
-
} = getCssDimensions(element);
|
|
2738
|
-
return {
|
|
2739
|
-
width,
|
|
2740
|
-
height
|
|
2741
|
-
};
|
|
2183
|
+
return getCssDimensions(element);
|
|
2742
2184
|
}
|
|
2743
2185
|
|
|
2744
2186
|
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
@@ -2760,26 +2202,17 @@
|
|
|
2760
2202
|
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2761
2203
|
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2762
2204
|
} 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.
|
|
2765
2205
|
offsets.x = getWindowScrollBarX(documentElement);
|
|
2766
2206
|
}
|
|
2767
2207
|
}
|
|
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;
|
|
2771
2208
|
return {
|
|
2772
|
-
x,
|
|
2773
|
-
y,
|
|
2209
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
2210
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
2774
2211
|
width: rect.width,
|
|
2775
2212
|
height: rect.height
|
|
2776
2213
|
};
|
|
2777
2214
|
}
|
|
2778
2215
|
|
|
2779
|
-
function isStaticPositioned(element) {
|
|
2780
|
-
return getComputedStyle(element).position === 'static';
|
|
2781
|
-
}
|
|
2782
|
-
|
|
2783
2216
|
function getTrueOffsetParent(element, polyfill) {
|
|
2784
2217
|
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
|
2785
2218
|
return null;
|
|
@@ -2787,56 +2220,40 @@
|
|
|
2787
2220
|
if (polyfill) {
|
|
2788
2221
|
return polyfill(element);
|
|
2789
2222
|
}
|
|
2790
|
-
|
|
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
|
+
return element.offsetParent;
|
|
2800
2224
|
}
|
|
2801
2225
|
|
|
2802
2226
|
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
2803
2227
|
// such as table ancestors and cross browser bugs.
|
|
2804
2228
|
function getOffsetParent(element, polyfill) {
|
|
2805
|
-
const
|
|
2806
|
-
if (isTopLayer(element)) {
|
|
2807
|
-
return win;
|
|
2808
|
-
}
|
|
2229
|
+
const window = getWindow(element);
|
|
2809
2230
|
if (!isHTMLElement(element)) {
|
|
2810
|
-
|
|
2811
|
-
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
2812
|
-
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
2813
|
-
return svgOffsetParent;
|
|
2814
|
-
}
|
|
2815
|
-
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
2816
|
-
}
|
|
2817
|
-
return win;
|
|
2231
|
+
return window;
|
|
2818
2232
|
}
|
|
2819
2233
|
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
2820
|
-
while (offsetParent && isTableElement(offsetParent) &&
|
|
2234
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
|
2821
2235
|
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
2822
2236
|
}
|
|
2823
|
-
if (offsetParent &&
|
|
2824
|
-
return
|
|
2237
|
+
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
|
|
2238
|
+
return window;
|
|
2825
2239
|
}
|
|
2826
|
-
return offsetParent || getContainingBlock(element) ||
|
|
2240
|
+
return offsetParent || getContainingBlock(element) || window;
|
|
2827
2241
|
}
|
|
2828
2242
|
|
|
2829
|
-
const getElementRects = async function (
|
|
2243
|
+
const getElementRects = async function (_ref) {
|
|
2244
|
+
let {
|
|
2245
|
+
reference,
|
|
2246
|
+
floating,
|
|
2247
|
+
strategy
|
|
2248
|
+
} = _ref;
|
|
2830
2249
|
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
2831
2250
|
const getDimensionsFn = this.getDimensions;
|
|
2832
|
-
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
2833
2251
|
return {
|
|
2834
|
-
reference: getRectRelativeToOffsetParent(
|
|
2252
|
+
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
2835
2253
|
floating: {
|
|
2836
2254
|
x: 0,
|
|
2837
2255
|
y: 0,
|
|
2838
|
-
|
|
2839
|
-
height: floatingDimensions.height
|
|
2256
|
+
...(await getDimensionsFn(floating))
|
|
2840
2257
|
}
|
|
2841
2258
|
};
|
|
2842
2259
|
};
|
|
@@ -2858,75 +2275,10 @@
|
|
|
2858
2275
|
isRTL
|
|
2859
2276
|
};
|
|
2860
2277
|
|
|
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
|
-
|
|
2927
2278
|
/**
|
|
2928
2279
|
* Computes the `x` and `y` coordinates that will place the floating element
|
|
2929
|
-
* next to a given
|
|
2280
|
+
* next to a reference element when it is given a certain CSS positioning
|
|
2281
|
+
* strategy.
|
|
2930
2282
|
*/
|
|
2931
2283
|
const computePosition = (reference, floating, options) => {
|
|
2932
2284
|
// This caches the expensive `getClippingElementAncestors` function so that
|