@radix-ui/react-tooltip 0.1.7 → 0.1.8-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +15 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +333 -1
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +314 -1
- package/dist/index.module.js.map +1 -1
- package/package.json +16 -17
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
|
|
3
|
+
import * as PopperPrimitive from "@radix-ui/react-popper";
|
|
2
4
|
import * as Radix from "@radix-ui/react-primitive";
|
|
3
5
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
|
-
import * as PopperPrimitive from "@radix-ui/react-popper";
|
|
5
6
|
export const createTooltipScope: import("@radix-ui/react-context").CreateScope;
|
|
6
7
|
interface TooltipProviderProps {
|
|
8
|
+
children: React.ReactNode;
|
|
7
9
|
/**
|
|
8
10
|
* The duration from when the mouse enters the trigger until the tooltip gets opened.
|
|
9
11
|
* @defaultValue 700
|
|
@@ -14,10 +16,10 @@ interface TooltipProviderProps {
|
|
|
14
16
|
* @defaultValue 300
|
|
15
17
|
*/
|
|
16
18
|
skipDelayDuration?: number;
|
|
17
|
-
children: React.ReactNode;
|
|
18
19
|
}
|
|
19
20
|
export const TooltipProvider: React.FC<TooltipProviderProps>;
|
|
20
21
|
export interface TooltipProps {
|
|
22
|
+
children?: React.ReactNode;
|
|
21
23
|
open?: boolean;
|
|
22
24
|
defaultOpen?: boolean;
|
|
23
25
|
onOpenChange?: (open: boolean) => void;
|
|
@@ -27,7 +29,6 @@ export interface TooltipProps {
|
|
|
27
29
|
* @defaultValue 700
|
|
28
30
|
*/
|
|
29
31
|
delayDuration?: number;
|
|
30
|
-
children?: React.ReactNode;
|
|
31
32
|
}
|
|
32
33
|
export const Tooltip: React.FC<TooltipProps>;
|
|
33
34
|
type PrimitiveButtonProps = Radix.ComponentPropsWithoutRef<typeof Primitive.button>;
|
|
@@ -42,12 +43,23 @@ export interface TooltipContentProps extends TooltipContentImplProps {
|
|
|
42
43
|
forceMount?: true;
|
|
43
44
|
}
|
|
44
45
|
export const TooltipContent: React.ForwardRefExoticComponent<TooltipContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
46
|
+
type DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;
|
|
45
47
|
type PopperContentProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;
|
|
46
48
|
interface TooltipContentImplProps extends PopperContentProps {
|
|
47
49
|
/**
|
|
48
50
|
* A more descriptive label for accessibility purpose
|
|
49
51
|
*/
|
|
50
52
|
'aria-label'?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Event handler called when the escape key is down.
|
|
55
|
+
* Can be prevented.
|
|
56
|
+
*/
|
|
57
|
+
onEscapeKeyDown?: DismissableLayerProps['onEscapeKeyDown'];
|
|
58
|
+
/**
|
|
59
|
+
* Event handler called when the a `pointerdown` event happens outside of the `Tooltip`.
|
|
60
|
+
* Can be prevented.
|
|
61
|
+
*/
|
|
62
|
+
onPointerDownOutside?: DismissableLayerProps['onPointerDownOutside'];
|
|
51
63
|
/**
|
|
52
64
|
* Whether the Tooltip should render in a Portal
|
|
53
65
|
* (default: `true`)
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;AAmBA,OAAA,yFAEE,CAAC;AA0BH;IACE,QAAQ,EAAE,MAAM,SAAS,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,OAAA,MAAM,iBAAiB,MAAM,EAAE,CAAC,oBAAoB,CAqCnD,CAAC;AAwBF;IACE,QAAQ,CAA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oB,CAAC","sources":["packages/react/tooltip/src/packages/react/tooltip/src/Tooltip.tsx","packages/react/tooltip/src/packages/react/tooltip/src/index.ts","packages/react/tooltip/src/index.ts"],"sourcesContent":[null,null,"export * from './Tooltip';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,334 @@
|
|
|
1
|
-
var
|
|
1
|
+
var $iVrL9$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
|
|
2
|
+
var $iVrL9$react = require("react");
|
|
3
|
+
var $iVrL9$radixuiprimitive = require("@radix-ui/primitive");
|
|
4
|
+
var $iVrL9$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
|
|
5
|
+
var $iVrL9$radixuireactcontext = require("@radix-ui/react-context");
|
|
6
|
+
var $iVrL9$radixuireactdismissablelayer = require("@radix-ui/react-dismissable-layer");
|
|
7
|
+
var $iVrL9$radixuireactid = require("@radix-ui/react-id");
|
|
8
|
+
var $iVrL9$radixuireactpopper = require("@radix-ui/react-popper");
|
|
9
|
+
var $iVrL9$radixuireactportal = require("@radix-ui/react-portal");
|
|
10
|
+
var $iVrL9$radixuireactpresence = require("@radix-ui/react-presence");
|
|
11
|
+
var $iVrL9$radixuireactprimitive = require("@radix-ui/react-primitive");
|
|
12
|
+
var $iVrL9$radixuireactslot = require("@radix-ui/react-slot");
|
|
13
|
+
var $iVrL9$radixuireactusecontrollablestate = require("@radix-ui/react-use-controllable-state");
|
|
14
|
+
var $iVrL9$radixuireactvisuallyhidden = require("@radix-ui/react-visually-hidden");
|
|
15
|
+
|
|
16
|
+
function $parcel$exportWildcard(dest, source) {
|
|
17
|
+
Object.keys(source).forEach(function(key) {
|
|
18
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Object.defineProperty(dest, key, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function get() {
|
|
25
|
+
return source[key];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return dest;
|
|
31
|
+
}
|
|
32
|
+
function $parcel$interopDefault(a) {
|
|
33
|
+
return a && a.__esModule ? a.default : a;
|
|
34
|
+
}
|
|
35
|
+
function $parcel$export(e, n, v, s) {
|
|
36
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
37
|
+
}
|
|
38
|
+
var $c34afbc43c90cc6f$exports = {};
|
|
39
|
+
|
|
40
|
+
$parcel$export($c34afbc43c90cc6f$exports, "createTooltipScope", () => $c34afbc43c90cc6f$export$1c540a2224f0d865);
|
|
41
|
+
$parcel$export($c34afbc43c90cc6f$exports, "TooltipProvider", () => $c34afbc43c90cc6f$export$f78649fb9ca566b8);
|
|
42
|
+
$parcel$export($c34afbc43c90cc6f$exports, "Tooltip", () => $c34afbc43c90cc6f$export$28c660c63b792dea);
|
|
43
|
+
$parcel$export($c34afbc43c90cc6f$exports, "TooltipTrigger", () => $c34afbc43c90cc6f$export$8c610744efcf8a1d);
|
|
44
|
+
$parcel$export($c34afbc43c90cc6f$exports, "TooltipContent", () => $c34afbc43c90cc6f$export$e9003e2be37ec060);
|
|
45
|
+
$parcel$export($c34afbc43c90cc6f$exports, "TooltipArrow", () => $c34afbc43c90cc6f$export$c27ee0ad710f7559);
|
|
46
|
+
$parcel$export($c34afbc43c90cc6f$exports, "Provider", () => $c34afbc43c90cc6f$export$2881499e37b75b9a);
|
|
47
|
+
$parcel$export($c34afbc43c90cc6f$exports, "Root", () => $c34afbc43c90cc6f$export$be92b6f5f03c0fe9);
|
|
48
|
+
$parcel$export($c34afbc43c90cc6f$exports, "Trigger", () => $c34afbc43c90cc6f$export$41fb9f06171c75f4);
|
|
49
|
+
$parcel$export($c34afbc43c90cc6f$exports, "Content", () => $c34afbc43c90cc6f$export$7c6e2c02157bb7d2);
|
|
50
|
+
$parcel$export($c34afbc43c90cc6f$exports, "Arrow", () => $c34afbc43c90cc6f$export$21b07c8f274aebd5);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
const [$c34afbc43c90cc6f$var$createTooltipContext, $c34afbc43c90cc6f$export$1c540a2224f0d865] = $iVrL9$radixuireactcontext.createContextScope('Tooltip', [
|
|
67
|
+
$iVrL9$radixuireactpopper.createPopperScope
|
|
68
|
+
]);
|
|
69
|
+
const $c34afbc43c90cc6f$var$usePopperScope = $iVrL9$radixuireactpopper.createPopperScope();
|
|
70
|
+
/* -------------------------------------------------------------------------------------------------
|
|
71
|
+
* TooltipProvider
|
|
72
|
+
* -----------------------------------------------------------------------------------------------*/ const $c34afbc43c90cc6f$var$PROVIDER_NAME = 'TooltipProvider';
|
|
73
|
+
const $c34afbc43c90cc6f$var$DEFAULT_DELAY_DURATION = 700;
|
|
74
|
+
const $c34afbc43c90cc6f$var$TOOLTIP_OPEN = 'tooltip.open';
|
|
75
|
+
const [$c34afbc43c90cc6f$var$TooltipProviderContextProvider, $c34afbc43c90cc6f$var$useTooltipProviderContext] = $c34afbc43c90cc6f$var$createTooltipContext($c34afbc43c90cc6f$var$PROVIDER_NAME, {
|
|
76
|
+
isOpenDelayed: true,
|
|
77
|
+
delayDuration: $c34afbc43c90cc6f$var$DEFAULT_DELAY_DURATION,
|
|
78
|
+
onOpen: ()=>{},
|
|
79
|
+
onClose: ()=>{}
|
|
80
|
+
});
|
|
81
|
+
const $c34afbc43c90cc6f$export$f78649fb9ca566b8 = (props)=>{
|
|
82
|
+
const { __scopeTooltip: __scopeTooltip , delayDuration: delayDuration = $c34afbc43c90cc6f$var$DEFAULT_DELAY_DURATION , skipDelayDuration: skipDelayDuration = 300 , children: children } = props;
|
|
83
|
+
const [isOpenDelayed, setIsOpenDelayed] = $iVrL9$react.useState(true);
|
|
84
|
+
const skipDelayTimerRef = $iVrL9$react.useRef(0);
|
|
85
|
+
$iVrL9$react.useEffect(()=>{
|
|
86
|
+
const skipDelayTimer = skipDelayTimerRef.current;
|
|
87
|
+
return ()=>window.clearTimeout(skipDelayTimer)
|
|
88
|
+
;
|
|
89
|
+
}, []);
|
|
90
|
+
return /*#__PURE__*/ $iVrL9$react.createElement($c34afbc43c90cc6f$var$TooltipProviderContextProvider, {
|
|
91
|
+
scope: __scopeTooltip,
|
|
92
|
+
isOpenDelayed: isOpenDelayed,
|
|
93
|
+
delayDuration: delayDuration,
|
|
94
|
+
onOpen: $iVrL9$react.useCallback(()=>{
|
|
95
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
96
|
+
setIsOpenDelayed(false);
|
|
97
|
+
}, []),
|
|
98
|
+
onClose: $iVrL9$react.useCallback(()=>{
|
|
99
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
100
|
+
skipDelayTimerRef.current = window.setTimeout(()=>setIsOpenDelayed(true)
|
|
101
|
+
, skipDelayDuration);
|
|
102
|
+
}, [
|
|
103
|
+
skipDelayDuration
|
|
104
|
+
])
|
|
105
|
+
}, children);
|
|
106
|
+
};
|
|
107
|
+
/*#__PURE__*/ Object.assign($c34afbc43c90cc6f$export$f78649fb9ca566b8, {
|
|
108
|
+
displayName: $c34afbc43c90cc6f$var$PROVIDER_NAME
|
|
109
|
+
});
|
|
110
|
+
/* -------------------------------------------------------------------------------------------------
|
|
111
|
+
* Tooltip
|
|
112
|
+
* -----------------------------------------------------------------------------------------------*/ const $c34afbc43c90cc6f$var$TOOLTIP_NAME = 'Tooltip';
|
|
113
|
+
const [$c34afbc43c90cc6f$var$TooltipContextProvider, $c34afbc43c90cc6f$var$useTooltipContext] = $c34afbc43c90cc6f$var$createTooltipContext($c34afbc43c90cc6f$var$TOOLTIP_NAME);
|
|
114
|
+
const $c34afbc43c90cc6f$export$28c660c63b792dea = (props)=>{
|
|
115
|
+
const { __scopeTooltip: __scopeTooltip , children: children , open: openProp , defaultOpen: defaultOpen = false , onOpenChange: onOpenChange , delayDuration: delayDurationProp } = props;
|
|
116
|
+
const context = $c34afbc43c90cc6f$var$useTooltipProviderContext($c34afbc43c90cc6f$var$TOOLTIP_NAME, __scopeTooltip);
|
|
117
|
+
const popperScope = $c34afbc43c90cc6f$var$usePopperScope(__scopeTooltip);
|
|
118
|
+
const [trigger, setTrigger] = $iVrL9$react.useState(null);
|
|
119
|
+
const contentId = $iVrL9$radixuireactid.useId();
|
|
120
|
+
const openTimerRef = $iVrL9$react.useRef(0);
|
|
121
|
+
const delayDuration = delayDurationProp !== null && delayDurationProp !== void 0 ? delayDurationProp : context.delayDuration;
|
|
122
|
+
const wasOpenDelayedRef = $iVrL9$react.useRef(false);
|
|
123
|
+
const { onOpen: onOpen , onClose: onClose } = context;
|
|
124
|
+
const [open1 = false, setOpen] = $iVrL9$radixuireactusecontrollablestate.useControllableState({
|
|
125
|
+
prop: openProp,
|
|
126
|
+
defaultProp: defaultOpen,
|
|
127
|
+
onChange: (open)=>{
|
|
128
|
+
if (open) {
|
|
129
|
+
// we dispatch here so `TooltipProvider` isn't required to
|
|
130
|
+
// ensure other tooltips are aware of this one opening.
|
|
131
|
+
document.dispatchEvent(new CustomEvent($c34afbc43c90cc6f$var$TOOLTIP_OPEN));
|
|
132
|
+
onOpen();
|
|
133
|
+
}
|
|
134
|
+
onOpenChange === null || onOpenChange === void 0 || onOpenChange(open);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
const stateAttribute = $iVrL9$react.useMemo(()=>{
|
|
138
|
+
return open1 ? wasOpenDelayedRef.current ? 'delayed-open' : 'instant-open' : 'closed';
|
|
139
|
+
}, [
|
|
140
|
+
open1
|
|
141
|
+
]);
|
|
142
|
+
const handleOpen = $iVrL9$react.useCallback(()=>{
|
|
143
|
+
window.clearTimeout(openTimerRef.current);
|
|
144
|
+
wasOpenDelayedRef.current = false;
|
|
145
|
+
setOpen(true);
|
|
146
|
+
}, [
|
|
147
|
+
setOpen
|
|
148
|
+
]);
|
|
149
|
+
const handleDelayedOpen = $iVrL9$react.useCallback(()=>{
|
|
150
|
+
window.clearTimeout(openTimerRef.current);
|
|
151
|
+
openTimerRef.current = window.setTimeout(()=>{
|
|
152
|
+
wasOpenDelayedRef.current = true;
|
|
153
|
+
setOpen(true);
|
|
154
|
+
}, delayDuration);
|
|
155
|
+
}, [
|
|
156
|
+
delayDuration,
|
|
157
|
+
setOpen
|
|
158
|
+
]);
|
|
159
|
+
$iVrL9$react.useEffect(()=>{
|
|
160
|
+
return ()=>window.clearTimeout(openTimerRef.current)
|
|
161
|
+
;
|
|
162
|
+
}, []);
|
|
163
|
+
return /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactpopper.Root, popperScope, /*#__PURE__*/ $iVrL9$react.createElement($c34afbc43c90cc6f$var$TooltipContextProvider, {
|
|
164
|
+
scope: __scopeTooltip,
|
|
165
|
+
contentId: contentId,
|
|
166
|
+
open: open1,
|
|
167
|
+
stateAttribute: stateAttribute,
|
|
168
|
+
trigger: trigger,
|
|
169
|
+
onTriggerChange: setTrigger,
|
|
170
|
+
onTriggerEnter: $iVrL9$react.useCallback(()=>{
|
|
171
|
+
if (context.isOpenDelayed) handleDelayedOpen();
|
|
172
|
+
else handleOpen();
|
|
173
|
+
}, [
|
|
174
|
+
context.isOpenDelayed,
|
|
175
|
+
handleDelayedOpen,
|
|
176
|
+
handleOpen
|
|
177
|
+
]),
|
|
178
|
+
onOpen: $iVrL9$react.useCallback(handleOpen, [
|
|
179
|
+
handleOpen
|
|
180
|
+
]),
|
|
181
|
+
onClose: $iVrL9$react.useCallback(()=>{
|
|
182
|
+
window.clearTimeout(openTimerRef.current);
|
|
183
|
+
setOpen(false);
|
|
184
|
+
onClose();
|
|
185
|
+
}, [
|
|
186
|
+
setOpen,
|
|
187
|
+
onClose
|
|
188
|
+
])
|
|
189
|
+
}, children));
|
|
190
|
+
};
|
|
191
|
+
/*#__PURE__*/ Object.assign($c34afbc43c90cc6f$export$28c660c63b792dea, {
|
|
192
|
+
displayName: $c34afbc43c90cc6f$var$TOOLTIP_NAME
|
|
193
|
+
});
|
|
194
|
+
/* -------------------------------------------------------------------------------------------------
|
|
195
|
+
* TooltipTrigger
|
|
196
|
+
* -----------------------------------------------------------------------------------------------*/ const $c34afbc43c90cc6f$var$TRIGGER_NAME = 'TooltipTrigger';
|
|
197
|
+
const $c34afbc43c90cc6f$export$8c610744efcf8a1d = /*#__PURE__*/ $iVrL9$react.forwardRef((props, forwardedRef)=>{
|
|
198
|
+
const { __scopeTooltip: __scopeTooltip , ...triggerProps } = props;
|
|
199
|
+
const context = $c34afbc43c90cc6f$var$useTooltipContext($c34afbc43c90cc6f$var$TRIGGER_NAME, __scopeTooltip);
|
|
200
|
+
const popperScope = $c34afbc43c90cc6f$var$usePopperScope(__scopeTooltip);
|
|
201
|
+
const composedTriggerRef = $iVrL9$radixuireactcomposerefs.useComposedRefs(forwardedRef, context.onTriggerChange);
|
|
202
|
+
const isMouseDownRef = $iVrL9$react.useRef(false);
|
|
203
|
+
const handleMouseUp = $iVrL9$react.useCallback(()=>isMouseDownRef.current = false
|
|
204
|
+
, []);
|
|
205
|
+
$iVrL9$react.useEffect(()=>{
|
|
206
|
+
return ()=>document.removeEventListener('mouseup', handleMouseUp)
|
|
207
|
+
;
|
|
208
|
+
}, [
|
|
209
|
+
handleMouseUp
|
|
210
|
+
]);
|
|
211
|
+
return /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactpopper.Anchor, ($parcel$interopDefault($iVrL9$babelruntimehelpersextends))({
|
|
212
|
+
asChild: true
|
|
213
|
+
}, popperScope), /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactprimitive.Primitive.button, ($parcel$interopDefault($iVrL9$babelruntimehelpersextends))({
|
|
214
|
+
// We purposefully avoid adding `type=button` here because tooltip triggers are also
|
|
215
|
+
// commonly anchors and the anchor `type` attribute signifies MIME type.
|
|
216
|
+
"aria-describedby": context.open ? context.contentId : undefined,
|
|
217
|
+
"data-state": context.stateAttribute
|
|
218
|
+
}, triggerProps, {
|
|
219
|
+
ref: composedTriggerRef,
|
|
220
|
+
onMouseEnter: $iVrL9$radixuiprimitive.composeEventHandlers(props.onMouseEnter, context.onTriggerEnter),
|
|
221
|
+
onMouseLeave: $iVrL9$radixuiprimitive.composeEventHandlers(props.onMouseLeave, context.onClose),
|
|
222
|
+
onMouseDown: $iVrL9$radixuiprimitive.composeEventHandlers(props.onMouseDown, ()=>{
|
|
223
|
+
isMouseDownRef.current = true;
|
|
224
|
+
document.addEventListener('mouseup', handleMouseUp, {
|
|
225
|
+
once: true
|
|
226
|
+
});
|
|
227
|
+
}),
|
|
228
|
+
onFocus: $iVrL9$radixuiprimitive.composeEventHandlers(props.onFocus, ()=>{
|
|
229
|
+
if (!isMouseDownRef.current) context.onOpen();
|
|
230
|
+
}),
|
|
231
|
+
onBlur: $iVrL9$radixuiprimitive.composeEventHandlers(props.onBlur, context.onClose),
|
|
232
|
+
onClick: $iVrL9$radixuiprimitive.composeEventHandlers(props.onClick, (event)=>{
|
|
233
|
+
// keyboard click will occur under different conditions for different node
|
|
234
|
+
// types so we use `onClick` instead of `onKeyDown` to respect that
|
|
235
|
+
const isKeyboardClick = event.detail === 0;
|
|
236
|
+
if (isKeyboardClick) context.onClose();
|
|
237
|
+
})
|
|
238
|
+
})));
|
|
239
|
+
});
|
|
240
|
+
/*#__PURE__*/ Object.assign($c34afbc43c90cc6f$export$8c610744efcf8a1d, {
|
|
241
|
+
displayName: $c34afbc43c90cc6f$var$TRIGGER_NAME
|
|
242
|
+
});
|
|
243
|
+
/* -------------------------------------------------------------------------------------------------
|
|
244
|
+
* TooltipContent
|
|
245
|
+
* -----------------------------------------------------------------------------------------------*/ const $c34afbc43c90cc6f$var$CONTENT_NAME = 'TooltipContent';
|
|
246
|
+
const $c34afbc43c90cc6f$export$e9003e2be37ec060 = /*#__PURE__*/ $iVrL9$react.forwardRef((props, forwardedRef)=>{
|
|
247
|
+
const { forceMount: forceMount , ...contentProps } = props;
|
|
248
|
+
const context = $c34afbc43c90cc6f$var$useTooltipContext($c34afbc43c90cc6f$var$CONTENT_NAME, props.__scopeTooltip);
|
|
249
|
+
return /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactpresence.Presence, {
|
|
250
|
+
present: forceMount || context.open
|
|
251
|
+
}, /*#__PURE__*/ $iVrL9$react.createElement($c34afbc43c90cc6f$var$TooltipContentImpl, ($parcel$interopDefault($iVrL9$babelruntimehelpersextends))({
|
|
252
|
+
ref: forwardedRef
|
|
253
|
+
}, contentProps)));
|
|
254
|
+
});
|
|
255
|
+
const $c34afbc43c90cc6f$var$TooltipContentImpl = /*#__PURE__*/ $iVrL9$react.forwardRef((props, forwardedRef)=>{
|
|
256
|
+
const { __scopeTooltip: __scopeTooltip , children: children , 'aria-label': ariaLabel , portalled: portalled = true , onEscapeKeyDown: onEscapeKeyDown , onPointerDownOutside: onPointerDownOutside , ...contentProps } = props;
|
|
257
|
+
const context = $c34afbc43c90cc6f$var$useTooltipContext($c34afbc43c90cc6f$var$CONTENT_NAME, __scopeTooltip);
|
|
258
|
+
const popperScope = $c34afbc43c90cc6f$var$usePopperScope(__scopeTooltip);
|
|
259
|
+
const PortalWrapper = portalled ? $iVrL9$radixuireactportal.Portal : $iVrL9$react.Fragment;
|
|
260
|
+
const { onClose: onClose } = context; // Close this tooltip if another one opens
|
|
261
|
+
$iVrL9$react.useEffect(()=>{
|
|
262
|
+
document.addEventListener($c34afbc43c90cc6f$var$TOOLTIP_OPEN, onClose);
|
|
263
|
+
return ()=>document.removeEventListener($c34afbc43c90cc6f$var$TOOLTIP_OPEN, onClose)
|
|
264
|
+
;
|
|
265
|
+
}, [
|
|
266
|
+
onClose
|
|
267
|
+
]); // Close the tooltip if the trigger is scrolled
|
|
268
|
+
$iVrL9$react.useEffect(()=>{
|
|
269
|
+
if (context.trigger) {
|
|
270
|
+
const handleScroll = (event)=>{
|
|
271
|
+
const target = event.target;
|
|
272
|
+
if (target !== null && target !== void 0 && target.contains(context.trigger)) onClose();
|
|
273
|
+
};
|
|
274
|
+
window.addEventListener('scroll', handleScroll, {
|
|
275
|
+
capture: true
|
|
276
|
+
});
|
|
277
|
+
return ()=>window.removeEventListener('scroll', handleScroll, {
|
|
278
|
+
capture: true
|
|
279
|
+
})
|
|
280
|
+
;
|
|
281
|
+
}
|
|
282
|
+
}, [
|
|
283
|
+
context.trigger,
|
|
284
|
+
onClose
|
|
285
|
+
]);
|
|
286
|
+
return /*#__PURE__*/ $iVrL9$react.createElement(PortalWrapper, null, /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactdismissablelayer.DismissableLayer, {
|
|
287
|
+
asChild: true,
|
|
288
|
+
disableOutsidePointerEvents: false,
|
|
289
|
+
onEscapeKeyDown: onEscapeKeyDown,
|
|
290
|
+
onPointerDownOutside: onPointerDownOutside,
|
|
291
|
+
onFocusOutside: (event)=>event.preventDefault()
|
|
292
|
+
,
|
|
293
|
+
onDismiss: onClose
|
|
294
|
+
}, /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactpopper.Content, ($parcel$interopDefault($iVrL9$babelruntimehelpersextends))({
|
|
295
|
+
"data-state": context.stateAttribute
|
|
296
|
+
}, popperScope, contentProps, {
|
|
297
|
+
ref: forwardedRef,
|
|
298
|
+
style: {
|
|
299
|
+
...contentProps.style,
|
|
300
|
+
// re-namespace exposed content custom property
|
|
301
|
+
['--radix-tooltip-content-transform-origin']: 'var(--radix-popper-transform-origin)'
|
|
302
|
+
}
|
|
303
|
+
}), /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactslot.Slottable, null, children), /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactvisuallyhidden.Root, {
|
|
304
|
+
id: context.contentId,
|
|
305
|
+
role: "tooltip"
|
|
306
|
+
}, ariaLabel || children))));
|
|
307
|
+
});
|
|
308
|
+
/*#__PURE__*/ Object.assign($c34afbc43c90cc6f$export$e9003e2be37ec060, {
|
|
309
|
+
displayName: $c34afbc43c90cc6f$var$CONTENT_NAME
|
|
310
|
+
});
|
|
311
|
+
/* -------------------------------------------------------------------------------------------------
|
|
312
|
+
* TooltipArrow
|
|
313
|
+
* -----------------------------------------------------------------------------------------------*/ const $c34afbc43c90cc6f$var$ARROW_NAME = 'TooltipArrow';
|
|
314
|
+
const $c34afbc43c90cc6f$export$c27ee0ad710f7559 = /*#__PURE__*/ $iVrL9$react.forwardRef((props, forwardedRef)=>{
|
|
315
|
+
const { __scopeTooltip: __scopeTooltip , ...arrowProps } = props;
|
|
316
|
+
const popperScope = $c34afbc43c90cc6f$var$usePopperScope(__scopeTooltip);
|
|
317
|
+
return /*#__PURE__*/ $iVrL9$react.createElement($iVrL9$radixuireactpopper.Arrow, ($parcel$interopDefault($iVrL9$babelruntimehelpersextends))({}, popperScope, arrowProps, {
|
|
318
|
+
ref: forwardedRef
|
|
319
|
+
}));
|
|
320
|
+
});
|
|
321
|
+
/*#__PURE__*/ Object.assign($c34afbc43c90cc6f$export$c27ee0ad710f7559, {
|
|
322
|
+
displayName: $c34afbc43c90cc6f$var$ARROW_NAME
|
|
323
|
+
});
|
|
324
|
+
/* -----------------------------------------------------------------------------------------------*/ const $c34afbc43c90cc6f$export$2881499e37b75b9a = $c34afbc43c90cc6f$export$f78649fb9ca566b8;
|
|
325
|
+
const $c34afbc43c90cc6f$export$be92b6f5f03c0fe9 = $c34afbc43c90cc6f$export$28c660c63b792dea;
|
|
326
|
+
const $c34afbc43c90cc6f$export$41fb9f06171c75f4 = $c34afbc43c90cc6f$export$8c610744efcf8a1d;
|
|
327
|
+
const $c34afbc43c90cc6f$export$7c6e2c02157bb7d2 = $c34afbc43c90cc6f$export$e9003e2be37ec060;
|
|
328
|
+
const $c34afbc43c90cc6f$export$21b07c8f274aebd5 = $c34afbc43c90cc6f$export$c27ee0ad710f7559;
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
$parcel$exportWildcard(module.exports, $c34afbc43c90cc6f$exports);
|
|
332
|
+
|
|
333
|
+
|
|
2
334
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"IAAgCA,wwBAAAA,8CAClBA,EAAEC,WAAaD,EAAEE,QAAUF,EAWzC,SAASG,EAAuBC,EAAMC,GAcpC,OAbAC,OAAOC,KAAKF,GAAQG,SAAQ,SAASC,GACvB,YAARA,GAA6B,eAARA,GAIzBH,OAAOI,eAAeN,EAAMK,EAAK,CAC/BE,YAAY,EACZC,IAAK,WACH,OAAOP,EAAOI,SAKbL,ECLT,MAAOS,EAAsBC,GAAsBC,EAAmB,UAAW,CAC/EC,iCAEF,MAAMC,EAAiBD,IAOjBE,EAAyB,KAUxBC,EAAgCC,GACrCP,EAZoB,kBAY6C,CAC/DQ,eAAe,EACfC,cAAeJ,EACfK,OAAQ,OACRC,QAAS,SAiBPC,EACJC,IAEA,MAAMC,eACJA,EADIL,cAEJA,EAAgBJ,EAFZU,kBAGJA,EAAoB,IAHhBC,SAIJA,GACEH,GACGL,EAAeS,GAAoBC,EAAMC,UAAS,GACnDC,EAAoBF,EAAMG,OAAO,GAOvC,OALAH,EAAMI,WAAU,KACd,MAAMC,EAAiBH,EAAkBI,QACzC,MAAO,IAAMC,OAAOC,aAAaH,KAChC,iBAGDI,EAAAC,cAACC,EAAD,CACEC,MAAOhB,EACPN,cAAeA,EACfC,cAAeA,EACfC,OAAQQ,EAAMa,aAAY,KACxBN,OAAOC,aAAaN,EAAkBI,SACtCP,GAAiB,KAChB,IACHN,QAASO,EAAMa,aAAY,KACzBN,OAAOC,aAAaN,EAAkBI,SACtCJ,EAAkBI,QAAUC,OAAOO,YACjC,IAAMf,GAAiB,IACvBF,KAED,CAACA,KAEHC,8BAWP,MAaOiB,EAAwBC,GAC7BlC,EAdmB,WA8BfmC,EAAmCtB,IACvC,MAAMC,eACJA,EADIE,SAEJA,EACAoB,KAA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F,MAAAA,OAAH,EAAGA,EAAaG,KAC3BC,EAAsBC,EAAYH,GAClCI,EAAaN,MAAAA,OAAH,EAAGA,EAAaO,IAC1BC,EAAqBH,EAAYC,GACjCG,EAAcrF,EAAQ9B,QAa5B,OAXAO,EAAMI,WAAU,WAGa0D,IAAxByC,GAAqCA,IAAwBF,QACtCvC,IAAvB6C,GAAoCA,IAAuBF,IAG5DG,MAED,CAACA,EAAaL,EAAqBI,EAAoBN,EAAaI,IAEhE,4BAGT,MAAMI,EAAWnH,qBACjB,MAAMkD,EAAO3B,iBACb,MAAM6F,EAAU9D,oBAChB,MAAMyC,EAAUd,oBAChB,MAAMsB,EAAQF","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/react/tooltip/src/Tooltip.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$reexport(e, n, v) {\n Object.defineProperty(e, n, {get: v, enumerable: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\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 { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useEscapeKeydown } from '@radix-ui/react-use-escape-keydown';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useRect } from '@radix-ui/react-use-rect';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as PopperPrimitive from '@radix-ui/react-popper';\nimport { createPopperScope } from '@radix-ui/react-popper';\nimport { Portal } from '@radix-ui/react-portal';\nimport { Slottable } from '@radix-ui/react-slot';\nimport * as VisuallyHiddenPrimitive from '@radix-ui/react-visually-hidden';\nimport { useId } from '@radix-ui/react-id';\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};\n\nconst [TooltipProviderContextProvider, useTooltipProviderContext] =\n createTooltipContext<TooltipProviderContextValue>(PROVIDER_NAME, {\n isOpenDelayed: true,\n delayDuration: DEFAULT_DELAY_DURATION,\n onOpen: () => {},\n onClose: () => {},\n });\n\ninterface TooltipProviderProps {\n /**\n * The duration from when the mouse 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 children: React.ReactNode;\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 children,\n } = props;\n const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);\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 >\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 onOpen(): void;\n onClose(): void;\n};\n\nconst [TooltipContextProvider, useTooltipContext] =\n createTooltipContext<TooltipContextValue>(TOOLTIP_NAME);\n\ninterface TooltipProps {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n\n /**\n * The duration from when the mouse 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 children?: React.ReactNode;\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 delayDuration: delayDurationProp,\n } = props;\n const context = useTooltipProviderContext(TOOLTIP_NAME, __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 delayDuration = delayDurationProp ?? context.delayDuration;\n const wasOpenDelayedRef = React.useRef(false);\n const { onOpen, onClose } = context;\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: (open) => {\n if (open) {\n // we dispatch here so `TooltipProvider` isn't required to\n // ensure other tooltips are aware of this one opening.\n document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));\n onOpen();\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 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 (context.isOpenDelayed) handleDelayedOpen();\n else handleOpen();\n }, [context.isOpenDelayed, handleDelayedOpen, handleOpen])}\n onOpen={React.useCallback(handleOpen, [handleOpen])}\n onClose={React.useCallback(() => {\n window.clearTimeout(openTimerRef.current);\n setOpen(false);\n onClose();\n }, [setOpen, onClose])}\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 popperScope = usePopperScope(__scopeTooltip);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.onTriggerChange);\n const isMouseDownRef = React.useRef(false);\n const handleMouseUp = React.useCallback(() => (isMouseDownRef.current = false), []);\n\n React.useEffect(() => {\n return () => document.removeEventListener('mouseup', handleMouseUp);\n }, [handleMouseUp]);\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={composedTriggerRef}\n onMouseEnter={composeEventHandlers(props.onMouseEnter, context.onTriggerEnter)}\n onMouseLeave={composeEventHandlers(props.onMouseLeave, context.onClose)}\n onMouseDown={composeEventHandlers(props.onMouseDown, () => {\n context.onClose();\n isMouseDownRef.current = true;\n document.addEventListener('mouseup', handleMouseUp, { once: true });\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\n if (!isMouseDownRef.current) context.onOpen();\n })}\n onBlur={composeEventHandlers(props.onBlur, context.onClose)}\n onClick={composeEventHandlers(props.onClick, (event) => {\n // keyboard click will occur under different conditions for different node\n // types so we use `onClick` instead of `onKeyDown` to respect that\n const isKeyboardClick = event.detail === 0;\n if (isKeyboardClick) context.onClose();\n })}\n />\n </PopperPrimitive.Anchor>\n );\n }\n);\n\nTooltipTrigger.displayName = TRIGGER_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 { forceMount, ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);\n return (\n <Presence present={forceMount || context.open}>\n <TooltipContentImpl ref={forwardedRef} {...contentProps} />\n </Presence>\n );\n }\n);\n\ntype TooltipContentImplElement = React.ElementRef<typeof PopperPrimitive.Content>;\ntype PopperContentProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;\ninterface TooltipContentImplProps extends PopperContentProps {\n /**\n * A more descriptive label for accessibility purpose\n */\n 'aria-label'?: string;\n\n /**\n * Whether the Tooltip should render in a Portal\n * (default: `true`)\n */\n portalled?: boolean;\n}\n\nconst TooltipContentImpl = React.forwardRef<TooltipContentImplElement, TooltipContentImplProps>(\n (props: ScopedProps<TooltipContentImplProps>, forwardedRef) => {\n const {\n __scopeTooltip,\n children,\n 'aria-label': ariaLabel,\n portalled = true,\n ...contentProps\n } = props;\n const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);\n const popperScope = usePopperScope(__scopeTooltip);\n const PortalWrapper = portalled ? Portal : React.Fragment;\n const { onClose } = context;\n\n useEscapeKeydown(() => onClose());\n\n React.useEffect(() => {\n // Close this tooltip if another one opens\n document.addEventListener(TOOLTIP_OPEN, onClose);\n return () => document.removeEventListener(TOOLTIP_OPEN, onClose);\n }, [onClose]);\n\n return (\n <PortalWrapper>\n <CheckTriggerMoved __scopeTooltip={__scopeTooltip} />\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 property\n ['--radix-tooltip-content-transform-origin' as any]:\n 'var(--radix-popper-transform-origin)',\n }}\n >\n <Slottable>{children}</Slottable>\n <VisuallyHiddenPrimitive.Root id={context.contentId} role=\"tooltip\">\n {ariaLabel || children}\n </VisuallyHiddenPrimitive.Root>\n </PopperPrimitive.Content>\n </PortalWrapper>\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 return <PopperPrimitive.Arrow {...popperScope} {...arrowProps} ref={forwardedRef} />;\n }\n);\n\nTooltipArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction CheckTriggerMoved(props: ScopedProps<{}>) {\n const { __scopeTooltip } = props;\n const context = useTooltipContext('CheckTriggerMoved', __scopeTooltip);\n\n const triggerRect = useRect(context.trigger);\n const triggerLeft = triggerRect?.left;\n const previousTriggerLeft = usePrevious(triggerLeft);\n const triggerTop = triggerRect?.top;\n const previousTriggerTop = usePrevious(triggerTop);\n const handleClose = context.onClose;\n\n React.useEffect(() => {\n // checking if the user has scrolled…\n const hasTriggerMoved =\n (previousTriggerLeft !== undefined && previousTriggerLeft !== triggerLeft) ||\n (previousTriggerTop !== undefined && previousTriggerTop !== triggerTop);\n\n if (hasTriggerMoved) {\n handleClose();\n }\n }, [handleClose, previousTriggerLeft, previousTriggerTop, triggerLeft, triggerTop]);\n\n return null;\n}\n\nconst Provider = TooltipProvider;\nconst Root = Tooltip;\nconst Trigger = TooltipTrigger;\nconst Content = TooltipContent;\nconst Arrow = TooltipArrow;\n\nexport {\n createTooltipScope,\n //\n TooltipProvider,\n Tooltip,\n TooltipTrigger,\n TooltipContent,\n TooltipArrow,\n //\n Provider,\n Root,\n Trigger,\n Content,\n Arrow,\n};\nexport type { TooltipProps, TooltipTriggerProps, TooltipContentProps, TooltipArrowProps };\n"],"names":["a","__esModule","default","$parcel$exportWildcard","dest","source","Object","keys","forEach","key","defineProperty","enumerable","get","createTooltipContext","createTooltipScope","createContextScope","createPopperScope","usePopperScope","DEFAULT_DELAY_DURATION","TooltipProviderContextProvider","useTooltipProviderContext","isOpenDelayed","delayDuration","onOpen","onClose","TooltipProvider","props","__scopeTooltip","skipDelayDuration","children","setIsOpenDelayed","React","useState","skipDelayTimerRef","useRef","useEffect","skipDelayTimer","current","window","clearTimeout","_react","createElement","$bfd2ef98f93cfd0786881e49eeb6a4$var$TooltipProviderContextProvider","scope","useCallback","setTimeout","TooltipContextProvider","useTooltipContext","Tooltip","open","openProp","defaultOpen","onOpenChange","delayDurationProp","context","popperScope","trigger","setTrigger","contentId","useId","openTimerRef","wasOpenDelayedRef","setOpen","useControllableState","prop","defaultProp","onChange","document","dispatchEvent","CustomEvent","stateAttribute","useMemo","handleOpen","handleDelayedOpen","_radixUiReactPopper","Root","$bfd2ef98f93cfd0786881e49eeb6a4$var$TooltipContextProvider","onTriggerChange","onTriggerEnter","TooltipTrigger","forwardRef","forwardedRef","triggerProps","composedTriggerRef","useComposedRefs","isMouseDownRef","handleMouseUp","removeEventListener","Anchor","_babelRuntimeHelpersExtends","asChild","Primitive","button","undefined","ref","onMouseEnter","composeEventHandlers","onMouseLeave","onMouseDown","addEventListener","once","onFocus","onBlur","onClick","event","detail","TooltipContent","forceMount","contentProps","Presence","present","$bfd2ef98f93cfd0786881e49eeb6a4$var$TooltipContentImpl","TooltipContentImpl","ariaLabel","portalled","PortalWrapper","Portal","Fragment","useEscapeKeydown","$bfd2ef98f93cfd0786881e49eeb6a4$var$CheckTriggerMoved","Content","style","Slottable","_radixUiReactVisuallyHidden","id","role","TooltipArrow","arrowProps","Arrow","CheckTriggerMoved","triggerRect","useRect","triggerLeft","left","previousTriggerLeft","usePrevious","triggerTop","top","previousTriggerTop","handleClose","Provider","Trigger"],"version":3,"file":"index.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;;;;;;;;;;;ACmBA,MAAM,CAACc,0CAAD,EAAuBC,yCAAvB,CAAA,GAA6CZ,6CAAkB,CAAC,SAAD,EAAY;IAC/EI,2CAD+E;CAAZ,CAArE,AAAA;AAGA,MAAMS,oCAAc,GAAGT,2CAAiB,EAAxC,AAAA;AAEA;;oGAEA,CAEA,MAAMU,mCAAa,GAAG,iBAAtB,AAAA;AACA,MAAMC,4CAAsB,GAAG,GAA/B,AAAA;AACA,MAAMC,kCAAY,GAAG,cAArB,AAAA;AASA,MAAM,CAACC,oDAAD,EAAiCC,+CAAjC,CAAA,GACJP,0CAAoB,CAA8BG,mCAA9B,EAA6C;IAC/DK,aAAa,EAAE,IADgD;IAE/DC,aAAa,EAAEL,4CAFgD;IAG/DM,MAAM,EAAE,IAAM,EAHiD;IAI/DC,OAAO,EAAE,IAAM,EAAfA;CAJkB,CADtB,AACmE;AAqBnE,MAAMC,yCAA+C,GACnDC,CAAAA,KADsD,GAEnD;IACH,MAAM,E,gBACJC,cADI,CAAA,iBAEJL,aAAa,GAAGL,4CAFZ,sBAGJW,iBAAiB,GAAG,GAHhB,G,UAIJC,QAAAA,CAAAA,EAJI,GAKFH,KALJ,AAAM;IAMN,MAAM,CAACL,aAAD,EAAgBS,gBAAhB,CAAA,GAAoC/B,qBAAA,CAAe,IAAf,CAA1C,AAAA;IACA,MAAMiC,iBAAiB,GAAGjC,mBAAA,CA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AAW,GAAGpC,oCAAc,CAACY,cAAD,CAAlC,AAAA;IACA,OAAA,aAAO,CAAA,0BAAA,CAAC,+BAAD,EAAA,2DAAA,CAAA,EAAA,EAA2BwB,WAA3B,EAA4C2D,UAA5C,EAAP;QAA+D,GAAG,EAAEvC,YAAL;KAAxD,CAAA,CAAP,CAAO;CAJU,CAArB,AAKG;AAGH,aAAA,CAAA,MAAA,CAAA,MAAA,CAAA,yCAAA,EAAA;IAAA,WAAA,EAAA,gCAAA;CAAA,CAAA,CAAA;AAEA,oGAAA,CAEA,MAAMwC,yCAAQ,GAAGtF,yCAAjB,AAAA;AACA,MAAMuF,yCAAI,GAAGpE,yCAAb,AAAA;AACA,MAAMqE,yCAAO,GAAG5C,yCAAhB,AAAA;AACA,MAAM6C,yCAAO,GAAGtB,yCAAhB,AAAA;AACA,MAAMuB,yCAAK,GAAGN,yCAAd,AAAA;;ADraA","sources":["packages/react/tooltip/src/index.ts","packages/react/tooltip/src/Tooltip.tsx"],"sourcesContent":["export * 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 } 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};\n\nconst [TooltipProviderContextProvider, useTooltipProviderContext] =\n createTooltipContext<TooltipProviderContextValue>(PROVIDER_NAME, {\n isOpenDelayed: true,\n delayDuration: DEFAULT_DELAY_DURATION,\n onOpen: () => {},\n onClose: () => {},\n });\n\ninterface TooltipProviderProps {\n children: React.ReactNode;\n /**\n * The duration from when the mouse 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\nconst TooltipProvider: React.FC<TooltipProviderProps> = (\n props: ScopedProps<TooltipProviderProps>\n) => {\n const {\n __scopeTooltip,\n delayDuration = DEFAULT_DELAY_DURATION,\n skipDelayDuration = 300,\n children,\n } = props;\n const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);\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 >\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 onOpen(): void;\n onClose(): void;\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 /**\n * The duration from when the mouse 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\nconst Tooltip: React.FC<TooltipProps> = (props: ScopedProps<TooltipProps>) => {\n const {\n __scopeTooltip,\n children,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n delayDuration: delayDurationProp,\n } = props;\n const context = useTooltipProviderContext(TOOLTIP_NAME, __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 delayDuration = delayDurationProp ?? context.delayDuration;\n const wasOpenDelayedRef = React.useRef(false);\n const { onOpen, onClose } = context;\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: (open) => {\n if (open) {\n // we dispatch here so `TooltipProvider` isn't required to\n // ensure other tooltips are aware of this one opening.\n document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));\n onOpen();\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 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 (context.isOpenDelayed) handleDelayedOpen();\n else handleOpen();\n }, [context.isOpenDelayed, handleDelayedOpen, handleOpen])}\n onOpen={React.useCallback(handleOpen, [handleOpen])}\n onClose={React.useCallback(() => {\n window.clearTimeout(openTimerRef.current);\n setOpen(false);\n onClose();\n }, [setOpen, onClose])}\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 popperScope = usePopperScope(__scopeTooltip);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.onTriggerChange);\n const isMouseDownRef = React.useRef(false);\n const handleMouseUp = React.useCallback(() => (isMouseDownRef.current = false), []);\n\n React.useEffect(() => {\n return () => document.removeEventListener('mouseup', handleMouseUp);\n }, [handleMouseUp]);\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={composedTriggerRef}\n onMouseEnter={composeEventHandlers(props.onMouseEnter, context.onTriggerEnter)}\n onMouseLeave={composeEventHandlers(props.onMouseLeave, context.onClose)}\n onMouseDown={composeEventHandlers(props.onMouseDown, () => {\n isMouseDownRef.current = true;\n document.addEventListener('mouseup', handleMouseUp, { once: true });\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\n if (!isMouseDownRef.current) context.onOpen();\n })}\n onBlur={composeEventHandlers(props.onBlur, context.onClose)}\n onClick={composeEventHandlers(props.onClick, (event) => {\n // keyboard click will occur under different conditions for different node\n // types so we use `onClick` instead of `onKeyDown` to respect that\n const isKeyboardClick = event.detail === 0;\n if (isKeyboardClick) context.onClose();\n })}\n />\n </PopperPrimitive.Anchor>\n );\n }\n);\n\nTooltipTrigger.displayName = TRIGGER_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 { forceMount, ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);\n return (\n <Presence present={forceMount || context.open}>\n <TooltipContentImpl ref={forwardedRef} {...contentProps} />\n </Presence>\n );\n }\n);\n\ntype TooltipContentImplElement = React.ElementRef<typeof PopperPrimitive.Content>;\ntype DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype PopperContentProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;\ninterface TooltipContentImplProps extends PopperContentProps {\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 /**\n * Whether the Tooltip should render in a Portal\n * (default: `true`)\n */\n portalled?: boolean;\n}\n\nconst TooltipContentImpl = React.forwardRef<TooltipContentImplElement, TooltipContentImplProps>(\n (props: ScopedProps<TooltipContentImplProps>, forwardedRef) => {\n const {\n __scopeTooltip,\n children,\n 'aria-label': ariaLabel,\n portalled = true,\n onEscapeKeyDown,\n onPointerDownOutside,\n ...contentProps\n } = props;\n const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);\n const popperScope = usePopperScope(__scopeTooltip);\n const PortalWrapper = portalled ? Portal : React.Fragment;\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 <PortalWrapper>\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 property\n ['--radix-tooltip-content-transform-origin' as any]:\n 'var(--radix-popper-transform-origin)',\n }}\n >\n <Slottable>{children}</Slottable>\n <VisuallyHiddenPrimitive.Root id={context.contentId} role=\"tooltip\">\n {ariaLabel || children}\n </VisuallyHiddenPrimitive.Root>\n </PopperPrimitive.Content>\n </DismissableLayer>\n </PortalWrapper>\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 return <PopperPrimitive.Arrow {...popperScope} {...arrowProps} ref={forwardedRef} />;\n }\n);\n\nTooltipArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Provider = TooltipProvider;\nconst Root = Tooltip;\nconst Trigger = TooltipTrigger;\nconst Content = TooltipContent;\nconst Arrow = TooltipArrow;\n\nexport {\n createTooltipScope,\n //\n TooltipProvider,\n Tooltip,\n TooltipTrigger,\n TooltipContent,\n TooltipArrow,\n //\n Provider,\n Root,\n Trigger,\n Content,\n Arrow,\n};\nexport type { TooltipProps, TooltipTriggerProps, TooltipContentProps, TooltipArrowProps };\n"],"names":["React","composeEventHandlers","useComposedRefs","createContextScope","DismissableLayer","useId","PopperPrimitive","createPopperScope","Portal","Presence","Primitive","Slottable","useControllableState","VisuallyHiddenPrimitive","createTooltipContext","createTooltipScope","usePopperScope","PROVIDER_NAME","DEFAULT_DELAY_DURATION","TOOLTIP_OPEN","TooltipProviderContextProvider","useTooltipProviderContext","isOpenDelayed","delayDuration","onOpen","onClose","TooltipProvider","props","__scopeTooltip","skipDelayDuration","children","setIsOpenDelayed","useState","skipDelayTimerRef","useRef","useEffect","skipDelayTimer","current","window","clearTimeout","useCallback","setTimeout","TOOLTIP_NAME","TooltipContextProvider","useTooltipContext","Tooltip","open","openProp","defaultOpen","onOpenChange","delayDurationProp","context","popperScope","trigger","setTrigger","contentId","openTimerRef","wasOpenDelayedRef","setOpen","prop","defaultProp","onChange","document","dispatchEvent","CustomEvent","stateAttribute","useMemo","handleOpen","handleDelayedOpen","TRIGGER_NAME","TooltipTrigger","forwardRef","forwardedRef","triggerProps","composedTriggerRef","onTriggerChange","isMouseDownRef","handleMouseUp","removeEventListener","undefined","onMouseEnter","onTriggerEnter","onMouseLeave","onMouseDown","addEventListener","once","onFocus","onBlur","onClick","event","isKeyboardClick","detail","CONTENT_NAME","TooltipContent","forceMount","contentProps","TooltipContentImpl","ariaLabel","portalled","onEscapeKeyDown","onPointerDownOutside","PortalWrapper","Fragment","handleScroll","target","contains","capture","preventDefault","style","ARROW_NAME","TooltipArrow","arrowProps","Provider","Root","Trigger","Content","Arrow"],"version":3,"file":"index.js.map"}
|
package/dist/index.module.js
CHANGED
|
@@ -1,2 +1,315 @@
|
|
|
1
|
-
import
|
|
1
|
+
import $8wepK$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import {useState as $8wepK$useState, useRef as $8wepK$useRef, useEffect as $8wepK$useEffect, createElement as $8wepK$createElement, useCallback as $8wepK$useCallback, useMemo as $8wepK$useMemo, forwardRef as $8wepK$forwardRef, Fragment as $8wepK$Fragment} from "react";
|
|
3
|
+
import {composeEventHandlers as $8wepK$composeEventHandlers} from "@radix-ui/primitive";
|
|
4
|
+
import {useComposedRefs as $8wepK$useComposedRefs} from "@radix-ui/react-compose-refs";
|
|
5
|
+
import {createContextScope as $8wepK$createContextScope} from "@radix-ui/react-context";
|
|
6
|
+
import {DismissableLayer as $8wepK$DismissableLayer} from "@radix-ui/react-dismissable-layer";
|
|
7
|
+
import {useId as $8wepK$useId} from "@radix-ui/react-id";
|
|
8
|
+
import {createPopperScope as $8wepK$createPopperScope, Root as $8wepK$Root, Anchor as $8wepK$Anchor, Content as $8wepK$Content, Arrow as $8wepK$Arrow} from "@radix-ui/react-popper";
|
|
9
|
+
import {Portal as $8wepK$Portal} from "@radix-ui/react-portal";
|
|
10
|
+
import {Presence as $8wepK$Presence} from "@radix-ui/react-presence";
|
|
11
|
+
import {Primitive as $8wepK$Primitive} from "@radix-ui/react-primitive";
|
|
12
|
+
import {Slottable as $8wepK$Slottable} from "@radix-ui/react-slot";
|
|
13
|
+
import {useControllableState as $8wepK$useControllableState} from "@radix-ui/react-use-controllable-state";
|
|
14
|
+
import {Root as $8wepK$Root1} from "@radix-ui/react-visually-hidden";
|
|
15
|
+
|
|
16
|
+
function $parcel$export(e, n, v, s) {
|
|
17
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
18
|
+
}
|
|
19
|
+
var $a093c7e1ec25a057$exports = {};
|
|
20
|
+
|
|
21
|
+
$parcel$export($a093c7e1ec25a057$exports, "createTooltipScope", () => $a093c7e1ec25a057$export$1c540a2224f0d865);
|
|
22
|
+
$parcel$export($a093c7e1ec25a057$exports, "TooltipProvider", () => $a093c7e1ec25a057$export$f78649fb9ca566b8);
|
|
23
|
+
$parcel$export($a093c7e1ec25a057$exports, "Tooltip", () => $a093c7e1ec25a057$export$28c660c63b792dea);
|
|
24
|
+
$parcel$export($a093c7e1ec25a057$exports, "TooltipTrigger", () => $a093c7e1ec25a057$export$8c610744efcf8a1d);
|
|
25
|
+
$parcel$export($a093c7e1ec25a057$exports, "TooltipContent", () => $a093c7e1ec25a057$export$e9003e2be37ec060);
|
|
26
|
+
$parcel$export($a093c7e1ec25a057$exports, "TooltipArrow", () => $a093c7e1ec25a057$export$c27ee0ad710f7559);
|
|
27
|
+
$parcel$export($a093c7e1ec25a057$exports, "Provider", () => $a093c7e1ec25a057$export$2881499e37b75b9a);
|
|
28
|
+
$parcel$export($a093c7e1ec25a057$exports, "Root", () => $a093c7e1ec25a057$export$be92b6f5f03c0fe9);
|
|
29
|
+
$parcel$export($a093c7e1ec25a057$exports, "Trigger", () => $a093c7e1ec25a057$export$41fb9f06171c75f4);
|
|
30
|
+
$parcel$export($a093c7e1ec25a057$exports, "Content", () => $a093c7e1ec25a057$export$7c6e2c02157bb7d2);
|
|
31
|
+
$parcel$export($a093c7e1ec25a057$exports, "Arrow", () => $a093c7e1ec25a057$export$21b07c8f274aebd5);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const [$a093c7e1ec25a057$var$createTooltipContext, $a093c7e1ec25a057$export$1c540a2224f0d865] = $8wepK$createContextScope('Tooltip', [
|
|
48
|
+
$8wepK$createPopperScope
|
|
49
|
+
]);
|
|
50
|
+
const $a093c7e1ec25a057$var$usePopperScope = $8wepK$createPopperScope();
|
|
51
|
+
/* -------------------------------------------------------------------------------------------------
|
|
52
|
+
* TooltipProvider
|
|
53
|
+
* -----------------------------------------------------------------------------------------------*/ const $a093c7e1ec25a057$var$PROVIDER_NAME = 'TooltipProvider';
|
|
54
|
+
const $a093c7e1ec25a057$var$DEFAULT_DELAY_DURATION = 700;
|
|
55
|
+
const $a093c7e1ec25a057$var$TOOLTIP_OPEN = 'tooltip.open';
|
|
56
|
+
const [$a093c7e1ec25a057$var$TooltipProviderContextProvider, $a093c7e1ec25a057$var$useTooltipProviderContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$PROVIDER_NAME, {
|
|
57
|
+
isOpenDelayed: true,
|
|
58
|
+
delayDuration: $a093c7e1ec25a057$var$DEFAULT_DELAY_DURATION,
|
|
59
|
+
onOpen: ()=>{},
|
|
60
|
+
onClose: ()=>{}
|
|
61
|
+
});
|
|
62
|
+
const $a093c7e1ec25a057$export$f78649fb9ca566b8 = (props)=>{
|
|
63
|
+
const { __scopeTooltip: __scopeTooltip , delayDuration: delayDuration = $a093c7e1ec25a057$var$DEFAULT_DELAY_DURATION , skipDelayDuration: skipDelayDuration = 300 , children: children } = props;
|
|
64
|
+
const [isOpenDelayed, setIsOpenDelayed] = $8wepK$useState(true);
|
|
65
|
+
const skipDelayTimerRef = $8wepK$useRef(0);
|
|
66
|
+
$8wepK$useEffect(()=>{
|
|
67
|
+
const skipDelayTimer = skipDelayTimerRef.current;
|
|
68
|
+
return ()=>window.clearTimeout(skipDelayTimer)
|
|
69
|
+
;
|
|
70
|
+
}, []);
|
|
71
|
+
return /*#__PURE__*/ $8wepK$createElement($a093c7e1ec25a057$var$TooltipProviderContextProvider, {
|
|
72
|
+
scope: __scopeTooltip,
|
|
73
|
+
isOpenDelayed: isOpenDelayed,
|
|
74
|
+
delayDuration: delayDuration,
|
|
75
|
+
onOpen: $8wepK$useCallback(()=>{
|
|
76
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
77
|
+
setIsOpenDelayed(false);
|
|
78
|
+
}, []),
|
|
79
|
+
onClose: $8wepK$useCallback(()=>{
|
|
80
|
+
window.clearTimeout(skipDelayTimerRef.current);
|
|
81
|
+
skipDelayTimerRef.current = window.setTimeout(()=>setIsOpenDelayed(true)
|
|
82
|
+
, skipDelayDuration);
|
|
83
|
+
}, [
|
|
84
|
+
skipDelayDuration
|
|
85
|
+
])
|
|
86
|
+
}, children);
|
|
87
|
+
};
|
|
88
|
+
/*#__PURE__*/ Object.assign($a093c7e1ec25a057$export$f78649fb9ca566b8, {
|
|
89
|
+
displayName: $a093c7e1ec25a057$var$PROVIDER_NAME
|
|
90
|
+
});
|
|
91
|
+
/* -------------------------------------------------------------------------------------------------
|
|
92
|
+
* Tooltip
|
|
93
|
+
* -----------------------------------------------------------------------------------------------*/ const $a093c7e1ec25a057$var$TOOLTIP_NAME = 'Tooltip';
|
|
94
|
+
const [$a093c7e1ec25a057$var$TooltipContextProvider, $a093c7e1ec25a057$var$useTooltipContext] = $a093c7e1ec25a057$var$createTooltipContext($a093c7e1ec25a057$var$TOOLTIP_NAME);
|
|
95
|
+
const $a093c7e1ec25a057$export$28c660c63b792dea = (props)=>{
|
|
96
|
+
const { __scopeTooltip: __scopeTooltip , children: children , open: openProp , defaultOpen: defaultOpen = false , onOpenChange: onOpenChange , delayDuration: delayDurationProp } = props;
|
|
97
|
+
const context = $a093c7e1ec25a057$var$useTooltipProviderContext($a093c7e1ec25a057$var$TOOLTIP_NAME, __scopeTooltip);
|
|
98
|
+
const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
|
|
99
|
+
const [trigger, setTrigger] = $8wepK$useState(null);
|
|
100
|
+
const contentId = $8wepK$useId();
|
|
101
|
+
const openTimerRef = $8wepK$useRef(0);
|
|
102
|
+
const delayDuration = delayDurationProp !== null && delayDurationProp !== void 0 ? delayDurationProp : context.delayDuration;
|
|
103
|
+
const wasOpenDelayedRef = $8wepK$useRef(false);
|
|
104
|
+
const { onOpen: onOpen , onClose: onClose } = context;
|
|
105
|
+
const [open1 = false, setOpen] = $8wepK$useControllableState({
|
|
106
|
+
prop: openProp,
|
|
107
|
+
defaultProp: defaultOpen,
|
|
108
|
+
onChange: (open)=>{
|
|
109
|
+
if (open) {
|
|
110
|
+
// we dispatch here so `TooltipProvider` isn't required to
|
|
111
|
+
// ensure other tooltips are aware of this one opening.
|
|
112
|
+
document.dispatchEvent(new CustomEvent($a093c7e1ec25a057$var$TOOLTIP_OPEN));
|
|
113
|
+
onOpen();
|
|
114
|
+
}
|
|
115
|
+
onOpenChange === null || onOpenChange === void 0 || onOpenChange(open);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const stateAttribute = $8wepK$useMemo(()=>{
|
|
119
|
+
return open1 ? wasOpenDelayedRef.current ? 'delayed-open' : 'instant-open' : 'closed';
|
|
120
|
+
}, [
|
|
121
|
+
open1
|
|
122
|
+
]);
|
|
123
|
+
const handleOpen = $8wepK$useCallback(()=>{
|
|
124
|
+
window.clearTimeout(openTimerRef.current);
|
|
125
|
+
wasOpenDelayedRef.current = false;
|
|
126
|
+
setOpen(true);
|
|
127
|
+
}, [
|
|
128
|
+
setOpen
|
|
129
|
+
]);
|
|
130
|
+
const handleDelayedOpen = $8wepK$useCallback(()=>{
|
|
131
|
+
window.clearTimeout(openTimerRef.current);
|
|
132
|
+
openTimerRef.current = window.setTimeout(()=>{
|
|
133
|
+
wasOpenDelayedRef.current = true;
|
|
134
|
+
setOpen(true);
|
|
135
|
+
}, delayDuration);
|
|
136
|
+
}, [
|
|
137
|
+
delayDuration,
|
|
138
|
+
setOpen
|
|
139
|
+
]);
|
|
140
|
+
$8wepK$useEffect(()=>{
|
|
141
|
+
return ()=>window.clearTimeout(openTimerRef.current)
|
|
142
|
+
;
|
|
143
|
+
}, []);
|
|
144
|
+
return /*#__PURE__*/ $8wepK$createElement($8wepK$Root, popperScope, /*#__PURE__*/ $8wepK$createElement($a093c7e1ec25a057$var$TooltipContextProvider, {
|
|
145
|
+
scope: __scopeTooltip,
|
|
146
|
+
contentId: contentId,
|
|
147
|
+
open: open1,
|
|
148
|
+
stateAttribute: stateAttribute,
|
|
149
|
+
trigger: trigger,
|
|
150
|
+
onTriggerChange: setTrigger,
|
|
151
|
+
onTriggerEnter: $8wepK$useCallback(()=>{
|
|
152
|
+
if (context.isOpenDelayed) handleDelayedOpen();
|
|
153
|
+
else handleOpen();
|
|
154
|
+
}, [
|
|
155
|
+
context.isOpenDelayed,
|
|
156
|
+
handleDelayedOpen,
|
|
157
|
+
handleOpen
|
|
158
|
+
]),
|
|
159
|
+
onOpen: $8wepK$useCallback(handleOpen, [
|
|
160
|
+
handleOpen
|
|
161
|
+
]),
|
|
162
|
+
onClose: $8wepK$useCallback(()=>{
|
|
163
|
+
window.clearTimeout(openTimerRef.current);
|
|
164
|
+
setOpen(false);
|
|
165
|
+
onClose();
|
|
166
|
+
}, [
|
|
167
|
+
setOpen,
|
|
168
|
+
onClose
|
|
169
|
+
])
|
|
170
|
+
}, children));
|
|
171
|
+
};
|
|
172
|
+
/*#__PURE__*/ Object.assign($a093c7e1ec25a057$export$28c660c63b792dea, {
|
|
173
|
+
displayName: $a093c7e1ec25a057$var$TOOLTIP_NAME
|
|
174
|
+
});
|
|
175
|
+
/* -------------------------------------------------------------------------------------------------
|
|
176
|
+
* TooltipTrigger
|
|
177
|
+
* -----------------------------------------------------------------------------------------------*/ const $a093c7e1ec25a057$var$TRIGGER_NAME = 'TooltipTrigger';
|
|
178
|
+
const $a093c7e1ec25a057$export$8c610744efcf8a1d = /*#__PURE__*/ $8wepK$forwardRef((props, forwardedRef)=>{
|
|
179
|
+
const { __scopeTooltip: __scopeTooltip , ...triggerProps } = props;
|
|
180
|
+
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$TRIGGER_NAME, __scopeTooltip);
|
|
181
|
+
const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
|
|
182
|
+
const composedTriggerRef = $8wepK$useComposedRefs(forwardedRef, context.onTriggerChange);
|
|
183
|
+
const isMouseDownRef = $8wepK$useRef(false);
|
|
184
|
+
const handleMouseUp = $8wepK$useCallback(()=>isMouseDownRef.current = false
|
|
185
|
+
, []);
|
|
186
|
+
$8wepK$useEffect(()=>{
|
|
187
|
+
return ()=>document.removeEventListener('mouseup', handleMouseUp)
|
|
188
|
+
;
|
|
189
|
+
}, [
|
|
190
|
+
handleMouseUp
|
|
191
|
+
]);
|
|
192
|
+
return /*#__PURE__*/ $8wepK$createElement($8wepK$Anchor, $8wepK$babelruntimehelpersesmextends({
|
|
193
|
+
asChild: true
|
|
194
|
+
}, popperScope), /*#__PURE__*/ $8wepK$createElement($8wepK$Primitive.button, $8wepK$babelruntimehelpersesmextends({
|
|
195
|
+
// We purposefully avoid adding `type=button` here because tooltip triggers are also
|
|
196
|
+
// commonly anchors and the anchor `type` attribute signifies MIME type.
|
|
197
|
+
"aria-describedby": context.open ? context.contentId : undefined,
|
|
198
|
+
"data-state": context.stateAttribute
|
|
199
|
+
}, triggerProps, {
|
|
200
|
+
ref: composedTriggerRef,
|
|
201
|
+
onMouseEnter: $8wepK$composeEventHandlers(props.onMouseEnter, context.onTriggerEnter),
|
|
202
|
+
onMouseLeave: $8wepK$composeEventHandlers(props.onMouseLeave, context.onClose),
|
|
203
|
+
onMouseDown: $8wepK$composeEventHandlers(props.onMouseDown, ()=>{
|
|
204
|
+
isMouseDownRef.current = true;
|
|
205
|
+
document.addEventListener('mouseup', handleMouseUp, {
|
|
206
|
+
once: true
|
|
207
|
+
});
|
|
208
|
+
}),
|
|
209
|
+
onFocus: $8wepK$composeEventHandlers(props.onFocus, ()=>{
|
|
210
|
+
if (!isMouseDownRef.current) context.onOpen();
|
|
211
|
+
}),
|
|
212
|
+
onBlur: $8wepK$composeEventHandlers(props.onBlur, context.onClose),
|
|
213
|
+
onClick: $8wepK$composeEventHandlers(props.onClick, (event)=>{
|
|
214
|
+
// keyboard click will occur under different conditions for different node
|
|
215
|
+
// types so we use `onClick` instead of `onKeyDown` to respect that
|
|
216
|
+
const isKeyboardClick = event.detail === 0;
|
|
217
|
+
if (isKeyboardClick) context.onClose();
|
|
218
|
+
})
|
|
219
|
+
})));
|
|
220
|
+
});
|
|
221
|
+
/*#__PURE__*/ Object.assign($a093c7e1ec25a057$export$8c610744efcf8a1d, {
|
|
222
|
+
displayName: $a093c7e1ec25a057$var$TRIGGER_NAME
|
|
223
|
+
});
|
|
224
|
+
/* -------------------------------------------------------------------------------------------------
|
|
225
|
+
* TooltipContent
|
|
226
|
+
* -----------------------------------------------------------------------------------------------*/ const $a093c7e1ec25a057$var$CONTENT_NAME = 'TooltipContent';
|
|
227
|
+
const $a093c7e1ec25a057$export$e9003e2be37ec060 = /*#__PURE__*/ $8wepK$forwardRef((props, forwardedRef)=>{
|
|
228
|
+
const { forceMount: forceMount , ...contentProps } = props;
|
|
229
|
+
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, props.__scopeTooltip);
|
|
230
|
+
return /*#__PURE__*/ $8wepK$createElement($8wepK$Presence, {
|
|
231
|
+
present: forceMount || context.open
|
|
232
|
+
}, /*#__PURE__*/ $8wepK$createElement($a093c7e1ec25a057$var$TooltipContentImpl, $8wepK$babelruntimehelpersesmextends({
|
|
233
|
+
ref: forwardedRef
|
|
234
|
+
}, contentProps)));
|
|
235
|
+
});
|
|
236
|
+
const $a093c7e1ec25a057$var$TooltipContentImpl = /*#__PURE__*/ $8wepK$forwardRef((props, forwardedRef)=>{
|
|
237
|
+
const { __scopeTooltip: __scopeTooltip , children: children , 'aria-label': ariaLabel , portalled: portalled = true , onEscapeKeyDown: onEscapeKeyDown , onPointerDownOutside: onPointerDownOutside , ...contentProps } = props;
|
|
238
|
+
const context = $a093c7e1ec25a057$var$useTooltipContext($a093c7e1ec25a057$var$CONTENT_NAME, __scopeTooltip);
|
|
239
|
+
const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
|
|
240
|
+
const PortalWrapper = portalled ? $8wepK$Portal : $8wepK$Fragment;
|
|
241
|
+
const { onClose: onClose } = context; // Close this tooltip if another one opens
|
|
242
|
+
$8wepK$useEffect(()=>{
|
|
243
|
+
document.addEventListener($a093c7e1ec25a057$var$TOOLTIP_OPEN, onClose);
|
|
244
|
+
return ()=>document.removeEventListener($a093c7e1ec25a057$var$TOOLTIP_OPEN, onClose)
|
|
245
|
+
;
|
|
246
|
+
}, [
|
|
247
|
+
onClose
|
|
248
|
+
]); // Close the tooltip if the trigger is scrolled
|
|
249
|
+
$8wepK$useEffect(()=>{
|
|
250
|
+
if (context.trigger) {
|
|
251
|
+
const handleScroll = (event)=>{
|
|
252
|
+
const target = event.target;
|
|
253
|
+
if (target !== null && target !== void 0 && target.contains(context.trigger)) onClose();
|
|
254
|
+
};
|
|
255
|
+
window.addEventListener('scroll', handleScroll, {
|
|
256
|
+
capture: true
|
|
257
|
+
});
|
|
258
|
+
return ()=>window.removeEventListener('scroll', handleScroll, {
|
|
259
|
+
capture: true
|
|
260
|
+
})
|
|
261
|
+
;
|
|
262
|
+
}
|
|
263
|
+
}, [
|
|
264
|
+
context.trigger,
|
|
265
|
+
onClose
|
|
266
|
+
]);
|
|
267
|
+
return /*#__PURE__*/ $8wepK$createElement(PortalWrapper, null, /*#__PURE__*/ $8wepK$createElement($8wepK$DismissableLayer, {
|
|
268
|
+
asChild: true,
|
|
269
|
+
disableOutsidePointerEvents: false,
|
|
270
|
+
onEscapeKeyDown: onEscapeKeyDown,
|
|
271
|
+
onPointerDownOutside: onPointerDownOutside,
|
|
272
|
+
onFocusOutside: (event)=>event.preventDefault()
|
|
273
|
+
,
|
|
274
|
+
onDismiss: onClose
|
|
275
|
+
}, /*#__PURE__*/ $8wepK$createElement($8wepK$Content, $8wepK$babelruntimehelpersesmextends({
|
|
276
|
+
"data-state": context.stateAttribute
|
|
277
|
+
}, popperScope, contentProps, {
|
|
278
|
+
ref: forwardedRef,
|
|
279
|
+
style: {
|
|
280
|
+
...contentProps.style,
|
|
281
|
+
// re-namespace exposed content custom property
|
|
282
|
+
['--radix-tooltip-content-transform-origin']: 'var(--radix-popper-transform-origin)'
|
|
283
|
+
}
|
|
284
|
+
}), /*#__PURE__*/ $8wepK$createElement($8wepK$Slottable, null, children), /*#__PURE__*/ $8wepK$createElement($8wepK$Root1, {
|
|
285
|
+
id: context.contentId,
|
|
286
|
+
role: "tooltip"
|
|
287
|
+
}, ariaLabel || children))));
|
|
288
|
+
});
|
|
289
|
+
/*#__PURE__*/ Object.assign($a093c7e1ec25a057$export$e9003e2be37ec060, {
|
|
290
|
+
displayName: $a093c7e1ec25a057$var$CONTENT_NAME
|
|
291
|
+
});
|
|
292
|
+
/* -------------------------------------------------------------------------------------------------
|
|
293
|
+
* TooltipArrow
|
|
294
|
+
* -----------------------------------------------------------------------------------------------*/ const $a093c7e1ec25a057$var$ARROW_NAME = 'TooltipArrow';
|
|
295
|
+
const $a093c7e1ec25a057$export$c27ee0ad710f7559 = /*#__PURE__*/ $8wepK$forwardRef((props, forwardedRef)=>{
|
|
296
|
+
const { __scopeTooltip: __scopeTooltip , ...arrowProps } = props;
|
|
297
|
+
const popperScope = $a093c7e1ec25a057$var$usePopperScope(__scopeTooltip);
|
|
298
|
+
return /*#__PURE__*/ $8wepK$createElement($8wepK$Arrow, $8wepK$babelruntimehelpersesmextends({}, popperScope, arrowProps, {
|
|
299
|
+
ref: forwardedRef
|
|
300
|
+
}));
|
|
301
|
+
});
|
|
302
|
+
/*#__PURE__*/ Object.assign($a093c7e1ec25a057$export$c27ee0ad710f7559, {
|
|
303
|
+
displayName: $a093c7e1ec25a057$var$ARROW_NAME
|
|
304
|
+
});
|
|
305
|
+
/* -----------------------------------------------------------------------------------------------*/ const $a093c7e1ec25a057$export$2881499e37b75b9a = $a093c7e1ec25a057$export$f78649fb9ca566b8;
|
|
306
|
+
const $a093c7e1ec25a057$export$be92b6f5f03c0fe9 = $a093c7e1ec25a057$export$28c660c63b792dea;
|
|
307
|
+
const $a093c7e1ec25a057$export$41fb9f06171c75f4 = $a093c7e1ec25a057$export$8c610744efcf8a1d;
|
|
308
|
+
const $a093c7e1ec25a057$export$7c6e2c02157bb7d2 = $a093c7e1ec25a057$export$e9003e2be37ec060;
|
|
309
|
+
const $a093c7e1ec25a057$export$21b07c8f274aebd5 = $a093c7e1ec25a057$export$c27ee0ad710f7559;
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
export {$a093c7e1ec25a057$export$1c540a2224f0d865 as createTooltipScope, $a093c7e1ec25a057$export$f78649fb9ca566b8 as TooltipProvider, $a093c7e1ec25a057$export$28c660c63b792dea as Tooltip, $a093c7e1ec25a057$export$8c610744efcf8a1d as TooltipTrigger, $a093c7e1ec25a057$export$e9003e2be37ec060 as TooltipContent, $a093c7e1ec25a057$export$c27ee0ad710f7559 as TooltipArrow, $a093c7e1ec25a057$export$2881499e37b75b9a as Provider, $a093c7e1ec25a057$export$be92b6f5f03c0fe9 as Root, $a093c7e1ec25a057$export$41fb9f06171c75f4 as Trigger, $a093c7e1ec25a057$export$7c6e2c02157bb7d2 as Content, $a093c7e1ec25a057$export$21b07c8f274aebd5 as Arrow};
|
|
2
315
|
//# sourceMappingURL=index.module.js.map
|
package/dist/index.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"+4BAqBA,MAAOA,EAAsBC,GAAsBC,EAAmB,UAAW,CAC/EC,oCAEF,MAAMC,EAAiBD,IAOjBE,EAAyB,KAUxBC,EAAgCC,GACrCP,EAZoB,kBAY6C,CAC/DQ,eAAe,EACfC,cAAeJ,EACfK,OAAQ,OACRC,QAAS,gBAiBb,MAAMC,gBACJC,IAEA,MAAMC,eACJA,EADIL,cAEJA,EAAgBJ,EAFZU,kBAGJA,EAAoB,IAHhBC,SAIJA,GACEH,GACGL,EAAeS,GAAoBC,EAAMC,UAAS,GACnDC,EAAoBF,EAAMG,OAAO,GAOvC,OALAH,EAAMI,WAAU,KACd,MAAMC,EAAiBH,EAAkBI,QACzC,MAAO,IAAMC,OAAOC,aAAaH,KAChC,iBAGDI,EAAAC,cAACC,EAAD,CACEC,MAAOhB,EACPN,cAAeA,EACfC,cAAeA,EACfC,OAAQQ,EAAMa,aAAY,KACxBN,OAAOC,aAAaN,EAAkBI,SACtCP,GAAiB,KAChB,IACHN,QAASO,EAAMa,aAAY,KACzBN,OAAOC,aAAaN,EAAkBI,SACtCJ,EAAkBI,QAAUC,OAAOO,YACjC,IAAMf,GAAiB,IACvBF,KAED,CAACA,KAEHC,iBAWP,MAa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vG,GACzB,MAAMC,eAAEA,GAAmBD,EACrB4B,EAAUP,EAAkB,oBAAqBpB,GAEjDuG,EAAcC,EAAQ7E,EAAQE,SAC9B4E,EAAcF,MAAAA,OAAH,EAAGA,EAAaG,KAC3BC,EAAsBC,EAAYH,GAClCI,EAAaN,MAAAA,OAAH,EAAGA,EAAaO,IAC1BC,EAAqBH,EAAYC,GACjCG,EAAcrF,EAAQ9B,QAa5B,OAXAO,EAAMI,WAAU,WAGa0D,IAAxByC,GAAqCA,IAAwBF,QACtCvC,IAAvB6C,GAAoCA,IAAuBF,IAG5DG,MAED,CAACA,EAAaL,EAAqBI,EAAoBN,EAAaI,IAEhE,YAGT,MAAMI,SAAWnH,uBACjB,MAAMkD,KAAO3B,eACb,MAAM6F,QAAU9D,sBAChB,MAAMyC,QAAUd,sBAChB,MAAMsB,MAAQF","sources":["./packages/react/tooltip/src/Tooltip.tsx"],"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 { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport { useEscapeKeydown } from '@radix-ui/react-use-escape-keydown';\nimport { usePrevious } from '@radix-ui/react-use-previous';\nimport { useRect } from '@radix-ui/react-use-rect';\nimport { Presence } from '@radix-ui/react-presence';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport * as PopperPrimitive from '@radix-ui/react-popper';\nimport { createPopperScope } from '@radix-ui/react-popper';\nimport { Portal } from '@radix-ui/react-portal';\nimport { Slottable } from '@radix-ui/react-slot';\nimport * as VisuallyHiddenPrimitive from '@radix-ui/react-visually-hidden';\nimport { useId } from '@radix-ui/react-id';\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};\n\nconst [TooltipProviderContextProvider, useTooltipProviderContext] =\n createTooltipContext<TooltipProviderContextValue>(PROVIDER_NAME, {\n isOpenDelayed: true,\n delayDuration: DEFAULT_DELAY_DURATION,\n onOpen: () => {},\n onClose: () => {},\n });\n\ninterface TooltipProviderProps {\n /**\n * The duration from when the mouse 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 children: React.ReactNode;\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 children,\n } = props;\n const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);\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 >\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 onOpen(): void;\n onClose(): void;\n};\n\nconst [TooltipContextProvider, useTooltipContext] =\n createTooltipContext<TooltipContextValue>(TOOLTIP_NAME);\n\ninterface TooltipProps {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n\n /**\n * The duration from when the mouse 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 children?: React.ReactNode;\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 delayDuration: delayDurationProp,\n } = props;\n const context = useTooltipProviderContext(TOOLTIP_NAME, __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 delayDuration = delayDurationProp ?? context.delayDuration;\n const wasOpenDelayedRef = React.useRef(false);\n const { onOpen, onClose } = context;\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: (open) => {\n if (open) {\n // we dispatch here so `TooltipProvider` isn't required to\n // ensure other tooltips are aware of this one opening.\n document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));\n onOpen();\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 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 (context.isOpenDelayed) handleDelayedOpen();\n else handleOpen();\n }, [context.isOpenDelayed, handleDelayedOpen, handleOpen])}\n onOpen={React.useCallback(handleOpen, [handleOpen])}\n onClose={React.useCallback(() => {\n window.clearTimeout(openTimerRef.current);\n setOpen(false);\n onClose();\n }, [setOpen, onClose])}\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 popperScope = usePopperScope(__scopeTooltip);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.onTriggerChange);\n const isMouseDownRef = React.useRef(false);\n const handleMouseUp = React.useCallback(() => (isMouseDownRef.current = false), []);\n\n React.useEffect(() => {\n return () => document.removeEventListener('mouseup', handleMouseUp);\n }, [handleMouseUp]);\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={composedTriggerRef}\n onMouseEnter={composeEventHandlers(props.onMouseEnter, context.onTriggerEnter)}\n onMouseLeave={composeEventHandlers(props.onMouseLeave, context.onClose)}\n onMouseDown={composeEventHandlers(props.onMouseDown, () => {\n context.onClose();\n isMouseDownRef.current = true;\n document.addEventListener('mouseup', handleMouseUp, { once: true });\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\n if (!isMouseDownRef.current) context.onOpen();\n })}\n onBlur={composeEventHandlers(props.onBlur, context.onClose)}\n onClick={composeEventHandlers(props.onClick, (event) => {\n // keyboard click will occur under different conditions for different node\n // types so we use `onClick` instead of `onKeyDown` to respect that\n const isKeyboardClick = event.detail === 0;\n if (isKeyboardClick) context.onClose();\n })}\n />\n </PopperPrimitive.Anchor>\n );\n }\n);\n\nTooltipTrigger.displayName = TRIGGER_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 { forceMount, ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);\n return (\n <Presence present={forceMount || context.open}>\n <TooltipContentImpl ref={forwardedRef} {...contentProps} />\n </Presence>\n );\n }\n);\n\ntype TooltipContentImplElement = React.ElementRef<typeof PopperPrimitive.Content>;\ntype PopperContentProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;\ninterface TooltipContentImplProps extends PopperContentProps {\n /**\n * A more descriptive label for accessibility purpose\n */\n 'aria-label'?: string;\n\n /**\n * Whether the Tooltip should render in a Portal\n * (default: `true`)\n */\n portalled?: boolean;\n}\n\nconst TooltipContentImpl = React.forwardRef<TooltipContentImplElement, TooltipContentImplProps>(\n (props: ScopedProps<TooltipContentImplProps>, forwardedRef) => {\n const {\n __scopeTooltip,\n children,\n 'aria-label': ariaLabel,\n portalled = true,\n ...contentProps\n } = props;\n const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);\n const popperScope = usePopperScope(__scopeTooltip);\n const PortalWrapper = portalled ? Portal : React.Fragment;\n const { onClose } = context;\n\n useEscapeKeydown(() => onClose());\n\n React.useEffect(() => {\n // Close this tooltip if another one opens\n document.addEventListener(TOOLTIP_OPEN, onClose);\n return () => document.removeEventListener(TOOLTIP_OPEN, onClose);\n }, [onClose]);\n\n return (\n <PortalWrapper>\n <CheckTriggerMoved __scopeTooltip={__scopeTooltip} />\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 property\n ['--radix-tooltip-content-transform-origin' as any]:\n 'var(--radix-popper-transform-origin)',\n }}\n >\n <Slottable>{children}</Slottable>\n <VisuallyHiddenPrimitive.Root id={context.contentId} role=\"tooltip\">\n {ariaLabel || children}\n </VisuallyHiddenPrimitive.Root>\n </PopperPrimitive.Content>\n </PortalWrapper>\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 return <PopperPrimitive.Arrow {...popperScope} {...arrowProps} ref={forwardedRef} />;\n }\n);\n\nTooltipArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction CheckTriggerMoved(props: ScopedProps<{}>) {\n const { __scopeTooltip } = props;\n const context = useTooltipContext('CheckTriggerMoved', __scopeTooltip);\n\n const triggerRect = useRect(context.trigger);\n const triggerLeft = triggerRect?.left;\n const previousTriggerLeft = usePrevious(triggerLeft);\n const triggerTop = triggerRect?.top;\n const previousTriggerTop = usePrevious(triggerTop);\n const handleClose = context.onClose;\n\n React.useEffect(() => {\n // checking if the user has scrolled…\n const hasTriggerMoved =\n (previousTriggerLeft !== undefined && previousTriggerLeft !== triggerLeft) ||\n (previousTriggerTop !== undefined && previousTriggerTop !== triggerTop);\n\n if (hasTriggerMoved) {\n handleClose();\n }\n }, [handleClose, previousTriggerLeft, previousTriggerTop, triggerLeft, triggerTop]);\n\n return null;\n}\n\nconst Provider = TooltipProvider;\nconst Root = Tooltip;\nconst Trigger = TooltipTrigger;\nconst Content = TooltipContent;\nconst Arrow = TooltipArrow;\n\nexport {\n createTooltipScope,\n //\n TooltipProvider,\n Tooltip,\n TooltipTrigger,\n TooltipContent,\n TooltipArrow,\n //\n Provider,\n Root,\n Trigger,\n Content,\n Arrow,\n};\nexport type { TooltipProps, TooltipTriggerProps, TooltipContentProps, TooltipArrowProps };\n"],"names":["createTooltipContext","createTooltipScope","createContextScope","createPopperScope","usePopperScope","DEFAULT_DELAY_DURATION","TooltipProviderContextProvider","useTooltipProviderContext","isOpenDelayed","delayDuration","onOpen","onClose","TooltipProvider","props","__scopeTooltip","skipDelayDuration","children","setIsOpenDelayed","React","useState","skipDelayTimerRef","useRef","useEffect","skipDelayTimer","current","window","clearTimeout","_react","createElement","$badf5d6f88b7e9fa4e0bb85d71c0396a$var$TooltipProviderContextProvider","scope","useCallback","setTimeout","TooltipContextProvider","useTooltipContext","Tooltip","open","openProp","defaultOpen","onOpenChange","delayDurationProp","context","popperScope","trigger","setTrigger","contentId","useId","openTimerRef","wasOpenDelayedRef","setOpen","useControllableState","prop","defaultProp","onChange","document","dispatchEvent","CustomEvent","stateAttribute","useMemo","handleOpen","handleDelayedOpen","_radixUiReactPopper","Root","$badf5d6f88b7e9fa4e0bb85d71c0396a$var$TooltipContextProvider","onTriggerChange","onTriggerEnter","TooltipTrigger","forwardRef","forwardedRef","triggerProps","composedTriggerRef","useComposedRefs","isMouseDownRef","handleMouseUp","removeEventListener","Anchor","_babelRuntimeHelpersEsmExtends","asChild","Primitive","button","undefined","ref","onMouseEnter","composeEventHandlers","onMouseLeave","onMouseDown","addEventListener","once","onFocus","onBlur","onClick","event","detail","TooltipContent","forceMount","contentProps","Presence","present","$badf5d6f88b7e9fa4e0bb85d71c0396a$var$TooltipContentImpl","TooltipContentImpl","ariaLabel","portalled","PortalWrapper","Portal","Fragment","useEscapeKeydown","$badf5d6f88b7e9fa4e0bb85d71c0396a$var$CheckTriggerMoved","Content","style","Slottable","_radixUiReactVisuallyHidden","id","role","TooltipArrow","arrowProps","Arrow","CheckTriggerMoved","triggerRect","useRect","triggerLeft","left","previousTriggerLeft","usePrevious","triggerTop","top","previousTriggerTop","handleClose","Provider","Trigger"],"version":3,"file":"index.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;;;;;;;;;;;;;;;ACmBA,MAAM,CAACc,0CAAD,EAAuBC,yCAAvB,CAAA,GAA6CZ,yBAAkB,CAAC,SAAD,EAAY;IAC/EI,wBAD+E;CAAZ,CAArE,AAAA;AAGA,MAAMS,oCAAc,GAAGT,wBAAiB,EAAxC,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["packages/react/tooltip/src/index.ts","packages/react/tooltip/src/Tooltip.tsx"],"sourcesContent":["export * 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 } 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};\n\nconst [TooltipProviderContextProvider, useTooltipProviderContext] =\n createTooltipContext<TooltipProviderContextValue>(PROVIDER_NAME, {\n isOpenDelayed: true,\n delayDuration: DEFAULT_DELAY_DURATION,\n onOpen: () => {},\n onClose: () => {},\n });\n\ninterface TooltipProviderProps {\n children: React.ReactNode;\n /**\n * The duration from when the mouse 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\nconst TooltipProvider: React.FC<TooltipProviderProps> = (\n props: ScopedProps<TooltipProviderProps>\n) => {\n const {\n __scopeTooltip,\n delayDuration = DEFAULT_DELAY_DURATION,\n skipDelayDuration = 300,\n children,\n } = props;\n const [isOpenDelayed, setIsOpenDelayed] = React.useState(true);\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 >\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 onOpen(): void;\n onClose(): void;\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 /**\n * The duration from when the mouse 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\nconst Tooltip: React.FC<TooltipProps> = (props: ScopedProps<TooltipProps>) => {\n const {\n __scopeTooltip,\n children,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n delayDuration: delayDurationProp,\n } = props;\n const context = useTooltipProviderContext(TOOLTIP_NAME, __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 delayDuration = delayDurationProp ?? context.delayDuration;\n const wasOpenDelayedRef = React.useRef(false);\n const { onOpen, onClose } = context;\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: (open) => {\n if (open) {\n // we dispatch here so `TooltipProvider` isn't required to\n // ensure other tooltips are aware of this one opening.\n document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));\n onOpen();\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 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 (context.isOpenDelayed) handleDelayedOpen();\n else handleOpen();\n }, [context.isOpenDelayed, handleDelayedOpen, handleOpen])}\n onOpen={React.useCallback(handleOpen, [handleOpen])}\n onClose={React.useCallback(() => {\n window.clearTimeout(openTimerRef.current);\n setOpen(false);\n onClose();\n }, [setOpen, onClose])}\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 popperScope = usePopperScope(__scopeTooltip);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.onTriggerChange);\n const isMouseDownRef = React.useRef(false);\n const handleMouseUp = React.useCallback(() => (isMouseDownRef.current = false), []);\n\n React.useEffect(() => {\n return () => document.removeEventListener('mouseup', handleMouseUp);\n }, [handleMouseUp]);\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={composedTriggerRef}\n onMouseEnter={composeEventHandlers(props.onMouseEnter, context.onTriggerEnter)}\n onMouseLeave={composeEventHandlers(props.onMouseLeave, context.onClose)}\n onMouseDown={composeEventHandlers(props.onMouseDown, () => {\n isMouseDownRef.current = true;\n document.addEventListener('mouseup', handleMouseUp, { once: true });\n })}\n onFocus={composeEventHandlers(props.onFocus, () => {\n if (!isMouseDownRef.current) context.onOpen();\n })}\n onBlur={composeEventHandlers(props.onBlur, context.onClose)}\n onClick={composeEventHandlers(props.onClick, (event) => {\n // keyboard click will occur under different conditions for different node\n // types so we use `onClick` instead of `onKeyDown` to respect that\n const isKeyboardClick = event.detail === 0;\n if (isKeyboardClick) context.onClose();\n })}\n />\n </PopperPrimitive.Anchor>\n );\n }\n);\n\nTooltipTrigger.displayName = TRIGGER_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 { forceMount, ...contentProps } = props;\n const context = useTooltipContext(CONTENT_NAME, props.__scopeTooltip);\n return (\n <Presence present={forceMount || context.open}>\n <TooltipContentImpl ref={forwardedRef} {...contentProps} />\n </Presence>\n );\n }\n);\n\ntype TooltipContentImplElement = React.ElementRef<typeof PopperPrimitive.Content>;\ntype DismissableLayerProps = Radix.ComponentPropsWithoutRef<typeof DismissableLayer>;\ntype PopperContentProps = Radix.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;\ninterface TooltipContentImplProps extends PopperContentProps {\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 /**\n * Whether the Tooltip should render in a Portal\n * (default: `true`)\n */\n portalled?: boolean;\n}\n\nconst TooltipContentImpl = React.forwardRef<TooltipContentImplElement, TooltipContentImplProps>(\n (props: ScopedProps<TooltipContentImplProps>, forwardedRef) => {\n const {\n __scopeTooltip,\n children,\n 'aria-label': ariaLabel,\n portalled = true,\n onEscapeKeyDown,\n onPointerDownOutside,\n ...contentProps\n } = props;\n const context = useTooltipContext(CONTENT_NAME, __scopeTooltip);\n const popperScope = usePopperScope(__scopeTooltip);\n const PortalWrapper = portalled ? Portal : React.Fragment;\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 <PortalWrapper>\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 property\n ['--radix-tooltip-content-transform-origin' as any]:\n 'var(--radix-popper-transform-origin)',\n }}\n >\n <Slottable>{children}</Slottable>\n <VisuallyHiddenPrimitive.Root id={context.contentId} role=\"tooltip\">\n {ariaLabel || children}\n </VisuallyHiddenPrimitive.Root>\n </PopperPrimitive.Content>\n </DismissableLayer>\n </PortalWrapper>\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 return <PopperPrimitive.Arrow {...popperScope} {...arrowProps} ref={forwardedRef} />;\n }\n);\n\nTooltipArrow.displayName = ARROW_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nconst Provider = TooltipProvider;\nconst Root = Tooltip;\nconst Trigger = TooltipTrigger;\nconst Content = TooltipContent;\nconst Arrow = TooltipArrow;\n\nexport {\n createTooltipScope,\n //\n TooltipProvider,\n Tooltip,\n TooltipTrigger,\n TooltipContent,\n TooltipArrow,\n //\n Provider,\n Root,\n Trigger,\n Content,\n Arrow,\n};\nexport type { TooltipProps, TooltipTriggerProps, TooltipContentProps, TooltipArrowProps };\n"],"names":["React","composeEventHandlers","useComposedRefs","createContextScope","DismissableLayer","useId","PopperPrimitive","createPopperScope","Portal","Presence","Primitive","Slottable","useControllableState","VisuallyHiddenPrimitive","createTooltipContext","createTooltipScope","usePopperScope","PROVIDER_NAME","DEFAULT_DELAY_DURATION","TOOLTIP_OPEN","TooltipProviderContextProvider","useTooltipProviderContext","isOpenDelayed","delayDuration","onOpen","onClose","TooltipProvider","props","__scopeTooltip","skipDelayDuration","children","setIsOpenDelayed","useState","skipDelayTimerRef","useRef","useEffect","skipDelayTimer","current","window","clearTimeout","useCallback","setTimeout","TOOLTIP_NAME","TooltipContextProvider","useTooltipContext","Tooltip","open","openProp","defaultOpen","onOpenChange","delayDurationProp","context","popperScope","trigger","setTrigger","contentId","openTimerRef","wasOpenDelayedRef","setOpen","prop","defaultProp","onChange","document","dispatchEvent","CustomEvent","stateAttribute","useMemo","handleOpen","handleDelayedOpen","TRIGGER_NAME","TooltipTrigger","forwardRef","forwardedRef","triggerProps","composedTriggerRef","onTriggerChange","isMouseDownRef","handleMouseUp","removeEventListener","undefined","onMouseEnter","onTriggerEnter","onMouseLeave","onMouseDown","addEventListener","once","onFocus","onBlur","onClick","event","isKeyboardClick","detail","CONTENT_NAME","TooltipContent","forceMount","contentProps","TooltipContentImpl","ariaLabel","portalled","onEscapeKeyDown","onPointerDownOutside","PortalWrapper","Fragment","handleScroll","target","contains","capture","preventDefault","style","ARROW_NAME","TooltipArrow","arrowProps","Provider","Root","Trigger","Content","Arrow"],"version":3,"file":"index.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-tooltip",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8-rc.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,23 +18,21 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime": "^7.13.10",
|
|
20
20
|
"@radix-ui/primitive": "0.1.0",
|
|
21
|
-
"@radix-ui/react-compose-refs": "0.1.
|
|
22
|
-
"@radix-ui/react-context": "0.1.
|
|
23
|
-
"@radix-ui/react-
|
|
24
|
-
"@radix-ui/react-
|
|
25
|
-
"@radix-ui/react-
|
|
26
|
-
"@radix-ui/react-
|
|
27
|
-
"@radix-ui/react-
|
|
28
|
-
"@radix-ui/react-
|
|
29
|
-
"@radix-ui/react-
|
|
30
|
-
"@radix-ui/react-use-
|
|
31
|
-
"@radix-ui/react-
|
|
32
|
-
"@radix-ui/react-use-rect": "0.1.1",
|
|
33
|
-
"@radix-ui/react-visually-hidden": "0.1.4"
|
|
21
|
+
"@radix-ui/react-compose-refs": "0.1.1-rc.6",
|
|
22
|
+
"@radix-ui/react-context": "0.1.2-rc.6",
|
|
23
|
+
"@radix-ui/react-dismissable-layer": "0.1.6-rc.6",
|
|
24
|
+
"@radix-ui/react-id": "0.1.6-rc.6",
|
|
25
|
+
"@radix-ui/react-popper": "0.1.5-rc.6",
|
|
26
|
+
"@radix-ui/react-portal": "0.1.5-rc.6",
|
|
27
|
+
"@radix-ui/react-presence": "0.1.3-rc.6",
|
|
28
|
+
"@radix-ui/react-primitive": "0.1.5-rc.6",
|
|
29
|
+
"@radix-ui/react-slot": "0.1.3-rc.6",
|
|
30
|
+
"@radix-ui/react-use-controllable-state": "0.1.1-rc.6",
|
|
31
|
+
"@radix-ui/react-visually-hidden": "0.1.5-rc.6"
|
|
34
32
|
},
|
|
35
33
|
"peerDependencies": {
|
|
36
|
-
"react": "^16.8 || ^17.0",
|
|
37
|
-
"react-dom": "^16.8 || ^17.0"
|
|
34
|
+
"react": "^16.8 || ^17.0 || ^18.0",
|
|
35
|
+
"react-dom": "^16.8 || ^17.0 || ^18.0"
|
|
38
36
|
},
|
|
39
37
|
"homepage": "https://radix-ui.com/primitives",
|
|
40
38
|
"repository": {
|
|
@@ -43,5 +41,6 @@
|
|
|
43
41
|
},
|
|
44
42
|
"bugs": {
|
|
45
43
|
"url": "https://github.com/radix-ui/primitives/issues"
|
|
46
|
-
}
|
|
44
|
+
},
|
|
45
|
+
"stableVersion": "0.1.7"
|
|
47
46
|
}
|