@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.esm.js
CHANGED
|
@@ -2,8 +2,10 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useRef, useCallback, useEffect, useState, useLayoutEffect, useMemo, createContext, forwardRef, useContext, isValidElement, cloneElement, memo, Children, useReducer, Component } from 'react';
|
|
4
4
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { rentalStatusPalette, intentPalette, generalPalette, criticalityPalette, activityPalette, utilizationPalette, sitesPalette, color } from '@trackunit/ui-design-tokens';
|
|
6
|
+
import { iconNames } from '@trackunit/ui-icons';
|
|
7
|
+
import IconSpriteOutline from '@trackunit/ui-icons/icons-sprite-outline.svg';
|
|
8
|
+
import IconSpriteSolid from '@trackunit/ui-icons/icons-sprite-solid.svg';
|
|
7
9
|
import * as ReactDOM from 'react-dom';
|
|
8
10
|
import ReactDOM__default, { createPortal } from 'react-dom';
|
|
9
11
|
import { UNSAFE_NavigationContext } from 'react-router-dom';
|
|
@@ -399,7 +401,7 @@ const cvaIcon = cvaMerge(["aspect-square", "inline-grid", "relative"], {
|
|
|
399
401
|
size: "large",
|
|
400
402
|
},
|
|
401
403
|
});
|
|
402
|
-
|
|
404
|
+
cvaMerge([], {
|
|
403
405
|
variants: {
|
|
404
406
|
iconType: {
|
|
405
407
|
solid: "fill-current stroke-transparent",
|
|
@@ -407,7 +409,7 @@ const cvaIconComponent = cvaMerge([], {
|
|
|
407
409
|
},
|
|
408
410
|
},
|
|
409
411
|
});
|
|
410
|
-
|
|
412
|
+
cvaMerge([
|
|
411
413
|
"relative",
|
|
412
414
|
"aspect-square",
|
|
413
415
|
"after:content-['']",
|
|
@@ -422,30 +424,27 @@ const cvaLoadingDot = cvaMerge([
|
|
|
422
424
|
"after:opacity-50",
|
|
423
425
|
]);
|
|
424
426
|
|
|
427
|
+
const iconPalette = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, intentPalette), generalPalette), criticalityPalette), activityPalette), utilizationPalette), sitesPalette), rentalStatusPalette);
|
|
428
|
+
const iconColorNames = Object.keys(iconPalette).map(key => key.toLowerCase()); // This users the object in the Object.keys() to infer the type of the keys.
|
|
425
429
|
/**
|
|
426
430
|
* - The Icon component is used to display an Icon.
|
|
427
431
|
* - Icons are semantic vector graphics that adds character and improves the visual appeal of elements when combined with.
|
|
428
|
-
* - All the [HeroIcons](https://heroicons.dev/) as well as custom
|
|
432
|
+
* - All the [HeroIcons](https://heroicons.dev/) as well as custom Trackunit icons are available.
|
|
429
433
|
*
|
|
430
434
|
* @param {IconProps} props - The props for the Icon component
|
|
431
435
|
* @returns {JSX.Element} Icon component
|
|
432
436
|
*/
|
|
433
437
|
const Icon = ({ name, size = "large", className, dataTestId, color, onClick, fillColor, type, style, forwardedRef, }) => {
|
|
434
438
|
const correctIconType = React.useMemo(() => (type ? type : size === "large" ? "outline" : "solid"), [type, size]);
|
|
435
|
-
|
|
436
|
-
if (
|
|
437
|
-
IconComponent = heroIconLookup(name, correctIconType);
|
|
438
|
-
}
|
|
439
|
-
else if (TrackunitSolidIconsArray.find(icon => icon === name) ||
|
|
440
|
-
TrackunitOutlineIconsArray.find(icon => icon === name)) {
|
|
441
|
-
IconComponent = trackunitIconLookup(name, correctIconType);
|
|
442
|
-
}
|
|
443
|
-
if (!IconComponent) {
|
|
439
|
+
const iconName = iconNames[name];
|
|
440
|
+
if (!iconName) {
|
|
444
441
|
return null;
|
|
445
442
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
443
|
+
const href = {
|
|
444
|
+
solid: `${IconSpriteSolid}#${iconName}`,
|
|
445
|
+
outline: `${IconSpriteOutline}#${iconName}`,
|
|
446
|
+
};
|
|
447
|
+
return (jsx("span", { className: cvaIcon({ color, size, className }), onClick: onClick, "data-testid": dataTestId, ref: forwardedRef, children: 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: jsx("use", { href: href[correctIconType] }) }) }));
|
|
449
448
|
};
|
|
450
449
|
|
|
451
450
|
/**
|
|
@@ -455,7 +454,7 @@ const Icon = ({ name, size = "large", className, dataTestId, color, onClick, fil
|
|
|
455
454
|
* @returns {JSX.Element} StarButton component
|
|
456
455
|
*/
|
|
457
456
|
const StarButton = ({ starred, onClick }) => {
|
|
458
|
-
return (jsx("div", { onClick: onClick, "data-test-id": "starred-filter", children: jsx(Icon, { name: "
|
|
457
|
+
return (jsx("div", { onClick: onClick, "data-test-id": "starred-filter", children: jsx(Icon, { name: "Star", color: starred ? "primary" : "neutral", type: starred ? "solid" : "outline", size: "medium" }) }));
|
|
459
458
|
};
|
|
460
459
|
|
|
461
460
|
const cvaText = cvaMerge(["m-0", "relative", "text-sm", "font-normal"], {
|
|
@@ -597,13 +596,13 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
597
596
|
const getIconFromColor = () => {
|
|
598
597
|
switch (color) {
|
|
599
598
|
case "danger":
|
|
600
|
-
return jsx(Icon, { name: "
|
|
599
|
+
return jsx(Icon, { name: "ExclamationTriangle", color: "danger" });
|
|
601
600
|
case "warning":
|
|
602
|
-
return jsx(Icon, { name: "
|
|
601
|
+
return jsx(Icon, { name: "ExclamationCircle", color: "warning" });
|
|
603
602
|
case "success":
|
|
604
|
-
return jsx(Icon, { name: "
|
|
603
|
+
return jsx(Icon, { name: "CheckCircle", color: "success" });
|
|
605
604
|
default:
|
|
606
|
-
return jsx(Icon, { name: "
|
|
605
|
+
return jsx(Icon, { name: "InformationCircle" });
|
|
607
606
|
}
|
|
608
607
|
};
|
|
609
608
|
const getButtonColor = () => {
|
|
@@ -623,7 +622,7 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
623
622
|
}
|
|
624
623
|
}, [ref, autoScroll]);
|
|
625
624
|
const layout = inline ? "inline" : "default";
|
|
626
|
-
return (jsxs("div", { className: cvaAlert({ color, layout, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsx("div", { className: cvaAlertIconContainer({ layout }), children: getIconFromColor() }), jsxs("div", { className: cvaAlertContent({ layout }), children: [jsxs("div", { className: cvaAlertDetails(), children: [jsx("div", { className: cvaAlertContentBody(), children: body }), onClose && !inline ? (jsx("div", { className: cvaAlertCloseButtonContainer({ layout }), children: jsx(IconButton, { size: "small", variant: "transparent", color: "secondary", onClick: onClose, icon: jsx(Icon, { name: "
|
|
625
|
+
return (jsxs("div", { className: cvaAlert({ color, layout, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsx("div", { className: cvaAlertIconContainer({ layout }), children: getIconFromColor() }), jsxs("div", { className: cvaAlertContent({ layout }), children: [jsxs("div", { className: cvaAlertDetails(), children: [jsx("div", { className: cvaAlertContentBody(), children: body }), onClose && !inline ? (jsx("div", { className: cvaAlertCloseButtonContainer({ layout }), children: jsx(IconButton, { size: "small", variant: "transparent", color: "secondary", onClick: onClose, icon: jsx(Icon, { name: "XMark", size: "small" }), title: "Close Alert", circular: true }) })) : null] }), (primaryAction || secondaryAction || onClose) && (jsxs("div", { className: cvaAlertRightAligned({ layout }), children: [secondaryAction && (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 && (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 ? (jsx("div", { className: cvaAlertCloseButtonContainer({ layout }), children: jsx(IconButton, { size: "small", variant: "transparent", color: "secondary", onClick: onClose, icon: jsx(Icon, { name: "XMark", size: "small" }), title: "Close Alert", circular: true }) })) : null] }))] })] }));
|
|
627
626
|
};
|
|
628
627
|
|
|
629
628
|
const cvaBadge = cvaMerge([
|
|
@@ -855,7 +854,7 @@ const Heading = (_a) => {
|
|
|
855
854
|
* @returns {JSX.Element} CardHeader component
|
|
856
855
|
*/
|
|
857
856
|
const CardHeader = ({ heading, headingVariant = "primary", subHeading, onClose, dataTestId, className, children, accessories, density, extraClassName, hideSeparator = false, }) => {
|
|
858
|
-
return (jsx(DensityContainer, { dataTestId: dataTestId, className: cvaCardHeaderDensityContainer({ border: hideSeparator ? "borderless" : "default", className }), density: density, children: jsxs("div", { className: cvaCardHeader(), children: [jsxs("div", { className: extraClassName, children: [jsxs("div", { className: cvaCardHeaderHeadingContainer(), children: [jsx(Heading, { className: "self-center", variant: headingVariant, children: heading }), accessories] }), subHeading && (jsx(Heading, { subtle: true, variant: "subtitle", children: subHeading })), children] }), onClose && (jsx(IconButton, { dataTestId: "card-header-close-button", variant: "transparent", color: "secondary", onClick: onClose, icon: jsx(Icon, { name: "
|
|
857
|
+
return (jsx(DensityContainer, { dataTestId: dataTestId, className: cvaCardHeaderDensityContainer({ border: hideSeparator ? "borderless" : "default", className }), density: density, children: jsxs("div", { className: cvaCardHeader(), children: [jsxs("div", { className: extraClassName, children: [jsxs("div", { className: cvaCardHeaderHeadingContainer(), children: [jsx(Heading, { className: "self-center", variant: headingVariant, children: heading }), accessories] }), subHeading && (jsx(Heading, { subtle: true, variant: "subtitle", children: subHeading })), children] }), onClose && (jsx(IconButton, { dataTestId: "card-header-close-button", variant: "transparent", color: "secondary", onClick: onClose, icon: jsx(Icon, { name: "XMark", size: "small" }), className: "!h-min" }))] }) }));
|
|
859
858
|
};
|
|
860
859
|
|
|
861
860
|
function useMountedState() {
|
|
@@ -1194,7 +1193,7 @@ const Collapse = ({ id, initialExpanded = false, onToggle, label, children, layo
|
|
|
1194
1193
|
}
|
|
1195
1194
|
setExpanded(!expanded);
|
|
1196
1195
|
}, [expanded, onToggle]);
|
|
1197
|
-
return (jsxs("div", { className: cvaCollapse({ className }), "data-testid": dataTestId, children: [jsx("div", { className: cvaCollapseLabel(), role: "button", "aria-expanded": expanded, "aria-controls": id, onClick: handleClick, children: jsxs("div", { className: cvaCollapseLabelContainer({ layout }), children: [jsx(Text, { type: "span", weight: "bold", children: label }), jsx(IconButton, { icon: jsx(Icon, { className: cvaCollapseIcon({ expanded }), name: "
|
|
1196
|
+
return (jsxs("div", { className: cvaCollapse({ className }), "data-testid": dataTestId, children: [jsx("div", { className: cvaCollapseLabel(), role: "button", "aria-expanded": expanded, "aria-controls": id, onClick: handleClick, children: jsxs("div", { className: cvaCollapseLabelContainer({ layout }), children: [jsx(Text, { type: "span", weight: "bold", children: label }), jsx(IconButton, { icon: jsx(Icon, { className: cvaCollapseIcon({ expanded }), name: "ChevronDown", size: "small" }), size: "medium", variant: "transparent", color: "secondary" })] }) }), jsx(Collapsible, { expanded: expanded, id: id, children: children })] }));
|
|
1198
1197
|
};
|
|
1199
1198
|
const Collapsible = ({ children, expanded, id }) => {
|
|
1200
1199
|
const [ref, { height }] = useMeasure$1();
|
|
@@ -1860,7 +1859,7 @@ function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "func
|
|
|
1860
1859
|
* //=> Sun Jul 02 1995 00:00:00
|
|
1861
1860
|
*/
|
|
1862
1861
|
|
|
1863
|
-
function max$
|
|
1862
|
+
function max$1(dirtyDatesArray) {
|
|
1864
1863
|
requiredArgs(1, arguments);
|
|
1865
1864
|
var datesArray; // `dirtyDatesArray` is Array, Set or Map, or object with custom `forEach` method
|
|
1866
1865
|
|
|
@@ -1908,7 +1907,7 @@ function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "func
|
|
|
1908
1907
|
* //=> Wed Feb 11 1987 00:00:00
|
|
1909
1908
|
*/
|
|
1910
1909
|
|
|
1911
|
-
function min$
|
|
1910
|
+
function min$1(dirtyDatesArray) {
|
|
1912
1911
|
requiredArgs(1, arguments);
|
|
1913
1912
|
var datesArray; // `dirtyDatesArray` is Array, Set or Map, or object with custom `forEach` method
|
|
1914
1913
|
|
|
@@ -13920,10 +13919,10 @@ function getNextFocus(focusedDay, options) {
|
|
|
13920
13919
|
};
|
|
13921
13920
|
var newFocusedDay = moveFns[moveBy](focusedDay, direction === 'after' ? 1 : -1);
|
|
13922
13921
|
if (direction === 'before' && fromDate) {
|
|
13923
|
-
newFocusedDay = max$
|
|
13922
|
+
newFocusedDay = max$1([fromDate, newFocusedDay]);
|
|
13924
13923
|
}
|
|
13925
13924
|
else if (direction === 'after' && toDate) {
|
|
13926
|
-
newFocusedDay = min$
|
|
13925
|
+
newFocusedDay = min$1([toDate, newFocusedDay]);
|
|
13927
13926
|
}
|
|
13928
13927
|
var isFocusable = true;
|
|
13929
13928
|
if (modifiers) {
|
|
@@ -14785,330 +14784,68 @@ const DayPicker = ({ onDaySelect, disabledDays, selectedDays, language, classNam
|
|
|
14785
14784
|
return (jsx(DayPicker$1, { onDayClick: onDaySelect, selected: selectedDays, locale: locale, disabled: disabledDays, className: `custom-day-picker ${className !== null && className !== void 0 ? className : ""}`, max: max, footer: jsx("div", { "data-testid": dataTestId }) }));
|
|
14786
14785
|
};
|
|
14787
14786
|
|
|
14788
|
-
|
|
14789
|
-
|
|
14787
|
+
const min = Math.min;
|
|
14788
|
+
const max = Math.max;
|
|
14789
|
+
const round = Math.round;
|
|
14790
|
+
const floor = Math.floor;
|
|
14791
|
+
const createCoords = v => ({
|
|
14792
|
+
x: v,
|
|
14793
|
+
y: v
|
|
14794
|
+
});
|
|
14795
|
+
const oppositeSideMap = {
|
|
14796
|
+
left: 'right',
|
|
14797
|
+
right: 'left',
|
|
14798
|
+
bottom: 'top',
|
|
14799
|
+
top: 'bottom'
|
|
14800
|
+
};
|
|
14801
|
+
const oppositeAlignmentMap = {
|
|
14802
|
+
start: 'end',
|
|
14803
|
+
end: 'start'
|
|
14804
|
+
};
|
|
14805
|
+
function clamp(start, value, end) {
|
|
14806
|
+
return max(start, min(value, end));
|
|
14790
14807
|
}
|
|
14791
|
-
|
|
14792
|
-
function
|
|
14793
|
-
return axis === 'y' ? 'height' : 'width';
|
|
14808
|
+
function evaluate(value, param) {
|
|
14809
|
+
return typeof value === 'function' ? value(param) : value;
|
|
14794
14810
|
}
|
|
14795
|
-
|
|
14796
14811
|
function getSide(placement) {
|
|
14797
14812
|
return placement.split('-')[0];
|
|
14798
14813
|
}
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
14802
|
-
}
|
|
14803
|
-
|
|
14804
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
14805
|
-
let {
|
|
14806
|
-
reference,
|
|
14807
|
-
floating
|
|
14808
|
-
} = _ref;
|
|
14809
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
14810
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
14811
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
14812
|
-
const length = getLengthFromAxis(mainAxis);
|
|
14813
|
-
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
14814
|
-
const side = getSide(placement);
|
|
14815
|
-
const isVertical = mainAxis === 'x';
|
|
14816
|
-
let coords;
|
|
14817
|
-
switch (side) {
|
|
14818
|
-
case 'top':
|
|
14819
|
-
coords = {
|
|
14820
|
-
x: commonX,
|
|
14821
|
-
y: reference.y - floating.height
|
|
14822
|
-
};
|
|
14823
|
-
break;
|
|
14824
|
-
case 'bottom':
|
|
14825
|
-
coords = {
|
|
14826
|
-
x: commonX,
|
|
14827
|
-
y: reference.y + reference.height
|
|
14828
|
-
};
|
|
14829
|
-
break;
|
|
14830
|
-
case 'right':
|
|
14831
|
-
coords = {
|
|
14832
|
-
x: reference.x + reference.width,
|
|
14833
|
-
y: commonY
|
|
14834
|
-
};
|
|
14835
|
-
break;
|
|
14836
|
-
case 'left':
|
|
14837
|
-
coords = {
|
|
14838
|
-
x: reference.x - floating.width,
|
|
14839
|
-
y: commonY
|
|
14840
|
-
};
|
|
14841
|
-
break;
|
|
14842
|
-
default:
|
|
14843
|
-
coords = {
|
|
14844
|
-
x: reference.x,
|
|
14845
|
-
y: reference.y
|
|
14846
|
-
};
|
|
14847
|
-
}
|
|
14848
|
-
switch (getAlignment(placement)) {
|
|
14849
|
-
case 'start':
|
|
14850
|
-
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
14851
|
-
break;
|
|
14852
|
-
case 'end':
|
|
14853
|
-
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
14854
|
-
break;
|
|
14855
|
-
}
|
|
14856
|
-
return coords;
|
|
14857
|
-
}
|
|
14858
|
-
|
|
14859
|
-
/**
|
|
14860
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
14861
|
-
* next to a reference element when it is given a certain positioning strategy.
|
|
14862
|
-
*
|
|
14863
|
-
* This export does not have any `platform` interface logic. You will need to
|
|
14864
|
-
* write one for the platform you are using Floating UI with.
|
|
14865
|
-
*/
|
|
14866
|
-
const computePosition$1 = async (reference, floating, config) => {
|
|
14867
|
-
const {
|
|
14868
|
-
placement = 'bottom',
|
|
14869
|
-
strategy = 'absolute',
|
|
14870
|
-
middleware = [],
|
|
14871
|
-
platform
|
|
14872
|
-
} = config;
|
|
14873
|
-
const validMiddleware = middleware.filter(Boolean);
|
|
14874
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
14875
|
-
if (process.env.NODE_ENV !== "production") {
|
|
14876
|
-
if (platform == null) {
|
|
14877
|
-
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(' '));
|
|
14878
|
-
}
|
|
14879
|
-
if (validMiddleware.filter(_ref => {
|
|
14880
|
-
let {
|
|
14881
|
-
name
|
|
14882
|
-
} = _ref;
|
|
14883
|
-
return name === 'autoPlacement' || name === 'flip';
|
|
14884
|
-
}).length > 1) {
|
|
14885
|
-
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(' '));
|
|
14886
|
-
}
|
|
14887
|
-
if (!reference || !floating) {
|
|
14888
|
-
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(' '));
|
|
14889
|
-
}
|
|
14890
|
-
}
|
|
14891
|
-
let rects = await platform.getElementRects({
|
|
14892
|
-
reference,
|
|
14893
|
-
floating,
|
|
14894
|
-
strategy
|
|
14895
|
-
});
|
|
14896
|
-
let {
|
|
14897
|
-
x,
|
|
14898
|
-
y
|
|
14899
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
14900
|
-
let statefulPlacement = placement;
|
|
14901
|
-
let middlewareData = {};
|
|
14902
|
-
let resetCount = 0;
|
|
14903
|
-
for (let i = 0; i < validMiddleware.length; i++) {
|
|
14904
|
-
const {
|
|
14905
|
-
name,
|
|
14906
|
-
fn
|
|
14907
|
-
} = validMiddleware[i];
|
|
14908
|
-
const {
|
|
14909
|
-
x: nextX,
|
|
14910
|
-
y: nextY,
|
|
14911
|
-
data,
|
|
14912
|
-
reset
|
|
14913
|
-
} = await fn({
|
|
14914
|
-
x,
|
|
14915
|
-
y,
|
|
14916
|
-
initialPlacement: placement,
|
|
14917
|
-
placement: statefulPlacement,
|
|
14918
|
-
strategy,
|
|
14919
|
-
middlewareData,
|
|
14920
|
-
rects,
|
|
14921
|
-
platform,
|
|
14922
|
-
elements: {
|
|
14923
|
-
reference,
|
|
14924
|
-
floating
|
|
14925
|
-
}
|
|
14926
|
-
});
|
|
14927
|
-
x = nextX != null ? nextX : x;
|
|
14928
|
-
y = nextY != null ? nextY : y;
|
|
14929
|
-
middlewareData = {
|
|
14930
|
-
...middlewareData,
|
|
14931
|
-
[name]: {
|
|
14932
|
-
...middlewareData[name],
|
|
14933
|
-
...data
|
|
14934
|
-
}
|
|
14935
|
-
};
|
|
14936
|
-
if (process.env.NODE_ENV !== "production") {
|
|
14937
|
-
if (resetCount > 50) {
|
|
14938
|
-
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(' '));
|
|
14939
|
-
}
|
|
14940
|
-
}
|
|
14941
|
-
if (reset && resetCount <= 50) {
|
|
14942
|
-
resetCount++;
|
|
14943
|
-
if (typeof reset === 'object') {
|
|
14944
|
-
if (reset.placement) {
|
|
14945
|
-
statefulPlacement = reset.placement;
|
|
14946
|
-
}
|
|
14947
|
-
if (reset.rects) {
|
|
14948
|
-
rects = reset.rects === true ? await platform.getElementRects({
|
|
14949
|
-
reference,
|
|
14950
|
-
floating,
|
|
14951
|
-
strategy
|
|
14952
|
-
}) : reset.rects;
|
|
14953
|
-
}
|
|
14954
|
-
({
|
|
14955
|
-
x,
|
|
14956
|
-
y
|
|
14957
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
14958
|
-
}
|
|
14959
|
-
i = -1;
|
|
14960
|
-
continue;
|
|
14961
|
-
}
|
|
14962
|
-
}
|
|
14963
|
-
return {
|
|
14964
|
-
x,
|
|
14965
|
-
y,
|
|
14966
|
-
placement: statefulPlacement,
|
|
14967
|
-
strategy,
|
|
14968
|
-
middlewareData
|
|
14969
|
-
};
|
|
14970
|
-
};
|
|
14971
|
-
|
|
14972
|
-
function expandPaddingObject(padding) {
|
|
14973
|
-
return {
|
|
14974
|
-
top: 0,
|
|
14975
|
-
right: 0,
|
|
14976
|
-
bottom: 0,
|
|
14977
|
-
left: 0,
|
|
14978
|
-
...padding
|
|
14979
|
-
};
|
|
14980
|
-
}
|
|
14981
|
-
|
|
14982
|
-
function getSideObjectFromPadding(padding) {
|
|
14983
|
-
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
14984
|
-
top: padding,
|
|
14985
|
-
right: padding,
|
|
14986
|
-
bottom: padding,
|
|
14987
|
-
left: padding
|
|
14988
|
-
};
|
|
14814
|
+
function getAlignment(placement) {
|
|
14815
|
+
return placement.split('-')[1];
|
|
14989
14816
|
}
|
|
14990
|
-
|
|
14991
|
-
|
|
14992
|
-
return {
|
|
14993
|
-
...rect,
|
|
14994
|
-
top: rect.y,
|
|
14995
|
-
left: rect.x,
|
|
14996
|
-
right: rect.x + rect.width,
|
|
14997
|
-
bottom: rect.y + rect.height
|
|
14998
|
-
};
|
|
14817
|
+
function getOppositeAxis(axis) {
|
|
14818
|
+
return axis === 'x' ? 'y' : 'x';
|
|
14999
14819
|
}
|
|
15000
|
-
|
|
15001
|
-
|
|
15002
|
-
* Resolves with an object of overflow side offsets that determine how much the
|
|
15003
|
-
* element is overflowing a given clipping boundary on each side.
|
|
15004
|
-
* - positive = overflowing the boundary by that number of pixels
|
|
15005
|
-
* - negative = how many pixels left before it will overflow
|
|
15006
|
-
* - 0 = lies flush with the boundary
|
|
15007
|
-
* @see https://floating-ui.com/docs/detectOverflow
|
|
15008
|
-
*/
|
|
15009
|
-
async function detectOverflow(state, options) {
|
|
15010
|
-
var _await$platform$isEle;
|
|
15011
|
-
if (options === void 0) {
|
|
15012
|
-
options = {};
|
|
15013
|
-
}
|
|
15014
|
-
const {
|
|
15015
|
-
x,
|
|
15016
|
-
y,
|
|
15017
|
-
platform,
|
|
15018
|
-
rects,
|
|
15019
|
-
elements,
|
|
15020
|
-
strategy
|
|
15021
|
-
} = state;
|
|
15022
|
-
const {
|
|
15023
|
-
boundary = 'clippingAncestors',
|
|
15024
|
-
rootBoundary = 'viewport',
|
|
15025
|
-
elementContext = 'floating',
|
|
15026
|
-
altBoundary = false,
|
|
15027
|
-
padding = 0
|
|
15028
|
-
} = options;
|
|
15029
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
15030
|
-
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
15031
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
15032
|
-
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
15033
|
-
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))),
|
|
15034
|
-
boundary,
|
|
15035
|
-
rootBoundary,
|
|
15036
|
-
strategy
|
|
15037
|
-
}));
|
|
15038
|
-
const rect = elementContext === 'floating' ? {
|
|
15039
|
-
...rects.floating,
|
|
15040
|
-
x,
|
|
15041
|
-
y
|
|
15042
|
-
} : rects.reference;
|
|
15043
|
-
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
15044
|
-
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
15045
|
-
x: 1,
|
|
15046
|
-
y: 1
|
|
15047
|
-
} : {
|
|
15048
|
-
x: 1,
|
|
15049
|
-
y: 1
|
|
15050
|
-
};
|
|
15051
|
-
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
15052
|
-
rect,
|
|
15053
|
-
offsetParent,
|
|
15054
|
-
strategy
|
|
15055
|
-
}) : rect);
|
|
15056
|
-
if (process.env.NODE_ENV !== "production") ;
|
|
15057
|
-
return {
|
|
15058
|
-
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
15059
|
-
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
15060
|
-
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
15061
|
-
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
15062
|
-
};
|
|
14820
|
+
function getAxisLength(axis) {
|
|
14821
|
+
return axis === 'y' ? 'height' : 'width';
|
|
15063
14822
|
}
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
const max$1 = Math.max;
|
|
15067
|
-
|
|
15068
|
-
function within(min$1$1, value, max$1$1) {
|
|
15069
|
-
return max$1(min$1$1, min$1(value, max$1$1));
|
|
14823
|
+
function getSideAxis(placement) {
|
|
14824
|
+
return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
|
|
15070
14825
|
}
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
left: 'right',
|
|
15074
|
-
right: 'left',
|
|
15075
|
-
bottom: 'top',
|
|
15076
|
-
top: 'bottom'
|
|
15077
|
-
};
|
|
15078
|
-
function getOppositePlacement(placement) {
|
|
15079
|
-
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
14826
|
+
function getAlignmentAxis(placement) {
|
|
14827
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
15080
14828
|
}
|
|
15081
|
-
|
|
15082
14829
|
function getAlignmentSides(placement, rects, rtl) {
|
|
15083
14830
|
if (rtl === void 0) {
|
|
15084
14831
|
rtl = false;
|
|
15085
14832
|
}
|
|
15086
14833
|
const alignment = getAlignment(placement);
|
|
15087
|
-
const
|
|
15088
|
-
const length =
|
|
15089
|
-
let mainAlignmentSide =
|
|
14834
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
14835
|
+
const length = getAxisLength(alignmentAxis);
|
|
14836
|
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
15090
14837
|
if (rects.reference[length] > rects.floating[length]) {
|
|
15091
14838
|
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
15092
14839
|
}
|
|
15093
|
-
return
|
|
15094
|
-
main: mainAlignmentSide,
|
|
15095
|
-
cross: getOppositePlacement(mainAlignmentSide)
|
|
15096
|
-
};
|
|
15097
|
-
}
|
|
15098
|
-
|
|
15099
|
-
const oppositeAlignmentMap = {
|
|
15100
|
-
start: 'end',
|
|
15101
|
-
end: 'start'
|
|
15102
|
-
};
|
|
15103
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
15104
|
-
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
14840
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
15105
14841
|
}
|
|
15106
|
-
|
|
15107
14842
|
function getExpandedPlacements(placement) {
|
|
15108
14843
|
const oppositePlacement = getOppositePlacement(placement);
|
|
15109
14844
|
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
15110
14845
|
}
|
|
15111
|
-
|
|
14846
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
14847
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
14848
|
+
}
|
|
15112
14849
|
function getSideList(side, isStart, rtl) {
|
|
15113
14850
|
const lr = ['left', 'right'];
|
|
15114
14851
|
const rl = ['right', 'left'];
|
|
@@ -15137,6 +14874,494 @@ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
|
15137
14874
|
}
|
|
15138
14875
|
return list;
|
|
15139
14876
|
}
|
|
14877
|
+
function getOppositePlacement(placement) {
|
|
14878
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
14879
|
+
}
|
|
14880
|
+
function expandPaddingObject(padding) {
|
|
14881
|
+
return {
|
|
14882
|
+
top: 0,
|
|
14883
|
+
right: 0,
|
|
14884
|
+
bottom: 0,
|
|
14885
|
+
left: 0,
|
|
14886
|
+
...padding
|
|
14887
|
+
};
|
|
14888
|
+
}
|
|
14889
|
+
function getPaddingObject(padding) {
|
|
14890
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
14891
|
+
top: padding,
|
|
14892
|
+
right: padding,
|
|
14893
|
+
bottom: padding,
|
|
14894
|
+
left: padding
|
|
14895
|
+
};
|
|
14896
|
+
}
|
|
14897
|
+
function rectToClientRect(rect) {
|
|
14898
|
+
return {
|
|
14899
|
+
...rect,
|
|
14900
|
+
top: rect.y,
|
|
14901
|
+
left: rect.x,
|
|
14902
|
+
right: rect.x + rect.width,
|
|
14903
|
+
bottom: rect.y + rect.height
|
|
14904
|
+
};
|
|
14905
|
+
}
|
|
14906
|
+
|
|
14907
|
+
function getNodeName(node) {
|
|
14908
|
+
if (isNode(node)) {
|
|
14909
|
+
return (node.nodeName || '').toLowerCase();
|
|
14910
|
+
}
|
|
14911
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
14912
|
+
// returning `#document` an infinite loop won't occur.
|
|
14913
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
14914
|
+
return '#document';
|
|
14915
|
+
}
|
|
14916
|
+
function getWindow(node) {
|
|
14917
|
+
var _node$ownerDocument;
|
|
14918
|
+
return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
14919
|
+
}
|
|
14920
|
+
function getDocumentElement(node) {
|
|
14921
|
+
var _ref;
|
|
14922
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
14923
|
+
}
|
|
14924
|
+
function isNode(value) {
|
|
14925
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
14926
|
+
}
|
|
14927
|
+
function isElement(value) {
|
|
14928
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
14929
|
+
}
|
|
14930
|
+
function isHTMLElement(value) {
|
|
14931
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
14932
|
+
}
|
|
14933
|
+
function isShadowRoot(value) {
|
|
14934
|
+
// Browsers without `ShadowRoot` support.
|
|
14935
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
14936
|
+
return false;
|
|
14937
|
+
}
|
|
14938
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
14939
|
+
}
|
|
14940
|
+
function isOverflowElement(element) {
|
|
14941
|
+
const {
|
|
14942
|
+
overflow,
|
|
14943
|
+
overflowX,
|
|
14944
|
+
overflowY,
|
|
14945
|
+
display
|
|
14946
|
+
} = getComputedStyle$1(element);
|
|
14947
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
14948
|
+
}
|
|
14949
|
+
function isTableElement(element) {
|
|
14950
|
+
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
14951
|
+
}
|
|
14952
|
+
function isContainingBlock(element) {
|
|
14953
|
+
const webkit = isWebKit();
|
|
14954
|
+
const css = getComputedStyle$1(element);
|
|
14955
|
+
|
|
14956
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
14957
|
+
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));
|
|
14958
|
+
}
|
|
14959
|
+
function getContainingBlock(element) {
|
|
14960
|
+
let currentNode = getParentNode(element);
|
|
14961
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
14962
|
+
if (isContainingBlock(currentNode)) {
|
|
14963
|
+
return currentNode;
|
|
14964
|
+
} else {
|
|
14965
|
+
currentNode = getParentNode(currentNode);
|
|
14966
|
+
}
|
|
14967
|
+
}
|
|
14968
|
+
return null;
|
|
14969
|
+
}
|
|
14970
|
+
function isWebKit() {
|
|
14971
|
+
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
14972
|
+
return CSS.supports('-webkit-backdrop-filter', 'none');
|
|
14973
|
+
}
|
|
14974
|
+
function isLastTraversableNode(node) {
|
|
14975
|
+
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
14976
|
+
}
|
|
14977
|
+
function getComputedStyle$1(element) {
|
|
14978
|
+
return getWindow(element).getComputedStyle(element);
|
|
14979
|
+
}
|
|
14980
|
+
function getNodeScroll(element) {
|
|
14981
|
+
if (isElement(element)) {
|
|
14982
|
+
return {
|
|
14983
|
+
scrollLeft: element.scrollLeft,
|
|
14984
|
+
scrollTop: element.scrollTop
|
|
14985
|
+
};
|
|
14986
|
+
}
|
|
14987
|
+
return {
|
|
14988
|
+
scrollLeft: element.pageXOffset,
|
|
14989
|
+
scrollTop: element.pageYOffset
|
|
14990
|
+
};
|
|
14991
|
+
}
|
|
14992
|
+
function getParentNode(node) {
|
|
14993
|
+
if (getNodeName(node) === 'html') {
|
|
14994
|
+
return node;
|
|
14995
|
+
}
|
|
14996
|
+
const result =
|
|
14997
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
14998
|
+
node.assignedSlot ||
|
|
14999
|
+
// DOM Element detected.
|
|
15000
|
+
node.parentNode ||
|
|
15001
|
+
// ShadowRoot detected.
|
|
15002
|
+
isShadowRoot(node) && node.host ||
|
|
15003
|
+
// Fallback.
|
|
15004
|
+
getDocumentElement(node);
|
|
15005
|
+
return isShadowRoot(result) ? result.host : result;
|
|
15006
|
+
}
|
|
15007
|
+
function getNearestOverflowAncestor(node) {
|
|
15008
|
+
const parentNode = getParentNode(node);
|
|
15009
|
+
if (isLastTraversableNode(parentNode)) {
|
|
15010
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
15011
|
+
}
|
|
15012
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
15013
|
+
return parentNode;
|
|
15014
|
+
}
|
|
15015
|
+
return getNearestOverflowAncestor(parentNode);
|
|
15016
|
+
}
|
|
15017
|
+
function getOverflowAncestors(node, list) {
|
|
15018
|
+
var _node$ownerDocument2;
|
|
15019
|
+
if (list === void 0) {
|
|
15020
|
+
list = [];
|
|
15021
|
+
}
|
|
15022
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
15023
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
15024
|
+
const win = getWindow(scrollableAncestor);
|
|
15025
|
+
if (isBody) {
|
|
15026
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
|
|
15027
|
+
}
|
|
15028
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
|
|
15029
|
+
}
|
|
15030
|
+
|
|
15031
|
+
function activeElement(doc) {
|
|
15032
|
+
let activeElement = doc.activeElement;
|
|
15033
|
+
while (((_activeElement = activeElement) == null ? void 0 : (_activeElement$shadow = _activeElement.shadowRoot) == null ? void 0 : _activeElement$shadow.activeElement) != null) {
|
|
15034
|
+
var _activeElement, _activeElement$shadow;
|
|
15035
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
|
15036
|
+
}
|
|
15037
|
+
return activeElement;
|
|
15038
|
+
}
|
|
15039
|
+
function contains(parent, child) {
|
|
15040
|
+
if (!parent || !child) {
|
|
15041
|
+
return false;
|
|
15042
|
+
}
|
|
15043
|
+
const rootNode = child.getRootNode && child.getRootNode();
|
|
15044
|
+
|
|
15045
|
+
// First, attempt with faster native method
|
|
15046
|
+
if (parent.contains(child)) {
|
|
15047
|
+
return true;
|
|
15048
|
+
}
|
|
15049
|
+
|
|
15050
|
+
// then fallback to custom implementation with Shadow DOM support
|
|
15051
|
+
if (rootNode && isShadowRoot(rootNode)) {
|
|
15052
|
+
let next = child;
|
|
15053
|
+
while (next) {
|
|
15054
|
+
if (parent === next) {
|
|
15055
|
+
return true;
|
|
15056
|
+
}
|
|
15057
|
+
// @ts-ignore
|
|
15058
|
+
next = next.parentNode || next.host;
|
|
15059
|
+
}
|
|
15060
|
+
}
|
|
15061
|
+
|
|
15062
|
+
// Give up, the result is false
|
|
15063
|
+
return false;
|
|
15064
|
+
}
|
|
15065
|
+
// Avoid Chrome DevTools blue warning.
|
|
15066
|
+
function getPlatform() {
|
|
15067
|
+
const uaData = navigator.userAgentData;
|
|
15068
|
+
if (uaData != null && uaData.platform) {
|
|
15069
|
+
return uaData.platform;
|
|
15070
|
+
}
|
|
15071
|
+
return navigator.platform;
|
|
15072
|
+
}
|
|
15073
|
+
function getUserAgent() {
|
|
15074
|
+
const uaData = navigator.userAgentData;
|
|
15075
|
+
if (uaData && Array.isArray(uaData.brands)) {
|
|
15076
|
+
return uaData.brands.map(_ref => {
|
|
15077
|
+
let {
|
|
15078
|
+
brand,
|
|
15079
|
+
version
|
|
15080
|
+
} = _ref;
|
|
15081
|
+
return brand + "/" + version;
|
|
15082
|
+
}).join(' ');
|
|
15083
|
+
}
|
|
15084
|
+
return navigator.userAgent;
|
|
15085
|
+
}
|
|
15086
|
+
|
|
15087
|
+
// License: https://github.com/adobe/react-spectrum/blob/b35d5c02fe900badccd0cf1a8f23bb593419f238/packages/@react-aria/utils/src/isVirtualEvent.ts
|
|
15088
|
+
function isVirtualClick(event) {
|
|
15089
|
+
if (event.mozInputSource === 0 && event.isTrusted) {
|
|
15090
|
+
return true;
|
|
15091
|
+
}
|
|
15092
|
+
const androidRe = /Android/i;
|
|
15093
|
+
if ((androidRe.test(getPlatform()) || androidRe.test(getUserAgent())) && event.pointerType) {
|
|
15094
|
+
return event.type === 'click' && event.buttons === 1;
|
|
15095
|
+
}
|
|
15096
|
+
return event.detail === 0 && !event.pointerType;
|
|
15097
|
+
}
|
|
15098
|
+
function isVirtualPointerEvent(event) {
|
|
15099
|
+
return event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType !== 'mouse' ||
|
|
15100
|
+
// iOS VoiceOver returns 0.333• for width/height.
|
|
15101
|
+
event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0;
|
|
15102
|
+
}
|
|
15103
|
+
function isSafari() {
|
|
15104
|
+
// Chrome DevTools does not complain about navigator.vendor
|
|
15105
|
+
return /apple/i.test(navigator.vendor);
|
|
15106
|
+
}
|
|
15107
|
+
function isMouseLikePointerType(pointerType, strict) {
|
|
15108
|
+
// On some Linux machines with Chromium, mouse inputs return a `pointerType`
|
|
15109
|
+
// of "pen": https://github.com/floating-ui/floating-ui/issues/2015
|
|
15110
|
+
const values = ['mouse', 'pen'];
|
|
15111
|
+
if (!strict) {
|
|
15112
|
+
values.push('', undefined);
|
|
15113
|
+
}
|
|
15114
|
+
return values.includes(pointerType);
|
|
15115
|
+
}
|
|
15116
|
+
function isReactEvent(event) {
|
|
15117
|
+
return 'nativeEvent' in event;
|
|
15118
|
+
}
|
|
15119
|
+
function isRootElement(element) {
|
|
15120
|
+
return element.matches('html,body');
|
|
15121
|
+
}
|
|
15122
|
+
function getDocument(node) {
|
|
15123
|
+
return (node == null ? void 0 : node.ownerDocument) || document;
|
|
15124
|
+
}
|
|
15125
|
+
function isEventTargetWithin(event, node) {
|
|
15126
|
+
if (node == null) {
|
|
15127
|
+
return false;
|
|
15128
|
+
}
|
|
15129
|
+
if ('composedPath' in event) {
|
|
15130
|
+
return event.composedPath().includes(node);
|
|
15131
|
+
}
|
|
15132
|
+
|
|
15133
|
+
// TS thinks `event` is of type never as it assumes all browsers support composedPath, but browsers without shadow dom don't
|
|
15134
|
+
const e = event;
|
|
15135
|
+
return e.target != null && node.contains(e.target);
|
|
15136
|
+
}
|
|
15137
|
+
function getTarget(event) {
|
|
15138
|
+
if ('composedPath' in event) {
|
|
15139
|
+
return event.composedPath()[0];
|
|
15140
|
+
}
|
|
15141
|
+
|
|
15142
|
+
// TS thinks `event` is of type never as it assumes all browsers support
|
|
15143
|
+
// `composedPath()`, but browsers without shadow DOM don't.
|
|
15144
|
+
return event.target;
|
|
15145
|
+
}
|
|
15146
|
+
const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled])," + "[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
|
|
15147
|
+
function isTypeableElement(element) {
|
|
15148
|
+
return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
|
|
15149
|
+
}
|
|
15150
|
+
function stopEvent(event) {
|
|
15151
|
+
event.preventDefault();
|
|
15152
|
+
event.stopPropagation();
|
|
15153
|
+
}
|
|
15154
|
+
|
|
15155
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
15156
|
+
let {
|
|
15157
|
+
reference,
|
|
15158
|
+
floating
|
|
15159
|
+
} = _ref;
|
|
15160
|
+
const sideAxis = getSideAxis(placement);
|
|
15161
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
15162
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
15163
|
+
const side = getSide(placement);
|
|
15164
|
+
const isVertical = sideAxis === 'y';
|
|
15165
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
15166
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
15167
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
15168
|
+
let coords;
|
|
15169
|
+
switch (side) {
|
|
15170
|
+
case 'top':
|
|
15171
|
+
coords = {
|
|
15172
|
+
x: commonX,
|
|
15173
|
+
y: reference.y - floating.height
|
|
15174
|
+
};
|
|
15175
|
+
break;
|
|
15176
|
+
case 'bottom':
|
|
15177
|
+
coords = {
|
|
15178
|
+
x: commonX,
|
|
15179
|
+
y: reference.y + reference.height
|
|
15180
|
+
};
|
|
15181
|
+
break;
|
|
15182
|
+
case 'right':
|
|
15183
|
+
coords = {
|
|
15184
|
+
x: reference.x + reference.width,
|
|
15185
|
+
y: commonY
|
|
15186
|
+
};
|
|
15187
|
+
break;
|
|
15188
|
+
case 'left':
|
|
15189
|
+
coords = {
|
|
15190
|
+
x: reference.x - floating.width,
|
|
15191
|
+
y: commonY
|
|
15192
|
+
};
|
|
15193
|
+
break;
|
|
15194
|
+
default:
|
|
15195
|
+
coords = {
|
|
15196
|
+
x: reference.x,
|
|
15197
|
+
y: reference.y
|
|
15198
|
+
};
|
|
15199
|
+
}
|
|
15200
|
+
switch (getAlignment(placement)) {
|
|
15201
|
+
case 'start':
|
|
15202
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
15203
|
+
break;
|
|
15204
|
+
case 'end':
|
|
15205
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
15206
|
+
break;
|
|
15207
|
+
}
|
|
15208
|
+
return coords;
|
|
15209
|
+
}
|
|
15210
|
+
|
|
15211
|
+
/**
|
|
15212
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
15213
|
+
* next to a reference element when it is given a certain positioning strategy.
|
|
15214
|
+
*
|
|
15215
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
15216
|
+
* write one for the platform you are using Floating UI with.
|
|
15217
|
+
*/
|
|
15218
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
15219
|
+
const {
|
|
15220
|
+
placement = 'bottom',
|
|
15221
|
+
strategy = 'absolute',
|
|
15222
|
+
middleware = [],
|
|
15223
|
+
platform
|
|
15224
|
+
} = config;
|
|
15225
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
15226
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
15227
|
+
let rects = await platform.getElementRects({
|
|
15228
|
+
reference,
|
|
15229
|
+
floating,
|
|
15230
|
+
strategy
|
|
15231
|
+
});
|
|
15232
|
+
let {
|
|
15233
|
+
x,
|
|
15234
|
+
y
|
|
15235
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
15236
|
+
let statefulPlacement = placement;
|
|
15237
|
+
let middlewareData = {};
|
|
15238
|
+
let resetCount = 0;
|
|
15239
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
15240
|
+
const {
|
|
15241
|
+
name,
|
|
15242
|
+
fn
|
|
15243
|
+
} = validMiddleware[i];
|
|
15244
|
+
const {
|
|
15245
|
+
x: nextX,
|
|
15246
|
+
y: nextY,
|
|
15247
|
+
data,
|
|
15248
|
+
reset
|
|
15249
|
+
} = await fn({
|
|
15250
|
+
x,
|
|
15251
|
+
y,
|
|
15252
|
+
initialPlacement: placement,
|
|
15253
|
+
placement: statefulPlacement,
|
|
15254
|
+
strategy,
|
|
15255
|
+
middlewareData,
|
|
15256
|
+
rects,
|
|
15257
|
+
platform,
|
|
15258
|
+
elements: {
|
|
15259
|
+
reference,
|
|
15260
|
+
floating
|
|
15261
|
+
}
|
|
15262
|
+
});
|
|
15263
|
+
x = nextX != null ? nextX : x;
|
|
15264
|
+
y = nextY != null ? nextY : y;
|
|
15265
|
+
middlewareData = {
|
|
15266
|
+
...middlewareData,
|
|
15267
|
+
[name]: {
|
|
15268
|
+
...middlewareData[name],
|
|
15269
|
+
...data
|
|
15270
|
+
}
|
|
15271
|
+
};
|
|
15272
|
+
if (reset && resetCount <= 50) {
|
|
15273
|
+
resetCount++;
|
|
15274
|
+
if (typeof reset === 'object') {
|
|
15275
|
+
if (reset.placement) {
|
|
15276
|
+
statefulPlacement = reset.placement;
|
|
15277
|
+
}
|
|
15278
|
+
if (reset.rects) {
|
|
15279
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
15280
|
+
reference,
|
|
15281
|
+
floating,
|
|
15282
|
+
strategy
|
|
15283
|
+
}) : reset.rects;
|
|
15284
|
+
}
|
|
15285
|
+
({
|
|
15286
|
+
x,
|
|
15287
|
+
y
|
|
15288
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
15289
|
+
}
|
|
15290
|
+
i = -1;
|
|
15291
|
+
continue;
|
|
15292
|
+
}
|
|
15293
|
+
}
|
|
15294
|
+
return {
|
|
15295
|
+
x,
|
|
15296
|
+
y,
|
|
15297
|
+
placement: statefulPlacement,
|
|
15298
|
+
strategy,
|
|
15299
|
+
middlewareData
|
|
15300
|
+
};
|
|
15301
|
+
};
|
|
15302
|
+
|
|
15303
|
+
/**
|
|
15304
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
15305
|
+
* element is overflowing a given clipping boundary on each side.
|
|
15306
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
15307
|
+
* - negative = how many pixels left before it will overflow
|
|
15308
|
+
* - 0 = lies flush with the boundary
|
|
15309
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
15310
|
+
*/
|
|
15311
|
+
async function detectOverflow(state, options) {
|
|
15312
|
+
var _await$platform$isEle;
|
|
15313
|
+
if (options === void 0) {
|
|
15314
|
+
options = {};
|
|
15315
|
+
}
|
|
15316
|
+
const {
|
|
15317
|
+
x,
|
|
15318
|
+
y,
|
|
15319
|
+
platform,
|
|
15320
|
+
rects,
|
|
15321
|
+
elements,
|
|
15322
|
+
strategy
|
|
15323
|
+
} = state;
|
|
15324
|
+
const {
|
|
15325
|
+
boundary = 'clippingAncestors',
|
|
15326
|
+
rootBoundary = 'viewport',
|
|
15327
|
+
elementContext = 'floating',
|
|
15328
|
+
altBoundary = false,
|
|
15329
|
+
padding = 0
|
|
15330
|
+
} = evaluate(options, state);
|
|
15331
|
+
const paddingObject = getPaddingObject(padding);
|
|
15332
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
15333
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
15334
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
15335
|
+
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))),
|
|
15336
|
+
boundary,
|
|
15337
|
+
rootBoundary,
|
|
15338
|
+
strategy
|
|
15339
|
+
}));
|
|
15340
|
+
const rect = elementContext === 'floating' ? {
|
|
15341
|
+
...rects.floating,
|
|
15342
|
+
x,
|
|
15343
|
+
y
|
|
15344
|
+
} : rects.reference;
|
|
15345
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
15346
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
15347
|
+
x: 1,
|
|
15348
|
+
y: 1
|
|
15349
|
+
} : {
|
|
15350
|
+
x: 1,
|
|
15351
|
+
y: 1
|
|
15352
|
+
};
|
|
15353
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
15354
|
+
rect,
|
|
15355
|
+
offsetParent,
|
|
15356
|
+
strategy
|
|
15357
|
+
}) : rect);
|
|
15358
|
+
return {
|
|
15359
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
15360
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
15361
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
15362
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
15363
|
+
};
|
|
15364
|
+
}
|
|
15140
15365
|
|
|
15141
15366
|
/**
|
|
15142
15367
|
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
@@ -15169,7 +15394,7 @@ const flip = function (options) {
|
|
|
15169
15394
|
fallbackAxisSideDirection = 'none',
|
|
15170
15395
|
flipAlignment = true,
|
|
15171
15396
|
...detectOverflowOptions
|
|
15172
|
-
} = options;
|
|
15397
|
+
} = evaluate(options, state);
|
|
15173
15398
|
const side = getSide(placement);
|
|
15174
15399
|
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
15175
15400
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
@@ -15185,11 +15410,8 @@ const flip = function (options) {
|
|
|
15185
15410
|
overflows.push(overflow[side]);
|
|
15186
15411
|
}
|
|
15187
15412
|
if (checkCrossAxis) {
|
|
15188
|
-
const
|
|
15189
|
-
|
|
15190
|
-
cross
|
|
15191
|
-
} = getAlignmentSides(placement, rects, rtl);
|
|
15192
|
-
overflows.push(overflow[main], overflow[cross]);
|
|
15413
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
15414
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
15193
15415
|
}
|
|
15194
15416
|
overflowsData = [...overflowsData, {
|
|
15195
15417
|
placement,
|
|
@@ -15248,7 +15470,9 @@ const flip = function (options) {
|
|
|
15248
15470
|
};
|
|
15249
15471
|
};
|
|
15250
15472
|
|
|
15251
|
-
|
|
15473
|
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
15474
|
+
// Derivable.
|
|
15475
|
+
async function convertValueToCoords(state, options) {
|
|
15252
15476
|
const {
|
|
15253
15477
|
placement,
|
|
15254
15478
|
platform,
|
|
@@ -15257,10 +15481,10 @@ async function convertValueToCoords(state, value) {
|
|
|
15257
15481
|
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
15258
15482
|
const side = getSide(placement);
|
|
15259
15483
|
const alignment = getAlignment(placement);
|
|
15260
|
-
const isVertical =
|
|
15484
|
+
const isVertical = getSideAxis(placement) === 'y';
|
|
15261
15485
|
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
15262
15486
|
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
15263
|
-
const rawValue =
|
|
15487
|
+
const rawValue = evaluate(options, state);
|
|
15264
15488
|
|
|
15265
15489
|
// eslint-disable-next-line prefer-const
|
|
15266
15490
|
let {
|
|
@@ -15296,19 +15520,19 @@ async function convertValueToCoords(state, value) {
|
|
|
15296
15520
|
* object may be passed.
|
|
15297
15521
|
* @see https://floating-ui.com/docs/offset
|
|
15298
15522
|
*/
|
|
15299
|
-
const offset = function (
|
|
15300
|
-
if (
|
|
15301
|
-
|
|
15523
|
+
const offset = function (options) {
|
|
15524
|
+
if (options === void 0) {
|
|
15525
|
+
options = 0;
|
|
15302
15526
|
}
|
|
15303
15527
|
return {
|
|
15304
15528
|
name: 'offset',
|
|
15305
|
-
options
|
|
15529
|
+
options,
|
|
15306
15530
|
async fn(state) {
|
|
15307
15531
|
const {
|
|
15308
15532
|
x,
|
|
15309
15533
|
y
|
|
15310
15534
|
} = state;
|
|
15311
|
-
const diffCoords = await convertValueToCoords(state,
|
|
15535
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
15312
15536
|
return {
|
|
15313
15537
|
x: x + diffCoords.x,
|
|
15314
15538
|
y: y + diffCoords.y,
|
|
@@ -15318,10 +15542,6 @@ const offset = function (value) {
|
|
|
15318
15542
|
};
|
|
15319
15543
|
};
|
|
15320
15544
|
|
|
15321
|
-
function getCrossAxis(axis) {
|
|
15322
|
-
return axis === 'x' ? 'y' : 'x';
|
|
15323
|
-
}
|
|
15324
|
-
|
|
15325
15545
|
/**
|
|
15326
15546
|
* Optimizes the visibility of the floating element by shifting it in order to
|
|
15327
15547
|
* keep it in view when it will overflow the clipping boundary.
|
|
@@ -15356,14 +15576,14 @@ const shift = function (options) {
|
|
|
15356
15576
|
}
|
|
15357
15577
|
},
|
|
15358
15578
|
...detectOverflowOptions
|
|
15359
|
-
} = options;
|
|
15579
|
+
} = evaluate(options, state);
|
|
15360
15580
|
const coords = {
|
|
15361
15581
|
x,
|
|
15362
15582
|
y
|
|
15363
15583
|
};
|
|
15364
15584
|
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
15365
|
-
const
|
|
15366
|
-
const
|
|
15585
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
15586
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
15367
15587
|
let mainAxisCoord = coords[mainAxis];
|
|
15368
15588
|
let crossAxisCoord = coords[crossAxis];
|
|
15369
15589
|
if (checkMainAxis) {
|
|
@@ -15371,14 +15591,14 @@ const shift = function (options) {
|
|
|
15371
15591
|
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
15372
15592
|
const min = mainAxisCoord + overflow[minSide];
|
|
15373
15593
|
const max = mainAxisCoord - overflow[maxSide];
|
|
15374
|
-
mainAxisCoord =
|
|
15594
|
+
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
15375
15595
|
}
|
|
15376
15596
|
if (checkCrossAxis) {
|
|
15377
15597
|
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
15378
15598
|
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
15379
15599
|
const min = crossAxisCoord + overflow[minSide];
|
|
15380
15600
|
const max = crossAxisCoord - overflow[maxSide];
|
|
15381
|
-
crossAxisCoord =
|
|
15601
|
+
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
15382
15602
|
}
|
|
15383
15603
|
const limitedCoords = limiter.fn({
|
|
15384
15604
|
...state,
|
|
@@ -15419,12 +15639,11 @@ const size = function (options) {
|
|
|
15419
15639
|
const {
|
|
15420
15640
|
apply = () => {},
|
|
15421
15641
|
...detectOverflowOptions
|
|
15422
|
-
} = options;
|
|
15642
|
+
} = evaluate(options, state);
|
|
15423
15643
|
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
15424
15644
|
const side = getSide(placement);
|
|
15425
15645
|
const alignment = getAlignment(placement);
|
|
15426
|
-
const
|
|
15427
|
-
const isXAxis = axis === 'x';
|
|
15646
|
+
const isYAxis = getSideAxis(placement) === 'y';
|
|
15428
15647
|
const {
|
|
15429
15648
|
width,
|
|
15430
15649
|
height
|
|
@@ -15440,26 +15659,25 @@ const size = function (options) {
|
|
|
15440
15659
|
}
|
|
15441
15660
|
const overflowAvailableHeight = height - overflow[heightSide];
|
|
15442
15661
|
const overflowAvailableWidth = width - overflow[widthSide];
|
|
15662
|
+
const noShift = !state.middlewareData.shift;
|
|
15443
15663
|
let availableHeight = overflowAvailableHeight;
|
|
15444
15664
|
let availableWidth = overflowAvailableWidth;
|
|
15445
|
-
if (
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
width - overflow.right - overflow.left, overflowAvailableWidth);
|
|
15665
|
+
if (isYAxis) {
|
|
15666
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
15667
|
+
availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
|
|
15449
15668
|
} else {
|
|
15450
|
-
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
|
|
15455
|
-
const
|
|
15456
|
-
const
|
|
15457
|
-
const
|
|
15458
|
-
|
|
15459
|
-
|
|
15460
|
-
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max$1(overflow.left, overflow.right));
|
|
15669
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
15670
|
+
availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
|
|
15671
|
+
}
|
|
15672
|
+
if (noShift && !alignment) {
|
|
15673
|
+
const xMin = max(overflow.left, 0);
|
|
15674
|
+
const xMax = max(overflow.right, 0);
|
|
15675
|
+
const yMin = max(overflow.top, 0);
|
|
15676
|
+
const yMax = max(overflow.bottom, 0);
|
|
15677
|
+
if (isYAxis) {
|
|
15678
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
|
|
15461
15679
|
} else {
|
|
15462
|
-
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max
|
|
15680
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
|
|
15463
15681
|
}
|
|
15464
15682
|
}
|
|
15465
15683
|
await apply({
|
|
@@ -15480,106 +15698,13 @@ const size = function (options) {
|
|
|
15480
15698
|
};
|
|
15481
15699
|
};
|
|
15482
15700
|
|
|
15483
|
-
function getWindow$1(node) {
|
|
15484
|
-
var _node$ownerDocument;
|
|
15485
|
-
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
15486
|
-
}
|
|
15487
|
-
|
|
15488
|
-
function getComputedStyle$1(element) {
|
|
15489
|
-
return getWindow$1(element).getComputedStyle(element);
|
|
15490
|
-
}
|
|
15491
|
-
|
|
15492
|
-
function isNode(value) {
|
|
15493
|
-
return value instanceof getWindow$1(value).Node;
|
|
15494
|
-
}
|
|
15495
|
-
function getNodeName(node) {
|
|
15496
|
-
return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
|
|
15497
|
-
}
|
|
15498
|
-
|
|
15499
|
-
let uaString;
|
|
15500
|
-
function getUAString() {
|
|
15501
|
-
if (uaString) {
|
|
15502
|
-
return uaString;
|
|
15503
|
-
}
|
|
15504
|
-
const uaData = navigator.userAgentData;
|
|
15505
|
-
if (uaData && Array.isArray(uaData.brands)) {
|
|
15506
|
-
uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
|
|
15507
|
-
return uaString;
|
|
15508
|
-
}
|
|
15509
|
-
return navigator.userAgent;
|
|
15510
|
-
}
|
|
15511
|
-
|
|
15512
|
-
function isHTMLElement$1(value) {
|
|
15513
|
-
return value instanceof getWindow$1(value).HTMLElement;
|
|
15514
|
-
}
|
|
15515
|
-
function isElement$1(value) {
|
|
15516
|
-
return value instanceof getWindow$1(value).Element;
|
|
15517
|
-
}
|
|
15518
|
-
function isShadowRoot$1(node) {
|
|
15519
|
-
// Browsers without `ShadowRoot` support.
|
|
15520
|
-
if (typeof ShadowRoot === 'undefined') {
|
|
15521
|
-
return false;
|
|
15522
|
-
}
|
|
15523
|
-
const OwnElement = getWindow$1(node).ShadowRoot;
|
|
15524
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
15525
|
-
}
|
|
15526
|
-
function isOverflowElement(element) {
|
|
15527
|
-
const {
|
|
15528
|
-
overflow,
|
|
15529
|
-
overflowX,
|
|
15530
|
-
overflowY,
|
|
15531
|
-
display
|
|
15532
|
-
} = getComputedStyle$1(element);
|
|
15533
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
15534
|
-
}
|
|
15535
|
-
function isTableElement(element) {
|
|
15536
|
-
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
15537
|
-
}
|
|
15538
|
-
function isContainingBlock(element) {
|
|
15539
|
-
// TODO: Try to use feature detection here instead.
|
|
15540
|
-
const isFirefox = /firefox/i.test(getUAString());
|
|
15541
|
-
const css = getComputedStyle$1(element);
|
|
15542
|
-
const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
|
|
15543
|
-
|
|
15544
|
-
// This is non-exhaustive but covers the most common CSS properties that
|
|
15545
|
-
// create a containing block.
|
|
15546
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
15547
|
-
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 => {
|
|
15548
|
-
// Add type check for old browsers.
|
|
15549
|
-
const contain = css.contain;
|
|
15550
|
-
return contain != null ? contain.includes(value) : false;
|
|
15551
|
-
});
|
|
15552
|
-
}
|
|
15553
|
-
|
|
15554
|
-
/**
|
|
15555
|
-
* Determines whether or not `.getBoundingClientRect()` is affected by visual
|
|
15556
|
-
* viewport offsets. In Safari, the `x`/`y` offsets are values relative to the
|
|
15557
|
-
* visual viewport, while in other engines, they are values relative to the
|
|
15558
|
-
* layout viewport.
|
|
15559
|
-
*/
|
|
15560
|
-
function isClientRectVisualViewportBased() {
|
|
15561
|
-
// TODO: Try to use feature detection here instead. Feature detection for
|
|
15562
|
-
// this can fail in various ways, making the userAgent check the most
|
|
15563
|
-
// reliable:
|
|
15564
|
-
// • Always-visible scrollbar or not
|
|
15565
|
-
// • Width of <html>
|
|
15566
|
-
|
|
15567
|
-
// Is Safari.
|
|
15568
|
-
return /^((?!chrome|android).)*safari/i.test(getUAString());
|
|
15569
|
-
}
|
|
15570
|
-
function isLastTraversableNode(node) {
|
|
15571
|
-
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
15572
|
-
}
|
|
15573
|
-
|
|
15574
|
-
const min = Math.min;
|
|
15575
|
-
const max = Math.max;
|
|
15576
|
-
const round = Math.round;
|
|
15577
|
-
|
|
15578
15701
|
function getCssDimensions(element) {
|
|
15579
15702
|
const css = getComputedStyle$1(element);
|
|
15580
|
-
|
|
15581
|
-
|
|
15582
|
-
|
|
15703
|
+
// In testing environments, the `width` and `height` properties are empty
|
|
15704
|
+
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
15705
|
+
let width = parseFloat(css.width) || 0;
|
|
15706
|
+
let height = parseFloat(css.height) || 0;
|
|
15707
|
+
const hasOffset = isHTMLElement(element);
|
|
15583
15708
|
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
15584
15709
|
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
15585
15710
|
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
@@ -15590,31 +15715,27 @@ function getCssDimensions(element) {
|
|
|
15590
15715
|
return {
|
|
15591
15716
|
width,
|
|
15592
15717
|
height,
|
|
15593
|
-
|
|
15718
|
+
$: shouldFallback
|
|
15594
15719
|
};
|
|
15595
15720
|
}
|
|
15596
15721
|
|
|
15597
15722
|
function unwrapElement(element) {
|
|
15598
|
-
return !isElement
|
|
15723
|
+
return !isElement(element) ? element.contextElement : element;
|
|
15599
15724
|
}
|
|
15600
15725
|
|
|
15601
|
-
const FALLBACK_SCALE = {
|
|
15602
|
-
x: 1,
|
|
15603
|
-
y: 1
|
|
15604
|
-
};
|
|
15605
15726
|
function getScale(element) {
|
|
15606
15727
|
const domElement = unwrapElement(element);
|
|
15607
|
-
if (!isHTMLElement
|
|
15608
|
-
return
|
|
15728
|
+
if (!isHTMLElement(domElement)) {
|
|
15729
|
+
return createCoords(1);
|
|
15609
15730
|
}
|
|
15610
15731
|
const rect = domElement.getBoundingClientRect();
|
|
15611
15732
|
const {
|
|
15612
15733
|
width,
|
|
15613
15734
|
height,
|
|
15614
|
-
|
|
15735
|
+
$
|
|
15615
15736
|
} = getCssDimensions(domElement);
|
|
15616
|
-
let x = (
|
|
15617
|
-
let y = (
|
|
15737
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
15738
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
15618
15739
|
|
|
15619
15740
|
// 0, NaN, or Infinity should always fallback to 1.
|
|
15620
15741
|
|
|
@@ -15630,8 +15751,28 @@ function getScale(element) {
|
|
|
15630
15751
|
};
|
|
15631
15752
|
}
|
|
15632
15753
|
|
|
15754
|
+
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
15755
|
+
function getVisualOffsets(element) {
|
|
15756
|
+
const win = getWindow(element);
|
|
15757
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
15758
|
+
return noOffsets;
|
|
15759
|
+
}
|
|
15760
|
+
return {
|
|
15761
|
+
x: win.visualViewport.offsetLeft,
|
|
15762
|
+
y: win.visualViewport.offsetTop
|
|
15763
|
+
};
|
|
15764
|
+
}
|
|
15765
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
15766
|
+
if (isFixed === void 0) {
|
|
15767
|
+
isFixed = false;
|
|
15768
|
+
}
|
|
15769
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
15770
|
+
return false;
|
|
15771
|
+
}
|
|
15772
|
+
return isFixed;
|
|
15773
|
+
}
|
|
15774
|
+
|
|
15633
15775
|
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
15634
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
15635
15776
|
if (includeScale === void 0) {
|
|
15636
15777
|
includeScale = false;
|
|
15637
15778
|
}
|
|
@@ -15640,39 +15781,38 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
15640
15781
|
}
|
|
15641
15782
|
const clientRect = element.getBoundingClientRect();
|
|
15642
15783
|
const domElement = unwrapElement(element);
|
|
15643
|
-
let scale =
|
|
15784
|
+
let scale = createCoords(1);
|
|
15644
15785
|
if (includeScale) {
|
|
15645
15786
|
if (offsetParent) {
|
|
15646
|
-
if (isElement
|
|
15787
|
+
if (isElement(offsetParent)) {
|
|
15647
15788
|
scale = getScale(offsetParent);
|
|
15648
15789
|
}
|
|
15649
15790
|
} else {
|
|
15650
15791
|
scale = getScale(element);
|
|
15651
15792
|
}
|
|
15652
15793
|
}
|
|
15653
|
-
const
|
|
15654
|
-
|
|
15655
|
-
let
|
|
15656
|
-
let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
|
|
15794
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
15795
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
15796
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
15657
15797
|
let width = clientRect.width / scale.x;
|
|
15658
15798
|
let height = clientRect.height / scale.y;
|
|
15659
15799
|
if (domElement) {
|
|
15660
|
-
const win = getWindow
|
|
15661
|
-
const offsetWin = offsetParent && isElement
|
|
15800
|
+
const win = getWindow(domElement);
|
|
15801
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
15662
15802
|
let currentIFrame = win.frameElement;
|
|
15663
15803
|
while (currentIFrame && offsetParent && offsetWin !== win) {
|
|
15664
15804
|
const iframeScale = getScale(currentIFrame);
|
|
15665
15805
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
15666
|
-
const css = getComputedStyle(currentIFrame);
|
|
15667
|
-
iframeRect.
|
|
15668
|
-
iframeRect.
|
|
15806
|
+
const css = getComputedStyle$1(currentIFrame);
|
|
15807
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
15808
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
15669
15809
|
x *= iframeScale.x;
|
|
15670
15810
|
y *= iframeScale.y;
|
|
15671
15811
|
width *= iframeScale.x;
|
|
15672
15812
|
height *= iframeScale.y;
|
|
15673
|
-
x +=
|
|
15674
|
-
y +=
|
|
15675
|
-
currentIFrame = getWindow
|
|
15813
|
+
x += left;
|
|
15814
|
+
y += top;
|
|
15815
|
+
currentIFrame = getWindow(currentIFrame).frameElement;
|
|
15676
15816
|
}
|
|
15677
15817
|
}
|
|
15678
15818
|
return rectToClientRect({
|
|
@@ -15683,30 +15823,13 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
15683
15823
|
});
|
|
15684
15824
|
}
|
|
15685
15825
|
|
|
15686
|
-
function getDocumentElement(node) {
|
|
15687
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
15688
|
-
}
|
|
15689
|
-
|
|
15690
|
-
function getNodeScroll(element) {
|
|
15691
|
-
if (isElement$1(element)) {
|
|
15692
|
-
return {
|
|
15693
|
-
scrollLeft: element.scrollLeft,
|
|
15694
|
-
scrollTop: element.scrollTop
|
|
15695
|
-
};
|
|
15696
|
-
}
|
|
15697
|
-
return {
|
|
15698
|
-
scrollLeft: element.pageXOffset,
|
|
15699
|
-
scrollTop: element.pageYOffset
|
|
15700
|
-
};
|
|
15701
|
-
}
|
|
15702
|
-
|
|
15703
15826
|
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
15704
15827
|
let {
|
|
15705
15828
|
rect,
|
|
15706
15829
|
offsetParent,
|
|
15707
15830
|
strategy
|
|
15708
15831
|
} = _ref;
|
|
15709
|
-
const isOffsetParentAnElement = isHTMLElement
|
|
15832
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
15710
15833
|
const documentElement = getDocumentElement(offsetParent);
|
|
15711
15834
|
if (offsetParent === documentElement) {
|
|
15712
15835
|
return rect;
|
|
@@ -15715,19 +15838,13 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
15715
15838
|
scrollLeft: 0,
|
|
15716
15839
|
scrollTop: 0
|
|
15717
15840
|
};
|
|
15718
|
-
let scale =
|
|
15719
|
-
|
|
15720
|
-
y: 1
|
|
15721
|
-
};
|
|
15722
|
-
const offsets = {
|
|
15723
|
-
x: 0,
|
|
15724
|
-
y: 0
|
|
15725
|
-
};
|
|
15841
|
+
let scale = createCoords(1);
|
|
15842
|
+
const offsets = createCoords(0);
|
|
15726
15843
|
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
15727
15844
|
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
15728
15845
|
scroll = getNodeScroll(offsetParent);
|
|
15729
15846
|
}
|
|
15730
|
-
if (isHTMLElement
|
|
15847
|
+
if (isHTMLElement(offsetParent)) {
|
|
15731
15848
|
const offsetRect = getBoundingClientRect(offsetParent);
|
|
15732
15849
|
scale = getScale(offsetParent);
|
|
15733
15850
|
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
@@ -15742,6 +15859,10 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
15742
15859
|
};
|
|
15743
15860
|
}
|
|
15744
15861
|
|
|
15862
|
+
function getClientRects(element) {
|
|
15863
|
+
return Array.from(element.getClientRects());
|
|
15864
|
+
}
|
|
15865
|
+
|
|
15745
15866
|
function getWindowScrollBarX(element) {
|
|
15746
15867
|
// If <html> has a CSS width greater than the viewport, then this will be
|
|
15747
15868
|
// incorrect for RTL.
|
|
@@ -15769,51 +15890,8 @@ function getDocumentRect(element) {
|
|
|
15769
15890
|
};
|
|
15770
15891
|
}
|
|
15771
15892
|
|
|
15772
|
-
function getParentNode(node) {
|
|
15773
|
-
if (getNodeName(node) === 'html') {
|
|
15774
|
-
return node;
|
|
15775
|
-
}
|
|
15776
|
-
const result =
|
|
15777
|
-
// Step into the shadow DOM of the parent of a slotted node.
|
|
15778
|
-
node.assignedSlot ||
|
|
15779
|
-
// DOM Element detected.
|
|
15780
|
-
node.parentNode ||
|
|
15781
|
-
// ShadowRoot detected.
|
|
15782
|
-
isShadowRoot$1(node) && node.host ||
|
|
15783
|
-
// Fallback.
|
|
15784
|
-
getDocumentElement(node);
|
|
15785
|
-
return isShadowRoot$1(result) ? result.host : result;
|
|
15786
|
-
}
|
|
15787
|
-
|
|
15788
|
-
function getNearestOverflowAncestor(node) {
|
|
15789
|
-
const parentNode = getParentNode(node);
|
|
15790
|
-
if (isLastTraversableNode(parentNode)) {
|
|
15791
|
-
// `getParentNode` will never return a `Document` due to the fallback
|
|
15792
|
-
// check, so it's either the <html> or <body> element.
|
|
15793
|
-
return parentNode.ownerDocument.body;
|
|
15794
|
-
}
|
|
15795
|
-
if (isHTMLElement$1(parentNode) && isOverflowElement(parentNode)) {
|
|
15796
|
-
return parentNode;
|
|
15797
|
-
}
|
|
15798
|
-
return getNearestOverflowAncestor(parentNode);
|
|
15799
|
-
}
|
|
15800
|
-
|
|
15801
|
-
function getOverflowAncestors(node, list) {
|
|
15802
|
-
var _node$ownerDocument;
|
|
15803
|
-
if (list === void 0) {
|
|
15804
|
-
list = [];
|
|
15805
|
-
}
|
|
15806
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
15807
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
15808
|
-
const win = getWindow$1(scrollableAncestor);
|
|
15809
|
-
if (isBody) {
|
|
15810
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
|
|
15811
|
-
}
|
|
15812
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
|
|
15813
|
-
}
|
|
15814
|
-
|
|
15815
15893
|
function getViewportRect(element, strategy) {
|
|
15816
|
-
const win = getWindow
|
|
15894
|
+
const win = getWindow(element);
|
|
15817
15895
|
const html = getDocumentElement(element);
|
|
15818
15896
|
const visualViewport = win.visualViewport;
|
|
15819
15897
|
let width = html.clientWidth;
|
|
@@ -15823,7 +15901,7 @@ function getViewportRect(element, strategy) {
|
|
|
15823
15901
|
if (visualViewport) {
|
|
15824
15902
|
width = visualViewport.width;
|
|
15825
15903
|
height = visualViewport.height;
|
|
15826
|
-
const visualViewportBased =
|
|
15904
|
+
const visualViewportBased = isWebKit();
|
|
15827
15905
|
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
15828
15906
|
x = visualViewport.offsetLeft;
|
|
15829
15907
|
y = visualViewport.offsetTop;
|
|
@@ -15842,10 +15920,7 @@ function getInnerBoundingClientRect(element, strategy) {
|
|
|
15842
15920
|
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
15843
15921
|
const top = clientRect.top + element.clientTop;
|
|
15844
15922
|
const left = clientRect.left + element.clientLeft;
|
|
15845
|
-
const scale = isHTMLElement
|
|
15846
|
-
x: 1,
|
|
15847
|
-
y: 1
|
|
15848
|
-
};
|
|
15923
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
15849
15924
|
const width = element.clientWidth * scale.x;
|
|
15850
15925
|
const height = element.clientHeight * scale.y;
|
|
15851
15926
|
const x = left * scale.x;
|
|
@@ -15863,22 +15938,25 @@ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy)
|
|
|
15863
15938
|
rect = getViewportRect(element, strategy);
|
|
15864
15939
|
} else if (clippingAncestor === 'document') {
|
|
15865
15940
|
rect = getDocumentRect(getDocumentElement(element));
|
|
15866
|
-
} else if (isElement
|
|
15941
|
+
} else if (isElement(clippingAncestor)) {
|
|
15867
15942
|
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
15868
15943
|
} else {
|
|
15869
|
-
const
|
|
15870
|
-
|
|
15944
|
+
const visualOffsets = getVisualOffsets(element);
|
|
15945
|
+
rect = {
|
|
15946
|
+
...clippingAncestor,
|
|
15947
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
15948
|
+
y: clippingAncestor.y - visualOffsets.y
|
|
15871
15949
|
};
|
|
15872
|
-
if (isClientRectVisualViewportBased()) {
|
|
15873
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
15874
|
-
const win = getWindow$1(element);
|
|
15875
|
-
mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0;
|
|
15876
|
-
mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0;
|
|
15877
|
-
}
|
|
15878
|
-
rect = mutableRect;
|
|
15879
15950
|
}
|
|
15880
15951
|
return rectToClientRect(rect);
|
|
15881
15952
|
}
|
|
15953
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
15954
|
+
const parentNode = getParentNode(element);
|
|
15955
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
15956
|
+
return false;
|
|
15957
|
+
}
|
|
15958
|
+
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
15959
|
+
}
|
|
15882
15960
|
|
|
15883
15961
|
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
15884
15962
|
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
@@ -15888,27 +15966,25 @@ function getClippingElementAncestors(element, cache) {
|
|
|
15888
15966
|
if (cachedResult) {
|
|
15889
15967
|
return cachedResult;
|
|
15890
15968
|
}
|
|
15891
|
-
let result = getOverflowAncestors(element).filter(el => isElement
|
|
15969
|
+
let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
15892
15970
|
let currentContainingBlockComputedStyle = null;
|
|
15893
15971
|
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
|
15894
15972
|
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
15895
15973
|
|
|
15896
15974
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
15897
|
-
while (isElement
|
|
15975
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
15898
15976
|
const computedStyle = getComputedStyle$1(currentNode);
|
|
15899
|
-
const
|
|
15900
|
-
|
|
15901
|
-
if (shouldIgnoreCurrentNode) {
|
|
15977
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
15978
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
15902
15979
|
currentContainingBlockComputedStyle = null;
|
|
15980
|
+
}
|
|
15981
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
15982
|
+
if (shouldDropCurrentNode) {
|
|
15983
|
+
// Drop non-containing blocks.
|
|
15984
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
15903
15985
|
} else {
|
|
15904
|
-
|
|
15905
|
-
|
|
15906
|
-
// Drop non-containing blocks.
|
|
15907
|
-
result = result.filter(ancestor => ancestor !== currentNode);
|
|
15908
|
-
} else {
|
|
15909
|
-
// Record last containing block for next iteration.
|
|
15910
|
-
currentContainingBlockComputedStyle = computedStyle;
|
|
15911
|
-
}
|
|
15986
|
+
// Record last containing block for next iteration.
|
|
15987
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
15912
15988
|
}
|
|
15913
15989
|
currentNode = getParentNode(currentNode);
|
|
15914
15990
|
}
|
|
@@ -15948,8 +16024,38 @@ function getDimensions(element) {
|
|
|
15948
16024
|
return getCssDimensions(element);
|
|
15949
16025
|
}
|
|
15950
16026
|
|
|
16027
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
16028
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
16029
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
16030
|
+
const isFixed = strategy === 'fixed';
|
|
16031
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
16032
|
+
let scroll = {
|
|
16033
|
+
scrollLeft: 0,
|
|
16034
|
+
scrollTop: 0
|
|
16035
|
+
};
|
|
16036
|
+
const offsets = createCoords(0);
|
|
16037
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
16038
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
16039
|
+
scroll = getNodeScroll(offsetParent);
|
|
16040
|
+
}
|
|
16041
|
+
if (isOffsetParentAnElement) {
|
|
16042
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
16043
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
16044
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
16045
|
+
} else if (documentElement) {
|
|
16046
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
16047
|
+
}
|
|
16048
|
+
}
|
|
16049
|
+
return {
|
|
16050
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
16051
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
16052
|
+
width: rect.width,
|
|
16053
|
+
height: rect.height
|
|
16054
|
+
};
|
|
16055
|
+
}
|
|
16056
|
+
|
|
15951
16057
|
function getTrueOffsetParent(element, polyfill) {
|
|
15952
|
-
if (!isHTMLElement
|
|
16058
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
15953
16059
|
return null;
|
|
15954
16060
|
}
|
|
15955
16061
|
if (polyfill) {
|
|
@@ -15957,23 +16063,12 @@ function getTrueOffsetParent(element, polyfill) {
|
|
|
15957
16063
|
}
|
|
15958
16064
|
return element.offsetParent;
|
|
15959
16065
|
}
|
|
15960
|
-
function getContainingBlock(element) {
|
|
15961
|
-
let currentNode = getParentNode(element);
|
|
15962
|
-
while (isHTMLElement$1(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
15963
|
-
if (isContainingBlock(currentNode)) {
|
|
15964
|
-
return currentNode;
|
|
15965
|
-
} else {
|
|
15966
|
-
currentNode = getParentNode(currentNode);
|
|
15967
|
-
}
|
|
15968
|
-
}
|
|
15969
|
-
return null;
|
|
15970
|
-
}
|
|
15971
16066
|
|
|
15972
16067
|
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
15973
16068
|
// such as table ancestors and cross browser bugs.
|
|
15974
16069
|
function getOffsetParent(element, polyfill) {
|
|
15975
|
-
const window = getWindow
|
|
15976
|
-
if (!isHTMLElement
|
|
16070
|
+
const window = getWindow(element);
|
|
16071
|
+
if (!isHTMLElement(element)) {
|
|
15977
16072
|
return window;
|
|
15978
16073
|
}
|
|
15979
16074
|
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
@@ -15986,67 +16081,115 @@ function getOffsetParent(element, polyfill) {
|
|
|
15986
16081
|
return offsetParent || getContainingBlock(element) || window;
|
|
15987
16082
|
}
|
|
15988
16083
|
|
|
15989
|
-
function
|
|
15990
|
-
|
|
15991
|
-
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
|
|
15995
|
-
|
|
15996
|
-
|
|
15997
|
-
const offsets = {
|
|
15998
|
-
x: 0,
|
|
15999
|
-
y: 0
|
|
16000
|
-
};
|
|
16001
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
16002
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
16003
|
-
scroll = getNodeScroll(offsetParent);
|
|
16004
|
-
}
|
|
16005
|
-
if (isHTMLElement$1(offsetParent)) {
|
|
16006
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
16007
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
16008
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
16009
|
-
} else if (documentElement) {
|
|
16010
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
16011
|
-
}
|
|
16012
|
-
}
|
|
16084
|
+
const getElementRects = async function (_ref) {
|
|
16085
|
+
let {
|
|
16086
|
+
reference,
|
|
16087
|
+
floating,
|
|
16088
|
+
strategy
|
|
16089
|
+
} = _ref;
|
|
16090
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
16091
|
+
const getDimensionsFn = this.getDimensions;
|
|
16013
16092
|
return {
|
|
16014
|
-
|
|
16015
|
-
|
|
16016
|
-
|
|
16017
|
-
|
|
16093
|
+
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
16094
|
+
floating: {
|
|
16095
|
+
x: 0,
|
|
16096
|
+
y: 0,
|
|
16097
|
+
...(await getDimensionsFn(floating))
|
|
16098
|
+
}
|
|
16018
16099
|
};
|
|
16100
|
+
};
|
|
16101
|
+
|
|
16102
|
+
function isRTL(element) {
|
|
16103
|
+
return getComputedStyle$1(element).direction === 'rtl';
|
|
16019
16104
|
}
|
|
16020
16105
|
|
|
16021
16106
|
const platform = {
|
|
16022
|
-
getClippingRect,
|
|
16023
16107
|
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
16024
|
-
isElement: isElement$1,
|
|
16025
|
-
getDimensions,
|
|
16026
|
-
getOffsetParent,
|
|
16027
16108
|
getDocumentElement,
|
|
16109
|
+
getClippingRect,
|
|
16110
|
+
getOffsetParent,
|
|
16111
|
+
getElementRects,
|
|
16112
|
+
getClientRects,
|
|
16113
|
+
getDimensions,
|
|
16028
16114
|
getScale,
|
|
16029
|
-
|
|
16030
|
-
|
|
16031
|
-
reference,
|
|
16032
|
-
floating,
|
|
16033
|
-
strategy
|
|
16034
|
-
} = _ref;
|
|
16035
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
16036
|
-
const getDimensionsFn = this.getDimensions;
|
|
16037
|
-
return {
|
|
16038
|
-
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
16039
|
-
floating: {
|
|
16040
|
-
x: 0,
|
|
16041
|
-
y: 0,
|
|
16042
|
-
...(await getDimensionsFn(floating))
|
|
16043
|
-
}
|
|
16044
|
-
};
|
|
16045
|
-
},
|
|
16046
|
-
getClientRects: element => Array.from(element.getClientRects()),
|
|
16047
|
-
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
16115
|
+
isElement,
|
|
16116
|
+
isRTL
|
|
16048
16117
|
};
|
|
16049
16118
|
|
|
16119
|
+
// https://samthor.au/2021/observing-dom/
|
|
16120
|
+
function observeMove(element, onMove) {
|
|
16121
|
+
let io = null;
|
|
16122
|
+
let timeoutId;
|
|
16123
|
+
const root = getDocumentElement(element);
|
|
16124
|
+
function cleanup() {
|
|
16125
|
+
clearTimeout(timeoutId);
|
|
16126
|
+
io && io.disconnect();
|
|
16127
|
+
io = null;
|
|
16128
|
+
}
|
|
16129
|
+
function refresh(skip, threshold) {
|
|
16130
|
+
if (skip === void 0) {
|
|
16131
|
+
skip = false;
|
|
16132
|
+
}
|
|
16133
|
+
if (threshold === void 0) {
|
|
16134
|
+
threshold = 1;
|
|
16135
|
+
}
|
|
16136
|
+
cleanup();
|
|
16137
|
+
const {
|
|
16138
|
+
left,
|
|
16139
|
+
top,
|
|
16140
|
+
width,
|
|
16141
|
+
height
|
|
16142
|
+
} = element.getBoundingClientRect();
|
|
16143
|
+
if (!skip) {
|
|
16144
|
+
onMove();
|
|
16145
|
+
}
|
|
16146
|
+
if (!width || !height) {
|
|
16147
|
+
return;
|
|
16148
|
+
}
|
|
16149
|
+
const insetTop = floor(top);
|
|
16150
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
16151
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
16152
|
+
const insetLeft = floor(left);
|
|
16153
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
16154
|
+
const options = {
|
|
16155
|
+
rootMargin,
|
|
16156
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
16157
|
+
};
|
|
16158
|
+
let isFirstUpdate = true;
|
|
16159
|
+
function handleObserve(entries) {
|
|
16160
|
+
const ratio = entries[0].intersectionRatio;
|
|
16161
|
+
if (ratio !== threshold) {
|
|
16162
|
+
if (!isFirstUpdate) {
|
|
16163
|
+
return refresh();
|
|
16164
|
+
}
|
|
16165
|
+
if (!ratio) {
|
|
16166
|
+
timeoutId = setTimeout(() => {
|
|
16167
|
+
refresh(false, 1e-7);
|
|
16168
|
+
}, 100);
|
|
16169
|
+
} else {
|
|
16170
|
+
refresh(false, ratio);
|
|
16171
|
+
}
|
|
16172
|
+
}
|
|
16173
|
+
isFirstUpdate = false;
|
|
16174
|
+
}
|
|
16175
|
+
|
|
16176
|
+
// Older browsers don't support a `document` as the root and will throw an
|
|
16177
|
+
// error.
|
|
16178
|
+
try {
|
|
16179
|
+
io = new IntersectionObserver(handleObserve, {
|
|
16180
|
+
...options,
|
|
16181
|
+
// Handle <iframe>s
|
|
16182
|
+
root: root.ownerDocument
|
|
16183
|
+
});
|
|
16184
|
+
} catch (e) {
|
|
16185
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
16186
|
+
}
|
|
16187
|
+
io.observe(element);
|
|
16188
|
+
}
|
|
16189
|
+
refresh(true);
|
|
16190
|
+
return cleanup;
|
|
16191
|
+
}
|
|
16192
|
+
|
|
16050
16193
|
/**
|
|
16051
16194
|
* Automatically updates the position of the floating element when necessary.
|
|
16052
16195
|
* Should only be called when the floating element is mounted on the DOM or
|
|
@@ -16060,29 +16203,41 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
16060
16203
|
options = {};
|
|
16061
16204
|
}
|
|
16062
16205
|
const {
|
|
16063
|
-
ancestorScroll
|
|
16206
|
+
ancestorScroll = true,
|
|
16064
16207
|
ancestorResize = true,
|
|
16065
|
-
elementResize =
|
|
16208
|
+
elementResize = typeof ResizeObserver === 'function',
|
|
16209
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
|
16066
16210
|
animationFrame = false
|
|
16067
16211
|
} = options;
|
|
16068
|
-
const
|
|
16069
|
-
const ancestors = ancestorScroll || ancestorResize ? [...(
|
|
16212
|
+
const referenceEl = unwrapElement(reference);
|
|
16213
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
|
16070
16214
|
ancestors.forEach(ancestor => {
|
|
16071
16215
|
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
16072
16216
|
passive: true
|
|
16073
16217
|
});
|
|
16074
16218
|
ancestorResize && ancestor.addEventListener('resize', update);
|
|
16075
16219
|
});
|
|
16076
|
-
|
|
16220
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
16221
|
+
let reobserveFrame = -1;
|
|
16222
|
+
let resizeObserver = null;
|
|
16077
16223
|
if (elementResize) {
|
|
16078
|
-
|
|
16224
|
+
resizeObserver = new ResizeObserver(_ref => {
|
|
16225
|
+
let [firstEntry] = _ref;
|
|
16226
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
16227
|
+
// Prevent update loops when using the `size` middleware.
|
|
16228
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
16229
|
+
resizeObserver.unobserve(floating);
|
|
16230
|
+
cancelAnimationFrame(reobserveFrame);
|
|
16231
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
16232
|
+
resizeObserver && resizeObserver.observe(floating);
|
|
16233
|
+
});
|
|
16234
|
+
}
|
|
16079
16235
|
update();
|
|
16080
16236
|
});
|
|
16081
|
-
|
|
16082
|
-
|
|
16083
|
-
observer.observe(reference.contextElement);
|
|
16237
|
+
if (referenceEl && !animationFrame) {
|
|
16238
|
+
resizeObserver.observe(referenceEl);
|
|
16084
16239
|
}
|
|
16085
|
-
|
|
16240
|
+
resizeObserver.observe(floating);
|
|
16086
16241
|
}
|
|
16087
16242
|
let frameId;
|
|
16088
16243
|
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
@@ -16099,13 +16254,13 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
16099
16254
|
}
|
|
16100
16255
|
update();
|
|
16101
16256
|
return () => {
|
|
16102
|
-
var _observer;
|
|
16103
16257
|
ancestors.forEach(ancestor => {
|
|
16104
16258
|
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
16105
16259
|
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
16106
16260
|
});
|
|
16107
|
-
|
|
16108
|
-
|
|
16261
|
+
cleanupIo && cleanupIo();
|
|
16262
|
+
resizeObserver && resizeObserver.disconnect();
|
|
16263
|
+
resizeObserver = null;
|
|
16109
16264
|
if (animationFrame) {
|
|
16110
16265
|
cancelAnimationFrame(frameId);
|
|
16111
16266
|
}
|
|
@@ -16168,7 +16323,7 @@ function deepEqual(a, b) {
|
|
|
16168
16323
|
return false;
|
|
16169
16324
|
}
|
|
16170
16325
|
for (i = length; i-- !== 0;) {
|
|
16171
|
-
if (!
|
|
16326
|
+
if (!{}.hasOwnProperty.call(b, keys[i])) {
|
|
16172
16327
|
return false;
|
|
16173
16328
|
}
|
|
16174
16329
|
}
|
|
@@ -16186,6 +16341,19 @@ function deepEqual(a, b) {
|
|
|
16186
16341
|
return a !== a && b !== b;
|
|
16187
16342
|
}
|
|
16188
16343
|
|
|
16344
|
+
function getDPR(element) {
|
|
16345
|
+
if (typeof window === 'undefined') {
|
|
16346
|
+
return 1;
|
|
16347
|
+
}
|
|
16348
|
+
const win = element.ownerDocument.defaultView || window;
|
|
16349
|
+
return win.devicePixelRatio || 1;
|
|
16350
|
+
}
|
|
16351
|
+
|
|
16352
|
+
function roundByDPR(element, value) {
|
|
16353
|
+
const dpr = getDPR(element);
|
|
16354
|
+
return Math.round(value * dpr) / dpr;
|
|
16355
|
+
}
|
|
16356
|
+
|
|
16189
16357
|
function useLatestRef$1(value) {
|
|
16190
16358
|
const ref = React.useRef(value);
|
|
16191
16359
|
index$1(() => {
|
|
@@ -16207,12 +16375,17 @@ function useFloating$1(options) {
|
|
|
16207
16375
|
strategy = 'absolute',
|
|
16208
16376
|
middleware = [],
|
|
16209
16377
|
platform,
|
|
16378
|
+
elements: {
|
|
16379
|
+
reference: externalReference,
|
|
16380
|
+
floating: externalFloating
|
|
16381
|
+
} = {},
|
|
16382
|
+
transform = true,
|
|
16210
16383
|
whileElementsMounted,
|
|
16211
16384
|
open
|
|
16212
16385
|
} = options;
|
|
16213
16386
|
const [data, setData] = React.useState({
|
|
16214
|
-
x:
|
|
16215
|
-
y:
|
|
16387
|
+
x: 0,
|
|
16388
|
+
y: 0,
|
|
16216
16389
|
strategy,
|
|
16217
16390
|
placement,
|
|
16218
16391
|
middlewareData: {},
|
|
@@ -16222,25 +16395,27 @@ function useFloating$1(options) {
|
|
|
16222
16395
|
if (!deepEqual(latestMiddleware, middleware)) {
|
|
16223
16396
|
setLatestMiddleware(middleware);
|
|
16224
16397
|
}
|
|
16225
|
-
const
|
|
16226
|
-
const
|
|
16227
|
-
const dataRef = React.useRef(data);
|
|
16228
|
-
const whileElementsMountedRef = useLatestRef$1(whileElementsMounted);
|
|
16229
|
-
const platformRef = useLatestRef$1(platform);
|
|
16230
|
-
const [reference, _setReference] = React.useState(null);
|
|
16231
|
-
const [floating, _setFloating] = React.useState(null);
|
|
16398
|
+
const [_reference, _setReference] = React.useState(null);
|
|
16399
|
+
const [_floating, _setFloating] = React.useState(null);
|
|
16232
16400
|
const setReference = React.useCallback(node => {
|
|
16233
|
-
if (referenceRef.current
|
|
16401
|
+
if (node != referenceRef.current) {
|
|
16234
16402
|
referenceRef.current = node;
|
|
16235
16403
|
_setReference(node);
|
|
16236
16404
|
}
|
|
16237
|
-
}, []);
|
|
16405
|
+
}, [_setReference]);
|
|
16238
16406
|
const setFloating = React.useCallback(node => {
|
|
16239
|
-
if (floatingRef.current
|
|
16407
|
+
if (node !== floatingRef.current) {
|
|
16240
16408
|
floatingRef.current = node;
|
|
16241
16409
|
_setFloating(node);
|
|
16242
16410
|
}
|
|
16243
|
-
}, []);
|
|
16411
|
+
}, [_setFloating]);
|
|
16412
|
+
const referenceEl = externalReference || _reference;
|
|
16413
|
+
const floatingEl = externalFloating || _floating;
|
|
16414
|
+
const referenceRef = React.useRef(null);
|
|
16415
|
+
const floatingRef = React.useRef(null);
|
|
16416
|
+
const dataRef = React.useRef(data);
|
|
16417
|
+
const whileElementsMountedRef = useLatestRef$1(whileElementsMounted);
|
|
16418
|
+
const platformRef = useLatestRef$1(platform);
|
|
16244
16419
|
const update = React.useCallback(() => {
|
|
16245
16420
|
if (!referenceRef.current || !floatingRef.current) {
|
|
16246
16421
|
return;
|
|
@@ -16283,14 +16458,16 @@ function useFloating$1(options) {
|
|
|
16283
16458
|
};
|
|
16284
16459
|
}, []);
|
|
16285
16460
|
index$1(() => {
|
|
16286
|
-
if (
|
|
16461
|
+
if (referenceEl) referenceRef.current = referenceEl;
|
|
16462
|
+
if (floatingEl) floatingRef.current = floatingEl;
|
|
16463
|
+
if (referenceEl && floatingEl) {
|
|
16287
16464
|
if (whileElementsMountedRef.current) {
|
|
16288
|
-
return whileElementsMountedRef.current(
|
|
16465
|
+
return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
16289
16466
|
} else {
|
|
16290
16467
|
update();
|
|
16291
16468
|
}
|
|
16292
16469
|
}
|
|
16293
|
-
}, [
|
|
16470
|
+
}, [referenceEl, floatingEl, update, whileElementsMountedRef]);
|
|
16294
16471
|
const refs = React.useMemo(() => ({
|
|
16295
16472
|
reference: referenceRef,
|
|
16296
16473
|
floating: floatingRef,
|
|
@@ -16298,147 +16475,44 @@ function useFloating$1(options) {
|
|
|
16298
16475
|
setFloating
|
|
16299
16476
|
}), [setReference, setFloating]);
|
|
16300
16477
|
const elements = React.useMemo(() => ({
|
|
16301
|
-
reference,
|
|
16302
|
-
floating
|
|
16303
|
-
}), [
|
|
16478
|
+
reference: referenceEl,
|
|
16479
|
+
floating: floatingEl
|
|
16480
|
+
}), [referenceEl, floatingEl]);
|
|
16481
|
+
const floatingStyles = React.useMemo(() => {
|
|
16482
|
+
const initialStyles = {
|
|
16483
|
+
position: strategy,
|
|
16484
|
+
left: 0,
|
|
16485
|
+
top: 0
|
|
16486
|
+
};
|
|
16487
|
+
if (!elements.floating) {
|
|
16488
|
+
return initialStyles;
|
|
16489
|
+
}
|
|
16490
|
+
const x = roundByDPR(elements.floating, data.x);
|
|
16491
|
+
const y = roundByDPR(elements.floating, data.y);
|
|
16492
|
+
if (transform) {
|
|
16493
|
+
return {
|
|
16494
|
+
...initialStyles,
|
|
16495
|
+
transform: "translate(" + x + "px, " + y + "px)",
|
|
16496
|
+
...(getDPR(elements.floating) >= 1.5 && {
|
|
16497
|
+
willChange: 'transform'
|
|
16498
|
+
})
|
|
16499
|
+
};
|
|
16500
|
+
}
|
|
16501
|
+
return {
|
|
16502
|
+
position: strategy,
|
|
16503
|
+
left: x,
|
|
16504
|
+
top: y
|
|
16505
|
+
};
|
|
16506
|
+
}, [strategy, transform, elements.floating, data.x, data.y]);
|
|
16304
16507
|
return React.useMemo(() => ({
|
|
16305
16508
|
...data,
|
|
16306
16509
|
update,
|
|
16307
16510
|
refs,
|
|
16308
16511
|
elements,
|
|
16309
|
-
|
|
16310
|
-
|
|
16311
|
-
}), [data, update, refs, elements, setReference, setFloating]);
|
|
16512
|
+
floatingStyles
|
|
16513
|
+
}), [data, update, refs, elements, floatingStyles]);
|
|
16312
16514
|
}
|
|
16313
16515
|
|
|
16314
|
-
var getDefaultParent = function (originalTarget) {
|
|
16315
|
-
if (typeof document === 'undefined') {
|
|
16316
|
-
return null;
|
|
16317
|
-
}
|
|
16318
|
-
var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
|
|
16319
|
-
return sampleTarget.ownerDocument.body;
|
|
16320
|
-
};
|
|
16321
|
-
var counterMap = new WeakMap();
|
|
16322
|
-
var uncontrolledNodes = new WeakMap();
|
|
16323
|
-
var markerMap = {};
|
|
16324
|
-
var lockCount = 0;
|
|
16325
|
-
var unwrapHost = function (node) {
|
|
16326
|
-
return node && (node.host || unwrapHost(node.parentNode));
|
|
16327
|
-
};
|
|
16328
|
-
var correctTargets = function (parent, targets) {
|
|
16329
|
-
return targets.map(function (target) {
|
|
16330
|
-
if (parent.contains(target)) {
|
|
16331
|
-
return target;
|
|
16332
|
-
}
|
|
16333
|
-
var correctedTarget = unwrapHost(target);
|
|
16334
|
-
if (correctedTarget && parent.contains(correctedTarget)) {
|
|
16335
|
-
return correctedTarget;
|
|
16336
|
-
}
|
|
16337
|
-
console.error('aria-hidden', target, 'in not contained inside', parent, '. Doing nothing');
|
|
16338
|
-
return null;
|
|
16339
|
-
}).filter(function (x) { return Boolean(x); });
|
|
16340
|
-
};
|
|
16341
|
-
/**
|
|
16342
|
-
* Marks everything except given node(or nodes) as aria-hidden
|
|
16343
|
-
* @param {Element | Element[]} originalTarget - elements to keep on the page
|
|
16344
|
-
* @param [parentNode] - top element, defaults to document.body
|
|
16345
|
-
* @param {String} [markerName] - a special attribute to mark every node
|
|
16346
|
-
* @param {String} [controlAttribute] - html Attribute to control
|
|
16347
|
-
* @return {Undo} undo command
|
|
16348
|
-
*/
|
|
16349
|
-
var applyAttributeToOthers = function (originalTarget, parentNode, markerName, controlAttribute) {
|
|
16350
|
-
var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
16351
|
-
if (!markerMap[markerName]) {
|
|
16352
|
-
markerMap[markerName] = new WeakMap();
|
|
16353
|
-
}
|
|
16354
|
-
var markerCounter = markerMap[markerName];
|
|
16355
|
-
var hiddenNodes = [];
|
|
16356
|
-
var elementsToKeep = new Set();
|
|
16357
|
-
var elementsToStop = new Set(targets);
|
|
16358
|
-
var keep = function (el) {
|
|
16359
|
-
if (!el || elementsToKeep.has(el)) {
|
|
16360
|
-
return;
|
|
16361
|
-
}
|
|
16362
|
-
elementsToKeep.add(el);
|
|
16363
|
-
keep(el.parentNode);
|
|
16364
|
-
};
|
|
16365
|
-
targets.forEach(keep);
|
|
16366
|
-
var deep = function (parent) {
|
|
16367
|
-
if (!parent || elementsToStop.has(parent)) {
|
|
16368
|
-
return;
|
|
16369
|
-
}
|
|
16370
|
-
Array.prototype.forEach.call(parent.children, function (node) {
|
|
16371
|
-
if (elementsToKeep.has(node)) {
|
|
16372
|
-
deep(node);
|
|
16373
|
-
}
|
|
16374
|
-
else {
|
|
16375
|
-
var attr = node.getAttribute(controlAttribute);
|
|
16376
|
-
var alreadyHidden = attr !== null && attr !== 'false';
|
|
16377
|
-
var counterValue = (counterMap.get(node) || 0) + 1;
|
|
16378
|
-
var markerValue = (markerCounter.get(node) || 0) + 1;
|
|
16379
|
-
counterMap.set(node, counterValue);
|
|
16380
|
-
markerCounter.set(node, markerValue);
|
|
16381
|
-
hiddenNodes.push(node);
|
|
16382
|
-
if (counterValue === 1 && alreadyHidden) {
|
|
16383
|
-
uncontrolledNodes.set(node, true);
|
|
16384
|
-
}
|
|
16385
|
-
if (markerValue === 1) {
|
|
16386
|
-
node.setAttribute(markerName, 'true');
|
|
16387
|
-
}
|
|
16388
|
-
if (!alreadyHidden) {
|
|
16389
|
-
node.setAttribute(controlAttribute, 'true');
|
|
16390
|
-
}
|
|
16391
|
-
}
|
|
16392
|
-
});
|
|
16393
|
-
};
|
|
16394
|
-
deep(parentNode);
|
|
16395
|
-
elementsToKeep.clear();
|
|
16396
|
-
lockCount++;
|
|
16397
|
-
return function () {
|
|
16398
|
-
hiddenNodes.forEach(function (node) {
|
|
16399
|
-
var counterValue = counterMap.get(node) - 1;
|
|
16400
|
-
var markerValue = markerCounter.get(node) - 1;
|
|
16401
|
-
counterMap.set(node, counterValue);
|
|
16402
|
-
markerCounter.set(node, markerValue);
|
|
16403
|
-
if (!counterValue) {
|
|
16404
|
-
if (!uncontrolledNodes.has(node)) {
|
|
16405
|
-
node.removeAttribute(controlAttribute);
|
|
16406
|
-
}
|
|
16407
|
-
uncontrolledNodes.delete(node);
|
|
16408
|
-
}
|
|
16409
|
-
if (!markerValue) {
|
|
16410
|
-
node.removeAttribute(markerName);
|
|
16411
|
-
}
|
|
16412
|
-
});
|
|
16413
|
-
lockCount--;
|
|
16414
|
-
if (!lockCount) {
|
|
16415
|
-
// clear
|
|
16416
|
-
counterMap = new WeakMap();
|
|
16417
|
-
counterMap = new WeakMap();
|
|
16418
|
-
uncontrolledNodes = new WeakMap();
|
|
16419
|
-
markerMap = {};
|
|
16420
|
-
}
|
|
16421
|
-
};
|
|
16422
|
-
};
|
|
16423
|
-
/**
|
|
16424
|
-
* Marks everything except given node(or nodes) as aria-hidden
|
|
16425
|
-
* @param {Element | Element[]} originalTarget - elements to keep on the page
|
|
16426
|
-
* @param [parentNode] - top element, defaults to document.body
|
|
16427
|
-
* @param {String} [markerName] - a special attribute to mark every node
|
|
16428
|
-
* @return {Undo} undo command
|
|
16429
|
-
*/
|
|
16430
|
-
var hideOthers = function (originalTarget, parentNode, markerName) {
|
|
16431
|
-
if (markerName === void 0) { markerName = 'data-aria-hidden'; }
|
|
16432
|
-
var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
16433
|
-
var activeParentNode = parentNode || getDefaultParent(originalTarget);
|
|
16434
|
-
if (!activeParentNode) {
|
|
16435
|
-
return function () { return null; };
|
|
16436
|
-
}
|
|
16437
|
-
// we should not hide ariaLive elements - https://github.com/theKashey/aria-hidden/issues/10
|
|
16438
|
-
targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll('[aria-live]')));
|
|
16439
|
-
return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
|
|
16440
|
-
};
|
|
16441
|
-
|
|
16442
16516
|
/*!
|
|
16443
16517
|
* tabbable 6.0.1
|
|
16444
16518
|
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
@@ -16861,8 +16935,53 @@ var tabbable = function tabbable(el, options) {
|
|
|
16861
16935
|
return sortByOrder(candidates);
|
|
16862
16936
|
};
|
|
16863
16937
|
|
|
16938
|
+
/**
|
|
16939
|
+
* Merges an array of refs into a single memoized callback ref or `null`.
|
|
16940
|
+
* @see https://floating-ui.com/docs/useMergeRefs
|
|
16941
|
+
*/
|
|
16942
|
+
function useMergeRefs(refs) {
|
|
16943
|
+
return React.useMemo(() => {
|
|
16944
|
+
if (refs.every(ref => ref == null)) {
|
|
16945
|
+
return null;
|
|
16946
|
+
}
|
|
16947
|
+
return value => {
|
|
16948
|
+
refs.forEach(ref => {
|
|
16949
|
+
if (typeof ref === 'function') {
|
|
16950
|
+
ref(value);
|
|
16951
|
+
} else if (ref != null) {
|
|
16952
|
+
ref.current = value;
|
|
16953
|
+
}
|
|
16954
|
+
});
|
|
16955
|
+
};
|
|
16956
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
16957
|
+
}, refs);
|
|
16958
|
+
}
|
|
16959
|
+
|
|
16960
|
+
let rafId = 0;
|
|
16961
|
+
function enqueueFocus(el, options) {
|
|
16962
|
+
if (options === void 0) {
|
|
16963
|
+
options = {};
|
|
16964
|
+
}
|
|
16965
|
+
const {
|
|
16966
|
+
preventScroll = false,
|
|
16967
|
+
cancelPrevious = true,
|
|
16968
|
+
sync = false
|
|
16969
|
+
} = options;
|
|
16970
|
+
cancelPrevious && cancelAnimationFrame(rafId);
|
|
16971
|
+
const exec = () => el == null ? void 0 : el.focus({
|
|
16972
|
+
preventScroll
|
|
16973
|
+
});
|
|
16974
|
+
if (sync) {
|
|
16975
|
+
exec();
|
|
16976
|
+
} else {
|
|
16977
|
+
rafId = requestAnimationFrame(exec);
|
|
16978
|
+
}
|
|
16979
|
+
}
|
|
16980
|
+
|
|
16981
|
+
var index = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
|
|
16982
|
+
|
|
16864
16983
|
function _extends() {
|
|
16865
|
-
_extends = Object.assign
|
|
16984
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
16866
16985
|
for (var i = 1; i < arguments.length; i++) {
|
|
16867
16986
|
var source = arguments[i];
|
|
16868
16987
|
for (var key in source) {
|
|
@@ -16876,8 +16995,6 @@ function _extends() {
|
|
|
16876
16995
|
return _extends.apply(this, arguments);
|
|
16877
16996
|
}
|
|
16878
16997
|
|
|
16879
|
-
var index = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
|
|
16880
|
-
|
|
16881
16998
|
let serverHandoffComplete = false;
|
|
16882
16999
|
let count = 0;
|
|
16883
17000
|
const genId = () => "floating-ui-" + count++;
|
|
@@ -16933,105 +17050,8 @@ const useFloatingParentNodeId = () => {
|
|
|
16933
17050
|
};
|
|
16934
17051
|
const useFloatingTree = () => React.useContext(FloatingTreeContext);
|
|
16935
17052
|
|
|
16936
|
-
function
|
|
16937
|
-
return
|
|
16938
|
-
}
|
|
16939
|
-
|
|
16940
|
-
// Avoid Chrome DevTools blue warning.
|
|
16941
|
-
function getPlatform() {
|
|
16942
|
-
const uaData = navigator.userAgentData;
|
|
16943
|
-
if (uaData != null && uaData.platform) {
|
|
16944
|
-
return uaData.platform;
|
|
16945
|
-
}
|
|
16946
|
-
return navigator.platform;
|
|
16947
|
-
}
|
|
16948
|
-
function getUserAgent() {
|
|
16949
|
-
const uaData = navigator.userAgentData;
|
|
16950
|
-
if (uaData && Array.isArray(uaData.brands)) {
|
|
16951
|
-
return uaData.brands.map(_ref => {
|
|
16952
|
-
let {
|
|
16953
|
-
brand,
|
|
16954
|
-
version
|
|
16955
|
-
} = _ref;
|
|
16956
|
-
return brand + "/" + version;
|
|
16957
|
-
}).join(' ');
|
|
16958
|
-
}
|
|
16959
|
-
return navigator.userAgent;
|
|
16960
|
-
}
|
|
16961
|
-
|
|
16962
|
-
function getWindow(value) {
|
|
16963
|
-
return getDocument(value).defaultView || window;
|
|
16964
|
-
}
|
|
16965
|
-
function isElement(value) {
|
|
16966
|
-
return value ? value instanceof getWindow(value).Element : false;
|
|
16967
|
-
}
|
|
16968
|
-
function isHTMLElement(value) {
|
|
16969
|
-
return value ? value instanceof getWindow(value).HTMLElement : false;
|
|
16970
|
-
}
|
|
16971
|
-
function isShadowRoot(node) {
|
|
16972
|
-
// Browsers without `ShadowRoot` support
|
|
16973
|
-
if (typeof ShadowRoot === 'undefined') {
|
|
16974
|
-
return false;
|
|
16975
|
-
}
|
|
16976
|
-
const OwnElement = getWindow(node).ShadowRoot;
|
|
16977
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
16978
|
-
}
|
|
16979
|
-
|
|
16980
|
-
// License: https://github.com/adobe/react-spectrum/blob/b35d5c02fe900badccd0cf1a8f23bb593419f238/packages/@react-aria/utils/src/isVirtualEvent.ts
|
|
16981
|
-
function isVirtualClick(event) {
|
|
16982
|
-
if (event.mozInputSource === 0 && event.isTrusted) {
|
|
16983
|
-
return true;
|
|
16984
|
-
}
|
|
16985
|
-
const androidRe = /Android/i;
|
|
16986
|
-
if ((androidRe.test(getPlatform()) || androidRe.test(getUserAgent())) && event.pointerType) {
|
|
16987
|
-
return event.type === 'click' && event.buttons === 1;
|
|
16988
|
-
}
|
|
16989
|
-
return event.detail === 0 && !event.pointerType;
|
|
16990
|
-
}
|
|
16991
|
-
function isVirtualPointerEvent(event) {
|
|
16992
|
-
return event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType !== 'mouse' ||
|
|
16993
|
-
// iOS VoiceOver returns 0.333• for width/height.
|
|
16994
|
-
event.width < 1 && event.height < 1 && event.pressure === 0 && event.detail === 0;
|
|
16995
|
-
}
|
|
16996
|
-
function isSafari() {
|
|
16997
|
-
// Chrome DevTools does not complain about navigator.vendor
|
|
16998
|
-
return /apple/i.test(navigator.vendor);
|
|
16999
|
-
}
|
|
17000
|
-
function isMouseLikePointerType(pointerType, strict) {
|
|
17001
|
-
// On some Linux machines with Chromium, mouse inputs return a `pointerType`
|
|
17002
|
-
// of "pen": https://github.com/floating-ui/floating-ui/issues/2015
|
|
17003
|
-
const values = ['mouse', 'pen'];
|
|
17004
|
-
if (!strict) {
|
|
17005
|
-
values.push('', undefined);
|
|
17006
|
-
}
|
|
17007
|
-
return values.includes(pointerType);
|
|
17008
|
-
}
|
|
17009
|
-
|
|
17010
|
-
function contains(parent, child) {
|
|
17011
|
-
if (!parent || !child) {
|
|
17012
|
-
return false;
|
|
17013
|
-
}
|
|
17014
|
-
const rootNode = child.getRootNode && child.getRootNode();
|
|
17015
|
-
|
|
17016
|
-
// First, attempt with faster native method
|
|
17017
|
-
if (parent.contains(child)) {
|
|
17018
|
-
return true;
|
|
17019
|
-
}
|
|
17020
|
-
|
|
17021
|
-
// then fallback to custom implementation with Shadow DOM support
|
|
17022
|
-
if (rootNode && isShadowRoot(rootNode)) {
|
|
17023
|
-
let next = child;
|
|
17024
|
-
while (next) {
|
|
17025
|
-
if (parent === next) {
|
|
17026
|
-
return true;
|
|
17027
|
-
}
|
|
17028
|
-
// @ts-ignore
|
|
17029
|
-
next = next.parentNode || next.host;
|
|
17030
|
-
}
|
|
17031
|
-
}
|
|
17032
|
-
|
|
17033
|
-
// Give up, the result is false
|
|
17034
|
-
return false;
|
|
17053
|
+
function createAttribute(name) {
|
|
17054
|
+
return "data-floating-ui-" + name;
|
|
17035
17055
|
}
|
|
17036
17056
|
|
|
17037
17057
|
function useLatestRef(value) {
|
|
@@ -17042,7 +17062,7 @@ function useLatestRef(value) {
|
|
|
17042
17062
|
return ref;
|
|
17043
17063
|
}
|
|
17044
17064
|
|
|
17045
|
-
const safePolygonIdentifier = '
|
|
17065
|
+
const safePolygonIdentifier = /*#__PURE__*/createAttribute('safe-polygon');
|
|
17046
17066
|
function getDelay(value, prop, pointerType) {
|
|
17047
17067
|
if (pointerType && !isMouseLikePointerType(pointerType)) {
|
|
17048
17068
|
return 0;
|
|
@@ -17057,7 +17077,7 @@ function getDelay(value, prop, pointerType) {
|
|
|
17057
17077
|
* CSS `:hover`.
|
|
17058
17078
|
* @see https://floating-ui.com/docs/useHover
|
|
17059
17079
|
*/
|
|
17060
|
-
|
|
17080
|
+
function useHover$1(context, props) {
|
|
17061
17081
|
if (props === void 0) {
|
|
17062
17082
|
props = {};
|
|
17063
17083
|
}
|
|
@@ -17117,9 +17137,9 @@ const useHover$1 = function (context, props) {
|
|
|
17117
17137
|
if (!enabled || !handleCloseRef.current || !open) {
|
|
17118
17138
|
return;
|
|
17119
17139
|
}
|
|
17120
|
-
function onLeave() {
|
|
17140
|
+
function onLeave(event) {
|
|
17121
17141
|
if (isHoverOpen()) {
|
|
17122
|
-
onOpenChange(false);
|
|
17142
|
+
onOpenChange(false, event);
|
|
17123
17143
|
}
|
|
17124
17144
|
}
|
|
17125
17145
|
const html = getDocument(floating).documentElement;
|
|
@@ -17128,17 +17148,17 @@ const useHover$1 = function (context, props) {
|
|
|
17128
17148
|
html.removeEventListener('mouseleave', onLeave);
|
|
17129
17149
|
};
|
|
17130
17150
|
}, [floating, open, onOpenChange, enabled, handleCloseRef, dataRef, isHoverOpen]);
|
|
17131
|
-
const closeWithDelay = React.useCallback(function (runElseBranch) {
|
|
17151
|
+
const closeWithDelay = React.useCallback(function (event, runElseBranch) {
|
|
17132
17152
|
if (runElseBranch === void 0) {
|
|
17133
17153
|
runElseBranch = true;
|
|
17134
17154
|
}
|
|
17135
17155
|
const closeDelay = getDelay(delayRef.current, 'close', pointerTypeRef.current);
|
|
17136
17156
|
if (closeDelay && !handlerRef.current) {
|
|
17137
17157
|
clearTimeout(timeoutRef.current);
|
|
17138
|
-
timeoutRef.current = setTimeout(() => onOpenChange(false), closeDelay);
|
|
17158
|
+
timeoutRef.current = setTimeout(() => onOpenChange(false, event), closeDelay);
|
|
17139
17159
|
} else if (runElseBranch) {
|
|
17140
17160
|
clearTimeout(timeoutRef.current);
|
|
17141
|
-
onOpenChange(false);
|
|
17161
|
+
onOpenChange(false, event);
|
|
17142
17162
|
}
|
|
17143
17163
|
}, [delayRef, onOpenChange]);
|
|
17144
17164
|
const cleanupMouseMoveHandler = React.useCallback(() => {
|
|
@@ -17170,14 +17190,13 @@ const useHover$1 = function (context, props) {
|
|
|
17170
17190
|
if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current) || restMs > 0 && getDelay(delayRef.current, 'open') === 0) {
|
|
17171
17191
|
return;
|
|
17172
17192
|
}
|
|
17173
|
-
dataRef.current.openEvent = event;
|
|
17174
17193
|
const openDelay = getDelay(delayRef.current, 'open', pointerTypeRef.current);
|
|
17175
17194
|
if (openDelay) {
|
|
17176
17195
|
timeoutRef.current = setTimeout(() => {
|
|
17177
|
-
onOpenChange(true);
|
|
17196
|
+
onOpenChange(true, event);
|
|
17178
17197
|
}, openDelay);
|
|
17179
17198
|
} else {
|
|
17180
|
-
onOpenChange(true);
|
|
17199
|
+
onOpenChange(true, event);
|
|
17181
17200
|
}
|
|
17182
17201
|
}
|
|
17183
17202
|
function onMouseLeave(event) {
|
|
@@ -17200,7 +17219,8 @@ const useHover$1 = function (context, props) {
|
|
|
17200
17219
|
onClose() {
|
|
17201
17220
|
clearPointerEvents();
|
|
17202
17221
|
cleanupMouseMoveHandler();
|
|
17203
|
-
|
|
17222
|
+
// Should the event expose that it was closed by `safePolygon`?
|
|
17223
|
+
closeWithDelay(event);
|
|
17204
17224
|
}
|
|
17205
17225
|
});
|
|
17206
17226
|
const handler = handlerRef.current;
|
|
@@ -17216,7 +17236,7 @@ const useHover$1 = function (context, props) {
|
|
|
17216
17236
|
// consistently.
|
|
17217
17237
|
const shouldClose = pointerTypeRef.current === 'touch' ? !contains(floating, event.relatedTarget) : true;
|
|
17218
17238
|
if (shouldClose) {
|
|
17219
|
-
closeWithDelay();
|
|
17239
|
+
closeWithDelay(event);
|
|
17220
17240
|
}
|
|
17221
17241
|
}
|
|
17222
17242
|
|
|
@@ -17235,7 +17255,7 @@ const useHover$1 = function (context, props) {
|
|
|
17235
17255
|
onClose() {
|
|
17236
17256
|
clearPointerEvents();
|
|
17237
17257
|
cleanupMouseMoveHandler();
|
|
17238
|
-
closeWithDelay();
|
|
17258
|
+
closeWithDelay(event);
|
|
17239
17259
|
}
|
|
17240
17260
|
})(event);
|
|
17241
17261
|
}
|
|
@@ -17302,7 +17322,7 @@ const useHover$1 = function (context, props) {
|
|
|
17302
17322
|
clearTimeout(restTimeoutRef.current);
|
|
17303
17323
|
clearPointerEvents();
|
|
17304
17324
|
};
|
|
17305
|
-
}, [enabled, cleanupMouseMoveHandler, clearPointerEvents]);
|
|
17325
|
+
}, [enabled, domReference, cleanupMouseMoveHandler, clearPointerEvents]);
|
|
17306
17326
|
return React.useMemo(() => {
|
|
17307
17327
|
if (!enabled) {
|
|
17308
17328
|
return {};
|
|
@@ -17314,14 +17334,14 @@ const useHover$1 = function (context, props) {
|
|
|
17314
17334
|
reference: {
|
|
17315
17335
|
onPointerDown: setPointerRef,
|
|
17316
17336
|
onPointerEnter: setPointerRef,
|
|
17317
|
-
onMouseMove() {
|
|
17337
|
+
onMouseMove(event) {
|
|
17318
17338
|
if (open || restMs === 0) {
|
|
17319
17339
|
return;
|
|
17320
17340
|
}
|
|
17321
17341
|
clearTimeout(restTimeoutRef.current);
|
|
17322
17342
|
restTimeoutRef.current = setTimeout(() => {
|
|
17323
17343
|
if (!blockMouseMoveRef.current) {
|
|
17324
|
-
onOpenChange(true);
|
|
17344
|
+
onOpenChange(true, event.nativeEvent);
|
|
17325
17345
|
}
|
|
17326
17346
|
}, restMs);
|
|
17327
17347
|
}
|
|
@@ -17330,51 +17350,18 @@ const useHover$1 = function (context, props) {
|
|
|
17330
17350
|
onMouseEnter() {
|
|
17331
17351
|
clearTimeout(timeoutRef.current);
|
|
17332
17352
|
},
|
|
17333
|
-
onMouseLeave() {
|
|
17353
|
+
onMouseLeave(event) {
|
|
17334
17354
|
events.emit('dismiss', {
|
|
17335
17355
|
type: 'mouseLeave',
|
|
17336
17356
|
data: {
|
|
17337
17357
|
returnFocus: false
|
|
17338
17358
|
}
|
|
17339
17359
|
});
|
|
17340
|
-
closeWithDelay(false);
|
|
17360
|
+
closeWithDelay(event.nativeEvent, false);
|
|
17341
17361
|
}
|
|
17342
17362
|
}
|
|
17343
17363
|
};
|
|
17344
17364
|
}, [events, enabled, restMs, open, onOpenChange, closeWithDelay]);
|
|
17345
|
-
};
|
|
17346
|
-
|
|
17347
|
-
/**
|
|
17348
|
-
* Find the real active element. Traverses into shadowRoots.
|
|
17349
|
-
*/
|
|
17350
|
-
function activeElement(doc) {
|
|
17351
|
-
let activeElement = doc.activeElement;
|
|
17352
|
-
while (((_activeElement = activeElement) == null ? void 0 : (_activeElement$shadow = _activeElement.shadowRoot) == null ? void 0 : _activeElement$shadow.activeElement) != null) {
|
|
17353
|
-
var _activeElement, _activeElement$shadow;
|
|
17354
|
-
activeElement = activeElement.shadowRoot.activeElement;
|
|
17355
|
-
}
|
|
17356
|
-
return activeElement;
|
|
17357
|
-
}
|
|
17358
|
-
|
|
17359
|
-
let rafId = 0;
|
|
17360
|
-
function enqueueFocus(el, options) {
|
|
17361
|
-
if (options === void 0) {
|
|
17362
|
-
options = {};
|
|
17363
|
-
}
|
|
17364
|
-
const {
|
|
17365
|
-
preventScroll = false,
|
|
17366
|
-
cancelPrevious = true,
|
|
17367
|
-
sync = false
|
|
17368
|
-
} = options;
|
|
17369
|
-
cancelPrevious && cancelAnimationFrame(rafId);
|
|
17370
|
-
const exec = () => el == null ? void 0 : el.focus({
|
|
17371
|
-
preventScroll
|
|
17372
|
-
});
|
|
17373
|
-
if (sync) {
|
|
17374
|
-
exec();
|
|
17375
|
-
} else {
|
|
17376
|
-
rafId = requestAnimationFrame(exec);
|
|
17377
|
-
}
|
|
17378
17365
|
}
|
|
17379
17366
|
|
|
17380
17367
|
function getAncestors(nodes, id) {
|
|
@@ -17410,24 +17397,107 @@ function getChildren(nodes, id) {
|
|
|
17410
17397
|
return allChildren;
|
|
17411
17398
|
}
|
|
17412
17399
|
|
|
17413
|
-
|
|
17414
|
-
|
|
17415
|
-
|
|
17400
|
+
// Modified to add conditional `aria-hidden` support:
|
|
17401
|
+
// https://github.com/theKashey/aria-hidden/blob/9220c8f4a4fd35f63bee5510a9f41a37264382d4/src/index.ts
|
|
17402
|
+
let counterMap = /*#__PURE__*/new WeakMap();
|
|
17403
|
+
let uncontrolledElementsSet = /*#__PURE__*/new WeakSet();
|
|
17404
|
+
let markerMap = {};
|
|
17405
|
+
let lockCount = 0;
|
|
17406
|
+
const supportsInert = () => typeof HTMLElement !== 'undefined' && 'inert' in HTMLElement.prototype;
|
|
17407
|
+
const unwrapHost = node => node && (node.host || unwrapHost(node.parentNode));
|
|
17408
|
+
const correctElements = (parent, targets) => targets.map(target => {
|
|
17409
|
+
if (parent.contains(target)) {
|
|
17410
|
+
return target;
|
|
17416
17411
|
}
|
|
17417
|
-
|
|
17418
|
-
|
|
17419
|
-
|
|
17420
|
-
|
|
17421
|
-
|
|
17422
|
-
|
|
17423
|
-
|
|
17424
|
-
|
|
17425
|
-
|
|
17412
|
+
const correctedTarget = unwrapHost(target);
|
|
17413
|
+
if (parent.contains(correctedTarget)) {
|
|
17414
|
+
return correctedTarget;
|
|
17415
|
+
}
|
|
17416
|
+
return null;
|
|
17417
|
+
}).filter(x => x != null);
|
|
17418
|
+
function applyAttributeToOthers(uncorrectedAvoidElements, body, ariaHidden, inert) {
|
|
17419
|
+
const markerName = 'data-floating-ui-inert';
|
|
17420
|
+
const controlAttribute = inert ? 'inert' : ariaHidden ? 'aria-hidden' : null;
|
|
17421
|
+
const avoidElements = correctElements(body, uncorrectedAvoidElements);
|
|
17422
|
+
const elementsToKeep = new Set();
|
|
17423
|
+
const elementsToStop = new Set(avoidElements);
|
|
17424
|
+
const hiddenElements = [];
|
|
17425
|
+
if (!markerMap[markerName]) {
|
|
17426
|
+
markerMap[markerName] = new WeakMap();
|
|
17427
|
+
}
|
|
17428
|
+
const markerCounter = markerMap[markerName];
|
|
17429
|
+
avoidElements.forEach(keep);
|
|
17430
|
+
deep(body);
|
|
17431
|
+
elementsToKeep.clear();
|
|
17432
|
+
function keep(el) {
|
|
17433
|
+
if (!el || elementsToKeep.has(el)) {
|
|
17434
|
+
return;
|
|
17435
|
+
}
|
|
17436
|
+
elementsToKeep.add(el);
|
|
17437
|
+
el.parentNode && keep(el.parentNode);
|
|
17438
|
+
}
|
|
17439
|
+
function deep(parent) {
|
|
17440
|
+
if (!parent || elementsToStop.has(parent)) {
|
|
17441
|
+
return;
|
|
17442
|
+
}
|
|
17443
|
+
Array.prototype.forEach.call(parent.children, node => {
|
|
17444
|
+
if (elementsToKeep.has(node)) {
|
|
17445
|
+
deep(node);
|
|
17446
|
+
} else {
|
|
17447
|
+
const attr = controlAttribute ? node.getAttribute(controlAttribute) : null;
|
|
17448
|
+
const alreadyHidden = attr !== null && attr !== 'false';
|
|
17449
|
+
const counterValue = (counterMap.get(node) || 0) + 1;
|
|
17450
|
+
const markerValue = (markerCounter.get(node) || 0) + 1;
|
|
17451
|
+
counterMap.set(node, counterValue);
|
|
17452
|
+
markerCounter.set(node, markerValue);
|
|
17453
|
+
hiddenElements.push(node);
|
|
17454
|
+
if (counterValue === 1 && alreadyHidden) {
|
|
17455
|
+
uncontrolledElementsSet.add(node);
|
|
17456
|
+
}
|
|
17457
|
+
if (markerValue === 1) {
|
|
17458
|
+
node.setAttribute(markerName, '');
|
|
17459
|
+
}
|
|
17460
|
+
if (!alreadyHidden && controlAttribute) {
|
|
17461
|
+
node.setAttribute(controlAttribute, 'true');
|
|
17462
|
+
}
|
|
17463
|
+
}
|
|
17464
|
+
});
|
|
17465
|
+
}
|
|
17466
|
+
lockCount++;
|
|
17467
|
+
return () => {
|
|
17468
|
+
hiddenElements.forEach(element => {
|
|
17469
|
+
const counterValue = (counterMap.get(element) || 0) - 1;
|
|
17470
|
+
const markerValue = (markerCounter.get(element) || 0) - 1;
|
|
17471
|
+
counterMap.set(element, counterValue);
|
|
17472
|
+
markerCounter.set(element, markerValue);
|
|
17473
|
+
if (!counterValue) {
|
|
17474
|
+
if (!uncontrolledElementsSet.has(element) && controlAttribute) {
|
|
17475
|
+
element.removeAttribute(controlAttribute);
|
|
17476
|
+
}
|
|
17477
|
+
uncontrolledElementsSet.delete(element);
|
|
17478
|
+
}
|
|
17479
|
+
if (!markerValue) {
|
|
17480
|
+
element.removeAttribute(markerName);
|
|
17481
|
+
}
|
|
17482
|
+
});
|
|
17483
|
+
lockCount--;
|
|
17484
|
+
if (!lockCount) {
|
|
17485
|
+
counterMap = new WeakMap();
|
|
17486
|
+
counterMap = new WeakMap();
|
|
17487
|
+
uncontrolledElementsSet = new WeakSet();
|
|
17488
|
+
markerMap = {};
|
|
17489
|
+
}
|
|
17490
|
+
};
|
|
17426
17491
|
}
|
|
17427
|
-
|
|
17428
|
-
|
|
17429
|
-
|
|
17430
|
-
|
|
17492
|
+
function markOthers(avoidElements, ariaHidden, inert) {
|
|
17493
|
+
if (ariaHidden === void 0) {
|
|
17494
|
+
ariaHidden = false;
|
|
17495
|
+
}
|
|
17496
|
+
if (inert === void 0) {
|
|
17497
|
+
inert = false;
|
|
17498
|
+
}
|
|
17499
|
+
const body = getDocument(avoidElements[0]).body;
|
|
17500
|
+
return applyAttributeToOthers(avoidElements.concat(Array.from(body.querySelectorAll('[aria-live]'))), body, ariaHidden, inert);
|
|
17431
17501
|
}
|
|
17432
17502
|
|
|
17433
17503
|
const getTabbableOptions = () => ({
|
|
@@ -17517,20 +17587,20 @@ const FocusGuard = /*#__PURE__*/React.forwardRef(function FocusGuard(props, ref)
|
|
|
17517
17587
|
document.removeEventListener('keydown', setActiveElementOnTab);
|
|
17518
17588
|
};
|
|
17519
17589
|
}, []);
|
|
17520
|
-
|
|
17521
|
-
ref
|
|
17522
|
-
tabIndex: 0
|
|
17590
|
+
const restProps = {
|
|
17591
|
+
ref,
|
|
17592
|
+
tabIndex: 0,
|
|
17523
17593
|
// Role is only for VoiceOver
|
|
17524
|
-
,
|
|
17525
|
-
role:
|
|
17526
|
-
|
|
17527
|
-
"data-floating-ui-focus-guard": "",
|
|
17594
|
+
role,
|
|
17595
|
+
'aria-hidden': role ? undefined : true,
|
|
17596
|
+
[createAttribute('focus-guard')]: '',
|
|
17528
17597
|
style: HIDDEN_STYLES
|
|
17529
|
-
}
|
|
17598
|
+
};
|
|
17599
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, props, restProps));
|
|
17530
17600
|
});
|
|
17531
17601
|
|
|
17532
17602
|
const PortalContext = /*#__PURE__*/React.createContext(null);
|
|
17533
|
-
|
|
17603
|
+
function useFloatingPortalNode(_temp) {
|
|
17534
17604
|
let {
|
|
17535
17605
|
id,
|
|
17536
17606
|
root
|
|
@@ -17538,20 +17608,39 @@ const useFloatingPortalNode = function (_temp) {
|
|
|
17538
17608
|
const [portalNode, setPortalNode] = React.useState(null);
|
|
17539
17609
|
const uniqueId = useId();
|
|
17540
17610
|
const portalContext = usePortalContext();
|
|
17611
|
+
const data = React.useMemo(() => ({
|
|
17612
|
+
id,
|
|
17613
|
+
root,
|
|
17614
|
+
portalContext,
|
|
17615
|
+
uniqueId
|
|
17616
|
+
}), [id, root, portalContext, uniqueId]);
|
|
17617
|
+
const dataRef = React.useRef();
|
|
17541
17618
|
index(() => {
|
|
17619
|
+
return () => {
|
|
17620
|
+
portalNode == null ? void 0 : portalNode.remove();
|
|
17621
|
+
};
|
|
17622
|
+
}, [portalNode, data]);
|
|
17623
|
+
index(() => {
|
|
17624
|
+
if (dataRef.current === data) return;
|
|
17625
|
+
dataRef.current = data;
|
|
17626
|
+
const {
|
|
17627
|
+
id,
|
|
17628
|
+
root,
|
|
17629
|
+
portalContext,
|
|
17630
|
+
uniqueId
|
|
17631
|
+
} = data;
|
|
17542
17632
|
const existingIdRoot = id ? document.getElementById(id) : null;
|
|
17543
|
-
const attr = '
|
|
17633
|
+
const attr = createAttribute('portal');
|
|
17544
17634
|
if (existingIdRoot) {
|
|
17545
17635
|
const subRoot = document.createElement('div');
|
|
17546
17636
|
subRoot.id = uniqueId;
|
|
17547
17637
|
subRoot.setAttribute(attr, '');
|
|
17548
17638
|
existingIdRoot.appendChild(subRoot);
|
|
17549
17639
|
setPortalNode(subRoot);
|
|
17550
|
-
return () => {
|
|
17551
|
-
subRoot.remove();
|
|
17552
|
-
};
|
|
17553
17640
|
} else {
|
|
17554
|
-
let container = (portalContext == null ? void 0 : portalContext.portalNode)
|
|
17641
|
+
let container = root || (portalContext == null ? void 0 : portalContext.portalNode);
|
|
17642
|
+
if (container && !isElement(container)) container = container.current;
|
|
17643
|
+
container = container || document.body;
|
|
17555
17644
|
let idWrapper = null;
|
|
17556
17645
|
if (id) {
|
|
17557
17646
|
idWrapper = document.createElement('div');
|
|
@@ -17561,25 +17650,19 @@ const useFloatingPortalNode = function (_temp) {
|
|
|
17561
17650
|
const subRoot = document.createElement('div');
|
|
17562
17651
|
subRoot.id = uniqueId;
|
|
17563
17652
|
subRoot.setAttribute(attr, '');
|
|
17564
|
-
setPortalNode(subRoot);
|
|
17565
17653
|
container = idWrapper || container;
|
|
17566
17654
|
container.appendChild(subRoot);
|
|
17567
|
-
|
|
17568
|
-
var _idWrapper;
|
|
17569
|
-
subRoot.remove();
|
|
17570
|
-
(_idWrapper = idWrapper) == null ? void 0 : _idWrapper.remove();
|
|
17571
|
-
};
|
|
17655
|
+
setPortalNode(subRoot);
|
|
17572
17656
|
}
|
|
17573
|
-
}, [
|
|
17657
|
+
}, [data]);
|
|
17574
17658
|
return portalNode;
|
|
17575
|
-
}
|
|
17576
|
-
|
|
17659
|
+
}
|
|
17577
17660
|
/**
|
|
17578
17661
|
* Portals the floating element into a given container element — by default,
|
|
17579
17662
|
* outside of the app root and into the body.
|
|
17580
17663
|
* @see https://floating-ui.com/docs/FloatingPortal
|
|
17581
17664
|
*/
|
|
17582
|
-
|
|
17665
|
+
function FloatingPortal(_ref) {
|
|
17583
17666
|
let {
|
|
17584
17667
|
children,
|
|
17585
17668
|
id,
|
|
@@ -17600,7 +17683,9 @@ const FloatingPortal = _ref => {
|
|
|
17600
17683
|
// rendered.
|
|
17601
17684
|
!!focusManagerState &&
|
|
17602
17685
|
// Guards are only for non-modal focus management.
|
|
17603
|
-
!focusManagerState.modal &&
|
|
17686
|
+
!focusManagerState.modal &&
|
|
17687
|
+
// Don't render if unmount is transitioning.
|
|
17688
|
+
focusManagerState.open && preserveTabOrder && !!(root || portalNode);
|
|
17604
17689
|
|
|
17605
17690
|
// https://codesandbox.io/s/tabbable-portal-f4tng?file=/src/TabbablePortal.tsx
|
|
17606
17691
|
React.useEffect(() => {
|
|
@@ -17662,11 +17747,11 @@ const FloatingPortal = _ref => {
|
|
|
17662
17747
|
} else {
|
|
17663
17748
|
const nextTabbable = getNextTabbable() || (focusManagerState == null ? void 0 : focusManagerState.refs.domReference.current);
|
|
17664
17749
|
nextTabbable == null ? void 0 : nextTabbable.focus();
|
|
17665
|
-
(focusManagerState == null ? void 0 : focusManagerState.closeOnFocusOut) && (focusManagerState == null ? void 0 : focusManagerState.onOpenChange(false));
|
|
17750
|
+
(focusManagerState == null ? void 0 : focusManagerState.closeOnFocusOut) && (focusManagerState == null ? void 0 : focusManagerState.onOpenChange(false, event.nativeEvent));
|
|
17666
17751
|
}
|
|
17667
17752
|
}
|
|
17668
17753
|
}));
|
|
17669
|
-
}
|
|
17754
|
+
}
|
|
17670
17755
|
const usePortalContext = () => React.useContext(PortalContext);
|
|
17671
17756
|
|
|
17672
17757
|
const VisuallyHiddenDismiss = /*#__PURE__*/React.forwardRef(function VisuallyHiddenDismiss(props, ref) {
|
|
@@ -17681,18 +17766,19 @@ const VisuallyHiddenDismiss = /*#__PURE__*/React.forwardRef(function VisuallyHid
|
|
|
17681
17766
|
* Provides focus management for the floating element.
|
|
17682
17767
|
* @see https://floating-ui.com/docs/FloatingFocusManager
|
|
17683
17768
|
*/
|
|
17684
|
-
function FloatingFocusManager(
|
|
17685
|
-
|
|
17769
|
+
function FloatingFocusManager(props) {
|
|
17770
|
+
const {
|
|
17686
17771
|
context,
|
|
17687
17772
|
children,
|
|
17773
|
+
disabled = false,
|
|
17688
17774
|
order = ['content'],
|
|
17689
|
-
guards = true,
|
|
17775
|
+
guards: _guards = true,
|
|
17690
17776
|
initialFocus = 0,
|
|
17691
17777
|
returnFocus = true,
|
|
17692
17778
|
modal = true,
|
|
17693
17779
|
visuallyHiddenDismiss = false,
|
|
17694
17780
|
closeOnFocusOut = true
|
|
17695
|
-
} =
|
|
17781
|
+
} = props;
|
|
17696
17782
|
const {
|
|
17697
17783
|
open,
|
|
17698
17784
|
refs,
|
|
@@ -17705,12 +17791,14 @@ function FloatingFocusManager(_ref) {
|
|
|
17705
17791
|
floating
|
|
17706
17792
|
}
|
|
17707
17793
|
} = context;
|
|
17794
|
+
|
|
17795
|
+
// Force the guards to be rendered if the `inert` attribute is not supported.
|
|
17796
|
+
const guards = supportsInert() ? _guards : true;
|
|
17708
17797
|
const orderRef = useLatestRef(order);
|
|
17709
17798
|
const initialFocusRef = useLatestRef(initialFocus);
|
|
17710
17799
|
const returnFocusRef = useLatestRef(returnFocus);
|
|
17711
17800
|
const tree = useFloatingTree();
|
|
17712
17801
|
const portalContext = usePortalContext();
|
|
17713
|
-
const [tabbableContentLength, setTabbableContentLength] = React.useState(null);
|
|
17714
17802
|
|
|
17715
17803
|
// Controlled by `useListNavigation`.
|
|
17716
17804
|
const ignoreInitialFocus = typeof initialFocus === 'number' && initialFocus < 0;
|
|
@@ -17726,7 +17814,7 @@ function FloatingFocusManager(_ref) {
|
|
|
17726
17814
|
// aria-hidden should be applied to all nodes still. Further, the visually
|
|
17727
17815
|
// hidden dismiss button should only appear at the end of the list, not the
|
|
17728
17816
|
// start.
|
|
17729
|
-
const
|
|
17817
|
+
const isUntrappedTypeableCombobox = domReference && domReference.getAttribute('role') === 'combobox' && isTypeableElement(domReference) && ignoreInitialFocus;
|
|
17730
17818
|
const getTabbableContent = React.useCallback(function (container) {
|
|
17731
17819
|
if (container === void 0) {
|
|
17732
17820
|
container = floating;
|
|
@@ -17746,13 +17834,11 @@ function FloatingFocusManager(_ref) {
|
|
|
17746
17834
|
}).filter(Boolean).flat();
|
|
17747
17835
|
}, [domReference, floating, orderRef, getTabbableContent]);
|
|
17748
17836
|
React.useEffect(() => {
|
|
17749
|
-
if (!modal)
|
|
17750
|
-
return;
|
|
17751
|
-
}
|
|
17837
|
+
if (disabled || !modal) return;
|
|
17752
17838
|
function onKeyDown(event) {
|
|
17753
17839
|
if (event.key === 'Tab') {
|
|
17754
17840
|
// The focus guards have nothing to focus, so we need to stop the event.
|
|
17755
|
-
if (getTabbableContent().length === 0 && !
|
|
17841
|
+
if (contains(floating, activeElement(getDocument(floating))) && getTabbableContent().length === 0 && !isUntrappedTypeableCombobox) {
|
|
17756
17842
|
stopEvent(event);
|
|
17757
17843
|
}
|
|
17758
17844
|
const els = getTabbableElements();
|
|
@@ -17776,11 +17862,9 @@ function FloatingFocusManager(_ref) {
|
|
|
17776
17862
|
return () => {
|
|
17777
17863
|
doc.removeEventListener('keydown', onKeyDown);
|
|
17778
17864
|
};
|
|
17779
|
-
}, [domReference, floating, modal, orderRef, refs,
|
|
17865
|
+
}, [disabled, domReference, floating, modal, orderRef, refs, isUntrappedTypeableCombobox, getTabbableContent, getTabbableElements]);
|
|
17780
17866
|
React.useEffect(() => {
|
|
17781
|
-
if (!closeOnFocusOut)
|
|
17782
|
-
return;
|
|
17783
|
-
}
|
|
17867
|
+
if (disabled || !closeOnFocusOut) return;
|
|
17784
17868
|
|
|
17785
17869
|
// In Safari, buttons lose focus when pressing them.
|
|
17786
17870
|
function handlePointerDown() {
|
|
@@ -17791,22 +17875,24 @@ function FloatingFocusManager(_ref) {
|
|
|
17791
17875
|
}
|
|
17792
17876
|
function handleFocusOutside(event) {
|
|
17793
17877
|
const relatedTarget = event.relatedTarget;
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
|
|
17801
|
-
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
|
|
17807
|
-
|
|
17808
|
-
|
|
17809
|
-
|
|
17878
|
+
queueMicrotask(() => {
|
|
17879
|
+
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 => {
|
|
17880
|
+
var _node$context, _node$context2;
|
|
17881
|
+
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);
|
|
17882
|
+
}) || getAncestors(tree.nodesRef.current, nodeId).find(node => {
|
|
17883
|
+
var _node$context3, _node$context4;
|
|
17884
|
+
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;
|
|
17885
|
+
})));
|
|
17886
|
+
|
|
17887
|
+
// Focus did not move inside the floating tree, and there are no tabbable
|
|
17888
|
+
// portal guards to handle closing.
|
|
17889
|
+
if (relatedTarget && movedToUnrelatedNode && !isPointerDownRef.current &&
|
|
17890
|
+
// Fix React 18 Strict Mode returnFocus due to double rendering.
|
|
17891
|
+
relatedTarget !== previouslyFocusedElementRef.current) {
|
|
17892
|
+
preventReturnFocusRef.current = true;
|
|
17893
|
+
onOpenChange(false, event);
|
|
17894
|
+
}
|
|
17895
|
+
});
|
|
17810
17896
|
}
|
|
17811
17897
|
if (floating && isHTMLElement(domReference)) {
|
|
17812
17898
|
domReference.addEventListener('focusout', handleFocusOutside);
|
|
@@ -17818,63 +17904,46 @@ function FloatingFocusManager(_ref) {
|
|
|
17818
17904
|
!modal && floating.removeEventListener('focusout', handleFocusOutside);
|
|
17819
17905
|
};
|
|
17820
17906
|
}
|
|
17821
|
-
}, [domReference, floating, modal, nodeId, tree, portalContext, onOpenChange, closeOnFocusOut]);
|
|
17907
|
+
}, [disabled, domReference, floating, modal, nodeId, tree, portalContext, onOpenChange, closeOnFocusOut]);
|
|
17822
17908
|
React.useEffect(() => {
|
|
17823
17909
|
var _portalContext$portal;
|
|
17910
|
+
if (disabled) return;
|
|
17911
|
+
|
|
17824
17912
|
// Don't hide portals nested within the parent portal.
|
|
17825
|
-
const portalNodes = Array.from((portalContext == null ? void 0 : (_portalContext$portal = portalContext.portalNode) == null ? void 0 : _portalContext$portal.querySelectorAll('
|
|
17826
|
-
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
if (floating && modal) {
|
|
17830
|
-
const insideNodes = [floating, ...portalNodes, ...getDismissButtons()];
|
|
17831
|
-
const cleanup = hideOthers(orderRef.current.includes('reference') || isTypeableCombobox ? insideNodes.concat(domReference || []) : insideNodes);
|
|
17913
|
+
const portalNodes = Array.from((portalContext == null ? void 0 : (_portalContext$portal = portalContext.portalNode) == null ? void 0 : _portalContext$portal.querySelectorAll("[" + createAttribute('portal') + "]")) || []);
|
|
17914
|
+
if (floating) {
|
|
17915
|
+
const insideElements = [floating, ...portalNodes, startDismissButtonRef.current, endDismissButtonRef.current, orderRef.current.includes('reference') || isUntrappedTypeableCombobox ? domReference : null].filter(x => x != null);
|
|
17916
|
+
const cleanup = modal ? markOthers(insideElements, guards, !guards) : markOthers(insideElements);
|
|
17832
17917
|
return () => {
|
|
17833
17918
|
cleanup();
|
|
17834
17919
|
};
|
|
17835
17920
|
}
|
|
17836
|
-
}, [domReference, floating, modal, orderRef, portalContext,
|
|
17837
|
-
React.useEffect(() => {
|
|
17838
|
-
if (modal && !guards && floating) {
|
|
17839
|
-
const tabIndexValues = [];
|
|
17840
|
-
const options = getTabbableOptions();
|
|
17841
|
-
const allTabbable = tabbable(getDocument(floating).body, options);
|
|
17842
|
-
const floatingTabbable = getTabbableElements();
|
|
17843
|
-
|
|
17844
|
-
// Exclude all tabbable elements that are part of the order
|
|
17845
|
-
const elements = allTabbable.filter(el => !floatingTabbable.includes(el));
|
|
17846
|
-
elements.forEach((el, i) => {
|
|
17847
|
-
tabIndexValues[i] = el.getAttribute('tabindex');
|
|
17848
|
-
el.setAttribute('tabindex', '-1');
|
|
17849
|
-
});
|
|
17850
|
-
return () => {
|
|
17851
|
-
elements.forEach((el, i) => {
|
|
17852
|
-
const value = tabIndexValues[i];
|
|
17853
|
-
if (value == null) {
|
|
17854
|
-
el.removeAttribute('tabindex');
|
|
17855
|
-
} else {
|
|
17856
|
-
el.setAttribute('tabindex', value);
|
|
17857
|
-
}
|
|
17858
|
-
});
|
|
17859
|
-
};
|
|
17860
|
-
}
|
|
17861
|
-
}, [floating, modal, guards, getTabbableElements]);
|
|
17921
|
+
}, [disabled, domReference, floating, modal, orderRef, portalContext, isUntrappedTypeableCombobox, guards]);
|
|
17862
17922
|
index(() => {
|
|
17863
|
-
if (!floating) return;
|
|
17923
|
+
if (disabled || !floating) return;
|
|
17864
17924
|
const doc = getDocument(floating);
|
|
17925
|
+
const previouslyFocusedElement = activeElement(doc);
|
|
17926
|
+
|
|
17927
|
+
// Wait for any layout effect state setters to execute to set `tabIndex`.
|
|
17928
|
+
queueMicrotask(() => {
|
|
17929
|
+
const focusableElements = getTabbableElements(floating);
|
|
17930
|
+
const initialFocusValue = initialFocusRef.current;
|
|
17931
|
+
const elToFocus = (typeof initialFocusValue === 'number' ? focusableElements[initialFocusValue] : initialFocusValue.current) || floating;
|
|
17932
|
+
const focusAlreadyInsideFloatingEl = contains(floating, previouslyFocusedElement);
|
|
17933
|
+
if (!ignoreInitialFocus && !focusAlreadyInsideFloatingEl && open) {
|
|
17934
|
+
enqueueFocus(elToFocus, {
|
|
17935
|
+
preventScroll: elToFocus === floating
|
|
17936
|
+
});
|
|
17937
|
+
}
|
|
17938
|
+
});
|
|
17939
|
+
}, [disabled, open, floating, ignoreInitialFocus, getTabbableElements, initialFocusRef]);
|
|
17940
|
+
index(() => {
|
|
17941
|
+
if (disabled || !floating) return;
|
|
17865
17942
|
let preventReturnFocusScroll = false;
|
|
17943
|
+
const doc = getDocument(floating);
|
|
17866
17944
|
const previouslyFocusedElement = activeElement(doc);
|
|
17867
17945
|
const contextData = dataRef.current;
|
|
17868
|
-
const initialFocusValue = initialFocusRef.current;
|
|
17869
17946
|
previouslyFocusedElementRef.current = previouslyFocusedElement;
|
|
17870
|
-
const focusableElements = getTabbableElements(floating);
|
|
17871
|
-
const elToFocus = (typeof initialFocusValue === 'number' ? focusableElements[initialFocusValue] : initialFocusValue.current) || floating;
|
|
17872
|
-
|
|
17873
|
-
// If the `useListNavigation` hook is active, always ignore `initialFocus`
|
|
17874
|
-
// because it has its own handling of the initial focus.
|
|
17875
|
-
!ignoreInitialFocus && open && enqueueFocus(elToFocus, {
|
|
17876
|
-
preventScroll: elToFocus === floating
|
|
17877
|
-
});
|
|
17878
17947
|
|
|
17879
17948
|
// Dismissing via outside press should always ignore `returnFocus` to
|
|
17880
17949
|
// prevent unwanted scrolling.
|
|
@@ -17907,8 +17976,6 @@ function FloatingFocusManager(_ref) {
|
|
|
17907
17976
|
if (
|
|
17908
17977
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17909
17978
|
returnFocusRef.current && isHTMLElement(previouslyFocusedElementRef.current) && !preventReturnFocusRef.current) {
|
|
17910
|
-
// `isPointerDownRef.current` to avoid the focus ring from appearing on
|
|
17911
|
-
// the reference element when click-toggling it.
|
|
17912
17979
|
enqueueFocus(previouslyFocusedElementRef.current, {
|
|
17913
17980
|
// When dismissing nested floating elements, by the time the rAF has
|
|
17914
17981
|
// executed, the menus will all have been unmounted. When they try
|
|
@@ -17919,49 +17986,58 @@ function FloatingFocusManager(_ref) {
|
|
|
17919
17986
|
});
|
|
17920
17987
|
}
|
|
17921
17988
|
};
|
|
17922
|
-
}, [
|
|
17989
|
+
}, [disabled, floating, returnFocusRef, dataRef, refs, events, tree, nodeId]);
|
|
17923
17990
|
|
|
17924
17991
|
// Synchronize the `context` & `modal` value to the FloatingPortal context.
|
|
17925
17992
|
// It will decide whether or not it needs to render its own guards.
|
|
17926
17993
|
index(() => {
|
|
17927
|
-
if (!portalContext) return;
|
|
17994
|
+
if (disabled || !portalContext) return;
|
|
17928
17995
|
portalContext.setFocusManagerState({
|
|
17929
|
-
...context,
|
|
17930
17996
|
modal,
|
|
17931
|
-
closeOnFocusOut
|
|
17932
|
-
|
|
17997
|
+
closeOnFocusOut,
|
|
17998
|
+
open,
|
|
17999
|
+
onOpenChange,
|
|
18000
|
+
refs
|
|
17933
18001
|
});
|
|
17934
|
-
|
|
17935
18002
|
return () => {
|
|
17936
18003
|
portalContext.setFocusManagerState(null);
|
|
17937
18004
|
};
|
|
17938
|
-
}, [portalContext, modal,
|
|
18005
|
+
}, [disabled, portalContext, modal, open, onOpenChange, refs, closeOnFocusOut]);
|
|
17939
18006
|
index(() => {
|
|
17940
|
-
if (
|
|
17941
|
-
function
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
17948
|
-
|
|
18007
|
+
if (disabled) return;
|
|
18008
|
+
if (floating && typeof MutationObserver === 'function' && !ignoreInitialFocus) {
|
|
18009
|
+
const handleMutation = () => {
|
|
18010
|
+
const tabIndex = floating.getAttribute('tabindex');
|
|
18011
|
+
if (orderRef.current.includes('floating') || activeElement(getDocument(floating)) !== refs.domReference.current && getTabbableContent().length === 0) {
|
|
18012
|
+
if (tabIndex !== '0') {
|
|
18013
|
+
floating.setAttribute('tabindex', '0');
|
|
18014
|
+
}
|
|
18015
|
+
} else if (tabIndex !== '-1') {
|
|
18016
|
+
floating.setAttribute('tabindex', '-1');
|
|
18017
|
+
}
|
|
18018
|
+
};
|
|
18019
|
+
handleMutation();
|
|
18020
|
+
const observer = new MutationObserver(handleMutation);
|
|
17949
18021
|
observer.observe(floating, {
|
|
17950
18022
|
childList: true,
|
|
17951
|
-
subtree: true
|
|
18023
|
+
subtree: true,
|
|
18024
|
+
attributes: true
|
|
17952
18025
|
});
|
|
17953
18026
|
return () => {
|
|
17954
18027
|
observer.disconnect();
|
|
17955
18028
|
};
|
|
17956
18029
|
}
|
|
17957
|
-
}, [floating, getTabbableContent, ignoreInitialFocus
|
|
17958
|
-
const shouldRenderGuards = guards && (isInsidePortal || modal) && !isTypeableCombobox;
|
|
18030
|
+
}, [disabled, floating, refs, orderRef, getTabbableContent, ignoreInitialFocus]);
|
|
17959
18031
|
function renderDismissButton(location) {
|
|
17960
|
-
|
|
18032
|
+
if (disabled || !visuallyHiddenDismiss || !modal) {
|
|
18033
|
+
return null;
|
|
18034
|
+
}
|
|
18035
|
+
return /*#__PURE__*/React.createElement(VisuallyHiddenDismiss, {
|
|
17961
18036
|
ref: location === 'start' ? startDismissButtonRef : endDismissButtonRef,
|
|
17962
|
-
onClick:
|
|
17963
|
-
}, typeof visuallyHiddenDismiss === 'string' ? visuallyHiddenDismiss : 'Dismiss')
|
|
18037
|
+
onClick: event => onOpenChange(false, event.nativeEvent)
|
|
18038
|
+
}, typeof visuallyHiddenDismiss === 'string' ? visuallyHiddenDismiss : 'Dismiss');
|
|
17964
18039
|
}
|
|
18040
|
+
const shouldRenderGuards = !disabled && guards && !isUntrappedTypeableCombobox && (isInsidePortal || modal);
|
|
17965
18041
|
return /*#__PURE__*/React.createElement(React.Fragment, null, shouldRenderGuards && /*#__PURE__*/React.createElement(FocusGuard, {
|
|
17966
18042
|
"data-type": "inside",
|
|
17967
18043
|
ref: portalContext == null ? void 0 : portalContext.beforeInsideRef,
|
|
@@ -17980,9 +18056,7 @@ function FloatingFocusManager(_ref) {
|
|
|
17980
18056
|
}
|
|
17981
18057
|
}
|
|
17982
18058
|
}
|
|
17983
|
-
}),
|
|
17984
|
-
tabIndex: 0
|
|
17985
|
-
} : {}), renderDismissButton('end'), shouldRenderGuards && /*#__PURE__*/React.createElement(FocusGuard, {
|
|
18059
|
+
}), !isUntrappedTypeableCombobox && renderDismissButton('start'), children, renderDismissButton('end'), shouldRenderGuards && /*#__PURE__*/React.createElement(FocusGuard, {
|
|
17986
18060
|
"data-type": "inside",
|
|
17987
18061
|
ref: portalContext == null ? void 0 : portalContext.afterInsideRef,
|
|
17988
18062
|
onFocus: event => {
|
|
@@ -18014,7 +18088,7 @@ function isSpaceIgnored(element) {
|
|
|
18014
18088
|
* Opens or closes the floating element when clicking the reference element.
|
|
18015
18089
|
* @see https://floating-ui.com/docs/useClick
|
|
18016
18090
|
*/
|
|
18017
|
-
|
|
18091
|
+
function useClick(context, props) {
|
|
18018
18092
|
if (props === void 0) {
|
|
18019
18093
|
props = {};
|
|
18020
18094
|
}
|
|
@@ -18034,10 +18108,9 @@ const useClick = function (context, props) {
|
|
|
18034
18108
|
keyboardHandlers = true
|
|
18035
18109
|
} = props;
|
|
18036
18110
|
const pointerTypeRef = React.useRef();
|
|
18111
|
+
const didKeyDownRef = React.useRef(false);
|
|
18037
18112
|
return React.useMemo(() => {
|
|
18038
|
-
if (!enabled) {
|
|
18039
|
-
return {};
|
|
18040
|
-
}
|
|
18113
|
+
if (!enabled) return {};
|
|
18041
18114
|
return {
|
|
18042
18115
|
reference: {
|
|
18043
18116
|
onPointerDown(event) {
|
|
@@ -18055,16 +18128,13 @@ const useClick = function (context, props) {
|
|
|
18055
18128
|
if (eventOption === 'click') {
|
|
18056
18129
|
return;
|
|
18057
18130
|
}
|
|
18058
|
-
if (open) {
|
|
18059
|
-
|
|
18060
|
-
onOpenChange(false);
|
|
18061
|
-
}
|
|
18131
|
+
if (open && toggle && (dataRef.current.openEvent ? dataRef.current.openEvent.type === 'mousedown' : true)) {
|
|
18132
|
+
onOpenChange(false, event.nativeEvent);
|
|
18062
18133
|
} else {
|
|
18063
18134
|
// Prevent stealing focus from the floating element
|
|
18064
18135
|
event.preventDefault();
|
|
18065
|
-
onOpenChange(true);
|
|
18136
|
+
onOpenChange(true, event.nativeEvent);
|
|
18066
18137
|
}
|
|
18067
|
-
dataRef.current.openEvent = event.nativeEvent;
|
|
18068
18138
|
},
|
|
18069
18139
|
onClick(event) {
|
|
18070
18140
|
if (eventOption === 'mousedown' && pointerTypeRef.current) {
|
|
@@ -18074,63 +18144,52 @@ const useClick = function (context, props) {
|
|
|
18074
18144
|
if (isMouseLikePointerType(pointerTypeRef.current, true) && ignoreMouse) {
|
|
18075
18145
|
return;
|
|
18076
18146
|
}
|
|
18077
|
-
if (open) {
|
|
18078
|
-
|
|
18079
|
-
onOpenChange(false);
|
|
18080
|
-
}
|
|
18147
|
+
if (open && toggle && (dataRef.current.openEvent ? dataRef.current.openEvent.type === 'click' : true)) {
|
|
18148
|
+
onOpenChange(false, event.nativeEvent);
|
|
18081
18149
|
} else {
|
|
18082
|
-
onOpenChange(true);
|
|
18150
|
+
onOpenChange(true, event.nativeEvent);
|
|
18083
18151
|
}
|
|
18084
|
-
dataRef.current.openEvent = event.nativeEvent;
|
|
18085
18152
|
},
|
|
18086
18153
|
onKeyDown(event) {
|
|
18087
18154
|
pointerTypeRef.current = undefined;
|
|
18088
|
-
if (!keyboardHandlers) {
|
|
18089
|
-
return;
|
|
18090
|
-
}
|
|
18091
|
-
if (isButtonTarget(event)) {
|
|
18155
|
+
if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event)) {
|
|
18092
18156
|
return;
|
|
18093
18157
|
}
|
|
18094
18158
|
if (event.key === ' ' && !isSpaceIgnored(domReference)) {
|
|
18095
18159
|
// Prevent scrolling
|
|
18096
18160
|
event.preventDefault();
|
|
18161
|
+
didKeyDownRef.current = true;
|
|
18097
18162
|
}
|
|
18098
18163
|
if (event.key === 'Enter') {
|
|
18099
|
-
if (open) {
|
|
18100
|
-
|
|
18101
|
-
onOpenChange(false);
|
|
18102
|
-
}
|
|
18164
|
+
if (open && toggle) {
|
|
18165
|
+
onOpenChange(false, event.nativeEvent);
|
|
18103
18166
|
} else {
|
|
18104
|
-
onOpenChange(true);
|
|
18167
|
+
onOpenChange(true, event.nativeEvent);
|
|
18105
18168
|
}
|
|
18106
18169
|
}
|
|
18107
18170
|
},
|
|
18108
18171
|
onKeyUp(event) {
|
|
18109
|
-
if (!keyboardHandlers) {
|
|
18110
|
-
return;
|
|
18111
|
-
}
|
|
18112
|
-
if (isButtonTarget(event) || isSpaceIgnored(domReference)) {
|
|
18172
|
+
if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event) || isSpaceIgnored(domReference)) {
|
|
18113
18173
|
return;
|
|
18114
18174
|
}
|
|
18115
|
-
if (event.key === ' ') {
|
|
18116
|
-
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
}
|
|
18175
|
+
if (event.key === ' ' && didKeyDownRef.current) {
|
|
18176
|
+
didKeyDownRef.current = false;
|
|
18177
|
+
if (open && toggle) {
|
|
18178
|
+
onOpenChange(false, event.nativeEvent);
|
|
18120
18179
|
} else {
|
|
18121
|
-
onOpenChange(true);
|
|
18180
|
+
onOpenChange(true, event.nativeEvent);
|
|
18122
18181
|
}
|
|
18123
18182
|
}
|
|
18124
18183
|
}
|
|
18125
18184
|
}
|
|
18126
18185
|
};
|
|
18127
18186
|
}, [enabled, dataRef, eventOption, ignoreMouse, keyboardHandlers, domReference, toggle, open, onOpenChange]);
|
|
18128
|
-
}
|
|
18187
|
+
}
|
|
18129
18188
|
|
|
18130
18189
|
// `toString()` prevents bundlers from trying to `import { useInsertionEffect } from 'react'`
|
|
18131
18190
|
const useInsertionEffect = React[/*#__PURE__*/'useInsertionEffect'.toString()];
|
|
18132
18191
|
const useSafeInsertionEffect = useInsertionEffect || (fn => fn());
|
|
18133
|
-
function
|
|
18192
|
+
function useEffectEvent(callback) {
|
|
18134
18193
|
const ref = React.useRef(() => {
|
|
18135
18194
|
if (process.env.NODE_ENV !== "production") {
|
|
18136
18195
|
throw new Error('Cannot call an event handler while rendering.');
|
|
@@ -18147,26 +18206,6 @@ function useEvent(callback) {
|
|
|
18147
18206
|
}, []);
|
|
18148
18207
|
}
|
|
18149
18208
|
|
|
18150
|
-
/**
|
|
18151
|
-
* Check whether the event.target is within the provided node. Uses event.composedPath if available for custom element support.
|
|
18152
|
-
*
|
|
18153
|
-
* @param event The event whose target/composedPath to check
|
|
18154
|
-
* @param node The node to check against
|
|
18155
|
-
* @returns Whether the event.target/composedPath is within the node.
|
|
18156
|
-
*/
|
|
18157
|
-
function isEventTargetWithin(event, node) {
|
|
18158
|
-
if (node == null) {
|
|
18159
|
-
return false;
|
|
18160
|
-
}
|
|
18161
|
-
if ('composedPath' in event) {
|
|
18162
|
-
return event.composedPath().includes(node);
|
|
18163
|
-
}
|
|
18164
|
-
|
|
18165
|
-
// TS thinks `event` is of type never as it assumes all browsers support composedPath, but browsers without shadow dom don't
|
|
18166
|
-
const e = event;
|
|
18167
|
-
return e.target != null && node.contains(e.target);
|
|
18168
|
-
}
|
|
18169
|
-
|
|
18170
18209
|
const bubbleHandlerKeys = {
|
|
18171
18210
|
pointerdown: 'onPointerDown',
|
|
18172
18211
|
mousedown: 'onMouseDown',
|
|
@@ -18189,7 +18228,7 @@ const normalizeBubblesProp = bubbles => {
|
|
|
18189
18228
|
* the user presses the `escape` key or outside of the floating element.
|
|
18190
18229
|
* @see https://floating-ui.com/docs/useDismiss
|
|
18191
18230
|
*/
|
|
18192
|
-
|
|
18231
|
+
function useDismiss(context, props) {
|
|
18193
18232
|
if (props === void 0) {
|
|
18194
18233
|
props = {};
|
|
18195
18234
|
}
|
|
@@ -18217,14 +18256,14 @@ const useDismiss = function (context, props) {
|
|
|
18217
18256
|
} = props;
|
|
18218
18257
|
const tree = useFloatingTree();
|
|
18219
18258
|
const nested = useFloatingParentNodeId() != null;
|
|
18220
|
-
const outsidePressFn =
|
|
18259
|
+
const outsidePressFn = useEffectEvent(typeof unstable_outsidePress === 'function' ? unstable_outsidePress : () => false);
|
|
18221
18260
|
const outsidePress = typeof unstable_outsidePress === 'function' ? outsidePressFn : unstable_outsidePress;
|
|
18222
18261
|
const insideReactTreeRef = React.useRef(false);
|
|
18223
18262
|
const {
|
|
18224
18263
|
escapeKeyBubbles,
|
|
18225
18264
|
outsidePressBubbles
|
|
18226
18265
|
} = normalizeBubblesProp(bubbles);
|
|
18227
|
-
const closeOnEscapeKeyDown =
|
|
18266
|
+
const closeOnEscapeKeyDown = useEffectEvent(event => {
|
|
18228
18267
|
if (!open || !enabled || !escapeKey || event.key !== 'Escape') {
|
|
18229
18268
|
return;
|
|
18230
18269
|
}
|
|
@@ -18253,9 +18292,9 @@ const useDismiss = function (context, props) {
|
|
|
18253
18292
|
}
|
|
18254
18293
|
}
|
|
18255
18294
|
});
|
|
18256
|
-
onOpenChange(false);
|
|
18295
|
+
onOpenChange(false, isReactEvent(event) ? event.nativeEvent : event);
|
|
18257
18296
|
});
|
|
18258
|
-
const closeOnPressOutside =
|
|
18297
|
+
const closeOnPressOutside = useEffectEvent(event => {
|
|
18259
18298
|
// Given developers can stop the propagation of the synthetic event,
|
|
18260
18299
|
// we can only be confident with a positive value.
|
|
18261
18300
|
const insideReactTree = insideReactTreeRef.current;
|
|
@@ -18267,6 +18306,28 @@ const useDismiss = function (context, props) {
|
|
|
18267
18306
|
return;
|
|
18268
18307
|
}
|
|
18269
18308
|
const target = getTarget(event);
|
|
18309
|
+
const inertSelector = "[" + createAttribute('inert') + "]";
|
|
18310
|
+
const markers = getDocument(floating).querySelectorAll(inertSelector);
|
|
18311
|
+
let targetRootAncestor = isElement(target) ? target : null;
|
|
18312
|
+
while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
|
|
18313
|
+
const nextParent = getParentNode(targetRootAncestor);
|
|
18314
|
+
if (nextParent === getDocument(floating).body || !isElement(nextParent)) {
|
|
18315
|
+
break;
|
|
18316
|
+
} else {
|
|
18317
|
+
targetRootAncestor = nextParent;
|
|
18318
|
+
}
|
|
18319
|
+
}
|
|
18320
|
+
|
|
18321
|
+
// Check if the click occurred on a third-party element injected after the
|
|
18322
|
+
// floating element rendered.
|
|
18323
|
+
if (markers.length && isElement(target) && !isRootElement(target) &&
|
|
18324
|
+
// Clicked on a direct ancestor (e.g. FloatingOverlay).
|
|
18325
|
+
!contains(target, floating) &&
|
|
18326
|
+
// If the target root element contains none of the markers, then the
|
|
18327
|
+
// element was injected after the floating element rendered.
|
|
18328
|
+
Array.from(markers).every(marker => !contains(targetRootAncestor, marker))) {
|
|
18329
|
+
return;
|
|
18330
|
+
}
|
|
18270
18331
|
|
|
18271
18332
|
// Check if the click occurred on the scrollbar
|
|
18272
18333
|
if (isHTMLElement(target) && floating) {
|
|
@@ -18281,7 +18342,7 @@ const useDismiss = function (context, props) {
|
|
|
18281
18342
|
// check for. Plus, for modal dialogs with backdrops, it is more
|
|
18282
18343
|
// important that the backdrop is checked but not so much the window.
|
|
18283
18344
|
if (canScrollY) {
|
|
18284
|
-
const isRTL =
|
|
18345
|
+
const isRTL = getComputedStyle$1(target).direction === 'rtl';
|
|
18285
18346
|
if (isRTL) {
|
|
18286
18347
|
xCond = event.offsetX <= target.offsetWidth - target.clientWidth;
|
|
18287
18348
|
}
|
|
@@ -18319,7 +18380,7 @@ const useDismiss = function (context, props) {
|
|
|
18319
18380
|
} : isVirtualClick(event) || isVirtualPointerEvent(event)
|
|
18320
18381
|
}
|
|
18321
18382
|
});
|
|
18322
|
-
onOpenChange(false);
|
|
18383
|
+
onOpenChange(false, event);
|
|
18323
18384
|
});
|
|
18324
18385
|
React.useEffect(() => {
|
|
18325
18386
|
if (!open || !enabled) {
|
|
@@ -18327,8 +18388,8 @@ const useDismiss = function (context, props) {
|
|
|
18327
18388
|
}
|
|
18328
18389
|
dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
|
|
18329
18390
|
dataRef.current.__outsidePressBubbles = outsidePressBubbles;
|
|
18330
|
-
function onScroll() {
|
|
18331
|
-
onOpenChange(false);
|
|
18391
|
+
function onScroll(event) {
|
|
18392
|
+
onOpenChange(false, event);
|
|
18332
18393
|
}
|
|
18333
18394
|
const doc = getDocument(floating);
|
|
18334
18395
|
escapeKey && doc.addEventListener('keydown', closeOnEscapeKeyDown);
|
|
@@ -18374,7 +18435,7 @@ const useDismiss = function (context, props) {
|
|
|
18374
18435
|
return {
|
|
18375
18436
|
reference: {
|
|
18376
18437
|
onKeyDown: closeOnEscapeKeyDown,
|
|
18377
|
-
[bubbleHandlerKeys[referencePressEvent]]:
|
|
18438
|
+
[bubbleHandlerKeys[referencePressEvent]]: event => {
|
|
18378
18439
|
if (referencePress) {
|
|
18379
18440
|
events.emit('dismiss', {
|
|
18380
18441
|
type: 'referencePress',
|
|
@@ -18382,7 +18443,7 @@ const useDismiss = function (context, props) {
|
|
|
18382
18443
|
returnFocus: false
|
|
18383
18444
|
}
|
|
18384
18445
|
});
|
|
18385
|
-
onOpenChange(false);
|
|
18446
|
+
onOpenChange(false, event.nativeEvent);
|
|
18386
18447
|
}
|
|
18387
18448
|
}
|
|
18388
18449
|
},
|
|
@@ -18394,91 +18455,19 @@ const useDismiss = function (context, props) {
|
|
|
18394
18455
|
}
|
|
18395
18456
|
};
|
|
18396
18457
|
}, [enabled, events, referencePress, outsidePressEvent, referencePressEvent, onOpenChange, closeOnEscapeKeyDown]);
|
|
18397
|
-
};
|
|
18398
|
-
|
|
18399
|
-
/**
|
|
18400
|
-
* Merges an array of refs into a single memoized callback ref or `null`.
|
|
18401
|
-
* @see https://floating-ui.com/docs/useMergeRefs
|
|
18402
|
-
*/
|
|
18403
|
-
function useMergeRefs(refs) {
|
|
18404
|
-
return React.useMemo(() => {
|
|
18405
|
-
if (refs.every(ref => ref == null)) {
|
|
18406
|
-
return null;
|
|
18407
|
-
}
|
|
18408
|
-
return value => {
|
|
18409
|
-
refs.forEach(ref => {
|
|
18410
|
-
if (typeof ref === 'function') {
|
|
18411
|
-
ref(value);
|
|
18412
|
-
} else if (ref != null) {
|
|
18413
|
-
ref.current = value;
|
|
18414
|
-
}
|
|
18415
|
-
});
|
|
18416
|
-
};
|
|
18417
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18418
|
-
}, refs);
|
|
18419
18458
|
}
|
|
18420
18459
|
|
|
18421
|
-
|
|
18422
|
-
|
|
18423
|
-
|
|
18424
|
-
|
|
18425
|
-
*/
|
|
18426
|
-
const useRole = function (context, props) {
|
|
18427
|
-
if (props === void 0) {
|
|
18428
|
-
props = {};
|
|
18429
|
-
}
|
|
18430
|
-
const {
|
|
18431
|
-
open,
|
|
18432
|
-
floatingId
|
|
18433
|
-
} = context;
|
|
18434
|
-
const {
|
|
18435
|
-
enabled = true,
|
|
18436
|
-
role = 'dialog'
|
|
18437
|
-
} = props;
|
|
18438
|
-
const referenceId = useId();
|
|
18439
|
-
return React.useMemo(() => {
|
|
18440
|
-
const floatingProps = {
|
|
18441
|
-
id: floatingId,
|
|
18442
|
-
role
|
|
18443
|
-
};
|
|
18444
|
-
if (!enabled) {
|
|
18445
|
-
return {};
|
|
18446
|
-
}
|
|
18447
|
-
if (role === 'tooltip') {
|
|
18448
|
-
return {
|
|
18449
|
-
reference: {
|
|
18450
|
-
'aria-describedby': open ? floatingId : undefined
|
|
18451
|
-
},
|
|
18452
|
-
floating: floatingProps
|
|
18453
|
-
};
|
|
18454
|
-
}
|
|
18455
|
-
return {
|
|
18456
|
-
reference: {
|
|
18457
|
-
'aria-expanded': open ? 'true' : 'false',
|
|
18458
|
-
'aria-haspopup': role === 'alertdialog' ? 'dialog' : role,
|
|
18459
|
-
'aria-controls': open ? floatingId : undefined,
|
|
18460
|
-
...(role === 'listbox' && {
|
|
18461
|
-
role: 'combobox'
|
|
18462
|
-
}),
|
|
18463
|
-
...(role === 'menu' && {
|
|
18464
|
-
id: referenceId
|
|
18465
|
-
})
|
|
18466
|
-
},
|
|
18467
|
-
floating: {
|
|
18468
|
-
...floatingProps,
|
|
18469
|
-
...(role === 'menu' && {
|
|
18470
|
-
'aria-labelledby': referenceId
|
|
18471
|
-
})
|
|
18472
|
-
}
|
|
18473
|
-
};
|
|
18474
|
-
}, [enabled, role, open, floatingId, referenceId]);
|
|
18475
|
-
};
|
|
18460
|
+
let devMessageSet;
|
|
18461
|
+
if (process.env.NODE_ENV !== "production") {
|
|
18462
|
+
devMessageSet = /*#__PURE__*/new Set();
|
|
18463
|
+
}
|
|
18476
18464
|
|
|
18477
18465
|
/**
|
|
18478
18466
|
* Provides data to position a floating element and context to add interactions.
|
|
18479
18467
|
* @see https://floating-ui.com/docs/react
|
|
18480
18468
|
*/
|
|
18481
18469
|
function useFloating(options) {
|
|
18470
|
+
var _options$elements2;
|
|
18482
18471
|
if (options === void 0) {
|
|
18483
18472
|
options = {};
|
|
18484
18473
|
}
|
|
@@ -18487,13 +18476,32 @@ function useFloating(options) {
|
|
|
18487
18476
|
onOpenChange: unstable_onOpenChange,
|
|
18488
18477
|
nodeId
|
|
18489
18478
|
} = options;
|
|
18479
|
+
if (process.env.NODE_ENV !== "production") {
|
|
18480
|
+
var _options$elements;
|
|
18481
|
+
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.';
|
|
18482
|
+
if ((_options$elements = options.elements) != null && _options$elements.reference && !isElement(options.elements.reference)) {
|
|
18483
|
+
var _devMessageSet;
|
|
18484
|
+
if (!((_devMessageSet = devMessageSet) != null && _devMessageSet.has(err))) {
|
|
18485
|
+
var _devMessageSet2;
|
|
18486
|
+
(_devMessageSet2 = devMessageSet) == null ? void 0 : _devMessageSet2.add(err);
|
|
18487
|
+
console.error(err);
|
|
18488
|
+
}
|
|
18489
|
+
}
|
|
18490
|
+
}
|
|
18491
|
+
const [_domReference, setDomReference] = React.useState(null);
|
|
18492
|
+
const domReference = ((_options$elements2 = options.elements) == null ? void 0 : _options$elements2.reference) || _domReference;
|
|
18490
18493
|
const position = useFloating$1(options);
|
|
18491
18494
|
const tree = useFloatingTree();
|
|
18495
|
+
const onOpenChange = useEffectEvent((open, event) => {
|
|
18496
|
+
if (open) {
|
|
18497
|
+
dataRef.current.openEvent = event;
|
|
18498
|
+
}
|
|
18499
|
+
unstable_onOpenChange == null ? void 0 : unstable_onOpenChange(open, event);
|
|
18500
|
+
});
|
|
18492
18501
|
const domReferenceRef = React.useRef(null);
|
|
18493
18502
|
const dataRef = React.useRef({});
|
|
18494
18503
|
const events = React.useState(() => createPubSub())[0];
|
|
18495
18504
|
const floatingId = useId();
|
|
18496
|
-
const [domReference, setDomReference] = React.useState(null);
|
|
18497
18505
|
const setPositionReference = React.useCallback(node => {
|
|
18498
18506
|
const positionReference = isElement(node) ? {
|
|
18499
18507
|
getBoundingClientRect: () => node.getBoundingClientRect(),
|
|
@@ -18527,7 +18535,6 @@ function useFloating(options) {
|
|
|
18527
18535
|
...position.elements,
|
|
18528
18536
|
domReference: domReference
|
|
18529
18537
|
}), [position.elements, domReference]);
|
|
18530
|
-
const onOpenChange = useEvent(unstable_onOpenChange);
|
|
18531
18538
|
const context = React.useMemo(() => ({
|
|
18532
18539
|
...position,
|
|
18533
18540
|
refs,
|
|
@@ -18549,10 +18556,8 @@ function useFloating(options) {
|
|
|
18549
18556
|
...position,
|
|
18550
18557
|
context,
|
|
18551
18558
|
refs,
|
|
18552
|
-
elements
|
|
18553
|
-
|
|
18554
|
-
positionReference: setPositionReference
|
|
18555
|
-
}), [position, refs, elements, context, setReference, setPositionReference]);
|
|
18559
|
+
elements
|
|
18560
|
+
}), [position, refs, elements, context]);
|
|
18556
18561
|
}
|
|
18557
18562
|
|
|
18558
18563
|
function mergeProps(userProps, propsList, elementKey) {
|
|
@@ -18591,7 +18596,14 @@ function mergeProps(userProps, propsList, elementKey) {
|
|
|
18591
18596
|
}, {})
|
|
18592
18597
|
};
|
|
18593
18598
|
}
|
|
18594
|
-
|
|
18599
|
+
|
|
18600
|
+
/**
|
|
18601
|
+
* Merges an array of interaction hooks' props into prop getters, allowing
|
|
18602
|
+
* event handler functions to be composed together without overwriting one
|
|
18603
|
+
* another.
|
|
18604
|
+
* @see https://floating-ui.com/docs/react#interaction-hooks
|
|
18605
|
+
*/
|
|
18606
|
+
function useInteractions(propsList) {
|
|
18595
18607
|
if (propsList === void 0) {
|
|
18596
18608
|
propsList = [];
|
|
18597
18609
|
}
|
|
@@ -18616,7 +18628,63 @@ const useInteractions = function (propsList) {
|
|
|
18616
18628
|
getFloatingProps,
|
|
18617
18629
|
getItemProps
|
|
18618
18630
|
}), [getReferenceProps, getFloatingProps, getItemProps]);
|
|
18619
|
-
}
|
|
18631
|
+
}
|
|
18632
|
+
|
|
18633
|
+
/**
|
|
18634
|
+
* Adds base screen reader props to the reference and floating elements for a
|
|
18635
|
+
* given floating element `role`.
|
|
18636
|
+
* @see https://floating-ui.com/docs/useRole
|
|
18637
|
+
*/
|
|
18638
|
+
function useRole(context, props) {
|
|
18639
|
+
if (props === void 0) {
|
|
18640
|
+
props = {};
|
|
18641
|
+
}
|
|
18642
|
+
const {
|
|
18643
|
+
open,
|
|
18644
|
+
floatingId
|
|
18645
|
+
} = context;
|
|
18646
|
+
const {
|
|
18647
|
+
enabled = true,
|
|
18648
|
+
role = 'dialog'
|
|
18649
|
+
} = props;
|
|
18650
|
+
const referenceId = useId();
|
|
18651
|
+
return React.useMemo(() => {
|
|
18652
|
+
const floatingProps = {
|
|
18653
|
+
id: floatingId,
|
|
18654
|
+
role
|
|
18655
|
+
};
|
|
18656
|
+
if (!enabled) {
|
|
18657
|
+
return {};
|
|
18658
|
+
}
|
|
18659
|
+
if (role === 'tooltip') {
|
|
18660
|
+
return {
|
|
18661
|
+
reference: {
|
|
18662
|
+
'aria-describedby': open ? floatingId : undefined
|
|
18663
|
+
},
|
|
18664
|
+
floating: floatingProps
|
|
18665
|
+
};
|
|
18666
|
+
}
|
|
18667
|
+
return {
|
|
18668
|
+
reference: {
|
|
18669
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
18670
|
+
'aria-haspopup': role === 'alertdialog' ? 'dialog' : role,
|
|
18671
|
+
'aria-controls': open ? floatingId : undefined,
|
|
18672
|
+
...(role === 'listbox' && {
|
|
18673
|
+
role: 'combobox'
|
|
18674
|
+
}),
|
|
18675
|
+
...(role === 'menu' && {
|
|
18676
|
+
id: referenceId
|
|
18677
|
+
})
|
|
18678
|
+
},
|
|
18679
|
+
floating: {
|
|
18680
|
+
...floatingProps,
|
|
18681
|
+
...(role === 'menu' && {
|
|
18682
|
+
'aria-labelledby': referenceId
|
|
18683
|
+
})
|
|
18684
|
+
}
|
|
18685
|
+
};
|
|
18686
|
+
}, [enabled, role, open, floatingId, referenceId]);
|
|
18687
|
+
}
|
|
18620
18688
|
|
|
18621
18689
|
/**
|
|
18622
18690
|
* The hook that powers the Popover component.
|
|
@@ -18754,7 +18822,7 @@ const PopoverTrigger = forwardRef(function PopoverTrigger(_a, propRef) {
|
|
|
18754
18822
|
* @returns {JSX.Element} DayPickerPopover component
|
|
18755
18823
|
*/
|
|
18756
18824
|
const DayPickerPopover = ({ disabledDays, className, dataTestId, selectedDay, onDaySelect, color = "secondary", placement, size = "small", buttonContent, language, }) => {
|
|
18757
|
-
return (jsxs(Popover, { placement: placement, children: [jsx(PopoverTrigger, { children: jsx(Button$1, { color: color, size: size, className: className, prefix: jsx(Icon, { name: "
|
|
18825
|
+
return (jsxs(Popover, { placement: placement, children: [jsx(PopoverTrigger, { children: jsx(Button$1, { color: color, size: size, className: className, prefix: jsx(Icon, { name: "Calendar", size: "small" }), dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "show-day-picker", children: buttonContent }) }), jsx(PopoverContent, { children: jsx(Card, { children: jsx(DayPicker, { disabledDays: disabledDays, onDaySelect: onDaySelect, selectedDays: selectedDay, language: language }) }) })] }));
|
|
18758
18826
|
};
|
|
18759
18827
|
|
|
18760
18828
|
/**
|
|
@@ -36803,7 +36871,7 @@ const cvaMoreMenu = cvaMerge(["p-4"]);
|
|
|
36803
36871
|
*/
|
|
36804
36872
|
const MoreMenu = ({ className, dataTestId, menuPlacement, iconProps = {
|
|
36805
36873
|
size: "medium",
|
|
36806
|
-
name: "
|
|
36874
|
+
name: "EllipsisHorizontal",
|
|
36807
36875
|
}, iconButtonProps = {
|
|
36808
36876
|
size: "small",
|
|
36809
36877
|
circular: true,
|
|
@@ -37226,7 +37294,7 @@ const Tag = React.forwardRef((_a, ref) => {
|
|
|
37226
37294
|
var { className, dataTestId, children, size = "medium", onClose, color = "primary", disabled = false } = _a; __rest$1(_a, ["className", "dataTestId", "children", "size", "onClose", "color", "disabled"]);
|
|
37227
37295
|
return (jsxs("span", { className: cvaTag({ className, size, color, layout: Boolean(onClose) ? "withIcon" : "default" }), "data-testid": dataTestId && `${dataTestId}-tag`, ref: ref, children: [children, Boolean(onClose) && !disabled && (
|
|
37228
37296
|
// a fix for multiselect deselecting tags working together with fade out animation
|
|
37229
|
-
jsx("div", { className: cvaTagIconContainer(), onMouseDown: onClose, children: jsx(Icon, { name: "
|
|
37297
|
+
jsx("div", { className: cvaTagIconContainer(), onMouseDown: onClose, children: jsx(Icon, { name: "XCircle", dataTestId: dataTestId + "Icon", type: "solid", size: size, style: { WebkitTransition: "-webkit-transform 0.150s" }, className: cvaTagIcon() }) }))] }));
|
|
37230
37298
|
});
|
|
37231
37299
|
|
|
37232
37300
|
const cvaTip = cvaMerge("flex transition text-slate-300 hover:text-slate-500");
|
|
@@ -37250,7 +37318,7 @@ const cvaTipContent = cvaMerge("p-2 rounded max-w-sm flex gap-2 items-center tex
|
|
|
37250
37318
|
* @returns {JSX.Element} Tip component
|
|
37251
37319
|
*/
|
|
37252
37320
|
const Tip = ({ children, iconProps, dataTestId, className, placement = "bottom", mode = "dark", link, }) => {
|
|
37253
|
-
return (jsx("span", { "data-testid": dataTestId, className: cvaTip({ className }), children: jsxs(Popover, { placement: placement, activation: { click: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "", children: [jsx(PopoverTrigger, { children: jsx("div", { "data-testid": dataTestId && `${dataTestId}-trigger`, children: jsx(Icon, Object.assign({ name: "
|
|
37321
|
+
return (jsx("span", { "data-testid": dataTestId, className: cvaTip({ className }), children: jsxs(Popover, { placement: placement, activation: { click: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "", children: [jsx(PopoverTrigger, { children: jsx("div", { "data-testid": dataTestId && `${dataTestId}-trigger`, children: jsx(Icon, Object.assign({ name: "QuestionMarkCircle", size: "medium", dataTestId: dataTestId && `${dataTestId}-icon` }, iconProps)) }) }), jsx(PopoverContent, { children: jsxs("div", { className: cvaTipContent({ color: mode }), children: [jsx("div", { children: typeof children === "string" ? jsx("p", { children: children }) : children }), link ? (jsx("a", { href: link, children: jsx(Icon, { name: "ArrowRightCircle" }) })) : null] }) })] }) }));
|
|
37254
37322
|
};
|
|
37255
37323
|
|
|
37256
37324
|
const cvaPageHeader = cvaMerge([
|
|
@@ -37288,7 +37356,7 @@ const cvaPageHeaderChildContainer = cvaMerge(["flex", "flex-wrap", "gap-x-6", "i
|
|
|
37288
37356
|
* @returns {JSX.Element} PageHeader component
|
|
37289
37357
|
*/
|
|
37290
37358
|
const PageHeader = ({ className, dataTestId, action, showLoading, description, link, title, tag, backTo, tagColor, children, }) => {
|
|
37291
|
-
return (jsxs("div", { className: cvaPageHeader({ className: `${className} tu-page-header` }), "data-testid": dataTestId, children: [jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId && `${dataTestId}-heading-container`, children: [jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo && (jsx(IconButton, { to: backTo, color: "tertiary", variant: "transparent", size: "small", icon: jsx(Icon, { name: "
|
|
37359
|
+
return (jsxs("div", { className: cvaPageHeader({ className: `${className} tu-page-header` }), "data-testid": dataTestId, children: [jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId && `${dataTestId}-heading-container`, children: [jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo && (jsx(IconButton, { to: backTo, color: "tertiary", variant: "transparent", size: "small", icon: jsx(Icon, { name: "ArrowLeft" }) })), jsx("h1", { className: cvaPageHeaderHeading(), "data-testid": dataTestId && `${dataTestId}-heading`, children: title }), description && !showLoading && (jsx(Tip, { dataTestId: dataTestId && `${dataTestId}-tip`, iconProps: { name: "QuestionMarkCircle" }, link: link, children: description }))] }), tag && !showLoading && jsx(Tag, { dataTestId: dataTestId, color: tagColor, children: tag }), showLoading && jsx(Spinner, { dataTestId: dataTestId && `${dataTestId}-spinner`, centering: "vertically" }), action] }), jsx("div", { className: cvaPageHeaderChildContainer(), children: children })] }));
|
|
37292
37360
|
};
|
|
37293
37361
|
|
|
37294
37362
|
const cvaPagination = cvaMerge(["flex", "items-center", "gap-1"]);
|
|
@@ -37337,9 +37405,9 @@ const Pagination = ({ previousPage, nextPage, canPreviousPage, canNextPage, page
|
|
|
37337
37405
|
if (loading) {
|
|
37338
37406
|
return (jsx("div", { className: cvaPagination({ className }), children: jsx(SkeletonLines, { height: 16, width: 150 }) }));
|
|
37339
37407
|
}
|
|
37340
|
-
return (jsxs("div", { "data-testid": dataTestId, className: cvaPagination({ className }), children: [jsx(IconButton, { onClick: () => handlePageChange("prev"), disabled: cursorBase ? !canPreviousPage || false : page !== undefined && page <= 0, "data-testid": "prev-page", icon: jsx(Icon, { name: "
|
|
37408
|
+
return (jsxs("div", { "data-testid": dataTestId, className: cvaPagination({ className }), children: [jsx(IconButton, { onClick: () => handlePageChange("prev"), disabled: cursorBase ? !canPreviousPage || false : page !== undefined && page <= 0, "data-testid": "prev-page", icon: jsx(Icon, { name: "ChevronLeft", size: "small" }), size: "small", color: "secondary", variant: "transparent" }), !cursorBase && (jsxs(Fragment, { children: [jsx("div", { className: cvaPaginationText(), "data-testid": "current-page", children: currentPage }), jsx("div", { className: cvaPaginationText(), "data-testid": "page-count", children: pageCount !== null && pageCount !== undefined && getTranslatedCount && getTranslatedCount(pageCount) })] })), jsx(IconButton, { onClick: () => handlePageChange("next"), disabled: cursorBase
|
|
37341
37409
|
? !canNextPage || false
|
|
37342
|
-
: page !== undefined && pageCount !== undefined && pageCount !== null && page >= pageCount - 1, "data-testid": "next-page", icon: jsx(Icon, { name: "
|
|
37410
|
+
: page !== undefined && pageCount !== undefined && pageCount !== null && page >= pageCount - 1, "data-testid": "next-page", icon: jsx(Icon, { name: "ChevronRight", size: "small" }), size: "small", color: "secondary", variant: "transparent" })] }));
|
|
37343
37411
|
};
|
|
37344
37412
|
|
|
37345
37413
|
function useConfirmExit(confirmExit, when = true) {
|
|
@@ -38921,7 +38989,7 @@ const Timeline = ({ className, dataTestId, children }) => {
|
|
|
38921
38989
|
* @param {TimeLineElementProps} props the props
|
|
38922
38990
|
* @returns {JSX.Element} component
|
|
38923
38991
|
*/
|
|
38924
|
-
const TimelineElement = ({ date, showTime, children, className, dataTestId = "timeline-date", headerClassName, dot = jsx(Indicator, { className: "mt-[-1px]", color: "neutral", icon: jsx(Icon, { name: "
|
|
38992
|
+
const TimelineElement = ({ date, showTime, children, className, dataTestId = "timeline-date", headerClassName, dot = jsx(Indicator, { className: "mt-[-1px]", color: "neutral", icon: jsx(Icon, { name: "Calendar", size: "large" }) }), header = defaultHeader(date, showTime), onClick, }) => {
|
|
38925
38993
|
return (jsxs("li", { className: cvaTimelineElement({ className }), "data-date": `${date}`, "data-testid": dataTestId && `${dataTestId}`, onClick: () => onClick && onClick(), children: [jsx("div", { className: cvaTimelineDot(), children: dot }), jsx("div", { children: header }), jsx("div", {}), jsx("div", { children: jsx("div", { children: children }) })] }));
|
|
38926
38994
|
};
|
|
38927
38995
|
function defaultHeader(date, showTime) {
|
|
@@ -39064,4 +39132,4 @@ const cvaClickable = cvaMerge([
|
|
|
39064
39132
|
},
|
|
39065
39133
|
});
|
|
39066
39134
|
|
|
39067
|
-
export { Alert, Badge, Button$1 as Button, Card, CardBody, CardFooter, CardHeader, Collapse, CopyableText, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, Drawer, EmptyState, ExternalLink, Heading, Icon, IconButton, Indicator, MenuItem, MenuList, Modal, ModalBackdrop, MoreMenu, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text, Timeline, TimelineElement, Tip, Tooltip, ValueBar, cvaButton, cvaButtonSpinner, cvaClickable, cvaIconButtonContainer, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, setLocalStorage, useClickOutside, useContainerProps, useContinuousTimeout, useDebounce, useDevicePixelRatio, useHover, useIsFirstRender, useLocalStorage, useLocalStorageReducer, useModal, usePopoverContext, usePrompt, useResize, useTimeout, useVisibilityChange };
|
|
39135
|
+
export { Alert, Badge, Button$1 as Button, Card, CardBody, CardFooter, CardHeader, Collapse, CopyableText, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, Drawer, EmptyState, ExternalLink, Heading, Icon, IconButton, Indicator, MenuItem, MenuList, Modal, ModalBackdrop, MoreMenu, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text, Timeline, TimelineElement, Tip, Tooltip, ValueBar, cvaButton, cvaButtonSpinner, cvaClickable, cvaIconButtonContainer, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContainerProps, useContinuousTimeout, useDebounce, useDevicePixelRatio, useHover, useIsFirstRender, useLocalStorage, useLocalStorageReducer, useModal, usePopoverContext, usePrompt, useResize, useTimeout, useVisibilityChange };
|