@radix-ui/react-tooltip 1.0.8-rc.9 → 1.1.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +42 -30
- package/dist/index.d.ts +42 -30
- package/dist/index.js +457 -545
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +470 -555
- package/dist/index.mjs.map +7 -1
- package/package.json +13 -14
- package/dist/index.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,577 +1,492 @@
|
|
|
1
|
-
|
|
2
|
-
import {useState as $8wepK$useState, useRef as $8wepK$useRef, useEffect as $8wepK$useEffect, createElement as $8wepK$createElement, useCallback as $8wepK$useCallback, useMemo as $8wepK$useMemo, forwardRef as $8wepK$forwardRef} from "react";
|
|
3
|
-
import {composeEventHandlers as $8wepK$composeEventHandlers} from "@radix-ui/primitive";
|
|
4
|
-
import {useComposedRefs as $8wepK$useComposedRefs} from "@radix-ui/react-compose-refs";
|
|
5
|
-
import {createContextScope as $8wepK$createContextScope} from "@radix-ui/react-context";
|
|
6
|
-
import {DismissableLayer as $8wepK$DismissableLayer} from "@radix-ui/react-dismissable-layer";
|
|
7
|
-
import {useId as $8wepK$useId} from "@radix-ui/react-id";
|
|
8
|
-
import {createPopperScope as $8wepK$createPopperScope, Root as $8wepK$Root, Anchor as $8wepK$Anchor, Content as $8wepK$Content, Arrow as $8wepK$Arrow} from "@radix-ui/react-popper";
|
|
9
|
-
import {Portal as $8wepK$Portal} from "@radix-ui/react-portal";
|
|
10
|
-
import {Presence as $8wepK$Presence} from "@radix-ui/react-presence";
|
|
11
|
-
import {Primitive as $8wepK$Primitive} from "@radix-ui/react-primitive";
|
|
12
|
-
import {Slottable as $8wepK$Slottable} from "@radix-ui/react-slot";
|
|
13
|
-
import {useControllableState as $8wepK$useControllableState} from "@radix-ui/react-use-controllable-state";
|
|
14
|
-
import {Root as $8wepK$Root1} from "@radix-ui/react-visually-hidden";
|
|
1
|
+
"use client";
|
|
15
2
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
3
|
+
// packages/react/tooltip/src/Tooltip.tsx
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
6
|
+
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
7
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
8
|
+
import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
|
|
9
|
+
import { useId } from "@radix-ui/react-id";
|
|
10
|
+
import * as PopperPrimitive from "@radix-ui/react-popper";
|
|
11
|
+
import { createPopperScope } from "@radix-ui/react-popper";
|
|
12
|
+
import { Portal as PortalPrimitive } from "@radix-ui/react-portal";
|
|
13
|
+
import { Presence } from "@radix-ui/react-presence";
|
|
14
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
15
|
+
import { Slottable } from "@radix-ui/react-slot";
|
|
16
|
+
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
17
|
+
import * as VisuallyHiddenPrimitive from "@radix-ui/react-visually-hidden";
|
|
18
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
var [createTooltipContext, createTooltipScope] = createContextScope("Tooltip", [
|
|
20
|
+
createPopperScope
|
|
33
21
|
]);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
22
|
+
var usePopperScope = createPopperScope();
|
|
23
|
+
var PROVIDER_NAME = "TooltipProvider";
|
|
24
|
+
var DEFAULT_DELAY_DURATION = 700;
|
|
25
|
+
var TOOLTIP_OPEN = "tooltip.open";
|
|
26
|
+
var [TooltipProviderContextProvider, useTooltipProviderContext] = createTooltipContext(PROVIDER_NAME);
|
|
27
|
+
var TooltipProvider = (props) => {
|
|
28
|
+
const {
|
|
29
|
+
__scopeTooltip,
|
|
30
|
+
delayDuration = DEFAULT_DELAY_DURATION,
|
|
31
|
+
skipDelayDuration = 300,
|
|
32
|
+
disableHoverableContent = false,
|
|
33
|
+
children
|
|
34
|
+
} = props;
|
|
35
|
+
const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);
|
|
36
|
+
const isPointerInTransitRef = React.useRef(false);
|
|
37
|
+
const skipDelayTimerRef = React.useRef(0);
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
const skipDelayTimer = skipDelayTimerRef.current;
|
|
40
|
+
return () => window.clearTimeout(skipDelayTimer);
|
|
41
|
+
}, []);
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
TooltipProviderContextProvider,
|
|
44
|
+
{
|
|
45
|
+
scope: __scopeTooltip,
|
|
46
|
+
isOpenDelayed,
|
|
47
|
+
delayDuration,
|
|
48
|
+
onOpen: React.useCallback(() => {
|
|
49
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
50
|
+
setIsOpenDelayed(false);
|
|
51
|
+
}, []),
|
|
52
|
+
onClose: React.useCallback(() => {
|
|
53
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
54
|
+
skipDelayTimerRef.current = window.setTimeout(
|
|
55
|
+
() => setIsOpenDelayed(true),
|
|
56
|
+
skipDelayDuration
|
|
57
|
+
);
|
|
58
|
+
}, [skipDelayDuration]),
|
|
59
|
+
isPointerInTransitRef,
|
|
60
|
+
onPointerInTransitChange: React.useCallback((inTransit) => {
|
|
61
|
+
isPointerInTransitRef.current = inTransit;
|
|
62
|
+
}, []),
|
|
63
|
+
disableHoverableContent,
|
|
64
|
+
children
|
|
65
|
+
}
|
|
66
|
+
);
|
|
72
67
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
68
|
+
TooltipProvider.displayName = PROVIDER_NAME;
|
|
69
|
+
var TOOLTIP_NAME = "Tooltip";
|
|
70
|
+
var [TooltipContextProvider, useTooltipContext] = createTooltipContext(TOOLTIP_NAME);
|
|
71
|
+
var Tooltip = (props) => {
|
|
72
|
+
const {
|
|
73
|
+
__scopeTooltip,
|
|
74
|
+
children,
|
|
75
|
+
open: openProp,
|
|
76
|
+
defaultOpen = false,
|
|
77
|
+
onOpenChange,
|
|
78
|
+
disableHoverableContent: disableHoverableContentProp,
|
|
79
|
+
delayDuration: delayDurationProp
|
|
80
|
+
} = props;
|
|
81
|
+
const providerContext = useTooltipProviderContext(TOOLTIP_NAME, props.__scopeTooltip);
|
|
82
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
83
|
+
const [trigger, setTrigger] = React.useState(null);
|
|
84
|
+
const contentId = useId();
|
|
85
|
+
const openTimerRef = React.useRef(0);
|
|
86
|
+
const disableHoverableContent = disableHoverableContentProp ?? providerContext.disableHoverableContent;
|
|
87
|
+
const delayDuration = delayDurationProp ?? providerContext.delayDuration;
|
|
88
|
+
const wasOpenDelayedRef = React.useRef(false);
|
|
89
|
+
const [open = false, setOpen] = useControllableState({
|
|
90
|
+
prop: openProp,
|
|
91
|
+
defaultProp: defaultOpen,
|
|
92
|
+
onChange: (open2) => {
|
|
93
|
+
if (open2) {
|
|
94
|
+
providerContext.onOpen();
|
|
95
|
+
document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));
|
|
96
|
+
} else {
|
|
97
|
+
providerContext.onClose();
|
|
98
|
+
}
|
|
99
|
+
onOpenChange?.(open2);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const stateAttribute = React.useMemo(() => {
|
|
103
|
+
return open ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
|
|
104
|
+
}, [open]);
|
|
105
|
+
const handleOpen = React.useCallback(() => {
|
|
106
|
+
window.clearTimeout(openTimerRef.current);
|
|
107
|
+
wasOpenDelayedRef.current = false;
|
|
108
|
+
setOpen(true);
|
|
109
|
+
}, [setOpen]);
|
|
110
|
+
const handleClose = React.useCallback(() => {
|
|
111
|
+
window.clearTimeout(openTimerRef.current);
|
|
112
|
+
setOpen(false);
|
|
113
|
+
}, [setOpen]);
|
|
114
|
+
const handleDelayedOpen = React.useCallback(() => {
|
|
115
|
+
window.clearTimeout(openTimerRef.current);
|
|
116
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
117
|
+
wasOpenDelayedRef.current = true;
|
|
118
|
+
setOpen(true);
|
|
119
|
+
}, delayDuration);
|
|
120
|
+
}, [delayDuration, setOpen]);
|
|
121
|
+
React.useEffect(() => {
|
|
122
|
+
return () => window.clearTimeout(openTimerRef.current);
|
|
123
|
+
}, []);
|
|
124
|
+
return /* @__PURE__ */ jsx(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ jsx(
|
|
125
|
+
TooltipContextProvider,
|
|
126
|
+
{
|
|
127
|
+
scope: __scopeTooltip,
|
|
128
|
+
contentId,
|
|
129
|
+
open,
|
|
130
|
+
stateAttribute,
|
|
131
|
+
trigger,
|
|
132
|
+
onTriggerChange: setTrigger,
|
|
133
|
+
onTriggerEnter: React.useCallback(() => {
|
|
134
|
+
if (providerContext.isOpenDelayed) handleDelayedOpen();
|
|
135
|
+
else handleOpen();
|
|
136
|
+
}, [providerContext.isOpenDelayed, handleDelayedOpen, handleOpen]),
|
|
137
|
+
onTriggerLeave: React.useCallback(() => {
|
|
138
|
+
if (disableHoverableContent) {
|
|
139
|
+
handleClose();
|
|
140
|
+
} else {
|
|
141
|
+
window.clearTimeout(openTimerRef.current);
|
|
100
142
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
window.clearTimeout(openTimerRef.current);
|
|
109
|
-
wasOpenDelayedRef.current = false;
|
|
110
|
-
setOpen(true);
|
|
111
|
-
}, [
|
|
112
|
-
setOpen
|
|
113
|
-
]);
|
|
114
|
-
const handleClose = $8wepK$useCallback(()=>{
|
|
115
|
-
window.clearTimeout(openTimerRef.current);
|
|
116
|
-
setOpen(false);
|
|
117
|
-
}, [
|
|
118
|
-
setOpen
|
|
119
|
-
]);
|
|
120
|
-
const handleDelayedOpen = $8wepK$useCallback(()=>{
|
|
121
|
-
window.clearTimeout(openTimerRef.current);
|
|
122
|
-
openTimerRef.current = window.setTimeout(()=>{
|
|
123
|
-
wasOpenDelayedRef.current = true;
|
|
124
|
-
setOpen(true);
|
|
125
|
-
}, delayDuration);
|
|
126
|
-
}, [
|
|
127
|
-
delayDuration,
|
|
128
|
-
setOpen
|
|
129
|
-
]);
|
|
130
|
-
$8wepK$useEffect(()=>{
|
|
131
|
-
return ()=>window.clearTimeout(openTimerRef.current)
|
|
132
|
-
;
|
|
133
|
-
}, []);
|
|
134
|
-
return /*#__PURE__*/ $8wepK$createElement($8wepK$Root, popperScope, /*#__PURE__*/ $8wepK$createElement($a093c7e1ec25a057$var$TooltipContextProvider, {
|
|
135
|
-
scope: __scopeTooltip,
|
|
136
|
-
contentId: contentId,
|
|
137
|
-
open: open1,
|
|
138
|
-
stateAttribute: stateAttribute,
|
|
139
|
-
trigger: trigger,
|
|
140
|
-
onTriggerChange: setTrigger,
|
|
141
|
-
onTriggerEnter: $8wepK$useCallback(()=>{
|
|
142
|
-
if (providerContext.isOpenDelayed) handleDelayedOpen();
|
|
143
|
-
else handleOpen();
|
|
144
|
-
}, [
|
|
145
|
-
providerContext.isOpenDelayed,
|
|
146
|
-
handleDelayedOpen,
|
|
147
|
-
handleOpen
|
|
148
|
-
]),
|
|
149
|
-
onTriggerLeave: $8wepK$useCallback(()=>{
|
|
150
|
-
if (disableHoverableContent) handleClose();
|
|
151
|
-
else // Clear the timer in case the pointer leaves the trigger before the tooltip is opened.
|
|
152
|
-
window.clearTimeout(openTimerRef.current);
|
|
153
|
-
}, [
|
|
154
|
-
handleClose,
|
|
155
|
-
disableHoverableContent
|
|
156
|
-
]),
|
|
157
|
-
onOpen: handleOpen,
|
|
158
|
-
onClose: handleClose,
|
|
159
|
-
disableHoverableContent: disableHoverableContent
|
|
160
|
-
}, children));
|
|
143
|
+
}, [handleClose, disableHoverableContent]),
|
|
144
|
+
onOpen: handleOpen,
|
|
145
|
+
onClose: handleClose,
|
|
146
|
+
disableHoverableContent,
|
|
147
|
+
children
|
|
148
|
+
}
|
|
149
|
+
) });
|
|
161
150
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
const
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
]);
|
|
185
|
-
return /*#__PURE__*/ $8wepK$createElement($8wepK$Anchor, $8wepK$babelruntimehelpersesmextends({
|
|
186
|
-
asChild: true
|
|
187
|
-
}, popperScope), /*#__PURE__*/ $8wepK$createElement($8wepK$Primitive.button, $8wepK$babelruntimehelpersesmextends({
|
|
188
|
-
// We purposefully avoid adding `type=button` here because tooltip triggers are also
|
|
189
|
-
// commonly anchors and the anchor `type` attribute signifies MIME type.
|
|
190
|
-
"aria-describedby": context.open ? context.contentId : undefined,
|
|
191
|
-
"data-state": context.stateAttribute
|
|
192
|
-
}, triggerProps, {
|
|
151
|
+
Tooltip.displayName = TOOLTIP_NAME;
|
|
152
|
+
var TRIGGER_NAME = "TooltipTrigger";
|
|
153
|
+
var TooltipTrigger = React.forwardRef(
|
|
154
|
+
(props, forwardedRef) => {
|
|
155
|
+
const { __scopeTooltip, ...triggerProps } = props;
|
|
156
|
+
const context = useTooltipContext(TRIGGER_NAME, __scopeTooltip);
|
|
157
|
+
const providerContext = useTooltipProviderContext(TRIGGER_NAME, __scopeTooltip);
|
|
158
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
159
|
+
const ref = React.useRef(null);
|
|
160
|
+
const composedRefs = useComposedRefs(forwardedRef, ref, context.onTriggerChange);
|
|
161
|
+
const isPointerDownRef = React.useRef(false);
|
|
162
|
+
const hasPointerMoveOpenedRef = React.useRef(false);
|
|
163
|
+
const handlePointerUp = React.useCallback(() => isPointerDownRef.current = false, []);
|
|
164
|
+
React.useEffect(() => {
|
|
165
|
+
return () => document.removeEventListener("pointerup", handlePointerUp);
|
|
166
|
+
}, [handlePointerUp]);
|
|
167
|
+
return /* @__PURE__ */ jsx(PopperPrimitive.Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx(
|
|
168
|
+
Primitive.button,
|
|
169
|
+
{
|
|
170
|
+
"aria-describedby": context.open ? context.contentId : void 0,
|
|
171
|
+
"data-state": context.stateAttribute,
|
|
172
|
+
...triggerProps,
|
|
193
173
|
ref: composedRefs,
|
|
194
|
-
onPointerMove:
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
174
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
|
|
175
|
+
if (event.pointerType === "touch") return;
|
|
176
|
+
if (!hasPointerMoveOpenedRef.current && !providerContext.isPointerInTransitRef.current) {
|
|
177
|
+
context.onTriggerEnter();
|
|
178
|
+
hasPointerMoveOpenedRef.current = true;
|
|
179
|
+
}
|
|
200
180
|
}),
|
|
201
|
-
onPointerLeave:
|
|
202
|
-
|
|
203
|
-
|
|
181
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, () => {
|
|
182
|
+
context.onTriggerLeave();
|
|
183
|
+
hasPointerMoveOpenedRef.current = false;
|
|
204
184
|
}),
|
|
205
|
-
onPointerDown:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
once: true
|
|
209
|
-
});
|
|
185
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, () => {
|
|
186
|
+
isPointerDownRef.current = true;
|
|
187
|
+
document.addEventListener("pointerup", handlePointerUp, { once: true });
|
|
210
188
|
}),
|
|
211
|
-
onFocus:
|
|
212
|
-
|
|
189
|
+
onFocus: composeEventHandlers(props.onFocus, () => {
|
|
190
|
+
if (!isPointerDownRef.current) context.onOpen();
|
|
213
191
|
}),
|
|
214
|
-
onBlur:
|
|
215
|
-
onClick:
|
|
216
|
-
|
|
192
|
+
onBlur: composeEventHandlers(props.onBlur, context.onClose),
|
|
193
|
+
onClick: composeEventHandlers(props.onClick, context.onClose)
|
|
194
|
+
}
|
|
195
|
+
) });
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
TooltipTrigger.displayName = TRIGGER_NAME;
|
|
199
|
+
var PORTAL_NAME = "TooltipPortal";
|
|
200
|
+
var [PortalProvider, usePortalContext] = createTooltipContext(PORTAL_NAME, {
|
|
201
|
+
forceMount: void 0
|
|
217
202
|
});
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
/*
|
|
222
|
-
* TooltipPortal
|
|
223
|
-
* -----------------------------------------------------------------------------------------------*/ const $a093c7e1ec25a057$var$PORTAL_NAME = 'TooltipPortal';
|
|
224
|
-
const [$a093c7e1ec25a057$var$PortalProvider, $a093c7e1ec25a057$var$usePortalContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$PORTAL_NAME, {
|
|
225
|
-
forceMount: undefined
|
|
226
|
-
});
|
|
227
|
-
const $a093c7e1ec25a057$export$7b36b8f925ab7497 = (props)=>{
|
|
228
|
-
const { __scopeTooltip: __scopeTooltip , forceMount: forceMount , children: children , container: container } = props;
|
|
229
|
-
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$PORTAL_NAME, __scopeTooltip);
|
|
230
|
-
return /*#__PURE__*/ $8wepK$createElement($a093c7e1ec25a057$var$PortalProvider, {
|
|
231
|
-
scope: __scopeTooltip,
|
|
232
|
-
forceMount: forceMount
|
|
233
|
-
}, /*#__PURE__*/ $8wepK$createElement($8wepK$Presence, {
|
|
234
|
-
present: forceMount || context.open
|
|
235
|
-
}, /*#__PURE__*/ $8wepK$createElement($8wepK$Portal, {
|
|
236
|
-
asChild: true,
|
|
237
|
-
container: container
|
|
238
|
-
}, children)));
|
|
203
|
+
var TooltipPortal = (props) => {
|
|
204
|
+
const { __scopeTooltip, forceMount, children, container } = props;
|
|
205
|
+
const context = useTooltipContext(PORTAL_NAME, __scopeTooltip);
|
|
206
|
+
return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeTooltip, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(PortalPrimitive, { asChild: true, container, children }) }) });
|
|
239
207
|
};
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
;
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const handleTriggerLeave = (event)=>handleCreateGraceArea(event, content)
|
|
304
|
-
;
|
|
305
|
-
const handleContentLeave = (event)=>handleCreateGraceArea(event, trigger)
|
|
306
|
-
;
|
|
307
|
-
trigger.addEventListener('pointerleave', handleTriggerLeave);
|
|
308
|
-
content.addEventListener('pointerleave', handleContentLeave);
|
|
309
|
-
return ()=>{
|
|
310
|
-
trigger.removeEventListener('pointerleave', handleTriggerLeave);
|
|
311
|
-
content.removeEventListener('pointerleave', handleContentLeave);
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
}, [
|
|
315
|
-
trigger,
|
|
316
|
-
content,
|
|
317
|
-
handleCreateGraceArea,
|
|
318
|
-
handleRemoveGraceArea
|
|
319
|
-
]);
|
|
320
|
-
$8wepK$useEffect(()=>{
|
|
321
|
-
if (pointerGraceArea) {
|
|
322
|
-
const handleTrackPointerGrace = (event)=>{
|
|
323
|
-
const target = event.target;
|
|
324
|
-
const pointerPosition = {
|
|
325
|
-
x: event.clientX,
|
|
326
|
-
y: event.clientY
|
|
327
|
-
};
|
|
328
|
-
const hasEnteredTarget = (trigger === null || trigger === void 0 ? void 0 : trigger.contains(target)) || (content === null || content === void 0 ? void 0 : content.contains(target));
|
|
329
|
-
const isPointerOutsideGraceArea = !$a093c7e1ec25a057$var$isPointInPolygon(pointerPosition, pointerGraceArea);
|
|
330
|
-
if (hasEnteredTarget) handleRemoveGraceArea();
|
|
331
|
-
else if (isPointerOutsideGraceArea) {
|
|
332
|
-
handleRemoveGraceArea();
|
|
333
|
-
onClose();
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
document.addEventListener('pointermove', handleTrackPointerGrace);
|
|
337
|
-
return ()=>document.removeEventListener('pointermove', handleTrackPointerGrace)
|
|
338
|
-
;
|
|
208
|
+
TooltipPortal.displayName = PORTAL_NAME;
|
|
209
|
+
var CONTENT_NAME = "TooltipContent";
|
|
210
|
+
var TooltipContent = React.forwardRef(
|
|
211
|
+
(props, forwardedRef) => {
|
|
212
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);
|
|
213
|
+
const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
|
|
214
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
|
215
|
+
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 }) });
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
var TooltipContentHoverable = React.forwardRef((props, forwardedRef) => {
|
|
219
|
+
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
|
220
|
+
const providerContext = useTooltipProviderContext(CONTENT_NAME, props.__scopeTooltip);
|
|
221
|
+
const ref = React.useRef(null);
|
|
222
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
223
|
+
const [pointerGraceArea, setPointerGraceArea] = React.useState(null);
|
|
224
|
+
const { trigger, onClose } = context;
|
|
225
|
+
const content = ref.current;
|
|
226
|
+
const { onPointerInTransitChange } = providerContext;
|
|
227
|
+
const handleRemoveGraceArea = React.useCallback(() => {
|
|
228
|
+
setPointerGraceArea(null);
|
|
229
|
+
onPointerInTransitChange(false);
|
|
230
|
+
}, [onPointerInTransitChange]);
|
|
231
|
+
const handleCreateGraceArea = React.useCallback(
|
|
232
|
+
(event, hoverTarget) => {
|
|
233
|
+
const currentTarget = event.currentTarget;
|
|
234
|
+
const exitPoint = { x: event.clientX, y: event.clientY };
|
|
235
|
+
const exitSide = getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
|
|
236
|
+
const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);
|
|
237
|
+
const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
|
|
238
|
+
const graceArea = getHull([...paddedExitPoints, ...hoverTargetPoints]);
|
|
239
|
+
setPointerGraceArea(graceArea);
|
|
240
|
+
onPointerInTransitChange(true);
|
|
241
|
+
},
|
|
242
|
+
[onPointerInTransitChange]
|
|
243
|
+
);
|
|
244
|
+
React.useEffect(() => {
|
|
245
|
+
return () => handleRemoveGraceArea();
|
|
246
|
+
}, [handleRemoveGraceArea]);
|
|
247
|
+
React.useEffect(() => {
|
|
248
|
+
if (trigger && content) {
|
|
249
|
+
const handleTriggerLeave = (event) => handleCreateGraceArea(event, content);
|
|
250
|
+
const handleContentLeave = (event) => handleCreateGraceArea(event, trigger);
|
|
251
|
+
trigger.addEventListener("pointerleave", handleTriggerLeave);
|
|
252
|
+
content.addEventListener("pointerleave", handleContentLeave);
|
|
253
|
+
return () => {
|
|
254
|
+
trigger.removeEventListener("pointerleave", handleTriggerLeave);
|
|
255
|
+
content.removeEventListener("pointerleave", handleContentLeave);
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}, [trigger, content, handleCreateGraceArea, handleRemoveGraceArea]);
|
|
259
|
+
React.useEffect(() => {
|
|
260
|
+
if (pointerGraceArea) {
|
|
261
|
+
const handleTrackPointerGrace = (event) => {
|
|
262
|
+
const target = event.target;
|
|
263
|
+
const pointerPosition = { x: event.clientX, y: event.clientY };
|
|
264
|
+
const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);
|
|
265
|
+
const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
|
|
266
|
+
if (hasEnteredTarget) {
|
|
267
|
+
handleRemoveGraceArea();
|
|
268
|
+
} else if (isPointerOutsideGraceArea) {
|
|
269
|
+
handleRemoveGraceArea();
|
|
270
|
+
onClose();
|
|
339
271
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
]);
|
|
347
|
-
return /*#__PURE__*/ $8wepK$createElement($a093c7e1ec25a057$var$TooltipContentImpl, $8wepK$babelruntimehelpersesmextends({}, props, {
|
|
348
|
-
ref: composedRefs
|
|
349
|
-
}));
|
|
350
|
-
});
|
|
351
|
-
const [$a093c7e1ec25a057$var$VisuallyHiddenContentContextProvider, $a093c7e1ec25a057$var$useVisuallyHiddenContentContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$TOOLTIP_NAME, {
|
|
352
|
-
isInside: false
|
|
272
|
+
};
|
|
273
|
+
document.addEventListener("pointermove", handleTrackPointerGrace);
|
|
274
|
+
return () => document.removeEventListener("pointermove", handleTrackPointerGrace);
|
|
275
|
+
}
|
|
276
|
+
}, [trigger, content, pointerGraceArea, onClose, handleRemoveGraceArea]);
|
|
277
|
+
return /* @__PURE__ */ jsx(TooltipContentImpl, { ...props, ref: composedRefs });
|
|
353
278
|
});
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
279
|
+
var [VisuallyHiddenContentContextProvider, useVisuallyHiddenContentContext] = createTooltipContext(TOOLTIP_NAME, { isInside: false });
|
|
280
|
+
var TooltipContentImpl = React.forwardRef(
|
|
281
|
+
(props, forwardedRef) => {
|
|
282
|
+
const {
|
|
283
|
+
__scopeTooltip,
|
|
284
|
+
children,
|
|
285
|
+
"aria-label": ariaLabel,
|
|
286
|
+
onEscapeKeyDown,
|
|
287
|
+
onPointerDownOutside,
|
|
288
|
+
...contentProps
|
|
289
|
+
} = props;
|
|
290
|
+
const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);
|
|
291
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
292
|
+
const { onClose } = context;
|
|
293
|
+
React.useEffect(() => {
|
|
294
|
+
document.addEventListener(TOOLTIP_OPEN, onClose);
|
|
295
|
+
return () => document.removeEventListener(TOOLTIP_OPEN, onClose);
|
|
296
|
+
}, [onClose]);
|
|
297
|
+
React.useEffect(() => {
|
|
298
|
+
if (context.trigger) {
|
|
299
|
+
const handleScroll = (event) => {
|
|
300
|
+
const target = event.target;
|
|
301
|
+
if (target?.contains(context.trigger)) onClose();
|
|
302
|
+
};
|
|
303
|
+
window.addEventListener("scroll", handleScroll, { capture: true });
|
|
304
|
+
return () => window.removeEventListener("scroll", handleScroll, { capture: true });
|
|
305
|
+
}
|
|
306
|
+
}, [context.trigger, onClose]);
|
|
307
|
+
return /* @__PURE__ */ jsx(
|
|
308
|
+
DismissableLayer,
|
|
309
|
+
{
|
|
385
310
|
asChild: true,
|
|
386
311
|
disableOutsidePointerEvents: false,
|
|
387
|
-
onEscapeKeyDown
|
|
388
|
-
onPointerDownOutside
|
|
389
|
-
onFocusOutside: (event)=>event.preventDefault()
|
|
390
|
-
,
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
})
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
312
|
+
onEscapeKeyDown,
|
|
313
|
+
onPointerDownOutside,
|
|
314
|
+
onFocusOutside: (event) => event.preventDefault(),
|
|
315
|
+
onDismiss: onClose,
|
|
316
|
+
children: /* @__PURE__ */ jsxs(
|
|
317
|
+
PopperPrimitive.Content,
|
|
318
|
+
{
|
|
319
|
+
"data-state": context.stateAttribute,
|
|
320
|
+
...popperScope,
|
|
321
|
+
...contentProps,
|
|
322
|
+
ref: forwardedRef,
|
|
323
|
+
style: {
|
|
324
|
+
...contentProps.style,
|
|
325
|
+
// re-namespace exposed content custom properties
|
|
326
|
+
...{
|
|
327
|
+
"--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
328
|
+
"--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
|
|
329
|
+
"--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
|
|
330
|
+
"--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
|
|
331
|
+
"--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
children: [
|
|
335
|
+
/* @__PURE__ */ jsx(Slottable, { children }),
|
|
336
|
+
/* @__PURE__ */ jsx(VisuallyHiddenContentContextProvider, { scope: __scopeTooltip, isInside: true, children: /* @__PURE__ */ jsx(VisuallyHiddenPrimitive.Root, { id: context.contentId, role: "tooltip", children: ariaLabel || children }) })
|
|
337
|
+
]
|
|
338
|
+
}
|
|
339
|
+
)
|
|
340
|
+
}
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
);
|
|
344
|
+
TooltipContent.displayName = CONTENT_NAME;
|
|
345
|
+
var ARROW_NAME = "TooltipArrow";
|
|
346
|
+
var TooltipArrow = React.forwardRef(
|
|
347
|
+
(props, forwardedRef) => {
|
|
348
|
+
const { __scopeTooltip, ...arrowProps } = props;
|
|
349
|
+
const popperScope = usePopperScope(__scopeTooltip);
|
|
350
|
+
const visuallyHiddenContentContext = useVisuallyHiddenContentContext(
|
|
351
|
+
ARROW_NAME,
|
|
352
|
+
__scopeTooltip
|
|
353
|
+
);
|
|
354
|
+
return visuallyHiddenContentContext.isInside ? null : /* @__PURE__ */ jsx(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
TooltipArrow.displayName = ARROW_NAME;
|
|
358
|
+
function getExitSideFromRect(point, rect) {
|
|
359
|
+
const top = Math.abs(rect.top - point.y);
|
|
360
|
+
const bottom = Math.abs(rect.bottom - point.y);
|
|
361
|
+
const right = Math.abs(rect.right - point.x);
|
|
362
|
+
const left = Math.abs(rect.left - point.x);
|
|
363
|
+
switch (Math.min(top, bottom, right, left)) {
|
|
364
|
+
case left:
|
|
365
|
+
return "left";
|
|
366
|
+
case right:
|
|
367
|
+
return "right";
|
|
368
|
+
case top:
|
|
369
|
+
return "top";
|
|
370
|
+
case bottom:
|
|
371
|
+
return "bottom";
|
|
372
|
+
default:
|
|
373
|
+
throw new Error("unreachable");
|
|
374
|
+
}
|
|
447
375
|
}
|
|
448
|
-
function
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
break;
|
|
478
|
-
case 'right':
|
|
479
|
-
paddedExitPoints.push({
|
|
480
|
-
x: exitPoint.x - padding,
|
|
481
|
-
y: exitPoint.y - padding
|
|
482
|
-
}, {
|
|
483
|
-
x: exitPoint.x - padding,
|
|
484
|
-
y: exitPoint.y + padding
|
|
485
|
-
});
|
|
486
|
-
break;
|
|
487
|
-
}
|
|
488
|
-
return paddedExitPoints;
|
|
376
|
+
function getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
|
|
377
|
+
const paddedExitPoints = [];
|
|
378
|
+
switch (exitSide) {
|
|
379
|
+
case "top":
|
|
380
|
+
paddedExitPoints.push(
|
|
381
|
+
{ x: exitPoint.x - padding, y: exitPoint.y + padding },
|
|
382
|
+
{ x: exitPoint.x + padding, y: exitPoint.y + padding }
|
|
383
|
+
);
|
|
384
|
+
break;
|
|
385
|
+
case "bottom":
|
|
386
|
+
paddedExitPoints.push(
|
|
387
|
+
{ x: exitPoint.x - padding, y: exitPoint.y - padding },
|
|
388
|
+
{ x: exitPoint.x + padding, y: exitPoint.y - padding }
|
|
389
|
+
);
|
|
390
|
+
break;
|
|
391
|
+
case "left":
|
|
392
|
+
paddedExitPoints.push(
|
|
393
|
+
{ x: exitPoint.x + padding, y: exitPoint.y - padding },
|
|
394
|
+
{ x: exitPoint.x + padding, y: exitPoint.y + padding }
|
|
395
|
+
);
|
|
396
|
+
break;
|
|
397
|
+
case "right":
|
|
398
|
+
paddedExitPoints.push(
|
|
399
|
+
{ x: exitPoint.x - padding, y: exitPoint.y - padding },
|
|
400
|
+
{ x: exitPoint.x - padding, y: exitPoint.y + padding }
|
|
401
|
+
);
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
return paddedExitPoints;
|
|
489
405
|
}
|
|
490
|
-
function
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
function
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
else return 0;
|
|
534
|
-
});
|
|
535
|
-
return $a093c7e1ec25a057$var$getHullPresorted(newPoints);
|
|
536
|
-
} // Returns the convex hull, assuming that each points[i] <= points[i + 1]. Runs in O(n) time.
|
|
537
|
-
function $a093c7e1ec25a057$var$getHullPresorted(points) {
|
|
538
|
-
if (points.length <= 1) return points.slice();
|
|
539
|
-
const upperHull = [];
|
|
540
|
-
for(let i = 0; i < points.length; i++){
|
|
541
|
-
const p = points[i];
|
|
542
|
-
while(upperHull.length >= 2){
|
|
543
|
-
const q = upperHull[upperHull.length - 1];
|
|
544
|
-
const r = upperHull[upperHull.length - 2];
|
|
545
|
-
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();
|
|
546
|
-
else break;
|
|
547
|
-
}
|
|
548
|
-
upperHull.push(p);
|
|
406
|
+
function getPointsFromRect(rect) {
|
|
407
|
+
const { top, right, bottom, left } = rect;
|
|
408
|
+
return [
|
|
409
|
+
{ x: left, y: top },
|
|
410
|
+
{ x: right, y: top },
|
|
411
|
+
{ x: right, y: bottom },
|
|
412
|
+
{ x: left, y: bottom }
|
|
413
|
+
];
|
|
414
|
+
}
|
|
415
|
+
function isPointInPolygon(point, polygon) {
|
|
416
|
+
const { x, y } = point;
|
|
417
|
+
let inside = false;
|
|
418
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
419
|
+
const xi = polygon[i].x;
|
|
420
|
+
const yi = polygon[i].y;
|
|
421
|
+
const xj = polygon[j].x;
|
|
422
|
+
const yj = polygon[j].y;
|
|
423
|
+
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
|
|
424
|
+
if (intersect) inside = !inside;
|
|
425
|
+
}
|
|
426
|
+
return inside;
|
|
427
|
+
}
|
|
428
|
+
function getHull(points) {
|
|
429
|
+
const newPoints = points.slice();
|
|
430
|
+
newPoints.sort((a, b) => {
|
|
431
|
+
if (a.x < b.x) return -1;
|
|
432
|
+
else if (a.x > b.x) return 1;
|
|
433
|
+
else if (a.y < b.y) return -1;
|
|
434
|
+
else if (a.y > b.y) return 1;
|
|
435
|
+
else return 0;
|
|
436
|
+
});
|
|
437
|
+
return getHullPresorted(newPoints);
|
|
438
|
+
}
|
|
439
|
+
function getHullPresorted(points) {
|
|
440
|
+
if (points.length <= 1) return points.slice();
|
|
441
|
+
const upperHull = [];
|
|
442
|
+
for (let i = 0; i < points.length; i++) {
|
|
443
|
+
const p = points[i];
|
|
444
|
+
while (upperHull.length >= 2) {
|
|
445
|
+
const q = upperHull[upperHull.length - 1];
|
|
446
|
+
const r = upperHull[upperHull.length - 2];
|
|
447
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();
|
|
448
|
+
else break;
|
|
549
449
|
}
|
|
550
|
-
upperHull.
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
450
|
+
upperHull.push(p);
|
|
451
|
+
}
|
|
452
|
+
upperHull.pop();
|
|
453
|
+
const lowerHull = [];
|
|
454
|
+
for (let i = points.length - 1; i >= 0; i--) {
|
|
455
|
+
const p = points[i];
|
|
456
|
+
while (lowerHull.length >= 2) {
|
|
457
|
+
const q = lowerHull[lowerHull.length - 1];
|
|
458
|
+
const r = lowerHull[lowerHull.length - 2];
|
|
459
|
+
if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) lowerHull.pop();
|
|
460
|
+
else break;
|
|
561
461
|
}
|
|
562
|
-
lowerHull.
|
|
563
|
-
|
|
564
|
-
|
|
462
|
+
lowerHull.push(p);
|
|
463
|
+
}
|
|
464
|
+
lowerHull.pop();
|
|
465
|
+
if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) {
|
|
466
|
+
return upperHull;
|
|
467
|
+
} else {
|
|
468
|
+
return upperHull.concat(lowerHull);
|
|
469
|
+
}
|
|
565
470
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
471
|
+
var Provider = TooltipProvider;
|
|
472
|
+
var Root3 = Tooltip;
|
|
473
|
+
var Trigger = TooltipTrigger;
|
|
474
|
+
var Portal = TooltipPortal;
|
|
475
|
+
var Content2 = TooltipContent;
|
|
476
|
+
var Arrow2 = TooltipArrow;
|
|
477
|
+
export {
|
|
478
|
+
Arrow2 as Arrow,
|
|
479
|
+
Content2 as Content,
|
|
480
|
+
Portal,
|
|
481
|
+
Provider,
|
|
482
|
+
Root3 as Root,
|
|
483
|
+
Tooltip,
|
|
484
|
+
TooltipArrow,
|
|
485
|
+
TooltipContent,
|
|
486
|
+
TooltipPortal,
|
|
487
|
+
TooltipProvider,
|
|
488
|
+
TooltipTrigger,
|
|
489
|
+
Trigger,
|
|
490
|
+
createTooltipScope
|
|
491
|
+
};
|
|
577
492
|
//# sourceMappingURL=index.mjs.map
|