@vx-oss/heroui-v2-tooltip 2.2.25-alpha.0
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/LICENSE +32 -0
- package/README.md +24 -0
- package/dist/chunk-JMIJGG7Q.mjs +75 -0
- package/dist/chunk-ZQCIM4IR.mjs +207 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +313 -0
- package/dist/index.mjs +11 -0
- package/dist/tooltip.d.mts +16 -0
- package/dist/tooltip.d.ts +16 -0
- package/dist/tooltip.js +305 -0
- package/dist/tooltip.mjs +8 -0
- package/dist/use-tooltip.d.mts +93 -0
- package/dist/use-tooltip.d.ts +93 -0
- package/dist/use-tooltip.js +230 -0
- package/dist/use-tooltip.mjs +7 -0
- package/package.json +66 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as _vx_oss_heroui_v2_system from '@vx-oss/heroui-v2-system';
|
|
2
|
+
import { UseTooltipProps } from './use-tooltip.mjs';
|
|
3
|
+
import '@vx-oss/heroui-v2-aria-utils';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@vx-oss/heroui-v2-theme';
|
|
6
|
+
import '@react-types/tooltip';
|
|
7
|
+
import '@react-types/overlays';
|
|
8
|
+
import '@react-aria/overlays';
|
|
9
|
+
import 'framer-motion';
|
|
10
|
+
import '@vx-oss/heroui-v2-react-utils';
|
|
11
|
+
|
|
12
|
+
interface TooltipProps extends Omit<UseTooltipProps, "disableTriggerFocus" | "backdrop"> {
|
|
13
|
+
}
|
|
14
|
+
declare const Tooltip: _vx_oss_heroui_v2_system.InternalForwardRefRenderFunction<"div", TooltipProps, never>;
|
|
15
|
+
|
|
16
|
+
export { type TooltipProps, Tooltip as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as _vx_oss_heroui_v2_system from '@vx-oss/heroui-v2-system';
|
|
2
|
+
import { UseTooltipProps } from './use-tooltip.js';
|
|
3
|
+
import '@vx-oss/heroui-v2-aria-utils';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@vx-oss/heroui-v2-theme';
|
|
6
|
+
import '@react-types/tooltip';
|
|
7
|
+
import '@react-types/overlays';
|
|
8
|
+
import '@react-aria/overlays';
|
|
9
|
+
import 'framer-motion';
|
|
10
|
+
import '@vx-oss/heroui-v2-react-utils';
|
|
11
|
+
|
|
12
|
+
interface TooltipProps extends Omit<UseTooltipProps, "disableTriggerFocus" | "backdrop"> {
|
|
13
|
+
}
|
|
14
|
+
declare const Tooltip: _vx_oss_heroui_v2_system.InternalForwardRefRenderFunction<"div", TooltipProps, never>;
|
|
15
|
+
|
|
16
|
+
export { type TooltipProps, Tooltip as default };
|
package/dist/tooltip.js
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/tooltip.tsx
|
|
32
|
+
var tooltip_exports = {};
|
|
33
|
+
__export(tooltip_exports, {
|
|
34
|
+
default: () => tooltip_default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(tooltip_exports);
|
|
37
|
+
var import_heroui_v2_system2 = require("@vx-oss/heroui-v2-system");
|
|
38
|
+
var import_overlays2 = require("@react-aria/overlays");
|
|
39
|
+
var import_framer_motion = require("framer-motion");
|
|
40
|
+
var import_heroui_v2_framer_utils = require("@vx-oss/heroui-v2-framer-utils");
|
|
41
|
+
var import_heroui_v2_shared_utils2 = require("@vx-oss/heroui-v2-shared-utils");
|
|
42
|
+
var import_react3 = require("react");
|
|
43
|
+
var import_heroui_v2_aria_utils2 = require("@vx-oss/heroui-v2-aria-utils");
|
|
44
|
+
|
|
45
|
+
// src/use-tooltip.ts
|
|
46
|
+
var import_react = require("react");
|
|
47
|
+
var import_tooltip = require("@react-stately/tooltip");
|
|
48
|
+
var import_tooltip2 = require("@react-aria/tooltip");
|
|
49
|
+
var import_overlays = require("@react-aria/overlays");
|
|
50
|
+
var import_heroui_v2_system = require("@vx-oss/heroui-v2-system");
|
|
51
|
+
var import_heroui_v2_theme = require("@vx-oss/heroui-v2-theme");
|
|
52
|
+
var import_heroui_v2_shared_utils = require("@vx-oss/heroui-v2-shared-utils");
|
|
53
|
+
var import_heroui_v2_react_utils = require("@vx-oss/heroui-v2-react-utils");
|
|
54
|
+
var import_heroui_v2_react_utils2 = require("@vx-oss/heroui-v2-react-utils");
|
|
55
|
+
var import_react2 = require("react");
|
|
56
|
+
var import_heroui_v2_aria_utils = require("@vx-oss/heroui-v2-aria-utils");
|
|
57
|
+
var import_heroui_v2_use_safe_layout_effect = require("@vx-oss/heroui-v2-use-safe-layout-effect");
|
|
58
|
+
var import_heroui_v2_use_aria_overlay = require("@vx-oss/heroui-v2-use-aria-overlay");
|
|
59
|
+
function useTooltip(originalProps) {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
const globalContext = (0, import_heroui_v2_system.useProviderContext)();
|
|
62
|
+
const [props, variantProps] = (0, import_heroui_v2_system.mapPropsVariants)(originalProps, import_heroui_v2_theme.popover.variantKeys);
|
|
63
|
+
const {
|
|
64
|
+
ref,
|
|
65
|
+
as,
|
|
66
|
+
isOpen: isOpenProp,
|
|
67
|
+
content,
|
|
68
|
+
children,
|
|
69
|
+
defaultOpen,
|
|
70
|
+
onOpenChange,
|
|
71
|
+
isDisabled,
|
|
72
|
+
trigger: triggerAction,
|
|
73
|
+
shouldFlip = true,
|
|
74
|
+
containerPadding = 12,
|
|
75
|
+
placement: placementProp = "top",
|
|
76
|
+
delay = 0,
|
|
77
|
+
closeDelay = 500,
|
|
78
|
+
showArrow = false,
|
|
79
|
+
offset = 7,
|
|
80
|
+
crossOffset = 0,
|
|
81
|
+
isDismissable,
|
|
82
|
+
shouldCloseOnBlur = true,
|
|
83
|
+
portalContainer,
|
|
84
|
+
isKeyboardDismissDisabled = false,
|
|
85
|
+
updatePositionDeps = [],
|
|
86
|
+
shouldCloseOnInteractOutside,
|
|
87
|
+
className,
|
|
88
|
+
onClose,
|
|
89
|
+
motionProps,
|
|
90
|
+
classNames,
|
|
91
|
+
...otherProps
|
|
92
|
+
} = props;
|
|
93
|
+
const Component = as || "div";
|
|
94
|
+
const disableAnimation = (_b = (_a = originalProps == null ? void 0 : originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
|
|
95
|
+
const state = (0, import_tooltip.useTooltipTriggerState)({
|
|
96
|
+
delay,
|
|
97
|
+
closeDelay,
|
|
98
|
+
isDisabled,
|
|
99
|
+
defaultOpen,
|
|
100
|
+
isOpen: isOpenProp,
|
|
101
|
+
onOpenChange: (isOpen2) => {
|
|
102
|
+
onOpenChange == null ? void 0 : onOpenChange(isOpen2);
|
|
103
|
+
if (!isOpen2) {
|
|
104
|
+
onClose == null ? void 0 : onClose();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
const triggerRef = (0, import_react2.useRef)(null);
|
|
109
|
+
const overlayRef = (0, import_react2.useRef)(null);
|
|
110
|
+
const tooltipId = (0, import_react.useId)();
|
|
111
|
+
const isOpen = state.isOpen && !isDisabled;
|
|
112
|
+
(0, import_react.useImperativeHandle)(
|
|
113
|
+
ref,
|
|
114
|
+
() => (
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
(0, import_heroui_v2_react_utils2.createDOMRef)(overlayRef)
|
|
117
|
+
)
|
|
118
|
+
);
|
|
119
|
+
const { triggerProps, tooltipProps: triggerTooltipProps } = (0, import_tooltip2.useTooltipTrigger)(
|
|
120
|
+
{
|
|
121
|
+
isDisabled,
|
|
122
|
+
trigger: triggerAction
|
|
123
|
+
},
|
|
124
|
+
state,
|
|
125
|
+
triggerRef
|
|
126
|
+
);
|
|
127
|
+
const { tooltipProps } = (0, import_tooltip2.useTooltip)(
|
|
128
|
+
{
|
|
129
|
+
isOpen,
|
|
130
|
+
...(0, import_heroui_v2_shared_utils.mergeProps)(props, triggerTooltipProps)
|
|
131
|
+
},
|
|
132
|
+
state
|
|
133
|
+
);
|
|
134
|
+
const {
|
|
135
|
+
overlayProps: positionProps,
|
|
136
|
+
placement,
|
|
137
|
+
updatePosition
|
|
138
|
+
} = (0, import_overlays.useOverlayPosition)({
|
|
139
|
+
isOpen,
|
|
140
|
+
targetRef: triggerRef,
|
|
141
|
+
placement: (0, import_heroui_v2_aria_utils.toReactAriaPlacement)(placementProp),
|
|
142
|
+
overlayRef,
|
|
143
|
+
offset: showArrow ? offset + 3 : offset,
|
|
144
|
+
crossOffset,
|
|
145
|
+
shouldFlip,
|
|
146
|
+
containerPadding
|
|
147
|
+
});
|
|
148
|
+
(0, import_heroui_v2_use_safe_layout_effect.useSafeLayoutEffect)(() => {
|
|
149
|
+
if (!updatePositionDeps.length) return;
|
|
150
|
+
updatePosition();
|
|
151
|
+
}, updatePositionDeps);
|
|
152
|
+
const { overlayProps } = (0, import_heroui_v2_use_aria_overlay.useAriaOverlay)(
|
|
153
|
+
{
|
|
154
|
+
isOpen,
|
|
155
|
+
onClose: state.close,
|
|
156
|
+
isDismissable,
|
|
157
|
+
shouldCloseOnBlur,
|
|
158
|
+
isKeyboardDismissDisabled,
|
|
159
|
+
shouldCloseOnInteractOutside
|
|
160
|
+
},
|
|
161
|
+
overlayRef
|
|
162
|
+
);
|
|
163
|
+
const slots = (0, import_react2.useMemo)(
|
|
164
|
+
() => {
|
|
165
|
+
var _a2, _b2, _c;
|
|
166
|
+
return (0, import_heroui_v2_theme.popover)({
|
|
167
|
+
...variantProps,
|
|
168
|
+
disableAnimation,
|
|
169
|
+
radius: (_a2 = originalProps == null ? void 0 : originalProps.radius) != null ? _a2 : "md",
|
|
170
|
+
size: (_b2 = originalProps == null ? void 0 : originalProps.size) != null ? _b2 : "md",
|
|
171
|
+
shadow: (_c = originalProps == null ? void 0 : originalProps.shadow) != null ? _c : "sm"
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
[
|
|
175
|
+
(0, import_heroui_v2_shared_utils.objectToDeps)(variantProps),
|
|
176
|
+
disableAnimation,
|
|
177
|
+
originalProps == null ? void 0 : originalProps.radius,
|
|
178
|
+
originalProps == null ? void 0 : originalProps.size,
|
|
179
|
+
originalProps == null ? void 0 : originalProps.shadow
|
|
180
|
+
]
|
|
181
|
+
);
|
|
182
|
+
const getTriggerProps = (0, import_react2.useCallback)(
|
|
183
|
+
(props2 = {}, _ref = null) => ({
|
|
184
|
+
...(0, import_heroui_v2_shared_utils.mergeProps)(triggerProps, props2),
|
|
185
|
+
ref: (0, import_heroui_v2_react_utils.mergeRefs)(_ref, triggerRef),
|
|
186
|
+
"aria-describedby": isOpen ? tooltipId : void 0
|
|
187
|
+
}),
|
|
188
|
+
[triggerProps, isOpen, tooltipId, state]
|
|
189
|
+
);
|
|
190
|
+
const getTooltipProps = (0, import_react2.useCallback)(
|
|
191
|
+
() => ({
|
|
192
|
+
ref: overlayRef,
|
|
193
|
+
"data-slot": "base",
|
|
194
|
+
"data-open": (0, import_heroui_v2_shared_utils.dataAttr)(isOpen),
|
|
195
|
+
"data-arrow": (0, import_heroui_v2_shared_utils.dataAttr)(showArrow),
|
|
196
|
+
"data-disabled": (0, import_heroui_v2_shared_utils.dataAttr)(isDisabled),
|
|
197
|
+
"data-placement": (0, import_heroui_v2_aria_utils.getArrowPlacement)(placement || "top", placementProp),
|
|
198
|
+
...(0, import_heroui_v2_shared_utils.mergeProps)(tooltipProps, overlayProps, otherProps),
|
|
199
|
+
style: (0, import_heroui_v2_shared_utils.mergeProps)(positionProps.style, otherProps.style, props.style),
|
|
200
|
+
className: slots.base({ class: classNames == null ? void 0 : classNames.base }),
|
|
201
|
+
id: tooltipId
|
|
202
|
+
}),
|
|
203
|
+
[
|
|
204
|
+
slots,
|
|
205
|
+
isOpen,
|
|
206
|
+
showArrow,
|
|
207
|
+
isDisabled,
|
|
208
|
+
placement,
|
|
209
|
+
placementProp,
|
|
210
|
+
tooltipProps,
|
|
211
|
+
overlayProps,
|
|
212
|
+
otherProps,
|
|
213
|
+
positionProps,
|
|
214
|
+
props,
|
|
215
|
+
tooltipId
|
|
216
|
+
]
|
|
217
|
+
);
|
|
218
|
+
const getTooltipContentProps = (0, import_react2.useCallback)(
|
|
219
|
+
() => ({
|
|
220
|
+
"data-slot": "content",
|
|
221
|
+
"data-open": (0, import_heroui_v2_shared_utils.dataAttr)(isOpen),
|
|
222
|
+
"data-arrow": (0, import_heroui_v2_shared_utils.dataAttr)(showArrow),
|
|
223
|
+
"data-disabled": (0, import_heroui_v2_shared_utils.dataAttr)(isDisabled),
|
|
224
|
+
"data-placement": (0, import_heroui_v2_aria_utils.getArrowPlacement)(placement || "top", placementProp),
|
|
225
|
+
className: slots.content({ class: (0, import_heroui_v2_shared_utils.clsx)(classNames == null ? void 0 : classNames.content, className) })
|
|
226
|
+
}),
|
|
227
|
+
[slots, isOpen, showArrow, isDisabled, placement, placementProp, classNames]
|
|
228
|
+
);
|
|
229
|
+
return {
|
|
230
|
+
Component,
|
|
231
|
+
content,
|
|
232
|
+
children,
|
|
233
|
+
isOpen,
|
|
234
|
+
triggerRef,
|
|
235
|
+
showArrow,
|
|
236
|
+
portalContainer,
|
|
237
|
+
placement: placementProp,
|
|
238
|
+
disableAnimation,
|
|
239
|
+
isDisabled,
|
|
240
|
+
motionProps,
|
|
241
|
+
getTooltipContentProps,
|
|
242
|
+
getTriggerProps,
|
|
243
|
+
getTooltipProps
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// src/tooltip.tsx
|
|
248
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
249
|
+
var domAnimation = () => import("@vx-oss/heroui-v2-dom-animation").then((res) => res.default);
|
|
250
|
+
var Tooltip = (0, import_heroui_v2_system2.forwardRef)((props, ref) => {
|
|
251
|
+
var _a;
|
|
252
|
+
const {
|
|
253
|
+
Component,
|
|
254
|
+
children,
|
|
255
|
+
content,
|
|
256
|
+
isOpen,
|
|
257
|
+
portalContainer,
|
|
258
|
+
placement,
|
|
259
|
+
disableAnimation,
|
|
260
|
+
motionProps,
|
|
261
|
+
getTriggerProps,
|
|
262
|
+
getTooltipProps,
|
|
263
|
+
getTooltipContentProps
|
|
264
|
+
} = useTooltip({
|
|
265
|
+
...props,
|
|
266
|
+
ref
|
|
267
|
+
});
|
|
268
|
+
let trigger;
|
|
269
|
+
try {
|
|
270
|
+
const childrenNum = import_react3.Children.count(children);
|
|
271
|
+
if (childrenNum !== 1) throw new Error();
|
|
272
|
+
if (!(0, import_react3.isValidElement)(children)) {
|
|
273
|
+
trigger = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { ...getTriggerProps(), children });
|
|
274
|
+
} else {
|
|
275
|
+
const child = children;
|
|
276
|
+
const childRef = (_a = child.props.ref) != null ? _a : child.ref;
|
|
277
|
+
trigger = (0, import_react3.cloneElement)(child, getTriggerProps(child.props, childRef));
|
|
278
|
+
}
|
|
279
|
+
} catch {
|
|
280
|
+
trigger = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {});
|
|
281
|
+
(0, import_heroui_v2_shared_utils2.warn)("Tooltip must have only one child node. Please, check your code.");
|
|
282
|
+
}
|
|
283
|
+
const { ref: tooltipRef, id, style, ...otherTooltipProps } = getTooltipProps();
|
|
284
|
+
const animatedContent = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: tooltipRef, id, style, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
285
|
+
import_framer_motion.m.div,
|
|
286
|
+
{
|
|
287
|
+
animate: "enter",
|
|
288
|
+
exit: "exit",
|
|
289
|
+
initial: "exit",
|
|
290
|
+
variants: import_heroui_v2_framer_utils.TRANSITION_VARIANTS.scaleSpring,
|
|
291
|
+
...(0, import_heroui_v2_shared_utils2.mergeProps)(motionProps, otherTooltipProps),
|
|
292
|
+
style: {
|
|
293
|
+
...(0, import_heroui_v2_aria_utils2.getTransformOrigins)(placement)
|
|
294
|
+
},
|
|
295
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ...getTooltipContentProps(), children: content })
|
|
296
|
+
},
|
|
297
|
+
`${id}-tooltip-inner`
|
|
298
|
+
) }, `${id}-tooltip-content`);
|
|
299
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
300
|
+
trigger,
|
|
301
|
+
disableAnimation ? isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_overlays2.OverlayContainer, { portalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: tooltipRef, id, style, ...otherTooltipProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ...getTooltipContentProps(), children: content }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.LazyMotion, { features: domAnimation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framer_motion.AnimatePresence, { children: isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_overlays2.OverlayContainer, { portalContainer, children: animatedContent }) }) })
|
|
302
|
+
] });
|
|
303
|
+
});
|
|
304
|
+
Tooltip.displayName = "HeroUI.Tooltip";
|
|
305
|
+
var tooltip_default = Tooltip;
|
package/dist/tooltip.mjs
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as _vx_oss_heroui_v2_aria_utils from '@vx-oss/heroui-v2-aria-utils';
|
|
2
|
+
import { OverlayOptions } from '@vx-oss/heroui-v2-aria-utils';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import * as _vx_oss_heroui_v2_system from '@vx-oss/heroui-v2-system';
|
|
6
|
+
import { HTMLHeroUIProps, PropGetter } from '@vx-oss/heroui-v2-system';
|
|
7
|
+
import { SlotsToClasses, PopoverVariantProps } from '@vx-oss/heroui-v2-theme';
|
|
8
|
+
import { AriaTooltipProps } from '@react-types/tooltip';
|
|
9
|
+
import { OverlayTriggerProps } from '@react-types/overlays';
|
|
10
|
+
import { AriaOverlayProps } from '@react-aria/overlays';
|
|
11
|
+
import { HTMLMotionProps } from 'framer-motion';
|
|
12
|
+
import { ReactRef } from '@vx-oss/heroui-v2-react-utils';
|
|
13
|
+
|
|
14
|
+
interface Props extends Omit<HTMLHeroUIProps, "content"> {
|
|
15
|
+
/**
|
|
16
|
+
* Ref to the DOM node.
|
|
17
|
+
*/
|
|
18
|
+
ref?: ReactRef<HTMLElement | null>;
|
|
19
|
+
/**
|
|
20
|
+
* The children to render. Usually a trigger element.
|
|
21
|
+
*/
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* The content of the tooltip.
|
|
25
|
+
*/
|
|
26
|
+
content?: string | React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the tooltip should be disabled, independent from the trigger.
|
|
29
|
+
*/
|
|
30
|
+
isDisabled?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The delay time in ms for the tooltip to show up.
|
|
33
|
+
* @default 0
|
|
34
|
+
*/
|
|
35
|
+
delay?: number;
|
|
36
|
+
/**
|
|
37
|
+
* The delay time in ms for the tooltip to hide.
|
|
38
|
+
* @default 500
|
|
39
|
+
*/
|
|
40
|
+
closeDelay?: number;
|
|
41
|
+
/**
|
|
42
|
+
* By default, opens for both focus and hover. Can be made to open only for focus.
|
|
43
|
+
*/
|
|
44
|
+
trigger?: "focus";
|
|
45
|
+
/**
|
|
46
|
+
* The props to modify the framer motion animation. Use the `variants` API to create your own animation.
|
|
47
|
+
*/
|
|
48
|
+
motionProps?: Omit<HTMLMotionProps<"div">, "ref">;
|
|
49
|
+
/**
|
|
50
|
+
* The container element in which the overlay portal will be placed.
|
|
51
|
+
* @default document.body
|
|
52
|
+
*/
|
|
53
|
+
portalContainer?: Element;
|
|
54
|
+
/**
|
|
55
|
+
* List of dependencies to update the position of the tooltip.
|
|
56
|
+
* @default []
|
|
57
|
+
*/
|
|
58
|
+
updatePositionDeps?: any[];
|
|
59
|
+
/**
|
|
60
|
+
* Classname or List of classes to change the classNames of the element.
|
|
61
|
+
* if `className` is passed, it will be added to the base slot.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* <Tooltip classNames={{
|
|
66
|
+
* base:"base-classes",
|
|
67
|
+
* content: "content-classes",
|
|
68
|
+
* arrow: "arrow-classes",
|
|
69
|
+
* }} />
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
classNames?: SlotsToClasses<"base" | "arrow" | "content">;
|
|
73
|
+
}
|
|
74
|
+
type UseTooltipProps = Props & AriaTooltipProps & AriaOverlayProps & OverlayTriggerProps & OverlayOptions & PopoverVariantProps;
|
|
75
|
+
declare function useTooltip(originalProps: UseTooltipProps): {
|
|
76
|
+
Component: _vx_oss_heroui_v2_system.As<any>;
|
|
77
|
+
content: ReactNode;
|
|
78
|
+
children: ReactNode;
|
|
79
|
+
isOpen: boolean;
|
|
80
|
+
triggerRef: react.RefObject<HTMLElement>;
|
|
81
|
+
showArrow: boolean;
|
|
82
|
+
portalContainer: Element | undefined;
|
|
83
|
+
placement: _vx_oss_heroui_v2_aria_utils.OverlayPlacement;
|
|
84
|
+
disableAnimation: boolean;
|
|
85
|
+
isDisabled: boolean | undefined;
|
|
86
|
+
motionProps: Omit<HTMLMotionProps<"div">, "ref"> | undefined;
|
|
87
|
+
getTooltipContentProps: PropGetter;
|
|
88
|
+
getTriggerProps: PropGetter;
|
|
89
|
+
getTooltipProps: PropGetter;
|
|
90
|
+
};
|
|
91
|
+
type UseTooltipReturn = ReturnType<typeof useTooltip>;
|
|
92
|
+
|
|
93
|
+
export { type UseTooltipProps, type UseTooltipReturn, useTooltip };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as _vx_oss_heroui_v2_aria_utils from '@vx-oss/heroui-v2-aria-utils';
|
|
2
|
+
import { OverlayOptions } from '@vx-oss/heroui-v2-aria-utils';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import * as _vx_oss_heroui_v2_system from '@vx-oss/heroui-v2-system';
|
|
6
|
+
import { HTMLHeroUIProps, PropGetter } from '@vx-oss/heroui-v2-system';
|
|
7
|
+
import { SlotsToClasses, PopoverVariantProps } from '@vx-oss/heroui-v2-theme';
|
|
8
|
+
import { AriaTooltipProps } from '@react-types/tooltip';
|
|
9
|
+
import { OverlayTriggerProps } from '@react-types/overlays';
|
|
10
|
+
import { AriaOverlayProps } from '@react-aria/overlays';
|
|
11
|
+
import { HTMLMotionProps } from 'framer-motion';
|
|
12
|
+
import { ReactRef } from '@vx-oss/heroui-v2-react-utils';
|
|
13
|
+
|
|
14
|
+
interface Props extends Omit<HTMLHeroUIProps, "content"> {
|
|
15
|
+
/**
|
|
16
|
+
* Ref to the DOM node.
|
|
17
|
+
*/
|
|
18
|
+
ref?: ReactRef<HTMLElement | null>;
|
|
19
|
+
/**
|
|
20
|
+
* The children to render. Usually a trigger element.
|
|
21
|
+
*/
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* The content of the tooltip.
|
|
25
|
+
*/
|
|
26
|
+
content?: string | React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the tooltip should be disabled, independent from the trigger.
|
|
29
|
+
*/
|
|
30
|
+
isDisabled?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The delay time in ms for the tooltip to show up.
|
|
33
|
+
* @default 0
|
|
34
|
+
*/
|
|
35
|
+
delay?: number;
|
|
36
|
+
/**
|
|
37
|
+
* The delay time in ms for the tooltip to hide.
|
|
38
|
+
* @default 500
|
|
39
|
+
*/
|
|
40
|
+
closeDelay?: number;
|
|
41
|
+
/**
|
|
42
|
+
* By default, opens for both focus and hover. Can be made to open only for focus.
|
|
43
|
+
*/
|
|
44
|
+
trigger?: "focus";
|
|
45
|
+
/**
|
|
46
|
+
* The props to modify the framer motion animation. Use the `variants` API to create your own animation.
|
|
47
|
+
*/
|
|
48
|
+
motionProps?: Omit<HTMLMotionProps<"div">, "ref">;
|
|
49
|
+
/**
|
|
50
|
+
* The container element in which the overlay portal will be placed.
|
|
51
|
+
* @default document.body
|
|
52
|
+
*/
|
|
53
|
+
portalContainer?: Element;
|
|
54
|
+
/**
|
|
55
|
+
* List of dependencies to update the position of the tooltip.
|
|
56
|
+
* @default []
|
|
57
|
+
*/
|
|
58
|
+
updatePositionDeps?: any[];
|
|
59
|
+
/**
|
|
60
|
+
* Classname or List of classes to change the classNames of the element.
|
|
61
|
+
* if `className` is passed, it will be added to the base slot.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* <Tooltip classNames={{
|
|
66
|
+
* base:"base-classes",
|
|
67
|
+
* content: "content-classes",
|
|
68
|
+
* arrow: "arrow-classes",
|
|
69
|
+
* }} />
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
classNames?: SlotsToClasses<"base" | "arrow" | "content">;
|
|
73
|
+
}
|
|
74
|
+
type UseTooltipProps = Props & AriaTooltipProps & AriaOverlayProps & OverlayTriggerProps & OverlayOptions & PopoverVariantProps;
|
|
75
|
+
declare function useTooltip(originalProps: UseTooltipProps): {
|
|
76
|
+
Component: _vx_oss_heroui_v2_system.As<any>;
|
|
77
|
+
content: ReactNode;
|
|
78
|
+
children: ReactNode;
|
|
79
|
+
isOpen: boolean;
|
|
80
|
+
triggerRef: react.RefObject<HTMLElement>;
|
|
81
|
+
showArrow: boolean;
|
|
82
|
+
portalContainer: Element | undefined;
|
|
83
|
+
placement: _vx_oss_heroui_v2_aria_utils.OverlayPlacement;
|
|
84
|
+
disableAnimation: boolean;
|
|
85
|
+
isDisabled: boolean | undefined;
|
|
86
|
+
motionProps: Omit<HTMLMotionProps<"div">, "ref"> | undefined;
|
|
87
|
+
getTooltipContentProps: PropGetter;
|
|
88
|
+
getTriggerProps: PropGetter;
|
|
89
|
+
getTooltipProps: PropGetter;
|
|
90
|
+
};
|
|
91
|
+
type UseTooltipReturn = ReturnType<typeof useTooltip>;
|
|
92
|
+
|
|
93
|
+
export { type UseTooltipProps, type UseTooltipReturn, useTooltip };
|