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