@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,230 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/use-tooltip.ts
|
|
22
|
+
var use_tooltip_exports = {};
|
|
23
|
+
__export(use_tooltip_exports, {
|
|
24
|
+
useTooltip: () => useTooltip
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(use_tooltip_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_tooltip = require("@react-stately/tooltip");
|
|
29
|
+
var import_tooltip2 = require("@react-aria/tooltip");
|
|
30
|
+
var import_overlays = require("@react-aria/overlays");
|
|
31
|
+
var import_heroui_v2_system = require("@vx-oss/heroui-v2-system");
|
|
32
|
+
var import_heroui_v2_theme = require("@vx-oss/heroui-v2-theme");
|
|
33
|
+
var import_heroui_v2_shared_utils = require("@vx-oss/heroui-v2-shared-utils");
|
|
34
|
+
var import_heroui_v2_react_utils = require("@vx-oss/heroui-v2-react-utils");
|
|
35
|
+
var import_heroui_v2_react_utils2 = require("@vx-oss/heroui-v2-react-utils");
|
|
36
|
+
var import_react2 = require("react");
|
|
37
|
+
var import_heroui_v2_aria_utils = require("@vx-oss/heroui-v2-aria-utils");
|
|
38
|
+
var import_heroui_v2_use_safe_layout_effect = require("@vx-oss/heroui-v2-use-safe-layout-effect");
|
|
39
|
+
var import_heroui_v2_use_aria_overlay = require("@vx-oss/heroui-v2-use-aria-overlay");
|
|
40
|
+
function useTooltip(originalProps) {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const globalContext = (0, import_heroui_v2_system.useProviderContext)();
|
|
43
|
+
const [props, variantProps] = (0, import_heroui_v2_system.mapPropsVariants)(originalProps, import_heroui_v2_theme.popover.variantKeys);
|
|
44
|
+
const {
|
|
45
|
+
ref,
|
|
46
|
+
as,
|
|
47
|
+
isOpen: isOpenProp,
|
|
48
|
+
content,
|
|
49
|
+
children,
|
|
50
|
+
defaultOpen,
|
|
51
|
+
onOpenChange,
|
|
52
|
+
isDisabled,
|
|
53
|
+
trigger: triggerAction,
|
|
54
|
+
shouldFlip = true,
|
|
55
|
+
containerPadding = 12,
|
|
56
|
+
placement: placementProp = "top",
|
|
57
|
+
delay = 0,
|
|
58
|
+
closeDelay = 500,
|
|
59
|
+
showArrow = false,
|
|
60
|
+
offset = 7,
|
|
61
|
+
crossOffset = 0,
|
|
62
|
+
isDismissable,
|
|
63
|
+
shouldCloseOnBlur = true,
|
|
64
|
+
portalContainer,
|
|
65
|
+
isKeyboardDismissDisabled = false,
|
|
66
|
+
updatePositionDeps = [],
|
|
67
|
+
shouldCloseOnInteractOutside,
|
|
68
|
+
className,
|
|
69
|
+
onClose,
|
|
70
|
+
motionProps,
|
|
71
|
+
classNames,
|
|
72
|
+
...otherProps
|
|
73
|
+
} = props;
|
|
74
|
+
const Component = as || "div";
|
|
75
|
+
const disableAnimation = (_b = (_a = originalProps == null ? void 0 : originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
|
|
76
|
+
const state = (0, import_tooltip.useTooltipTriggerState)({
|
|
77
|
+
delay,
|
|
78
|
+
closeDelay,
|
|
79
|
+
isDisabled,
|
|
80
|
+
defaultOpen,
|
|
81
|
+
isOpen: isOpenProp,
|
|
82
|
+
onOpenChange: (isOpen2) => {
|
|
83
|
+
onOpenChange == null ? void 0 : onOpenChange(isOpen2);
|
|
84
|
+
if (!isOpen2) {
|
|
85
|
+
onClose == null ? void 0 : onClose();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
const triggerRef = (0, import_react2.useRef)(null);
|
|
90
|
+
const overlayRef = (0, import_react2.useRef)(null);
|
|
91
|
+
const tooltipId = (0, import_react.useId)();
|
|
92
|
+
const isOpen = state.isOpen && !isDisabled;
|
|
93
|
+
(0, import_react.useImperativeHandle)(
|
|
94
|
+
ref,
|
|
95
|
+
() => (
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
(0, import_heroui_v2_react_utils2.createDOMRef)(overlayRef)
|
|
98
|
+
)
|
|
99
|
+
);
|
|
100
|
+
const { triggerProps, tooltipProps: triggerTooltipProps } = (0, import_tooltip2.useTooltipTrigger)(
|
|
101
|
+
{
|
|
102
|
+
isDisabled,
|
|
103
|
+
trigger: triggerAction
|
|
104
|
+
},
|
|
105
|
+
state,
|
|
106
|
+
triggerRef
|
|
107
|
+
);
|
|
108
|
+
const { tooltipProps } = (0, import_tooltip2.useTooltip)(
|
|
109
|
+
{
|
|
110
|
+
isOpen,
|
|
111
|
+
...(0, import_heroui_v2_shared_utils.mergeProps)(props, triggerTooltipProps)
|
|
112
|
+
},
|
|
113
|
+
state
|
|
114
|
+
);
|
|
115
|
+
const {
|
|
116
|
+
overlayProps: positionProps,
|
|
117
|
+
placement,
|
|
118
|
+
updatePosition
|
|
119
|
+
} = (0, import_overlays.useOverlayPosition)({
|
|
120
|
+
isOpen,
|
|
121
|
+
targetRef: triggerRef,
|
|
122
|
+
placement: (0, import_heroui_v2_aria_utils.toReactAriaPlacement)(placementProp),
|
|
123
|
+
overlayRef,
|
|
124
|
+
offset: showArrow ? offset + 3 : offset,
|
|
125
|
+
crossOffset,
|
|
126
|
+
shouldFlip,
|
|
127
|
+
containerPadding
|
|
128
|
+
});
|
|
129
|
+
(0, import_heroui_v2_use_safe_layout_effect.useSafeLayoutEffect)(() => {
|
|
130
|
+
if (!updatePositionDeps.length) return;
|
|
131
|
+
updatePosition();
|
|
132
|
+
}, updatePositionDeps);
|
|
133
|
+
const { overlayProps } = (0, import_heroui_v2_use_aria_overlay.useAriaOverlay)(
|
|
134
|
+
{
|
|
135
|
+
isOpen,
|
|
136
|
+
onClose: state.close,
|
|
137
|
+
isDismissable,
|
|
138
|
+
shouldCloseOnBlur,
|
|
139
|
+
isKeyboardDismissDisabled,
|
|
140
|
+
shouldCloseOnInteractOutside
|
|
141
|
+
},
|
|
142
|
+
overlayRef
|
|
143
|
+
);
|
|
144
|
+
const slots = (0, import_react2.useMemo)(
|
|
145
|
+
() => {
|
|
146
|
+
var _a2, _b2, _c;
|
|
147
|
+
return (0, import_heroui_v2_theme.popover)({
|
|
148
|
+
...variantProps,
|
|
149
|
+
disableAnimation,
|
|
150
|
+
radius: (_a2 = originalProps == null ? void 0 : originalProps.radius) != null ? _a2 : "md",
|
|
151
|
+
size: (_b2 = originalProps == null ? void 0 : originalProps.size) != null ? _b2 : "md",
|
|
152
|
+
shadow: (_c = originalProps == null ? void 0 : originalProps.shadow) != null ? _c : "sm"
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
[
|
|
156
|
+
(0, import_heroui_v2_shared_utils.objectToDeps)(variantProps),
|
|
157
|
+
disableAnimation,
|
|
158
|
+
originalProps == null ? void 0 : originalProps.radius,
|
|
159
|
+
originalProps == null ? void 0 : originalProps.size,
|
|
160
|
+
originalProps == null ? void 0 : originalProps.shadow
|
|
161
|
+
]
|
|
162
|
+
);
|
|
163
|
+
const getTriggerProps = (0, import_react2.useCallback)(
|
|
164
|
+
(props2 = {}, _ref = null) => ({
|
|
165
|
+
...(0, import_heroui_v2_shared_utils.mergeProps)(triggerProps, props2),
|
|
166
|
+
ref: (0, import_heroui_v2_react_utils.mergeRefs)(_ref, triggerRef),
|
|
167
|
+
"aria-describedby": isOpen ? tooltipId : void 0
|
|
168
|
+
}),
|
|
169
|
+
[triggerProps, isOpen, tooltipId, state]
|
|
170
|
+
);
|
|
171
|
+
const getTooltipProps = (0, import_react2.useCallback)(
|
|
172
|
+
() => ({
|
|
173
|
+
ref: overlayRef,
|
|
174
|
+
"data-slot": "base",
|
|
175
|
+
"data-open": (0, import_heroui_v2_shared_utils.dataAttr)(isOpen),
|
|
176
|
+
"data-arrow": (0, import_heroui_v2_shared_utils.dataAttr)(showArrow),
|
|
177
|
+
"data-disabled": (0, import_heroui_v2_shared_utils.dataAttr)(isDisabled),
|
|
178
|
+
"data-placement": (0, import_heroui_v2_aria_utils.getArrowPlacement)(placement || "top", placementProp),
|
|
179
|
+
...(0, import_heroui_v2_shared_utils.mergeProps)(tooltipProps, overlayProps, otherProps),
|
|
180
|
+
style: (0, import_heroui_v2_shared_utils.mergeProps)(positionProps.style, otherProps.style, props.style),
|
|
181
|
+
className: slots.base({ class: classNames == null ? void 0 : classNames.base }),
|
|
182
|
+
id: tooltipId
|
|
183
|
+
}),
|
|
184
|
+
[
|
|
185
|
+
slots,
|
|
186
|
+
isOpen,
|
|
187
|
+
showArrow,
|
|
188
|
+
isDisabled,
|
|
189
|
+
placement,
|
|
190
|
+
placementProp,
|
|
191
|
+
tooltipProps,
|
|
192
|
+
overlayProps,
|
|
193
|
+
otherProps,
|
|
194
|
+
positionProps,
|
|
195
|
+
props,
|
|
196
|
+
tooltipId
|
|
197
|
+
]
|
|
198
|
+
);
|
|
199
|
+
const getTooltipContentProps = (0, import_react2.useCallback)(
|
|
200
|
+
() => ({
|
|
201
|
+
"data-slot": "content",
|
|
202
|
+
"data-open": (0, import_heroui_v2_shared_utils.dataAttr)(isOpen),
|
|
203
|
+
"data-arrow": (0, import_heroui_v2_shared_utils.dataAttr)(showArrow),
|
|
204
|
+
"data-disabled": (0, import_heroui_v2_shared_utils.dataAttr)(isDisabled),
|
|
205
|
+
"data-placement": (0, import_heroui_v2_aria_utils.getArrowPlacement)(placement || "top", placementProp),
|
|
206
|
+
className: slots.content({ class: (0, import_heroui_v2_shared_utils.clsx)(classNames == null ? void 0 : classNames.content, className) })
|
|
207
|
+
}),
|
|
208
|
+
[slots, isOpen, showArrow, isDisabled, placement, placementProp, classNames]
|
|
209
|
+
);
|
|
210
|
+
return {
|
|
211
|
+
Component,
|
|
212
|
+
content,
|
|
213
|
+
children,
|
|
214
|
+
isOpen,
|
|
215
|
+
triggerRef,
|
|
216
|
+
showArrow,
|
|
217
|
+
portalContainer,
|
|
218
|
+
placement: placementProp,
|
|
219
|
+
disableAnimation,
|
|
220
|
+
isDisabled,
|
|
221
|
+
motionProps,
|
|
222
|
+
getTooltipContentProps,
|
|
223
|
+
getTriggerProps,
|
|
224
|
+
getTooltipProps
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
228
|
+
0 && (module.exports = {
|
|
229
|
+
useTooltip
|
|
230
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vx-oss/heroui-v2-tooltip",
|
|
3
|
+
"version": "2.2.25-alpha.0",
|
|
4
|
+
"description": "A React Component for rendering dynamically positioned Tooltips",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tooltip"
|
|
7
|
+
],
|
|
8
|
+
"author": "Vx OSS Devs <oss-developers@vezham.com>",
|
|
9
|
+
"homepage": "https://vezham.com",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/vezham/heroui-v2.git",
|
|
22
|
+
"directory": "packages/components/tooltip"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/vezham/heroui-v2/issues"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": ">=18 || >=19.0.0-rc.0",
|
|
29
|
+
"react-dom": ">=18 || >=19.0.0-rc.0",
|
|
30
|
+
"framer-motion": ">=11.5.6 || >=12.0.0-alpha.1",
|
|
31
|
+
"@vx-oss/heroui-v2-theme": ">=2.4.24-alpha.0",
|
|
32
|
+
"@vx-oss/heroui-v2-system": ">=2.4.24-alpha.0"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@react-aria/overlays": "3.30.0",
|
|
36
|
+
"@react-aria/tooltip": "3.8.8",
|
|
37
|
+
"@react-stately/tooltip": "3.5.8",
|
|
38
|
+
"@react-types/overlays": "3.9.2",
|
|
39
|
+
"@react-types/tooltip": "3.4.21",
|
|
40
|
+
"@vx-oss/heroui-v2-react-utils": "2.1.15-alpha.0",
|
|
41
|
+
"@vx-oss/heroui-v2-shared-utils": "2.1.13-alpha.0",
|
|
42
|
+
"@vx-oss/heroui-v2-aria-utils": "2.2.25-alpha.0",
|
|
43
|
+
"@vx-oss/heroui-v2-use-safe-layout-effect": "2.1.9-alpha.0",
|
|
44
|
+
"@vx-oss/heroui-v2-use-aria-overlay": "2.0.5-alpha.0",
|
|
45
|
+
"@vx-oss/heroui-v2-dom-animation": "2.1.11-alpha.0",
|
|
46
|
+
"@vx-oss/heroui-v2-framer-utils": "2.1.24-alpha.0"
|
|
47
|
+
},
|
|
48
|
+
"clean-package": "../../../clean-package.config.json",
|
|
49
|
+
"module": "dist/index.mjs",
|
|
50
|
+
"types": "dist/index.d.ts",
|
|
51
|
+
"exports": {
|
|
52
|
+
".": {
|
|
53
|
+
"types": "./dist/index.d.ts",
|
|
54
|
+
"import": "./dist/index.mjs",
|
|
55
|
+
"require": "./dist/index.js"
|
|
56
|
+
},
|
|
57
|
+
"./package.json": "./package.json"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsup src --dts",
|
|
61
|
+
"build:fast": "tsup src",
|
|
62
|
+
"dev": "pnpm build:fast --watch",
|
|
63
|
+
"clean": "rimraf dist .turbo",
|
|
64
|
+
"typecheck": "tsc --noEmit"
|
|
65
|
+
}
|
|
66
|
+
}
|