@radix-ui/react-tooltip 1.1.0-rc.2 → 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 +494 -478
- package/dist/index.js.map +4 -4
- package/package.json +13 -13
package/dist/index.js
CHANGED
|
@@ -1,508 +1,524 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
mod
|
|
31
|
-
));
|
|
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);
|
|
32
30
|
|
|
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
|
-
|
|
62
|
-
|
|
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,
|
|
63
111
|
children
|
|
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
|
-
|
|
94
|
-
|
|
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();
|
|
95
145
|
}
|
|
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
|
-
|
|
125
|
-
|
|
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();
|
|
126
187
|
} else {
|
|
127
|
-
|
|
188
|
+
window.clearTimeout(openTimerRef.current);
|
|
128
189
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}, [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, []);
|
|
151
211
|
React.useEffect(() => {
|
|
152
|
-
return () =>
|
|
153
|
-
}, []);
|
|
154
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.
|
|
155
|
-
|
|
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,
|
|
156
216
|
{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}, [providerContext.isOpenDelayed, handleDelayedOpen, handleOpen]),
|
|
167
|
-
onTriggerLeave: React.useCallback(() => {
|
|
168
|
-
if (disableHoverableContent) {
|
|
169
|
-
handleClose();
|
|
170
|
-
} else {
|
|
171
|
-
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;
|
|
172
226
|
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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)
|
|
178
241
|
}
|
|
179
242
|
) });
|
|
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
|
-
|
|
226
|
-
|
|
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]
|
|
227
290
|
);
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
(props, forwardedRef) => {
|
|
242
|
-
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);
|
|
243
|
-
const { forceMount = portalContext.forceMount, side = "top", ...contentProps } = props;
|
|
244
|
-
const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);
|
|
245
|
-
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
|
+
};
|
|
246
304
|
}
|
|
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
|
-
|
|
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;
|
|
277
340
|
React.useEffect(() => {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
trigger.addEventListener("pointerleave", handleTriggerLeave);
|
|
282
|
-
content.addEventListener("pointerleave", handleContentLeave);
|
|
283
|
-
return () => {
|
|
284
|
-
trigger.removeEventListener("pointerleave", handleTriggerLeave);
|
|
285
|
-
content.removeEventListener("pointerleave", handleContentLeave);
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
}, [trigger, content, handleCreateGraceArea, handleRemoveGraceArea]);
|
|
341
|
+
document.addEventListener(TOOLTIP_OPEN, onClose);
|
|
342
|
+
return () => document.removeEventListener(TOOLTIP_OPEN, onClose);
|
|
343
|
+
}, [onClose]);
|
|
289
344
|
React.useEffect(() => {
|
|
290
|
-
if (
|
|
291
|
-
const
|
|
345
|
+
if (context.trigger) {
|
|
346
|
+
const handleScroll = (event) => {
|
|
292
347
|
const target = event.target;
|
|
293
|
-
|
|
294
|
-
const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);
|
|
295
|
-
const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
|
|
296
|
-
if (hasEnteredTarget) {
|
|
297
|
-
handleRemoveGraceArea();
|
|
298
|
-
} else if (isPointerOutsideGraceArea) {
|
|
299
|
-
handleRemoveGraceArea();
|
|
300
|
-
onClose();
|
|
301
|
-
}
|
|
348
|
+
if (target?.contains(context.trigger)) onClose();
|
|
302
349
|
};
|
|
303
|
-
|
|
304
|
-
return () =>
|
|
350
|
+
window.addEventListener("scroll", handleScroll, { capture: true });
|
|
351
|
+
return () => window.removeEventListener("scroll", handleScroll, { capture: true });
|
|
305
352
|
}
|
|
306
|
-
}, [trigger,
|
|
307
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const {
|
|
313
|
-
__scopeTooltip,
|
|
314
|
-
children,
|
|
315
|
-
"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,
|
|
316
359
|
onEscapeKeyDown,
|
|
317
360
|
onPointerDownOutside,
|
|
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
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
347
|
-
PopperPrimitive.Content,
|
|
348
|
-
{
|
|
349
|
-
"data-state": context.stateAttribute,
|
|
350
|
-
...popperScope,
|
|
351
|
-
...contentProps,
|
|
352
|
-
ref: forwardedRef,
|
|
353
|
-
style: {
|
|
354
|
-
...contentProps.style,
|
|
355
|
-
// re-namespace exposed content custom properties
|
|
356
|
-
...{
|
|
357
|
-
"--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
358
|
-
"--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
|
|
359
|
-
"--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
|
|
360
|
-
"--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
|
|
361
|
-
"--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
children: [
|
|
365
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_slot.Slottable, { children }),
|
|
366
|
-
/* @__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 }) })
|
|
367
|
-
]
|
|
368
|
-
}
|
|
369
|
-
)
|
|
370
|
-
}
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
);
|
|
374
|
-
TooltipContent.displayName = CONTENT_NAME;
|
|
375
|
-
var ARROW_NAME = "TooltipArrow";
|
|
376
|
-
var TooltipArrow = React.forwardRef(
|
|
377
|
-
(props, forwardedRef) => {
|
|
378
|
-
const { __scopeTooltip, ...arrowProps } = props;
|
|
379
|
-
const popperScope = usePopperScope(__scopeTooltip);
|
|
380
|
-
const visuallyHiddenContentContext = useVisuallyHiddenContentContext(
|
|
381
|
-
ARROW_NAME,
|
|
382
|
-
__scopeTooltip
|
|
383
|
-
);
|
|
384
|
-
return visuallyHiddenContentContext.isInside ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
|
|
385
|
-
}
|
|
386
|
-
);
|
|
387
|
-
TooltipArrow.displayName = ARROW_NAME;
|
|
388
|
-
function getExitSideFromRect(point, rect) {
|
|
389
|
-
const top = Math.abs(rect.top - point.y);
|
|
390
|
-
const bottom = Math.abs(rect.bottom - point.y);
|
|
391
|
-
const right = Math.abs(rect.right - point.x);
|
|
392
|
-
const left = Math.abs(rect.left - point.x);
|
|
393
|
-
switch (Math.min(top, bottom, right, left)) {
|
|
394
|
-
case left:
|
|
395
|
-
return "left";
|
|
396
|
-
case right:
|
|
397
|
-
return "right";
|
|
398
|
-
case top:
|
|
399
|
-
return "top";
|
|
400
|
-
case bottom:
|
|
401
|
-
return "bottom";
|
|
402
|
-
default:
|
|
403
|
-
throw new Error("unreachable");
|
|
404
|
-
}
|
|
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
|
+
);
|
|
405
389
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
{ x: exitPoint.x + padding, y: exitPoint.y - padding }
|
|
419
|
-
);
|
|
420
|
-
break;
|
|
421
|
-
case "left":
|
|
422
|
-
paddedExitPoints.push(
|
|
423
|
-
{ x: exitPoint.x + padding, y: exitPoint.y - padding },
|
|
424
|
-
{ x: exitPoint.x + padding, y: exitPoint.y + padding }
|
|
425
|
-
);
|
|
426
|
-
break;
|
|
427
|
-
case "right":
|
|
428
|
-
paddedExitPoints.push(
|
|
429
|
-
{ x: exitPoint.x - padding, y: exitPoint.y - padding },
|
|
430
|
-
{ x: exitPoint.x - padding, y: exitPoint.y + padding }
|
|
431
|
-
);
|
|
432
|
-
break;
|
|
433
|
-
}
|
|
434
|
-
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 });
|
|
435
402
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
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");
|
|
444
421
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
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;
|
|
457
450
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
467
|
-
|
|
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;
|
|
468
472
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
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;
|
|
493
496
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
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;
|
|
499
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);
|
|
500
516
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
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;
|
|
508
524
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/Tooltip.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { DismissableLayer } from '@radix-ui/react-dismissable-layer';\nimport { useId } from '@radix-ui/react-id';\nimport * as PopperPrimitive from '@radix-ui/react-popper';\nimport { createPopperScope } from '@radix-ui/react-popper';\nimport { Portal as PortalPrimitive } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slottable } from '@radix-ui/react-slot';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as VisuallyHiddenPrimitive from '@radix-ui/react-visually-hidden';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\ntype ScopedProps<P = {}> = P & { __scopeTooltip?: Scope };\nconst [createTooltipContext, createTooltipScope] = createContextScope('Tooltip', [\n createPopperScope,\n]);\nconst usePopperScope = createPopperScope();\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROVIDER_NAME = 'TooltipProvider';\nconst DEFAULT_DELAY_DURATION = 700;\nconst TOOLTIP_OPEN = 'tooltip.open';\n\ntype TooltipProviderContextValue = {\n isOpenDelayed: boolean;\n delayDuration: number;\n onOpen(): void;\n onClose(): void;\n onPointerInTransitChange(inTransit: boolean): void;\n isPointerInTransitRef: React.MutableRefObject<boolean>;\n disableHoverableContent: boolean;\n};\n\nconst [TooltipProviderContextProvider, useTooltipProviderContext] =\n createTooltipContext<TooltipProviderContextValue>(PROVIDER_NAME);\n\ninterface TooltipProviderProps {\n children: React.ReactNode;\n /**\n * The duration from when the pointer enters the trigger until the tooltip gets opened.\n * @defaultValue 700\n */\n delayDuration?: number;\n /**\n * How much time a user has to enter another trigger without incurring a delay again.\n * @defaultValue 300\n */\n skipDelayDuration?: number;\n /**\n * When `true`, trying to hover the content will result in the tooltip closing as the pointer leaves the trigger.\n * @defaultValue false\n */\n disableHoverableContent?: boolean;\n}\n\nconst TooltipProvider: React.FC<TooltipProviderProps> = (\n props: ScopedProps<TooltipProviderProps>\n) => {\n const {\n __scopeTooltip,\n delayDuration = DEFAULT_DELAY_DURATION,\n skipDelayDuration = 300,\n disableHoverableContent = false,\n children,\n } = props;\n const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);\n const isPointerInTransitRef = React.useRef(false);\n const skipDelayTimerRef = React.useRef(0);\n\n React.useEffect(() => {\n const skipDelayTimer = skipDelayTimerRef.current;\n return () => window.clearTimeout(skipDelayTimer);\n }, []);\n\n return (\n <TooltipProviderContextProvider\n scope={__scopeTooltip}\n isOpenDelayed={isOpenDelayed}\n delayDuration={delayDuration}\n onOpen={React.useCallback(() => {\n window.clearTimeout(skipDelayTimerRef.current);\n setIsOpenDelayed(false);\n }, [])}\n onClose={React.useCallback(() => {\n window.clearTimeout(skipDelayTimerRef.current);\n skipDelayTimerRef.current = window.setTimeout(\n () => setIsOpenDelayed(true),\n skipDelayDuration\n );\n }, [skipDelayDuration])}\n isPointerInTransitRef={isPointerInTransitRef}\n onPointerInTransitChange={React.useCallback((inTransit: boolean) => {\n isPointerInTransitRef.current = inTransit;\n }, [])}\n disableHoverableContent={disableHoverableContent}\n >\n {children}\n </TooltipProviderContextProvider>\n );\n};\n\nTooltipProvider.displayName = PROVIDER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * Tooltip\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOOLTIP_NAME = 'Tooltip';\n\ntype TooltipContextValue = {\n contentId: string;\n open: boolean;\n stateAttribute: 'closed' | 'delayed-open' | 'instant-open';\n trigger: TooltipTriggerElement | null;\n onTriggerChange(trigger: TooltipTriggerElement | null): void;\n onTriggerEnter(): void;\n onTriggerLeave(): void;\n onOpen(): void;\n onClose(): void;\n disableHoverableContent: boolean;\n};\n\nconst [TooltipContextProvider, useTooltipContext] =\n createTooltipContext<TooltipContextValue>(TOOLTIP_NAME);\n\ninterface TooltipProps {\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * The duration from when the pointer enters the trigger until the tooltip gets opened. This will\n * override the prop with the same name passed to Provider.\n * @defaultValue 700\n */\n delayDuration?: number;\n /**\n * When `true`, trying to hover the content will result in the tooltip closing as the pointer leaves the trigger.\n * @defaultValue false\n */\n disableHoverableContent?: boolean;\n}\n\nconst Tooltip: React.FC<TooltipProps> = (props: ScopedProps<TooltipProps>) => {\n const {\n __scopeTooltip,\n children,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n disableHoverableContent: disableHoverableContentProp,\n delayDuration: delayDurationProp,\n } = props;\n const providerContext = useTooltipProviderContext(TOOLTIP_NAME, props.__scopeTooltip);\n const popperScope = usePopperScope(__scopeTooltip);\n const [trigger, setTrigger] = React.useState<HTMLButtonElement | null>(null);\n const contentId = useId();\n const openTimerRef = React.useRef(0);\n const disableHoverableContent =\n disableHoverableContentProp ?? providerContext.disableHoverableContent;\n const delayDuration = delayDurationProp ?? providerContext.delayDuration;\n const wasOpenDelayedRef = React.useRef(false);\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: (open) => {\n if (open) {\n providerContext.onOpen();\n\n // as `onChange` is called within a lifecycle method we\n // avoid dispatching via `dispatchDiscreteCustomEvent`.\n document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));\n } else {\n providerContext.onClose();\n }\n onOpenChange?.(open);\n },\n });\n const stateAttribute = React.useMemo(() => {\n return open ? (wasOpenDelayedRef.current ? 'delayed-open' : 'instant-open') : 'closed';\n }, [open]);\n\n const handleOpen = React.useCallback(() => {\n window.clearTimeout(openTimerRef.current);\n wasOpenDelayedRef.current = false;\n setOpen(true);\n }, [setOpen]);\n\n const handleClose = React.useCallback(() => {\n window.clearTimeout(openTimerRef.current);\n setOpen(false);\n }, [setOpen]);\n\n const handleDelayedOpen = React.useCallback(() => {\n window.clearTimeout(openTimerRef.current);\n openTimerRef.current = window.setTimeout(() => {\n wasOpenDelayedRef.current = true;\n setOpen(true);\n }, delayDuration);\n }, [delayDuration, setOpen]);\n\n React.useEffect(() => {\n return () => window.clearTimeout(openTimerRef.current);\n }, []);\n\n return (\n <PopperPrimitive.Root {...popperScope}>\n <TooltipContextProvider\n scope={__scopeTooltip}\n contentId={contentId}\n open={open}\n stateAttribute={stateAttribute}\n trigger={trigger}\n onTriggerChange={setTrigger}\n onTriggerEnter={React.useCallback(() => {\n if (providerContext.isOpenDelayed) handleDelayedOpen();\n else handleOpen();\n }, [providerContext.isOpenDelayed, handleDelayedOpen, handleOpen])}\n onTriggerLeave={React.useCallback(() => {\n if (disableHoverableContent) {\n handleClose();\n } else {\n // Clear the timer in case the pointer leaves the trigger before the tooltip is opened.\n window.clearTimeout(openTimerRef.current);\n }\n }, [handleClose, disableHoverableContent])}\n onOpen={handleOpen}\n onClose={handleClose}\n disableHoverableContent={disableHoverableContent}\n >\n {children}\n </TooltipContextProvider>\n </PopperPrimitive.Root>\n );\n};\n\nTooltip.displayName = TOOLTIP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TooltipTrigger';\n\ntype TooltipTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface TooltipTriggerProps extends PrimitiveButtonProps {}\n\nconst TooltipTrigger = React.forwardRef<TooltipTriggerElement, TooltipTriggerProps>(\n (props: ScopedProps<TooltipTriggerProps>, forwardedRef) => {\n const { __scopeTooltip, ...triggerProps } = props;\n const context = useTooltipContext(TRIGGER_NAME, __scopeTooltip);\n const providerContext = useTooltipProviderContext(TRIGGER_NAME, __scopeTooltip);\n const popperScope = usePopperScope(__scopeTooltip);\n const ref = React.useRef<TooltipTriggerElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref, context.onTriggerChange);\n const isPointerDownRef = React.useRef(false);\n const hasPointerMoveOpenedRef = React.useRef(false);\n const handlePointerUp = React.useCallback(() => (isPointerDownRef.current = false), []);\n\n React.useEffect(() => {\n return () => document.removeEventListener('pointerup', handlePointerUp);\n }, [handlePointerUp]);\n\n return (\n <PopperPrimitive.Anchor asChild {...popperScope}>\n <Primitive.button\n // We purposefully avoid adding `type=button` here because tooltip triggers are also\n // commonly anchors and the anchor `type` attribute signifies MIME type.\n aria-describedby={context.open ? context.contentId : undefined}\n data-state={context.stateAttribute}\n {...triggerProps}\n ref={composedRefs}\n onPointerMove={composeEventHandlers(props.onPointerMove, (event) => {\n if (event.pointerType === 'touch') return;\n if (\n !hasPointerMoveOpenedRef.current &&\n !providerContext.isPointerInTransitRef.current\n ) {\n context.onTriggerEnter();\n hasPointerMoveOpenedRef.current = true;\n }\n })}\n onPointerLeave={composeEventHandlers(props.onPointerLeave, () => {\n context.onTriggerLeave();\n hasPointerMoveOpenedRef.current = false;\n })}\n onPointerDown={composeEventHandlers(props.onPointerDown, () => {\n isPointerDownRef.current = true;\n document.addEventListener('pointerup', handlePointerUp, { once: true });\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\n if (!isPointerDownRef.current) context.onOpen();\n })}\n onBlur={composeEventHandlers(props.onBlur, context.onClose)}\n onClick={composeEventHandlers(props.onClick, context.onClose)}\n />\n </PopperPrimitive.Anchor>\n );\n }\n);\n\nTooltipTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'TooltipPortal';\n\ntype PortalContextValue = { forceMount?: true };\nconst [PortalProvider, usePortalContext] = createTooltipContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n});\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface TooltipPortalProps {\n children?: React.ReactNode;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps['container'];\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst TooltipPortal: React.FC<TooltipPortalProps> = (props: ScopedProps<TooltipPortalProps>) => {\n const { __scopeTooltip, forceMount, children, container } = props;\n const context = useTooltipContext(PORTAL_NAME, __scopeTooltip);\n return (\n <PortalProvider scope={__scopeTooltip} forceMount={forceMount}>\n <Presence present={forceMount || context.open}>\n <PortalPrimitive asChild container={container}>\n {children}\n </PortalPrimitive>\n </Presence>\n </PortalProvider>\n );\n};\n\nTooltipPortal.displayName = PORTAL_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TooltipContent';\n\ntype TooltipContentElement = TooltipContentImplElement;\ninterface TooltipContentProps extends TooltipContentImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst TooltipContent = React.forwardRef<TooltipContentElement, TooltipContentProps>(\n (props: ScopedProps<TooltipContentProps>, forwardedRef) => {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);\n const { forceMount = portalContext.forceMount, side = 'top', ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);\n\n return (\n <Presence present={forceMount || context.open}>\n {context.disableHoverableContent ? (\n <TooltipContentImpl side={side} {...contentProps} ref={forwardedRef} />\n ) : (\n <TooltipContentHoverable side={side} {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n }\n);\n\ntype Point = { x: number; y: number };\ntype Polygon = Point[];\n\ntype TooltipContentHoverableElement = TooltipContentImplElement;\ninterface TooltipContentHoverableProps extends TooltipContentImplProps {}\n\nconst TooltipContentHoverable = React.forwardRef<\n TooltipContentHoverableElement,\n TooltipContentHoverableProps\n>((props: ScopedProps<TooltipContentHoverableProps>, forwardedRef) => {\n const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);\n const providerContext = useTooltipProviderContext(CONTENT_NAME, props.__scopeTooltip);\n const ref = React.useRef<TooltipContentHoverableElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const [pointerGraceArea, setPointerGraceArea] = React.useState<Polygon | null>(null);\n\n const { trigger, onClose } = context;\n const content = ref.current;\n\n const { onPointerInTransitChange } = providerContext;\n\n const handleRemoveGraceArea = React.useCallback(() => {\n setPointerGraceArea(null);\n onPointerInTransitChange(false);\n }, [onPointerInTransitChange]);\n\n const handleCreateGraceArea = React.useCallback(\n (event: PointerEvent, hoverTarget: HTMLElement) => {\n const currentTarget = event.currentTarget as HTMLElement;\n const exitPoint = { x: event.clientX, y: event.clientY };\n const exitSide = getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());\n const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);\n const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());\n const graceArea = getHull([...paddedExitPoints, ...hoverTargetPoints]);\n setPointerGraceArea(graceArea);\n onPointerInTransitChange(true);\n },\n [onPointerInTransitChange]\n );\n\n React.useEffect(() => {\n return () => handleRemoveGraceArea();\n }, [handleRemoveGraceArea]);\n\n React.useEffect(() => {\n if (trigger && content) {\n const handleTriggerLeave = (event: PointerEvent) => handleCreateGraceArea(event, content);\n const handleContentLeave = (event: PointerEvent) => handleCreateGraceArea(event, trigger);\n\n trigger.addEventListener('pointerleave', handleTriggerLeave);\n content.addEventListener('pointerleave', handleContentLeave);\n return () => {\n trigger.removeEventListener('pointerleave', handleTriggerLeave);\n content.removeEventListener('pointerleave', handleContentLeave);\n };\n }\n }, [trigger, content, handleCreateGraceArea, handleRemoveGraceArea]);\n\n React.useEffect(() => {\n if (pointerGraceArea) {\n const handleTrackPointerGrace = (event: PointerEvent) => {\n const target = event.target as HTMLElement;\n const pointerPosition = { x: event.clientX, y: event.clientY };\n const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);\n const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);\n\n if (hasEnteredTarget) {\n handleRemoveGraceArea();\n } else if (isPointerOutsideGraceArea) {\n handleRemoveGraceArea();\n onClose();\n }\n };\n document.addEventListener('pointermove', handleTrackPointerGrace);\n return () => document.removeEventListener('pointermove', handleTrackPointerGrace);\n }\n }, [trigger, content, pointerGraceArea, onClose, handleRemoveGraceArea]);\n\n return <TooltipContentImpl {...props} ref={composedRefs} />;\n});\n\nconst [VisuallyHiddenContentContextProvider, useVisuallyHiddenContentContext] =\n createTooltipContext(TOOLTIP_NAME, { isInside: false });\n\ntype TooltipContentImplElement = React.ElementRef<typeof PopperPrimitive.Content>;\ntype DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype PopperContentProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;\ninterface TooltipContentImplProps extends Omit<PopperContentProps, 'onPlaced'> {\n /**\n * A more descriptive label for accessibility purpose\n */\n 'aria-label'?: string;\n\n /**\n * Event handler called when the escape key is down.\n * Can be prevented.\n */\n onEscapeKeyDown?: DismissableLayerProps['onEscapeKeyDown'];\n /**\n * Event handler called when the a `pointerdown` event happens outside of the `Tooltip`.\n * Can be prevented.\n */\n onPointerDownOutside?: DismissableLayerProps['onPointerDownOutside'];\n}\n\nconst TooltipContentImpl = React.forwardRef<TooltipContentImplElement, TooltipContentImplProps>(\n (props: ScopedProps<TooltipContentImplProps>, forwardedRef) => {\n const {\n __scopeTooltip,\n children,\n 'aria-label': ariaLabel,\n onEscapeKeyDown,\n onPointerDownOutside,\n ...contentProps\n } = props;\n const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);\n const popperScope = usePopperScope(__scopeTooltip);\n const { onClose } = context;\n\n // Close this tooltip if another one opens\n React.useEffect(() => {\n document.addEventListener(TOOLTIP_OPEN, onClose);\n return () => document.removeEventListener(TOOLTIP_OPEN, onClose);\n }, [onClose]);\n\n // Close the tooltip if the trigger is scrolled\n React.useEffect(() => {\n if (context.trigger) {\n const handleScroll = (event: Event) => {\n const target = event.target as HTMLElement;\n if (target?.contains(context.trigger)) onClose();\n };\n window.addEventListener('scroll', handleScroll, { capture: true });\n return () => window.removeEventListener('scroll', handleScroll, { capture: true });\n }\n }, [context.trigger, onClose]);\n\n return (\n <DismissableLayer\n asChild\n disableOutsidePointerEvents={false}\n onEscapeKeyDown={onEscapeKeyDown}\n onPointerDownOutside={onPointerDownOutside}\n onFocusOutside={(event) => event.preventDefault()}\n onDismiss={onClose}\n >\n <PopperPrimitive.Content\n data-state={context.stateAttribute}\n {...popperScope}\n {...contentProps}\n ref={forwardedRef}\n style={{\n ...contentProps.style,\n // re-namespace exposed content custom properties\n ...{\n '--radix-tooltip-content-transform-origin': 'var(--radix-popper-transform-origin)',\n '--radix-tooltip-content-available-width': 'var(--radix-popper-available-width)',\n '--radix-tooltip-content-available-height': 'var(--radix-popper-available-height)',\n '--radix-tooltip-trigger-width': 'var(--radix-popper-anchor-width)',\n '--radix-tooltip-trigger-height': 'var(--radix-popper-anchor-height)',\n },\n }}\n >\n <Slottable>{children}</Slottable>\n <VisuallyHiddenContentContextProvider scope={__scopeTooltip} isInside={true}>\n <VisuallyHiddenPrimitive.Root id={context.contentId} role=\"tooltip\">\n {ariaLabel || children}\n </VisuallyHiddenPrimitive.Root>\n </VisuallyHiddenContentContextProvider>\n </PopperPrimitive.Content>\n </DismissableLayer>\n );\n }\n);\n\nTooltipContent.displayName = CONTENT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'TooltipArrow';\n\ntype TooltipArrowElement = React.ElementRef<typeof PopperPrimitive.Arrow>;\ntype PopperArrowProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Arrow>;\ninterface TooltipArrowProps extends PopperArrowProps {}\n\nconst TooltipArrow = React.forwardRef<TooltipArrowElement, TooltipArrowProps>(\n (props: ScopedProps<TooltipArrowProps>, forwardedRef) => {\n const { __scopeTooltip, ...arrowProps } = props;\n const popperScope = usePopperScope(__scopeTooltip);\n const visuallyHiddenContentContext = useVisuallyHiddenContentContext(\n ARROW_NAME,\n __scopeTooltip\n );\n // if the arrow is inside the `VisuallyHidden`, we don't want to render it all to\n // prevent issues in positioning the arrow due to the duplicate\n return visuallyHiddenContentContext.isInside ? null : (\n <PopperPrimitive.Arrow {...popperScope} {...arrowProps} ref={forwardedRef} />\n );\n }\n);\n\nTooltipArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype Side = NonNullable<TooltipContentProps['side']>;\n\nfunction getExitSideFromRect(point: Point, rect: DOMRect): Side {\n const top = Math.abs(rect.top - point.y);\n const bottom = Math.abs(rect.bottom - point.y);\n const right = Math.abs(rect.right - point.x);\n const left = Math.abs(rect.left - point.x);\n\n switch (Math.min(top, bottom, right, left)) {\n case left:\n return 'left';\n case right:\n return 'right';\n case top:\n return 'top';\n case bottom:\n return 'bottom';\n default:\n throw new Error('unreachable');\n }\n}\n\nfunction getPaddedExitPoints(exitPoint: Point, exitSide: Side, padding = 5) {\n const paddedExitPoints: Point[] = [];\n switch (exitSide) {\n case 'top':\n paddedExitPoints.push(\n { x: exitPoint.x - padding, y: exitPoint.y + padding },\n { x: exitPoint.x + padding, y: exitPoint.y + padding }\n );\n break;\n case 'bottom':\n paddedExitPoints.push(\n { x: exitPoint.x - padding, y: exitPoint.y - padding },\n { x: exitPoint.x + padding, y: exitPoint.y - padding }\n );\n break;\n case 'left':\n paddedExitPoints.push(\n { x: exitPoint.x + padding, y: exitPoint.y - padding },\n { x: exitPoint.x + padding, y: exitPoint.y + padding }\n );\n break;\n case 'right':\n paddedExitPoints.push(\n { x: exitPoint.x - padding, y: exitPoint.y - padding },\n { x: exitPoint.x - padding, y: exitPoint.y + padding }\n );\n break;\n }\n return paddedExitPoints;\n}\n\nfunction getPointsFromRect(rect: DOMRect) {\n const { top, right, bottom, left } = rect;\n return [\n { x: left, y: top },\n { x: right, y: top },\n { x: right, y: bottom },\n { x: left, y: bottom },\n ];\n}\n\n// Determine if a point is inside of a polygon.\n// Based on https://github.com/substack/point-in-polygon\nfunction isPointInPolygon(point: Point, polygon: Polygon) {\n const { x, y } = point;\n let inside = false;\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const xi = polygon[i].x;\n const yi = polygon[i].y;\n const xj = polygon[j].x;\n const yj = polygon[j].y;\n\n // prettier-ignore\n const intersect = ((yi > y) !== (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);\n if (intersect) inside = !inside;\n }\n\n return inside;\n}\n\n// Returns a new array of points representing the convex hull of the given set of points.\n// https://www.nayuki.io/page/convex-hull-algorithm\nfunction getHull<P extends Point>(points: Readonly<Array<P>>): Array<P> {\n const newPoints: Array<P> = points.slice();\n newPoints.sort((a: Point, b: Point) => {\n if (a.x < b.x) return -1;\n else if (a.x > b.x) return +1;\n else if (a.y < b.y) return -1;\n else if (a.y > b.y) return +1;\n else return 0;\n });\n return getHullPresorted(newPoints);\n}\n\n// Returns the convex hull, assuming that each points[i] <= points[i + 1]. Runs in O(n) time.\nfunction getHullPresorted<P extends Point>(points: Readonly<Array<P>>): Array<P> {\n if (points.length <= 1) return points.slice();\n\n const upperHull: Array<P> = [];\n for (let i = 0; i < points.length; i++) {\n const p = points[i];\n while (upperHull.length >= 2) {\n const q = upperHull[upperHull.length - 1];\n const r = upperHull[upperHull.length - 2];\n if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();\n else break;\n }\n upperHull.push(p);\n }\n upperHull.pop();\n\n const lowerHull: Array<P> = [];\n for (let i = points.length - 1; i >= 0; i--) {\n const p = points[i];\n while (lowerHull.length >= 2) {\n const q = lowerHull[lowerHull.length - 1];\n const r = lowerHull[lowerHull.length - 2];\n if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) lowerHull.pop();\n else break;\n }\n lowerHull.push(p);\n }\n lowerHull.pop();\n\n if (\n upperHull.length === 1 &&\n lowerHull.length === 1 &&\n upperHull[0].x === lowerHull[0].x &&\n upperHull[0].y === lowerHull[0].y\n ) {\n return upperHull;\n } else {\n return upperHull.concat(lowerHull);\n }\n}\n\nconst Provider = TooltipProvider;\nconst Root = Tooltip;\nconst Trigger = TooltipTrigger;\nconst Portal = TooltipPortal;\nconst Content = TooltipContent;\nconst Arrow = TooltipArrow;\n\nexport {\n createTooltipScope,\n //\n TooltipProvider,\n Tooltip,\n TooltipTrigger,\n TooltipPortal,\n TooltipContent,\n TooltipArrow,\n //\n Provider,\n Root,\n Trigger,\n Portal,\n Content,\n Arrow,\n};\nexport type {\n TooltipProps,\n TooltipTriggerProps,\n TooltipPortalProps,\n TooltipContentProps,\n TooltipArrowProps,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAuB;AACvB,yBAAqC;AACrC,kCAAgC;AAChC,6BAAmC;AACnC,uCAAiC;AACjC,wBAAsB;AACtB,wBAAiC;AACjC,4BAAkC;AAClC,4BAA0C;AAC1C,8BAAyB;AACzB,+BAA0B;AAC1B,0BAA0B;AAC1B,4CAAqC;AACrC,gCAAyC;AAuErC;AAjEJ,MAAM,CAAC,sBAAsB,kBAAkB,QAAI,yCAAmB,WAAW;AAAA,IAC/E;AAAA,EACF,CAAC;AACD,MAAM,qBAAiB,uCAAkB;AAMzC,MAAM,gBAAgB;AACtB,MAAM,yBAAyB;AAC/B,MAAM,eAAe;AAYrB,MAAM,CAAC,gCAAgC,yBAAyB,IAC9D,qBAAkD,aAAa;AAqBjE,MAAM,kBAAkD,CACtD,UACG;AACH,UAAM;AAAA,MACJ;AAAA,MACA,gBAAgB;AAAA,MAChB,oBAAoB;AAAA,MACpB,0BAA0B;AAAA,MAC1B;AAAA,IACF,IAAI;AACJ,UAAM,CAAC,eAAe,gBAAgB,IAAU,eAAS,IAAI;AAC7D,UAAM,wBAA8B,aAAO,KAAK;AAChD,UAAM,oBAA0B,aAAO,CAAC;AAExC,IAAM,gBAAU,MAAM;AACpB,YAAM,iBAAiB,kBAAkB;AACzC,aAAO,MAAM,OAAO,aAAa,cAAc;AAAA,IACjD,GAAG,CAAC,CAAC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I;AAEd,QACE,UAAU,WAAW,KACrB,UAAU,WAAW,KACrB,UAAU,CAAC,EAAE,MAAM,UAAU,CAAC,EAAE,KAChC,UAAU,CAAC,EAAE,MAAM,UAAU,CAAC,EAAE,GAChC;AACA,aAAO;AAAA,IACT,OAAO;AACL,aAAO,UAAU,OAAO,SAAS;AAAA,IACnC;AAAA,EACF;AAEA,MAAM,WAAW;AACjB,MAAMC,QAAO;AACb,MAAM,UAAU;AAChB,MAAM,SAAS;AACf,MAAMC,WAAU;AAChB,MAAMC,SAAQ;",
|
|
6
|
-
"names": ["open", "PortalPrimitive", "Root", "Content", "Arrow"]
|
|
3
|
+
"sources": ["../src/index.ts", "../src/Tooltip.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client';\nexport {\n createTooltipScope,\n //\n TooltipProvider,\n Tooltip,\n TooltipTrigger,\n TooltipPortal,\n TooltipContent,\n TooltipArrow,\n //\n Provider,\n Root,\n Trigger,\n Portal,\n Content,\n Arrow,\n} from './Tooltip';\nexport type {\n TooltipProps,\n TooltipTriggerProps,\n TooltipPortalProps,\n TooltipContentProps,\n TooltipArrowProps,\n} from './Tooltip';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { DismissableLayer } from '@radix-ui/react-dismissable-layer';\nimport { useId } from '@radix-ui/react-id';\nimport * as PopperPrimitive from '@radix-ui/react-popper';\nimport { createPopperScope } from '@radix-ui/react-popper';\nimport { Portal as PortalPrimitive } from '@radix-ui/react-portal';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slottable } from '@radix-ui/react-slot';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as VisuallyHiddenPrimitive from '@radix-ui/react-visually-hidden';\n\nimport type * as Radix from '@radix-ui/react-primitive';\nimport type { Scope } from '@radix-ui/react-context';\n\ntype ScopedProps<P = {}> = P & { __scopeTooltip?: Scope };\nconst [createTooltipContext, createTooltipScope] = createContextScope('Tooltip', [\n createPopperScope,\n]);\nconst usePopperScope = createPopperScope();\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipProvider\n * -----------------------------------------------------------------------------------------------*/\n\nconst PROVIDER_NAME = 'TooltipProvider';\nconst DEFAULT_DELAY_DURATION = 700;\nconst TOOLTIP_OPEN = 'tooltip.open';\n\ntype TooltipProviderContextValue = {\n isOpenDelayed: boolean;\n delayDuration: number;\n onOpen(): void;\n onClose(): void;\n onPointerInTransitChange(inTransit: boolean): void;\n isPointerInTransitRef: React.MutableRefObject<boolean>;\n disableHoverableContent: boolean;\n};\n\nconst [TooltipProviderContextProvider, useTooltipProviderContext] =\n createTooltipContext<TooltipProviderContextValue>(PROVIDER_NAME);\n\ninterface TooltipProviderProps {\n children: React.ReactNode;\n /**\n * The duration from when the pointer enters the trigger until the tooltip gets opened.\n * @defaultValue 700\n */\n delayDuration?: number;\n /**\n * How much time a user has to enter another trigger without incurring a delay again.\n * @defaultValue 300\n */\n skipDelayDuration?: number;\n /**\n * When `true`, trying to hover the content will result in the tooltip closing as the pointer leaves the trigger.\n * @defaultValue false\n */\n disableHoverableContent?: boolean;\n}\n\nconst TooltipProvider: React.FC<TooltipProviderProps> = (\n props: ScopedProps<TooltipProviderProps>\n) => {\n const {\n __scopeTooltip,\n delayDuration = DEFAULT_DELAY_DURATION,\n skipDelayDuration = 300,\n disableHoverableContent = false,\n children,\n } = props;\n const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);\n const isPointerInTransitRef = React.useRef(false);\n const skipDelayTimerRef = React.useRef(0);\n\n React.useEffect(() => {\n const skipDelayTimer = skipDelayTimerRef.current;\n return () => window.clearTimeout(skipDelayTimer);\n }, []);\n\n return (\n <TooltipProviderContextProvider\n scope={__scopeTooltip}\n isOpenDelayed={isOpenDelayed}\n delayDuration={delayDuration}\n onOpen={React.useCallback(() => {\n window.clearTimeout(skipDelayTimerRef.current);\n setIsOpenDelayed(false);\n }, [])}\n onClose={React.useCallback(() => {\n window.clearTimeout(skipDelayTimerRef.current);\n skipDelayTimerRef.current = window.setTimeout(\n () => setIsOpenDelayed(true),\n skipDelayDuration\n );\n }, [skipDelayDuration])}\n isPointerInTransitRef={isPointerInTransitRef}\n onPointerInTransitChange={React.useCallback((inTransit: boolean) => {\n isPointerInTransitRef.current = inTransit;\n }, [])}\n disableHoverableContent={disableHoverableContent}\n >\n {children}\n </TooltipProviderContextProvider>\n );\n};\n\nTooltipProvider.displayName = PROVIDER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * Tooltip\n * -----------------------------------------------------------------------------------------------*/\n\nconst TOOLTIP_NAME = 'Tooltip';\n\ntype TooltipContextValue = {\n contentId: string;\n open: boolean;\n stateAttribute: 'closed' | 'delayed-open' | 'instant-open';\n trigger: TooltipTriggerElement | null;\n onTriggerChange(trigger: TooltipTriggerElement | null): void;\n onTriggerEnter(): void;\n onTriggerLeave(): void;\n onOpen(): void;\n onClose(): void;\n disableHoverableContent: boolean;\n};\n\nconst [TooltipContextProvider, useTooltipContext] =\n createTooltipContext<TooltipContextValue>(TOOLTIP_NAME);\n\ninterface TooltipProps {\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * The duration from when the pointer enters the trigger until the tooltip gets opened. This will\n * override the prop with the same name passed to Provider.\n * @defaultValue 700\n */\n delayDuration?: number;\n /**\n * When `true`, trying to hover the content will result in the tooltip closing as the pointer leaves the trigger.\n * @defaultValue false\n */\n disableHoverableContent?: boolean;\n}\n\nconst Tooltip: React.FC<TooltipProps> = (props: ScopedProps<TooltipProps>) => {\n const {\n __scopeTooltip,\n children,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n disableHoverableContent: disableHoverableContentProp,\n delayDuration: delayDurationProp,\n } = props;\n const providerContext = useTooltipProviderContext(TOOLTIP_NAME, props.__scopeTooltip);\n const popperScope = usePopperScope(__scopeTooltip);\n const [trigger, setTrigger] = React.useState<HTMLButtonElement | null>(null);\n const contentId = useId();\n const openTimerRef = React.useRef(0);\n const disableHoverableContent =\n disableHoverableContentProp ?? providerContext.disableHoverableContent;\n const delayDuration = delayDurationProp ?? providerContext.delayDuration;\n const wasOpenDelayedRef = React.useRef(false);\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: (open) => {\n if (open) {\n providerContext.onOpen();\n\n // as `onChange` is called within a lifecycle method we\n // avoid dispatching via `dispatchDiscreteCustomEvent`.\n document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));\n } else {\n providerContext.onClose();\n }\n onOpenChange?.(open);\n },\n });\n const stateAttribute = React.useMemo(() => {\n return open ? (wasOpenDelayedRef.current ? 'delayed-open' : 'instant-open') : 'closed';\n }, [open]);\n\n const handleOpen = React.useCallback(() => {\n window.clearTimeout(openTimerRef.current);\n wasOpenDelayedRef.current = false;\n setOpen(true);\n }, [setOpen]);\n\n const handleClose = React.useCallback(() => {\n window.clearTimeout(openTimerRef.current);\n setOpen(false);\n }, [setOpen]);\n\n const handleDelayedOpen = React.useCallback(() => {\n window.clearTimeout(openTimerRef.current);\n openTimerRef.current = window.setTimeout(() => {\n wasOpenDelayedRef.current = true;\n setOpen(true);\n }, delayDuration);\n }, [delayDuration, setOpen]);\n\n React.useEffect(() => {\n return () => window.clearTimeout(openTimerRef.current);\n }, []);\n\n return (\n <PopperPrimitive.Root {...popperScope}>\n <TooltipContextProvider\n scope={__scopeTooltip}\n contentId={contentId}\n open={open}\n stateAttribute={stateAttribute}\n trigger={trigger}\n onTriggerChange={setTrigger}\n onTriggerEnter={React.useCallback(() => {\n if (providerContext.isOpenDelayed) handleDelayedOpen();\n else handleOpen();\n }, [providerContext.isOpenDelayed, handleDelayedOpen, handleOpen])}\n onTriggerLeave={React.useCallback(() => {\n if (disableHoverableContent) {\n handleClose();\n } else {\n // Clear the timer in case the pointer leaves the trigger before the tooltip is opened.\n window.clearTimeout(openTimerRef.current);\n }\n }, [handleClose, disableHoverableContent])}\n onOpen={handleOpen}\n onClose={handleClose}\n disableHoverableContent={disableHoverableContent}\n >\n {children}\n </TooltipContextProvider>\n </PopperPrimitive.Root>\n );\n};\n\nTooltip.displayName = TOOLTIP_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'TooltipTrigger';\n\ntype TooltipTriggerElement = React.ElementRef<typeof Primitive.button>;\ntype PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;\ninterface TooltipTriggerProps extends PrimitiveButtonProps {}\n\nconst TooltipTrigger = React.forwardRef<TooltipTriggerElement, TooltipTriggerProps>(\n (props: ScopedProps<TooltipTriggerProps>, forwardedRef) => {\n const { __scopeTooltip, ...triggerProps } = props;\n const context = useTooltipContext(TRIGGER_NAME, __scopeTooltip);\n const providerContext = useTooltipProviderContext(TRIGGER_NAME, __scopeTooltip);\n const popperScope = usePopperScope(__scopeTooltip);\n const ref = React.useRef<TooltipTriggerElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref, context.onTriggerChange);\n const isPointerDownRef = React.useRef(false);\n const hasPointerMoveOpenedRef = React.useRef(false);\n const handlePointerUp = React.useCallback(() => (isPointerDownRef.current = false), []);\n\n React.useEffect(() => {\n return () => document.removeEventListener('pointerup', handlePointerUp);\n }, [handlePointerUp]);\n\n return (\n <PopperPrimitive.Anchor asChild {...popperScope}>\n <Primitive.button\n // We purposefully avoid adding `type=button` here because tooltip triggers are also\n // commonly anchors and the anchor `type` attribute signifies MIME type.\n aria-describedby={context.open ? context.contentId : undefined}\n data-state={context.stateAttribute}\n {...triggerProps}\n ref={composedRefs}\n onPointerMove={composeEventHandlers(props.onPointerMove, (event) => {\n if (event.pointerType === 'touch') return;\n if (\n !hasPointerMoveOpenedRef.current &&\n !providerContext.isPointerInTransitRef.current\n ) {\n context.onTriggerEnter();\n hasPointerMoveOpenedRef.current = true;\n }\n })}\n onPointerLeave={composeEventHandlers(props.onPointerLeave, () => {\n context.onTriggerLeave();\n hasPointerMoveOpenedRef.current = false;\n })}\n onPointerDown={composeEventHandlers(props.onPointerDown, () => {\n isPointerDownRef.current = true;\n document.addEventListener('pointerup', handlePointerUp, { once: true });\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\n if (!isPointerDownRef.current) context.onOpen();\n })}\n onBlur={composeEventHandlers(props.onBlur, context.onClose)}\n onClick={composeEventHandlers(props.onClick, context.onClose)}\n />\n </PopperPrimitive.Anchor>\n );\n }\n);\n\nTooltipTrigger.displayName = TRIGGER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipPortal\n * -----------------------------------------------------------------------------------------------*/\n\nconst PORTAL_NAME = 'TooltipPortal';\n\ntype PortalContextValue = { forceMount?: true };\nconst [PortalProvider, usePortalContext] = createTooltipContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n});\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface TooltipPortalProps {\n children?: React.ReactNode;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps['container'];\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst TooltipPortal: React.FC<TooltipPortalProps> = (props: ScopedProps<TooltipPortalProps>) => {\n const { __scopeTooltip, forceMount, children, container } = props;\n const context = useTooltipContext(PORTAL_NAME, __scopeTooltip);\n return (\n <PortalProvider scope={__scopeTooltip} forceMount={forceMount}>\n <Presence present={forceMount || context.open}>\n <PortalPrimitive asChild container={container}>\n {children}\n </PortalPrimitive>\n </Presence>\n </PortalProvider>\n );\n};\n\nTooltipPortal.displayName = PORTAL_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'TooltipContent';\n\ntype TooltipContentElement = TooltipContentImplElement;\ninterface TooltipContentProps extends TooltipContentImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst TooltipContent = React.forwardRef<TooltipContentElement, TooltipContentProps>(\n (props: ScopedProps<TooltipContentProps>, forwardedRef) => {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopeTooltip);\n const { forceMount = portalContext.forceMount, side = 'top', ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);\n\n return (\n <Presence present={forceMount || context.open}>\n {context.disableHoverableContent ? (\n <TooltipContentImpl side={side} {...contentProps} ref={forwardedRef} />\n ) : (\n <TooltipContentHoverable side={side} {...contentProps} ref={forwardedRef} />\n )}\n </Presence>\n );\n }\n);\n\ntype Point = { x: number; y: number };\ntype Polygon = Point[];\n\ntype TooltipContentHoverableElement = TooltipContentImplElement;\ninterface TooltipContentHoverableProps extends TooltipContentImplProps {}\n\nconst TooltipContentHoverable = React.forwardRef<\n TooltipContentHoverableElement,\n TooltipContentHoverableProps\n>((props: ScopedProps<TooltipContentHoverableProps>, forwardedRef) => {\n const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);\n const providerContext = useTooltipProviderContext(CONTENT_NAME, props.__scopeTooltip);\n const ref = React.useRef<TooltipContentHoverableElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const [pointerGraceArea, setPointerGraceArea] = React.useState<Polygon | null>(null);\n\n const { trigger, onClose } = context;\n const content = ref.current;\n\n const { onPointerInTransitChange } = providerContext;\n\n const handleRemoveGraceArea = React.useCallback(() => {\n setPointerGraceArea(null);\n onPointerInTransitChange(false);\n }, [onPointerInTransitChange]);\n\n const handleCreateGraceArea = React.useCallback(\n (event: PointerEvent, hoverTarget: HTMLElement) => {\n const currentTarget = event.currentTarget as HTMLElement;\n const exitPoint = { x: event.clientX, y: event.clientY };\n const exitSide = getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());\n const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);\n const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());\n const graceArea = getHull([...paddedExitPoints, ...hoverTargetPoints]);\n setPointerGraceArea(graceArea);\n onPointerInTransitChange(true);\n },\n [onPointerInTransitChange]\n );\n\n React.useEffect(() => {\n return () => handleRemoveGraceArea();\n }, [handleRemoveGraceArea]);\n\n React.useEffect(() => {\n if (trigger && content) {\n const handleTriggerLeave = (event: PointerEvent) => handleCreateGraceArea(event, content);\n const handleContentLeave = (event: PointerEvent) => handleCreateGraceArea(event, trigger);\n\n trigger.addEventListener('pointerleave', handleTriggerLeave);\n content.addEventListener('pointerleave', handleContentLeave);\n return () => {\n trigger.removeEventListener('pointerleave', handleTriggerLeave);\n content.removeEventListener('pointerleave', handleContentLeave);\n };\n }\n }, [trigger, content, handleCreateGraceArea, handleRemoveGraceArea]);\n\n React.useEffect(() => {\n if (pointerGraceArea) {\n const handleTrackPointerGrace = (event: PointerEvent) => {\n const target = event.target as HTMLElement;\n const pointerPosition = { x: event.clientX, y: event.clientY };\n const hasEnteredTarget = trigger?.contains(target) || content?.contains(target);\n const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);\n\n if (hasEnteredTarget) {\n handleRemoveGraceArea();\n } else if (isPointerOutsideGraceArea) {\n handleRemoveGraceArea();\n onClose();\n }\n };\n document.addEventListener('pointermove', handleTrackPointerGrace);\n return () => document.removeEventListener('pointermove', handleTrackPointerGrace);\n }\n }, [trigger, content, pointerGraceArea, onClose, handleRemoveGraceArea]);\n\n return <TooltipContentImpl {...props} ref={composedRefs} />;\n});\n\nconst [VisuallyHiddenContentContextProvider, useVisuallyHiddenContentContext] =\n createTooltipContext(TOOLTIP_NAME, { isInside: false });\n\ntype TooltipContentImplElement = React.ElementRef<typeof PopperPrimitive.Content>;\ntype DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype PopperContentProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;\ninterface TooltipContentImplProps extends Omit<PopperContentProps, 'onPlaced'> {\n /**\n * A more descriptive label for accessibility purpose\n */\n 'aria-label'?: string;\n\n /**\n * Event handler called when the escape key is down.\n * Can be prevented.\n */\n onEscapeKeyDown?: DismissableLayerProps['onEscapeKeyDown'];\n /**\n * Event handler called when the a `pointerdown` event happens outside of the `Tooltip`.\n * Can be prevented.\n */\n onPointerDownOutside?: DismissableLayerProps['onPointerDownOutside'];\n}\n\nconst TooltipContentImpl = React.forwardRef<TooltipContentImplElement, TooltipContentImplProps>(\n (props: ScopedProps<TooltipContentImplProps>, forwardedRef) => {\n const {\n __scopeTooltip,\n children,\n 'aria-label': ariaLabel,\n onEscapeKeyDown,\n onPointerDownOutside,\n ...contentProps\n } = props;\n const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);\n const popperScope = usePopperScope(__scopeTooltip);\n const { onClose } = context;\n\n // Close this tooltip if another one opens\n React.useEffect(() => {\n document.addEventListener(TOOLTIP_OPEN, onClose);\n return () => document.removeEventListener(TOOLTIP_OPEN, onClose);\n }, [onClose]);\n\n // Close the tooltip if the trigger is scrolled\n React.useEffect(() => {\n if (context.trigger) {\n const handleScroll = (event: Event) => {\n const target = event.target as HTMLElement;\n if (target?.contains(context.trigger)) onClose();\n };\n window.addEventListener('scroll', handleScroll, { capture: true });\n return () => window.removeEventListener('scroll', handleScroll, { capture: true });\n }\n }, [context.trigger, onClose]);\n\n return (\n <DismissableLayer\n asChild\n disableOutsidePointerEvents={false}\n onEscapeKeyDown={onEscapeKeyDown}\n onPointerDownOutside={onPointerDownOutside}\n onFocusOutside={(event) => event.preventDefault()}\n onDismiss={onClose}\n >\n <PopperPrimitive.Content\n data-state={context.stateAttribute}\n {...popperScope}\n {...contentProps}\n ref={forwardedRef}\n style={{\n ...contentProps.style,\n // re-namespace exposed content custom properties\n ...{\n '--radix-tooltip-content-transform-origin': 'var(--radix-popper-transform-origin)',\n '--radix-tooltip-content-available-width': 'var(--radix-popper-available-width)',\n '--radix-tooltip-content-available-height': 'var(--radix-popper-available-height)',\n '--radix-tooltip-trigger-width': 'var(--radix-popper-anchor-width)',\n '--radix-tooltip-trigger-height': 'var(--radix-popper-anchor-height)',\n },\n }}\n >\n <Slottable>{children}</Slottable>\n <VisuallyHiddenContentContextProvider scope={__scopeTooltip} isInside={true}>\n <VisuallyHiddenPrimitive.Root id={context.contentId} role=\"tooltip\">\n {ariaLabel || children}\n </VisuallyHiddenPrimitive.Root>\n </VisuallyHiddenContentContextProvider>\n </PopperPrimitive.Content>\n </DismissableLayer>\n );\n }\n);\n\nTooltipContent.displayName = CONTENT_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * TooltipArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'TooltipArrow';\n\ntype TooltipArrowElement = React.ElementRef<typeof PopperPrimitive.Arrow>;\ntype PopperArrowProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Arrow>;\ninterface TooltipArrowProps extends PopperArrowProps {}\n\nconst TooltipArrow = React.forwardRef<TooltipArrowElement, TooltipArrowProps>(\n (props: ScopedProps<TooltipArrowProps>, forwardedRef) => {\n const { __scopeTooltip, ...arrowProps } = props;\n const popperScope = usePopperScope(__scopeTooltip);\n const visuallyHiddenContentContext = useVisuallyHiddenContentContext(\n ARROW_NAME,\n __scopeTooltip\n );\n // if the arrow is inside the `VisuallyHidden`, we don't want to render it all to\n // prevent issues in positioning the arrow due to the duplicate\n return visuallyHiddenContentContext.isInside ? null : (\n <PopperPrimitive.Arrow {...popperScope} {...arrowProps} ref={forwardedRef} />\n );\n }\n);\n\nTooltipArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype Side = NonNullable<TooltipContentProps['side']>;\n\nfunction getExitSideFromRect(point: Point, rect: DOMRect): Side {\n const top = Math.abs(rect.top - point.y);\n const bottom = Math.abs(rect.bottom - point.y);\n const right = Math.abs(rect.right - point.x);\n const left = Math.abs(rect.left - point.x);\n\n switch (Math.min(top, bottom, right, left)) {\n case left:\n return 'left';\n case right:\n return 'right';\n case top:\n return 'top';\n case bottom:\n return 'bottom';\n default:\n throw new Error('unreachable');\n }\n}\n\nfunction getPaddedExitPoints(exitPoint: Point, exitSide: Side, padding = 5) {\n const paddedExitPoints: Point[] = [];\n switch (exitSide) {\n case 'top':\n paddedExitPoints.push(\n { x: exitPoint.x - padding, y: exitPoint.y + padding },\n { x: exitPoint.x + padding, y: exitPoint.y + padding }\n );\n break;\n case 'bottom':\n paddedExitPoints.push(\n { x: exitPoint.x - padding, y: exitPoint.y - padding },\n { x: exitPoint.x + padding, y: exitPoint.y - padding }\n );\n break;\n case 'left':\n paddedExitPoints.push(\n { x: exitPoint.x + padding, y: exitPoint.y - padding },\n { x: exitPoint.x + padding, y: exitPoint.y + padding }\n );\n break;\n case 'right':\n paddedExitPoints.push(\n { x: exitPoint.x - padding, y: exitPoint.y - padding },\n { x: exitPoint.x - padding, y: exitPoint.y + padding }\n );\n break;\n }\n return paddedExitPoints;\n}\n\nfunction getPointsFromRect(rect: DOMRect) {\n const { top, right, bottom, left } = rect;\n return [\n { x: left, y: top },\n { x: right, y: top },\n { x: right, y: bottom },\n { x: left, y: bottom },\n ];\n}\n\n// Determine if a point is inside of a polygon.\n// Based on https://github.com/substack/point-in-polygon\nfunction isPointInPolygon(point: Point, polygon: Polygon) {\n const { x, y } = point;\n let inside = false;\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const xi = polygon[i].x;\n const yi = polygon[i].y;\n const xj = polygon[j].x;\n const yj = polygon[j].y;\n\n // prettier-ignore\n const intersect = ((yi > y) !== (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);\n if (intersect) inside = !inside;\n }\n\n return inside;\n}\n\n// Returns a new array of points representing the convex hull of the given set of points.\n// https://www.nayuki.io/page/convex-hull-algorithm\nfunction getHull<P extends Point>(points: Readonly<Array<P>>): Array<P> {\n const newPoints: Array<P> = points.slice();\n newPoints.sort((a: Point, b: Point) => {\n if (a.x < b.x) return -1;\n else if (a.x > b.x) return +1;\n else if (a.y < b.y) return -1;\n else if (a.y > b.y) return +1;\n else return 0;\n });\n return getHullPresorted(newPoints);\n}\n\n// Returns the convex hull, assuming that each points[i] <= points[i + 1]. Runs in O(n) time.\nfunction getHullPresorted<P extends Point>(points: Readonly<Array<P>>): Array<P> {\n if (points.length <= 1) return points.slice();\n\n const upperHull: Array<P> = [];\n for (let i = 0; i < points.length; i++) {\n const p = points[i];\n while (upperHull.length >= 2) {\n const q = upperHull[upperHull.length - 1];\n const r = upperHull[upperHull.length - 2];\n if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) upperHull.pop();\n else break;\n }\n upperHull.push(p);\n }\n upperHull.pop();\n\n const lowerHull: Array<P> = [];\n for (let i = points.length - 1; i >= 0; i--) {\n const p = points[i];\n while (lowerHull.length >= 2) {\n const q = lowerHull[lowerHull.length - 1];\n const r = lowerHull[lowerHull.length - 2];\n if ((q.x - r.x) * (p.y - r.y) >= (q.y - r.y) * (p.x - r.x)) lowerHull.pop();\n else break;\n }\n lowerHull.push(p);\n }\n lowerHull.pop();\n\n if (\n upperHull.length === 1 &&\n lowerHull.length === 1 &&\n upperHull[0].x === lowerHull[0].x &&\n upperHull[0].y === lowerHull[0].y\n ) {\n return upperHull;\n } else {\n return upperHull.concat(lowerHull);\n }\n}\n\nconst Provider = TooltipProvider;\nconst Root = Tooltip;\nconst Trigger = TooltipTrigger;\nconst Portal = TooltipPortal;\nconst Content = TooltipContent;\nconst Arrow = TooltipArrow;\n\nexport {\n createTooltipScope,\n //\n TooltipProvider,\n Tooltip,\n TooltipTrigger,\n TooltipPortal,\n TooltipContent,\n TooltipArrow,\n //\n Provider,\n Root,\n Trigger,\n Portal,\n Content,\n Arrow,\n};\nexport type {\n TooltipProps,\n TooltipTriggerProps,\n TooltipPortalProps,\n TooltipContentProps,\n TooltipArrowProps,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;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row", "Content", "Root", "open", "PortalPrimitive", "Root", "Content", "Arrow"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-tooltip",
|
|
3
|
-
"version": "1.1.0-rc.
|
|
3
|
+
"version": "1.1.0-rc.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
"version": "yarn version"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@radix-ui/primitive": "1.1.0-rc.
|
|
32
|
-
"@radix-ui/react-compose-refs": "1.1.0-rc.
|
|
33
|
-
"@radix-ui/react-context": "1.1.0-rc.
|
|
34
|
-
"@radix-ui/react-dismissable-layer": "1.1.0-rc.
|
|
35
|
-
"@radix-ui/react-id": "1.1.0-rc.
|
|
36
|
-
"@radix-ui/react-popper": "1.2.0-rc.
|
|
37
|
-
"@radix-ui/react-portal": "1.1.0-rc.
|
|
38
|
-
"@radix-ui/react-presence": "1.1.0-rc.
|
|
39
|
-
"@radix-ui/react-primitive": "1.1.0-rc.
|
|
40
|
-
"@radix-ui/react-slot": "1.1.0-rc.
|
|
41
|
-
"@radix-ui/react-use-controllable-state": "1.1.0-rc.
|
|
42
|
-
"@radix-ui/react-visually-hidden": "1.1.0-rc.
|
|
31
|
+
"@radix-ui/primitive": "1.1.0-rc.3",
|
|
32
|
+
"@radix-ui/react-compose-refs": "1.1.0-rc.3",
|
|
33
|
+
"@radix-ui/react-context": "1.1.0-rc.3",
|
|
34
|
+
"@radix-ui/react-dismissable-layer": "1.1.0-rc.3",
|
|
35
|
+
"@radix-ui/react-id": "1.1.0-rc.3",
|
|
36
|
+
"@radix-ui/react-popper": "1.2.0-rc.3",
|
|
37
|
+
"@radix-ui/react-portal": "1.1.0-rc.3",
|
|
38
|
+
"@radix-ui/react-presence": "1.1.0-rc.3",
|
|
39
|
+
"@radix-ui/react-primitive": "1.1.0-rc.3",
|
|
40
|
+
"@radix-ui/react-slot": "1.1.0-rc.3",
|
|
41
|
+
"@radix-ui/react-use-controllable-state": "1.1.0-rc.3",
|
|
42
|
+
"@radix-ui/react-visually-hidden": "1.1.0-rc.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@types/react": "*",
|