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