@indico-data/design-system 2.34.2 → 2.34.4
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/lib/index.d.ts +5 -1
- package/lib/index.esm.js +828 -90
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +828 -90
- package/lib/index.js.map +1 -1
- package/lib/src/components/forms/input/Input.d.ts +3 -1
- package/lib/src/components/forms/passwordInput/PasswordInput.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/floatUI/FloatUI.test.tsx +1 -19
- package/src/components/floatUI/FloatUI.tsx +17 -14
- package/src/components/forms/input/Input.tsx +8 -2
- package/src/components/forms/numberInput/NumberInput.tsx +4 -0
- package/src/components/forms/passwordInput/PasswordInput.tsx +6 -0
- package/src/storybook/formArgTypes.ts +24 -0
- package/lib/src/hooks/useClickOutside.d.ts +0 -2
- package/src/hooks/useClickOutside.tsx +0 -22
package/lib/index.esm.js
CHANGED
|
@@ -1176,8 +1176,8 @@ const size$2 = function (options) {
|
|
|
1176
1176
|
};
|
|
1177
1177
|
};
|
|
1178
1178
|
|
|
1179
|
-
function getNodeName$
|
|
1180
|
-
if (isNode$
|
|
1179
|
+
function getNodeName$3(node) {
|
|
1180
|
+
if (isNode$2(node)) {
|
|
1181
1181
|
return (node.nodeName || '').toLowerCase();
|
|
1182
1182
|
}
|
|
1183
1183
|
// Mocked nodes in testing environments may not be instances of Node. By
|
|
@@ -1189,17 +1189,17 @@ function getWindow$3(node) {
|
|
|
1189
1189
|
var _node$ownerDocument;
|
|
1190
1190
|
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
1191
1191
|
}
|
|
1192
|
-
function getDocumentElement$
|
|
1192
|
+
function getDocumentElement$3(node) {
|
|
1193
1193
|
var _ref;
|
|
1194
|
-
return (_ref = (isNode$
|
|
1194
|
+
return (_ref = (isNode$2(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
1195
1195
|
}
|
|
1196
|
-
function isNode$
|
|
1196
|
+
function isNode$2(value) {
|
|
1197
1197
|
return value instanceof Node || value instanceof getWindow$3(value).Node;
|
|
1198
1198
|
}
|
|
1199
1199
|
function isElement$3(value) {
|
|
1200
1200
|
return value instanceof Element || value instanceof getWindow$3(value).Element;
|
|
1201
1201
|
}
|
|
1202
|
-
function isHTMLElement$
|
|
1202
|
+
function isHTMLElement$3(value) {
|
|
1203
1203
|
return value instanceof HTMLElement || value instanceof getWindow$3(value).HTMLElement;
|
|
1204
1204
|
}
|
|
1205
1205
|
function isShadowRoot$3(value) {
|
|
@@ -1215,11 +1215,11 @@ function isOverflowElement$1(element) {
|
|
|
1215
1215
|
overflowX,
|
|
1216
1216
|
overflowY,
|
|
1217
1217
|
display
|
|
1218
|
-
} = getComputedStyle$
|
|
1218
|
+
} = getComputedStyle$4(element);
|
|
1219
1219
|
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
1220
1220
|
}
|
|
1221
1221
|
function isTableElement$2(element) {
|
|
1222
|
-
return ['table', 'td', 'th'].includes(getNodeName$
|
|
1222
|
+
return ['table', 'td', 'th'].includes(getNodeName$3(element));
|
|
1223
1223
|
}
|
|
1224
1224
|
function isTopLayer$1(element) {
|
|
1225
1225
|
return [':popover-open', ':modal'].some(selector => {
|
|
@@ -1232,20 +1232,20 @@ function isTopLayer$1(element) {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
function isContainingBlock$1(elementOrCss) {
|
|
1234
1234
|
const webkit = isWebKit$1();
|
|
1235
|
-
const css = isElement$3(elementOrCss) ? getComputedStyle$
|
|
1235
|
+
const css = isElement$3(elementOrCss) ? getComputedStyle$4(elementOrCss) : elementOrCss;
|
|
1236
1236
|
|
|
1237
1237
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1238
1238
|
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));
|
|
1239
1239
|
}
|
|
1240
1240
|
function getContainingBlock$2(element) {
|
|
1241
|
-
let currentNode = getParentNode$
|
|
1242
|
-
while (isHTMLElement$
|
|
1241
|
+
let currentNode = getParentNode$3(element);
|
|
1242
|
+
while (isHTMLElement$3(currentNode) && !isLastTraversableNode$2(currentNode)) {
|
|
1243
1243
|
if (isContainingBlock$1(currentNode)) {
|
|
1244
1244
|
return currentNode;
|
|
1245
1245
|
} else if (isTopLayer$1(currentNode)) {
|
|
1246
1246
|
return null;
|
|
1247
1247
|
}
|
|
1248
|
-
currentNode = getParentNode$
|
|
1248
|
+
currentNode = getParentNode$3(currentNode);
|
|
1249
1249
|
}
|
|
1250
1250
|
return null;
|
|
1251
1251
|
}
|
|
@@ -1253,10 +1253,10 @@ function isWebKit$1() {
|
|
|
1253
1253
|
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
1254
1254
|
return CSS.supports('-webkit-backdrop-filter', 'none');
|
|
1255
1255
|
}
|
|
1256
|
-
function isLastTraversableNode$
|
|
1257
|
-
return ['html', 'body', '#document'].includes(getNodeName$
|
|
1256
|
+
function isLastTraversableNode$2(node) {
|
|
1257
|
+
return ['html', 'body', '#document'].includes(getNodeName$3(node));
|
|
1258
1258
|
}
|
|
1259
|
-
function getComputedStyle$
|
|
1259
|
+
function getComputedStyle$4(element) {
|
|
1260
1260
|
return getWindow$3(element).getComputedStyle(element);
|
|
1261
1261
|
}
|
|
1262
1262
|
function getNodeScroll$2(element) {
|
|
@@ -1271,8 +1271,8 @@ function getNodeScroll$2(element) {
|
|
|
1271
1271
|
scrollTop: element.scrollY
|
|
1272
1272
|
};
|
|
1273
1273
|
}
|
|
1274
|
-
function getParentNode$
|
|
1275
|
-
if (getNodeName$
|
|
1274
|
+
function getParentNode$3(node) {
|
|
1275
|
+
if (getNodeName$3(node) === 'html') {
|
|
1276
1276
|
return node;
|
|
1277
1277
|
}
|
|
1278
1278
|
const result =
|
|
@@ -1283,15 +1283,15 @@ function getParentNode$2(node) {
|
|
|
1283
1283
|
// ShadowRoot detected.
|
|
1284
1284
|
isShadowRoot$3(node) && node.host ||
|
|
1285
1285
|
// Fallback.
|
|
1286
|
-
getDocumentElement$
|
|
1286
|
+
getDocumentElement$3(node);
|
|
1287
1287
|
return isShadowRoot$3(result) ? result.host : result;
|
|
1288
1288
|
}
|
|
1289
1289
|
function getNearestOverflowAncestor$1(node) {
|
|
1290
|
-
const parentNode = getParentNode$
|
|
1291
|
-
if (isLastTraversableNode$
|
|
1290
|
+
const parentNode = getParentNode$3(node);
|
|
1291
|
+
if (isLastTraversableNode$2(parentNode)) {
|
|
1292
1292
|
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
1293
1293
|
}
|
|
1294
|
-
if (isHTMLElement$
|
|
1294
|
+
if (isHTMLElement$3(parentNode) && isOverflowElement$1(parentNode)) {
|
|
1295
1295
|
return parentNode;
|
|
1296
1296
|
}
|
|
1297
1297
|
return getNearestOverflowAncestor$1(parentNode);
|
|
@@ -1318,12 +1318,12 @@ function getFrameElement(win) {
|
|
|
1318
1318
|
}
|
|
1319
1319
|
|
|
1320
1320
|
function getCssDimensions$1(element) {
|
|
1321
|
-
const css = getComputedStyle$
|
|
1321
|
+
const css = getComputedStyle$4(element);
|
|
1322
1322
|
// In testing environments, the `width` and `height` properties are empty
|
|
1323
1323
|
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
1324
1324
|
let width = parseFloat(css.width) || 0;
|
|
1325
1325
|
let height = parseFloat(css.height) || 0;
|
|
1326
|
-
const hasOffset = isHTMLElement$
|
|
1326
|
+
const hasOffset = isHTMLElement$3(element);
|
|
1327
1327
|
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
1328
1328
|
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
1329
1329
|
const shouldFallback = round$2(width) !== offsetWidth || round$2(height) !== offsetHeight;
|
|
@@ -1344,7 +1344,7 @@ function unwrapElement$1(element) {
|
|
|
1344
1344
|
|
|
1345
1345
|
function getScale$1(element) {
|
|
1346
1346
|
const domElement = unwrapElement$1(element);
|
|
1347
|
-
if (!isHTMLElement$
|
|
1347
|
+
if (!isHTMLElement$3(domElement)) {
|
|
1348
1348
|
return createCoords$1(1);
|
|
1349
1349
|
}
|
|
1350
1350
|
const rect = domElement.getBoundingClientRect();
|
|
@@ -1423,7 +1423,7 @@ function getBoundingClientRect$2(element, includeScale, isFixedStrategy, offsetP
|
|
|
1423
1423
|
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
1424
1424
|
const iframeScale = getScale$1(currentIFrame);
|
|
1425
1425
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1426
|
-
const css = getComputedStyle$
|
|
1426
|
+
const css = getComputedStyle$4(currentIFrame);
|
|
1427
1427
|
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1428
1428
|
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1429
1429
|
x *= iframeScale.x;
|
|
@@ -1452,7 +1452,7 @@ function convertOffsetParentRelativeRectToViewportRelativeRect$1(_ref) {
|
|
|
1452
1452
|
strategy
|
|
1453
1453
|
} = _ref;
|
|
1454
1454
|
const isFixed = strategy === 'fixed';
|
|
1455
|
-
const documentElement = getDocumentElement$
|
|
1455
|
+
const documentElement = getDocumentElement$3(offsetParent);
|
|
1456
1456
|
const topLayer = elements ? isTopLayer$1(elements.floating) : false;
|
|
1457
1457
|
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
1458
1458
|
return rect;
|
|
@@ -1463,12 +1463,12 @@ function convertOffsetParentRelativeRectToViewportRelativeRect$1(_ref) {
|
|
|
1463
1463
|
};
|
|
1464
1464
|
let scale = createCoords$1(1);
|
|
1465
1465
|
const offsets = createCoords$1(0);
|
|
1466
|
-
const isOffsetParentAnElement = isHTMLElement$
|
|
1466
|
+
const isOffsetParentAnElement = isHTMLElement$3(offsetParent);
|
|
1467
1467
|
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1468
|
-
if (getNodeName$
|
|
1468
|
+
if (getNodeName$3(offsetParent) !== 'body' || isOverflowElement$1(documentElement)) {
|
|
1469
1469
|
scroll = getNodeScroll$2(offsetParent);
|
|
1470
1470
|
}
|
|
1471
|
-
if (isHTMLElement$
|
|
1471
|
+
if (isHTMLElement$3(offsetParent)) {
|
|
1472
1472
|
const offsetRect = getBoundingClientRect$2(offsetParent);
|
|
1473
1473
|
scale = getScale$1(offsetParent);
|
|
1474
1474
|
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
@@ -1490,20 +1490,20 @@ function getClientRects$1(element) {
|
|
|
1490
1490
|
function getWindowScrollBarX$2(element) {
|
|
1491
1491
|
// If <html> has a CSS width greater than the viewport, then this will be
|
|
1492
1492
|
// incorrect for RTL.
|
|
1493
|
-
return getBoundingClientRect$2(getDocumentElement$
|
|
1493
|
+
return getBoundingClientRect$2(getDocumentElement$3(element)).left + getNodeScroll$2(element).scrollLeft;
|
|
1494
1494
|
}
|
|
1495
1495
|
|
|
1496
1496
|
// Gets the entire size of the scrollable document area, even extending outside
|
|
1497
1497
|
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
1498
1498
|
function getDocumentRect$2(element) {
|
|
1499
|
-
const html = getDocumentElement$
|
|
1499
|
+
const html = getDocumentElement$3(element);
|
|
1500
1500
|
const scroll = getNodeScroll$2(element);
|
|
1501
1501
|
const body = element.ownerDocument.body;
|
|
1502
1502
|
const width = max$3(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1503
1503
|
const height = max$3(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1504
1504
|
let x = -scroll.scrollLeft + getWindowScrollBarX$2(element);
|
|
1505
1505
|
const y = -scroll.scrollTop;
|
|
1506
|
-
if (getComputedStyle$
|
|
1506
|
+
if (getComputedStyle$4(body).direction === 'rtl') {
|
|
1507
1507
|
x += max$3(html.clientWidth, body.clientWidth) - width;
|
|
1508
1508
|
}
|
|
1509
1509
|
return {
|
|
@@ -1516,7 +1516,7 @@ function getDocumentRect$2(element) {
|
|
|
1516
1516
|
|
|
1517
1517
|
function getViewportRect$2(element, strategy) {
|
|
1518
1518
|
const win = getWindow$3(element);
|
|
1519
|
-
const html = getDocumentElement$
|
|
1519
|
+
const html = getDocumentElement$3(element);
|
|
1520
1520
|
const visualViewport = win.visualViewport;
|
|
1521
1521
|
let width = html.clientWidth;
|
|
1522
1522
|
let height = html.clientHeight;
|
|
@@ -1544,7 +1544,7 @@ function getInnerBoundingClientRect$2(element, strategy) {
|
|
|
1544
1544
|
const clientRect = getBoundingClientRect$2(element, true, strategy === 'fixed');
|
|
1545
1545
|
const top = clientRect.top + element.clientTop;
|
|
1546
1546
|
const left = clientRect.left + element.clientLeft;
|
|
1547
|
-
const scale = isHTMLElement$
|
|
1547
|
+
const scale = isHTMLElement$3(element) ? getScale$1(element) : createCoords$1(1);
|
|
1548
1548
|
const width = element.clientWidth * scale.x;
|
|
1549
1549
|
const height = element.clientHeight * scale.y;
|
|
1550
1550
|
const x = left * scale.x;
|
|
@@ -1561,7 +1561,7 @@ function getClientRectFromClippingAncestor$1(element, clippingAncestor, strategy
|
|
|
1561
1561
|
if (clippingAncestor === 'viewport') {
|
|
1562
1562
|
rect = getViewportRect$2(element, strategy);
|
|
1563
1563
|
} else if (clippingAncestor === 'document') {
|
|
1564
|
-
rect = getDocumentRect$2(getDocumentElement$
|
|
1564
|
+
rect = getDocumentRect$2(getDocumentElement$3(element));
|
|
1565
1565
|
} else if (isElement$3(clippingAncestor)) {
|
|
1566
1566
|
rect = getInnerBoundingClientRect$2(clippingAncestor, strategy);
|
|
1567
1567
|
} else {
|
|
@@ -1575,11 +1575,11 @@ function getClientRectFromClippingAncestor$1(element, clippingAncestor, strategy
|
|
|
1575
1575
|
return rectToClientRect$2(rect);
|
|
1576
1576
|
}
|
|
1577
1577
|
function hasFixedPositionAncestor$1(element, stopNode) {
|
|
1578
|
-
const parentNode = getParentNode$
|
|
1579
|
-
if (parentNode === stopNode || !isElement$3(parentNode) || isLastTraversableNode$
|
|
1578
|
+
const parentNode = getParentNode$3(element);
|
|
1579
|
+
if (parentNode === stopNode || !isElement$3(parentNode) || isLastTraversableNode$2(parentNode)) {
|
|
1580
1580
|
return false;
|
|
1581
1581
|
}
|
|
1582
|
-
return getComputedStyle$
|
|
1582
|
+
return getComputedStyle$4(parentNode).position === 'fixed' || hasFixedPositionAncestor$1(parentNode, stopNode);
|
|
1583
1583
|
}
|
|
1584
1584
|
|
|
1585
1585
|
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
@@ -1590,14 +1590,14 @@ function getClippingElementAncestors$1(element, cache) {
|
|
|
1590
1590
|
if (cachedResult) {
|
|
1591
1591
|
return cachedResult;
|
|
1592
1592
|
}
|
|
1593
|
-
let result = getOverflowAncestors$1(element, [], false).filter(el => isElement$3(el) && getNodeName$
|
|
1593
|
+
let result = getOverflowAncestors$1(element, [], false).filter(el => isElement$3(el) && getNodeName$3(el) !== 'body');
|
|
1594
1594
|
let currentContainingBlockComputedStyle = null;
|
|
1595
|
-
const elementIsFixed = getComputedStyle$
|
|
1596
|
-
let currentNode = elementIsFixed ? getParentNode$
|
|
1595
|
+
const elementIsFixed = getComputedStyle$4(element).position === 'fixed';
|
|
1596
|
+
let currentNode = elementIsFixed ? getParentNode$3(element) : element;
|
|
1597
1597
|
|
|
1598
1598
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1599
|
-
while (isElement$3(currentNode) && !isLastTraversableNode$
|
|
1600
|
-
const computedStyle = getComputedStyle$
|
|
1599
|
+
while (isElement$3(currentNode) && !isLastTraversableNode$2(currentNode)) {
|
|
1600
|
+
const computedStyle = getComputedStyle$4(currentNode);
|
|
1601
1601
|
const currentNodeIsContaining = isContainingBlock$1(currentNode);
|
|
1602
1602
|
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
1603
1603
|
currentContainingBlockComputedStyle = null;
|
|
@@ -1610,7 +1610,7 @@ function getClippingElementAncestors$1(element, cache) {
|
|
|
1610
1610
|
// Record last containing block for next iteration.
|
|
1611
1611
|
currentContainingBlockComputedStyle = computedStyle;
|
|
1612
1612
|
}
|
|
1613
|
-
currentNode = getParentNode$
|
|
1613
|
+
currentNode = getParentNode$3(currentNode);
|
|
1614
1614
|
}
|
|
1615
1615
|
cache.set(element, result);
|
|
1616
1616
|
return result;
|
|
@@ -1656,8 +1656,8 @@ function getDimensions$1(element) {
|
|
|
1656
1656
|
}
|
|
1657
1657
|
|
|
1658
1658
|
function getRectRelativeToOffsetParent$1(element, offsetParent, strategy) {
|
|
1659
|
-
const isOffsetParentAnElement = isHTMLElement$
|
|
1660
|
-
const documentElement = getDocumentElement$
|
|
1659
|
+
const isOffsetParentAnElement = isHTMLElement$3(offsetParent);
|
|
1660
|
+
const documentElement = getDocumentElement$3(offsetParent);
|
|
1661
1661
|
const isFixed = strategy === 'fixed';
|
|
1662
1662
|
const rect = getBoundingClientRect$2(element, true, isFixed, offsetParent);
|
|
1663
1663
|
let scroll = {
|
|
@@ -1666,7 +1666,7 @@ function getRectRelativeToOffsetParent$1(element, offsetParent, strategy) {
|
|
|
1666
1666
|
};
|
|
1667
1667
|
const offsets = createCoords$1(0);
|
|
1668
1668
|
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1669
|
-
if (getNodeName$
|
|
1669
|
+
if (getNodeName$3(offsetParent) !== 'body' || isOverflowElement$1(documentElement)) {
|
|
1670
1670
|
scroll = getNodeScroll$2(offsetParent);
|
|
1671
1671
|
}
|
|
1672
1672
|
if (isOffsetParentAnElement) {
|
|
@@ -1688,11 +1688,11 @@ function getRectRelativeToOffsetParent$1(element, offsetParent, strategy) {
|
|
|
1688
1688
|
}
|
|
1689
1689
|
|
|
1690
1690
|
function isStaticPositioned$1(element) {
|
|
1691
|
-
return getComputedStyle$
|
|
1691
|
+
return getComputedStyle$4(element).position === 'static';
|
|
1692
1692
|
}
|
|
1693
1693
|
|
|
1694
1694
|
function getTrueOffsetParent$2(element, polyfill) {
|
|
1695
|
-
if (!isHTMLElement$
|
|
1695
|
+
if (!isHTMLElement$3(element) || getComputedStyle$4(element).position === 'fixed') {
|
|
1696
1696
|
return null;
|
|
1697
1697
|
}
|
|
1698
1698
|
if (polyfill) {
|
|
@@ -1708,13 +1708,13 @@ function getOffsetParent$2(element, polyfill) {
|
|
|
1708
1708
|
if (isTopLayer$1(element)) {
|
|
1709
1709
|
return win;
|
|
1710
1710
|
}
|
|
1711
|
-
if (!isHTMLElement$
|
|
1712
|
-
let svgOffsetParent = getParentNode$
|
|
1713
|
-
while (svgOffsetParent && !isLastTraversableNode$
|
|
1711
|
+
if (!isHTMLElement$3(element)) {
|
|
1712
|
+
let svgOffsetParent = getParentNode$3(element);
|
|
1713
|
+
while (svgOffsetParent && !isLastTraversableNode$2(svgOffsetParent)) {
|
|
1714
1714
|
if (isElement$3(svgOffsetParent) && !isStaticPositioned$1(svgOffsetParent)) {
|
|
1715
1715
|
return svgOffsetParent;
|
|
1716
1716
|
}
|
|
1717
|
-
svgOffsetParent = getParentNode$
|
|
1717
|
+
svgOffsetParent = getParentNode$3(svgOffsetParent);
|
|
1718
1718
|
}
|
|
1719
1719
|
return win;
|
|
1720
1720
|
}
|
|
@@ -1722,7 +1722,7 @@ function getOffsetParent$2(element, polyfill) {
|
|
|
1722
1722
|
while (offsetParent && isTableElement$2(offsetParent) && isStaticPositioned$1(offsetParent)) {
|
|
1723
1723
|
offsetParent = getTrueOffsetParent$2(offsetParent, polyfill);
|
|
1724
1724
|
}
|
|
1725
|
-
if (offsetParent && isLastTraversableNode$
|
|
1725
|
+
if (offsetParent && isLastTraversableNode$2(offsetParent) && isStaticPositioned$1(offsetParent) && !isContainingBlock$1(offsetParent)) {
|
|
1726
1726
|
return win;
|
|
1727
1727
|
}
|
|
1728
1728
|
return offsetParent || getContainingBlock$2(element) || win;
|
|
@@ -1744,12 +1744,12 @@ const getElementRects$1 = async function (data) {
|
|
|
1744
1744
|
};
|
|
1745
1745
|
|
|
1746
1746
|
function isRTL$1(element) {
|
|
1747
|
-
return getComputedStyle$
|
|
1747
|
+
return getComputedStyle$4(element).direction === 'rtl';
|
|
1748
1748
|
}
|
|
1749
1749
|
|
|
1750
1750
|
const platform$1 = {
|
|
1751
1751
|
convertOffsetParentRelativeRectToViewportRelativeRect: convertOffsetParentRelativeRectToViewportRelativeRect$1,
|
|
1752
|
-
getDocumentElement: getDocumentElement$
|
|
1752
|
+
getDocumentElement: getDocumentElement$3,
|
|
1753
1753
|
getClippingRect: getClippingRect$2,
|
|
1754
1754
|
getOffsetParent: getOffsetParent$2,
|
|
1755
1755
|
getElementRects: getElementRects$1,
|
|
@@ -1764,7 +1764,7 @@ const platform$1 = {
|
|
|
1764
1764
|
function observeMove$1(element, onMove) {
|
|
1765
1765
|
let io = null;
|
|
1766
1766
|
let timeoutId;
|
|
1767
|
-
const root = getDocumentElement$
|
|
1767
|
+
const root = getDocumentElement$3(element);
|
|
1768
1768
|
function cleanup() {
|
|
1769
1769
|
var _io;
|
|
1770
1770
|
clearTimeout(timeoutId);
|
|
@@ -2092,7 +2092,7 @@ function useLatestRef(value) {
|
|
|
2092
2092
|
* Provides data to position a floating element.
|
|
2093
2093
|
* @see https://floating-ui.com/docs/useFloating
|
|
2094
2094
|
*/
|
|
2095
|
-
function useFloating(options) {
|
|
2095
|
+
function useFloating$1(options) {
|
|
2096
2096
|
if (options === void 0) {
|
|
2097
2097
|
options = {};
|
|
2098
2098
|
}
|
|
@@ -20964,7 +20964,7 @@ const DisplayFormError = ({ message }) => {
|
|
|
20964
20964
|
};
|
|
20965
20965
|
|
|
20966
20966
|
const Input = React__default.forwardRef((_a, ref) => {
|
|
20967
|
-
var { name, placeholder,
|
|
20967
|
+
var { name, placeholder, isRequired, isDisabled, isClearable, errorMessage, helpText, iconName, onChange, onBlur, onKeyDown, className } = _a, rest = __rest$1(_a, ["name", "placeholder", "isRequired", "isDisabled", "isClearable", "errorMessage", "helpText", "iconName", "onChange", "onBlur", "onKeyDown", "className"]);
|
|
20968
20968
|
const hasErrors = errorMessage && errorMessage.length > 0;
|
|
20969
20969
|
const handleClear = () => {
|
|
20970
20970
|
onChange({ target: { value: '' } });
|
|
@@ -20973,7 +20973,7 @@ const Input = React__default.forwardRef((_a, ref) => {
|
|
|
20973
20973
|
error: hasErrors,
|
|
20974
20974
|
'input--has-icon': iconName,
|
|
20975
20975
|
}, className);
|
|
20976
|
-
return (jsxs(Fragment, { children: [jsxs("div", { className: "input-wrapper", children: [iconName && (jsx(Icon, { name: iconName, "data-testid": `${name}-embedded-icon`, className: "embedded-icon" })), jsx("input", Object.assign({ ref: ref, "data-testid": `form-input-${name}`, name: name, type: "text", disabled: isDisabled, placeholder: placeholder, onChange: onChange, className: inputClasses, "aria-invalid": hasErrors ? true : undefined, "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired }, rest)), isClearable && !isDisabled && (jsx(Icon, { name: "x-close", "data-testid": `${name}-clearable-icon`, size: "sm", onClick: handleClear, className: "clearable-icon" }))] }), hasErrors && jsx(DisplayFormError, { message: errorMessage }), helpText && (jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
|
|
20976
|
+
return (jsxs(Fragment, { children: [jsxs("div", { className: "input-wrapper", children: [iconName && (jsx(Icon, { name: iconName, "data-testid": `${name}-embedded-icon`, className: "embedded-icon" })), jsx("input", Object.assign({ ref: ref, "data-testid": `form-input-${name}`, name: name, type: "text", disabled: isDisabled, placeholder: placeholder, onChange: onChange, onBlur: onBlur, onKeyDown: onKeyDown, className: inputClasses, "aria-invalid": hasErrors ? true : undefined, "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired }, rest)), isClearable && !isDisabled && (jsx(Icon, { name: "x-close", "data-testid": `${name}-clearable-icon`, size: "sm", onClick: handleClear, className: "clearable-icon" }))] }), hasErrors && jsx(DisplayFormError, { message: errorMessage }), helpText && (jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
|
|
20977
20977
|
});
|
|
20978
20978
|
const LabeledInput = withLabel(Input);
|
|
20979
20979
|
|
|
@@ -21001,7 +21001,7 @@ const Textarea = React__default.forwardRef((_a, ref) => {
|
|
|
21001
21001
|
const LabeledTextarea = withLabel(Textarea);
|
|
21002
21002
|
|
|
21003
21003
|
const PasswordInput = React__default.forwardRef((_a, ref) => {
|
|
21004
|
-
var { name, placeholder, onChange, isRequired, isDisabled, errorMessage, helpText, hasShowPassword = true } = _a, rest = __rest$1(_a, ["name", "placeholder", "onChange", "isRequired", "isDisabled", "errorMessage", "helpText", "hasShowPassword"]);
|
|
21004
|
+
var { name, placeholder, onChange, onBlur, onKeyDown, isRequired, isDisabled, errorMessage, helpText, hasShowPassword = true } = _a, rest = __rest$1(_a, ["name", "placeholder", "onChange", "onBlur", "onKeyDown", "isRequired", "isDisabled", "errorMessage", "helpText", "hasShowPassword"]);
|
|
21005
21005
|
const hasErrors = errorMessage && errorMessage.length > 0;
|
|
21006
21006
|
const [showPassword, setShowPassword] = useState(false);
|
|
21007
21007
|
const handleShowPassword = () => {
|
|
@@ -21010,7 +21010,7 @@ const PasswordInput = React__default.forwardRef((_a, ref) => {
|
|
|
21010
21010
|
const inputClasses = classNames('password-input', {
|
|
21011
21011
|
error: hasErrors,
|
|
21012
21012
|
}, 'password-input--has-icon');
|
|
21013
|
-
return (jsxs(Fragment, { children: [jsxs("div", { className: "password-input-wrapper", children: [jsx(Icon, { name: "lock", "data-testid": `${name}-embedded-icon`, className: "embedded-icon" }), jsx("input", Object.assign({ ref: ref, "data-testid": `form-password-input-${name}`, name: name, type: showPassword ? 'text' : 'password', disabled: isDisabled, placeholder: placeholder, onChange: onChange, className: inputClasses, "aria-invalid": hasErrors ? 'true' : 'false', "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired }, rest)), hasShowPassword && (jsx(Icon, { name: showPassword ? 'fa-eye-slash' : 'eye', "data-testid": `${name}-${showPassword ? 'hide' : 'show'}-password-icon`, size: "md", onClick: handleShowPassword, className: "toggle-show-password-icon" }))] }), hasErrors && jsx(DisplayFormError, { message: errorMessage }), helpText && (jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
|
|
21013
|
+
return (jsxs(Fragment, { children: [jsxs("div", { className: "password-input-wrapper", children: [jsx(Icon, { name: "lock", "data-testid": `${name}-embedded-icon`, className: "embedded-icon" }), jsx("input", Object.assign({ ref: ref, "data-testid": `form-password-input-${name}`, name: name, type: showPassword ? 'text' : 'password', disabled: isDisabled, placeholder: placeholder, onChange: onChange, onBlur: onBlur, onKeyDown: onKeyDown, className: inputClasses, "aria-invalid": hasErrors ? 'true' : 'false', "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired }, rest)), hasShowPassword && (jsx(Icon, { name: showPassword ? 'fa-eye-slash' : 'eye', "data-testid": `${name}-${showPassword ? 'hide' : 'show'}-password-icon`, size: "md", onClick: handleShowPassword, className: "toggle-show-password-icon" }))] }), hasErrors && jsx(DisplayFormError, { message: errorMessage }), helpText && (jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
|
|
21014
21014
|
});
|
|
21015
21015
|
const LabeledPasswordInput = withLabel(PasswordInput);
|
|
21016
21016
|
|
|
@@ -21062,13 +21062,32 @@ const Card = (_a) => {
|
|
|
21062
21062
|
return (jsxs("div", Object.assign({ className: cardClasses }, rest, { children: [(title || subtitle) && (jsxs("div", { className: "card__header", children: [title && jsx("h2", { children: title }), subtitle && jsx("p", { children: subtitle })] })), jsx("div", { className: "card__content", children: children })] })));
|
|
21063
21063
|
};
|
|
21064
21064
|
|
|
21065
|
+
function getNodeName$2(node) {
|
|
21066
|
+
if (isNode$1(node)) {
|
|
21067
|
+
return (node.nodeName || '').toLowerCase();
|
|
21068
|
+
}
|
|
21069
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
21070
|
+
// returning `#document` an infinite loop won't occur.
|
|
21071
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
21072
|
+
return '#document';
|
|
21073
|
+
}
|
|
21065
21074
|
function getWindow$2(node) {
|
|
21066
21075
|
var _node$ownerDocument;
|
|
21067
21076
|
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
21068
21077
|
}
|
|
21078
|
+
function getDocumentElement$2(node) {
|
|
21079
|
+
var _ref;
|
|
21080
|
+
return (_ref = (isNode$1(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
21081
|
+
}
|
|
21082
|
+
function isNode$1(value) {
|
|
21083
|
+
return value instanceof Node || value instanceof getWindow$2(value).Node;
|
|
21084
|
+
}
|
|
21069
21085
|
function isElement$2(value) {
|
|
21070
21086
|
return value instanceof Element || value instanceof getWindow$2(value).Element;
|
|
21071
21087
|
}
|
|
21088
|
+
function isHTMLElement$2(value) {
|
|
21089
|
+
return value instanceof HTMLElement || value instanceof getWindow$2(value).HTMLElement;
|
|
21090
|
+
}
|
|
21072
21091
|
function isShadowRoot$2(value) {
|
|
21073
21092
|
// Browsers without `ShadowRoot` support.
|
|
21074
21093
|
if (typeof ShadowRoot === 'undefined') {
|
|
@@ -21076,6 +21095,27 @@ function isShadowRoot$2(value) {
|
|
|
21076
21095
|
}
|
|
21077
21096
|
return value instanceof ShadowRoot || value instanceof getWindow$2(value).ShadowRoot;
|
|
21078
21097
|
}
|
|
21098
|
+
function isLastTraversableNode$1(node) {
|
|
21099
|
+
return ['html', 'body', '#document'].includes(getNodeName$2(node));
|
|
21100
|
+
}
|
|
21101
|
+
function getComputedStyle$3(element) {
|
|
21102
|
+
return getWindow$2(element).getComputedStyle(element);
|
|
21103
|
+
}
|
|
21104
|
+
function getParentNode$2(node) {
|
|
21105
|
+
if (getNodeName$2(node) === 'html') {
|
|
21106
|
+
return node;
|
|
21107
|
+
}
|
|
21108
|
+
const result =
|
|
21109
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
21110
|
+
node.assignedSlot ||
|
|
21111
|
+
// DOM Element detected.
|
|
21112
|
+
node.parentNode ||
|
|
21113
|
+
// ShadowRoot detected.
|
|
21114
|
+
isShadowRoot$2(node) && node.host ||
|
|
21115
|
+
// Fallback.
|
|
21116
|
+
getDocumentElement$2(node);
|
|
21117
|
+
return isShadowRoot$2(result) ? result.host : result;
|
|
21118
|
+
}
|
|
21079
21119
|
|
|
21080
21120
|
function activeElement(doc) {
|
|
21081
21121
|
let activeElement = doc.activeElement;
|
|
@@ -21115,9 +21155,46 @@ function isSafari() {
|
|
|
21115
21155
|
// Chrome DevTools does not complain about navigator.vendor
|
|
21116
21156
|
return /apple/i.test(navigator.vendor);
|
|
21117
21157
|
}
|
|
21158
|
+
function isMouseLikePointerType(pointerType, strict) {
|
|
21159
|
+
// On some Linux machines with Chromium, mouse inputs return a `pointerType`
|
|
21160
|
+
// of "pen": https://github.com/floating-ui/floating-ui/issues/2015
|
|
21161
|
+
const values = ['mouse', 'pen'];
|
|
21162
|
+
return values.includes(pointerType);
|
|
21163
|
+
}
|
|
21164
|
+
function isReactEvent(event) {
|
|
21165
|
+
return 'nativeEvent' in event;
|
|
21166
|
+
}
|
|
21167
|
+
function isRootElement(element) {
|
|
21168
|
+
return element.matches('html,body');
|
|
21169
|
+
}
|
|
21118
21170
|
function getDocument(node) {
|
|
21119
21171
|
return (node == null ? void 0 : node.ownerDocument) || document;
|
|
21120
21172
|
}
|
|
21173
|
+
function isEventTargetWithin(event, node) {
|
|
21174
|
+
if (node == null) {
|
|
21175
|
+
return false;
|
|
21176
|
+
}
|
|
21177
|
+
if ('composedPath' in event) {
|
|
21178
|
+
return event.composedPath().includes(node);
|
|
21179
|
+
}
|
|
21180
|
+
|
|
21181
|
+
// TS thinks `event` is of type never as it assumes all browsers support composedPath, but browsers without shadow dom don't
|
|
21182
|
+
const e = event;
|
|
21183
|
+
return e.target != null && node.contains(e.target);
|
|
21184
|
+
}
|
|
21185
|
+
function getTarget(event) {
|
|
21186
|
+
if ('composedPath' in event) {
|
|
21187
|
+
return event.composedPath()[0];
|
|
21188
|
+
}
|
|
21189
|
+
|
|
21190
|
+
// TS thinks `event` is of type never as it assumes all browsers support
|
|
21191
|
+
// `composedPath()`, but browsers without shadow DOM don't.
|
|
21192
|
+
return event.target;
|
|
21193
|
+
}
|
|
21194
|
+
const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled])," + "[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
|
|
21195
|
+
function isTypeableElement(element) {
|
|
21196
|
+
return isHTMLElement$2(element) && element.matches(TYPEABLE_SELECTOR);
|
|
21197
|
+
}
|
|
21121
21198
|
|
|
21122
21199
|
/*!
|
|
21123
21200
|
* tabbable 6.2.0
|
|
@@ -21702,6 +21779,25 @@ const SafeReact = {
|
|
|
21702
21779
|
...React$1
|
|
21703
21780
|
};
|
|
21704
21781
|
|
|
21782
|
+
const useInsertionEffect = SafeReact.useInsertionEffect;
|
|
21783
|
+
const useSafeInsertionEffect = useInsertionEffect || (fn => fn());
|
|
21784
|
+
function useEffectEvent(callback) {
|
|
21785
|
+
const ref = React$1.useRef(() => {
|
|
21786
|
+
if (process.env.NODE_ENV !== "production") {
|
|
21787
|
+
throw new Error('Cannot call an event handler while rendering.');
|
|
21788
|
+
}
|
|
21789
|
+
});
|
|
21790
|
+
useSafeInsertionEffect(() => {
|
|
21791
|
+
ref.current = callback;
|
|
21792
|
+
});
|
|
21793
|
+
return React$1.useCallback(function () {
|
|
21794
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
21795
|
+
args[_key] = arguments[_key];
|
|
21796
|
+
}
|
|
21797
|
+
return ref.current == null ? void 0 : ref.current(...args);
|
|
21798
|
+
}, []);
|
|
21799
|
+
}
|
|
21800
|
+
|
|
21705
21801
|
var index = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
|
|
21706
21802
|
|
|
21707
21803
|
function _extends$1() {
|
|
@@ -21746,12 +21842,81 @@ const useReactId = SafeReact.useId;
|
|
|
21746
21842
|
* @see https://floating-ui.com/docs/react-utils#useid
|
|
21747
21843
|
*/
|
|
21748
21844
|
const useId$1 = useReactId || useFloatingId;
|
|
21749
|
-
|
|
21845
|
+
|
|
21846
|
+
let devMessageSet;
|
|
21847
|
+
if (process.env.NODE_ENV !== "production") {
|
|
21848
|
+
devMessageSet = /*#__PURE__*/new Set();
|
|
21849
|
+
}
|
|
21850
|
+
function error() {
|
|
21851
|
+
var _devMessageSet3;
|
|
21852
|
+
for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
21853
|
+
messages[_key2] = arguments[_key2];
|
|
21854
|
+
}
|
|
21855
|
+
const message = "Floating UI: " + messages.join(' ');
|
|
21856
|
+
if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
|
|
21857
|
+
var _devMessageSet4;
|
|
21858
|
+
(_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
|
|
21859
|
+
console.error(message);
|
|
21860
|
+
}
|
|
21861
|
+
}
|
|
21862
|
+
|
|
21863
|
+
function createPubSub() {
|
|
21864
|
+
const map = new Map();
|
|
21865
|
+
return {
|
|
21866
|
+
emit(event, data) {
|
|
21867
|
+
var _map$get;
|
|
21868
|
+
(_map$get = map.get(event)) == null || _map$get.forEach(handler => handler(data));
|
|
21869
|
+
},
|
|
21870
|
+
on(event, listener) {
|
|
21871
|
+
map.set(event, [...(map.get(event) || []), listener]);
|
|
21872
|
+
},
|
|
21873
|
+
off(event, listener) {
|
|
21874
|
+
var _map$get2;
|
|
21875
|
+
map.set(event, ((_map$get2 = map.get(event)) == null ? void 0 : _map$get2.filter(l => l !== listener)) || []);
|
|
21876
|
+
}
|
|
21877
|
+
};
|
|
21878
|
+
}
|
|
21879
|
+
|
|
21880
|
+
const FloatingNodeContext = /*#__PURE__*/React$1.createContext(null);
|
|
21881
|
+
const FloatingTreeContext = /*#__PURE__*/React$1.createContext(null);
|
|
21882
|
+
|
|
21883
|
+
/**
|
|
21884
|
+
* Returns the parent node id for nested floating elements, if available.
|
|
21885
|
+
* Returns `null` for top-level floating elements.
|
|
21886
|
+
*/
|
|
21887
|
+
const useFloatingParentNodeId = () => {
|
|
21888
|
+
var _React$useContext;
|
|
21889
|
+
return ((_React$useContext = React$1.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
|
|
21890
|
+
};
|
|
21891
|
+
|
|
21892
|
+
/**
|
|
21893
|
+
* Returns the nearest floating tree context, if available.
|
|
21894
|
+
*/
|
|
21895
|
+
const useFloatingTree = () => React$1.useContext(FloatingTreeContext);
|
|
21750
21896
|
|
|
21751
21897
|
function createAttribute(name) {
|
|
21752
21898
|
return "data-floating-ui-" + name;
|
|
21753
21899
|
}
|
|
21754
21900
|
|
|
21901
|
+
function getChildren(nodes, id) {
|
|
21902
|
+
let allChildren = nodes.filter(node => {
|
|
21903
|
+
var _node$context;
|
|
21904
|
+
return node.parentId === id && ((_node$context = node.context) == null ? void 0 : _node$context.open);
|
|
21905
|
+
});
|
|
21906
|
+
let currentChildren = allChildren;
|
|
21907
|
+
while (currentChildren.length) {
|
|
21908
|
+
currentChildren = nodes.filter(node => {
|
|
21909
|
+
var _currentChildren;
|
|
21910
|
+
return (_currentChildren = currentChildren) == null ? void 0 : _currentChildren.some(n => {
|
|
21911
|
+
var _node$context2;
|
|
21912
|
+
return node.parentId === n.id && ((_node$context2 = node.context) == null ? void 0 : _node$context2.open);
|
|
21913
|
+
});
|
|
21914
|
+
});
|
|
21915
|
+
allChildren = allChildren.concat(currentChildren);
|
|
21916
|
+
}
|
|
21917
|
+
return allChildren;
|
|
21918
|
+
}
|
|
21919
|
+
|
|
21755
21920
|
const getTabbableOptions = () => ({
|
|
21756
21921
|
getShadowRoot: true,
|
|
21757
21922
|
displayCheck:
|
|
@@ -22016,22 +22181,599 @@ function FloatingPortal(props) {
|
|
|
22016
22181
|
}
|
|
22017
22182
|
const usePortalContext = () => React$1.useContext(PortalContext);
|
|
22018
22183
|
|
|
22019
|
-
|
|
22020
|
-
|
|
22021
|
-
|
|
22022
|
-
|
|
22023
|
-
|
|
22024
|
-
|
|
22025
|
-
|
|
22026
|
-
|
|
22027
|
-
|
|
22028
|
-
|
|
22029
|
-
|
|
22030
|
-
|
|
22031
|
-
|
|
22032
|
-
|
|
22033
|
-
|
|
22184
|
+
function isButtonTarget(event) {
|
|
22185
|
+
return isHTMLElement$2(event.target) && event.target.tagName === 'BUTTON';
|
|
22186
|
+
}
|
|
22187
|
+
function isSpaceIgnored(element) {
|
|
22188
|
+
return isTypeableElement(element);
|
|
22189
|
+
}
|
|
22190
|
+
/**
|
|
22191
|
+
* Opens or closes the floating element when clicking the reference element.
|
|
22192
|
+
* @see https://floating-ui.com/docs/useClick
|
|
22193
|
+
*/
|
|
22194
|
+
function useClick(context, props) {
|
|
22195
|
+
if (props === void 0) {
|
|
22196
|
+
props = {};
|
|
22197
|
+
}
|
|
22198
|
+
const {
|
|
22199
|
+
open,
|
|
22200
|
+
onOpenChange,
|
|
22201
|
+
dataRef,
|
|
22202
|
+
elements: {
|
|
22203
|
+
domReference
|
|
22204
|
+
}
|
|
22205
|
+
} = context;
|
|
22206
|
+
const {
|
|
22207
|
+
enabled = true,
|
|
22208
|
+
event: eventOption = 'click',
|
|
22209
|
+
toggle = true,
|
|
22210
|
+
ignoreMouse = false,
|
|
22211
|
+
keyboardHandlers = true
|
|
22212
|
+
} = props;
|
|
22213
|
+
const pointerTypeRef = React$1.useRef();
|
|
22214
|
+
const didKeyDownRef = React$1.useRef(false);
|
|
22215
|
+
const reference = React$1.useMemo(() => ({
|
|
22216
|
+
onPointerDown(event) {
|
|
22217
|
+
pointerTypeRef.current = event.pointerType;
|
|
22218
|
+
},
|
|
22219
|
+
onMouseDown(event) {
|
|
22220
|
+
const pointerType = pointerTypeRef.current;
|
|
22221
|
+
|
|
22222
|
+
// Ignore all buttons except for the "main" button.
|
|
22223
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
|
22224
|
+
if (event.button !== 0) return;
|
|
22225
|
+
if (eventOption === 'click') return;
|
|
22226
|
+
if (isMouseLikePointerType(pointerType) && ignoreMouse) return;
|
|
22227
|
+
if (open && toggle && (dataRef.current.openEvent ? dataRef.current.openEvent.type === 'mousedown' : true)) {
|
|
22228
|
+
onOpenChange(false, event.nativeEvent, 'click');
|
|
22229
|
+
} else {
|
|
22230
|
+
// Prevent stealing focus from the floating element
|
|
22231
|
+
event.preventDefault();
|
|
22232
|
+
onOpenChange(true, event.nativeEvent, 'click');
|
|
22233
|
+
}
|
|
22234
|
+
},
|
|
22235
|
+
onClick(event) {
|
|
22236
|
+
const pointerType = pointerTypeRef.current;
|
|
22237
|
+
if (eventOption === 'mousedown' && pointerTypeRef.current) {
|
|
22238
|
+
pointerTypeRef.current = undefined;
|
|
22239
|
+
return;
|
|
22240
|
+
}
|
|
22241
|
+
if (isMouseLikePointerType(pointerType) && ignoreMouse) return;
|
|
22242
|
+
if (open && toggle && (dataRef.current.openEvent ? dataRef.current.openEvent.type === 'click' : true)) {
|
|
22243
|
+
onOpenChange(false, event.nativeEvent, 'click');
|
|
22244
|
+
} else {
|
|
22245
|
+
onOpenChange(true, event.nativeEvent, 'click');
|
|
22246
|
+
}
|
|
22247
|
+
},
|
|
22248
|
+
onKeyDown(event) {
|
|
22249
|
+
pointerTypeRef.current = undefined;
|
|
22250
|
+
if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event)) {
|
|
22251
|
+
return;
|
|
22252
|
+
}
|
|
22253
|
+
if (event.key === ' ' && !isSpaceIgnored(domReference)) {
|
|
22254
|
+
// Prevent scrolling
|
|
22255
|
+
event.preventDefault();
|
|
22256
|
+
didKeyDownRef.current = true;
|
|
22257
|
+
}
|
|
22258
|
+
if (event.key === 'Enter') {
|
|
22259
|
+
if (open && toggle) {
|
|
22260
|
+
onOpenChange(false, event.nativeEvent, 'click');
|
|
22261
|
+
} else {
|
|
22262
|
+
onOpenChange(true, event.nativeEvent, 'click');
|
|
22263
|
+
}
|
|
22264
|
+
}
|
|
22265
|
+
},
|
|
22266
|
+
onKeyUp(event) {
|
|
22267
|
+
if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event) || isSpaceIgnored(domReference)) {
|
|
22268
|
+
return;
|
|
22269
|
+
}
|
|
22270
|
+
if (event.key === ' ' && didKeyDownRef.current) {
|
|
22271
|
+
didKeyDownRef.current = false;
|
|
22272
|
+
if (open && toggle) {
|
|
22273
|
+
onOpenChange(false, event.nativeEvent, 'click');
|
|
22274
|
+
} else {
|
|
22275
|
+
onOpenChange(true, event.nativeEvent, 'click');
|
|
22276
|
+
}
|
|
22277
|
+
}
|
|
22278
|
+
}
|
|
22279
|
+
}), [dataRef, domReference, eventOption, ignoreMouse, keyboardHandlers, onOpenChange, open, toggle]);
|
|
22280
|
+
return React$1.useMemo(() => enabled ? {
|
|
22281
|
+
reference
|
|
22282
|
+
} : {}, [enabled, reference]);
|
|
22283
|
+
}
|
|
22284
|
+
|
|
22285
|
+
const bubbleHandlerKeys = {
|
|
22286
|
+
pointerdown: 'onPointerDown',
|
|
22287
|
+
mousedown: 'onMouseDown',
|
|
22288
|
+
click: 'onClick'
|
|
22289
|
+
};
|
|
22290
|
+
const captureHandlerKeys = {
|
|
22291
|
+
pointerdown: 'onPointerDownCapture',
|
|
22292
|
+
mousedown: 'onMouseDownCapture',
|
|
22293
|
+
click: 'onClickCapture'
|
|
22034
22294
|
};
|
|
22295
|
+
const normalizeProp = normalizable => {
|
|
22296
|
+
var _normalizable$escapeK, _normalizable$outside;
|
|
22297
|
+
return {
|
|
22298
|
+
escapeKey: typeof normalizable === 'boolean' ? normalizable : (_normalizable$escapeK = normalizable == null ? void 0 : normalizable.escapeKey) != null ? _normalizable$escapeK : false,
|
|
22299
|
+
outsidePress: typeof normalizable === 'boolean' ? normalizable : (_normalizable$outside = normalizable == null ? void 0 : normalizable.outsidePress) != null ? _normalizable$outside : true
|
|
22300
|
+
};
|
|
22301
|
+
};
|
|
22302
|
+
/**
|
|
22303
|
+
* Closes the floating element when a dismissal is requested — by default, when
|
|
22304
|
+
* the user presses the `escape` key or outside of the floating element.
|
|
22305
|
+
* @see https://floating-ui.com/docs/useDismiss
|
|
22306
|
+
*/
|
|
22307
|
+
function useDismiss(context, props) {
|
|
22308
|
+
if (props === void 0) {
|
|
22309
|
+
props = {};
|
|
22310
|
+
}
|
|
22311
|
+
const {
|
|
22312
|
+
open,
|
|
22313
|
+
onOpenChange,
|
|
22314
|
+
elements,
|
|
22315
|
+
dataRef
|
|
22316
|
+
} = context;
|
|
22317
|
+
const {
|
|
22318
|
+
enabled = true,
|
|
22319
|
+
escapeKey = true,
|
|
22320
|
+
outsidePress: unstable_outsidePress = true,
|
|
22321
|
+
outsidePressEvent = 'pointerdown',
|
|
22322
|
+
referencePress = false,
|
|
22323
|
+
referencePressEvent = 'pointerdown',
|
|
22324
|
+
ancestorScroll = false,
|
|
22325
|
+
bubbles,
|
|
22326
|
+
capture
|
|
22327
|
+
} = props;
|
|
22328
|
+
const tree = useFloatingTree();
|
|
22329
|
+
const outsidePressFn = useEffectEvent(typeof unstable_outsidePress === 'function' ? unstable_outsidePress : () => false);
|
|
22330
|
+
const outsidePress = typeof unstable_outsidePress === 'function' ? outsidePressFn : unstable_outsidePress;
|
|
22331
|
+
const insideReactTreeRef = React$1.useRef(false);
|
|
22332
|
+
const endedOrStartedInsideRef = React$1.useRef(false);
|
|
22333
|
+
const {
|
|
22334
|
+
escapeKey: escapeKeyBubbles,
|
|
22335
|
+
outsidePress: outsidePressBubbles
|
|
22336
|
+
} = normalizeProp(bubbles);
|
|
22337
|
+
const {
|
|
22338
|
+
escapeKey: escapeKeyCapture,
|
|
22339
|
+
outsidePress: outsidePressCapture
|
|
22340
|
+
} = normalizeProp(capture);
|
|
22341
|
+
const closeOnEscapeKeyDown = useEffectEvent(event => {
|
|
22342
|
+
var _dataRef$current$floa;
|
|
22343
|
+
if (!open || !enabled || !escapeKey || event.key !== 'Escape') {
|
|
22344
|
+
return;
|
|
22345
|
+
}
|
|
22346
|
+
const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
|
|
22347
|
+
const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
|
|
22348
|
+
if (!escapeKeyBubbles) {
|
|
22349
|
+
event.stopPropagation();
|
|
22350
|
+
if (children.length > 0) {
|
|
22351
|
+
let shouldDismiss = true;
|
|
22352
|
+
children.forEach(child => {
|
|
22353
|
+
var _child$context;
|
|
22354
|
+
if ((_child$context = child.context) != null && _child$context.open && !child.context.dataRef.current.__escapeKeyBubbles) {
|
|
22355
|
+
shouldDismiss = false;
|
|
22356
|
+
return;
|
|
22357
|
+
}
|
|
22358
|
+
});
|
|
22359
|
+
if (!shouldDismiss) {
|
|
22360
|
+
return;
|
|
22361
|
+
}
|
|
22362
|
+
}
|
|
22363
|
+
}
|
|
22364
|
+
onOpenChange(false, isReactEvent(event) ? event.nativeEvent : event, 'escape-key');
|
|
22365
|
+
});
|
|
22366
|
+
const closeOnEscapeKeyDownCapture = useEffectEvent(event => {
|
|
22367
|
+
var _getTarget2;
|
|
22368
|
+
const callback = () => {
|
|
22369
|
+
var _getTarget;
|
|
22370
|
+
closeOnEscapeKeyDown(event);
|
|
22371
|
+
(_getTarget = getTarget(event)) == null || _getTarget.removeEventListener('keydown', callback);
|
|
22372
|
+
};
|
|
22373
|
+
(_getTarget2 = getTarget(event)) == null || _getTarget2.addEventListener('keydown', callback);
|
|
22374
|
+
});
|
|
22375
|
+
const closeOnPressOutside = useEffectEvent(event => {
|
|
22376
|
+
var _dataRef$current$floa2;
|
|
22377
|
+
// Given developers can stop the propagation of the synthetic event,
|
|
22378
|
+
// we can only be confident with a positive value.
|
|
22379
|
+
const insideReactTree = insideReactTreeRef.current;
|
|
22380
|
+
insideReactTreeRef.current = false;
|
|
22381
|
+
|
|
22382
|
+
// When click outside is lazy (`click` event), handle dragging.
|
|
22383
|
+
// Don't close if:
|
|
22384
|
+
// - The click started inside the floating element.
|
|
22385
|
+
// - The click ended inside the floating element.
|
|
22386
|
+
const endedOrStartedInside = endedOrStartedInsideRef.current;
|
|
22387
|
+
endedOrStartedInsideRef.current = false;
|
|
22388
|
+
if (outsidePressEvent === 'click' && endedOrStartedInside) {
|
|
22389
|
+
return;
|
|
22390
|
+
}
|
|
22391
|
+
if (insideReactTree) {
|
|
22392
|
+
return;
|
|
22393
|
+
}
|
|
22394
|
+
if (typeof outsidePress === 'function' && !outsidePress(event)) {
|
|
22395
|
+
return;
|
|
22396
|
+
}
|
|
22397
|
+
const target = getTarget(event);
|
|
22398
|
+
const inertSelector = "[" + createAttribute('inert') + "]";
|
|
22399
|
+
const markers = getDocument(elements.floating).querySelectorAll(inertSelector);
|
|
22400
|
+
let targetRootAncestor = isElement$2(target) ? target : null;
|
|
22401
|
+
while (targetRootAncestor && !isLastTraversableNode$1(targetRootAncestor)) {
|
|
22402
|
+
const nextParent = getParentNode$2(targetRootAncestor);
|
|
22403
|
+
if (isLastTraversableNode$1(nextParent) || !isElement$2(nextParent)) {
|
|
22404
|
+
break;
|
|
22405
|
+
}
|
|
22406
|
+
targetRootAncestor = nextParent;
|
|
22407
|
+
}
|
|
22408
|
+
|
|
22409
|
+
// Check if the click occurred on a third-party element injected after the
|
|
22410
|
+
// floating element rendered.
|
|
22411
|
+
if (markers.length && isElement$2(target) && !isRootElement(target) &&
|
|
22412
|
+
// Clicked on a direct ancestor (e.g. FloatingOverlay).
|
|
22413
|
+
!contains$1(target, elements.floating) &&
|
|
22414
|
+
// If the target root element contains none of the markers, then the
|
|
22415
|
+
// element was injected after the floating element rendered.
|
|
22416
|
+
Array.from(markers).every(marker => !contains$1(targetRootAncestor, marker))) {
|
|
22417
|
+
return;
|
|
22418
|
+
}
|
|
22419
|
+
|
|
22420
|
+
// Check if the click occurred on the scrollbar
|
|
22421
|
+
if (isHTMLElement$2(target) && floating) {
|
|
22422
|
+
// In Firefox, `target.scrollWidth > target.clientWidth` for inline
|
|
22423
|
+
// elements.
|
|
22424
|
+
const canScrollX = target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
|
|
22425
|
+
const canScrollY = target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
|
|
22426
|
+
let xCond = canScrollY && event.offsetX > target.clientWidth;
|
|
22427
|
+
|
|
22428
|
+
// In some browsers it is possible to change the <body> (or window)
|
|
22429
|
+
// scrollbar to the left side, but is very rare and is difficult to
|
|
22430
|
+
// check for. Plus, for modal dialogs with backdrops, it is more
|
|
22431
|
+
// important that the backdrop is checked but not so much the window.
|
|
22432
|
+
if (canScrollY) {
|
|
22433
|
+
const isRTL = getComputedStyle$3(target).direction === 'rtl';
|
|
22434
|
+
if (isRTL) {
|
|
22435
|
+
xCond = event.offsetX <= target.offsetWidth - target.clientWidth;
|
|
22436
|
+
}
|
|
22437
|
+
}
|
|
22438
|
+
if (xCond || canScrollX && event.offsetY > target.clientHeight) {
|
|
22439
|
+
return;
|
|
22440
|
+
}
|
|
22441
|
+
}
|
|
22442
|
+
const nodeId = (_dataRef$current$floa2 = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa2.nodeId;
|
|
22443
|
+
const targetIsInsideChildren = tree && getChildren(tree.nodesRef.current, nodeId).some(node => {
|
|
22444
|
+
var _node$context;
|
|
22445
|
+
return isEventTargetWithin(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating);
|
|
22446
|
+
});
|
|
22447
|
+
if (isEventTargetWithin(event, elements.floating) || isEventTargetWithin(event, elements.domReference) || targetIsInsideChildren) {
|
|
22448
|
+
return;
|
|
22449
|
+
}
|
|
22450
|
+
const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
|
|
22451
|
+
if (children.length > 0) {
|
|
22452
|
+
let shouldDismiss = true;
|
|
22453
|
+
children.forEach(child => {
|
|
22454
|
+
var _child$context2;
|
|
22455
|
+
if ((_child$context2 = child.context) != null && _child$context2.open && !child.context.dataRef.current.__outsidePressBubbles) {
|
|
22456
|
+
shouldDismiss = false;
|
|
22457
|
+
return;
|
|
22458
|
+
}
|
|
22459
|
+
});
|
|
22460
|
+
if (!shouldDismiss) {
|
|
22461
|
+
return;
|
|
22462
|
+
}
|
|
22463
|
+
}
|
|
22464
|
+
onOpenChange(false, event, 'outside-press');
|
|
22465
|
+
});
|
|
22466
|
+
const closeOnPressOutsideCapture = useEffectEvent(event => {
|
|
22467
|
+
var _getTarget4;
|
|
22468
|
+
const callback = () => {
|
|
22469
|
+
var _getTarget3;
|
|
22470
|
+
closeOnPressOutside(event);
|
|
22471
|
+
(_getTarget3 = getTarget(event)) == null || _getTarget3.removeEventListener(outsidePressEvent, callback);
|
|
22472
|
+
};
|
|
22473
|
+
(_getTarget4 = getTarget(event)) == null || _getTarget4.addEventListener(outsidePressEvent, callback);
|
|
22474
|
+
});
|
|
22475
|
+
React$1.useEffect(() => {
|
|
22476
|
+
if (!open || !enabled) {
|
|
22477
|
+
return;
|
|
22478
|
+
}
|
|
22479
|
+
dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
|
|
22480
|
+
dataRef.current.__outsidePressBubbles = outsidePressBubbles;
|
|
22481
|
+
function onScroll(event) {
|
|
22482
|
+
onOpenChange(false, event, 'ancestor-scroll');
|
|
22483
|
+
}
|
|
22484
|
+
const doc = getDocument(elements.floating);
|
|
22485
|
+
escapeKey && doc.addEventListener('keydown', escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
|
|
22486
|
+
outsidePress && doc.addEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
|
|
22487
|
+
let ancestors = [];
|
|
22488
|
+
if (ancestorScroll) {
|
|
22489
|
+
if (isElement$2(elements.domReference)) {
|
|
22490
|
+
ancestors = getOverflowAncestors$1(elements.domReference);
|
|
22491
|
+
}
|
|
22492
|
+
if (isElement$2(elements.floating)) {
|
|
22493
|
+
ancestors = ancestors.concat(getOverflowAncestors$1(elements.floating));
|
|
22494
|
+
}
|
|
22495
|
+
if (!isElement$2(elements.reference) && elements.reference && elements.reference.contextElement) {
|
|
22496
|
+
ancestors = ancestors.concat(getOverflowAncestors$1(elements.reference.contextElement));
|
|
22497
|
+
}
|
|
22498
|
+
}
|
|
22499
|
+
|
|
22500
|
+
// Ignore the visual viewport for scrolling dismissal (allow pinch-zoom)
|
|
22501
|
+
ancestors = ancestors.filter(ancestor => {
|
|
22502
|
+
var _doc$defaultView;
|
|
22503
|
+
return ancestor !== ((_doc$defaultView = doc.defaultView) == null ? void 0 : _doc$defaultView.visualViewport);
|
|
22504
|
+
});
|
|
22505
|
+
ancestors.forEach(ancestor => {
|
|
22506
|
+
ancestor.addEventListener('scroll', onScroll, {
|
|
22507
|
+
passive: true
|
|
22508
|
+
});
|
|
22509
|
+
});
|
|
22510
|
+
return () => {
|
|
22511
|
+
escapeKey && doc.removeEventListener('keydown', escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
|
|
22512
|
+
outsidePress && doc.removeEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
|
|
22513
|
+
ancestors.forEach(ancestor => {
|
|
22514
|
+
ancestor.removeEventListener('scroll', onScroll);
|
|
22515
|
+
});
|
|
22516
|
+
};
|
|
22517
|
+
}, [dataRef, elements, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture]);
|
|
22518
|
+
React$1.useEffect(() => {
|
|
22519
|
+
insideReactTreeRef.current = false;
|
|
22520
|
+
}, [outsidePress, outsidePressEvent]);
|
|
22521
|
+
const reference = React$1.useMemo(() => ({
|
|
22522
|
+
onKeyDown: closeOnEscapeKeyDown,
|
|
22523
|
+
[bubbleHandlerKeys[referencePressEvent]]: event => {
|
|
22524
|
+
if (referencePress) {
|
|
22525
|
+
onOpenChange(false, event.nativeEvent, 'reference-press');
|
|
22526
|
+
}
|
|
22527
|
+
}
|
|
22528
|
+
}), [closeOnEscapeKeyDown, onOpenChange, referencePress, referencePressEvent]);
|
|
22529
|
+
const floating = React$1.useMemo(() => ({
|
|
22530
|
+
onKeyDown: closeOnEscapeKeyDown,
|
|
22531
|
+
onMouseDown() {
|
|
22532
|
+
endedOrStartedInsideRef.current = true;
|
|
22533
|
+
},
|
|
22534
|
+
onMouseUp() {
|
|
22535
|
+
endedOrStartedInsideRef.current = true;
|
|
22536
|
+
},
|
|
22537
|
+
[captureHandlerKeys[outsidePressEvent]]: () => {
|
|
22538
|
+
insideReactTreeRef.current = true;
|
|
22539
|
+
}
|
|
22540
|
+
}), [closeOnEscapeKeyDown, outsidePressEvent]);
|
|
22541
|
+
return React$1.useMemo(() => enabled ? {
|
|
22542
|
+
reference,
|
|
22543
|
+
floating
|
|
22544
|
+
} : {}, [enabled, reference, floating]);
|
|
22545
|
+
}
|
|
22546
|
+
|
|
22547
|
+
function useFloatingRootContext(options) {
|
|
22548
|
+
const {
|
|
22549
|
+
open = false,
|
|
22550
|
+
onOpenChange: onOpenChangeProp,
|
|
22551
|
+
elements: elementsProp
|
|
22552
|
+
} = options;
|
|
22553
|
+
const floatingId = useId$1();
|
|
22554
|
+
const dataRef = React$1.useRef({});
|
|
22555
|
+
const [events] = React$1.useState(() => createPubSub());
|
|
22556
|
+
const nested = useFloatingParentNodeId() != null;
|
|
22557
|
+
if (process.env.NODE_ENV !== "production") {
|
|
22558
|
+
const optionDomReference = elementsProp.reference;
|
|
22559
|
+
if (optionDomReference && !isElement$2(optionDomReference)) {
|
|
22560
|
+
error('Cannot pass a virtual element to the `elements.reference` option,', 'as it must be a real DOM element. Use `refs.setPositionReference()`', 'instead.');
|
|
22561
|
+
}
|
|
22562
|
+
}
|
|
22563
|
+
const [positionReference, setPositionReference] = React$1.useState(elementsProp.reference);
|
|
22564
|
+
const onOpenChange = useEffectEvent((open, event, reason) => {
|
|
22565
|
+
dataRef.current.openEvent = open ? event : undefined;
|
|
22566
|
+
events.emit('openchange', {
|
|
22567
|
+
open,
|
|
22568
|
+
event,
|
|
22569
|
+
reason,
|
|
22570
|
+
nested
|
|
22571
|
+
});
|
|
22572
|
+
onOpenChangeProp == null || onOpenChangeProp(open, event, reason);
|
|
22573
|
+
});
|
|
22574
|
+
const refs = React$1.useMemo(() => ({
|
|
22575
|
+
setPositionReference
|
|
22576
|
+
}), []);
|
|
22577
|
+
const elements = React$1.useMemo(() => ({
|
|
22578
|
+
reference: positionReference || elementsProp.reference || null,
|
|
22579
|
+
floating: elementsProp.floating || null,
|
|
22580
|
+
domReference: elementsProp.reference
|
|
22581
|
+
}), [positionReference, elementsProp.reference, elementsProp.floating]);
|
|
22582
|
+
return React$1.useMemo(() => ({
|
|
22583
|
+
dataRef,
|
|
22584
|
+
open,
|
|
22585
|
+
onOpenChange,
|
|
22586
|
+
elements,
|
|
22587
|
+
events,
|
|
22588
|
+
floatingId,
|
|
22589
|
+
refs
|
|
22590
|
+
}), [open, onOpenChange, elements, events, floatingId, refs]);
|
|
22591
|
+
}
|
|
22592
|
+
|
|
22593
|
+
/**
|
|
22594
|
+
* Provides data to position a floating element and context to add interactions.
|
|
22595
|
+
* @see https://floating-ui.com/docs/useFloating
|
|
22596
|
+
*/
|
|
22597
|
+
function useFloating(options) {
|
|
22598
|
+
if (options === void 0) {
|
|
22599
|
+
options = {};
|
|
22600
|
+
}
|
|
22601
|
+
const {
|
|
22602
|
+
nodeId
|
|
22603
|
+
} = options;
|
|
22604
|
+
const internalRootContext = useFloatingRootContext({
|
|
22605
|
+
...options,
|
|
22606
|
+
elements: {
|
|
22607
|
+
reference: null,
|
|
22608
|
+
floating: null,
|
|
22609
|
+
...options.elements
|
|
22610
|
+
}
|
|
22611
|
+
});
|
|
22612
|
+
const rootContext = options.rootContext || internalRootContext;
|
|
22613
|
+
const computedElements = rootContext.elements;
|
|
22614
|
+
const [_domReference, setDomReference] = React$1.useState(null);
|
|
22615
|
+
const [positionReference, _setPositionReference] = React$1.useState(null);
|
|
22616
|
+
const optionDomReference = computedElements == null ? void 0 : computedElements.reference;
|
|
22617
|
+
const domReference = optionDomReference || _domReference;
|
|
22618
|
+
const domReferenceRef = React$1.useRef(null);
|
|
22619
|
+
const tree = useFloatingTree();
|
|
22620
|
+
index(() => {
|
|
22621
|
+
if (domReference) {
|
|
22622
|
+
domReferenceRef.current = domReference;
|
|
22623
|
+
}
|
|
22624
|
+
}, [domReference]);
|
|
22625
|
+
const position = useFloating$1({
|
|
22626
|
+
...options,
|
|
22627
|
+
elements: {
|
|
22628
|
+
...computedElements,
|
|
22629
|
+
...(positionReference && {
|
|
22630
|
+
reference: positionReference
|
|
22631
|
+
})
|
|
22632
|
+
}
|
|
22633
|
+
});
|
|
22634
|
+
const setPositionReference = React$1.useCallback(node => {
|
|
22635
|
+
const computedPositionReference = isElement$2(node) ? {
|
|
22636
|
+
getBoundingClientRect: () => node.getBoundingClientRect(),
|
|
22637
|
+
contextElement: node
|
|
22638
|
+
} : node;
|
|
22639
|
+
// Store the positionReference in state if the DOM reference is specified externally via the
|
|
22640
|
+
// `elements.reference` option. This ensures that it won't be overridden on future renders.
|
|
22641
|
+
_setPositionReference(computedPositionReference);
|
|
22642
|
+
position.refs.setReference(computedPositionReference);
|
|
22643
|
+
}, [position.refs]);
|
|
22644
|
+
const setReference = React$1.useCallback(node => {
|
|
22645
|
+
if (isElement$2(node) || node === null) {
|
|
22646
|
+
domReferenceRef.current = node;
|
|
22647
|
+
setDomReference(node);
|
|
22648
|
+
}
|
|
22649
|
+
|
|
22650
|
+
// Backwards-compatibility for passing a virtual element to `reference`
|
|
22651
|
+
// after it has set the DOM reference.
|
|
22652
|
+
if (isElement$2(position.refs.reference.current) || position.refs.reference.current === null ||
|
|
22653
|
+
// Don't allow setting virtual elements using the old technique back to
|
|
22654
|
+
// `null` to support `positionReference` + an unstable `reference`
|
|
22655
|
+
// callback ref.
|
|
22656
|
+
node !== null && !isElement$2(node)) {
|
|
22657
|
+
position.refs.setReference(node);
|
|
22658
|
+
}
|
|
22659
|
+
}, [position.refs]);
|
|
22660
|
+
const refs = React$1.useMemo(() => ({
|
|
22661
|
+
...position.refs,
|
|
22662
|
+
setReference,
|
|
22663
|
+
setPositionReference,
|
|
22664
|
+
domReference: domReferenceRef
|
|
22665
|
+
}), [position.refs, setReference, setPositionReference]);
|
|
22666
|
+
const elements = React$1.useMemo(() => ({
|
|
22667
|
+
...position.elements,
|
|
22668
|
+
domReference: domReference
|
|
22669
|
+
}), [position.elements, domReference]);
|
|
22670
|
+
const context = React$1.useMemo(() => ({
|
|
22671
|
+
...position,
|
|
22672
|
+
...rootContext,
|
|
22673
|
+
refs,
|
|
22674
|
+
elements,
|
|
22675
|
+
nodeId
|
|
22676
|
+
}), [position, refs, elements, nodeId, rootContext]);
|
|
22677
|
+
index(() => {
|
|
22678
|
+
rootContext.dataRef.current.floatingContext = context;
|
|
22679
|
+
const node = tree == null ? void 0 : tree.nodesRef.current.find(node => node.id === nodeId);
|
|
22680
|
+
if (node) {
|
|
22681
|
+
node.context = context;
|
|
22682
|
+
}
|
|
22683
|
+
});
|
|
22684
|
+
return React$1.useMemo(() => ({
|
|
22685
|
+
...position,
|
|
22686
|
+
context,
|
|
22687
|
+
refs,
|
|
22688
|
+
elements
|
|
22689
|
+
}), [position, refs, elements, context]);
|
|
22690
|
+
}
|
|
22691
|
+
|
|
22692
|
+
const ACTIVE_KEY = 'active';
|
|
22693
|
+
const SELECTED_KEY = 'selected';
|
|
22694
|
+
function mergeProps(userProps, propsList, elementKey) {
|
|
22695
|
+
const map = new Map();
|
|
22696
|
+
const isItem = elementKey === 'item';
|
|
22697
|
+
let domUserProps = userProps;
|
|
22698
|
+
if (isItem && userProps) {
|
|
22699
|
+
const {
|
|
22700
|
+
[ACTIVE_KEY]: _,
|
|
22701
|
+
[SELECTED_KEY]: __,
|
|
22702
|
+
...validProps
|
|
22703
|
+
} = userProps;
|
|
22704
|
+
domUserProps = validProps;
|
|
22705
|
+
}
|
|
22706
|
+
return {
|
|
22707
|
+
...(elementKey === 'floating' && {
|
|
22708
|
+
tabIndex: -1
|
|
22709
|
+
}),
|
|
22710
|
+
...domUserProps,
|
|
22711
|
+
...propsList.map(value => {
|
|
22712
|
+
const propsOrGetProps = value ? value[elementKey] : null;
|
|
22713
|
+
if (typeof propsOrGetProps === 'function') {
|
|
22714
|
+
return userProps ? propsOrGetProps(userProps) : null;
|
|
22715
|
+
}
|
|
22716
|
+
return propsOrGetProps;
|
|
22717
|
+
}).concat(userProps).reduce((acc, props) => {
|
|
22718
|
+
if (!props) {
|
|
22719
|
+
return acc;
|
|
22720
|
+
}
|
|
22721
|
+
Object.entries(props).forEach(_ref => {
|
|
22722
|
+
let [key, value] = _ref;
|
|
22723
|
+
if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) {
|
|
22724
|
+
return;
|
|
22725
|
+
}
|
|
22726
|
+
if (key.indexOf('on') === 0) {
|
|
22727
|
+
if (!map.has(key)) {
|
|
22728
|
+
map.set(key, []);
|
|
22729
|
+
}
|
|
22730
|
+
if (typeof value === 'function') {
|
|
22731
|
+
var _map$get;
|
|
22732
|
+
(_map$get = map.get(key)) == null || _map$get.push(value);
|
|
22733
|
+
acc[key] = function () {
|
|
22734
|
+
var _map$get2;
|
|
22735
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
22736
|
+
args[_key] = arguments[_key];
|
|
22737
|
+
}
|
|
22738
|
+
return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map(fn => fn(...args)).find(val => val !== undefined);
|
|
22739
|
+
};
|
|
22740
|
+
}
|
|
22741
|
+
} else {
|
|
22742
|
+
acc[key] = value;
|
|
22743
|
+
}
|
|
22744
|
+
});
|
|
22745
|
+
return acc;
|
|
22746
|
+
}, {})
|
|
22747
|
+
};
|
|
22748
|
+
}
|
|
22749
|
+
/**
|
|
22750
|
+
* Merges an array of interaction hooks' props into prop getters, allowing
|
|
22751
|
+
* event handler functions to be composed together without overwriting one
|
|
22752
|
+
* another.
|
|
22753
|
+
* @see https://floating-ui.com/docs/useInteractions
|
|
22754
|
+
*/
|
|
22755
|
+
function useInteractions(propsList) {
|
|
22756
|
+
if (propsList === void 0) {
|
|
22757
|
+
propsList = [];
|
|
22758
|
+
}
|
|
22759
|
+
const referenceDeps = propsList.map(key => key == null ? void 0 : key.reference);
|
|
22760
|
+
const floatingDeps = propsList.map(key => key == null ? void 0 : key.floating);
|
|
22761
|
+
const itemDeps = propsList.map(key => key == null ? void 0 : key.item);
|
|
22762
|
+
const getReferenceProps = React$1.useCallback(userProps => mergeProps(userProps, propsList, 'reference'),
|
|
22763
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22764
|
+
referenceDeps);
|
|
22765
|
+
const getFloatingProps = React$1.useCallback(userProps => mergeProps(userProps, propsList, 'floating'),
|
|
22766
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22767
|
+
floatingDeps);
|
|
22768
|
+
const getItemProps = React$1.useCallback(userProps => mergeProps(userProps, propsList, 'item'),
|
|
22769
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22770
|
+
itemDeps);
|
|
22771
|
+
return React$1.useMemo(() => ({
|
|
22772
|
+
getReferenceProps,
|
|
22773
|
+
getFloatingProps,
|
|
22774
|
+
getItemProps
|
|
22775
|
+
}), [getReferenceProps, getFloatingProps, getItemProps]);
|
|
22776
|
+
}
|
|
22035
22777
|
|
|
22036
22778
|
const defaultOptions$1 = {
|
|
22037
22779
|
placement: 'bottom-start',
|
|
@@ -22053,18 +22795,14 @@ function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: con
|
|
|
22053
22795
|
if (!isValidElement(trigger) || !isValidElement(content)) {
|
|
22054
22796
|
throw new Error('Both children of FloatUI must be valid React elements.');
|
|
22055
22797
|
}
|
|
22056
|
-
const {
|
|
22798
|
+
const { refs, floatingStyles, context } = useFloating(Object.assign(Object.assign({}, floatingOptions), { open: isOpen, onOpenChange: setIsOpen, elements: {
|
|
22057
22799
|
reference: referenceElementRef.current,
|
|
22058
|
-
} }
|
|
22059
|
-
|
|
22060
|
-
const
|
|
22061
|
-
|
|
22062
|
-
|
|
22063
|
-
|
|
22064
|
-
top: y !== null && y !== void 0 ? y : 0,
|
|
22065
|
-
left: x !== null && x !== void 0 ? x : 0,
|
|
22066
|
-
}, role: "dialog", "aria-label": ariaLabel, className: "floatui-container", children: jsx("div", { ref: floatUIContentRef, className: "floatui-content", children: content }) }));
|
|
22067
|
-
return (jsxs(Fragment, { children: [jsx("div", { ref: referenceElementRef, onClick: () => setIsOpen(!isOpen), children: trigger }), isOpen &&
|
|
22800
|
+
} }));
|
|
22801
|
+
const click = useClick(context);
|
|
22802
|
+
const dismiss = useDismiss(context);
|
|
22803
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss]);
|
|
22804
|
+
const tooltipContent = (jsx("div", Object.assign({ ref: refs.setFloating }, getFloatingProps(), { style: floatingStyles, role: "dialog", "aria-label": ariaLabel, className: "floatui-container", children: jsx("div", { ref: floatUIContentRef, className: "floatui-content", children: content }) })));
|
|
22805
|
+
return (jsxs(Fragment, { children: [jsx("div", Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: trigger })), isOpen &&
|
|
22068
22806
|
(isPortal ? (jsx(FloatingPortal, { id: portalOptions === null || portalOptions === void 0 ? void 0 : portalOptions.rootId, children: tooltipContent })) : (tooltipContent))] }));
|
|
22069
22807
|
}
|
|
22070
22808
|
|
|
@@ -43875,5 +44613,5 @@ const Pill = (_a) => {
|
|
|
43875
44613
|
return (jsx("div", Object.assign({ className: pillClasses }, rest, { children: children })));
|
|
43876
44614
|
};
|
|
43877
44615
|
|
|
43878
|
-
export { animation as ANIMATION, Radio$1 as AbstractRadio, RadioGroup$1 as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button$2 as Button, allColors as COLORS, Card, Checkbox, CirclePulse, CircleSpinner, Col, ConfirmModal, Container, DatePicker, EditableInput, FloatUI, Form, GlobalStyles, Icon, IconButton, LabeledInput as Input, Button$1 as LegacyButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, Menu, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, LabeledPasswordInput as PasswordInput, PercentageRing, Pill, Radio, RadioGroup, Radio$2 as RadioInput, RandomLoadingMessage, Row$1 as Row, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Select$1 as SelectInput, Shrug, SingleCombobox, Skeleton, typography as TYPOGRAPHY, Table$1 as Table, TextInput, TextTruncate, LabeledTextarea as Textarea, Toggle, Toggle$1 as ToggleInput, Tooltip, arrow$4 as arrow, autoPlacement, autoUpdate$1 as autoUpdate, color as colorUtils, computePosition$2 as computePosition, detectOverflow$2 as detectOverflow, flip$4 as flip, getOverflowAncestors$1 as getOverflowAncestors, hide$3 as hide, inline, limitShift, number as numberUtils, offset$4 as offset, platform$1 as platform, shift$2 as shift, size, string as stringUtils, useFloating };
|
|
44616
|
+
export { animation as ANIMATION, Radio$1 as AbstractRadio, RadioGroup$1 as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button$2 as Button, allColors as COLORS, Card, Checkbox, CirclePulse, CircleSpinner, Col, ConfirmModal, Container, DatePicker, EditableInput, FloatUI, Form, GlobalStyles, Icon, IconButton, LabeledInput as Input, Button$1 as LegacyButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, Menu, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, LabeledPasswordInput as PasswordInput, PercentageRing, Pill, Radio, RadioGroup, Radio$2 as RadioInput, RandomLoadingMessage, Row$1 as Row, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Select$1 as SelectInput, Shrug, SingleCombobox, Skeleton, typography as TYPOGRAPHY, Table$1 as Table, TextInput, TextTruncate, LabeledTextarea as Textarea, Toggle, Toggle$1 as ToggleInput, Tooltip, arrow$4 as arrow, autoPlacement, autoUpdate$1 as autoUpdate, color as colorUtils, computePosition$2 as computePosition, detectOverflow$2 as detectOverflow, flip$4 as flip, getOverflowAncestors$1 as getOverflowAncestors, hide$3 as hide, inline, limitShift, number as numberUtils, offset$4 as offset, platform$1 as platform, shift$2 as shift, size, string as stringUtils, useFloating$1 as useFloating };
|
|
43879
44617
|
//# sourceMappingURL=index.esm.js.map
|