@trackunit/react-components 0.1.156 → 0.1.158
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/index.cjs.js +1353 -1281
- package/index.esm.js +1351 -1283
- package/package.json +3 -3
- package/src/components/Icon/Icon.d.ts +251 -3
- package/src/components/Popover/Popover.d.ts +23 -18
- package/src/components/Popover/usePopover.d.ts +25 -20
package/index.cjs.js
CHANGED
|
@@ -5,8 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
|
|
8
|
-
var uiIcons = require('@trackunit/ui-icons');
|
|
9
8
|
var uiDesignTokens = require('@trackunit/ui-design-tokens');
|
|
9
|
+
var uiIcons = require('@trackunit/ui-icons');
|
|
10
|
+
var IconSpriteOutline = require('@trackunit/ui-icons/icons-sprite-outline.svg');
|
|
11
|
+
var IconSpriteSolid = require('@trackunit/ui-icons/icons-sprite-solid.svg');
|
|
10
12
|
var ReactDOM = require('react-dom');
|
|
11
13
|
var reactRouterDom = require('react-router-dom');
|
|
12
14
|
|
|
@@ -32,6 +34,8 @@ function _interopNamespace(e) {
|
|
|
32
34
|
|
|
33
35
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
36
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
37
|
+
var IconSpriteOutline__default = /*#__PURE__*/_interopDefaultLegacy(IconSpriteOutline);
|
|
38
|
+
var IconSpriteSolid__default = /*#__PURE__*/_interopDefaultLegacy(IconSpriteSolid);
|
|
35
39
|
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
36
40
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
37
41
|
|
|
@@ -426,7 +430,7 @@ const cvaIcon = cssClassVarianceUtilities.cvaMerge(["aspect-square", "inline-gri
|
|
|
426
430
|
size: "large",
|
|
427
431
|
},
|
|
428
432
|
});
|
|
429
|
-
|
|
433
|
+
cssClassVarianceUtilities.cvaMerge([], {
|
|
430
434
|
variants: {
|
|
431
435
|
iconType: {
|
|
432
436
|
solid: "fill-current stroke-transparent",
|
|
@@ -434,7 +438,7 @@ const cvaIconComponent = cssClassVarianceUtilities.cvaMerge([], {
|
|
|
434
438
|
},
|
|
435
439
|
},
|
|
436
440
|
});
|
|
437
|
-
|
|
441
|
+
cssClassVarianceUtilities.cvaMerge([
|
|
438
442
|
"relative",
|
|
439
443
|
"aspect-square",
|
|
440
444
|
"after:content-['']",
|
|
@@ -449,30 +453,27 @@ const cvaLoadingDot = cssClassVarianceUtilities.cvaMerge([
|
|
|
449
453
|
"after:opacity-50",
|
|
450
454
|
]);
|
|
451
455
|
|
|
456
|
+
const iconPalette = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, uiDesignTokens.intentPalette), uiDesignTokens.generalPalette), uiDesignTokens.criticalityPalette), uiDesignTokens.activityPalette), uiDesignTokens.utilizationPalette), uiDesignTokens.sitesPalette), uiDesignTokens.rentalStatusPalette);
|
|
457
|
+
const iconColorNames = Object.keys(iconPalette).map(key => key.toLowerCase()); // This users the object in the Object.keys() to infer the type of the keys.
|
|
452
458
|
/**
|
|
453
459
|
* - The Icon component is used to display an Icon.
|
|
454
460
|
* - Icons are semantic vector graphics that adds character and improves the visual appeal of elements when combined with.
|
|
455
|
-
* - All the [HeroIcons](https://heroicons.dev/) as well as custom
|
|
461
|
+
* - All the [HeroIcons](https://heroicons.dev/) as well as custom Trackunit icons are available.
|
|
456
462
|
*
|
|
457
463
|
* @param {IconProps} props - The props for the Icon component
|
|
458
464
|
* @returns {JSX.Element} Icon component
|
|
459
465
|
*/
|
|
460
466
|
const Icon = ({ name, size = "large", className, dataTestId, color, onClick, fillColor, type, style, forwardedRef, }) => {
|
|
461
467
|
const correctIconType = React__namespace.useMemo(() => (type ? type : size === "large" ? "outline" : "solid"), [type, size]);
|
|
462
|
-
|
|
463
|
-
if (
|
|
464
|
-
IconComponent = uiIcons.heroIconLookup(name, correctIconType);
|
|
465
|
-
}
|
|
466
|
-
else if (uiIcons.TrackunitSolidIconsArray.find(icon => icon === name) ||
|
|
467
|
-
uiIcons.TrackunitOutlineIconsArray.find(icon => icon === name)) {
|
|
468
|
-
IconComponent = uiIcons.trackunitIconLookup(name, correctIconType);
|
|
469
|
-
}
|
|
470
|
-
if (!IconComponent) {
|
|
468
|
+
const iconName = uiIcons.iconNames[name];
|
|
469
|
+
if (!iconName) {
|
|
471
470
|
return null;
|
|
472
471
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
472
|
+
const href = {
|
|
473
|
+
solid: `${IconSpriteSolid__default["default"]}#${iconName}`,
|
|
474
|
+
outline: `${IconSpriteOutline__default["default"]}#${iconName}`,
|
|
475
|
+
};
|
|
476
|
+
return (jsxRuntime.jsx("span", { className: cvaIcon({ color, size, className }), onClick: onClick, "data-testid": dataTestId, ref: forwardedRef, children: jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", "data-testid": dataTestId ? `${dataTestId}-${iconName}` : iconName, style: fillColor ? Object.assign(Object.assign({}, style), { fill: fillColor }) : Object.assign({}, style), children: jsxRuntime.jsx("use", { href: href[correctIconType] }) }) }));
|
|
476
477
|
};
|
|
477
478
|
|
|
478
479
|
/**
|
|
@@ -482,7 +483,7 @@ const Icon = ({ name, size = "large", className, dataTestId, color, onClick, fil
|
|
|
482
483
|
* @returns {JSX.Element} StarButton component
|
|
483
484
|
*/
|
|
484
485
|
const StarButton = ({ starred, onClick }) => {
|
|
485
|
-
return (jsxRuntime.jsx("div", { onClick: onClick, "data-test-id": "starred-filter", children: jsxRuntime.jsx(Icon, { name: "
|
|
486
|
+
return (jsxRuntime.jsx("div", { onClick: onClick, "data-test-id": "starred-filter", children: jsxRuntime.jsx(Icon, { name: "Star", color: starred ? "primary" : "neutral", type: starred ? "solid" : "outline", size: "medium" }) }));
|
|
486
487
|
};
|
|
487
488
|
|
|
488
489
|
const cvaText = cssClassVarianceUtilities.cvaMerge(["m-0", "relative", "text-sm", "font-normal"], {
|
|
@@ -624,13 +625,13 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
624
625
|
const getIconFromColor = () => {
|
|
625
626
|
switch (color) {
|
|
626
627
|
case "danger":
|
|
627
|
-
return jsxRuntime.jsx(Icon, { name: "
|
|
628
|
+
return jsxRuntime.jsx(Icon, { name: "ExclamationTriangle", color: "danger" });
|
|
628
629
|
case "warning":
|
|
629
|
-
return jsxRuntime.jsx(Icon, { name: "
|
|
630
|
+
return jsxRuntime.jsx(Icon, { name: "ExclamationCircle", color: "warning" });
|
|
630
631
|
case "success":
|
|
631
|
-
return jsxRuntime.jsx(Icon, { name: "
|
|
632
|
+
return jsxRuntime.jsx(Icon, { name: "CheckCircle", color: "success" });
|
|
632
633
|
default:
|
|
633
|
-
return jsxRuntime.jsx(Icon, { name: "
|
|
634
|
+
return jsxRuntime.jsx(Icon, { name: "InformationCircle" });
|
|
634
635
|
}
|
|
635
636
|
};
|
|
636
637
|
const getButtonColor = () => {
|
|
@@ -650,7 +651,7 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
650
651
|
}
|
|
651
652
|
}, [ref, autoScroll]);
|
|
652
653
|
const layout = inline ? "inline" : "default";
|
|
653
|
-
return (jsxRuntime.jsxs("div", { className: cvaAlert({ color, layout, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxRuntime.jsx("div", { className: cvaAlertIconContainer({ layout }), children: getIconFromColor() }), jsxRuntime.jsxs("div", { className: cvaAlertContent({ layout }), children: [jsxRuntime.jsxs("div", { className: cvaAlertDetails(), children: [jsxRuntime.jsx("div", { className: cvaAlertContentBody(), children: body }), onClose && !inline ? (jsxRuntime.jsx("div", { className: cvaAlertCloseButtonContainer({ layout }), children: jsxRuntime.jsx(IconButton, { size: "small", variant: "transparent", color: "secondary", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "
|
|
654
|
+
return (jsxRuntime.jsxs("div", { className: cvaAlert({ color, layout, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxRuntime.jsx("div", { className: cvaAlertIconContainer({ layout }), children: getIconFromColor() }), jsxRuntime.jsxs("div", { className: cvaAlertContent({ layout }), children: [jsxRuntime.jsxs("div", { className: cvaAlertDetails(), children: [jsxRuntime.jsx("div", { className: cvaAlertContentBody(), children: body }), onClose && !inline ? (jsxRuntime.jsx("div", { className: cvaAlertCloseButtonContainer({ layout }), children: jsxRuntime.jsx(IconButton, { size: "small", variant: "transparent", color: "secondary", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "XMark", size: "small" }), title: "Close Alert", circular: true }) })) : null] }), (primaryAction || secondaryAction || onClose) && (jsxRuntime.jsxs("div", { className: cvaAlertRightAligned({ layout }), children: [secondaryAction && (jsxRuntime.jsx(Button$1, { size: "small", variant: "transparent", color: getButtonColor(), onClick: secondaryAction.onClick, loading: secondaryAction === null || secondaryAction === void 0 ? void 0 : secondaryAction.loading, children: secondaryAction.label })), primaryAction && (jsxRuntime.jsx(Button$1, { size: "small", color: getButtonColor(), onClick: primaryAction.onClick, loading: primaryAction === null || primaryAction === void 0 ? void 0 : primaryAction.loading, children: primaryAction.label })), onClose && inline ? (jsxRuntime.jsx("div", { className: cvaAlertCloseButtonContainer({ layout }), children: jsxRuntime.jsx(IconButton, { size: "small", variant: "transparent", color: "secondary", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "XMark", size: "small" }), title: "Close Alert", circular: true }) })) : null] }))] })] }));
|
|
654
655
|
};
|
|
655
656
|
|
|
656
657
|
const cvaBadge = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -882,7 +883,7 @@ const Heading = (_a) => {
|
|
|
882
883
|
* @returns {JSX.Element} CardHeader component
|
|
883
884
|
*/
|
|
884
885
|
const CardHeader = ({ heading, headingVariant = "primary", subHeading, onClose, dataTestId, className, children, accessories, density, extraClassName, hideSeparator = false, }) => {
|
|
885
|
-
return (jsxRuntime.jsx(DensityContainer, { dataTestId: dataTestId, className: cvaCardHeaderDensityContainer({ border: hideSeparator ? "borderless" : "default", className }), density: density, children: jsxRuntime.jsxs("div", { className: cvaCardHeader(), children: [jsxRuntime.jsxs("div", { className: extraClassName, children: [jsxRuntime.jsxs("div", { className: cvaCardHeaderHeadingContainer(), children: [jsxRuntime.jsx(Heading, { className: "self-center", variant: headingVariant, children: heading }), accessories] }), subHeading && (jsxRuntime.jsx(Heading, { subtle: true, variant: "subtitle", children: subHeading })), children] }), onClose && (jsxRuntime.jsx(IconButton, { dataTestId: "card-header-close-button", variant: "transparent", color: "secondary", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "
|
|
886
|
+
return (jsxRuntime.jsx(DensityContainer, { dataTestId: dataTestId, className: cvaCardHeaderDensityContainer({ border: hideSeparator ? "borderless" : "default", className }), density: density, children: jsxRuntime.jsxs("div", { className: cvaCardHeader(), children: [jsxRuntime.jsxs("div", { className: extraClassName, children: [jsxRuntime.jsxs("div", { className: cvaCardHeaderHeadingContainer(), children: [jsxRuntime.jsx(Heading, { className: "self-center", variant: headingVariant, children: heading }), accessories] }), subHeading && (jsxRuntime.jsx(Heading, { subtle: true, variant: "subtitle", children: subHeading })), children] }), onClose && (jsxRuntime.jsx(IconButton, { dataTestId: "card-header-close-button", variant: "transparent", color: "secondary", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "XMark", size: "small" }), className: "!h-min" }))] }) }));
|
|
886
887
|
};
|
|
887
888
|
|
|
888
889
|
function useMountedState() {
|
|
@@ -1221,7 +1222,7 @@ const Collapse = ({ id, initialExpanded = false, onToggle, label, children, layo
|
|
|
1221
1222
|
}
|
|
1222
1223
|
setExpanded(!expanded);
|
|
1223
1224
|
}, [expanded, onToggle]);
|
|
1224
|
-
return (jsxRuntime.jsxs("div", { className: cvaCollapse({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx("div", { className: cvaCollapseLabel(), role: "button", "aria-expanded": expanded, "aria-controls": id, onClick: handleClick, children: jsxRuntime.jsxs("div", { className: cvaCollapseLabelContainer({ layout }), children: [jsxRuntime.jsx(Text, { type: "span", weight: "bold", children: label }), jsxRuntime.jsx(IconButton, { icon: jsxRuntime.jsx(Icon, { className: cvaCollapseIcon({ expanded }), name: "
|
|
1225
|
+
return (jsxRuntime.jsxs("div", { className: cvaCollapse({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx("div", { className: cvaCollapseLabel(), role: "button", "aria-expanded": expanded, "aria-controls": id, onClick: handleClick, children: jsxRuntime.jsxs("div", { className: cvaCollapseLabelContainer({ layout }), children: [jsxRuntime.jsx(Text, { type: "span", weight: "bold", children: label }), jsxRuntime.jsx(IconButton, { icon: jsxRuntime.jsx(Icon, { className: cvaCollapseIcon({ expanded }), name: "ChevronDown", size: "small" }), size: "medium", variant: "transparent", color: "secondary" })] }) }), jsxRuntime.jsx(Collapsible, { expanded: expanded, id: id, children: children })] }));
|
|
1225
1226
|
};
|
|
1226
1227
|
const Collapsible = ({ children, expanded, id }) => {
|
|
1227
1228
|
const [ref, { height }] = useMeasure$1();
|
|
@@ -1887,7 +1888,7 @@ function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "func
|
|
|
1887
1888
|
* //=> Sun Jul 02 1995 00:00:00
|
|
1888
1889
|
*/
|
|
1889
1890
|
|
|
1890
|
-
function max$
|
|
1891
|
+
function max$1(dirtyDatesArray) {
|
|
1891
1892
|
requiredArgs(1, arguments);
|
|
1892
1893
|
var datesArray; // `dirtyDatesArray` is Array, Set or Map, or object with custom `forEach` method
|
|
1893
1894
|
|
|
@@ -1935,7 +1936,7 @@ function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "func
|
|
|
1935
1936
|
* //=> Wed Feb 11 1987 00:00:00
|
|
1936
1937
|
*/
|
|
1937
1938
|
|
|
1938
|
-
function min$
|
|
1939
|
+
function min$1(dirtyDatesArray) {
|
|
1939
1940
|
requiredArgs(1, arguments);
|
|
1940
1941
|
var datesArray; // `dirtyDatesArray` is Array, Set or Map, or object with custom `forEach` method
|
|
1941
1942
|
|
|
@@ -13947,10 +13948,10 @@ function getNextFocus(focusedDay, options) {
|
|
|
13947
13948
|
};
|
|
13948
13949
|
var newFocusedDay = moveFns[moveBy](focusedDay, direction === 'after' ? 1 : -1);
|
|
13949
13950
|
if (direction === 'before' && fromDate) {
|
|
13950
|
-
newFocusedDay = max$
|
|
13951
|
+
newFocusedDay = max$1([fromDate, newFocusedDay]);
|
|
13951
13952
|
}
|
|
13952
13953
|
else if (direction === 'after' && toDate) {
|
|
13953
|
-
newFocusedDay = min$
|
|
13954
|
+
newFocusedDay = min$1([toDate, newFocusedDay]);
|
|
13954
13955
|
}
|
|
13955
13956
|
var isFocusable = true;
|
|
13956
13957
|
if (modifiers) {
|
|
@@ -14812,330 +14813,68 @@ const DayPicker = ({ onDaySelect, disabledDays, selectedDays, language, classNam
|
|
|
14812
14813
|
return (jsxRuntime.jsx(DayPicker$1, { onDayClick: onDaySelect, selected: selectedDays, locale: locale, disabled: disabledDays, className: `custom-day-picker ${className !== null && className !== void 0 ? className : ""}`, max: max, footer: jsxRuntime.jsx("div", { "data-testid": dataTestId }) }));
|
|
14813
14814
|
};
|
|
14814
14815
|
|
|
14815
|
-
|
|
14816
|
-
|
|
14816
|
+
const min = Math.min;
|
|
14817
|
+
const max = Math.max;
|
|
14818
|
+
const round = Math.round;
|
|
14819
|
+
const floor = Math.floor;
|
|
14820
|
+
const createCoords = v => ({
|
|
14821
|
+
x: v,
|
|
14822
|
+
y: v
|
|
14823
|
+
});
|
|
14824
|
+
const oppositeSideMap = {
|
|
14825
|
+
left: 'right',
|
|
14826
|
+
right: 'left',
|
|
14827
|
+
bottom: 'top',
|
|
14828
|
+
top: 'bottom'
|
|
14829
|
+
};
|
|
14830
|
+
const oppositeAlignmentMap = {
|
|
14831
|
+
start: 'end',
|
|
14832
|
+
end: 'start'
|
|
14833
|
+
};
|
|
14834
|
+
function clamp(start, value, end) {
|
|
14835
|
+
return max(start, min(value, end));
|
|
14817
14836
|
}
|
|
14818
|
-
|
|
14819
|
-
function
|
|
14820
|
-
return axis === 'y' ? 'height' : 'width';
|
|
14837
|
+
function evaluate(value, param) {
|
|
14838
|
+
return typeof value === 'function' ? value(param) : value;
|
|
14821
14839
|
}
|
|
14822
|
-
|
|
14823
14840
|
function getSide(placement) {
|
|
14824
14841
|
return placement.split('-')[0];
|
|
14825
14842
|
}
|
|
14826
|
-
|
|
14827
|
-
|
|
14828
|
-
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
14829
|
-
}
|
|
14830
|
-
|
|
14831
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
14832
|
-
let {
|
|
14833
|
-
reference,
|
|
14834
|
-
floating
|
|
14835
|
-
} = _ref;
|
|
14836
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
14837
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
14838
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
14839
|
-
const length = getLengthFromAxis(mainAxis);
|
|
14840
|
-
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
14841
|
-
const side = getSide(placement);
|
|
14842
|
-
const isVertical = mainAxis === 'x';
|
|
14843
|
-
let coords;
|
|
14844
|
-
switch (side) {
|
|
14845
|
-
case 'top':
|
|
14846
|
-
coords = {
|
|
14847
|
-
x: commonX,
|
|
14848
|
-
y: reference.y - floating.height
|
|
14849
|
-
};
|
|
14850
|
-
break;
|
|
14851
|
-
case 'bottom':
|
|
14852
|
-
coords = {
|
|
14853
|
-
x: commonX,
|
|
14854
|
-
y: reference.y + reference.height
|
|
14855
|
-
};
|
|
14856
|
-
break;
|
|
14857
|
-
case 'right':
|
|
14858
|
-
coords = {
|
|
14859
|
-
x: reference.x + reference.width,
|
|
14860
|
-
y: commonY
|
|
14861
|
-
};
|
|
14862
|
-
break;
|
|
14863
|
-
case 'left':
|
|
14864
|
-
coords = {
|
|
14865
|
-
x: reference.x - floating.width,
|
|
14866
|
-
y: commonY
|
|
14867
|
-
};
|
|
14868
|
-
break;
|
|
14869
|
-
default:
|
|
14870
|
-
coords = {
|
|
14871
|
-
x: reference.x,
|
|
14872
|
-
y: reference.y
|
|
14873
|
-
};
|
|
14874
|
-
}
|
|
14875
|
-
switch (getAlignment(placement)) {
|
|
14876
|
-
case 'start':
|
|
14877
|
-
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
14878
|
-
break;
|
|
14879
|
-
case 'end':
|
|
14880
|
-
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
14881
|
-
break;
|
|
14882
|
-
}
|
|
14883
|
-
return coords;
|
|
14884
|
-
}
|
|
14885
|
-
|
|
14886
|
-
/**
|
|
14887
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
14888
|
-
* next to a reference element when it is given a certain positioning strategy.
|
|
14889
|
-
*
|
|
14890
|
-
* This export does not have any `platform` interface logic. You will need to
|
|
14891
|
-
* write one for the platform you are using Floating UI with.
|
|
14892
|
-
*/
|
|
14893
|
-
const computePosition$1 = async (reference, floating, config) => {
|
|
14894
|
-
const {
|
|
14895
|
-
placement = 'bottom',
|
|
14896
|
-
strategy = 'absolute',
|
|
14897
|
-
middleware = [],
|
|
14898
|
-
platform
|
|
14899
|
-
} = config;
|
|
14900
|
-
const validMiddleware = middleware.filter(Boolean);
|
|
14901
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
14902
|
-
if (process.env.NODE_ENV !== "production") {
|
|
14903
|
-
if (platform == null) {
|
|
14904
|
-
console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));
|
|
14905
|
-
}
|
|
14906
|
-
if (validMiddleware.filter(_ref => {
|
|
14907
|
-
let {
|
|
14908
|
-
name
|
|
14909
|
-
} = _ref;
|
|
14910
|
-
return name === 'autoPlacement' || name === 'flip';
|
|
14911
|
-
}).length > 1) {
|
|
14912
|
-
throw new Error(['Floating UI: duplicate `flip` and/or `autoPlacement` middleware', 'detected. This will lead to an infinite loop. Ensure only one of', 'either has been passed to the `middleware` array.'].join(' '));
|
|
14913
|
-
}
|
|
14914
|
-
if (!reference || !floating) {
|
|
14915
|
-
console.error(['Floating UI: The reference and/or floating element was not defined', 'when `computePosition()` was called. Ensure that both elements have', 'been created and can be measured.'].join(' '));
|
|
14916
|
-
}
|
|
14917
|
-
}
|
|
14918
|
-
let rects = await platform.getElementRects({
|
|
14919
|
-
reference,
|
|
14920
|
-
floating,
|
|
14921
|
-
strategy
|
|
14922
|
-
});
|
|
14923
|
-
let {
|
|
14924
|
-
x,
|
|
14925
|
-
y
|
|
14926
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
14927
|
-
let statefulPlacement = placement;
|
|
14928
|
-
let middlewareData = {};
|
|
14929
|
-
let resetCount = 0;
|
|
14930
|
-
for (let i = 0; i < validMiddleware.length; i++) {
|
|
14931
|
-
const {
|
|
14932
|
-
name,
|
|
14933
|
-
fn
|
|
14934
|
-
} = validMiddleware[i];
|
|
14935
|
-
const {
|
|
14936
|
-
x: nextX,
|
|
14937
|
-
y: nextY,
|
|
14938
|
-
data,
|
|
14939
|
-
reset
|
|
14940
|
-
} = await fn({
|
|
14941
|
-
x,
|
|
14942
|
-
y,
|
|
14943
|
-
initialPlacement: placement,
|
|
14944
|
-
placement: statefulPlacement,
|
|
14945
|
-
strategy,
|
|
14946
|
-
middlewareData,
|
|
14947
|
-
rects,
|
|
14948
|
-
platform,
|
|
14949
|
-
elements: {
|
|
14950
|
-
reference,
|
|
14951
|
-
floating
|
|
14952
|
-
}
|
|
14953
|
-
});
|
|
14954
|
-
x = nextX != null ? nextX : x;
|
|
14955
|
-
y = nextY != null ? nextY : y;
|
|
14956
|
-
middlewareData = {
|
|
14957
|
-
...middlewareData,
|
|
14958
|
-
[name]: {
|
|
14959
|
-
...middlewareData[name],
|
|
14960
|
-
...data
|
|
14961
|
-
}
|
|
14962
|
-
};
|
|
14963
|
-
if (process.env.NODE_ENV !== "production") {
|
|
14964
|
-
if (resetCount > 50) {
|
|
14965
|
-
console.warn(['Floating UI: The middleware lifecycle appears to be running in an', 'infinite loop. This is usually caused by a `reset` continually', 'being returned without a break condition.'].join(' '));
|
|
14966
|
-
}
|
|
14967
|
-
}
|
|
14968
|
-
if (reset && resetCount <= 50) {
|
|
14969
|
-
resetCount++;
|
|
14970
|
-
if (typeof reset === 'object') {
|
|
14971
|
-
if (reset.placement) {
|
|
14972
|
-
statefulPlacement = reset.placement;
|
|
14973
|
-
}
|
|
14974
|
-
if (reset.rects) {
|
|
14975
|
-
rects = reset.rects === true ? await platform.getElementRects({
|
|
14976
|
-
reference,
|
|
14977
|
-
floating,
|
|
14978
|
-
strategy
|
|
14979
|
-
}) : reset.rects;
|
|
14980
|
-
}
|
|
14981
|
-
({
|
|
14982
|
-
x,
|
|
14983
|
-
y
|
|
14984
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
14985
|
-
}
|
|
14986
|
-
i = -1;
|
|
14987
|
-
continue;
|
|
14988
|
-
}
|
|
14989
|
-
}
|
|
14990
|
-
return {
|
|
14991
|
-
x,
|
|
14992
|
-
y,
|
|
14993
|
-
placement: statefulPlacement,
|
|
14994
|
-
strategy,
|
|
14995
|
-
middlewareData
|
|
14996
|
-
};
|
|
14997
|
-
};
|
|
14998
|
-
|
|
14999
|
-
function expandPaddingObject(padding) {
|
|
15000
|
-
return {
|
|
15001
|
-
top: 0,
|
|
15002
|
-
right: 0,
|
|
15003
|
-
bottom: 0,
|
|
15004
|
-
left: 0,
|
|
15005
|
-
...padding
|
|
15006
|
-
};
|
|
15007
|
-
}
|
|
15008
|
-
|
|
15009
|
-
function getSideObjectFromPadding(padding) {
|
|
15010
|
-
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
15011
|
-
top: padding,
|
|
15012
|
-
right: padding,
|
|
15013
|
-
bottom: padding,
|
|
15014
|
-
left: padding
|
|
15015
|
-
};
|
|
14843
|
+
function getAlignment(placement) {
|
|
14844
|
+
return placement.split('-')[1];
|
|
15016
14845
|
}
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
return {
|
|
15020
|
-
...rect,
|
|
15021
|
-
top: rect.y,
|
|
15022
|
-
left: rect.x,
|
|
15023
|
-
right: rect.x + rect.width,
|
|
15024
|
-
bottom: rect.y + rect.height
|
|
15025
|
-
};
|
|
14846
|
+
function getOppositeAxis(axis) {
|
|
14847
|
+
return axis === 'x' ? 'y' : 'x';
|
|
15026
14848
|
}
|
|
15027
|
-
|
|
15028
|
-
|
|
15029
|
-
* Resolves with an object of overflow side offsets that determine how much the
|
|
15030
|
-
* element is overflowing a given clipping boundary on each side.
|
|
15031
|
-
* - positive = overflowing the boundary by that number of pixels
|
|
15032
|
-
* - negative = how many pixels left before it will overflow
|
|
15033
|
-
* - 0 = lies flush with the boundary
|
|
15034
|
-
* @see https://floating-ui.com/docs/detectOverflow
|
|
15035
|
-
*/
|
|
15036
|
-
async function detectOverflow(state, options) {
|
|
15037
|
-
var _await$platform$isEle;
|
|
15038
|
-
if (options === void 0) {
|
|
15039
|
-
options = {};
|
|
15040
|
-
}
|
|
15041
|
-
const {
|
|
15042
|
-
x,
|
|
15043
|
-
y,
|
|
15044
|
-
platform,
|
|
15045
|
-
rects,
|
|
15046
|
-
elements,
|
|
15047
|
-
strategy
|
|
15048
|
-
} = state;
|
|
15049
|
-
const {
|
|
15050
|
-
boundary = 'clippingAncestors',
|
|
15051
|
-
rootBoundary = 'viewport',
|
|
15052
|
-
elementContext = 'floating',
|
|
15053
|
-
altBoundary = false,
|
|
15054
|
-
padding = 0
|
|
15055
|
-
} = options;
|
|
15056
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
15057
|
-
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
15058
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
15059
|
-
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
15060
|
-
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
15061
|
-
boundary,
|
|
15062
|
-
rootBoundary,
|
|
15063
|
-
strategy
|
|
15064
|
-
}));
|
|
15065
|
-
const rect = elementContext === 'floating' ? {
|
|
15066
|
-
...rects.floating,
|
|
15067
|
-
x,
|
|
15068
|
-
y
|
|
15069
|
-
} : rects.reference;
|
|
15070
|
-
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
15071
|
-
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
15072
|
-
x: 1,
|
|
15073
|
-
y: 1
|
|
15074
|
-
} : {
|
|
15075
|
-
x: 1,
|
|
15076
|
-
y: 1
|
|
15077
|
-
};
|
|
15078
|
-
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
15079
|
-
rect,
|
|
15080
|
-
offsetParent,
|
|
15081
|
-
strategy
|
|
15082
|
-
}) : rect);
|
|
15083
|
-
if (process.env.NODE_ENV !== "production") ;
|
|
15084
|
-
return {
|
|
15085
|
-
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
15086
|
-
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
15087
|
-
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
15088
|
-
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
15089
|
-
};
|
|
14849
|
+
function getAxisLength(axis) {
|
|
14850
|
+
return axis === 'y' ? 'height' : 'width';
|
|
15090
14851
|
}
|
|
15091
|
-
|
|
15092
|
-
|
|
15093
|
-
const max$1 = Math.max;
|
|
15094
|
-
|
|
15095
|
-
function within(min$1$1, value, max$1$1) {
|
|
15096
|
-
return max$1(min$1$1, min$1(value, max$1$1));
|
|
14852
|
+
function getSideAxis(placement) {
|
|
14853
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
|
|
15097
14854
|
}
|
|
15098
|
-
|
|
15099
|
-
|
|
15100
|
-
left: 'right',
|
|
15101
|
-
right: 'left',
|
|
15102
|
-
bottom: 'top',
|
|
15103
|
-
top: 'bottom'
|
|
15104
|
-
};
|
|
15105
|
-
function getOppositePlacement(placement) {
|
|
15106
|
-
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
14855
|
+
function getAlignmentAxis(placement) {
|
|
14856
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
15107
14857
|
}
|
|
15108
|
-
|
|
15109
14858
|
function getAlignmentSides(placement, rects, rtl) {
|
|
15110
14859
|
if (rtl === void 0) {
|
|
15111
14860
|
rtl = false;
|
|
15112
14861
|
}
|
|
15113
14862
|
const alignment = getAlignment(placement);
|
|
15114
|
-
const
|
|
15115
|
-
const length =
|
|
15116
|
-
let mainAlignmentSide =
|
|
14863
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
14864
|
+
const length = getAxisLength(alignmentAxis);
|
|
14865
|
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
15117
14866
|
if (rects.reference[length] > rects.floating[length]) {
|
|
15118
14867
|
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
15119
14868
|
}
|
|
15120
|
-
return
|
|
15121
|
-
main: mainAlignmentSide,
|
|
15122
|
-
cross: getOppositePlacement(mainAlignmentSide)
|
|
15123
|
-
};
|
|
15124
|
-
}
|
|
15125
|
-
|
|
15126
|
-
const oppositeAlignmentMap = {
|
|
15127
|
-
start: 'end',
|
|
15128
|
-
end: 'start'
|
|
15129
|
-
};
|
|
15130
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
15131
|
-
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
14869
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
15132
14870
|
}
|
|
15133
|
-
|
|
15134
14871
|
function getExpandedPlacements(placement) {
|
|
15135
14872
|
const oppositePlacement = getOppositePlacement(placement);
|
|
15136
14873
|
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
15137
14874
|
}
|
|
15138
|
-
|
|
14875
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
14876
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
14877
|
+
}
|
|
15139
14878
|
function getSideList(side, isStart, rtl) {
|
|
15140
14879
|
const lr = ['left', 'right'];
|
|
15141
14880
|
const rl = ['right', 'left'];
|
|
@@ -15164,6 +14903,494 @@ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
|
15164
14903
|
}
|
|
15165
14904
|
return list;
|
|
15166
14905
|
}
|
|
14906
|
+
function getOppositePlacement(placement) {
|
|
14907
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
14908
|
+
}
|
|
14909
|
+
function expandPaddingObject(padding) {
|
|
14910
|
+
return {
|
|
14911
|
+
top: 0,
|
|
14912
|
+
right: 0,
|
|
14913
|
+
bottom: 0,
|
|
14914
|
+
left: 0,
|
|
14915
|
+
...padding
|
|
14916
|
+
};
|
|
14917
|
+
}
|
|
14918
|
+
function getPaddingObject(padding) {
|
|
14919
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
14920
|
+
top: padding,
|
|
14921
|
+
right: padding,
|
|
14922
|
+
bottom: padding,
|
|
14923
|
+
left: padding
|
|
14924
|
+
};
|
|
14925
|
+
}
|
|
14926
|
+
function rectToClientRect(rect) {
|
|
14927
|
+
return {
|
|
14928
|
+
...rect,
|
|
14929
|
+
top: rect.y,
|
|
14930
|
+
left: rect.x,
|
|
14931
|
+
right: rect.x + rect.width,
|
|
14932
|
+
bottom: rect.y + rect.height
|
|
14933
|
+
};
|
|
14934
|
+
}
|
|
14935
|
+
|
|
14936
|
+
function getNodeName(node) {
|
|
14937
|
+
if (isNode(node)) {
|
|
14938
|
+
return (node.nodeName || '').toLowerCase();
|
|
14939
|
+
}
|
|
14940
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
14941
|
+
// returning `#document` an infinite loop won't occur.
|
|
14942
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
14943
|
+
return '#document';
|
|
14944
|
+
}
|
|
14945
|
+
function getWindow(node) {
|
|
14946
|
+
var _node$ownerDocument;
|
|
14947
|
+
return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
14948
|
+
}
|
|
14949
|
+
function getDocumentElement(node) {
|
|
14950
|
+
var _ref;
|
|
14951
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
14952
|
+
}
|
|
14953
|
+
function isNode(value) {
|
|
14954
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
14955
|
+
}
|
|
14956
|
+
function isElement(value) {
|
|
14957
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
14958
|
+
}
|
|
14959
|
+
function isHTMLElement(value) {
|
|
14960
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
14961
|
+
}
|
|
14962
|
+
function isShadowRoot(value) {
|
|
14963
|
+
// Browsers without `ShadowRoot` support.
|
|
14964
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
14965
|
+
return false;
|
|
14966
|
+
}
|
|
14967
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
14968
|
+
}
|
|
14969
|
+
function isOverflowElement(element) {
|
|
14970
|
+
const {
|
|
14971
|
+
overflow,
|
|
14972
|
+
overflowX,
|
|
14973
|
+
overflowY,
|
|
14974
|
+
display
|
|
14975
|
+
} = getComputedStyle$1(element);
|
|
14976
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
14977
|
+
}
|
|
14978
|
+
function isTableElement(element) {
|
|
14979
|
+
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
14980
|
+
}
|
|
14981
|
+
function isContainingBlock(element) {
|
|
14982
|
+
const webkit = isWebKit();
|
|
14983
|
+
const css = getComputedStyle$1(element);
|
|
14984
|
+
|
|
14985
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
14986
|
+
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));
|
|
14987
|
+
}
|
|
14988
|
+
function getContainingBlock(element) {
|
|
14989
|
+
let currentNode = getParentNode(element);
|
|
14990
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
14991
|
+
if (isContainingBlock(currentNode)) {
|
|
14992
|
+
return currentNode;
|
|
14993
|
+
} else {
|
|
14994
|
+
currentNode = getParentNode(currentNode);
|
|
14995
|
+
}
|
|
14996
|
+
}
|
|
14997
|
+
return null;
|
|
14998
|
+
}
|
|
14999
|
+
function isWebKit() {
|
|
15000
|
+
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
15001
|
+
return CSS.supports('-webkit-backdrop-filter', 'none');
|
|
15002
|
+
}
|
|
15003
|
+
function isLastTraversableNode(node) {
|
|
15004
|
+
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
15005
|
+
}
|
|
15006
|
+
function getComputedStyle$1(element) {
|
|
15007
|
+
return getWindow(element).getComputedStyle(element);
|
|
15008
|
+
}
|
|
15009
|
+
function getNodeScroll(element) {
|
|
15010
|
+
if (isElement(element)) {
|
|
15011
|
+
return {
|
|
15012
|
+
scrollLeft: element.scrollLeft,
|
|
15013
|
+
scrollTop: element.scrollTop
|
|
15014
|
+
};
|
|
15015
|
+
}
|
|
15016
|
+
return {
|
|
15017
|
+
scrollLeft: element.pageXOffset,
|
|
15018
|
+
scrollTop: element.pageYOffset
|
|
15019
|
+
};
|
|
15020
|
+
}
|
|
15021
|
+
function getParentNode(node) {
|
|
15022
|
+
if (getNodeName(node) === 'html') {
|
|
15023
|
+
return node;
|
|
15024
|
+
}
|
|
15025
|
+
const result =
|
|
15026
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
15027
|
+
node.assignedSlot ||
|
|
15028
|
+
// DOM Element detected.
|
|
15029
|
+
node.parentNode ||
|
|
15030
|
+
// ShadowRoot detected.
|
|
15031
|
+
isShadowRoot(node) && node.host ||
|
|
15032
|
+
// Fallback.
|
|
15033
|
+
getDocumentElement(node);
|
|
15034
|
+
return isShadowRoot(result) ? result.host : result;
|
|
15035
|
+
}
|
|
15036
|
+
function getNearestOverflowAncestor(node) {
|
|
15037
|
+
const parentNode = getParentNode(node);
|
|
15038
|
+
if (isLastTraversableNode(parentNode)) {
|
|
15039
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
15040
|
+
}
|
|
15041
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
15042
|
+
return parentNode;
|
|
15043
|
+
}
|
|
15044
|
+
return getNearestOverflowAncestor(parentNode);
|
|
15045
|
+
}
|
|
15046
|
+
function getOverflowAncestors(node, list) {
|
|
15047
|
+
var _node$ownerDocument2;
|
|
15048
|
+
if (list === void 0) {
|
|
15049
|
+
list = [];
|
|
15050
|
+
}
|
|
15051
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
15052
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
15053
|
+
const win = getWindow(scrollableAncestor);
|
|
15054
|
+
if (isBody) {
|
|
15055
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
|
|
15056
|
+
}
|
|
15057
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
|
|
15058
|
+
}
|
|
15059
|
+
|
|
15060
|
+
function activeElement(doc) {
|
|
15061
|
+
let activeElement = doc.activeElement;
|
|
15062
|
+
while (((_activeElement = activeElement) == null ? void 0 : (_activeElement$shadow = _activeElement.shadowRoot) == null ? void 0 : _activeElement$shadow.activeElement) != null) {
|
|
15063
|
+
var _activeElement, _activeElement$shadow;
|
|
15064
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
|
15065
|
+
}
|
|
15066
|
+
return activeElement;
|
|
15067
|
+
}
|
|
15068
|
+
function contains(parent, child) {
|
|
15069
|
+
if (!parent || !child) {
|
|
15070
|
+
return false;
|
|
15071
|
+
}
|
|
15072
|
+
const rootNode = child.getRootNode && child.getRootNode();
|
|
15073
|
+
|
|
15074
|
+
// First, attempt with faster native method
|
|
15075
|
+
if (parent.contains(child)) {
|
|
15076
|
+
return true;
|
|
15077
|
+
}
|
|
15078
|
+
|
|
15079
|
+
// then fallback to custom implementation with Shadow DOM support
|
|
15080
|
+
if (rootNode && isShadowRoot(rootNode)) {
|
|
15081
|
+
let next = child;
|
|
15082
|
+
while (next) {
|
|
15083
|
+
if (parent === next) {
|
|
15084
|
+
return true;
|
|
15085
|
+
}
|
|
15086
|
+
// @ts-ignore
|
|
15087
|
+
next = next.parentNode || next.host;
|
|
15088
|
+
}
|
|
15089
|
+
}
|
|
15090
|
+
|
|
15091
|
+
// Give up, the result is false
|
|
15092
|
+
return false;
|
|
15093
|
+
}
|
|
15094
|
+
// Avoid Chrome DevTools blue warning.
|
|
15095
|
+
function getPlatform() {
|
|
15096
|
+
const uaData = navigator.userAgentData;
|
|
15097
|
+
if (uaData != null && uaData.platform) {
|
|
15098
|
+
return uaData.platform;
|
|
15099
|
+
}
|
|
15100
|
+
return navigator.platform;
|
|
15101
|
+
}
|
|
15102
|
+
function getUserAgent() {
|
|
15103
|
+
const uaData = navigator.userAgentData;
|
|
15104
|
+
if (uaData && Array.isArray(uaData.brands)) {
|
|
15105
|
+
return uaData.brands.map(_ref => {
|
|
15106
|
+
let {
|
|
15107
|
+
brand,
|
|
15108
|
+
version
|
|
15109
|
+
} = _ref;
|
|
15110
|
+
return brand + "/" + version;
|
|
15111
|
+
}).join(' ');
|
|
15112
|
+
}
|
|
15113
|
+
return navigator.userAgent;
|
|
15114
|
+
}
|
|
15115
|
+
|
|
15116
|
+
// License: https://github.com/adobe/react-spectrum/blob/b35d5c02fe900badccd0cf1a8f23bb593419f238/packages/@react-aria/utils/src/isVirtualEvent.ts
|
|
15117
|
+
function isVirtualClick(event) {
|
|
15118
|
+
if (event.mozInputSource === 0 && event.isTrusted) {
|
|
15119
|
+
return true;
|
|
15120
|
+
}
|
|
15121
|
+
const androidRe = /Android/i;
|
|
15122
|
+
if ((androidRe.test(getPlatform()) || androidRe.test(getUserAgent())) && event.pointerType) {
|
|
15123
|
+
return event.type === 'click' && event.buttons === 1;
|
|
15124
|
+
}
|
|
15125
|
+
return event.detail === 0 && !event.pointerType;
|
|
15126
|
+
}
|
|
15127
|
+
function isVirtualPointerEvent(event) {
|
|
15128
|
+
return event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType !== 'mouse' ||
|
|
15129
|
+
// iOS VoiceOver returns 0.333• for width/height.
|
|
15130
|
+
event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0;
|
|
15131
|
+
}
|
|
15132
|
+
function isSafari() {
|
|
15133
|
+
// Chrome DevTools does not complain about navigator.vendor
|
|
15134
|
+
return /apple/i.test(navigator.vendor);
|
|
15135
|
+
}
|
|
15136
|
+
function isMouseLikePointerType(pointerType, strict) {
|
|
15137
|
+
// On some Linux machines with Chromium, mouse inputs return a `pointerType`
|
|
15138
|
+
// of "pen": https://github.com/floating-ui/floating-ui/issues/2015
|
|
15139
|
+
const values = ['mouse', 'pen'];
|
|
15140
|
+
if (!strict) {
|
|
15141
|
+
values.push('', undefined);
|
|
15142
|
+
}
|
|
15143
|
+
return values.includes(pointerType);
|
|
15144
|
+
}
|
|
15145
|
+
function isReactEvent(event) {
|
|
15146
|
+
return 'nativeEvent' in event;
|
|
15147
|
+
}
|
|
15148
|
+
function isRootElement(element) {
|
|
15149
|
+
return element.matches('html,body');
|
|
15150
|
+
}
|
|
15151
|
+
function getDocument(node) {
|
|
15152
|
+
return (node == null ? void 0 : node.ownerDocument) || document;
|
|
15153
|
+
}
|
|
15154
|
+
function isEventTargetWithin(event, node) {
|
|
15155
|
+
if (node == null) {
|
|
15156
|
+
return false;
|
|
15157
|
+
}
|
|
15158
|
+
if ('composedPath' in event) {
|
|
15159
|
+
return event.composedPath().includes(node);
|
|
15160
|
+
}
|
|
15161
|
+
|
|
15162
|
+
// TS thinks `event` is of type never as it assumes all browsers support composedPath, but browsers without shadow dom don't
|
|
15163
|
+
const e = event;
|
|
15164
|
+
return e.target != null && node.contains(e.target);
|
|
15165
|
+
}
|
|
15166
|
+
function getTarget(event) {
|
|
15167
|
+
if ('composedPath' in event) {
|
|
15168
|
+
return event.composedPath()[0];
|
|
15169
|
+
}
|
|
15170
|
+
|
|
15171
|
+
// TS thinks `event` is of type never as it assumes all browsers support
|
|
15172
|
+
// `composedPath()`, but browsers without shadow DOM don't.
|
|
15173
|
+
return event.target;
|
|
15174
|
+
}
|
|
15175
|
+
const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled])," + "[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
|
|
15176
|
+
function isTypeableElement(element) {
|
|
15177
|
+
return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
|
|
15178
|
+
}
|
|
15179
|
+
function stopEvent(event) {
|
|
15180
|
+
event.preventDefault();
|
|
15181
|
+
event.stopPropagation();
|
|
15182
|
+
}
|
|
15183
|
+
|
|
15184
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
15185
|
+
let {
|
|
15186
|
+
reference,
|
|
15187
|
+
floating
|
|
15188
|
+
} = _ref;
|
|
15189
|
+
const sideAxis = getSideAxis(placement);
|
|
15190
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
15191
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
15192
|
+
const side = getSide(placement);
|
|
15193
|
+
const isVertical = sideAxis === 'y';
|
|
15194
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
15195
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
15196
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
15197
|
+
let coords;
|
|
15198
|
+
switch (side) {
|
|
15199
|
+
case 'top':
|
|
15200
|
+
coords = {
|
|
15201
|
+
x: commonX,
|
|
15202
|
+
y: reference.y - floating.height
|
|
15203
|
+
};
|
|
15204
|
+
break;
|
|
15205
|
+
case 'bottom':
|
|
15206
|
+
coords = {
|
|
15207
|
+
x: commonX,
|
|
15208
|
+
y: reference.y + reference.height
|
|
15209
|
+
};
|
|
15210
|
+
break;
|
|
15211
|
+
case 'right':
|
|
15212
|
+
coords = {
|
|
15213
|
+
x: reference.x + reference.width,
|
|
15214
|
+
y: commonY
|
|
15215
|
+
};
|
|
15216
|
+
break;
|
|
15217
|
+
case 'left':
|
|
15218
|
+
coords = {
|
|
15219
|
+
x: reference.x - floating.width,
|
|
15220
|
+
y: commonY
|
|
15221
|
+
};
|
|
15222
|
+
break;
|
|
15223
|
+
default:
|
|
15224
|
+
coords = {
|
|
15225
|
+
x: reference.x,
|
|
15226
|
+
y: reference.y
|
|
15227
|
+
};
|
|
15228
|
+
}
|
|
15229
|
+
switch (getAlignment(placement)) {
|
|
15230
|
+
case 'start':
|
|
15231
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
15232
|
+
break;
|
|
15233
|
+
case 'end':
|
|
15234
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
15235
|
+
break;
|
|
15236
|
+
}
|
|
15237
|
+
return coords;
|
|
15238
|
+
}
|
|
15239
|
+
|
|
15240
|
+
/**
|
|
15241
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
15242
|
+
* next to a reference element when it is given a certain positioning strategy.
|
|
15243
|
+
*
|
|
15244
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
15245
|
+
* write one for the platform you are using Floating UI with.
|
|
15246
|
+
*/
|
|
15247
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
15248
|
+
const {
|
|
15249
|
+
placement = 'bottom',
|
|
15250
|
+
strategy = 'absolute',
|
|
15251
|
+
middleware = [],
|
|
15252
|
+
platform
|
|
15253
|
+
} = config;
|
|
15254
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
15255
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
15256
|
+
let rects = await platform.getElementRects({
|
|
15257
|
+
reference,
|
|
15258
|
+
floating,
|
|
15259
|
+
strategy
|
|
15260
|
+
});
|
|
15261
|
+
let {
|
|
15262
|
+
x,
|
|
15263
|
+
y
|
|
15264
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
15265
|
+
let statefulPlacement = placement;
|
|
15266
|
+
let middlewareData = {};
|
|
15267
|
+
let resetCount = 0;
|
|
15268
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
15269
|
+
const {
|
|
15270
|
+
name,
|
|
15271
|
+
fn
|
|
15272
|
+
} = validMiddleware[i];
|
|
15273
|
+
const {
|
|
15274
|
+
x: nextX,
|
|
15275
|
+
y: nextY,
|
|
15276
|
+
data,
|
|
15277
|
+
reset
|
|
15278
|
+
} = await fn({
|
|
15279
|
+
x,
|
|
15280
|
+
y,
|
|
15281
|
+
initialPlacement: placement,
|
|
15282
|
+
placement: statefulPlacement,
|
|
15283
|
+
strategy,
|
|
15284
|
+
middlewareData,
|
|
15285
|
+
rects,
|
|
15286
|
+
platform,
|
|
15287
|
+
elements: {
|
|
15288
|
+
reference,
|
|
15289
|
+
floating
|
|
15290
|
+
}
|
|
15291
|
+
});
|
|
15292
|
+
x = nextX != null ? nextX : x;
|
|
15293
|
+
y = nextY != null ? nextY : y;
|
|
15294
|
+
middlewareData = {
|
|
15295
|
+
...middlewareData,
|
|
15296
|
+
[name]: {
|
|
15297
|
+
...middlewareData[name],
|
|
15298
|
+
...data
|
|
15299
|
+
}
|
|
15300
|
+
};
|
|
15301
|
+
if (reset && resetCount <= 50) {
|
|
15302
|
+
resetCount++;
|
|
15303
|
+
if (typeof reset === 'object') {
|
|
15304
|
+
if (reset.placement) {
|
|
15305
|
+
statefulPlacement = reset.placement;
|
|
15306
|
+
}
|
|
15307
|
+
if (reset.rects) {
|
|
15308
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
15309
|
+
reference,
|
|
15310
|
+
floating,
|
|
15311
|
+
strategy
|
|
15312
|
+
}) : reset.rects;
|
|
15313
|
+
}
|
|
15314
|
+
({
|
|
15315
|
+
x,
|
|
15316
|
+
y
|
|
15317
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
15318
|
+
}
|
|
15319
|
+
i = -1;
|
|
15320
|
+
continue;
|
|
15321
|
+
}
|
|
15322
|
+
}
|
|
15323
|
+
return {
|
|
15324
|
+
x,
|
|
15325
|
+
y,
|
|
15326
|
+
placement: statefulPlacement,
|
|
15327
|
+
strategy,
|
|
15328
|
+
middlewareData
|
|
15329
|
+
};
|
|
15330
|
+
};
|
|
15331
|
+
|
|
15332
|
+
/**
|
|
15333
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
15334
|
+
* element is overflowing a given clipping boundary on each side.
|
|
15335
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
15336
|
+
* - negative = how many pixels left before it will overflow
|
|
15337
|
+
* - 0 = lies flush with the boundary
|
|
15338
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
15339
|
+
*/
|
|
15340
|
+
async function detectOverflow(state, options) {
|
|
15341
|
+
var _await$platform$isEle;
|
|
15342
|
+
if (options === void 0) {
|
|
15343
|
+
options = {};
|
|
15344
|
+
}
|
|
15345
|
+
const {
|
|
15346
|
+
x,
|
|
15347
|
+
y,
|
|
15348
|
+
platform,
|
|
15349
|
+
rects,
|
|
15350
|
+
elements,
|
|
15351
|
+
strategy
|
|
15352
|
+
} = state;
|
|
15353
|
+
const {
|
|
15354
|
+
boundary = 'clippingAncestors',
|
|
15355
|
+
rootBoundary = 'viewport',
|
|
15356
|
+
elementContext = 'floating',
|
|
15357
|
+
altBoundary = false,
|
|
15358
|
+
padding = 0
|
|
15359
|
+
} = evaluate(options, state);
|
|
15360
|
+
const paddingObject = getPaddingObject(padding);
|
|
15361
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
15362
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
15363
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
15364
|
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
15365
|
+
boundary,
|
|
15366
|
+
rootBoundary,
|
|
15367
|
+
strategy
|
|
15368
|
+
}));
|
|
15369
|
+
const rect = elementContext === 'floating' ? {
|
|
15370
|
+
...rects.floating,
|
|
15371
|
+
x,
|
|
15372
|
+
y
|
|
15373
|
+
} : rects.reference;
|
|
15374
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
15375
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
15376
|
+
x: 1,
|
|
15377
|
+
y: 1
|
|
15378
|
+
} : {
|
|
15379
|
+
x: 1,
|
|
15380
|
+
y: 1
|
|
15381
|
+
};
|
|
15382
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
15383
|
+
rect,
|
|
15384
|
+
offsetParent,
|
|
15385
|
+
strategy
|
|
15386
|
+
}) : rect);
|
|
15387
|
+
return {
|
|
15388
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
15389
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
15390
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
15391
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
15392
|
+
};
|
|
15393
|
+
}
|
|
15167
15394
|
|
|
15168
15395
|
/**
|
|
15169
15396
|
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
@@ -15196,7 +15423,7 @@ const flip = function (options) {
|
|
|
15196
15423
|
fallbackAxisSideDirection = 'none',
|
|
15197
15424
|
flipAlignment = true,
|
|
15198
15425
|
...detectOverflowOptions
|
|
15199
|
-
} = options;
|
|
15426
|
+
} = evaluate(options, state);
|
|
15200
15427
|
const side = getSide(placement);
|
|
15201
15428
|
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
15202
15429
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
@@ -15212,11 +15439,8 @@ const flip = function (options) {
|
|
|
15212
15439
|
overflows.push(overflow[side]);
|
|
15213
15440
|
}
|
|
15214
15441
|
if (checkCrossAxis) {
|
|
15215
|
-
const
|
|
15216
|
-
|
|
15217
|
-
cross
|
|
15218
|
-
} = getAlignmentSides(placement, rects, rtl);
|
|
15219
|
-
overflows.push(overflow[main], overflow[cross]);
|
|
15442
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
15443
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
15220
15444
|
}
|
|
15221
15445
|
overflowsData = [...overflowsData, {
|
|
15222
15446
|
placement,
|
|
@@ -15275,7 +15499,9 @@ const flip = function (options) {
|
|
|
15275
15499
|
};
|
|
15276
15500
|
};
|
|
15277
15501
|
|
|
15278
|
-
|
|
15502
|
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
15503
|
+
// Derivable.
|
|
15504
|
+
async function convertValueToCoords(state, options) {
|
|
15279
15505
|
const {
|
|
15280
15506
|
placement,
|
|
15281
15507
|
platform,
|
|
@@ -15284,10 +15510,10 @@ async function convertValueToCoords(state, value) {
|
|
|
15284
15510
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
15285
15511
|
const side = getSide(placement);
|
|
15286
15512
|
const alignment = getAlignment(placement);
|
|
15287
|
-
const isVertical =
|
|
15513
|
+
const isVertical = getSideAxis(placement) === 'y';
|
|
15288
15514
|
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
15289
15515
|
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
15290
|
-
const rawValue =
|
|
15516
|
+
const rawValue = evaluate(options, state);
|
|
15291
15517
|
|
|
15292
15518
|
// eslint-disable-next-line prefer-const
|
|
15293
15519
|
let {
|
|
@@ -15323,19 +15549,19 @@ async function convertValueToCoords(state, value) {
|
|
|
15323
15549
|
* object may be passed.
|
|
15324
15550
|
* @see https://floating-ui.com/docs/offset
|
|
15325
15551
|
*/
|
|
15326
|
-
const offset = function (
|
|
15327
|
-
if (
|
|
15328
|
-
|
|
15552
|
+
const offset = function (options) {
|
|
15553
|
+
if (options === void 0) {
|
|
15554
|
+
options = 0;
|
|
15329
15555
|
}
|
|
15330
15556
|
return {
|
|
15331
15557
|
name: 'offset',
|
|
15332
|
-
options
|
|
15558
|
+
options,
|
|
15333
15559
|
async fn(state) {
|
|
15334
15560
|
const {
|
|
15335
15561
|
x,
|
|
15336
15562
|
y
|
|
15337
15563
|
} = state;
|
|
15338
|
-
const diffCoords = await convertValueToCoords(state,
|
|
15564
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
15339
15565
|
return {
|
|
15340
15566
|
x: x + diffCoords.x,
|
|
15341
15567
|
y: y + diffCoords.y,
|
|
@@ -15345,10 +15571,6 @@ const offset = function (value) {
|
|
|
15345
15571
|
};
|
|
15346
15572
|
};
|
|
15347
15573
|
|
|
15348
|
-
function getCrossAxis(axis) {
|
|
15349
|
-
return axis === 'x' ? 'y' : 'x';
|
|
15350
|
-
}
|
|
15351
|
-
|
|
15352
15574
|
/**
|
|
15353
15575
|
* Optimizes the visibility of the floating element by shifting it in order to
|
|
15354
15576
|
* keep it in view when it will overflow the clipping boundary.
|
|
@@ -15383,14 +15605,14 @@ const shift = function (options) {
|
|
|
15383
15605
|
}
|
|
15384
15606
|
},
|
|
15385
15607
|
...detectOverflowOptions
|
|
15386
|
-
} = options;
|
|
15608
|
+
} = evaluate(options, state);
|
|
15387
15609
|
const coords = {
|
|
15388
15610
|
x,
|
|
15389
15611
|
y
|
|
15390
15612
|
};
|
|
15391
15613
|
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
15392
|
-
const
|
|
15393
|
-
const
|
|
15614
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
15615
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
15394
15616
|
let mainAxisCoord = coords[mainAxis];
|
|
15395
15617
|
let crossAxisCoord = coords[crossAxis];
|
|
15396
15618
|
if (checkMainAxis) {
|
|
@@ -15398,14 +15620,14 @@ const shift = function (options) {
|
|
|
15398
15620
|
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
15399
15621
|
const min = mainAxisCoord + overflow[minSide];
|
|
15400
15622
|
const max = mainAxisCoord - overflow[maxSide];
|
|
15401
|
-
mainAxisCoord =
|
|
15623
|
+
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
15402
15624
|
}
|
|
15403
15625
|
if (checkCrossAxis) {
|
|
15404
15626
|
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
15405
15627
|
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
15406
15628
|
const min = crossAxisCoord + overflow[minSide];
|
|
15407
15629
|
const max = crossAxisCoord - overflow[maxSide];
|
|
15408
|
-
crossAxisCoord =
|
|
15630
|
+
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
15409
15631
|
}
|
|
15410
15632
|
const limitedCoords = limiter.fn({
|
|
15411
15633
|
...state,
|
|
@@ -15446,12 +15668,11 @@ const size = function (options) {
|
|
|
15446
15668
|
const {
|
|
15447
15669
|
apply = () => {},
|
|
15448
15670
|
...detectOverflowOptions
|
|
15449
|
-
} = options;
|
|
15671
|
+
} = evaluate(options, state);
|
|
15450
15672
|
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
15451
15673
|
const side = getSide(placement);
|
|
15452
15674
|
const alignment = getAlignment(placement);
|
|
15453
|
-
const
|
|
15454
|
-
const isXAxis = axis === 'x';
|
|
15675
|
+
const isYAxis = getSideAxis(placement) === 'y';
|
|
15455
15676
|
const {
|
|
15456
15677
|
width,
|
|
15457
15678
|
height
|
|
@@ -15467,26 +15688,25 @@ const size = function (options) {
|
|
|
15467
15688
|
}
|
|
15468
15689
|
const overflowAvailableHeight = height - overflow[heightSide];
|
|
15469
15690
|
const overflowAvailableWidth = width - overflow[widthSide];
|
|
15691
|
+
const noShift = !state.middlewareData.shift;
|
|
15470
15692
|
let availableHeight = overflowAvailableHeight;
|
|
15471
15693
|
let availableWidth = overflowAvailableWidth;
|
|
15472
|
-
if (
|
|
15473
|
-
|
|
15474
|
-
|
|
15475
|
-
width - overflow.right - overflow.left, overflowAvailableWidth);
|
|
15694
|
+
if (isYAxis) {
|
|
15695
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
15696
|
+
availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
|
|
15476
15697
|
} else {
|
|
15477
|
-
|
|
15478
|
-
|
|
15479
|
-
|
|
15480
|
-
|
|
15481
|
-
|
|
15482
|
-
const
|
|
15483
|
-
const
|
|
15484
|
-
const
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max$1(overflow.left, overflow.right));
|
|
15698
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
15699
|
+
availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
|
|
15700
|
+
}
|
|
15701
|
+
if (noShift && !alignment) {
|
|
15702
|
+
const xMin = max(overflow.left, 0);
|
|
15703
|
+
const xMax = max(overflow.right, 0);
|
|
15704
|
+
const yMin = max(overflow.top, 0);
|
|
15705
|
+
const yMax = max(overflow.bottom, 0);
|
|
15706
|
+
if (isYAxis) {
|
|
15707
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
15488
15708
|
} else {
|
|
15489
|
-
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max
|
|
15709
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
15490
15710
|
}
|
|
15491
15711
|
}
|
|
15492
15712
|
await apply({
|
|
@@ -15507,106 +15727,13 @@ const size = function (options) {
|
|
|
15507
15727
|
};
|
|
15508
15728
|
};
|
|
15509
15729
|
|
|
15510
|
-
function getWindow$1(node) {
|
|
15511
|
-
var _node$ownerDocument;
|
|
15512
|
-
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
15513
|
-
}
|
|
15514
|
-
|
|
15515
|
-
function getComputedStyle$1(element) {
|
|
15516
|
-
return getWindow$1(element).getComputedStyle(element);
|
|
15517
|
-
}
|
|
15518
|
-
|
|
15519
|
-
function isNode(value) {
|
|
15520
|
-
return value instanceof getWindow$1(value).Node;
|
|
15521
|
-
}
|
|
15522
|
-
function getNodeName(node) {
|
|
15523
|
-
return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
|
|
15524
|
-
}
|
|
15525
|
-
|
|
15526
|
-
let uaString;
|
|
15527
|
-
function getUAString() {
|
|
15528
|
-
if (uaString) {
|
|
15529
|
-
return uaString;
|
|
15530
|
-
}
|
|
15531
|
-
const uaData = navigator.userAgentData;
|
|
15532
|
-
if (uaData && Array.isArray(uaData.brands)) {
|
|
15533
|
-
uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
|
|
15534
|
-
return uaString;
|
|
15535
|
-
}
|
|
15536
|
-
return navigator.userAgent;
|
|
15537
|
-
}
|
|
15538
|
-
|
|
15539
|
-
function isHTMLElement$1(value) {
|
|
15540
|
-
return value instanceof getWindow$1(value).HTMLElement;
|
|
15541
|
-
}
|
|
15542
|
-
function isElement$1(value) {
|
|
15543
|
-
return value instanceof getWindow$1(value).Element;
|
|
15544
|
-
}
|
|
15545
|
-
function isShadowRoot$1(node) {
|
|
15546
|
-
// Browsers without `ShadowRoot` support.
|
|
15547
|
-
if (typeof ShadowRoot === 'undefined') {
|
|
15548
|
-
return false;
|
|
15549
|
-
}
|
|
15550
|
-
const OwnElement = getWindow$1(node).ShadowRoot;
|
|
15551
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
15552
|
-
}
|
|
15553
|
-
function isOverflowElement(element) {
|
|
15554
|
-
const {
|
|
15555
|
-
overflow,
|
|
15556
|
-
overflowX,
|
|
15557
|
-
overflowY,
|
|
15558
|
-
display
|
|
15559
|
-
} = getComputedStyle$1(element);
|
|
15560
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
15561
|
-
}
|
|
15562
|
-
function isTableElement(element) {
|
|
15563
|
-
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
15564
|
-
}
|
|
15565
|
-
function isContainingBlock(element) {
|
|
15566
|
-
// TODO: Try to use feature detection here instead.
|
|
15567
|
-
const isFirefox = /firefox/i.test(getUAString());
|
|
15568
|
-
const css = getComputedStyle$1(element);
|
|
15569
|
-
const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
|
|
15570
|
-
|
|
15571
|
-
// This is non-exhaustive but covers the most common CSS properties that
|
|
15572
|
-
// create a containing block.
|
|
15573
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
15574
|
-
return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => {
|
|
15575
|
-
// Add type check for old browsers.
|
|
15576
|
-
const contain = css.contain;
|
|
15577
|
-
return contain != null ? contain.includes(value) : false;
|
|
15578
|
-
});
|
|
15579
|
-
}
|
|
15580
|
-
|
|
15581
|
-
/**
|
|
15582
|
-
* Determines whether or not `.getBoundingClientRect()` is affected by visual
|
|
15583
|
-
* viewport offsets. In Safari, the `x`/`y` offsets are values relative to the
|
|
15584
|
-
* visual viewport, while in other engines, they are values relative to the
|
|
15585
|
-
* layout viewport.
|
|
15586
|
-
*/
|
|
15587
|
-
function isClientRectVisualViewportBased() {
|
|
15588
|
-
// TODO: Try to use feature detection here instead. Feature detection for
|
|
15589
|
-
// this can fail in various ways, making the userAgent check the most
|
|
15590
|
-
// reliable:
|
|
15591
|
-
// • Always-visible scrollbar or not
|
|
15592
|
-
// • Width of <html>
|
|
15593
|
-
|
|
15594
|
-
// Is Safari.
|
|
15595
|
-
return /^((?!chrome|android).)*safari/i.test(getUAString());
|
|
15596
|
-
}
|
|
15597
|
-
function isLastTraversableNode(node) {
|
|
15598
|
-
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
15599
|
-
}
|
|
15600
|
-
|
|
15601
|
-
const min = Math.min;
|
|
15602
|
-
const max = Math.max;
|
|
15603
|
-
const round = Math.round;
|
|
15604
|
-
|
|
15605
15730
|
function getCssDimensions(element) {
|
|
15606
15731
|
const css = getComputedStyle$1(element);
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
|
|
15732
|
+
// In testing environments, the `width` and `height` properties are empty
|
|
15733
|
+
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
15734
|
+
let width = parseFloat(css.width) || 0;
|
|
15735
|
+
let height = parseFloat(css.height) || 0;
|
|
15736
|
+
const hasOffset = isHTMLElement(element);
|
|
15610
15737
|
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
15611
15738
|
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
15612
15739
|
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
@@ -15617,31 +15744,27 @@ function getCssDimensions(element) {
|
|
|
15617
15744
|
return {
|
|
15618
15745
|
width,
|
|
15619
15746
|
height,
|
|
15620
|
-
|
|
15747
|
+
$: shouldFallback
|
|
15621
15748
|
};
|
|
15622
15749
|
}
|
|
15623
15750
|
|
|
15624
15751
|
function unwrapElement(element) {
|
|
15625
|
-
return !isElement
|
|
15752
|
+
return !isElement(element) ? element.contextElement : element;
|
|
15626
15753
|
}
|
|
15627
15754
|
|
|
15628
|
-
const FALLBACK_SCALE = {
|
|
15629
|
-
x: 1,
|
|
15630
|
-
y: 1
|
|
15631
|
-
};
|
|
15632
15755
|
function getScale(element) {
|
|
15633
15756
|
const domElement = unwrapElement(element);
|
|
15634
|
-
if (!isHTMLElement
|
|
15635
|
-
return
|
|
15757
|
+
if (!isHTMLElement(domElement)) {
|
|
15758
|
+
return createCoords(1);
|
|
15636
15759
|
}
|
|
15637
15760
|
const rect = domElement.getBoundingClientRect();
|
|
15638
15761
|
const {
|
|
15639
15762
|
width,
|
|
15640
15763
|
height,
|
|
15641
|
-
|
|
15764
|
+
$
|
|
15642
15765
|
} = getCssDimensions(domElement);
|
|
15643
|
-
let x = (
|
|
15644
|
-
let y = (
|
|
15766
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
15767
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
15645
15768
|
|
|
15646
15769
|
// 0, NaN, or Infinity should always fallback to 1.
|
|
15647
15770
|
|
|
@@ -15657,8 +15780,28 @@ function getScale(element) {
|
|
|
15657
15780
|
};
|
|
15658
15781
|
}
|
|
15659
15782
|
|
|
15783
|
+
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
15784
|
+
function getVisualOffsets(element) {
|
|
15785
|
+
const win = getWindow(element);
|
|
15786
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
15787
|
+
return noOffsets;
|
|
15788
|
+
}
|
|
15789
|
+
return {
|
|
15790
|
+
x: win.visualViewport.offsetLeft,
|
|
15791
|
+
y: win.visualViewport.offsetTop
|
|
15792
|
+
};
|
|
15793
|
+
}
|
|
15794
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
15795
|
+
if (isFixed === void 0) {
|
|
15796
|
+
isFixed = false;
|
|
15797
|
+
}
|
|
15798
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
15799
|
+
return false;
|
|
15800
|
+
}
|
|
15801
|
+
return isFixed;
|
|
15802
|
+
}
|
|
15803
|
+
|
|
15660
15804
|
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
15661
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
15662
15805
|
if (includeScale === void 0) {
|
|
15663
15806
|
includeScale = false;
|
|
15664
15807
|
}
|
|
@@ -15667,39 +15810,38 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
15667
15810
|
}
|
|
15668
15811
|
const clientRect = element.getBoundingClientRect();
|
|
15669
15812
|
const domElement = unwrapElement(element);
|
|
15670
|
-
let scale =
|
|
15813
|
+
let scale = createCoords(1);
|
|
15671
15814
|
if (includeScale) {
|
|
15672
15815
|
if (offsetParent) {
|
|
15673
|
-
if (isElement
|
|
15816
|
+
if (isElement(offsetParent)) {
|
|
15674
15817
|
scale = getScale(offsetParent);
|
|
15675
15818
|
}
|
|
15676
15819
|
} else {
|
|
15677
15820
|
scale = getScale(element);
|
|
15678
15821
|
}
|
|
15679
15822
|
}
|
|
15680
|
-
const
|
|
15681
|
-
|
|
15682
|
-
let
|
|
15683
|
-
let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
|
|
15823
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
15824
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
15825
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
15684
15826
|
let width = clientRect.width / scale.x;
|
|
15685
15827
|
let height = clientRect.height / scale.y;
|
|
15686
15828
|
if (domElement) {
|
|
15687
|
-
const win = getWindow
|
|
15688
|
-
const offsetWin = offsetParent && isElement
|
|
15829
|
+
const win = getWindow(domElement);
|
|
15830
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
15689
15831
|
let currentIFrame = win.frameElement;
|
|
15690
15832
|
while (currentIFrame && offsetParent && offsetWin !== win) {
|
|
15691
15833
|
const iframeScale = getScale(currentIFrame);
|
|
15692
15834
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
15693
|
-
const css = getComputedStyle(currentIFrame);
|
|
15694
|
-
iframeRect.
|
|
15695
|
-
iframeRect.
|
|
15835
|
+
const css = getComputedStyle$1(currentIFrame);
|
|
15836
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
15837
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
15696
15838
|
x *= iframeScale.x;
|
|
15697
15839
|
y *= iframeScale.y;
|
|
15698
15840
|
width *= iframeScale.x;
|
|
15699
15841
|
height *= iframeScale.y;
|
|
15700
|
-
x +=
|
|
15701
|
-
y +=
|
|
15702
|
-
currentIFrame = getWindow
|
|
15842
|
+
x += left;
|
|
15843
|
+
y += top;
|
|
15844
|
+
currentIFrame = getWindow(currentIFrame).frameElement;
|
|
15703
15845
|
}
|
|
15704
15846
|
}
|
|
15705
15847
|
return rectToClientRect({
|
|
@@ -15710,30 +15852,13 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
15710
15852
|
});
|
|
15711
15853
|
}
|
|
15712
15854
|
|
|
15713
|
-
function getDocumentElement(node) {
|
|
15714
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
15715
|
-
}
|
|
15716
|
-
|
|
15717
|
-
function getNodeScroll(element) {
|
|
15718
|
-
if (isElement$1(element)) {
|
|
15719
|
-
return {
|
|
15720
|
-
scrollLeft: element.scrollLeft,
|
|
15721
|
-
scrollTop: element.scrollTop
|
|
15722
|
-
};
|
|
15723
|
-
}
|
|
15724
|
-
return {
|
|
15725
|
-
scrollLeft: element.pageXOffset,
|
|
15726
|
-
scrollTop: element.pageYOffset
|
|
15727
|
-
};
|
|
15728
|
-
}
|
|
15729
|
-
|
|
15730
15855
|
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
15731
15856
|
let {
|
|
15732
15857
|
rect,
|
|
15733
15858
|
offsetParent,
|
|
15734
15859
|
strategy
|
|
15735
15860
|
} = _ref;
|
|
15736
|
-
const isOffsetParentAnElement = isHTMLElement
|
|
15861
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
15737
15862
|
const documentElement = getDocumentElement(offsetParent);
|
|
15738
15863
|
if (offsetParent === documentElement) {
|
|
15739
15864
|
return rect;
|
|
@@ -15742,19 +15867,13 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
15742
15867
|
scrollLeft: 0,
|
|
15743
15868
|
scrollTop: 0
|
|
15744
15869
|
};
|
|
15745
|
-
let scale =
|
|
15746
|
-
|
|
15747
|
-
y: 1
|
|
15748
|
-
};
|
|
15749
|
-
const offsets = {
|
|
15750
|
-
x: 0,
|
|
15751
|
-
y: 0
|
|
15752
|
-
};
|
|
15870
|
+
let scale = createCoords(1);
|
|
15871
|
+
const offsets = createCoords(0);
|
|
15753
15872
|
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
15754
15873
|
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
15755
15874
|
scroll = getNodeScroll(offsetParent);
|
|
15756
15875
|
}
|
|
15757
|
-
if (isHTMLElement
|
|
15876
|
+
if (isHTMLElement(offsetParent)) {
|
|
15758
15877
|
const offsetRect = getBoundingClientRect(offsetParent);
|
|
15759
15878
|
scale = getScale(offsetParent);
|
|
15760
15879
|
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
@@ -15769,6 +15888,10 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
15769
15888
|
};
|
|
15770
15889
|
}
|
|
15771
15890
|
|
|
15891
|
+
function getClientRects(element) {
|
|
15892
|
+
return Array.from(element.getClientRects());
|
|
15893
|
+
}
|
|
15894
|
+
|
|
15772
15895
|
function getWindowScrollBarX(element) {
|
|
15773
15896
|
// If <html> has a CSS width greater than the viewport, then this will be
|
|
15774
15897
|
// incorrect for RTL.
|
|
@@ -15796,51 +15919,8 @@ function getDocumentRect(element) {
|
|
|
15796
15919
|
};
|
|
15797
15920
|
}
|
|
15798
15921
|
|
|
15799
|
-
function getParentNode(node) {
|
|
15800
|
-
if (getNodeName(node) === 'html') {
|
|
15801
|
-
return node;
|
|
15802
|
-
}
|
|
15803
|
-
const result =
|
|
15804
|
-
// Step into the shadow DOM of the parent of a slotted node.
|
|
15805
|
-
node.assignedSlot ||
|
|
15806
|
-
// DOM Element detected.
|
|
15807
|
-
node.parentNode ||
|
|
15808
|
-
// ShadowRoot detected.
|
|
15809
|
-
isShadowRoot$1(node) && node.host ||
|
|
15810
|
-
// Fallback.
|
|
15811
|
-
getDocumentElement(node);
|
|
15812
|
-
return isShadowRoot$1(result) ? result.host : result;
|
|
15813
|
-
}
|
|
15814
|
-
|
|
15815
|
-
function getNearestOverflowAncestor(node) {
|
|
15816
|
-
const parentNode = getParentNode(node);
|
|
15817
|
-
if (isLastTraversableNode(parentNode)) {
|
|
15818
|
-
// `getParentNode` will never return a `Document` due to the fallback
|
|
15819
|
-
// check, so it's either the <html> or <body> element.
|
|
15820
|
-
return parentNode.ownerDocument.body;
|
|
15821
|
-
}
|
|
15822
|
-
if (isHTMLElement$1(parentNode) && isOverflowElement(parentNode)) {
|
|
15823
|
-
return parentNode;
|
|
15824
|
-
}
|
|
15825
|
-
return getNearestOverflowAncestor(parentNode);
|
|
15826
|
-
}
|
|
15827
|
-
|
|
15828
|
-
function getOverflowAncestors(node, list) {
|
|
15829
|
-
var _node$ownerDocument;
|
|
15830
|
-
if (list === void 0) {
|
|
15831
|
-
list = [];
|
|
15832
|
-
}
|
|
15833
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
15834
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
15835
|
-
const win = getWindow$1(scrollableAncestor);
|
|
15836
|
-
if (isBody) {
|
|
15837
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
|
|
15838
|
-
}
|
|
15839
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
|
|
15840
|
-
}
|
|
15841
|
-
|
|
15842
15922
|
function getViewportRect(element, strategy) {
|
|
15843
|
-
const win = getWindow
|
|
15923
|
+
const win = getWindow(element);
|
|
15844
15924
|
const html = getDocumentElement(element);
|
|
15845
15925
|
const visualViewport = win.visualViewport;
|
|
15846
15926
|
let width = html.clientWidth;
|
|
@@ -15850,7 +15930,7 @@ function getViewportRect(element, strategy) {
|
|
|
15850
15930
|
if (visualViewport) {
|
|
15851
15931
|
width = visualViewport.width;
|
|
15852
15932
|
height = visualViewport.height;
|
|
15853
|
-
const visualViewportBased =
|
|
15933
|
+
const visualViewportBased = isWebKit();
|
|
15854
15934
|
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
15855
15935
|
x = visualViewport.offsetLeft;
|
|
15856
15936
|
y = visualViewport.offsetTop;
|
|
@@ -15869,10 +15949,7 @@ function getInnerBoundingClientRect(element, strategy) {
|
|
|
15869
15949
|
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
15870
15950
|
const top = clientRect.top + element.clientTop;
|
|
15871
15951
|
const left = clientRect.left + element.clientLeft;
|
|
15872
|
-
const scale = isHTMLElement
|
|
15873
|
-
x: 1,
|
|
15874
|
-
y: 1
|
|
15875
|
-
};
|
|
15952
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
15876
15953
|
const width = element.clientWidth * scale.x;
|
|
15877
15954
|
const height = element.clientHeight * scale.y;
|
|
15878
15955
|
const x = left * scale.x;
|
|
@@ -15890,22 +15967,25 @@ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy)
|
|
|
15890
15967
|
rect = getViewportRect(element, strategy);
|
|
15891
15968
|
} else if (clippingAncestor === 'document') {
|
|
15892
15969
|
rect = getDocumentRect(getDocumentElement(element));
|
|
15893
|
-
} else if (isElement
|
|
15970
|
+
} else if (isElement(clippingAncestor)) {
|
|
15894
15971
|
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
15895
15972
|
} else {
|
|
15896
|
-
const
|
|
15897
|
-
|
|
15973
|
+
const visualOffsets = getVisualOffsets(element);
|
|
15974
|
+
rect = {
|
|
15975
|
+
...clippingAncestor,
|
|
15976
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
15977
|
+
y: clippingAncestor.y - visualOffsets.y
|
|
15898
15978
|
};
|
|
15899
|
-
if (isClientRectVisualViewportBased()) {
|
|
15900
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
15901
|
-
const win = getWindow$1(element);
|
|
15902
|
-
mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0;
|
|
15903
|
-
mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0;
|
|
15904
|
-
}
|
|
15905
|
-
rect = mutableRect;
|
|
15906
15979
|
}
|
|
15907
15980
|
return rectToClientRect(rect);
|
|
15908
15981
|
}
|
|
15982
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
15983
|
+
const parentNode = getParentNode(element);
|
|
15984
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
15985
|
+
return false;
|
|
15986
|
+
}
|
|
15987
|
+
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
15988
|
+
}
|
|
15909
15989
|
|
|
15910
15990
|
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
15911
15991
|
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
@@ -15915,27 +15995,25 @@ function getClippingElementAncestors(element, cache) {
|
|
|
15915
15995
|
if (cachedResult) {
|
|
15916
15996
|
return cachedResult;
|
|
15917
15997
|
}
|
|
15918
|
-
let result = getOverflowAncestors(element).filter(el => isElement
|
|
15998
|
+
let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
15919
15999
|
let currentContainingBlockComputedStyle = null;
|
|
15920
16000
|
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
|
15921
16001
|
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
15922
16002
|
|
|
15923
16003
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
15924
|
-
while (isElement
|
|
16004
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
15925
16005
|
const computedStyle = getComputedStyle$1(currentNode);
|
|
15926
|
-
const
|
|
15927
|
-
|
|
15928
|
-
if (shouldIgnoreCurrentNode) {
|
|
16006
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
16007
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
15929
16008
|
currentContainingBlockComputedStyle = null;
|
|
16009
|
+
}
|
|
16010
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
16011
|
+
if (shouldDropCurrentNode) {
|
|
16012
|
+
// Drop non-containing blocks.
|
|
16013
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
15930
16014
|
} else {
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
// Drop non-containing blocks.
|
|
15934
|
-
result = result.filter(ancestor => ancestor !== currentNode);
|
|
15935
|
-
} else {
|
|
15936
|
-
// Record last containing block for next iteration.
|
|
15937
|
-
currentContainingBlockComputedStyle = computedStyle;
|
|
15938
|
-
}
|
|
16015
|
+
// Record last containing block for next iteration.
|
|
16016
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
15939
16017
|
}
|
|
15940
16018
|
currentNode = getParentNode(currentNode);
|
|
15941
16019
|
}
|
|
@@ -15975,8 +16053,38 @@ function getDimensions(element) {
|
|
|
15975
16053
|
return getCssDimensions(element);
|
|
15976
16054
|
}
|
|
15977
16055
|
|
|
16056
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
16057
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
16058
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
16059
|
+
const isFixed = strategy === 'fixed';
|
|
16060
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
16061
|
+
let scroll = {
|
|
16062
|
+
scrollLeft: 0,
|
|
16063
|
+
scrollTop: 0
|
|
16064
|
+
};
|
|
16065
|
+
const offsets = createCoords(0);
|
|
16066
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
16067
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
16068
|
+
scroll = getNodeScroll(offsetParent);
|
|
16069
|
+
}
|
|
16070
|
+
if (isOffsetParentAnElement) {
|
|
16071
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
16072
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
16073
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
16074
|
+
} else if (documentElement) {
|
|
16075
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
16076
|
+
}
|
|
16077
|
+
}
|
|
16078
|
+
return {
|
|
16079
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
16080
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
16081
|
+
width: rect.width,
|
|
16082
|
+
height: rect.height
|
|
16083
|
+
};
|
|
16084
|
+
}
|
|
16085
|
+
|
|
15978
16086
|
function getTrueOffsetParent(element, polyfill) {
|
|
15979
|
-
if (!isHTMLElement
|
|
16087
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
15980
16088
|
return null;
|
|
15981
16089
|
}
|
|
15982
16090
|
if (polyfill) {
|
|
@@ -15984,23 +16092,12 @@ function getTrueOffsetParent(element, polyfill) {
|
|
|
15984
16092
|
}
|
|
15985
16093
|
return element.offsetParent;
|
|
15986
16094
|
}
|
|
15987
|
-
function getContainingBlock(element) {
|
|
15988
|
-
let currentNode = getParentNode(element);
|
|
15989
|
-
while (isHTMLElement$1(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
15990
|
-
if (isContainingBlock(currentNode)) {
|
|
15991
|
-
return currentNode;
|
|
15992
|
-
} else {
|
|
15993
|
-
currentNode = getParentNode(currentNode);
|
|
15994
|
-
}
|
|
15995
|
-
}
|
|
15996
|
-
return null;
|
|
15997
|
-
}
|
|
15998
16095
|
|
|
15999
16096
|
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
16000
16097
|
// such as table ancestors and cross browser bugs.
|
|
16001
16098
|
function getOffsetParent(element, polyfill) {
|
|
16002
|
-
const window = getWindow
|
|
16003
|
-
if (!isHTMLElement
|
|
16099
|
+
const window = getWindow(element);
|
|
16100
|
+
if (!isHTMLElement(element)) {
|
|
16004
16101
|
return window;
|
|
16005
16102
|
}
|
|
16006
16103
|
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
@@ -16013,67 +16110,115 @@ function getOffsetParent(element, polyfill) {
|
|
|
16013
16110
|
return offsetParent || getContainingBlock(element) || window;
|
|
16014
16111
|
}
|
|
16015
16112
|
|
|
16016
|
-
function
|
|
16017
|
-
|
|
16018
|
-
|
|
16019
|
-
|
|
16020
|
-
|
|
16021
|
-
|
|
16022
|
-
|
|
16023
|
-
|
|
16024
|
-
const offsets = {
|
|
16025
|
-
x: 0,
|
|
16026
|
-
y: 0
|
|
16027
|
-
};
|
|
16028
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
16029
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
16030
|
-
scroll = getNodeScroll(offsetParent);
|
|
16031
|
-
}
|
|
16032
|
-
if (isHTMLElement$1(offsetParent)) {
|
|
16033
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
16034
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
16035
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
16036
|
-
} else if (documentElement) {
|
|
16037
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
16038
|
-
}
|
|
16039
|
-
}
|
|
16113
|
+
const getElementRects = async function (_ref) {
|
|
16114
|
+
let {
|
|
16115
|
+
reference,
|
|
16116
|
+
floating,
|
|
16117
|
+
strategy
|
|
16118
|
+
} = _ref;
|
|
16119
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
16120
|
+
const getDimensionsFn = this.getDimensions;
|
|
16040
16121
|
return {
|
|
16041
|
-
|
|
16042
|
-
|
|
16043
|
-
|
|
16044
|
-
|
|
16122
|
+
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
16123
|
+
floating: {
|
|
16124
|
+
x: 0,
|
|
16125
|
+
y: 0,
|
|
16126
|
+
...(await getDimensionsFn(floating))
|
|
16127
|
+
}
|
|
16045
16128
|
};
|
|
16129
|
+
};
|
|
16130
|
+
|
|
16131
|
+
function isRTL(element) {
|
|
16132
|
+
return getComputedStyle$1(element).direction === 'rtl';
|
|
16046
16133
|
}
|
|
16047
16134
|
|
|
16048
16135
|
const platform = {
|
|
16049
|
-
getClippingRect,
|
|
16050
16136
|
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
16051
|
-
isElement: isElement$1,
|
|
16052
|
-
getDimensions,
|
|
16053
|
-
getOffsetParent,
|
|
16054
16137
|
getDocumentElement,
|
|
16138
|
+
getClippingRect,
|
|
16139
|
+
getOffsetParent,
|
|
16140
|
+
getElementRects,
|
|
16141
|
+
getClientRects,
|
|
16142
|
+
getDimensions,
|
|
16055
16143
|
getScale,
|
|
16056
|
-
|
|
16057
|
-
|
|
16058
|
-
reference,
|
|
16059
|
-
floating,
|
|
16060
|
-
strategy
|
|
16061
|
-
} = _ref;
|
|
16062
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
16063
|
-
const getDimensionsFn = this.getDimensions;
|
|
16064
|
-
return {
|
|
16065
|
-
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
16066
|
-
floating: {
|
|
16067
|
-
x: 0,
|
|
16068
|
-
y: 0,
|
|
16069
|
-
...(await getDimensionsFn(floating))
|
|
16070
|
-
}
|
|
16071
|
-
};
|
|
16072
|
-
},
|
|
16073
|
-
getClientRects: element => Array.from(element.getClientRects()),
|
|
16074
|
-
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
16144
|
+
isElement,
|
|
16145
|
+
isRTL
|
|
16075
16146
|
};
|
|
16076
16147
|
|
|
16148
|
+
// https://samthor.au/2021/observing-dom/
|
|
16149
|
+
function observeMove(element, onMove) {
|
|
16150
|
+
let io = null;
|
|
16151
|
+
let timeoutId;
|
|
16152
|
+
const root = getDocumentElement(element);
|
|
16153
|
+
function cleanup() {
|
|
16154
|
+
clearTimeout(timeoutId);
|
|
16155
|
+
io && io.disconnect();
|
|
16156
|
+
io = null;
|
|
16157
|
+
}
|
|
16158
|
+
function refresh(skip, threshold) {
|
|
16159
|
+
if (skip === void 0) {
|
|
16160
|
+
skip = false;
|
|
16161
|
+
}
|
|
16162
|
+
if (threshold === void 0) {
|
|
16163
|
+
threshold = 1;
|
|
16164
|
+
}
|
|
16165
|
+
cleanup();
|
|
16166
|
+
const {
|
|
16167
|
+
left,
|
|
16168
|
+
top,
|
|
16169
|
+
width,
|
|
16170
|
+
height
|
|
16171
|
+
} = element.getBoundingClientRect();
|
|
16172
|
+
if (!skip) {
|
|
16173
|
+
onMove();
|
|
16174
|
+
}
|
|
16175
|
+
if (!width || !height) {
|
|
16176
|
+
return;
|
|
16177
|
+
}
|
|
16178
|
+
const insetTop = floor(top);
|
|
16179
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
16180
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
16181
|
+
const insetLeft = floor(left);
|
|
16182
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
16183
|
+
const options = {
|
|
16184
|
+
rootMargin,
|
|
16185
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
16186
|
+
};
|
|
16187
|
+
let isFirstUpdate = true;
|
|
16188
|
+
function handleObserve(entries) {
|
|
16189
|
+
const ratio = entries[0].intersectionRatio;
|
|
16190
|
+
if (ratio !== threshold) {
|
|
16191
|
+
if (!isFirstUpdate) {
|
|
16192
|
+
return refresh();
|
|
16193
|
+
}
|
|
16194
|
+
if (!ratio) {
|
|
16195
|
+
timeoutId = setTimeout(() => {
|
|
16196
|
+
refresh(false, 1e-7);
|
|
16197
|
+
}, 100);
|
|
16198
|
+
} else {
|
|
16199
|
+
refresh(false, ratio);
|
|
16200
|
+
}
|
|
16201
|
+
}
|
|
16202
|
+
isFirstUpdate = false;
|
|
16203
|
+
}
|
|
16204
|
+
|
|
16205
|
+
// Older browsers don't support a `document` as the root and will throw an
|
|
16206
|
+
// error.
|
|
16207
|
+
try {
|
|
16208
|
+
io = new IntersectionObserver(handleObserve, {
|
|
16209
|
+
...options,
|
|
16210
|
+
// Handle <iframe>s
|
|
16211
|
+
root: root.ownerDocument
|
|
16212
|
+
});
|
|
16213
|
+
} catch (e) {
|
|
16214
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
16215
|
+
}
|
|
16216
|
+
io.observe(element);
|
|
16217
|
+
}
|
|
16218
|
+
refresh(true);
|
|
16219
|
+
return cleanup;
|
|
16220
|
+
}
|
|
16221
|
+
|
|
16077
16222
|
/**
|
|
16078
16223
|
* Automatically updates the position of the floating element when necessary.
|
|
16079
16224
|
* Should only be called when the floating element is mounted on the DOM or
|
|
@@ -16087,29 +16232,41 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
16087
16232
|
options = {};
|
|
16088
16233
|
}
|
|
16089
16234
|
const {
|
|
16090
|
-
ancestorScroll
|
|
16235
|
+
ancestorScroll = true,
|
|
16091
16236
|
ancestorResize = true,
|
|
16092
|
-
elementResize =
|
|
16237
|
+
elementResize = typeof ResizeObserver === 'function',
|
|
16238
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
|
16093
16239
|
animationFrame = false
|
|
16094
16240
|
} = options;
|
|
16095
|
-
const
|
|
16096
|
-
const ancestors = ancestorScroll || ancestorResize ? [...(
|
|
16241
|
+
const referenceEl = unwrapElement(reference);
|
|
16242
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
|
16097
16243
|
ancestors.forEach(ancestor => {
|
|
16098
16244
|
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
16099
16245
|
passive: true
|
|
16100
16246
|
});
|
|
16101
16247
|
ancestorResize && ancestor.addEventListener('resize', update);
|
|
16102
16248
|
});
|
|
16103
|
-
|
|
16249
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
16250
|
+
let reobserveFrame = -1;
|
|
16251
|
+
let resizeObserver = null;
|
|
16104
16252
|
if (elementResize) {
|
|
16105
|
-
|
|
16253
|
+
resizeObserver = new ResizeObserver(_ref => {
|
|
16254
|
+
let [firstEntry] = _ref;
|
|
16255
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
16256
|
+
// Prevent update loops when using the `size` middleware.
|
|
16257
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
16258
|
+
resizeObserver.unobserve(floating);
|
|
16259
|
+
cancelAnimationFrame(reobserveFrame);
|
|
16260
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
16261
|
+
resizeObserver && resizeObserver.observe(floating);
|
|
16262
|
+
});
|
|
16263
|
+
}
|
|
16106
16264
|
update();
|
|
16107
16265
|
});
|
|
16108
|
-
|
|
16109
|
-
|
|
16110
|
-
observer.observe(reference.contextElement);
|
|
16266
|
+
if (referenceEl && !animationFrame) {
|
|
16267
|
+
resizeObserver.observe(referenceEl);
|
|
16111
16268
|
}
|
|
16112
|
-
|
|
16269
|
+
resizeObserver.observe(floating);
|
|
16113
16270
|
}
|
|
16114
16271
|
let frameId;
|
|
16115
16272
|
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
@@ -16126,13 +16283,13 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
16126
16283
|
}
|
|
16127
16284
|
update();
|
|
16128
16285
|
return () => {
|
|
16129
|
-
var _observer;
|
|
16130
16286
|
ancestors.forEach(ancestor => {
|
|
16131
16287
|
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
16132
16288
|
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
16133
16289
|
});
|
|
16134
|
-
|
|
16135
|
-
|
|
16290
|
+
cleanupIo && cleanupIo();
|
|
16291
|
+
resizeObserver && resizeObserver.disconnect();
|
|
16292
|
+
resizeObserver = null;
|
|
16136
16293
|
if (animationFrame) {
|
|
16137
16294
|
cancelAnimationFrame(frameId);
|
|
16138
16295
|
}
|
|
@@ -16195,7 +16352,7 @@ function deepEqual(a, b) {
|
|
|
16195
16352
|
return false;
|
|
16196
16353
|
}
|
|
16197
16354
|
for (i = length; i-- !== 0;) {
|
|
16198
|
-
if (!
|
|
16355
|
+
if (!{}.hasOwnProperty.call(b, keys[i])) {
|
|
16199
16356
|
return false;
|
|
16200
16357
|
}
|
|
16201
16358
|
}
|
|
@@ -16213,6 +16370,19 @@ function deepEqual(a, b) {
|
|
|
16213
16370
|
return a !== a && b !== b;
|
|
16214
16371
|
}
|
|
16215
16372
|
|
|
16373
|
+
function getDPR(element) {
|
|
16374
|
+
if (typeof window === 'undefined') {
|
|
16375
|
+
return 1;
|
|
16376
|
+
}
|
|
16377
|
+
const win = element.ownerDocument.defaultView || window;
|
|
16378
|
+
return win.devicePixelRatio || 1;
|
|
16379
|
+
}
|
|
16380
|
+
|
|
16381
|
+
function roundByDPR(element, value) {
|
|
16382
|
+
const dpr = getDPR(element);
|
|
16383
|
+
return Math.round(value * dpr) / dpr;
|
|
16384
|
+
}
|
|
16385
|
+
|
|
16216
16386
|
function useLatestRef$1(value) {
|
|
16217
16387
|
const ref = React__namespace.useRef(value);
|
|
16218
16388
|
index$1(() => {
|
|
@@ -16234,12 +16404,17 @@ function useFloating$1(options) {
|
|
|
16234
16404
|
strategy = 'absolute',
|
|
16235
16405
|
middleware = [],
|
|
16236
16406
|
platform,
|
|
16407
|
+
elements: {
|
|
16408
|
+
reference: externalReference,
|
|
16409
|
+
floating: externalFloating
|
|
16410
|
+
} = {},
|
|
16411
|
+
transform = true,
|
|
16237
16412
|
whileElementsMounted,
|
|
16238
16413
|
open
|
|
16239
16414
|
} = options;
|
|
16240
16415
|
const [data, setData] = React__namespace.useState({
|
|
16241
|
-
x:
|
|
16242
|
-
y:
|
|
16416
|
+
x: 0,
|
|
16417
|
+
y: 0,
|
|
16243
16418
|
strategy,
|
|
16244
16419
|
placement,
|
|
16245
16420
|
middlewareData: {},
|
|
@@ -16249,25 +16424,27 @@ function useFloating$1(options) {
|
|
|
16249
16424
|
if (!deepEqual(latestMiddleware, middleware)) {
|
|
16250
16425
|
setLatestMiddleware(middleware);
|
|
16251
16426
|
}
|
|
16252
|
-
const
|
|
16253
|
-
const
|
|
16254
|
-
const dataRef = React__namespace.useRef(data);
|
|
16255
|
-
const whileElementsMountedRef = useLatestRef$1(whileElementsMounted);
|
|
16256
|
-
const platformRef = useLatestRef$1(platform);
|
|
16257
|
-
const [reference, _setReference] = React__namespace.useState(null);
|
|
16258
|
-
const [floating, _setFloating] = React__namespace.useState(null);
|
|
16427
|
+
const [_reference, _setReference] = React__namespace.useState(null);
|
|
16428
|
+
const [_floating, _setFloating] = React__namespace.useState(null);
|
|
16259
16429
|
const setReference = React__namespace.useCallback(node => {
|
|
16260
|
-
if (referenceRef.current
|
|
16430
|
+
if (node != referenceRef.current) {
|
|
16261
16431
|
referenceRef.current = node;
|
|
16262
16432
|
_setReference(node);
|
|
16263
16433
|
}
|
|
16264
|
-
}, []);
|
|
16434
|
+
}, [_setReference]);
|
|
16265
16435
|
const setFloating = React__namespace.useCallback(node => {
|
|
16266
|
-
if (floatingRef.current
|
|
16436
|
+
if (node !== floatingRef.current) {
|
|
16267
16437
|
floatingRef.current = node;
|
|
16268
16438
|
_setFloating(node);
|
|
16269
16439
|
}
|
|
16270
|
-
}, []);
|
|
16440
|
+
}, [_setFloating]);
|
|
16441
|
+
const referenceEl = externalReference || _reference;
|
|
16442
|
+
const floatingEl = externalFloating || _floating;
|
|
16443
|
+
const referenceRef = React__namespace.useRef(null);
|
|
16444
|
+
const floatingRef = React__namespace.useRef(null);
|
|
16445
|
+
const dataRef = React__namespace.useRef(data);
|
|
16446
|
+
const whileElementsMountedRef = useLatestRef$1(whileElementsMounted);
|
|
16447
|
+
const platformRef = useLatestRef$1(platform);
|
|
16271
16448
|
const update = React__namespace.useCallback(() => {
|
|
16272
16449
|
if (!referenceRef.current || !floatingRef.current) {
|
|
16273
16450
|
return;
|
|
@@ -16310,14 +16487,16 @@ function useFloating$1(options) {
|
|
|
16310
16487
|
};
|
|
16311
16488
|
}, []);
|
|
16312
16489
|
index$1(() => {
|
|
16313
|
-
if (
|
|
16490
|
+
if (referenceEl) referenceRef.current = referenceEl;
|
|
16491
|
+
if (floatingEl) floatingRef.current = floatingEl;
|
|
16492
|
+
if (referenceEl && floatingEl) {
|
|
16314
16493
|
if (whileElementsMountedRef.current) {
|
|
16315
|
-
return whileElementsMountedRef.current(
|
|
16494
|
+
return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
16316
16495
|
} else {
|
|
16317
16496
|
update();
|
|
16318
16497
|
}
|
|
16319
16498
|
}
|
|
16320
|
-
}, [
|
|
16499
|
+
}, [referenceEl, floatingEl, update, whileElementsMountedRef]);
|
|
16321
16500
|
const refs = React__namespace.useMemo(() => ({
|
|
16322
16501
|
reference: referenceRef,
|
|
16323
16502
|
floating: floatingRef,
|
|
@@ -16325,147 +16504,44 @@ function useFloating$1(options) {
|
|
|
16325
16504
|
setFloating
|
|
16326
16505
|
}), [setReference, setFloating]);
|
|
16327
16506
|
const elements = React__namespace.useMemo(() => ({
|
|
16328
|
-
reference,
|
|
16329
|
-
floating
|
|
16330
|
-
}), [
|
|
16507
|
+
reference: referenceEl,
|
|
16508
|
+
floating: floatingEl
|
|
16509
|
+
}), [referenceEl, floatingEl]);
|
|
16510
|
+
const floatingStyles = React__namespace.useMemo(() => {
|
|
16511
|
+
const initialStyles = {
|
|
16512
|
+
position: strategy,
|
|
16513
|
+
left: 0,
|
|
16514
|
+
top: 0
|
|
16515
|
+
};
|
|
16516
|
+
if (!elements.floating) {
|
|
16517
|
+
return initialStyles;
|
|
16518
|
+
}
|
|
16519
|
+
const x = roundByDPR(elements.floating, data.x);
|
|
16520
|
+
const y = roundByDPR(elements.floating, data.y);
|
|
16521
|
+
if (transform) {
|
|
16522
|
+
return {
|
|
16523
|
+
...initialStyles,
|
|
16524
|
+
transform: "translate(" + x + "px, " + y + "px)",
|
|
16525
|
+
...(getDPR(elements.floating) >= 1.5 && {
|
|
16526
|
+
willChange: 'transform'
|
|
16527
|
+
})
|
|
16528
|
+
};
|
|
16529
|
+
}
|
|
16530
|
+
return {
|
|
16531
|
+
position: strategy,
|
|
16532
|
+
left: x,
|
|
16533
|
+
top: y
|
|
16534
|
+
};
|
|
16535
|
+
}, [strategy, transform, elements.floating, data.x, data.y]);
|
|
16331
16536
|
return React__namespace.useMemo(() => ({
|
|
16332
16537
|
...data,
|
|
16333
16538
|
update,
|
|
16334
16539
|
refs,
|
|
16335
16540
|
elements,
|
|
16336
|
-
|
|
16337
|
-
|
|
16338
|
-
}), [data, update, refs, elements, setReference, setFloating]);
|
|
16541
|
+
floatingStyles
|
|
16542
|
+
}), [data, update, refs, elements, floatingStyles]);
|
|
16339
16543
|
}
|
|
16340
16544
|
|
|
16341
|
-
var getDefaultParent = function (originalTarget) {
|
|
16342
|
-
if (typeof document === 'undefined') {
|
|
16343
|
-
return null;
|
|
16344
|
-
}
|
|
16345
|
-
var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
|
|
16346
|
-
return sampleTarget.ownerDocument.body;
|
|
16347
|
-
};
|
|
16348
|
-
var counterMap = new WeakMap();
|
|
16349
|
-
var uncontrolledNodes = new WeakMap();
|
|
16350
|
-
var markerMap = {};
|
|
16351
|
-
var lockCount = 0;
|
|
16352
|
-
var unwrapHost = function (node) {
|
|
16353
|
-
return node && (node.host || unwrapHost(node.parentNode));
|
|
16354
|
-
};
|
|
16355
|
-
var correctTargets = function (parent, targets) {
|
|
16356
|
-
return targets.map(function (target) {
|
|
16357
|
-
if (parent.contains(target)) {
|
|
16358
|
-
return target;
|
|
16359
|
-
}
|
|
16360
|
-
var correctedTarget = unwrapHost(target);
|
|
16361
|
-
if (correctedTarget && parent.contains(correctedTarget)) {
|
|
16362
|
-
return correctedTarget;
|
|
16363
|
-
}
|
|
16364
|
-
console.error('aria-hidden', target, 'in not contained inside', parent, '. Doing nothing');
|
|
16365
|
-
return null;
|
|
16366
|
-
}).filter(function (x) { return Boolean(x); });
|
|
16367
|
-
};
|
|
16368
|
-
/**
|
|
16369
|
-
* Marks everything except given node(or nodes) as aria-hidden
|
|
16370
|
-
* @param {Element | Element[]} originalTarget - elements to keep on the page
|
|
16371
|
-
* @param [parentNode] - top element, defaults to document.body
|
|
16372
|
-
* @param {String} [markerName] - a special attribute to mark every node
|
|
16373
|
-
* @param {String} [controlAttribute] - html Attribute to control
|
|
16374
|
-
* @return {Undo} undo command
|
|
16375
|
-
*/
|
|
16376
|
-
var applyAttributeToOthers = function (originalTarget, parentNode, markerName, controlAttribute) {
|
|
16377
|
-
var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
16378
|
-
if (!markerMap[markerName]) {
|
|
16379
|
-
markerMap[markerName] = new WeakMap();
|
|
16380
|
-
}
|
|
16381
|
-
var markerCounter = markerMap[markerName];
|
|
16382
|
-
var hiddenNodes = [];
|
|
16383
|
-
var elementsToKeep = new Set();
|
|
16384
|
-
var elementsToStop = new Set(targets);
|
|
16385
|
-
var keep = function (el) {
|
|
16386
|
-
if (!el || elementsToKeep.has(el)) {
|
|
16387
|
-
return;
|
|
16388
|
-
}
|
|
16389
|
-
elementsToKeep.add(el);
|
|
16390
|
-
keep(el.parentNode);
|
|
16391
|
-
};
|
|
16392
|
-
targets.forEach(keep);
|
|
16393
|
-
var deep = function (parent) {
|
|
16394
|
-
if (!parent || elementsToStop.has(parent)) {
|
|
16395
|
-
return;
|
|
16396
|
-
}
|
|
16397
|
-
Array.prototype.forEach.call(parent.children, function (node) {
|
|
16398
|
-
if (elementsToKeep.has(node)) {
|
|
16399
|
-
deep(node);
|
|
16400
|
-
}
|
|
16401
|
-
else {
|
|
16402
|
-
var attr = node.getAttribute(controlAttribute);
|
|
16403
|
-
var alreadyHidden = attr !== null && attr !== 'false';
|
|
16404
|
-
var counterValue = (counterMap.get(node) || 0) + 1;
|
|
16405
|
-
var markerValue = (markerCounter.get(node) || 0) + 1;
|
|
16406
|
-
counterMap.set(node, counterValue);
|
|
16407
|
-
markerCounter.set(node, markerValue);
|
|
16408
|
-
hiddenNodes.push(node);
|
|
16409
|
-
if (counterValue === 1 && alreadyHidden) {
|
|
16410
|
-
uncontrolledNodes.set(node, true);
|
|
16411
|
-
}
|
|
16412
|
-
if (markerValue === 1) {
|
|
16413
|
-
node.setAttribute(markerName, 'true');
|
|
16414
|
-
}
|
|
16415
|
-
if (!alreadyHidden) {
|
|
16416
|
-
node.setAttribute(controlAttribute, 'true');
|
|
16417
|
-
}
|
|
16418
|
-
}
|
|
16419
|
-
});
|
|
16420
|
-
};
|
|
16421
|
-
deep(parentNode);
|
|
16422
|
-
elementsToKeep.clear();
|
|
16423
|
-
lockCount++;
|
|
16424
|
-
return function () {
|
|
16425
|
-
hiddenNodes.forEach(function (node) {
|
|
16426
|
-
var counterValue = counterMap.get(node) - 1;
|
|
16427
|
-
var markerValue = markerCounter.get(node) - 1;
|
|
16428
|
-
counterMap.set(node, counterValue);
|
|
16429
|
-
markerCounter.set(node, markerValue);
|
|
16430
|
-
if (!counterValue) {
|
|
16431
|
-
if (!uncontrolledNodes.has(node)) {
|
|
16432
|
-
node.removeAttribute(controlAttribute);
|
|
16433
|
-
}
|
|
16434
|
-
uncontrolledNodes.delete(node);
|
|
16435
|
-
}
|
|
16436
|
-
if (!markerValue) {
|
|
16437
|
-
node.removeAttribute(markerName);
|
|
16438
|
-
}
|
|
16439
|
-
});
|
|
16440
|
-
lockCount--;
|
|
16441
|
-
if (!lockCount) {
|
|
16442
|
-
// clear
|
|
16443
|
-
counterMap = new WeakMap();
|
|
16444
|
-
counterMap = new WeakMap();
|
|
16445
|
-
uncontrolledNodes = new WeakMap();
|
|
16446
|
-
markerMap = {};
|
|
16447
|
-
}
|
|
16448
|
-
};
|
|
16449
|
-
};
|
|
16450
|
-
/**
|
|
16451
|
-
* Marks everything except given node(or nodes) as aria-hidden
|
|
16452
|
-
* @param {Element | Element[]} originalTarget - elements to keep on the page
|
|
16453
|
-
* @param [parentNode] - top element, defaults to document.body
|
|
16454
|
-
* @param {String} [markerName] - a special attribute to mark every node
|
|
16455
|
-
* @return {Undo} undo command
|
|
16456
|
-
*/
|
|
16457
|
-
var hideOthers = function (originalTarget, parentNode, markerName) {
|
|
16458
|
-
if (markerName === void 0) { markerName = 'data-aria-hidden'; }
|
|
16459
|
-
var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
16460
|
-
var activeParentNode = parentNode || getDefaultParent(originalTarget);
|
|
16461
|
-
if (!activeParentNode) {
|
|
16462
|
-
return function () { return null; };
|
|
16463
|
-
}
|
|
16464
|
-
// we should not hide ariaLive elements - https://github.com/theKashey/aria-hidden/issues/10
|
|
16465
|
-
targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll('[aria-live]')));
|
|
16466
|
-
return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
|
|
16467
|
-
};
|
|
16468
|
-
|
|
16469
16545
|
/*!
|
|
16470
16546
|
* tabbable 6.0.1
|
|
16471
16547
|
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
@@ -16888,8 +16964,53 @@ var tabbable = function tabbable(el, options) {
|
|
|
16888
16964
|
return sortByOrder(candidates);
|
|
16889
16965
|
};
|
|
16890
16966
|
|
|
16967
|
+
/**
|
|
16968
|
+
* Merges an array of refs into a single memoized callback ref or `null`.
|
|
16969
|
+
* @see https://floating-ui.com/docs/useMergeRefs
|
|
16970
|
+
*/
|
|
16971
|
+
function useMergeRefs(refs) {
|
|
16972
|
+
return React__namespace.useMemo(() => {
|
|
16973
|
+
if (refs.every(ref => ref == null)) {
|
|
16974
|
+
return null;
|
|
16975
|
+
}
|
|
16976
|
+
return value => {
|
|
16977
|
+
refs.forEach(ref => {
|
|
16978
|
+
if (typeof ref === 'function') {
|
|
16979
|
+
ref(value);
|
|
16980
|
+
} else if (ref != null) {
|
|
16981
|
+
ref.current = value;
|
|
16982
|
+
}
|
|
16983
|
+
});
|
|
16984
|
+
};
|
|
16985
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
16986
|
+
}, refs);
|
|
16987
|
+
}
|
|
16988
|
+
|
|
16989
|
+
let rafId = 0;
|
|
16990
|
+
function enqueueFocus(el, options) {
|
|
16991
|
+
if (options === void 0) {
|
|
16992
|
+
options = {};
|
|
16993
|
+
}
|
|
16994
|
+
const {
|
|
16995
|
+
preventScroll = false,
|
|
16996
|
+
cancelPrevious = true,
|
|
16997
|
+
sync = false
|
|
16998
|
+
} = options;
|
|
16999
|
+
cancelPrevious && cancelAnimationFrame(rafId);
|
|
17000
|
+
const exec = () => el == null ? void 0 : el.focus({
|
|
17001
|
+
preventScroll
|
|
17002
|
+
});
|
|
17003
|
+
if (sync) {
|
|
17004
|
+
exec();
|
|
17005
|
+
} else {
|
|
17006
|
+
rafId = requestAnimationFrame(exec);
|
|
17007
|
+
}
|
|
17008
|
+
}
|
|
17009
|
+
|
|
17010
|
+
var index = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
17011
|
+
|
|
16891
17012
|
function _extends() {
|
|
16892
|
-
_extends = Object.assign
|
|
17013
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
16893
17014
|
for (var i = 1; i < arguments.length; i++) {
|
|
16894
17015
|
var source = arguments[i];
|
|
16895
17016
|
for (var key in source) {
|
|
@@ -16903,8 +17024,6 @@ function _extends() {
|
|
|
16903
17024
|
return _extends.apply(this, arguments);
|
|
16904
17025
|
}
|
|
16905
17026
|
|
|
16906
|
-
var index = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
16907
|
-
|
|
16908
17027
|
let serverHandoffComplete = false;
|
|
16909
17028
|
let count = 0;
|
|
16910
17029
|
const genId = () => "floating-ui-" + count++;
|
|
@@ -16960,105 +17079,8 @@ const useFloatingParentNodeId = () => {
|
|
|
16960
17079
|
};
|
|
16961
17080
|
const useFloatingTree = () => React__namespace.useContext(FloatingTreeContext);
|
|
16962
17081
|
|
|
16963
|
-
function
|
|
16964
|
-
return
|
|
16965
|
-
}
|
|
16966
|
-
|
|
16967
|
-
// Avoid Chrome DevTools blue warning.
|
|
16968
|
-
function getPlatform() {
|
|
16969
|
-
const uaData = navigator.userAgentData;
|
|
16970
|
-
if (uaData != null && uaData.platform) {
|
|
16971
|
-
return uaData.platform;
|
|
16972
|
-
}
|
|
16973
|
-
return navigator.platform;
|
|
16974
|
-
}
|
|
16975
|
-
function getUserAgent() {
|
|
16976
|
-
const uaData = navigator.userAgentData;
|
|
16977
|
-
if (uaData && Array.isArray(uaData.brands)) {
|
|
16978
|
-
return uaData.brands.map(_ref => {
|
|
16979
|
-
let {
|
|
16980
|
-
brand,
|
|
16981
|
-
version
|
|
16982
|
-
} = _ref;
|
|
16983
|
-
return brand + "/" + version;
|
|
16984
|
-
}).join(' ');
|
|
16985
|
-
}
|
|
16986
|
-
return navigator.userAgent;
|
|
16987
|
-
}
|
|
16988
|
-
|
|
16989
|
-
function getWindow(value) {
|
|
16990
|
-
return getDocument(value).defaultView || window;
|
|
16991
|
-
}
|
|
16992
|
-
function isElement(value) {
|
|
16993
|
-
return value ? value instanceof getWindow(value).Element : false;
|
|
16994
|
-
}
|
|
16995
|
-
function isHTMLElement(value) {
|
|
16996
|
-
return value ? value instanceof getWindow(value).HTMLElement : false;
|
|
16997
|
-
}
|
|
16998
|
-
function isShadowRoot(node) {
|
|
16999
|
-
// Browsers without `ShadowRoot` support
|
|
17000
|
-
if (typeof ShadowRoot === 'undefined') {
|
|
17001
|
-
return false;
|
|
17002
|
-
}
|
|
17003
|
-
const OwnElement = getWindow(node).ShadowRoot;
|
|
17004
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
17005
|
-
}
|
|
17006
|
-
|
|
17007
|
-
// License: https://github.com/adobe/react-spectrum/blob/b35d5c02fe900badccd0cf1a8f23bb593419f238/packages/@react-aria/utils/src/isVirtualEvent.ts
|
|
17008
|
-
function isVirtualClick(event) {
|
|
17009
|
-
if (event.mozInputSource === 0 && event.isTrusted) {
|
|
17010
|
-
return true;
|
|
17011
|
-
}
|
|
17012
|
-
const androidRe = /Android/i;
|
|
17013
|
-
if ((androidRe.test(getPlatform()) || androidRe.test(getUserAgent())) && event.pointerType) {
|
|
17014
|
-
return event.type === 'click' && event.buttons === 1;
|
|
17015
|
-
}
|
|
17016
|
-
return event.detail === 0 && !event.pointerType;
|
|
17017
|
-
}
|
|
17018
|
-
function isVirtualPointerEvent(event) {
|
|
17019
|
-
return event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType !== 'mouse' ||
|
|
17020
|
-
// iOS VoiceOver returns 0.333• for width/height.
|
|
17021
|
-
event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0;
|
|
17022
|
-
}
|
|
17023
|
-
function isSafari() {
|
|
17024
|
-
// Chrome DevTools does not complain about navigator.vendor
|
|
17025
|
-
return /apple/i.test(navigator.vendor);
|
|
17026
|
-
}
|
|
17027
|
-
function isMouseLikePointerType(pointerType, strict) {
|
|
17028
|
-
// On some Linux machines with Chromium, mouse inputs return a `pointerType`
|
|
17029
|
-
// of "pen": https://github.com/floating-ui/floating-ui/issues/2015
|
|
17030
|
-
const values = ['mouse', 'pen'];
|
|
17031
|
-
if (!strict) {
|
|
17032
|
-
values.push('', undefined);
|
|
17033
|
-
}
|
|
17034
|
-
return values.includes(pointerType);
|
|
17035
|
-
}
|
|
17036
|
-
|
|
17037
|
-
function contains(parent, child) {
|
|
17038
|
-
if (!parent || !child) {
|
|
17039
|
-
return false;
|
|
17040
|
-
}
|
|
17041
|
-
const rootNode = child.getRootNode && child.getRootNode();
|
|
17042
|
-
|
|
17043
|
-
// First, attempt with faster native method
|
|
17044
|
-
if (parent.contains(child)) {
|
|
17045
|
-
return true;
|
|
17046
|
-
}
|
|
17047
|
-
|
|
17048
|
-
// then fallback to custom implementation with Shadow DOM support
|
|
17049
|
-
if (rootNode && isShadowRoot(rootNode)) {
|
|
17050
|
-
let next = child;
|
|
17051
|
-
while (next) {
|
|
17052
|
-
if (parent === next) {
|
|
17053
|
-
return true;
|
|
17054
|
-
}
|
|
17055
|
-
// @ts-ignore
|
|
17056
|
-
next = next.parentNode || next.host;
|
|
17057
|
-
}
|
|
17058
|
-
}
|
|
17059
|
-
|
|
17060
|
-
// Give up, the result is false
|
|
17061
|
-
return false;
|
|
17082
|
+
function createAttribute(name) {
|
|
17083
|
+
return "data-floating-ui-" + name;
|
|
17062
17084
|
}
|
|
17063
17085
|
|
|
17064
17086
|
function useLatestRef(value) {
|
|
@@ -17069,7 +17091,7 @@ function useLatestRef(value) {
|
|
|
17069
17091
|
return ref;
|
|
17070
17092
|
}
|
|
17071
17093
|
|
|
17072
|
-
const safePolygonIdentifier = '
|
|
17094
|
+
const safePolygonIdentifier = /*#__PURE__*/createAttribute('safe-polygon');
|
|
17073
17095
|
function getDelay(value, prop, pointerType) {
|
|
17074
17096
|
if (pointerType && !isMouseLikePointerType(pointerType)) {
|
|
17075
17097
|
return 0;
|
|
@@ -17084,7 +17106,7 @@ function getDelay(value, prop, pointerType) {
|
|
|
17084
17106
|
* CSS `:hover`.
|
|
17085
17107
|
* @see https://floating-ui.com/docs/useHover
|
|
17086
17108
|
*/
|
|
17087
|
-
|
|
17109
|
+
function useHover$1(context, props) {
|
|
17088
17110
|
if (props === void 0) {
|
|
17089
17111
|
props = {};
|
|
17090
17112
|
}
|
|
@@ -17144,9 +17166,9 @@ const useHover$1 = function (context, props) {
|
|
|
17144
17166
|
if (!enabled || !handleCloseRef.current || !open) {
|
|
17145
17167
|
return;
|
|
17146
17168
|
}
|
|
17147
|
-
function onLeave() {
|
|
17169
|
+
function onLeave(event) {
|
|
17148
17170
|
if (isHoverOpen()) {
|
|
17149
|
-
onOpenChange(false);
|
|
17171
|
+
onOpenChange(false, event);
|
|
17150
17172
|
}
|
|
17151
17173
|
}
|
|
17152
17174
|
const html = getDocument(floating).documentElement;
|
|
@@ -17155,17 +17177,17 @@ const useHover$1 = function (context, props) {
|
|
|
17155
17177
|
html.removeEventListener('mouseleave', onLeave);
|
|
17156
17178
|
};
|
|
17157
17179
|
}, [floating, open, onOpenChange, enabled, handleCloseRef, dataRef, isHoverOpen]);
|
|
17158
|
-
const closeWithDelay = React__namespace.useCallback(function (runElseBranch) {
|
|
17180
|
+
const closeWithDelay = React__namespace.useCallback(function (event, runElseBranch) {
|
|
17159
17181
|
if (runElseBranch === void 0) {
|
|
17160
17182
|
runElseBranch = true;
|
|
17161
17183
|
}
|
|
17162
17184
|
const closeDelay = getDelay(delayRef.current, 'close', pointerTypeRef.current);
|
|
17163
17185
|
if (closeDelay && !handlerRef.current) {
|
|
17164
17186
|
clearTimeout(timeoutRef.current);
|
|
17165
|
-
timeoutRef.current = setTimeout(() => onOpenChange(false), closeDelay);
|
|
17187
|
+
timeoutRef.current = setTimeout(() => onOpenChange(false, event), closeDelay);
|
|
17166
17188
|
} else if (runElseBranch) {
|
|
17167
17189
|
clearTimeout(timeoutRef.current);
|
|
17168
|
-
onOpenChange(false);
|
|
17190
|
+
onOpenChange(false, event);
|
|
17169
17191
|
}
|
|
17170
17192
|
}, [delayRef, onOpenChange]);
|
|
17171
17193
|
const cleanupMouseMoveHandler = React__namespace.useCallback(() => {
|
|
@@ -17197,14 +17219,13 @@ const useHover$1 = function (context, props) {
|
|
|
17197
17219
|
if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current) || restMs > 0 && getDelay(delayRef.current, 'open') === 0) {
|
|
17198
17220
|
return;
|
|
17199
17221
|
}
|
|
17200
|
-
dataRef.current.openEvent = event;
|
|
17201
17222
|
const openDelay = getDelay(delayRef.current, 'open', pointerTypeRef.current);
|
|
17202
17223
|
if (openDelay) {
|
|
17203
17224
|
timeoutRef.current = setTimeout(() => {
|
|
17204
|
-
onOpenChange(true);
|
|
17225
|
+
onOpenChange(true, event);
|
|
17205
17226
|
}, openDelay);
|
|
17206
17227
|
} else {
|
|
17207
|
-
onOpenChange(true);
|
|
17228
|
+
onOpenChange(true, event);
|
|
17208
17229
|
}
|
|
17209
17230
|
}
|
|
17210
17231
|
function onMouseLeave(event) {
|
|
@@ -17227,7 +17248,8 @@ const useHover$1 = function (context, props) {
|
|
|
17227
17248
|
onClose() {
|
|
17228
17249
|
clearPointerEvents();
|
|
17229
17250
|
cleanupMouseMoveHandler();
|
|
17230
|
-
|
|
17251
|
+
// Should the event expose that it was closed by `safePolygon`?
|
|
17252
|
+
closeWithDelay(event);
|
|
17231
17253
|
}
|
|
17232
17254
|
});
|
|
17233
17255
|
const handler = handlerRef.current;
|
|
@@ -17243,7 +17265,7 @@ const useHover$1 = function (context, props) {
|
|
|
17243
17265
|
// consistently.
|
|
17244
17266
|
const shouldClose = pointerTypeRef.current === 'touch' ? !contains(floating, event.relatedTarget) : true;
|
|
17245
17267
|
if (shouldClose) {
|
|
17246
|
-
closeWithDelay();
|
|
17268
|
+
closeWithDelay(event);
|
|
17247
17269
|
}
|
|
17248
17270
|
}
|
|
17249
17271
|
|
|
@@ -17262,7 +17284,7 @@ const useHover$1 = function (context, props) {
|
|
|
17262
17284
|
onClose() {
|
|
17263
17285
|
clearPointerEvents();
|
|
17264
17286
|
cleanupMouseMoveHandler();
|
|
17265
|
-
closeWithDelay();
|
|
17287
|
+
closeWithDelay(event);
|
|
17266
17288
|
}
|
|
17267
17289
|
})(event);
|
|
17268
17290
|
}
|
|
@@ -17329,7 +17351,7 @@ const useHover$1 = function (context, props) {
|
|
|
17329
17351
|
clearTimeout(restTimeoutRef.current);
|
|
17330
17352
|
clearPointerEvents();
|
|
17331
17353
|
};
|
|
17332
|
-
}, [enabled, cleanupMouseMoveHandler, clearPointerEvents]);
|
|
17354
|
+
}, [enabled, domReference, cleanupMouseMoveHandler, clearPointerEvents]);
|
|
17333
17355
|
return React__namespace.useMemo(() => {
|
|
17334
17356
|
if (!enabled) {
|
|
17335
17357
|
return {};
|
|
@@ -17341,14 +17363,14 @@ const useHover$1 = function (context, props) {
|
|
|
17341
17363
|
reference: {
|
|
17342
17364
|
onPointerDown: setPointerRef,
|
|
17343
17365
|
onPointerEnter: setPointerRef,
|
|
17344
|
-
onMouseMove() {
|
|
17366
|
+
onMouseMove(event) {
|
|
17345
17367
|
if (open || restMs === 0) {
|
|
17346
17368
|
return;
|
|
17347
17369
|
}
|
|
17348
17370
|
clearTimeout(restTimeoutRef.current);
|
|
17349
17371
|
restTimeoutRef.current = setTimeout(() => {
|
|
17350
17372
|
if (!blockMouseMoveRef.current) {
|
|
17351
|
-
onOpenChange(true);
|
|
17373
|
+
onOpenChange(true, event.nativeEvent);
|
|
17352
17374
|
}
|
|
17353
17375
|
}, restMs);
|
|
17354
17376
|
}
|
|
@@ -17357,51 +17379,18 @@ const useHover$1 = function (context, props) {
|
|
|
17357
17379
|
onMouseEnter() {
|
|
17358
17380
|
clearTimeout(timeoutRef.current);
|
|
17359
17381
|
},
|
|
17360
|
-
onMouseLeave() {
|
|
17382
|
+
onMouseLeave(event) {
|
|
17361
17383
|
events.emit('dismiss', {
|
|
17362
17384
|
type: 'mouseLeave',
|
|
17363
17385
|
data: {
|
|
17364
17386
|
returnFocus: false
|
|
17365
17387
|
}
|
|
17366
17388
|
});
|
|
17367
|
-
closeWithDelay(false);
|
|
17389
|
+
closeWithDelay(event.nativeEvent, false);
|
|
17368
17390
|
}
|
|
17369
17391
|
}
|
|
17370
17392
|
};
|
|
17371
17393
|
}, [events, enabled, restMs, open, onOpenChange, closeWithDelay]);
|
|
17372
|
-
};
|
|
17373
|
-
|
|
17374
|
-
/**
|
|
17375
|
-
* Find the real active element. Traverses into shadowRoots.
|
|
17376
|
-
*/
|
|
17377
|
-
function activeElement(doc) {
|
|
17378
|
-
let activeElement = doc.activeElement;
|
|
17379
|
-
while (((_activeElement = activeElement) == null ? void 0 : (_activeElement$shadow = _activeElement.shadowRoot) == null ? void 0 : _activeElement$shadow.activeElement) != null) {
|
|
17380
|
-
var _activeElement, _activeElement$shadow;
|
|
17381
|
-
activeElement = activeElement.shadowRoot.activeElement;
|
|
17382
|
-
}
|
|
17383
|
-
return activeElement;
|
|
17384
|
-
}
|
|
17385
|
-
|
|
17386
|
-
let rafId = 0;
|
|
17387
|
-
function enqueueFocus(el, options) {
|
|
17388
|
-
if (options === void 0) {
|
|
17389
|
-
options = {};
|
|
17390
|
-
}
|
|
17391
|
-
const {
|
|
17392
|
-
preventScroll = false,
|
|
17393
|
-
cancelPrevious = true,
|
|
17394
|
-
sync = false
|
|
17395
|
-
} = options;
|
|
17396
|
-
cancelPrevious && cancelAnimationFrame(rafId);
|
|
17397
|
-
const exec = () => el == null ? void 0 : el.focus({
|
|
17398
|
-
preventScroll
|
|
17399
|
-
});
|
|
17400
|
-
if (sync) {
|
|
17401
|
-
exec();
|
|
17402
|
-
} else {
|
|
17403
|
-
rafId = requestAnimationFrame(exec);
|
|
17404
|
-
}
|
|
17405
17394
|
}
|
|
17406
17395
|
|
|
17407
17396
|
function getAncestors(nodes, id) {
|
|
@@ -17437,24 +17426,107 @@ function getChildren(nodes, id) {
|
|
|
17437
17426
|
return allChildren;
|
|
17438
17427
|
}
|
|
17439
17428
|
|
|
17440
|
-
|
|
17441
|
-
|
|
17442
|
-
|
|
17429
|
+
// Modified to add conditional `aria-hidden` support:
|
|
17430
|
+
// https://github.com/theKashey/aria-hidden/blob/9220c8f4a4fd35f63bee5510a9f41a37264382d4/src/index.ts
|
|
17431
|
+
let counterMap = /*#__PURE__*/new WeakMap();
|
|
17432
|
+
let uncontrolledElementsSet = /*#__PURE__*/new WeakSet();
|
|
17433
|
+
let markerMap = {};
|
|
17434
|
+
let lockCount = 0;
|
|
17435
|
+
const supportsInert = () => typeof HTMLElement !== 'undefined' && 'inert' in HTMLElement.prototype;
|
|
17436
|
+
const unwrapHost = node => node && (node.host || unwrapHost(node.parentNode));
|
|
17437
|
+
const correctElements = (parent, targets) => targets.map(target => {
|
|
17438
|
+
if (parent.contains(target)) {
|
|
17439
|
+
return target;
|
|
17443
17440
|
}
|
|
17444
|
-
|
|
17445
|
-
|
|
17446
|
-
|
|
17447
|
-
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
|
|
17441
|
+
const correctedTarget = unwrapHost(target);
|
|
17442
|
+
if (parent.contains(correctedTarget)) {
|
|
17443
|
+
return correctedTarget;
|
|
17444
|
+
}
|
|
17445
|
+
return null;
|
|
17446
|
+
}).filter(x => x != null);
|
|
17447
|
+
function applyAttributeToOthers(uncorrectedAvoidElements, body, ariaHidden, inert) {
|
|
17448
|
+
const markerName = 'data-floating-ui-inert';
|
|
17449
|
+
const controlAttribute = inert ? 'inert' : ariaHidden ? 'aria-hidden' : null;
|
|
17450
|
+
const avoidElements = correctElements(body, uncorrectedAvoidElements);
|
|
17451
|
+
const elementsToKeep = new Set();
|
|
17452
|
+
const elementsToStop = new Set(avoidElements);
|
|
17453
|
+
const hiddenElements = [];
|
|
17454
|
+
if (!markerMap[markerName]) {
|
|
17455
|
+
markerMap[markerName] = new WeakMap();
|
|
17456
|
+
}
|
|
17457
|
+
const markerCounter = markerMap[markerName];
|
|
17458
|
+
avoidElements.forEach(keep);
|
|
17459
|
+
deep(body);
|
|
17460
|
+
elementsToKeep.clear();
|
|
17461
|
+
function keep(el) {
|
|
17462
|
+
if (!el || elementsToKeep.has(el)) {
|
|
17463
|
+
return;
|
|
17464
|
+
}
|
|
17465
|
+
elementsToKeep.add(el);
|
|
17466
|
+
el.parentNode && keep(el.parentNode);
|
|
17467
|
+
}
|
|
17468
|
+
function deep(parent) {
|
|
17469
|
+
if (!parent || elementsToStop.has(parent)) {
|
|
17470
|
+
return;
|
|
17471
|
+
}
|
|
17472
|
+
Array.prototype.forEach.call(parent.children, node => {
|
|
17473
|
+
if (elementsToKeep.has(node)) {
|
|
17474
|
+
deep(node);
|
|
17475
|
+
} else {
|
|
17476
|
+
const attr = controlAttribute ? node.getAttribute(controlAttribute) : null;
|
|
17477
|
+
const alreadyHidden = attr !== null && attr !== 'false';
|
|
17478
|
+
const counterValue = (counterMap.get(node) || 0) + 1;
|
|
17479
|
+
const markerValue = (markerCounter.get(node) || 0) + 1;
|
|
17480
|
+
counterMap.set(node, counterValue);
|
|
17481
|
+
markerCounter.set(node, markerValue);
|
|
17482
|
+
hiddenElements.push(node);
|
|
17483
|
+
if (counterValue === 1 && alreadyHidden) {
|
|
17484
|
+
uncontrolledElementsSet.add(node);
|
|
17485
|
+
}
|
|
17486
|
+
if (markerValue === 1) {
|
|
17487
|
+
node.setAttribute(markerName, '');
|
|
17488
|
+
}
|
|
17489
|
+
if (!alreadyHidden && controlAttribute) {
|
|
17490
|
+
node.setAttribute(controlAttribute, 'true');
|
|
17491
|
+
}
|
|
17492
|
+
}
|
|
17493
|
+
});
|
|
17494
|
+
}
|
|
17495
|
+
lockCount++;
|
|
17496
|
+
return () => {
|
|
17497
|
+
hiddenElements.forEach(element => {
|
|
17498
|
+
const counterValue = (counterMap.get(element) || 0) - 1;
|
|
17499
|
+
const markerValue = (markerCounter.get(element) || 0) - 1;
|
|
17500
|
+
counterMap.set(element, counterValue);
|
|
17501
|
+
markerCounter.set(element, markerValue);
|
|
17502
|
+
if (!counterValue) {
|
|
17503
|
+
if (!uncontrolledElementsSet.has(element) && controlAttribute) {
|
|
17504
|
+
element.removeAttribute(controlAttribute);
|
|
17505
|
+
}
|
|
17506
|
+
uncontrolledElementsSet.delete(element);
|
|
17507
|
+
}
|
|
17508
|
+
if (!markerValue) {
|
|
17509
|
+
element.removeAttribute(markerName);
|
|
17510
|
+
}
|
|
17511
|
+
});
|
|
17512
|
+
lockCount--;
|
|
17513
|
+
if (!lockCount) {
|
|
17514
|
+
counterMap = new WeakMap();
|
|
17515
|
+
counterMap = new WeakMap();
|
|
17516
|
+
uncontrolledElementsSet = new WeakSet();
|
|
17517
|
+
markerMap = {};
|
|
17518
|
+
}
|
|
17519
|
+
};
|
|
17453
17520
|
}
|
|
17454
|
-
|
|
17455
|
-
|
|
17456
|
-
|
|
17457
|
-
|
|
17521
|
+
function markOthers(avoidElements, ariaHidden, inert) {
|
|
17522
|
+
if (ariaHidden === void 0) {
|
|
17523
|
+
ariaHidden = false;
|
|
17524
|
+
}
|
|
17525
|
+
if (inert === void 0) {
|
|
17526
|
+
inert = false;
|
|
17527
|
+
}
|
|
17528
|
+
const body = getDocument(avoidElements[0]).body;
|
|
17529
|
+
return applyAttributeToOthers(avoidElements.concat(Array.from(body.querySelectorAll('[aria-live]'))), body, ariaHidden, inert);
|
|
17458
17530
|
}
|
|
17459
17531
|
|
|
17460
17532
|
const getTabbableOptions = () => ({
|
|
@@ -17544,20 +17616,20 @@ const FocusGuard = /*#__PURE__*/React__namespace.forwardRef(function FocusGuard(
|
|
|
17544
17616
|
document.removeEventListener('keydown', setActiveElementOnTab);
|
|
17545
17617
|
};
|
|
17546
17618
|
}, []);
|
|
17547
|
-
|
|
17548
|
-
ref
|
|
17549
|
-
tabIndex: 0
|
|
17619
|
+
const restProps = {
|
|
17620
|
+
ref,
|
|
17621
|
+
tabIndex: 0,
|
|
17550
17622
|
// Role is only for VoiceOver
|
|
17551
|
-
,
|
|
17552
|
-
role:
|
|
17553
|
-
|
|
17554
|
-
"data-floating-ui-focus-guard": "",
|
|
17623
|
+
role,
|
|
17624
|
+
'aria-hidden': role ? undefined : true,
|
|
17625
|
+
[createAttribute('focus-guard')]: '',
|
|
17555
17626
|
style: HIDDEN_STYLES
|
|
17556
|
-
}
|
|
17627
|
+
};
|
|
17628
|
+
return /*#__PURE__*/React__namespace.createElement("span", _extends({}, props, restProps));
|
|
17557
17629
|
});
|
|
17558
17630
|
|
|
17559
17631
|
const PortalContext = /*#__PURE__*/React__namespace.createContext(null);
|
|
17560
|
-
|
|
17632
|
+
function useFloatingPortalNode(_temp) {
|
|
17561
17633
|
let {
|
|
17562
17634
|
id,
|
|
17563
17635
|
root
|
|
@@ -17565,20 +17637,39 @@ const useFloatingPortalNode = function (_temp) {
|
|
|
17565
17637
|
const [portalNode, setPortalNode] = React__namespace.useState(null);
|
|
17566
17638
|
const uniqueId = useId();
|
|
17567
17639
|
const portalContext = usePortalContext();
|
|
17640
|
+
const data = React__namespace.useMemo(() => ({
|
|
17641
|
+
id,
|
|
17642
|
+
root,
|
|
17643
|
+
portalContext,
|
|
17644
|
+
uniqueId
|
|
17645
|
+
}), [id, root, portalContext, uniqueId]);
|
|
17646
|
+
const dataRef = React__namespace.useRef();
|
|
17568
17647
|
index(() => {
|
|
17648
|
+
return () => {
|
|
17649
|
+
portalNode == null ? void 0 : portalNode.remove();
|
|
17650
|
+
};
|
|
17651
|
+
}, [portalNode, data]);
|
|
17652
|
+
index(() => {
|
|
17653
|
+
if (dataRef.current === data) return;
|
|
17654
|
+
dataRef.current = data;
|
|
17655
|
+
const {
|
|
17656
|
+
id,
|
|
17657
|
+
root,
|
|
17658
|
+
portalContext,
|
|
17659
|
+
uniqueId
|
|
17660
|
+
} = data;
|
|
17569
17661
|
const existingIdRoot = id ? document.getElementById(id) : null;
|
|
17570
|
-
const attr = '
|
|
17662
|
+
const attr = createAttribute('portal');
|
|
17571
17663
|
if (existingIdRoot) {
|
|
17572
17664
|
const subRoot = document.createElement('div');
|
|
17573
17665
|
subRoot.id = uniqueId;
|
|
17574
17666
|
subRoot.setAttribute(attr, '');
|
|
17575
17667
|
existingIdRoot.appendChild(subRoot);
|
|
17576
17668
|
setPortalNode(subRoot);
|
|
17577
|
-
return () => {
|
|
17578
|
-
subRoot.remove();
|
|
17579
|
-
};
|
|
17580
17669
|
} else {
|
|
17581
|
-
let container = (portalContext == null ? void 0 : portalContext.portalNode)
|
|
17670
|
+
let container = root || (portalContext == null ? void 0 : portalContext.portalNode);
|
|
17671
|
+
if (container && !isElement(container)) container = container.current;
|
|
17672
|
+
container = container || document.body;
|
|
17582
17673
|
let idWrapper = null;
|
|
17583
17674
|
if (id) {
|
|
17584
17675
|
idWrapper = document.createElement('div');
|
|
@@ -17588,25 +17679,19 @@ const useFloatingPortalNode = function (_temp) {
|
|
|
17588
17679
|
const subRoot = document.createElement('div');
|
|
17589
17680
|
subRoot.id = uniqueId;
|
|
17590
17681
|
subRoot.setAttribute(attr, '');
|
|
17591
|
-
setPortalNode(subRoot);
|
|
17592
17682
|
container = idWrapper || container;
|
|
17593
17683
|
container.appendChild(subRoot);
|
|
17594
|
-
|
|
17595
|
-
var _idWrapper;
|
|
17596
|
-
subRoot.remove();
|
|
17597
|
-
(_idWrapper = idWrapper) == null ? void 0 : _idWrapper.remove();
|
|
17598
|
-
};
|
|
17684
|
+
setPortalNode(subRoot);
|
|
17599
17685
|
}
|
|
17600
|
-
}, [
|
|
17686
|
+
}, [data]);
|
|
17601
17687
|
return portalNode;
|
|
17602
|
-
}
|
|
17603
|
-
|
|
17688
|
+
}
|
|
17604
17689
|
/**
|
|
17605
17690
|
* Portals the floating element into a given container element — by default,
|
|
17606
17691
|
* outside of the app root and into the body.
|
|
17607
17692
|
* @see https://floating-ui.com/docs/FloatingPortal
|
|
17608
17693
|
*/
|
|
17609
|
-
|
|
17694
|
+
function FloatingPortal(_ref) {
|
|
17610
17695
|
let {
|
|
17611
17696
|
children,
|
|
17612
17697
|
id,
|
|
@@ -17627,7 +17712,9 @@ const FloatingPortal = _ref => {
|
|
|
17627
17712
|
// rendered.
|
|
17628
17713
|
!!focusManagerState &&
|
|
17629
17714
|
// Guards are only for non-modal focus management.
|
|
17630
|
-
!focusManagerState.modal &&
|
|
17715
|
+
!focusManagerState.modal &&
|
|
17716
|
+
// Don't render if unmount is transitioning.
|
|
17717
|
+
focusManagerState.open && preserveTabOrder && !!(root || portalNode);
|
|
17631
17718
|
|
|
17632
17719
|
// https://codesandbox.io/s/tabbable-portal-f4tng?file=/src/TabbablePortal.tsx
|
|
17633
17720
|
React__namespace.useEffect(() => {
|
|
@@ -17689,11 +17776,11 @@ const FloatingPortal = _ref => {
|
|
|
17689
17776
|
} else {
|
|
17690
17777
|
const nextTabbable = getNextTabbable() || (focusManagerState == null ? void 0 : focusManagerState.refs.domReference.current);
|
|
17691
17778
|
nextTabbable == null ? void 0 : nextTabbable.focus();
|
|
17692
|
-
(focusManagerState == null ? void 0 : focusManagerState.closeOnFocusOut) && (focusManagerState == null ? void 0 : focusManagerState.onOpenChange(false));
|
|
17779
|
+
(focusManagerState == null ? void 0 : focusManagerState.closeOnFocusOut) && (focusManagerState == null ? void 0 : focusManagerState.onOpenChange(false, event.nativeEvent));
|
|
17693
17780
|
}
|
|
17694
17781
|
}
|
|
17695
17782
|
}));
|
|
17696
|
-
}
|
|
17783
|
+
}
|
|
17697
17784
|
const usePortalContext = () => React__namespace.useContext(PortalContext);
|
|
17698
17785
|
|
|
17699
17786
|
const VisuallyHiddenDismiss = /*#__PURE__*/React__namespace.forwardRef(function VisuallyHiddenDismiss(props, ref) {
|
|
@@ -17708,18 +17795,19 @@ const VisuallyHiddenDismiss = /*#__PURE__*/React__namespace.forwardRef(function
|
|
|
17708
17795
|
* Provides focus management for the floating element.
|
|
17709
17796
|
* @see https://floating-ui.com/docs/FloatingFocusManager
|
|
17710
17797
|
*/
|
|
17711
|
-
function FloatingFocusManager(
|
|
17712
|
-
|
|
17798
|
+
function FloatingFocusManager(props) {
|
|
17799
|
+
const {
|
|
17713
17800
|
context,
|
|
17714
17801
|
children,
|
|
17802
|
+
disabled = false,
|
|
17715
17803
|
order = ['content'],
|
|
17716
|
-
guards = true,
|
|
17804
|
+
guards: _guards = true,
|
|
17717
17805
|
initialFocus = 0,
|
|
17718
17806
|
returnFocus = true,
|
|
17719
17807
|
modal = true,
|
|
17720
17808
|
visuallyHiddenDismiss = false,
|
|
17721
17809
|
closeOnFocusOut = true
|
|
17722
|
-
} =
|
|
17810
|
+
} = props;
|
|
17723
17811
|
const {
|
|
17724
17812
|
open,
|
|
17725
17813
|
refs,
|
|
@@ -17732,12 +17820,14 @@ function FloatingFocusManager(_ref) {
|
|
|
17732
17820
|
floating
|
|
17733
17821
|
}
|
|
17734
17822
|
} = context;
|
|
17823
|
+
|
|
17824
|
+
// Force the guards to be rendered if the `inert` attribute is not supported.
|
|
17825
|
+
const guards = supportsInert() ? _guards : true;
|
|
17735
17826
|
const orderRef = useLatestRef(order);
|
|
17736
17827
|
const initialFocusRef = useLatestRef(initialFocus);
|
|
17737
17828
|
const returnFocusRef = useLatestRef(returnFocus);
|
|
17738
17829
|
const tree = useFloatingTree();
|
|
17739
17830
|
const portalContext = usePortalContext();
|
|
17740
|
-
const [tabbableContentLength, setTabbableContentLength] = React__namespace.useState(null);
|
|
17741
17831
|
|
|
17742
17832
|
// Controlled by `useListNavigation`.
|
|
17743
17833
|
const ignoreInitialFocus = typeof initialFocus === 'number' && initialFocus < 0;
|
|
@@ -17753,7 +17843,7 @@ function FloatingFocusManager(_ref) {
|
|
|
17753
17843
|
// aria-hidden should be applied to all nodes still. Further, the visually
|
|
17754
17844
|
// hidden dismiss button should only appear at the end of the list, not the
|
|
17755
17845
|
// start.
|
|
17756
|
-
const
|
|
17846
|
+
const isUntrappedTypeableCombobox = domReference && domReference.getAttribute('role') === 'combobox' && isTypeableElement(domReference) && ignoreInitialFocus;
|
|
17757
17847
|
const getTabbableContent = React__namespace.useCallback(function (container) {
|
|
17758
17848
|
if (container === void 0) {
|
|
17759
17849
|
container = floating;
|
|
@@ -17773,13 +17863,11 @@ function FloatingFocusManager(_ref) {
|
|
|
17773
17863
|
}).filter(Boolean).flat();
|
|
17774
17864
|
}, [domReference, floating, orderRef, getTabbableContent]);
|
|
17775
17865
|
React__namespace.useEffect(() => {
|
|
17776
|
-
if (!modal)
|
|
17777
|
-
return;
|
|
17778
|
-
}
|
|
17866
|
+
if (disabled || !modal) return;
|
|
17779
17867
|
function onKeyDown(event) {
|
|
17780
17868
|
if (event.key === 'Tab') {
|
|
17781
17869
|
// The focus guards have nothing to focus, so we need to stop the event.
|
|
17782
|
-
if (getTabbableContent().length === 0 && !
|
|
17870
|
+
if (contains(floating, activeElement(getDocument(floating))) && getTabbableContent().length === 0 && !isUntrappedTypeableCombobox) {
|
|
17783
17871
|
stopEvent(event);
|
|
17784
17872
|
}
|
|
17785
17873
|
const els = getTabbableElements();
|
|
@@ -17803,11 +17891,9 @@ function FloatingFocusManager(_ref) {
|
|
|
17803
17891
|
return () => {
|
|
17804
17892
|
doc.removeEventListener('keydown', onKeyDown);
|
|
17805
17893
|
};
|
|
17806
|
-
}, [domReference, floating, modal, orderRef, refs,
|
|
17894
|
+
}, [disabled, domReference, floating, modal, orderRef, refs, isUntrappedTypeableCombobox, getTabbableContent, getTabbableElements]);
|
|
17807
17895
|
React__namespace.useEffect(() => {
|
|
17808
|
-
if (!closeOnFocusOut)
|
|
17809
|
-
return;
|
|
17810
|
-
}
|
|
17896
|
+
if (disabled || !closeOnFocusOut) return;
|
|
17811
17897
|
|
|
17812
17898
|
// In Safari, buttons lose focus when pressing them.
|
|
17813
17899
|
function handlePointerDown() {
|
|
@@ -17818,22 +17904,24 @@ function FloatingFocusManager(_ref) {
|
|
|
17818
17904
|
}
|
|
17819
17905
|
function handleFocusOutside(event) {
|
|
17820
17906
|
const relatedTarget = event.relatedTarget;
|
|
17821
|
-
|
|
17822
|
-
|
|
17823
|
-
|
|
17824
|
-
|
|
17825
|
-
|
|
17826
|
-
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
17831
|
-
|
|
17832
|
-
|
|
17833
|
-
|
|
17834
|
-
|
|
17835
|
-
|
|
17836
|
-
|
|
17907
|
+
queueMicrotask(() => {
|
|
17908
|
+
const movedToUnrelatedNode = !(contains(domReference, relatedTarget) || contains(floating, relatedTarget) || contains(relatedTarget, floating) || contains(portalContext == null ? void 0 : portalContext.portalNode, relatedTarget) || relatedTarget != null && relatedTarget.hasAttribute(createAttribute('focus-guard')) || tree && (getChildren(tree.nodesRef.current, nodeId).find(node => {
|
|
17909
|
+
var _node$context, _node$context2;
|
|
17910
|
+
return contains((_node$context = node.context) == null ? void 0 : _node$context.elements.floating, relatedTarget) || contains((_node$context2 = node.context) == null ? void 0 : _node$context2.elements.domReference, relatedTarget);
|
|
17911
|
+
}) || getAncestors(tree.nodesRef.current, nodeId).find(node => {
|
|
17912
|
+
var _node$context3, _node$context4;
|
|
17913
|
+
return ((_node$context3 = node.context) == null ? void 0 : _node$context3.elements.floating) === relatedTarget || ((_node$context4 = node.context) == null ? void 0 : _node$context4.elements.domReference) === relatedTarget;
|
|
17914
|
+
})));
|
|
17915
|
+
|
|
17916
|
+
// Focus did not move inside the floating tree, and there are no tabbable
|
|
17917
|
+
// portal guards to handle closing.
|
|
17918
|
+
if (relatedTarget && movedToUnrelatedNode && !isPointerDownRef.current &&
|
|
17919
|
+
// Fix React 18 Strict Mode returnFocus due to double rendering.
|
|
17920
|
+
relatedTarget !== previouslyFocusedElementRef.current) {
|
|
17921
|
+
preventReturnFocusRef.current = true;
|
|
17922
|
+
onOpenChange(false, event);
|
|
17923
|
+
}
|
|
17924
|
+
});
|
|
17837
17925
|
}
|
|
17838
17926
|
if (floating && isHTMLElement(domReference)) {
|
|
17839
17927
|
domReference.addEventListener('focusout', handleFocusOutside);
|
|
@@ -17845,63 +17933,46 @@ function FloatingFocusManager(_ref) {
|
|
|
17845
17933
|
!modal && floating.removeEventListener('focusout', handleFocusOutside);
|
|
17846
17934
|
};
|
|
17847
17935
|
}
|
|
17848
|
-
}, [domReference, floating, modal, nodeId, tree, portalContext, onOpenChange, closeOnFocusOut]);
|
|
17936
|
+
}, [disabled, domReference, floating, modal, nodeId, tree, portalContext, onOpenChange, closeOnFocusOut]);
|
|
17849
17937
|
React__namespace.useEffect(() => {
|
|
17850
17938
|
var _portalContext$portal;
|
|
17939
|
+
if (disabled) return;
|
|
17940
|
+
|
|
17851
17941
|
// Don't hide portals nested within the parent portal.
|
|
17852
|
-
const portalNodes = Array.from((portalContext == null ? void 0 : (_portalContext$portal = portalContext.portalNode) == null ? void 0 : _portalContext$portal.querySelectorAll('
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
|
|
17856
|
-
if (floating && modal) {
|
|
17857
|
-
const insideNodes = [floating, ...portalNodes, ...getDismissButtons()];
|
|
17858
|
-
const cleanup = hideOthers(orderRef.current.includes('reference') || isTypeableCombobox ? insideNodes.concat(domReference || []) : insideNodes);
|
|
17942
|
+
const portalNodes = Array.from((portalContext == null ? void 0 : (_portalContext$portal = portalContext.portalNode) == null ? void 0 : _portalContext$portal.querySelectorAll("[" + createAttribute('portal') + "]")) || []);
|
|
17943
|
+
if (floating) {
|
|
17944
|
+
const insideElements = [floating, ...portalNodes, startDismissButtonRef.current, endDismissButtonRef.current, orderRef.current.includes('reference') || isUntrappedTypeableCombobox ? domReference : null].filter(x => x != null);
|
|
17945
|
+
const cleanup = modal ? markOthers(insideElements, guards, !guards) : markOthers(insideElements);
|
|
17859
17946
|
return () => {
|
|
17860
17947
|
cleanup();
|
|
17861
17948
|
};
|
|
17862
17949
|
}
|
|
17863
|
-
}, [domReference, floating, modal, orderRef, portalContext,
|
|
17864
|
-
React__namespace.useEffect(() => {
|
|
17865
|
-
if (modal && !guards && floating) {
|
|
17866
|
-
const tabIndexValues = [];
|
|
17867
|
-
const options = getTabbableOptions();
|
|
17868
|
-
const allTabbable = tabbable(getDocument(floating).body, options);
|
|
17869
|
-
const floatingTabbable = getTabbableElements();
|
|
17870
|
-
|
|
17871
|
-
// Exclude all tabbable elements that are part of the order
|
|
17872
|
-
const elements = allTabbable.filter(el => !floatingTabbable.includes(el));
|
|
17873
|
-
elements.forEach((el, i) => {
|
|
17874
|
-
tabIndexValues[i] = el.getAttribute('tabindex');
|
|
17875
|
-
el.setAttribute('tabindex', '-1');
|
|
17876
|
-
});
|
|
17877
|
-
return () => {
|
|
17878
|
-
elements.forEach((el, i) => {
|
|
17879
|
-
const value = tabIndexValues[i];
|
|
17880
|
-
if (value == null) {
|
|
17881
|
-
el.removeAttribute('tabindex');
|
|
17882
|
-
} else {
|
|
17883
|
-
el.setAttribute('tabindex', value);
|
|
17884
|
-
}
|
|
17885
|
-
});
|
|
17886
|
-
};
|
|
17887
|
-
}
|
|
17888
|
-
}, [floating, modal, guards, getTabbableElements]);
|
|
17950
|
+
}, [disabled, domReference, floating, modal, orderRef, portalContext, isUntrappedTypeableCombobox, guards]);
|
|
17889
17951
|
index(() => {
|
|
17890
|
-
if (!floating) return;
|
|
17952
|
+
if (disabled || !floating) return;
|
|
17891
17953
|
const doc = getDocument(floating);
|
|
17954
|
+
const previouslyFocusedElement = activeElement(doc);
|
|
17955
|
+
|
|
17956
|
+
// Wait for any layout effect state setters to execute to set `tabIndex`.
|
|
17957
|
+
queueMicrotask(() => {
|
|
17958
|
+
const focusableElements = getTabbableElements(floating);
|
|
17959
|
+
const initialFocusValue = initialFocusRef.current;
|
|
17960
|
+
const elToFocus = (typeof initialFocusValue === 'number' ? focusableElements[initialFocusValue] : initialFocusValue.current) || floating;
|
|
17961
|
+
const focusAlreadyInsideFloatingEl = contains(floating, previouslyFocusedElement);
|
|
17962
|
+
if (!ignoreInitialFocus && !focusAlreadyInsideFloatingEl && open) {
|
|
17963
|
+
enqueueFocus(elToFocus, {
|
|
17964
|
+
preventScroll: elToFocus === floating
|
|
17965
|
+
});
|
|
17966
|
+
}
|
|
17967
|
+
});
|
|
17968
|
+
}, [disabled, open, floating, ignoreInitialFocus, getTabbableElements, initialFocusRef]);
|
|
17969
|
+
index(() => {
|
|
17970
|
+
if (disabled || !floating) return;
|
|
17892
17971
|
let preventReturnFocusScroll = false;
|
|
17972
|
+
const doc = getDocument(floating);
|
|
17893
17973
|
const previouslyFocusedElement = activeElement(doc);
|
|
17894
17974
|
const contextData = dataRef.current;
|
|
17895
|
-
const initialFocusValue = initialFocusRef.current;
|
|
17896
17975
|
previouslyFocusedElementRef.current = previouslyFocusedElement;
|
|
17897
|
-
const focusableElements = getTabbableElements(floating);
|
|
17898
|
-
const elToFocus = (typeof initialFocusValue === 'number' ? focusableElements[initialFocusValue] : initialFocusValue.current) || floating;
|
|
17899
|
-
|
|
17900
|
-
// If the `useListNavigation` hook is active, always ignore `initialFocus`
|
|
17901
|
-
// because it has its own handling of the initial focus.
|
|
17902
|
-
!ignoreInitialFocus && open && enqueueFocus(elToFocus, {
|
|
17903
|
-
preventScroll: elToFocus === floating
|
|
17904
|
-
});
|
|
17905
17976
|
|
|
17906
17977
|
// Dismissing via outside press should always ignore `returnFocus` to
|
|
17907
17978
|
// prevent unwanted scrolling.
|
|
@@ -17934,8 +18005,6 @@ function FloatingFocusManager(_ref) {
|
|
|
17934
18005
|
if (
|
|
17935
18006
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17936
18007
|
returnFocusRef.current && isHTMLElement(previouslyFocusedElementRef.current) && !preventReturnFocusRef.current) {
|
|
17937
|
-
// `isPointerDownRef.current` to avoid the focus ring from appearing on
|
|
17938
|
-
// the reference element when click-toggling it.
|
|
17939
18008
|
enqueueFocus(previouslyFocusedElementRef.current, {
|
|
17940
18009
|
// When dismissing nested floating elements, by the time the rAF has
|
|
17941
18010
|
// executed, the menus will all have been unmounted. When they try
|
|
@@ -17946,49 +18015,58 @@ function FloatingFocusManager(_ref) {
|
|
|
17946
18015
|
});
|
|
17947
18016
|
}
|
|
17948
18017
|
};
|
|
17949
|
-
}, [
|
|
18018
|
+
}, [disabled, floating, returnFocusRef, dataRef, refs, events, tree, nodeId]);
|
|
17950
18019
|
|
|
17951
18020
|
// Synchronize the `context` & `modal` value to the FloatingPortal context.
|
|
17952
18021
|
// It will decide whether or not it needs to render its own guards.
|
|
17953
18022
|
index(() => {
|
|
17954
|
-
if (!portalContext) return;
|
|
18023
|
+
if (disabled || !portalContext) return;
|
|
17955
18024
|
portalContext.setFocusManagerState({
|
|
17956
|
-
...context,
|
|
17957
18025
|
modal,
|
|
17958
|
-
closeOnFocusOut
|
|
17959
|
-
|
|
18026
|
+
closeOnFocusOut,
|
|
18027
|
+
open,
|
|
18028
|
+
onOpenChange,
|
|
18029
|
+
refs
|
|
17960
18030
|
});
|
|
17961
|
-
|
|
17962
18031
|
return () => {
|
|
17963
18032
|
portalContext.setFocusManagerState(null);
|
|
17964
18033
|
};
|
|
17965
|
-
}, [portalContext, modal,
|
|
18034
|
+
}, [disabled, portalContext, modal, open, onOpenChange, refs, closeOnFocusOut]);
|
|
17966
18035
|
index(() => {
|
|
17967
|
-
if (
|
|
17968
|
-
function
|
|
17969
|
-
|
|
17970
|
-
|
|
17971
|
-
|
|
17972
|
-
|
|
17973
|
-
|
|
17974
|
-
|
|
17975
|
-
|
|
18036
|
+
if (disabled) return;
|
|
18037
|
+
if (floating && typeof MutationObserver === 'function' && !ignoreInitialFocus) {
|
|
18038
|
+
const handleMutation = () => {
|
|
18039
|
+
const tabIndex = floating.getAttribute('tabindex');
|
|
18040
|
+
if (orderRef.current.includes('floating') || activeElement(getDocument(floating)) !== refs.domReference.current && getTabbableContent().length === 0) {
|
|
18041
|
+
if (tabIndex !== '0') {
|
|
18042
|
+
floating.setAttribute('tabindex', '0');
|
|
18043
|
+
}
|
|
18044
|
+
} else if (tabIndex !== '-1') {
|
|
18045
|
+
floating.setAttribute('tabindex', '-1');
|
|
18046
|
+
}
|
|
18047
|
+
};
|
|
18048
|
+
handleMutation();
|
|
18049
|
+
const observer = new MutationObserver(handleMutation);
|
|
17976
18050
|
observer.observe(floating, {
|
|
17977
18051
|
childList: true,
|
|
17978
|
-
subtree: true
|
|
18052
|
+
subtree: true,
|
|
18053
|
+
attributes: true
|
|
17979
18054
|
});
|
|
17980
18055
|
return () => {
|
|
17981
18056
|
observer.disconnect();
|
|
17982
18057
|
};
|
|
17983
18058
|
}
|
|
17984
|
-
}, [floating, getTabbableContent, ignoreInitialFocus
|
|
17985
|
-
const shouldRenderGuards = guards && (isInsidePortal || modal) && !isTypeableCombobox;
|
|
18059
|
+
}, [disabled, floating, refs, orderRef, getTabbableContent, ignoreInitialFocus]);
|
|
17986
18060
|
function renderDismissButton(location) {
|
|
17987
|
-
|
|
18061
|
+
if (disabled || !visuallyHiddenDismiss || !modal) {
|
|
18062
|
+
return null;
|
|
18063
|
+
}
|
|
18064
|
+
return /*#__PURE__*/React__namespace.createElement(VisuallyHiddenDismiss, {
|
|
17988
18065
|
ref: location === 'start' ? startDismissButtonRef : endDismissButtonRef,
|
|
17989
|
-
onClick:
|
|
17990
|
-
}, typeof visuallyHiddenDismiss === 'string' ? visuallyHiddenDismiss : 'Dismiss')
|
|
18066
|
+
onClick: event => onOpenChange(false, event.nativeEvent)
|
|
18067
|
+
}, typeof visuallyHiddenDismiss === 'string' ? visuallyHiddenDismiss : 'Dismiss');
|
|
17991
18068
|
}
|
|
18069
|
+
const shouldRenderGuards = !disabled && guards && !isUntrappedTypeableCombobox && (isInsidePortal || modal);
|
|
17992
18070
|
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, shouldRenderGuards && /*#__PURE__*/React__namespace.createElement(FocusGuard, {
|
|
17993
18071
|
"data-type": "inside",
|
|
17994
18072
|
ref: portalContext == null ? void 0 : portalContext.beforeInsideRef,
|
|
@@ -18007,9 +18085,7 @@ function FloatingFocusManager(_ref) {
|
|
|
18007
18085
|
}
|
|
18008
18086
|
}
|
|
18009
18087
|
}
|
|
18010
|
-
}),
|
|
18011
|
-
tabIndex: 0
|
|
18012
|
-
} : {}), renderDismissButton('end'), shouldRenderGuards && /*#__PURE__*/React__namespace.createElement(FocusGuard, {
|
|
18088
|
+
}), !isUntrappedTypeableCombobox && renderDismissButton('start'), children, renderDismissButton('end'), shouldRenderGuards && /*#__PURE__*/React__namespace.createElement(FocusGuard, {
|
|
18013
18089
|
"data-type": "inside",
|
|
18014
18090
|
ref: portalContext == null ? void 0 : portalContext.afterInsideRef,
|
|
18015
18091
|
onFocus: event => {
|
|
@@ -18041,7 +18117,7 @@ function isSpaceIgnored(element) {
|
|
|
18041
18117
|
* Opens or closes the floating element when clicking the reference element.
|
|
18042
18118
|
* @see https://floating-ui.com/docs/useClick
|
|
18043
18119
|
*/
|
|
18044
|
-
|
|
18120
|
+
function useClick(context, props) {
|
|
18045
18121
|
if (props === void 0) {
|
|
18046
18122
|
props = {};
|
|
18047
18123
|
}
|
|
@@ -18061,10 +18137,9 @@ const useClick = function (context, props) {
|
|
|
18061
18137
|
keyboardHandlers = true
|
|
18062
18138
|
} = props;
|
|
18063
18139
|
const pointerTypeRef = React__namespace.useRef();
|
|
18140
|
+
const didKeyDownRef = React__namespace.useRef(false);
|
|
18064
18141
|
return React__namespace.useMemo(() => {
|
|
18065
|
-
if (!enabled) {
|
|
18066
|
-
return {};
|
|
18067
|
-
}
|
|
18142
|
+
if (!enabled) return {};
|
|
18068
18143
|
return {
|
|
18069
18144
|
reference: {
|
|
18070
18145
|
onPointerDown(event) {
|
|
@@ -18082,16 +18157,13 @@ const useClick = function (context, props) {
|
|
|
18082
18157
|
if (eventOption === 'click') {
|
|
18083
18158
|
return;
|
|
18084
18159
|
}
|
|
18085
|
-
if (open) {
|
|
18086
|
-
|
|
18087
|
-
onOpenChange(false);
|
|
18088
|
-
}
|
|
18160
|
+
if (open && toggle && (dataRef.current.openEvent ? dataRef.current.openEvent.type === 'mousedown' : true)) {
|
|
18161
|
+
onOpenChange(false, event.nativeEvent);
|
|
18089
18162
|
} else {
|
|
18090
18163
|
// Prevent stealing focus from the floating element
|
|
18091
18164
|
event.preventDefault();
|
|
18092
|
-
onOpenChange(true);
|
|
18165
|
+
onOpenChange(true, event.nativeEvent);
|
|
18093
18166
|
}
|
|
18094
|
-
dataRef.current.openEvent = event.nativeEvent;
|
|
18095
18167
|
},
|
|
18096
18168
|
onClick(event) {
|
|
18097
18169
|
if (eventOption === 'mousedown' && pointerTypeRef.current) {
|
|
@@ -18101,63 +18173,52 @@ const useClick = function (context, props) {
|
|
|
18101
18173
|
if (isMouseLikePointerType(pointerTypeRef.current, true) && ignoreMouse) {
|
|
18102
18174
|
return;
|
|
18103
18175
|
}
|
|
18104
|
-
if (open) {
|
|
18105
|
-
|
|
18106
|
-
onOpenChange(false);
|
|
18107
|
-
}
|
|
18176
|
+
if (open && toggle && (dataRef.current.openEvent ? dataRef.current.openEvent.type === 'click' : true)) {
|
|
18177
|
+
onOpenChange(false, event.nativeEvent);
|
|
18108
18178
|
} else {
|
|
18109
|
-
onOpenChange(true);
|
|
18179
|
+
onOpenChange(true, event.nativeEvent);
|
|
18110
18180
|
}
|
|
18111
|
-
dataRef.current.openEvent = event.nativeEvent;
|
|
18112
18181
|
},
|
|
18113
18182
|
onKeyDown(event) {
|
|
18114
18183
|
pointerTypeRef.current = undefined;
|
|
18115
|
-
if (!keyboardHandlers) {
|
|
18116
|
-
return;
|
|
18117
|
-
}
|
|
18118
|
-
if (isButtonTarget(event)) {
|
|
18184
|
+
if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event)) {
|
|
18119
18185
|
return;
|
|
18120
18186
|
}
|
|
18121
18187
|
if (event.key === ' ' && !isSpaceIgnored(domReference)) {
|
|
18122
18188
|
// Prevent scrolling
|
|
18123
18189
|
event.preventDefault();
|
|
18190
|
+
didKeyDownRef.current = true;
|
|
18124
18191
|
}
|
|
18125
18192
|
if (event.key === 'Enter') {
|
|
18126
|
-
if (open) {
|
|
18127
|
-
|
|
18128
|
-
onOpenChange(false);
|
|
18129
|
-
}
|
|
18193
|
+
if (open && toggle) {
|
|
18194
|
+
onOpenChange(false, event.nativeEvent);
|
|
18130
18195
|
} else {
|
|
18131
|
-
onOpenChange(true);
|
|
18196
|
+
onOpenChange(true, event.nativeEvent);
|
|
18132
18197
|
}
|
|
18133
18198
|
}
|
|
18134
18199
|
},
|
|
18135
18200
|
onKeyUp(event) {
|
|
18136
|
-
if (!keyboardHandlers) {
|
|
18137
|
-
return;
|
|
18138
|
-
}
|
|
18139
|
-
if (isButtonTarget(event) || isSpaceIgnored(domReference)) {
|
|
18201
|
+
if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event) || isSpaceIgnored(domReference)) {
|
|
18140
18202
|
return;
|
|
18141
18203
|
}
|
|
18142
|
-
if (event.key === ' ') {
|
|
18143
|
-
|
|
18144
|
-
|
|
18145
|
-
|
|
18146
|
-
}
|
|
18204
|
+
if (event.key === ' ' && didKeyDownRef.current) {
|
|
18205
|
+
didKeyDownRef.current = false;
|
|
18206
|
+
if (open && toggle) {
|
|
18207
|
+
onOpenChange(false, event.nativeEvent);
|
|
18147
18208
|
} else {
|
|
18148
|
-
onOpenChange(true);
|
|
18209
|
+
onOpenChange(true, event.nativeEvent);
|
|
18149
18210
|
}
|
|
18150
18211
|
}
|
|
18151
18212
|
}
|
|
18152
18213
|
}
|
|
18153
18214
|
};
|
|
18154
18215
|
}, [enabled, dataRef, eventOption, ignoreMouse, keyboardHandlers, domReference, toggle, open, onOpenChange]);
|
|
18155
|
-
}
|
|
18216
|
+
}
|
|
18156
18217
|
|
|
18157
18218
|
// `toString()` prevents bundlers from trying to `import { useInsertionEffect } from 'react'`
|
|
18158
18219
|
const useInsertionEffect = React__namespace[/*#__PURE__*/'useInsertionEffect'.toString()];
|
|
18159
18220
|
const useSafeInsertionEffect = useInsertionEffect || (fn => fn());
|
|
18160
|
-
function
|
|
18221
|
+
function useEffectEvent(callback) {
|
|
18161
18222
|
const ref = React__namespace.useRef(() => {
|
|
18162
18223
|
if (process.env.NODE_ENV !== "production") {
|
|
18163
18224
|
throw new Error('Cannot call an event handler while rendering.');
|
|
@@ -18174,26 +18235,6 @@ function useEvent(callback) {
|
|
|
18174
18235
|
}, []);
|
|
18175
18236
|
}
|
|
18176
18237
|
|
|
18177
|
-
/**
|
|
18178
|
-
* Check whether the event.target is within the provided node. Uses event.composedPath if available for custom element support.
|
|
18179
|
-
*
|
|
18180
|
-
* @param event The event whose target/composedPath to check
|
|
18181
|
-
* @param node The node to check against
|
|
18182
|
-
* @returns Whether the event.target/composedPath is within the node.
|
|
18183
|
-
*/
|
|
18184
|
-
function isEventTargetWithin(event, node) {
|
|
18185
|
-
if (node == null) {
|
|
18186
|
-
return false;
|
|
18187
|
-
}
|
|
18188
|
-
if ('composedPath' in event) {
|
|
18189
|
-
return event.composedPath().includes(node);
|
|
18190
|
-
}
|
|
18191
|
-
|
|
18192
|
-
// TS thinks `event` is of type never as it assumes all browsers support composedPath, but browsers without shadow dom don't
|
|
18193
|
-
const e = event;
|
|
18194
|
-
return e.target != null && node.contains(e.target);
|
|
18195
|
-
}
|
|
18196
|
-
|
|
18197
18238
|
const bubbleHandlerKeys = {
|
|
18198
18239
|
pointerdown: 'onPointerDown',
|
|
18199
18240
|
mousedown: 'onMouseDown',
|
|
@@ -18216,7 +18257,7 @@ const normalizeBubblesProp = bubbles => {
|
|
|
18216
18257
|
* the user presses the `escape` key or outside of the floating element.
|
|
18217
18258
|
* @see https://floating-ui.com/docs/useDismiss
|
|
18218
18259
|
*/
|
|
18219
|
-
|
|
18260
|
+
function useDismiss(context, props) {
|
|
18220
18261
|
if (props === void 0) {
|
|
18221
18262
|
props = {};
|
|
18222
18263
|
}
|
|
@@ -18244,14 +18285,14 @@ const useDismiss = function (context, props) {
|
|
|
18244
18285
|
} = props;
|
|
18245
18286
|
const tree = useFloatingTree();
|
|
18246
18287
|
const nested = useFloatingParentNodeId() != null;
|
|
18247
|
-
const outsidePressFn =
|
|
18288
|
+
const outsidePressFn = useEffectEvent(typeof unstable_outsidePress === 'function' ? unstable_outsidePress : () => false);
|
|
18248
18289
|
const outsidePress = typeof unstable_outsidePress === 'function' ? outsidePressFn : unstable_outsidePress;
|
|
18249
18290
|
const insideReactTreeRef = React__namespace.useRef(false);
|
|
18250
18291
|
const {
|
|
18251
18292
|
escapeKeyBubbles,
|
|
18252
18293
|
outsidePressBubbles
|
|
18253
18294
|
} = normalizeBubblesProp(bubbles);
|
|
18254
|
-
const closeOnEscapeKeyDown =
|
|
18295
|
+
const closeOnEscapeKeyDown = useEffectEvent(event => {
|
|
18255
18296
|
if (!open || !enabled || !escapeKey || event.key !== 'Escape') {
|
|
18256
18297
|
return;
|
|
18257
18298
|
}
|
|
@@ -18280,9 +18321,9 @@ const useDismiss = function (context, props) {
|
|
|
18280
18321
|
}
|
|
18281
18322
|
}
|
|
18282
18323
|
});
|
|
18283
|
-
onOpenChange(false);
|
|
18324
|
+
onOpenChange(false, isReactEvent(event) ? event.nativeEvent : event);
|
|
18284
18325
|
});
|
|
18285
|
-
const closeOnPressOutside =
|
|
18326
|
+
const closeOnPressOutside = useEffectEvent(event => {
|
|
18286
18327
|
// Given developers can stop the propagation of the synthetic event,
|
|
18287
18328
|
// we can only be confident with a positive value.
|
|
18288
18329
|
const insideReactTree = insideReactTreeRef.current;
|
|
@@ -18294,6 +18335,28 @@ const useDismiss = function (context, props) {
|
|
|
18294
18335
|
return;
|
|
18295
18336
|
}
|
|
18296
18337
|
const target = getTarget(event);
|
|
18338
|
+
const inertSelector = "[" + createAttribute('inert') + "]";
|
|
18339
|
+
const markers = getDocument(floating).querySelectorAll(inertSelector);
|
|
18340
|
+
let targetRootAncestor = isElement(target) ? target : null;
|
|
18341
|
+
while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
|
|
18342
|
+
const nextParent = getParentNode(targetRootAncestor);
|
|
18343
|
+
if (nextParent === getDocument(floating).body || !isElement(nextParent)) {
|
|
18344
|
+
break;
|
|
18345
|
+
} else {
|
|
18346
|
+
targetRootAncestor = nextParent;
|
|
18347
|
+
}
|
|
18348
|
+
}
|
|
18349
|
+
|
|
18350
|
+
// Check if the click occurred on a third-party element injected after the
|
|
18351
|
+
// floating element rendered.
|
|
18352
|
+
if (markers.length && isElement(target) && !isRootElement(target) &&
|
|
18353
|
+
// Clicked on a direct ancestor (e.g. FloatingOverlay).
|
|
18354
|
+
!contains(target, floating) &&
|
|
18355
|
+
// If the target root element contains none of the markers, then the
|
|
18356
|
+
// element was injected after the floating element rendered.
|
|
18357
|
+
Array.from(markers).every(marker => !contains(targetRootAncestor, marker))) {
|
|
18358
|
+
return;
|
|
18359
|
+
}
|
|
18297
18360
|
|
|
18298
18361
|
// Check if the click occurred on the scrollbar
|
|
18299
18362
|
if (isHTMLElement(target) && floating) {
|
|
@@ -18308,7 +18371,7 @@ const useDismiss = function (context, props) {
|
|
|
18308
18371
|
// check for. Plus, for modal dialogs with backdrops, it is more
|
|
18309
18372
|
// important that the backdrop is checked but not so much the window.
|
|
18310
18373
|
if (canScrollY) {
|
|
18311
|
-
const isRTL =
|
|
18374
|
+
const isRTL = getComputedStyle$1(target).direction === 'rtl';
|
|
18312
18375
|
if (isRTL) {
|
|
18313
18376
|
xCond = event.offsetX <= target.offsetWidth - target.clientWidth;
|
|
18314
18377
|
}
|
|
@@ -18346,7 +18409,7 @@ const useDismiss = function (context, props) {
|
|
|
18346
18409
|
} : isVirtualClick(event) || isVirtualPointerEvent(event)
|
|
18347
18410
|
}
|
|
18348
18411
|
});
|
|
18349
|
-
onOpenChange(false);
|
|
18412
|
+
onOpenChange(false, event);
|
|
18350
18413
|
});
|
|
18351
18414
|
React__namespace.useEffect(() => {
|
|
18352
18415
|
if (!open || !enabled) {
|
|
@@ -18354,8 +18417,8 @@ const useDismiss = function (context, props) {
|
|
|
18354
18417
|
}
|
|
18355
18418
|
dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
|
|
18356
18419
|
dataRef.current.__outsidePressBubbles = outsidePressBubbles;
|
|
18357
|
-
function onScroll() {
|
|
18358
|
-
onOpenChange(false);
|
|
18420
|
+
function onScroll(event) {
|
|
18421
|
+
onOpenChange(false, event);
|
|
18359
18422
|
}
|
|
18360
18423
|
const doc = getDocument(floating);
|
|
18361
18424
|
escapeKey && doc.addEventListener('keydown', closeOnEscapeKeyDown);
|
|
@@ -18401,7 +18464,7 @@ const useDismiss = function (context, props) {
|
|
|
18401
18464
|
return {
|
|
18402
18465
|
reference: {
|
|
18403
18466
|
onKeyDown: closeOnEscapeKeyDown,
|
|
18404
|
-
[bubbleHandlerKeys[referencePressEvent]]:
|
|
18467
|
+
[bubbleHandlerKeys[referencePressEvent]]: event => {
|
|
18405
18468
|
if (referencePress) {
|
|
18406
18469
|
events.emit('dismiss', {
|
|
18407
18470
|
type: 'referencePress',
|
|
@@ -18409,7 +18472,7 @@ const useDismiss = function (context, props) {
|
|
|
18409
18472
|
returnFocus: false
|
|
18410
18473
|
}
|
|
18411
18474
|
});
|
|
18412
|
-
onOpenChange(false);
|
|
18475
|
+
onOpenChange(false, event.nativeEvent);
|
|
18413
18476
|
}
|
|
18414
18477
|
}
|
|
18415
18478
|
},
|
|
@@ -18421,91 +18484,19 @@ const useDismiss = function (context, props) {
|
|
|
18421
18484
|
}
|
|
18422
18485
|
};
|
|
18423
18486
|
}, [enabled, events, referencePress, outsidePressEvent, referencePressEvent, onOpenChange, closeOnEscapeKeyDown]);
|
|
18424
|
-
};
|
|
18425
|
-
|
|
18426
|
-
/**
|
|
18427
|
-
* Merges an array of refs into a single memoized callback ref or `null`.
|
|
18428
|
-
* @see https://floating-ui.com/docs/useMergeRefs
|
|
18429
|
-
*/
|
|
18430
|
-
function useMergeRefs(refs) {
|
|
18431
|
-
return React__namespace.useMemo(() => {
|
|
18432
|
-
if (refs.every(ref => ref == null)) {
|
|
18433
|
-
return null;
|
|
18434
|
-
}
|
|
18435
|
-
return value => {
|
|
18436
|
-
refs.forEach(ref => {
|
|
18437
|
-
if (typeof ref === 'function') {
|
|
18438
|
-
ref(value);
|
|
18439
|
-
} else if (ref != null) {
|
|
18440
|
-
ref.current = value;
|
|
18441
|
-
}
|
|
18442
|
-
});
|
|
18443
|
-
};
|
|
18444
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18445
|
-
}, refs);
|
|
18446
18487
|
}
|
|
18447
18488
|
|
|
18448
|
-
|
|
18449
|
-
|
|
18450
|
-
|
|
18451
|
-
|
|
18452
|
-
*/
|
|
18453
|
-
const useRole = function (context, props) {
|
|
18454
|
-
if (props === void 0) {
|
|
18455
|
-
props = {};
|
|
18456
|
-
}
|
|
18457
|
-
const {
|
|
18458
|
-
open,
|
|
18459
|
-
floatingId
|
|
18460
|
-
} = context;
|
|
18461
|
-
const {
|
|
18462
|
-
enabled = true,
|
|
18463
|
-
role = 'dialog'
|
|
18464
|
-
} = props;
|
|
18465
|
-
const referenceId = useId();
|
|
18466
|
-
return React__namespace.useMemo(() => {
|
|
18467
|
-
const floatingProps = {
|
|
18468
|
-
id: floatingId,
|
|
18469
|
-
role
|
|
18470
|
-
};
|
|
18471
|
-
if (!enabled) {
|
|
18472
|
-
return {};
|
|
18473
|
-
}
|
|
18474
|
-
if (role === 'tooltip') {
|
|
18475
|
-
return {
|
|
18476
|
-
reference: {
|
|
18477
|
-
'aria-describedby': open ? floatingId : undefined
|
|
18478
|
-
},
|
|
18479
|
-
floating: floatingProps
|
|
18480
|
-
};
|
|
18481
|
-
}
|
|
18482
|
-
return {
|
|
18483
|
-
reference: {
|
|
18484
|
-
'aria-expanded': open ? 'true' : 'false',
|
|
18485
|
-
'aria-haspopup': role === 'alertdialog' ? 'dialog' : role,
|
|
18486
|
-
'aria-controls': open ? floatingId : undefined,
|
|
18487
|
-
...(role === 'listbox' && {
|
|
18488
|
-
role: 'combobox'
|
|
18489
|
-
}),
|
|
18490
|
-
...(role === 'menu' && {
|
|
18491
|
-
id: referenceId
|
|
18492
|
-
})
|
|
18493
|
-
},
|
|
18494
|
-
floating: {
|
|
18495
|
-
...floatingProps,
|
|
18496
|
-
...(role === 'menu' && {
|
|
18497
|
-
'aria-labelledby': referenceId
|
|
18498
|
-
})
|
|
18499
|
-
}
|
|
18500
|
-
};
|
|
18501
|
-
}, [enabled, role, open, floatingId, referenceId]);
|
|
18502
|
-
};
|
|
18489
|
+
let devMessageSet;
|
|
18490
|
+
if (process.env.NODE_ENV !== "production") {
|
|
18491
|
+
devMessageSet = /*#__PURE__*/new Set();
|
|
18492
|
+
}
|
|
18503
18493
|
|
|
18504
18494
|
/**
|
|
18505
18495
|
* Provides data to position a floating element and context to add interactions.
|
|
18506
18496
|
* @see https://floating-ui.com/docs/react
|
|
18507
18497
|
*/
|
|
18508
18498
|
function useFloating(options) {
|
|
18499
|
+
var _options$elements2;
|
|
18509
18500
|
if (options === void 0) {
|
|
18510
18501
|
options = {};
|
|
18511
18502
|
}
|
|
@@ -18514,13 +18505,32 @@ function useFloating(options) {
|
|
|
18514
18505
|
onOpenChange: unstable_onOpenChange,
|
|
18515
18506
|
nodeId
|
|
18516
18507
|
} = options;
|
|
18508
|
+
if (process.env.NODE_ENV !== "production") {
|
|
18509
|
+
var _options$elements;
|
|
18510
|
+
const err = 'Floating UI: Cannot pass a virtual element to the ' + '`elements.reference` option, as it must be a real DOM element. ' + 'Use `refs.setPositionReference` instead.';
|
|
18511
|
+
if ((_options$elements = options.elements) != null && _options$elements.reference && !isElement(options.elements.reference)) {
|
|
18512
|
+
var _devMessageSet;
|
|
18513
|
+
if (!((_devMessageSet = devMessageSet) != null && _devMessageSet.has(err))) {
|
|
18514
|
+
var _devMessageSet2;
|
|
18515
|
+
(_devMessageSet2 = devMessageSet) == null ? void 0 : _devMessageSet2.add(err);
|
|
18516
|
+
console.error(err);
|
|
18517
|
+
}
|
|
18518
|
+
}
|
|
18519
|
+
}
|
|
18520
|
+
const [_domReference, setDomReference] = React__namespace.useState(null);
|
|
18521
|
+
const domReference = ((_options$elements2 = options.elements) == null ? void 0 : _options$elements2.reference) || _domReference;
|
|
18517
18522
|
const position = useFloating$1(options);
|
|
18518
18523
|
const tree = useFloatingTree();
|
|
18524
|
+
const onOpenChange = useEffectEvent((open, event) => {
|
|
18525
|
+
if (open) {
|
|
18526
|
+
dataRef.current.openEvent = event;
|
|
18527
|
+
}
|
|
18528
|
+
unstable_onOpenChange == null ? void 0 : unstable_onOpenChange(open, event);
|
|
18529
|
+
});
|
|
18519
18530
|
const domReferenceRef = React__namespace.useRef(null);
|
|
18520
18531
|
const dataRef = React__namespace.useRef({});
|
|
18521
18532
|
const events = React__namespace.useState(() => createPubSub())[0];
|
|
18522
18533
|
const floatingId = useId();
|
|
18523
|
-
const [domReference, setDomReference] = React__namespace.useState(null);
|
|
18524
18534
|
const setPositionReference = React__namespace.useCallback(node => {
|
|
18525
18535
|
const positionReference = isElement(node) ? {
|
|
18526
18536
|
getBoundingClientRect: () => node.getBoundingClientRect(),
|
|
@@ -18554,7 +18564,6 @@ function useFloating(options) {
|
|
|
18554
18564
|
...position.elements,
|
|
18555
18565
|
domReference: domReference
|
|
18556
18566
|
}), [position.elements, domReference]);
|
|
18557
|
-
const onOpenChange = useEvent(unstable_onOpenChange);
|
|
18558
18567
|
const context = React__namespace.useMemo(() => ({
|
|
18559
18568
|
...position,
|
|
18560
18569
|
refs,
|
|
@@ -18576,10 +18585,8 @@ function useFloating(options) {
|
|
|
18576
18585
|
...position,
|
|
18577
18586
|
context,
|
|
18578
18587
|
refs,
|
|
18579
|
-
elements
|
|
18580
|
-
|
|
18581
|
-
positionReference: setPositionReference
|
|
18582
|
-
}), [position, refs, elements, context, setReference, setPositionReference]);
|
|
18588
|
+
elements
|
|
18589
|
+
}), [position, refs, elements, context]);
|
|
18583
18590
|
}
|
|
18584
18591
|
|
|
18585
18592
|
function mergeProps(userProps, propsList, elementKey) {
|
|
@@ -18618,7 +18625,14 @@ function mergeProps(userProps, propsList, elementKey) {
|
|
|
18618
18625
|
}, {})
|
|
18619
18626
|
};
|
|
18620
18627
|
}
|
|
18621
|
-
|
|
18628
|
+
|
|
18629
|
+
/**
|
|
18630
|
+
* Merges an array of interaction hooks' props into prop getters, allowing
|
|
18631
|
+
* event handler functions to be composed together without overwriting one
|
|
18632
|
+
* another.
|
|
18633
|
+
* @see https://floating-ui.com/docs/react#interaction-hooks
|
|
18634
|
+
*/
|
|
18635
|
+
function useInteractions(propsList) {
|
|
18622
18636
|
if (propsList === void 0) {
|
|
18623
18637
|
propsList = [];
|
|
18624
18638
|
}
|
|
@@ -18643,7 +18657,63 @@ const useInteractions = function (propsList) {
|
|
|
18643
18657
|
getFloatingProps,
|
|
18644
18658
|
getItemProps
|
|
18645
18659
|
}), [getReferenceProps, getFloatingProps, getItemProps]);
|
|
18646
|
-
}
|
|
18660
|
+
}
|
|
18661
|
+
|
|
18662
|
+
/**
|
|
18663
|
+
* Adds base screen reader props to the reference and floating elements for a
|
|
18664
|
+
* given floating element `role`.
|
|
18665
|
+
* @see https://floating-ui.com/docs/useRole
|
|
18666
|
+
*/
|
|
18667
|
+
function useRole(context, props) {
|
|
18668
|
+
if (props === void 0) {
|
|
18669
|
+
props = {};
|
|
18670
|
+
}
|
|
18671
|
+
const {
|
|
18672
|
+
open,
|
|
18673
|
+
floatingId
|
|
18674
|
+
} = context;
|
|
18675
|
+
const {
|
|
18676
|
+
enabled = true,
|
|
18677
|
+
role = 'dialog'
|
|
18678
|
+
} = props;
|
|
18679
|
+
const referenceId = useId();
|
|
18680
|
+
return React__namespace.useMemo(() => {
|
|
18681
|
+
const floatingProps = {
|
|
18682
|
+
id: floatingId,
|
|
18683
|
+
role
|
|
18684
|
+
};
|
|
18685
|
+
if (!enabled) {
|
|
18686
|
+
return {};
|
|
18687
|
+
}
|
|
18688
|
+
if (role === 'tooltip') {
|
|
18689
|
+
return {
|
|
18690
|
+
reference: {
|
|
18691
|
+
'aria-describedby': open ? floatingId : undefined
|
|
18692
|
+
},
|
|
18693
|
+
floating: floatingProps
|
|
18694
|
+
};
|
|
18695
|
+
}
|
|
18696
|
+
return {
|
|
18697
|
+
reference: {
|
|
18698
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
18699
|
+
'aria-haspopup': role === 'alertdialog' ? 'dialog' : role,
|
|
18700
|
+
'aria-controls': open ? floatingId : undefined,
|
|
18701
|
+
...(role === 'listbox' && {
|
|
18702
|
+
role: 'combobox'
|
|
18703
|
+
}),
|
|
18704
|
+
...(role === 'menu' && {
|
|
18705
|
+
id: referenceId
|
|
18706
|
+
})
|
|
18707
|
+
},
|
|
18708
|
+
floating: {
|
|
18709
|
+
...floatingProps,
|
|
18710
|
+
...(role === 'menu' && {
|
|
18711
|
+
'aria-labelledby': referenceId
|
|
18712
|
+
})
|
|
18713
|
+
}
|
|
18714
|
+
};
|
|
18715
|
+
}, [enabled, role, open, floatingId, referenceId]);
|
|
18716
|
+
}
|
|
18647
18717
|
|
|
18648
18718
|
/**
|
|
18649
18719
|
* The hook that powers the Popover component.
|
|
@@ -18781,7 +18851,7 @@ const PopoverTrigger = React.forwardRef(function PopoverTrigger(_a, propRef) {
|
|
|
18781
18851
|
* @returns {JSX.Element} DayPickerPopover component
|
|
18782
18852
|
*/
|
|
18783
18853
|
const DayPickerPopover = ({ disabledDays, className, dataTestId, selectedDay, onDaySelect, color = "secondary", placement, size = "small", buttonContent, language, }) => {
|
|
18784
|
-
return (jsxRuntime.jsxs(Popover, { placement: placement, children: [jsxRuntime.jsx(PopoverTrigger, { children: jsxRuntime.jsx(Button$1, { color: color, size: size, className: className, prefix: jsxRuntime.jsx(Icon, { name: "
|
|
18854
|
+
return (jsxRuntime.jsxs(Popover, { placement: placement, children: [jsxRuntime.jsx(PopoverTrigger, { children: jsxRuntime.jsx(Button$1, { color: color, size: size, className: className, prefix: jsxRuntime.jsx(Icon, { name: "Calendar", size: "small" }), dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "show-day-picker", children: buttonContent }) }), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsx(Card, { children: jsxRuntime.jsx(DayPicker, { disabledDays: disabledDays, onDaySelect: onDaySelect, selectedDays: selectedDay, language: language }) }) })] }));
|
|
18785
18855
|
};
|
|
18786
18856
|
|
|
18787
18857
|
/**
|
|
@@ -36830,7 +36900,7 @@ const cvaMoreMenu = cssClassVarianceUtilities.cvaMerge(["p-4"]);
|
|
|
36830
36900
|
*/
|
|
36831
36901
|
const MoreMenu = ({ className, dataTestId, menuPlacement, iconProps = {
|
|
36832
36902
|
size: "medium",
|
|
36833
|
-
name: "
|
|
36903
|
+
name: "EllipsisHorizontal",
|
|
36834
36904
|
}, iconButtonProps = {
|
|
36835
36905
|
size: "small",
|
|
36836
36906
|
circular: true,
|
|
@@ -37253,7 +37323,7 @@ const Tag = React__namespace.forwardRef((_a, ref) => {
|
|
|
37253
37323
|
var { className, dataTestId, children, size = "medium", onClose, color = "primary", disabled = false } = _a; __rest$1(_a, ["className", "dataTestId", "children", "size", "onClose", "color", "disabled"]);
|
|
37254
37324
|
return (jsxRuntime.jsxs("span", { className: cvaTag({ className, size, color, layout: Boolean(onClose) ? "withIcon" : "default" }), "data-testid": dataTestId && `${dataTestId}-tag`, ref: ref, children: [children, Boolean(onClose) && !disabled && (
|
|
37255
37325
|
// a fix for multiselect deselecting tags working together with fade out animation
|
|
37256
|
-
jsxRuntime.jsx("div", { className: cvaTagIconContainer(), onMouseDown: onClose, children: jsxRuntime.jsx(Icon, { name: "
|
|
37326
|
+
jsxRuntime.jsx("div", { className: cvaTagIconContainer(), onMouseDown: onClose, children: jsxRuntime.jsx(Icon, { name: "XCircle", dataTestId: dataTestId + "Icon", type: "solid", size: size, style: { WebkitTransition: "-webkit-transform 0.150s" }, className: cvaTagIcon() }) }))] }));
|
|
37257
37327
|
});
|
|
37258
37328
|
|
|
37259
37329
|
const cvaTip = cssClassVarianceUtilities.cvaMerge("flex transition text-slate-300 hover:text-slate-500");
|
|
@@ -37277,7 +37347,7 @@ const cvaTipContent = cssClassVarianceUtilities.cvaMerge("p-2 rounded max-w-sm f
|
|
|
37277
37347
|
* @returns {JSX.Element} Tip component
|
|
37278
37348
|
*/
|
|
37279
37349
|
const Tip = ({ children, iconProps, dataTestId, className, placement = "bottom", mode = "dark", link, }) => {
|
|
37280
|
-
return (jsxRuntime.jsx("span", { "data-testid": dataTestId, className: cvaTip({ className }), children: jsxRuntime.jsxs(Popover, { placement: placement, activation: { click: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "", children: [jsxRuntime.jsx(PopoverTrigger, { children: jsxRuntime.jsx("div", { "data-testid": dataTestId && `${dataTestId}-trigger`, children: jsxRuntime.jsx(Icon, Object.assign({ name: "
|
|
37350
|
+
return (jsxRuntime.jsx("span", { "data-testid": dataTestId, className: cvaTip({ className }), children: jsxRuntime.jsxs(Popover, { placement: placement, activation: { click: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "", children: [jsxRuntime.jsx(PopoverTrigger, { children: jsxRuntime.jsx("div", { "data-testid": dataTestId && `${dataTestId}-trigger`, children: jsxRuntime.jsx(Icon, Object.assign({ name: "QuestionMarkCircle", size: "medium", dataTestId: dataTestId && `${dataTestId}-icon` }, iconProps)) }) }), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs("div", { className: cvaTipContent({ color: mode }), children: [jsxRuntime.jsx("div", { children: typeof children === "string" ? jsxRuntime.jsx("p", { children: children }) : children }), link ? (jsxRuntime.jsx("a", { href: link, children: jsxRuntime.jsx(Icon, { name: "ArrowRightCircle" }) })) : null] }) })] }) }));
|
|
37281
37351
|
};
|
|
37282
37352
|
|
|
37283
37353
|
const cvaPageHeader = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -37315,7 +37385,7 @@ const cvaPageHeaderChildContainer = cssClassVarianceUtilities.cvaMerge(["flex",
|
|
|
37315
37385
|
* @returns {JSX.Element} PageHeader component
|
|
37316
37386
|
*/
|
|
37317
37387
|
const PageHeader = ({ className, dataTestId, action, showLoading, description, link, title, tag, backTo, tagColor, children, }) => {
|
|
37318
|
-
return (jsxRuntime.jsxs("div", { className: cvaPageHeader({ className: `${className} tu-page-header` }), "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId && `${dataTestId}-heading-container`, children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo && (jsxRuntime.jsx(IconButton, { to: backTo, color: "tertiary", variant: "transparent", size: "small", icon: jsxRuntime.jsx(Icon, { name: "
|
|
37388
|
+
return (jsxRuntime.jsxs("div", { className: cvaPageHeader({ className: `${className} tu-page-header` }), "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId && `${dataTestId}-heading-container`, children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo && (jsxRuntime.jsx(IconButton, { to: backTo, color: "tertiary", variant: "transparent", size: "small", icon: jsxRuntime.jsx(Icon, { name: "ArrowLeft" }) })), jsxRuntime.jsx("h1", { className: cvaPageHeaderHeading(), "data-testid": dataTestId && `${dataTestId}-heading`, children: title }), description && !showLoading && (jsxRuntime.jsx(Tip, { dataTestId: dataTestId && `${dataTestId}-tip`, iconProps: { name: "QuestionMarkCircle" }, link: link, children: description }))] }), tag && !showLoading && jsxRuntime.jsx(Tag, { dataTestId: dataTestId, color: tagColor, children: tag }), showLoading && jsxRuntime.jsx(Spinner, { dataTestId: dataTestId && `${dataTestId}-spinner`, centering: "vertically" }), action] }), jsxRuntime.jsx("div", { className: cvaPageHeaderChildContainer(), children: children })] }));
|
|
37319
37389
|
};
|
|
37320
37390
|
|
|
37321
37391
|
const cvaPagination = cssClassVarianceUtilities.cvaMerge(["flex", "items-center", "gap-1"]);
|
|
@@ -37364,9 +37434,9 @@ const Pagination = ({ previousPage, nextPage, canPreviousPage, canNextPage, page
|
|
|
37364
37434
|
if (loading) {
|
|
37365
37435
|
return (jsxRuntime.jsx("div", { className: cvaPagination({ className }), children: jsxRuntime.jsx(SkeletonLines, { height: 16, width: 150 }) }));
|
|
37366
37436
|
}
|
|
37367
|
-
return (jsxRuntime.jsxs("div", { "data-testid": dataTestId, className: cvaPagination({ className }), children: [jsxRuntime.jsx(IconButton, { onClick: () => handlePageChange("prev"), disabled: cursorBase ? !canPreviousPage || false : page !== undefined && page <= 0, "data-testid": "prev-page", icon: jsxRuntime.jsx(Icon, { name: "
|
|
37437
|
+
return (jsxRuntime.jsxs("div", { "data-testid": dataTestId, className: cvaPagination({ className }), children: [jsxRuntime.jsx(IconButton, { onClick: () => handlePageChange("prev"), disabled: cursorBase ? !canPreviousPage || false : page !== undefined && page <= 0, "data-testid": "prev-page", icon: jsxRuntime.jsx(Icon, { name: "ChevronLeft", size: "small" }), size: "small", color: "secondary", variant: "transparent" }), !cursorBase && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: cvaPaginationText(), "data-testid": "current-page", children: currentPage }), jsxRuntime.jsx("div", { className: cvaPaginationText(), "data-testid": "page-count", children: pageCount !== null && pageCount !== undefined && getTranslatedCount && getTranslatedCount(pageCount) })] })), jsxRuntime.jsx(IconButton, { onClick: () => handlePageChange("next"), disabled: cursorBase
|
|
37368
37438
|
? !canNextPage || false
|
|
37369
|
-
: page !== undefined && pageCount !== undefined && pageCount !== null && page >= pageCount - 1, "data-testid": "next-page", icon: jsxRuntime.jsx(Icon, { name: "
|
|
37439
|
+
: page !== undefined && pageCount !== undefined && pageCount !== null && page >= pageCount - 1, "data-testid": "next-page", icon: jsxRuntime.jsx(Icon, { name: "ChevronRight", size: "small" }), size: "small", color: "secondary", variant: "transparent" })] }));
|
|
37370
37440
|
};
|
|
37371
37441
|
|
|
37372
37442
|
function useConfirmExit(confirmExit, when = true) {
|
|
@@ -38948,7 +39018,7 @@ const Timeline = ({ className, dataTestId, children }) => {
|
|
|
38948
39018
|
* @param {TimeLineElementProps} props the props
|
|
38949
39019
|
* @returns {JSX.Element} component
|
|
38950
39020
|
*/
|
|
38951
|
-
const TimelineElement = ({ date, showTime, children, className, dataTestId = "timeline-date", headerClassName, dot = jsxRuntime.jsx(Indicator, { className: "mt-[-1px]", color: "neutral", icon: jsxRuntime.jsx(Icon, { name: "
|
|
39021
|
+
const TimelineElement = ({ date, showTime, children, className, dataTestId = "timeline-date", headerClassName, dot = jsxRuntime.jsx(Indicator, { className: "mt-[-1px]", color: "neutral", icon: jsxRuntime.jsx(Icon, { name: "Calendar", size: "large" }) }), header = defaultHeader(date, showTime), onClick, }) => {
|
|
38952
39022
|
return (jsxRuntime.jsxs("li", { className: cvaTimelineElement({ className }), "data-date": `${date}`, "data-testid": dataTestId && `${dataTestId}`, onClick: () => onClick && onClick(), children: [jsxRuntime.jsx("div", { className: cvaTimelineDot(), children: dot }), jsxRuntime.jsx("div", { children: header }), jsxRuntime.jsx("div", {}), jsxRuntime.jsx("div", { children: jsxRuntime.jsx("div", { children: children }) })] }));
|
|
38953
39023
|
};
|
|
38954
39024
|
function defaultHeader(date, showTime) {
|
|
@@ -39153,6 +39223,8 @@ exports.cvaMenuItemSuffix = cvaMenuItemSuffix;
|
|
|
39153
39223
|
exports.docs = docs;
|
|
39154
39224
|
exports.getDevicePixelRatio = getDevicePixelRatio;
|
|
39155
39225
|
exports.getValueBarColorByValue = getValueBarColorByValue;
|
|
39226
|
+
exports.iconColorNames = iconColorNames;
|
|
39227
|
+
exports.iconPalette = iconPalette;
|
|
39156
39228
|
exports.setLocalStorage = setLocalStorage;
|
|
39157
39229
|
exports.useClickOutside = useClickOutside;
|
|
39158
39230
|
exports.useContainerProps = useContainerProps;
|