@arc-ui/components 12.0.0-beta.20 → 12.0.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Alert/Alert.cjs +40 -14
- package/lib/Alert/Alert.mjs +41 -15
- package/lib/Alert/styles.css +1 -1
- package/lib/Align/styles.css +1 -1
- package/lib/AppButton/styles.css +1 -1
- package/lib/Avatar/styles.css +1 -1
- package/lib/AvatarGroup/styles.css +1 -1
- package/lib/Badge/styles.css +1 -1
- package/lib/Banner/Banner.cjs +2 -2
- package/lib/Banner/Banner.mjs +2 -2
- package/lib/Box/styles.css +1 -1
- package/lib/BrandLogo/styles.css +1 -1
- package/lib/Breadcrumbs/Breadcrumbs.cjs +2 -1
- package/lib/Breadcrumbs/Breadcrumbs.mjs +2 -1
- package/lib/Breadcrumbs/styles.css +1 -1
- package/lib/Button/styles.css +1 -1
- package/lib/ButtonGroup/styles.css +1 -1
- package/lib/ButtonV2/styles.css +1 -1
- package/lib/Calendar/Calendar.cjs +2 -2
- package/lib/Calendar/Calendar.mjs +2 -2
- package/lib/Calendar/styles.css +1 -1
- package/lib/CardFooter/styles.css +1 -1
- package/lib/CardHeading/styles.css +1 -1
- package/lib/Carousel/Carousel.cjs +1 -1
- package/lib/Carousel/Carousel.mjs +1 -1
- package/lib/Carousel/styles.css +1 -1
- package/lib/Checkbox/styles.css +1 -1
- package/lib/Columns/styles.css +1 -1
- package/lib/ComboBox/styles.css +1 -1
- package/lib/ContentSwitcher/ContentSwitcher.cjs +3 -2
- package/lib/ContentSwitcher/ContentSwitcher.mjs +3 -2
- package/lib/ContentSwitcher/styles.css +1 -1
- package/lib/ContentSwitcherDropdown/styles.css +1 -1
- package/lib/DatePicker/DatePicker.cjs +3 -3
- package/lib/DatePicker/DatePicker.mjs +4 -4
- package/lib/DatePicker/styles.css +1 -1
- package/lib/Disclosure/styles.css +1 -1
- package/lib/DisclosureMini/styles.css +1 -1
- package/lib/Download/styles.css +1 -1
- package/lib/Drawer/Drawer.cjs +2 -18
- package/lib/Drawer/Drawer.mjs +3 -19
- package/lib/Drawer/styles.css +1 -1
- package/lib/Elevation/styles.css +1 -1
- package/lib/Filter/styles.css +1 -1
- package/lib/FormControl/styles.css +1 -1
- package/lib/GhostedHeroBanner/styles.css +1 -1
- package/lib/GradientPageBackground/GradientPageBackground.cjs +1 -1
- package/lib/GradientPageBackground/GradientPageBackground.mjs +1 -1
- package/lib/GradientPageBackground/styles.css +1 -1
- package/lib/Grid/styles.css +1 -1
- package/lib/Group/styles.css +1 -1
- package/lib/Heading/styles.css +1 -1
- package/lib/HeroBanner/HeroBanner.cjs +2 -2
- package/lib/HeroBanner/HeroBanner.mjs +2 -2
- package/lib/HeroBanner/styles.css +1 -1
- package/lib/HeroButton/styles.css +1 -1
- package/lib/Hidden/Hidden.cjs +6 -14
- package/lib/Hidden/Hidden.mjs +4 -16
- package/lib/Hidden/styles.css +1 -1
- package/lib/HorizontalCard/styles.css +1 -1
- package/lib/Icon/styles.css +1 -1
- package/lib/Image/styles.css +1 -1
- package/lib/ImpactCard/styles.css +1 -1
- package/lib/InformationCard/InformationCard.cjs +6 -22
- package/lib/InformationCard/InformationCard.mjs +4 -20
- package/lib/InformationCard/styles.css +1 -1
- package/lib/Link/Link.cjs +8 -51
- package/lib/Link/Link.mjs +7 -54
- package/lib/Link/styles.css +1 -1
- package/lib/Markup/styles.css +1 -1
- package/lib/MediaCard/styles.css +1 -1
- package/lib/Menu/Menu.cjs +1 -1
- package/lib/Menu/Menu.mjs +1 -1
- package/lib/Menu/styles.css +1 -1
- package/lib/Modal/styles.css +1 -1
- package/lib/NavigationHeader/NavigationHeader.cjs +687 -0
- package/lib/NavigationHeader/NavigationHeader.mjs +682 -0
- package/lib/NavigationHeader/styles.css +1 -0
- package/lib/Pagination/styles.css +1 -1
- package/lib/PaginationSimple/styles.css +1 -1
- package/lib/Popover/Popover.cjs +9 -26
- package/lib/Popover/Popover.mjs +7 -28
- package/lib/Popover/styles.css +1 -1
- package/lib/Poster/styles.css +1 -1
- package/lib/ProgressBar/styles.css +1 -1
- package/lib/ProgressStepper/styles.css +1 -1
- package/lib/ProgressStepperOverflow/ProgressStepperOverflow.cjs +3 -2
- package/lib/ProgressStepperOverflow/ProgressStepperOverflow.mjs +3 -2
- package/lib/ProgressStepperOverflow/styles.css +1 -1
- package/lib/RadioCardGroup/styles.css +1 -1
- package/lib/RadioGroup/styles.css +1 -1
- package/lib/Rule/styles.css +1 -1
- package/lib/ScrollToTop/ScrollToTop.cjs +2 -1
- package/lib/ScrollToTop/ScrollToTop.mjs +2 -1
- package/lib/ScrollToTop/styles.css +1 -1
- package/lib/Section/styles.css +1 -1
- package/lib/Select/styles.css +1 -1
- package/lib/SiteFooter/SiteFooter.cjs +2 -2
- package/lib/SiteFooter/SiteFooter.mjs +2 -2
- package/lib/SiteFooter/styles.css +1 -1
- package/lib/SiteFooterV2/SiteFooterV2.cjs +2 -2
- package/lib/SiteFooterV2/SiteFooterV2.mjs +2 -2
- package/lib/SiteFooterV2/styles.css +1 -1
- package/lib/SiteHeaderV2/SiteHeaderV2.cjs +2 -2
- package/lib/SiteHeaderV2/SiteHeaderV2.mjs +3 -3
- package/lib/SiteHeaderV2/styles.css +1 -1
- package/lib/Skeleton/styles.css +1 -1
- package/lib/SkipLink/styles.css +1 -1
- package/lib/Spinner/styles.css +1 -1
- package/lib/Surface/styles.css +1 -1
- package/lib/Switch/styles.css +1 -1
- package/lib/TabbedBanner/TabbedBanner.cjs +23 -34
- package/lib/TabbedBanner/TabbedBanner.mjs +25 -36
- package/lib/TabbedBanner/styles.css +1 -1
- package/lib/Tabs/Tabs.cjs +2 -2
- package/lib/Tabs/Tabs.mjs +2 -2
- package/lib/Tabs/styles.css +1 -1
- package/lib/Tag/styles.css +1 -1
- package/lib/TemplateBanner/TemplateBanner.cjs +2 -2
- package/lib/TemplateBanner/TemplateBanner.mjs +2 -2
- package/lib/TemplateBanner/styles.css +1 -1
- package/lib/Text/styles.css +1 -1
- package/lib/TextArea/TextArea.cjs +9 -7
- package/lib/TextArea/TextArea.mjs +9 -7
- package/lib/TextArea/styles.css +1 -1
- package/lib/TextInput/styles.css +1 -1
- package/lib/Theme/Theme.cjs +1 -1
- package/lib/Theme/Theme.mjs +1 -1
- package/lib/Theme/styles.css +1 -1
- package/lib/ThemeIcon/styles.css +1 -1
- package/lib/ThumbnailSignpost/styles.css +1 -1
- package/lib/Toast/styles.css +1 -1
- package/lib/Tooltip/Tooltip.cjs +11 -1363
- package/lib/Tooltip/Tooltip.mjs +10 -1348
- package/lib/Tooltip/styles.css +1 -1
- package/lib/Truncate/styles.css +1 -1
- package/lib/TypographyCard/styles.css +1 -1
- package/lib/UniversalHeader/styles.css +1 -1
- package/lib/VerticalSpace/styles.css +1 -1
- package/lib/VideoPlayer/styles.css +1 -1
- package/lib/Visible/Visible.cjs +1 -1
- package/lib/Visible/Visible.mjs +1 -1
- package/lib/Visible/styles.css +1 -1
- package/lib/VisuallyHidden/styles.css +1 -1
- package/lib/_shared/cjs/{Calendar-D4ZSaHHU.cjs → Calendar-B-va25n2.cjs} +1 -1
- package/lib/_shared/cjs/{ContentSwitcherList-nlxMHXs-.cjs → ContentSwitcherList-bCEzIPN2.cjs} +3 -3
- package/lib/_shared/cjs/{DatePicker-DS6fAvxD.cjs → DatePicker-Dt4faA_N.cjs} +1 -1
- package/lib/_shared/cjs/Hidden-Vsv1-xWO.cjs +19 -0
- package/lib/_shared/cjs/Link-7xUgVf1I.cjs +48 -0
- package/lib/_shared/cjs/Popover-C5mmMkYU.cjs +31 -0
- package/lib/_shared/cjs/{ProgressStepperOverflow-v-TyS5Sp.cjs → ProgressStepperOverflow-BAGZNC26.cjs} +1 -1
- package/lib/_shared/cjs/{SiteHeaderV2NavItemWithSubNav-fQPk0gZU.cjs → SiteHeaderV2NavItemWithSubNav-CagFKPEa.cjs} +1 -1
- package/lib/_shared/cjs/{TemplateBanner-CGtTUy81.cjs → TemplateBanner-CImrJ9ON.cjs} +15 -4
- package/lib/_shared/cjs/Tooltip-BPHL0ELI.cjs +1378 -0
- package/lib/_shared/cjs/{Visible-Dx__9oZG.cjs → Visible-vchtZSfm.cjs} +2 -1
- package/lib/_shared/cjs/arc-breakpoints-DWUgmeLA.cjs +23 -0
- package/lib/_shared/cjs/{debounce-BeIT3oyF.cjs → debounce-uPMetQ6J.cjs} +4 -251
- package/lib/_shared/cjs/{index.es-DBEGtWPg.cjs → index.es-DlNskPlN.cjs} +1 -1
- package/lib/_shared/cjs/isSymbol-BGrHFUbV.cjs +255 -0
- package/lib/_shared/cjs/kebabCase-D5yA6u-V.cjs +743 -0
- package/lib/_shared/esm/{Calendar-CjqPM7ta.mjs → Calendar-Bd2_eT1Y.mjs} +1 -1
- package/lib/_shared/esm/{ContentSwitcherList-DKPD9GfN.mjs → ContentSwitcherList-bCQz0qkU.mjs} +3 -3
- package/lib/_shared/esm/{DatePicker-3sYJ3wGn.mjs → DatePicker-DT4OEzxP.mjs} +1 -1
- package/lib/_shared/esm/Hidden-DsrAaC0z.mjs +17 -0
- package/lib/_shared/esm/Link-Biyg9qBH.mjs +46 -0
- package/lib/_shared/esm/Popover-8FfvgL4c.mjs +29 -0
- package/lib/_shared/esm/{ProgressStepperOverflow-B9ba8ljs.mjs → ProgressStepperOverflow-fPkLltVO.mjs} +1 -1
- package/lib/_shared/esm/{SiteHeaderV2NavItemWithSubNav-BMoBdUxK.mjs → SiteHeaderV2NavItemWithSubNav-CxGwdV6u.mjs} +1 -1
- package/lib/_shared/esm/{TemplateBanner-Up6cR-3_.mjs → TemplateBanner-DeHjliNP.mjs} +15 -4
- package/lib/_shared/esm/Tooltip-Dc82Ht7G.mjs +1358 -0
- package/lib/_shared/esm/{Visible-C-jVXUWp.mjs → Visible-B13QJn7R.mjs} +2 -1
- package/lib/_shared/esm/arc-breakpoints-D5hR5m3t.mjs +21 -0
- package/lib/_shared/esm/{debounce-mCD9-ufA.mjs → debounce-D_Nx5go6.mjs} +2 -249
- package/lib/_shared/esm/{index.es-DCvYtQfu.mjs → index.es-C3WqfFKH.mjs} +1 -1
- package/lib/_shared/esm/isSymbol-DgWNE2Tm.mjs +251 -0
- package/lib/_shared/esm/kebabCase-CCEMRBfd.mjs +737 -0
- package/lib/index.cjs +2183 -792
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +393 -131
- package/lib/index.d.mts +393 -131
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +2181 -794
- package/lib/index.mjs.map +1 -1
- package/lib/styles.css +12 -8
- package/package.json +10 -8
|
@@ -0,0 +1,1358 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { _ as __rest, a as __assign, f as filterAttrs } from './filter-attrs-B6CM-NUr.mjs';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import React__default from 'react';
|
|
5
|
+
import { g as useEscapeKeydown, f as useCallbackRef, b as useLayoutEffect2, c as createContextScope$1, a as useId, u as useControllableState, e as useThemeElement } from './index-Bz2JQq34.mjs';
|
|
6
|
+
import * as ReactDOM from 'react-dom';
|
|
7
|
+
import ReactDOM__default from 'react-dom';
|
|
8
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
9
|
+
import { u as useSize, a as useFloating, b as autoUpdate, o as offset, s as shift, l as limitShift, f as flip, c as size, d as arrow, h as hide } from './index-CWHcEz3_.mjs';
|
|
10
|
+
import { S as Surface } from './Surface-Colbp3Zx.mjs';
|
|
11
|
+
import { I as Icon } from './Icon-CcPOJcQm.mjs';
|
|
12
|
+
import { T as Text } from './Text-CBlnm5CT.mjs';
|
|
13
|
+
|
|
14
|
+
// packages/core/primitive/src/primitive.tsx
|
|
15
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
16
|
+
return function handleEvent(event) {
|
|
17
|
+
originalEventHandler?.(event);
|
|
18
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
19
|
+
return ourEventHandler?.(event);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// packages/react/compose-refs/src/composeRefs.tsx
|
|
25
|
+
function setRef(ref, value) {
|
|
26
|
+
if (typeof ref === "function") {
|
|
27
|
+
ref(value);
|
|
28
|
+
} else if (ref !== null && ref !== void 0) {
|
|
29
|
+
ref.current = value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function composeRefs(...refs) {
|
|
33
|
+
return (node) => refs.forEach((ref) => setRef(ref, node));
|
|
34
|
+
}
|
|
35
|
+
function useComposedRefs(...refs) {
|
|
36
|
+
return React.useCallback(composeRefs(...refs), refs);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// packages/react/slot/src/Slot.tsx
|
|
40
|
+
var Slot = React.forwardRef((props, forwardedRef) => {
|
|
41
|
+
const { children, ...slotProps } = props;
|
|
42
|
+
const childrenArray = React.Children.toArray(children);
|
|
43
|
+
const slottable = childrenArray.find(isSlottable);
|
|
44
|
+
if (slottable) {
|
|
45
|
+
const newElement = slottable.props.children;
|
|
46
|
+
const newChildren = childrenArray.map((child) => {
|
|
47
|
+
if (child === slottable) {
|
|
48
|
+
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
49
|
+
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
50
|
+
} else {
|
|
51
|
+
return child;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
55
|
+
}
|
|
56
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
57
|
+
});
|
|
58
|
+
Slot.displayName = "Slot";
|
|
59
|
+
var SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
60
|
+
const { children, ...slotProps } = props;
|
|
61
|
+
if (React.isValidElement(children)) {
|
|
62
|
+
const childrenRef = getElementRef$1(children);
|
|
63
|
+
return React.cloneElement(children, {
|
|
64
|
+
...mergeProps(slotProps, children.props),
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
ref: forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
70
|
+
});
|
|
71
|
+
SlotClone.displayName = "SlotClone";
|
|
72
|
+
var Slottable = ({ children }) => {
|
|
73
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
74
|
+
};
|
|
75
|
+
function isSlottable(child) {
|
|
76
|
+
return React.isValidElement(child) && child.type === Slottable;
|
|
77
|
+
}
|
|
78
|
+
function mergeProps(slotProps, childProps) {
|
|
79
|
+
const overrideProps = { ...childProps };
|
|
80
|
+
for (const propName in childProps) {
|
|
81
|
+
const slotPropValue = slotProps[propName];
|
|
82
|
+
const childPropValue = childProps[propName];
|
|
83
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
84
|
+
if (isHandler) {
|
|
85
|
+
if (slotPropValue && childPropValue) {
|
|
86
|
+
overrideProps[propName] = (...args) => {
|
|
87
|
+
childPropValue(...args);
|
|
88
|
+
slotPropValue(...args);
|
|
89
|
+
};
|
|
90
|
+
} else if (slotPropValue) {
|
|
91
|
+
overrideProps[propName] = slotPropValue;
|
|
92
|
+
}
|
|
93
|
+
} else if (propName === "style") {
|
|
94
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
95
|
+
} else if (propName === "className") {
|
|
96
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return { ...slotProps, ...overrideProps };
|
|
100
|
+
}
|
|
101
|
+
function getElementRef$1(element) {
|
|
102
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
103
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
104
|
+
if (mayWarn) {
|
|
105
|
+
return element.ref;
|
|
106
|
+
}
|
|
107
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
108
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
109
|
+
if (mayWarn) {
|
|
110
|
+
return element.props.ref;
|
|
111
|
+
}
|
|
112
|
+
return element.props.ref || element.ref;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// packages/react/primitive/src/Primitive.tsx
|
|
116
|
+
var NODES = [
|
|
117
|
+
"a",
|
|
118
|
+
"button",
|
|
119
|
+
"div",
|
|
120
|
+
"form",
|
|
121
|
+
"h2",
|
|
122
|
+
"h3",
|
|
123
|
+
"img",
|
|
124
|
+
"input",
|
|
125
|
+
"label",
|
|
126
|
+
"li",
|
|
127
|
+
"nav",
|
|
128
|
+
"ol",
|
|
129
|
+
"p",
|
|
130
|
+
"span",
|
|
131
|
+
"svg",
|
|
132
|
+
"ul"
|
|
133
|
+
];
|
|
134
|
+
var Primitive = NODES.reduce((primitive, node) => {
|
|
135
|
+
const Node = React.forwardRef((props, forwardedRef) => {
|
|
136
|
+
const { asChild, ...primitiveProps } = props;
|
|
137
|
+
const Comp = asChild ? Slot : node;
|
|
138
|
+
if (typeof window !== "undefined") {
|
|
139
|
+
window[Symbol.for("radix-ui")] = true;
|
|
140
|
+
}
|
|
141
|
+
return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
142
|
+
});
|
|
143
|
+
Node.displayName = `Primitive.${node}`;
|
|
144
|
+
return { ...primitive, [node]: Node };
|
|
145
|
+
}, {});
|
|
146
|
+
function dispatchDiscreteCustomEvent(target, event) {
|
|
147
|
+
if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
var DISMISSABLE_LAYER_NAME = "DismissableLayer";
|
|
151
|
+
var CONTEXT_UPDATE = "dismissableLayer.update";
|
|
152
|
+
var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
|
|
153
|
+
var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
|
|
154
|
+
var originalBodyPointerEvents;
|
|
155
|
+
var DismissableLayerContext = React.createContext({
|
|
156
|
+
layers: /* @__PURE__ */ new Set(),
|
|
157
|
+
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
158
|
+
branches: /* @__PURE__ */ new Set()
|
|
159
|
+
});
|
|
160
|
+
var DismissableLayer = React.forwardRef(
|
|
161
|
+
(props, forwardedRef) => {
|
|
162
|
+
const {
|
|
163
|
+
disableOutsidePointerEvents = false,
|
|
164
|
+
onEscapeKeyDown,
|
|
165
|
+
onPointerDownOutside,
|
|
166
|
+
onFocusOutside,
|
|
167
|
+
onInteractOutside,
|
|
168
|
+
onDismiss,
|
|
169
|
+
...layerProps
|
|
170
|
+
} = props;
|
|
171
|
+
const context = React.useContext(DismissableLayerContext);
|
|
172
|
+
const [node, setNode] = React.useState(null);
|
|
173
|
+
const ownerDocument = node?.ownerDocument ?? globalThis?.document;
|
|
174
|
+
const [, force] = React.useState({});
|
|
175
|
+
const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
|
|
176
|
+
const layers = Array.from(context.layers);
|
|
177
|
+
const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
|
|
178
|
+
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
|
|
179
|
+
const index = node ? layers.indexOf(node) : -1;
|
|
180
|
+
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
181
|
+
const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
182
|
+
const pointerDownOutside = usePointerDownOutside((event) => {
|
|
183
|
+
const target = event.target;
|
|
184
|
+
const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
185
|
+
if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
|
|
186
|
+
onPointerDownOutside?.(event);
|
|
187
|
+
onInteractOutside?.(event);
|
|
188
|
+
if (!event.defaultPrevented) onDismiss?.();
|
|
189
|
+
}, ownerDocument);
|
|
190
|
+
const focusOutside = useFocusOutside((event) => {
|
|
191
|
+
const target = event.target;
|
|
192
|
+
const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
193
|
+
if (isFocusInBranch) return;
|
|
194
|
+
onFocusOutside?.(event);
|
|
195
|
+
onInteractOutside?.(event);
|
|
196
|
+
if (!event.defaultPrevented) onDismiss?.();
|
|
197
|
+
}, ownerDocument);
|
|
198
|
+
useEscapeKeydown((event) => {
|
|
199
|
+
const isHighestLayer = index === context.layers.size - 1;
|
|
200
|
+
if (!isHighestLayer) return;
|
|
201
|
+
onEscapeKeyDown?.(event);
|
|
202
|
+
if (!event.defaultPrevented && onDismiss) {
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
onDismiss();
|
|
205
|
+
}
|
|
206
|
+
}, ownerDocument);
|
|
207
|
+
React.useEffect(() => {
|
|
208
|
+
if (!node) return;
|
|
209
|
+
if (disableOutsidePointerEvents) {
|
|
210
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
211
|
+
originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
|
|
212
|
+
ownerDocument.body.style.pointerEvents = "none";
|
|
213
|
+
}
|
|
214
|
+
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
215
|
+
}
|
|
216
|
+
context.layers.add(node);
|
|
217
|
+
dispatchUpdate();
|
|
218
|
+
return () => {
|
|
219
|
+
if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
|
|
220
|
+
ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}, [node, ownerDocument, disableOutsidePointerEvents, context]);
|
|
224
|
+
React.useEffect(() => {
|
|
225
|
+
return () => {
|
|
226
|
+
if (!node) return;
|
|
227
|
+
context.layers.delete(node);
|
|
228
|
+
context.layersWithOutsidePointerEventsDisabled.delete(node);
|
|
229
|
+
dispatchUpdate();
|
|
230
|
+
};
|
|
231
|
+
}, [node, context]);
|
|
232
|
+
React.useEffect(() => {
|
|
233
|
+
const handleUpdate = () => force({});
|
|
234
|
+
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
235
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
236
|
+
}, []);
|
|
237
|
+
return /* @__PURE__ */ jsx(
|
|
238
|
+
Primitive.div,
|
|
239
|
+
{
|
|
240
|
+
...layerProps,
|
|
241
|
+
ref: composedRefs,
|
|
242
|
+
style: {
|
|
243
|
+
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
244
|
+
...props.style
|
|
245
|
+
},
|
|
246
|
+
onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
247
|
+
onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
248
|
+
onPointerDownCapture: composeEventHandlers(
|
|
249
|
+
props.onPointerDownCapture,
|
|
250
|
+
pointerDownOutside.onPointerDownCapture
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
|
|
257
|
+
var BRANCH_NAME = "DismissableLayerBranch";
|
|
258
|
+
var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
|
|
259
|
+
const context = React.useContext(DismissableLayerContext);
|
|
260
|
+
const ref = React.useRef(null);
|
|
261
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
262
|
+
React.useEffect(() => {
|
|
263
|
+
const node = ref.current;
|
|
264
|
+
if (node) {
|
|
265
|
+
context.branches.add(node);
|
|
266
|
+
return () => {
|
|
267
|
+
context.branches.delete(node);
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
}, [context.branches]);
|
|
271
|
+
return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
|
|
272
|
+
});
|
|
273
|
+
DismissableLayerBranch.displayName = BRANCH_NAME;
|
|
274
|
+
function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
|
|
275
|
+
const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
|
|
276
|
+
const isPointerInsideReactTreeRef = React.useRef(false);
|
|
277
|
+
const handleClickRef = React.useRef(() => {
|
|
278
|
+
});
|
|
279
|
+
React.useEffect(() => {
|
|
280
|
+
const handlePointerDown = (event) => {
|
|
281
|
+
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
282
|
+
let handleAndDispatchPointerDownOutsideEvent2 = function() {
|
|
283
|
+
handleAndDispatchCustomEvent(
|
|
284
|
+
POINTER_DOWN_OUTSIDE,
|
|
285
|
+
handlePointerDownOutside,
|
|
286
|
+
eventDetail,
|
|
287
|
+
{ discrete: true }
|
|
288
|
+
);
|
|
289
|
+
};
|
|
290
|
+
const eventDetail = { originalEvent: event };
|
|
291
|
+
if (event.pointerType === "touch") {
|
|
292
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
293
|
+
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
|
|
294
|
+
ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
|
|
295
|
+
} else {
|
|
296
|
+
handleAndDispatchPointerDownOutsideEvent2();
|
|
297
|
+
}
|
|
298
|
+
} else {
|
|
299
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
300
|
+
}
|
|
301
|
+
isPointerInsideReactTreeRef.current = false;
|
|
302
|
+
};
|
|
303
|
+
const timerId = window.setTimeout(() => {
|
|
304
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown);
|
|
305
|
+
}, 0);
|
|
306
|
+
return () => {
|
|
307
|
+
window.clearTimeout(timerId);
|
|
308
|
+
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
|
|
309
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
310
|
+
};
|
|
311
|
+
}, [ownerDocument, handlePointerDownOutside]);
|
|
312
|
+
return {
|
|
313
|
+
// ensures we check React component tree (not just DOM tree)
|
|
314
|
+
onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
|
|
318
|
+
const handleFocusOutside = useCallbackRef(onFocusOutside);
|
|
319
|
+
const isFocusInsideReactTreeRef = React.useRef(false);
|
|
320
|
+
React.useEffect(() => {
|
|
321
|
+
const handleFocus = (event) => {
|
|
322
|
+
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
323
|
+
const eventDetail = { originalEvent: event };
|
|
324
|
+
handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
|
|
325
|
+
discrete: false
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
ownerDocument.addEventListener("focusin", handleFocus);
|
|
330
|
+
return () => ownerDocument.removeEventListener("focusin", handleFocus);
|
|
331
|
+
}, [ownerDocument, handleFocusOutside]);
|
|
332
|
+
return {
|
|
333
|
+
onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
|
|
334
|
+
onBlurCapture: () => isFocusInsideReactTreeRef.current = false
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function dispatchUpdate() {
|
|
338
|
+
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
339
|
+
document.dispatchEvent(event);
|
|
340
|
+
}
|
|
341
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
342
|
+
const target = detail.originalEvent.target;
|
|
343
|
+
const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
|
|
344
|
+
if (handler) target.addEventListener(name, handler, { once: true });
|
|
345
|
+
if (discrete) {
|
|
346
|
+
dispatchDiscreteCustomEvent(target, event);
|
|
347
|
+
} else {
|
|
348
|
+
target.dispatchEvent(event);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// packages/react/arrow/src/Arrow.tsx
|
|
353
|
+
var NAME$1 = "Arrow";
|
|
354
|
+
var Arrow$1 = React.forwardRef((props, forwardedRef) => {
|
|
355
|
+
const { children, width = 10, height = 5, ...arrowProps } = props;
|
|
356
|
+
return /* @__PURE__ */ jsx(
|
|
357
|
+
Primitive.svg,
|
|
358
|
+
{
|
|
359
|
+
...arrowProps,
|
|
360
|
+
ref: forwardedRef,
|
|
361
|
+
width,
|
|
362
|
+
height,
|
|
363
|
+
viewBox: "0 0 30 10",
|
|
364
|
+
preserveAspectRatio: "none",
|
|
365
|
+
children: props.asChild ? children : /* @__PURE__ */ jsx("polygon", { points: "0,0 30,0 15,10" })
|
|
366
|
+
}
|
|
367
|
+
);
|
|
368
|
+
});
|
|
369
|
+
Arrow$1.displayName = NAME$1;
|
|
370
|
+
var Root$1 = Arrow$1;
|
|
371
|
+
|
|
372
|
+
// packages/react/context/src/createContext.tsx
|
|
373
|
+
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
374
|
+
let defaultContexts = [];
|
|
375
|
+
function createContext3(rootComponentName, defaultContext) {
|
|
376
|
+
const BaseContext = React.createContext(defaultContext);
|
|
377
|
+
const index = defaultContexts.length;
|
|
378
|
+
defaultContexts = [...defaultContexts, defaultContext];
|
|
379
|
+
function Provider(props) {
|
|
380
|
+
const { scope, children, ...context } = props;
|
|
381
|
+
const Context = scope?.[scopeName][index] || BaseContext;
|
|
382
|
+
const value = React.useMemo(() => context, Object.values(context));
|
|
383
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value, children });
|
|
384
|
+
}
|
|
385
|
+
function useContext2(consumerName, scope) {
|
|
386
|
+
const Context = scope?.[scopeName][index] || BaseContext;
|
|
387
|
+
const context = React.useContext(Context);
|
|
388
|
+
if (context) return context;
|
|
389
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
390
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
391
|
+
}
|
|
392
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
393
|
+
return [Provider, useContext2];
|
|
394
|
+
}
|
|
395
|
+
const createScope = () => {
|
|
396
|
+
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
397
|
+
return React.createContext(defaultContext);
|
|
398
|
+
});
|
|
399
|
+
return function useScope(scope) {
|
|
400
|
+
const contexts = scope?.[scopeName] || scopeContexts;
|
|
401
|
+
return React.useMemo(
|
|
402
|
+
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
|
|
403
|
+
[scope, contexts]
|
|
404
|
+
);
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
createScope.scopeName = scopeName;
|
|
408
|
+
return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
|
|
409
|
+
}
|
|
410
|
+
function composeContextScopes(...scopes) {
|
|
411
|
+
const baseScope = scopes[0];
|
|
412
|
+
if (scopes.length === 1) return baseScope;
|
|
413
|
+
const createScope = () => {
|
|
414
|
+
const scopeHooks = scopes.map((createScope2) => ({
|
|
415
|
+
useScope: createScope2(),
|
|
416
|
+
scopeName: createScope2.scopeName
|
|
417
|
+
}));
|
|
418
|
+
return function useComposedScopes(overrideScopes) {
|
|
419
|
+
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
|
|
420
|
+
const scopeProps = useScope(overrideScopes);
|
|
421
|
+
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
422
|
+
return { ...nextScopes2, ...currentScope };
|
|
423
|
+
}, {});
|
|
424
|
+
return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
425
|
+
};
|
|
426
|
+
};
|
|
427
|
+
createScope.scopeName = baseScope.scopeName;
|
|
428
|
+
return createScope;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
var POPPER_NAME = "Popper";
|
|
432
|
+
var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
|
|
433
|
+
var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
|
434
|
+
var Popper = (props) => {
|
|
435
|
+
const { __scopePopper, children } = props;
|
|
436
|
+
const [anchor, setAnchor] = React.useState(null);
|
|
437
|
+
return /* @__PURE__ */ jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
|
|
438
|
+
};
|
|
439
|
+
Popper.displayName = POPPER_NAME;
|
|
440
|
+
var ANCHOR_NAME = "PopperAnchor";
|
|
441
|
+
var PopperAnchor = React.forwardRef(
|
|
442
|
+
(props, forwardedRef) => {
|
|
443
|
+
const { __scopePopper, virtualRef, ...anchorProps } = props;
|
|
444
|
+
const context = usePopperContext(ANCHOR_NAME, __scopePopper);
|
|
445
|
+
const ref = React.useRef(null);
|
|
446
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
447
|
+
React.useEffect(() => {
|
|
448
|
+
context.onAnchorChange(virtualRef?.current || ref.current);
|
|
449
|
+
});
|
|
450
|
+
return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
|
|
451
|
+
}
|
|
452
|
+
);
|
|
453
|
+
PopperAnchor.displayName = ANCHOR_NAME;
|
|
454
|
+
var CONTENT_NAME$1 = "PopperContent";
|
|
455
|
+
var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME$1);
|
|
456
|
+
var PopperContent = React.forwardRef(
|
|
457
|
+
(props, forwardedRef) => {
|
|
458
|
+
const {
|
|
459
|
+
__scopePopper,
|
|
460
|
+
side = "bottom",
|
|
461
|
+
sideOffset = 0,
|
|
462
|
+
align = "center",
|
|
463
|
+
alignOffset = 0,
|
|
464
|
+
arrowPadding = 0,
|
|
465
|
+
avoidCollisions = true,
|
|
466
|
+
collisionBoundary = [],
|
|
467
|
+
collisionPadding: collisionPaddingProp = 0,
|
|
468
|
+
sticky = "partial",
|
|
469
|
+
hideWhenDetached = false,
|
|
470
|
+
updatePositionStrategy = "optimized",
|
|
471
|
+
onPlaced,
|
|
472
|
+
...contentProps
|
|
473
|
+
} = props;
|
|
474
|
+
const context = usePopperContext(CONTENT_NAME$1, __scopePopper);
|
|
475
|
+
const [content, setContent] = React.useState(null);
|
|
476
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
|
|
477
|
+
const [arrow$1, setArrow] = React.useState(null);
|
|
478
|
+
const arrowSize = useSize(arrow$1);
|
|
479
|
+
const arrowWidth = arrowSize?.width ?? 0;
|
|
480
|
+
const arrowHeight = arrowSize?.height ?? 0;
|
|
481
|
+
const desiredPlacement = side + (align !== "center" ? "-" + align : "");
|
|
482
|
+
const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
|
|
483
|
+
const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
|
|
484
|
+
const hasExplicitBoundaries = boundary.length > 0;
|
|
485
|
+
const detectOverflowOptions = {
|
|
486
|
+
padding: collisionPadding,
|
|
487
|
+
boundary: boundary.filter(isNotNull),
|
|
488
|
+
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
|
489
|
+
altBoundary: hasExplicitBoundaries
|
|
490
|
+
};
|
|
491
|
+
const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
|
|
492
|
+
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
|
|
493
|
+
strategy: "fixed",
|
|
494
|
+
placement: desiredPlacement,
|
|
495
|
+
whileElementsMounted: (...args) => {
|
|
496
|
+
const cleanup = autoUpdate(...args, {
|
|
497
|
+
animationFrame: updatePositionStrategy === "always"
|
|
498
|
+
});
|
|
499
|
+
return cleanup;
|
|
500
|
+
},
|
|
501
|
+
elements: {
|
|
502
|
+
reference: context.anchor
|
|
503
|
+
},
|
|
504
|
+
middleware: [
|
|
505
|
+
offset({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }),
|
|
506
|
+
avoidCollisions && shift({
|
|
507
|
+
mainAxis: true,
|
|
508
|
+
crossAxis: false,
|
|
509
|
+
limiter: sticky === "partial" ? limitShift() : void 0,
|
|
510
|
+
...detectOverflowOptions
|
|
511
|
+
}),
|
|
512
|
+
avoidCollisions && flip({ ...detectOverflowOptions }),
|
|
513
|
+
size({
|
|
514
|
+
...detectOverflowOptions,
|
|
515
|
+
apply: ({ elements, rects, availableWidth, availableHeight }) => {
|
|
516
|
+
const { width: anchorWidth, height: anchorHeight } = rects.reference;
|
|
517
|
+
const contentStyle = elements.floating.style;
|
|
518
|
+
contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
|
|
519
|
+
contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
|
|
520
|
+
contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
|
|
521
|
+
contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
|
|
522
|
+
}
|
|
523
|
+
}),
|
|
524
|
+
arrow$1 && arrow({ element: arrow$1, padding: arrowPadding }),
|
|
525
|
+
transformOrigin({ arrowWidth, arrowHeight }),
|
|
526
|
+
hideWhenDetached && hide({ strategy: "referenceHidden", ...detectOverflowOptions })
|
|
527
|
+
]
|
|
528
|
+
});
|
|
529
|
+
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
530
|
+
const handlePlaced = useCallbackRef(onPlaced);
|
|
531
|
+
useLayoutEffect2(() => {
|
|
532
|
+
if (isPositioned) {
|
|
533
|
+
handlePlaced?.();
|
|
534
|
+
}
|
|
535
|
+
}, [isPositioned, handlePlaced]);
|
|
536
|
+
const arrowX = middlewareData.arrow?.x;
|
|
537
|
+
const arrowY = middlewareData.arrow?.y;
|
|
538
|
+
const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
|
|
539
|
+
const [contentZIndex, setContentZIndex] = React.useState();
|
|
540
|
+
useLayoutEffect2(() => {
|
|
541
|
+
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
542
|
+
}, [content]);
|
|
543
|
+
return /* @__PURE__ */ jsx(
|
|
544
|
+
"div",
|
|
545
|
+
{
|
|
546
|
+
ref: refs.setFloating,
|
|
547
|
+
"data-radix-popper-content-wrapper": "",
|
|
548
|
+
style: {
|
|
549
|
+
...floatingStyles,
|
|
550
|
+
transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
|
|
551
|
+
// keep off the page when measuring
|
|
552
|
+
minWidth: "max-content",
|
|
553
|
+
zIndex: contentZIndex,
|
|
554
|
+
["--radix-popper-transform-origin"]: [
|
|
555
|
+
middlewareData.transformOrigin?.x,
|
|
556
|
+
middlewareData.transformOrigin?.y
|
|
557
|
+
].join(" "),
|
|
558
|
+
// hide the content if using the hide middleware and should be hidden
|
|
559
|
+
// set visibility to hidden and disable pointer events so the UI behaves
|
|
560
|
+
// as if the PopperContent isn't there at all
|
|
561
|
+
...middlewareData.hide?.referenceHidden && {
|
|
562
|
+
visibility: "hidden",
|
|
563
|
+
pointerEvents: "none"
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
dir: props.dir,
|
|
567
|
+
children: /* @__PURE__ */ jsx(
|
|
568
|
+
PopperContentProvider,
|
|
569
|
+
{
|
|
570
|
+
scope: __scopePopper,
|
|
571
|
+
placedSide,
|
|
572
|
+
onArrowChange: setArrow,
|
|
573
|
+
arrowX,
|
|
574
|
+
arrowY,
|
|
575
|
+
shouldHideArrow: cannotCenterArrow,
|
|
576
|
+
children: /* @__PURE__ */ jsx(
|
|
577
|
+
Primitive.div,
|
|
578
|
+
{
|
|
579
|
+
"data-side": placedSide,
|
|
580
|
+
"data-align": placedAlign,
|
|
581
|
+
...contentProps,
|
|
582
|
+
ref: composedRefs,
|
|
583
|
+
style: {
|
|
584
|
+
...contentProps.style,
|
|
585
|
+
// if the PopperContent hasn't been placed yet (not all measurements done)
|
|
586
|
+
// we prevent animations so that users's animation don't kick in too early referring wrong sides
|
|
587
|
+
animation: !isPositioned ? "none" : void 0
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
)
|
|
591
|
+
}
|
|
592
|
+
)
|
|
593
|
+
}
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
);
|
|
597
|
+
PopperContent.displayName = CONTENT_NAME$1;
|
|
598
|
+
var ARROW_NAME$1 = "PopperArrow";
|
|
599
|
+
var OPPOSITE_SIDE = {
|
|
600
|
+
top: "bottom",
|
|
601
|
+
right: "left",
|
|
602
|
+
bottom: "top",
|
|
603
|
+
left: "right"
|
|
604
|
+
};
|
|
605
|
+
var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
|
|
606
|
+
const { __scopePopper, ...arrowProps } = props;
|
|
607
|
+
const contentContext = useContentContext(ARROW_NAME$1, __scopePopper);
|
|
608
|
+
const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
|
|
609
|
+
return (
|
|
610
|
+
// we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
|
|
611
|
+
// doesn't report size as we'd expect on SVG elements.
|
|
612
|
+
// it reports their bounding box which is effectively the largest path inside the SVG.
|
|
613
|
+
/* @__PURE__ */ jsx(
|
|
614
|
+
"span",
|
|
615
|
+
{
|
|
616
|
+
ref: contentContext.onArrowChange,
|
|
617
|
+
style: {
|
|
618
|
+
position: "absolute",
|
|
619
|
+
left: contentContext.arrowX,
|
|
620
|
+
top: contentContext.arrowY,
|
|
621
|
+
[baseSide]: 0,
|
|
622
|
+
transformOrigin: {
|
|
623
|
+
top: "",
|
|
624
|
+
right: "0 0",
|
|
625
|
+
bottom: "center 0",
|
|
626
|
+
left: "100% 0"
|
|
627
|
+
}[contentContext.placedSide],
|
|
628
|
+
transform: {
|
|
629
|
+
top: "translateY(100%)",
|
|
630
|
+
right: "translateY(50%) rotate(90deg) translateX(-50%)",
|
|
631
|
+
bottom: `rotate(180deg)`,
|
|
632
|
+
left: "translateY(50%) rotate(-90deg) translateX(50%)"
|
|
633
|
+
}[contentContext.placedSide],
|
|
634
|
+
visibility: contentContext.shouldHideArrow ? "hidden" : void 0
|
|
635
|
+
},
|
|
636
|
+
children: /* @__PURE__ */ jsx(
|
|
637
|
+
Root$1,
|
|
638
|
+
{
|
|
639
|
+
...arrowProps,
|
|
640
|
+
ref: forwardedRef,
|
|
641
|
+
style: {
|
|
642
|
+
...arrowProps.style,
|
|
643
|
+
// ensures the element can be measured correctly (mostly for if SVG)
|
|
644
|
+
display: "block"
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
)
|
|
648
|
+
}
|
|
649
|
+
)
|
|
650
|
+
);
|
|
651
|
+
});
|
|
652
|
+
PopperArrow.displayName = ARROW_NAME$1;
|
|
653
|
+
function isNotNull(value) {
|
|
654
|
+
return value !== null;
|
|
655
|
+
}
|
|
656
|
+
var transformOrigin = (options) => ({
|
|
657
|
+
name: "transformOrigin",
|
|
658
|
+
options,
|
|
659
|
+
fn(data) {
|
|
660
|
+
const { placement, rects, middlewareData } = data;
|
|
661
|
+
const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
|
|
662
|
+
const isArrowHidden = cannotCenterArrow;
|
|
663
|
+
const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
|
|
664
|
+
const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
|
|
665
|
+
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
666
|
+
const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
|
|
667
|
+
const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
|
|
668
|
+
const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
|
|
669
|
+
let x = "";
|
|
670
|
+
let y = "";
|
|
671
|
+
if (placedSide === "bottom") {
|
|
672
|
+
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
|
673
|
+
y = `${-arrowHeight}px`;
|
|
674
|
+
} else if (placedSide === "top") {
|
|
675
|
+
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
|
676
|
+
y = `${rects.floating.height + arrowHeight}px`;
|
|
677
|
+
} else if (placedSide === "right") {
|
|
678
|
+
x = `${-arrowHeight}px`;
|
|
679
|
+
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
|
680
|
+
} else if (placedSide === "left") {
|
|
681
|
+
x = `${rects.floating.width + arrowHeight}px`;
|
|
682
|
+
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
|
683
|
+
}
|
|
684
|
+
return { data: { x, y } };
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
function getSideAndAlignFromPlacement(placement) {
|
|
688
|
+
const [side, align = "center"] = placement.split("-");
|
|
689
|
+
return [side, align];
|
|
690
|
+
}
|
|
691
|
+
var Root2 = Popper;
|
|
692
|
+
var Anchor = PopperAnchor;
|
|
693
|
+
var Content = PopperContent;
|
|
694
|
+
var Arrow = PopperArrow;
|
|
695
|
+
|
|
696
|
+
var PORTAL_NAME$1 = "Portal";
|
|
697
|
+
var Portal$1 = React.forwardRef((props, forwardedRef) => {
|
|
698
|
+
const { container: containerProp, ...portalProps } = props;
|
|
699
|
+
const [mounted, setMounted] = React.useState(false);
|
|
700
|
+
useLayoutEffect2(() => setMounted(true), []);
|
|
701
|
+
const container = containerProp || mounted && globalThis?.document?.body;
|
|
702
|
+
return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
|
703
|
+
});
|
|
704
|
+
Portal$1.displayName = PORTAL_NAME$1;
|
|
705
|
+
|
|
706
|
+
function useStateMachine(initialState, machine) {
|
|
707
|
+
return React.useReducer((state, event) => {
|
|
708
|
+
const nextState = machine[state][event];
|
|
709
|
+
return nextState ?? state;
|
|
710
|
+
}, initialState);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// packages/react/presence/src/Presence.tsx
|
|
714
|
+
var Presence = (props) => {
|
|
715
|
+
const { present, children } = props;
|
|
716
|
+
const presence = usePresence(present);
|
|
717
|
+
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
|
|
718
|
+
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
719
|
+
const forceMount = typeof children === "function";
|
|
720
|
+
return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
|
|
721
|
+
};
|
|
722
|
+
Presence.displayName = "Presence";
|
|
723
|
+
function usePresence(present) {
|
|
724
|
+
const [node, setNode] = React.useState();
|
|
725
|
+
const stylesRef = React.useRef({});
|
|
726
|
+
const prevPresentRef = React.useRef(present);
|
|
727
|
+
const prevAnimationNameRef = React.useRef("none");
|
|
728
|
+
const initialState = present ? "mounted" : "unmounted";
|
|
729
|
+
const [state, send] = useStateMachine(initialState, {
|
|
730
|
+
mounted: {
|
|
731
|
+
UNMOUNT: "unmounted",
|
|
732
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
733
|
+
},
|
|
734
|
+
unmountSuspended: {
|
|
735
|
+
MOUNT: "mounted",
|
|
736
|
+
ANIMATION_END: "unmounted"
|
|
737
|
+
},
|
|
738
|
+
unmounted: {
|
|
739
|
+
MOUNT: "mounted"
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
React.useEffect(() => {
|
|
743
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
744
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
745
|
+
}, [state]);
|
|
746
|
+
useLayoutEffect2(() => {
|
|
747
|
+
const styles = stylesRef.current;
|
|
748
|
+
const wasPresent = prevPresentRef.current;
|
|
749
|
+
const hasPresentChanged = wasPresent !== present;
|
|
750
|
+
if (hasPresentChanged) {
|
|
751
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
752
|
+
const currentAnimationName = getAnimationName(styles);
|
|
753
|
+
if (present) {
|
|
754
|
+
send("MOUNT");
|
|
755
|
+
} else if (currentAnimationName === "none" || styles?.display === "none") {
|
|
756
|
+
send("UNMOUNT");
|
|
757
|
+
} else {
|
|
758
|
+
const isAnimating = prevAnimationName !== currentAnimationName;
|
|
759
|
+
if (wasPresent && isAnimating) {
|
|
760
|
+
send("ANIMATION_OUT");
|
|
761
|
+
} else {
|
|
762
|
+
send("UNMOUNT");
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
prevPresentRef.current = present;
|
|
766
|
+
}
|
|
767
|
+
}, [present, send]);
|
|
768
|
+
useLayoutEffect2(() => {
|
|
769
|
+
if (node) {
|
|
770
|
+
let timeoutId;
|
|
771
|
+
const ownerWindow = node.ownerDocument.defaultView ?? window;
|
|
772
|
+
const handleAnimationEnd = (event) => {
|
|
773
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
774
|
+
const isCurrentAnimation = currentAnimationName.includes(event.animationName);
|
|
775
|
+
if (event.target === node && isCurrentAnimation) {
|
|
776
|
+
send("ANIMATION_END");
|
|
777
|
+
if (!prevPresentRef.current) {
|
|
778
|
+
const currentFillMode = node.style.animationFillMode;
|
|
779
|
+
node.style.animationFillMode = "forwards";
|
|
780
|
+
timeoutId = ownerWindow.setTimeout(() => {
|
|
781
|
+
if (node.style.animationFillMode === "forwards") {
|
|
782
|
+
node.style.animationFillMode = currentFillMode;
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
const handleAnimationStart = (event) => {
|
|
789
|
+
if (event.target === node) {
|
|
790
|
+
prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
node.addEventListener("animationstart", handleAnimationStart);
|
|
794
|
+
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
795
|
+
node.addEventListener("animationend", handleAnimationEnd);
|
|
796
|
+
return () => {
|
|
797
|
+
ownerWindow.clearTimeout(timeoutId);
|
|
798
|
+
node.removeEventListener("animationstart", handleAnimationStart);
|
|
799
|
+
node.removeEventListener("animationcancel", handleAnimationEnd);
|
|
800
|
+
node.removeEventListener("animationend", handleAnimationEnd);
|
|
801
|
+
};
|
|
802
|
+
} else {
|
|
803
|
+
send("ANIMATION_END");
|
|
804
|
+
}
|
|
805
|
+
}, [node, send]);
|
|
806
|
+
return {
|
|
807
|
+
isPresent: ["mounted", "unmountSuspended"].includes(state),
|
|
808
|
+
ref: React.useCallback((node2) => {
|
|
809
|
+
if (node2) stylesRef.current = getComputedStyle(node2);
|
|
810
|
+
setNode(node2);
|
|
811
|
+
}, [])
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
function getAnimationName(styles) {
|
|
815
|
+
return styles?.animationName || "none";
|
|
816
|
+
}
|
|
817
|
+
function getElementRef(element) {
|
|
818
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
819
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
820
|
+
if (mayWarn) {
|
|
821
|
+
return element.ref;
|
|
822
|
+
}
|
|
823
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
824
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
825
|
+
if (mayWarn) {
|
|
826
|
+
return element.props.ref;
|
|
827
|
+
}
|
|
828
|
+
return element.props.ref || element.ref;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
// packages/react/visually-hidden/src/VisuallyHidden.tsx
|
|
832
|
+
var NAME = "VisuallyHidden";
|
|
833
|
+
var VisuallyHidden = React.forwardRef(
|
|
834
|
+
(props, forwardedRef) => {
|
|
835
|
+
return /* @__PURE__ */ jsx(
|
|
836
|
+
Primitive.span,
|
|
837
|
+
{
|
|
838
|
+
...props,
|
|
839
|
+
ref: forwardedRef,
|
|
840
|
+
style: {
|
|
841
|
+
// See: https://github.com/twbs/bootstrap/blob/master/scss/mixins/_screen-reader.scss
|
|
842
|
+
position: "absolute",
|
|
843
|
+
border: 0,
|
|
844
|
+
width: 1,
|
|
845
|
+
height: 1,
|
|
846
|
+
padding: 0,
|
|
847
|
+
margin: -1,
|
|
848
|
+
overflow: "hidden",
|
|
849
|
+
clip: "rect(0, 0, 0, 0)",
|
|
850
|
+
whiteSpace: "nowrap",
|
|
851
|
+
wordWrap: "normal",
|
|
852
|
+
...props.style
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
);
|
|
856
|
+
}
|
|
857
|
+
);
|
|
858
|
+
VisuallyHidden.displayName = NAME;
|
|
859
|
+
var Root = VisuallyHidden;
|
|
860
|
+
|
|
861
|
+
var [createTooltipContext, createTooltipScope] = createContextScope$1("Tooltip", [
|
|
862
|
+
createPopperScope
|
|
863
|
+
]);
|
|
864
|
+
var usePopperScope = createPopperScope();
|
|
865
|
+
var PROVIDER_NAME = "TooltipProvider";
|
|
866
|
+
var DEFAULT_DELAY_DURATION = 700;
|
|
867
|
+
var TOOLTIP_OPEN = "tooltip.open";
|
|
868
|
+
var [TooltipProviderContextProvider, useTooltipProviderContext] = createTooltipContext(PROVIDER_NAME);
|
|
869
|
+
var TooltipProvider = (props) => {
|
|
870
|
+
const {
|
|
871
|
+
__scopeTooltip,
|
|
872
|
+
delayDuration = DEFAULT_DELAY_DURATION,
|
|
873
|
+
skipDelayDuration = 300,
|
|
874
|
+
disableHoverableContent = false,
|
|
875
|
+
children
|
|
876
|
+
} = props;
|
|
877
|
+
const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);
|
|
878
|
+
const isPointerInTransitRef = React.useRef(false);
|
|
879
|
+
const skipDelayTimerRef = React.useRef(0);
|
|
880
|
+
React.useEffect(() => {
|
|
881
|
+
const skipDelayTimer = skipDelayTimerRef.current;
|
|
882
|
+
return () => window.clearTimeout(skipDelayTimer);
|
|
883
|
+
}, []);
|
|
884
|
+
return /* @__PURE__ */ jsx(
|
|
885
|
+
TooltipProviderContextProvider,
|
|
886
|
+
{
|
|
887
|
+
scope: __scopeTooltip,
|
|
888
|
+
isOpenDelayed,
|
|
889
|
+
delayDuration,
|
|
890
|
+
onOpen: React.useCallback(() => {
|
|
891
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
892
|
+
setIsOpenDelayed(false);
|
|
893
|
+
}, []),
|
|
894
|
+
onClose: React.useCallback(() => {
|
|
895
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
896
|
+
skipDelayTimerRef.current = window.setTimeout(
|
|
897
|
+
() => setIsOpenDelayed(true),
|
|
898
|
+
skipDelayDuration
|
|
899
|
+
);
|
|
900
|
+
}, [skipDelayDuration]),
|
|
901
|
+
isPointerInTransitRef,
|
|
902
|
+
onPointerInTransitChange: React.useCallback((inTransit) => {
|
|
903
|
+
isPointerInTransitRef.current = inTransit;
|
|
904
|
+
}, []),
|
|
905
|
+
disableHoverableContent,
|
|
906
|
+
children
|
|
907
|
+
}
|
|
908
|
+
);
|
|
909
|
+
};
|
|
910
|
+
TooltipProvider.displayName = PROVIDER_NAME;
|
|
911
|
+
var TOOLTIP_NAME = "Tooltip";
|
|
912
|
+
var [TooltipContextProvider, useTooltipContext] = createTooltipContext(TOOLTIP_NAME);
|
|
913
|
+
var Tooltip$1 = (props) => {
|
|
914
|
+
const {
|
|
915
|
+
__scopeTooltip,
|
|
916
|
+
children,
|
|
917
|
+
open: openProp,
|
|
918
|
+
defaultOpen = false,
|
|
919
|
+
onOpenChange,
|
|
920
|
+
disableHoverableContent: disableHoverableContentProp,
|
|
921
|
+
delayDuration: delayDurationProp
|
|
922
|
+
} = props;
|
|
923
|
+
const providerContext = useTooltipProviderContext(TOOLTIP_NAME, props.__scopeTooltip);
|
|
924
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
925
|
+
const [trigger, setTrigger] = React.useState(null);
|
|
926
|
+
const contentId = useId();
|
|
927
|
+
const openTimerRef = React.useRef(0);
|
|
928
|
+
const disableHoverableContent = disableHoverableContentProp ?? providerContext.disableHoverableContent;
|
|
929
|
+
const delayDuration = delayDurationProp ?? providerContext.delayDuration;
|
|
930
|
+
const wasOpenDelayedRef = React.useRef(false);
|
|
931
|
+
const [open = false, setOpen] = useControllableState({
|
|
932
|
+
prop: openProp,
|
|
933
|
+
defaultProp: defaultOpen,
|
|
934
|
+
onChange: (open2) => {
|
|
935
|
+
if (open2) {
|
|
936
|
+
providerContext.onOpen();
|
|
937
|
+
document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));
|
|
938
|
+
} else {
|
|
939
|
+
providerContext.onClose();
|
|
940
|
+
}
|
|
941
|
+
onOpenChange?.(open2);
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
const stateAttribute = React.useMemo(() => {
|
|
945
|
+
return open ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
|
|
946
|
+
}, [open]);
|
|
947
|
+
const handleOpen = React.useCallback(() => {
|
|
948
|
+
window.clearTimeout(openTimerRef.current);
|
|
949
|
+
openTimerRef.current = 0;
|
|
950
|
+
wasOpenDelayedRef.current = false;
|
|
951
|
+
setOpen(true);
|
|
952
|
+
}, [setOpen]);
|
|
953
|
+
const handleClose = React.useCallback(() => {
|
|
954
|
+
window.clearTimeout(openTimerRef.current);
|
|
955
|
+
openTimerRef.current = 0;
|
|
956
|
+
setOpen(false);
|
|
957
|
+
}, [setOpen]);
|
|
958
|
+
const handleDelayedOpen = React.useCallback(() => {
|
|
959
|
+
window.clearTimeout(openTimerRef.current);
|
|
960
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
961
|
+
wasOpenDelayedRef.current = true;
|
|
962
|
+
setOpen(true);
|
|
963
|
+
openTimerRef.current = 0;
|
|
964
|
+
}, delayDuration);
|
|
965
|
+
}, [delayDuration, setOpen]);
|
|
966
|
+
React.useEffect(() => {
|
|
967
|
+
return () => {
|
|
968
|
+
if (openTimerRef.current) {
|
|
969
|
+
window.clearTimeout(openTimerRef.current);
|
|
970
|
+
openTimerRef.current = 0;
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
}, []);
|
|
974
|
+
return /* @__PURE__ */ jsx(Root2, { ...popperScope, children: /* @__PURE__ */ jsx(
|
|
975
|
+
TooltipContextProvider,
|
|
976
|
+
{
|
|
977
|
+
scope: __scopeTooltip,
|
|
978
|
+
contentId,
|
|
979
|
+
open,
|
|
980
|
+
stateAttribute,
|
|
981
|
+
trigger,
|
|
982
|
+
onTriggerChange: setTrigger,
|
|
983
|
+
onTriggerEnter: React.useCallback(() => {
|
|
984
|
+
if (providerContext.isOpenDelayed) handleDelayedOpen();
|
|
985
|
+
else handleOpen();
|
|
986
|
+
}, [providerContext.isOpenDelayed, handleDelayedOpen, handleOpen]),
|
|
987
|
+
onTriggerLeave: React.useCallback(() => {
|
|
988
|
+
if (disableHoverableContent) {
|
|
989
|
+
handleClose();
|
|
990
|
+
} else {
|
|
991
|
+
window.clearTimeout(openTimerRef.current);
|
|
992
|
+
openTimerRef.current = 0;
|
|
993
|
+
}
|
|
994
|
+
}, [handleClose, disableHoverableContent]),
|
|
995
|
+
onOpen: handleOpen,
|
|
996
|
+
onClose: handleClose,
|
|
997
|
+
disableHoverableContent,
|
|
998
|
+
children
|
|
999
|
+
}
|
|
1000
|
+
) });
|
|
1001
|
+
};
|
|
1002
|
+
Tooltip$1.displayName = TOOLTIP_NAME;
|
|
1003
|
+
var TRIGGER_NAME = "TooltipTrigger";
|
|
1004
|
+
var TooltipTrigger = React.forwardRef(
|
|
1005
|
+
(props, forwardedRef) => {
|
|
1006
|
+
const { __scopeTooltip, ...triggerProps } = props;
|
|
1007
|
+
const context = useTooltipContext(TRIGGER_NAME, __scopeTooltip);
|
|
1008
|
+
const providerContext = useTooltipProviderContext(TRIGGER_NAME, __scopeTooltip);
|
|
1009
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
1010
|
+
const ref = React.useRef(null);
|
|
1011
|
+
const composedRefs = useComposedRefs(forwardedRef, ref, context.onTriggerChange);
|
|
1012
|
+
const isPointerDownRef = React.useRef(false);
|
|
1013
|
+
const hasPointerMoveOpenedRef = React.useRef(false);
|
|
1014
|
+
const handlePointerUp = React.useCallback(() => isPointerDownRef.current = false, []);
|
|
1015
|
+
React.useEffect(() => {
|
|
1016
|
+
return () => document.removeEventListener("pointerup", handlePointerUp);
|
|
1017
|
+
}, [handlePointerUp]);
|
|
1018
|
+
return /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx(
|
|
1019
|
+
Primitive.button,
|
|
1020
|
+
{
|
|
1021
|
+
"aria-describedby": context.open ? context.contentId : void 0,
|
|
1022
|
+
"data-state": context.stateAttribute,
|
|
1023
|
+
...triggerProps,
|
|
1024
|
+
ref: composedRefs,
|
|
1025
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
|
|
1026
|
+
if (event.pointerType === "touch") return;
|
|
1027
|
+
if (!hasPointerMoveOpenedRef.current && !providerContext.isPointerInTransitRef.current) {
|
|
1028
|
+
context.onTriggerEnter();
|
|
1029
|
+
hasPointerMoveOpenedRef.current = true;
|
|
1030
|
+
}
|
|
1031
|
+
}),
|
|
1032
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, () => {
|
|
1033
|
+
context.onTriggerLeave();
|
|
1034
|
+
hasPointerMoveOpenedRef.current = false;
|
|
1035
|
+
}),
|
|
1036
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, () => {
|
|
1037
|
+
isPointerDownRef.current = true;
|
|
1038
|
+
document.addEventListener("pointerup", handlePointerUp, { once: true });
|
|
1039
|
+
}),
|
|
1040
|
+
onFocus: composeEventHandlers(props.onFocus, () => {
|
|
1041
|
+
if (!isPointerDownRef.current) context.onOpen();
|
|
1042
|
+
}),
|
|
1043
|
+
onBlur: composeEventHandlers(props.onBlur, context.onClose),
|
|
1044
|
+
onClick: composeEventHandlers(props.onClick, context.onClose)
|
|
1045
|
+
}
|
|
1046
|
+
) });
|
|
1047
|
+
}
|
|
1048
|
+
);
|
|
1049
|
+
TooltipTrigger.displayName = TRIGGER_NAME;
|
|
1050
|
+
var PORTAL_NAME = "TooltipPortal";
|
|
1051
|
+
var [PortalProvider, usePortalContext] = createTooltipContext(PORTAL_NAME, {
|
|
1052
|
+
forceMount: void 0
|
|
1053
|
+
});
|
|
1054
|
+
var TooltipPortal = (props) => {
|
|
1055
|
+
const { __scopeTooltip, forceMount, children, container } = props;
|
|
1056
|
+
const context = useTooltipContext(PORTAL_NAME, __scopeTooltip);
|
|
1057
|
+
return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeTooltip, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children }) }) });
|
|
1058
|
+
};
|
|
1059
|
+
TooltipPortal.displayName = PORTAL_NAME;
|
|
1060
|
+
var CONTENT_NAME = "TooltipContent";
|
|
1061
|
+
var TooltipContent = React.forwardRef(
|
|
1062
|
+
(props, forwardedRef) => {
|
|
1063
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);
|
|
1064
|
+
const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
|
|
1065
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
|
1066
|
+
return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.disableHoverableContent ? /* @__PURE__ */ jsx(TooltipContentImpl, { side, ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(TooltipContentHoverable, { side, ...contentProps, ref: forwardedRef }) });
|
|
1067
|
+
}
|
|
1068
|
+
);
|
|
1069
|
+
var TooltipContentHoverable = React.forwardRef((props, forwardedRef) => {
|
|
1070
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
|
1071
|
+
const providerContext = useTooltipProviderContext(CONTENT_NAME, props.__scopeTooltip);
|
|
1072
|
+
const ref = React.useRef(null);
|
|
1073
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
1074
|
+
const [pointerGraceArea, setPointerGraceArea] = React.useState(null);
|
|
1075
|
+
const { trigger, onClose } = context;
|
|
1076
|
+
const content = ref.current;
|
|
1077
|
+
const { onPointerInTransitChange } = providerContext;
|
|
1078
|
+
const handleRemoveGraceArea = React.useCallback(() => {
|
|
1079
|
+
setPointerGraceArea(null);
|
|
1080
|
+
onPointerInTransitChange(false);
|
|
1081
|
+
}, [onPointerInTransitChange]);
|
|
1082
|
+
const handleCreateGraceArea = React.useCallback(
|
|
1083
|
+
(event, hoverTarget) => {
|
|
1084
|
+
const currentTarget = event.currentTarget;
|
|
1085
|
+
const exitPoint = { x: event.clientX, y: event.clientY };
|
|
1086
|
+
const exitSide = getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
|
|
1087
|
+
const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);
|
|
1088
|
+
const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
|
|
1089
|
+
const graceArea = getHull([...paddedExitPoints, ...hoverTargetPoints]);
|
|
1090
|
+
setPointerGraceArea(graceArea);
|
|
1091
|
+
onPointerInTransitChange(true);
|
|
1092
|
+
},
|
|
1093
|
+
[onPointerInTransitChange]
|
|
1094
|
+
);
|
|
1095
|
+
React.useEffect(() => {
|
|
1096
|
+
return () => handleRemoveGraceArea();
|
|
1097
|
+
}, [handleRemoveGraceArea]);
|
|
1098
|
+
React.useEffect(() => {
|
|
1099
|
+
if (trigger && content) {
|
|
1100
|
+
const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
|
|
1101
|
+
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
|
|
1102
|
+
trigger.addEventListener("pointerleave", handleTriggerLeave);
|
|
1103
|
+
content.addEventListener("pointerleave", handleContentLeave);
|
|
1104
|
+
return () => {
|
|
1105
|
+
trigger.removeEventListener("pointerleave", handleTriggerLeave);
|
|
1106
|
+
content.removeEventListener("pointerleave", handleContentLeave);
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
}, [trigger, content, handleCreateGraceArea, handleRemoveGraceArea]);
|
|
1110
|
+
React.useEffect(() => {
|
|
1111
|
+
if (pointerGraceArea) {
|
|
1112
|
+
const handleTrackPointerGrace = (event) => {
|
|
1113
|
+
const target = event.target;
|
|
1114
|
+
const pointerPosition = { x: event.clientX, y: event.clientY };
|
|
1115
|
+
const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);
|
|
1116
|
+
const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
|
|
1117
|
+
if (hasEnteredTarget) {
|
|
1118
|
+
handleRemoveGraceArea();
|
|
1119
|
+
} else if (isPointerOutsideGraceArea) {
|
|
1120
|
+
handleRemoveGraceArea();
|
|
1121
|
+
onClose();
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
document.addEventListener("pointermove", handleTrackPointerGrace);
|
|
1125
|
+
return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
|
|
1126
|
+
}
|
|
1127
|
+
}, [trigger, content, pointerGraceArea, onClose, handleRemoveGraceArea]);
|
|
1128
|
+
return /* @__PURE__ */ jsx(TooltipContentImpl, { ...props, ref: composedRefs });
|
|
1129
|
+
});
|
|
1130
|
+
var [VisuallyHiddenContentContextProvider, useVisuallyHiddenContentContext] = createTooltipContext(TOOLTIP_NAME, { isInside: false });
|
|
1131
|
+
var TooltipContentImpl = React.forwardRef(
|
|
1132
|
+
(props, forwardedRef) => {
|
|
1133
|
+
const {
|
|
1134
|
+
__scopeTooltip,
|
|
1135
|
+
children,
|
|
1136
|
+
"aria-label": ariaLabel,
|
|
1137
|
+
onEscapeKeyDown,
|
|
1138
|
+
onPointerDownOutside,
|
|
1139
|
+
...contentProps
|
|
1140
|
+
} = props;
|
|
1141
|
+
const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);
|
|
1142
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
1143
|
+
const { onClose } = context;
|
|
1144
|
+
React.useEffect(() => {
|
|
1145
|
+
document.addEventListener(TOOLTIP_OPEN, onClose);
|
|
1146
|
+
return () => document.removeEventListener(TOOLTIP_OPEN, onClose);
|
|
1147
|
+
}, [onClose]);
|
|
1148
|
+
React.useEffect(() => {
|
|
1149
|
+
if (context.trigger) {
|
|
1150
|
+
const handleScroll = (event) => {
|
|
1151
|
+
const target = event.target;
|
|
1152
|
+
if (target?.contains(context.trigger)) onClose();
|
|
1153
|
+
};
|
|
1154
|
+
window.addEventListener("scroll", handleScroll, { capture: true });
|
|
1155
|
+
return () => window.removeEventListener("scroll", handleScroll, { capture: true });
|
|
1156
|
+
}
|
|
1157
|
+
}, [context.trigger, onClose]);
|
|
1158
|
+
return /* @__PURE__ */ jsx(
|
|
1159
|
+
DismissableLayer,
|
|
1160
|
+
{
|
|
1161
|
+
asChild: true,
|
|
1162
|
+
disableOutsidePointerEvents: false,
|
|
1163
|
+
onEscapeKeyDown,
|
|
1164
|
+
onPointerDownOutside,
|
|
1165
|
+
onFocusOutside: (event) => event.preventDefault(),
|
|
1166
|
+
onDismiss: onClose,
|
|
1167
|
+
children: /* @__PURE__ */ jsxs(
|
|
1168
|
+
Content,
|
|
1169
|
+
{
|
|
1170
|
+
"data-state": context.stateAttribute,
|
|
1171
|
+
...popperScope,
|
|
1172
|
+
...contentProps,
|
|
1173
|
+
ref: forwardedRef,
|
|
1174
|
+
style: {
|
|
1175
|
+
...contentProps.style,
|
|
1176
|
+
// re-namespace exposed content custom properties
|
|
1177
|
+
...{
|
|
1178
|
+
"--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
1179
|
+
"--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
|
|
1180
|
+
"--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
|
|
1181
|
+
"--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
|
|
1182
|
+
"--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
|
|
1183
|
+
}
|
|
1184
|
+
},
|
|
1185
|
+
children: [
|
|
1186
|
+
/* @__PURE__ */ jsx(Slottable, { children }),
|
|
1187
|
+
/* @__PURE__ */ jsx(VisuallyHiddenContentContextProvider, { scope: __scopeTooltip, isInside: true, children: /* @__PURE__ */ jsx(Root, { id: context.contentId, role: "tooltip", children: ariaLabel || children }) })
|
|
1188
|
+
]
|
|
1189
|
+
}
|
|
1190
|
+
)
|
|
1191
|
+
}
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1194
|
+
);
|
|
1195
|
+
TooltipContent.displayName = CONTENT_NAME;
|
|
1196
|
+
var ARROW_NAME = "TooltipArrow";
|
|
1197
|
+
var TooltipArrow = React.forwardRef(
|
|
1198
|
+
(props, forwardedRef) => {
|
|
1199
|
+
const { __scopeTooltip, ...arrowProps } = props;
|
|
1200
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
1201
|
+
const visuallyHiddenContentContext = useVisuallyHiddenContentContext(
|
|
1202
|
+
ARROW_NAME,
|
|
1203
|
+
__scopeTooltip
|
|
1204
|
+
);
|
|
1205
|
+
return visuallyHiddenContentContext.isInside ? null : /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
|
|
1206
|
+
}
|
|
1207
|
+
);
|
|
1208
|
+
TooltipArrow.displayName = ARROW_NAME;
|
|
1209
|
+
function getExitSideFromRect(point, rect) {
|
|
1210
|
+
const top = Math.abs(rect.top - point.y);
|
|
1211
|
+
const bottom = Math.abs(rect.bottom - point.y);
|
|
1212
|
+
const right = Math.abs(rect.right - point.x);
|
|
1213
|
+
const left = Math.abs(rect.left - point.x);
|
|
1214
|
+
switch (Math.min(top, bottom, right, left)) {
|
|
1215
|
+
case left:
|
|
1216
|
+
return "left";
|
|
1217
|
+
case right:
|
|
1218
|
+
return "right";
|
|
1219
|
+
case top:
|
|
1220
|
+
return "top";
|
|
1221
|
+
case bottom:
|
|
1222
|
+
return "bottom";
|
|
1223
|
+
default:
|
|
1224
|
+
throw new Error("unreachable");
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
function getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
|
|
1228
|
+
const paddedExitPoints = [];
|
|
1229
|
+
switch (exitSide) {
|
|
1230
|
+
case "top":
|
|
1231
|
+
paddedExitPoints.push(
|
|
1232
|
+
{ x: exitPoint.x - padding, y: exitPoint.y + padding },
|
|
1233
|
+
{ x: exitPoint.x + padding, y: exitPoint.y + padding }
|
|
1234
|
+
);
|
|
1235
|
+
break;
|
|
1236
|
+
case "bottom":
|
|
1237
|
+
paddedExitPoints.push(
|
|
1238
|
+
{ x: exitPoint.x - padding, y: exitPoint.y - padding },
|
|
1239
|
+
{ x: exitPoint.x + padding, y: exitPoint.y - padding }
|
|
1240
|
+
);
|
|
1241
|
+
break;
|
|
1242
|
+
case "left":
|
|
1243
|
+
paddedExitPoints.push(
|
|
1244
|
+
{ x: exitPoint.x + padding, y: exitPoint.y - padding },
|
|
1245
|
+
{ x: exitPoint.x + padding, y: exitPoint.y + padding }
|
|
1246
|
+
);
|
|
1247
|
+
break;
|
|
1248
|
+
case "right":
|
|
1249
|
+
paddedExitPoints.push(
|
|
1250
|
+
{ x: exitPoint.x - padding, y: exitPoint.y - padding },
|
|
1251
|
+
{ x: exitPoint.x - padding, y: exitPoint.y + padding }
|
|
1252
|
+
);
|
|
1253
|
+
break;
|
|
1254
|
+
}
|
|
1255
|
+
return paddedExitPoints;
|
|
1256
|
+
}
|
|
1257
|
+
function getPointsFromRect(rect) {
|
|
1258
|
+
const { top, right, bottom, left } = rect;
|
|
1259
|
+
return [
|
|
1260
|
+
{ x: left, y: top },
|
|
1261
|
+
{ x: right, y: top },
|
|
1262
|
+
{ x: right, y: bottom },
|
|
1263
|
+
{ x: left, y: bottom }
|
|
1264
|
+
];
|
|
1265
|
+
}
|
|
1266
|
+
function isPointInPolygon(point, polygon) {
|
|
1267
|
+
const { x, y } = point;
|
|
1268
|
+
let inside = false;
|
|
1269
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
1270
|
+
const xi = polygon[i].x;
|
|
1271
|
+
const yi = polygon[i].y;
|
|
1272
|
+
const xj = polygon[j].x;
|
|
1273
|
+
const yj = polygon[j].y;
|
|
1274
|
+
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
|
|
1275
|
+
if (intersect) inside = !inside;
|
|
1276
|
+
}
|
|
1277
|
+
return inside;
|
|
1278
|
+
}
|
|
1279
|
+
function getHull(points) {
|
|
1280
|
+
const newPoints = points.slice();
|
|
1281
|
+
newPoints.sort((a, b) => {
|
|
1282
|
+
if (a.x < b.x) return -1;
|
|
1283
|
+
else if (a.x > b.x) return 1;
|
|
1284
|
+
else if (a.y < b.y) return -1;
|
|
1285
|
+
else if (a.y > b.y) return 1;
|
|
1286
|
+
else return 0;
|
|
1287
|
+
});
|
|
1288
|
+
return getHullPresorted(newPoints);
|
|
1289
|
+
}
|
|
1290
|
+
function getHullPresorted(points) {
|
|
1291
|
+
if (points.length <= 1) return points.slice();
|
|
1292
|
+
const upperHull = [];
|
|
1293
|
+
for (let i = 0; i < points.length; i++) {
|
|
1294
|
+
const p = points[i];
|
|
1295
|
+
while (upperHull.length >= 2) {
|
|
1296
|
+
const q = upperHull[upperHull.length - 1];
|
|
1297
|
+
const r = upperHull[upperHull.length - 2];
|
|
1298
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();
|
|
1299
|
+
else break;
|
|
1300
|
+
}
|
|
1301
|
+
upperHull.push(p);
|
|
1302
|
+
}
|
|
1303
|
+
upperHull.pop();
|
|
1304
|
+
const lowerHull = [];
|
|
1305
|
+
for (let i = points.length - 1; i >= 0; i--) {
|
|
1306
|
+
const p = points[i];
|
|
1307
|
+
while (lowerHull.length >= 2) {
|
|
1308
|
+
const q = lowerHull[lowerHull.length - 1];
|
|
1309
|
+
const r = lowerHull[lowerHull.length - 2];
|
|
1310
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) lowerHull.pop();
|
|
1311
|
+
else break;
|
|
1312
|
+
}
|
|
1313
|
+
lowerHull.push(p);
|
|
1314
|
+
}
|
|
1315
|
+
lowerHull.pop();
|
|
1316
|
+
if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) {
|
|
1317
|
+
return upperHull;
|
|
1318
|
+
} else {
|
|
1319
|
+
return upperHull.concat(lowerHull);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
var Root3 = Tooltip$1;
|
|
1323
|
+
var Trigger = TooltipTrigger;
|
|
1324
|
+
var Portal = TooltipPortal;
|
|
1325
|
+
var Content2 = TooltipContent;
|
|
1326
|
+
var Arrow2 = TooltipArrow;
|
|
1327
|
+
|
|
1328
|
+
/** Use `Tooltip` to display information related to an element when the element receives keyboard focus or the mouse hovers over it */
|
|
1329
|
+
var Tooltip = function (_a) {
|
|
1330
|
+
var children = _a.children, side = _a.side, sideOffset = _a.sideOffset, align = _a.align, alignContent = _a.alignContent, title = _a.title, supportingCopy = _a.supportingCopy, icon = _a.icon, _b = _a.maxWidth, maxWidth = _b === void 0 ? "450px" : _b, _c = _a.delayDuration, delayDuration = _c === void 0 ? 300 : _c, open = _a.open, onOpenChange = _a.onOpenChange, _d = _a.asChild, asChild = _d === void 0 ? false : _d, _e = _a.zIndex, zIndex = _e === void 0 ? 100 : _e, props = __rest(_a, ["children", "side", "sideOffset", "align", "alignContent", "title", "supportingCopy", "icon", "maxWidth", "delayDuration", "open", "onOpenChange", "asChild", "zIndex"]);
|
|
1331
|
+
var _f = useThemeElement(), themeElement = _f[0], setThemeElement = _f[1];
|
|
1332
|
+
return (React__default.createElement("div", __assign({}, filterAttrs(props)),
|
|
1333
|
+
React__default.createElement(TooltipProvider, null,
|
|
1334
|
+
React__default.createElement(Root3, __assign({ delayDuration: delayDuration, open: open, onOpenChange: onOpenChange }, filterAttrs(props)),
|
|
1335
|
+
React__default.createElement(Trigger, { asChild: asChild, className: "arc-Tooltip-trigger" }, children),
|
|
1336
|
+
React__default.createElement("div", { ref: setThemeElement },
|
|
1337
|
+
React__default.createElement(Portal, { container: themeElement },
|
|
1338
|
+
React__default.createElement(Content2, __assign({ side: side, sideOffset: sideOffset, align: align, alignOffset: align === "start" ? -4 : align === "end" ? -4 : undefined, style: { zIndex: zIndex } }, props),
|
|
1339
|
+
React__default.createElement(Surface, { background: "dark-neutral-01", isTransparent: true },
|
|
1340
|
+
React__default.createElement("div", { className: "arc-Tooltip-content", style: { maxWidth: maxWidth } },
|
|
1341
|
+
React__default.createElement("div", { className: "arc-Tooltip-title", style: {
|
|
1342
|
+
display: "flex",
|
|
1343
|
+
gap: 4,
|
|
1344
|
+
alignItems: "center",
|
|
1345
|
+
justifyContent: alignContent,
|
|
1346
|
+
} },
|
|
1347
|
+
icon && (React__default.createElement("div", { style: { flexShrink: 0 } },
|
|
1348
|
+
React__default.createElement(Icon, { icon: icon, size: 24 }))),
|
|
1349
|
+
React__default.createElement(Text, { size: "s" }, title)),
|
|
1350
|
+
React__default.createElement("div", { style: {
|
|
1351
|
+
display: "flex",
|
|
1352
|
+
justifyContent: alignContent || "center",
|
|
1353
|
+
} },
|
|
1354
|
+
React__default.createElement(Text, { tone: "supporting", size: "s" }, supportingCopy)),
|
|
1355
|
+
React__default.createElement(Arrow2, { className: "arc-Tooltip-arrow" }))))))))));
|
|
1356
|
+
};
|
|
1357
|
+
|
|
1358
|
+
export { Tooltip as T };
|