@fabio.caffarello/react-design-system 4.7.0 → 4.8.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/dist/granular/index.js +405 -403
- package/dist/granular/index.js.map +1 -1
- package/dist/granular/ui/components/EmptyState/EmptyState.js +52 -50
- package/dist/granular/ui/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/granular/ui/primitives/Avatar/Avatar.js.map +1 -1
- package/dist/granular/ui/primitives/Avatar/AvatarBase.js +122 -0
- package/dist/granular/ui/primitives/Avatar/AvatarBase.js.map +1 -0
- package/dist/granular/ui/primitives/Tooltip/Tooltip.js +140 -117
- package/dist/granular/ui/primitives/Tooltip/Tooltip.js.map +1 -1
- package/dist/index.cjs +86 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3054 -2936
- package/dist/index.js.map +1 -1
- package/dist/react-design-system.css +1 -1
- package/dist/server/index.cjs +6 -6
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +493 -400
- package/dist/server/index.js.map +1 -1
- package/dist/ui/components/EmptyState/EmptyState.d.ts +24 -2
- package/dist/ui/primitives/Avatar/Avatar.d.ts +2 -1
- package/dist/ui/primitives/Avatar/AvatarBase.d.ts +63 -0
- package/dist/ui/primitives/Avatar/index.d.ts +2 -0
- package/dist/ui/primitives/Tooltip/Tooltip.d.ts +31 -2
- package/dist/ui/server.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,128 +1,143 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var C = Object.prototype.hasOwnProperty,
|
|
6
|
-
var
|
|
7
|
-
for (var r in
|
|
8
|
-
C.call(
|
|
9
|
-
if (
|
|
10
|
-
for (var r of
|
|
11
|
-
|
|
2
|
+
var J = Object.defineProperty, Q = Object.defineProperties;
|
|
3
|
+
var U = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var g = Object.getOwnPropertySymbols;
|
|
5
|
+
var C = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable;
|
|
6
|
+
var M = (e, n, r) => n in e ? J(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[n] = r, R = (e, n) => {
|
|
7
|
+
for (var r in n || (n = {}))
|
|
8
|
+
C.call(n, r) && M(e, r, n[r]);
|
|
9
|
+
if (g)
|
|
10
|
+
for (var r of g(n))
|
|
11
|
+
L.call(n, r) && M(e, r, n[r]);
|
|
12
12
|
return e;
|
|
13
|
-
},
|
|
14
|
-
var V = (e,
|
|
13
|
+
}, B = (e, n) => Q(e, U(n));
|
|
14
|
+
var V = (e, n) => {
|
|
15
15
|
var r = {};
|
|
16
|
-
for (var
|
|
17
|
-
C.call(e,
|
|
18
|
-
if (e != null &&
|
|
19
|
-
for (var
|
|
20
|
-
|
|
16
|
+
for (var l in e)
|
|
17
|
+
C.call(e, l) && n.indexOf(l) < 0 && (r[l] = e[l]);
|
|
18
|
+
if (e != null && g)
|
|
19
|
+
for (var l of g(e))
|
|
20
|
+
n.indexOf(l) < 0 && L.call(e, l) && (r[l] = e[l]);
|
|
21
21
|
return r;
|
|
22
22
|
};
|
|
23
|
-
import { jsxs as
|
|
24
|
-
import { forwardRef as
|
|
25
|
-
import { getBorderWidthClass as
|
|
26
|
-
import { getRadiusClass as
|
|
27
|
-
import { getShadowClass as
|
|
28
|
-
import { getSpacingClass as
|
|
29
|
-
import { getTypographySize as
|
|
30
|
-
import { getZIndexClass as
|
|
31
|
-
import { cva as
|
|
32
|
-
import { cn as
|
|
33
|
-
import { mergeRefs as
|
|
34
|
-
const
|
|
35
|
-
var y =
|
|
36
|
-
content:
|
|
23
|
+
import { jsxs as k, jsx as X } from "react/jsx-runtime";
|
|
24
|
+
import { forwardRef as Y, useState as P, useRef as w, useId as tt, useEffect as x, isValidElement as et, cloneElement as rt } from "react";
|
|
25
|
+
import { getBorderWidthClass as ot } from "../../tokens/borders.js";
|
|
26
|
+
import { getRadiusClass as nt } from "../../tokens/radius.js";
|
|
27
|
+
import { getShadowClass as at } from "../../tokens/shadows.js";
|
|
28
|
+
import { getSpacingClass as m } from "../../tokens/spacing.js";
|
|
29
|
+
import { getTypographySize as st } from "../../tokens/typography.js";
|
|
30
|
+
import { getZIndexClass as lt } from "../../tokens/z-index.js";
|
|
31
|
+
import { cva as I } from "../../utils/cva.js";
|
|
32
|
+
import { cn as s } from "../../utils/cn.js";
|
|
33
|
+
import { mergeRefs as it } from "../../utils/mergeRefs.js";
|
|
34
|
+
const ut = Y(function(ft, F) {
|
|
35
|
+
var y = ft, {
|
|
36
|
+
content: n,
|
|
37
37
|
children: r,
|
|
38
|
-
position:
|
|
39
|
-
delay:
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
position: l = "top",
|
|
39
|
+
delay: N = 200,
|
|
40
|
+
interactive: f = !1,
|
|
41
|
+
className: T = "",
|
|
42
|
+
"aria-label": ct,
|
|
43
|
+
preservePositioning: S = !1
|
|
44
|
+
} = y, D = V(y, [
|
|
44
45
|
"content",
|
|
45
46
|
"children",
|
|
46
47
|
"position",
|
|
47
48
|
"delay",
|
|
49
|
+
"interactive",
|
|
48
50
|
"className",
|
|
49
51
|
"aria-label",
|
|
50
52
|
"preservePositioning"
|
|
51
53
|
]);
|
|
52
|
-
const [
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
}, F = () => {
|
|
58
|
-
u.current && (clearTimeout(u.current), u.current = null), f(!1);
|
|
59
|
-
}, K = () => {
|
|
60
|
-
f(!0);
|
|
54
|
+
const [b, c] = P(!1), i = w(null), d = w(null), p = w(null), E = `tooltip-${tt()}`, K = () => {
|
|
55
|
+
const o = setTimeout(() => {
|
|
56
|
+
c(!0);
|
|
57
|
+
}, N);
|
|
58
|
+
i.current = o;
|
|
61
59
|
}, j = () => {
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
if (i.current && (clearTimeout(i.current), i.current = null), !f) {
|
|
61
|
+
c(!1);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const o = setTimeout(() => c(!1), 150);
|
|
65
|
+
i.current = o;
|
|
66
|
+
}, W = () => {
|
|
67
|
+
c(!0);
|
|
68
|
+
}, z = (o) => {
|
|
69
|
+
var t;
|
|
70
|
+
f && ((t = d.current) != null && t.contains(o.relatedTarget)) || c(!1);
|
|
71
|
+
}, A = (o) => {
|
|
64
72
|
var t;
|
|
65
|
-
|
|
73
|
+
o.key === "Escape" && (c(!1), (t = p.current) == null || t.blur());
|
|
74
|
+
}, O = () => {
|
|
75
|
+
i.current && (clearTimeout(i.current), i.current = null);
|
|
76
|
+
}, Z = () => {
|
|
77
|
+
c(!1);
|
|
78
|
+
}, _ = (o) => {
|
|
79
|
+
var t, v;
|
|
80
|
+
!((t = d.current) != null && t.contains(o.relatedTarget)) && !((v = p.current) != null && v.contains(o.relatedTarget)) && c(!1);
|
|
66
81
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}, []),
|
|
70
|
-
if (!
|
|
71
|
-
const
|
|
72
|
-
|
|
82
|
+
x(() => () => {
|
|
83
|
+
i.current && (clearTimeout(i.current), i.current = null);
|
|
84
|
+
}, []), x(() => {
|
|
85
|
+
if (!b) return;
|
|
86
|
+
const o = (t) => {
|
|
87
|
+
d.current && !d.current.contains(t.target) && p.current && !p.current.contains(t.target) && c(!1);
|
|
73
88
|
};
|
|
74
|
-
return document.addEventListener("mousedown",
|
|
75
|
-
document.removeEventListener("mousedown",
|
|
89
|
+
return document.addEventListener("mousedown", o), () => {
|
|
90
|
+
document.removeEventListener("mousedown", o);
|
|
76
91
|
};
|
|
77
|
-
}, [
|
|
78
|
-
const
|
|
92
|
+
}, [b]);
|
|
93
|
+
const h = (o) => ({
|
|
79
94
|
top: "border-t-surface-inverse",
|
|
80
95
|
bottom: "border-b-surface-inverse",
|
|
81
96
|
left: "border-l-surface-inverse",
|
|
82
97
|
right: "border-r-surface-inverse"
|
|
83
|
-
})[
|
|
84
|
-
|
|
98
|
+
})[o], $ = I(
|
|
99
|
+
s(
|
|
85
100
|
"absolute",
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
lt("tooltip"),
|
|
102
|
+
m("sm", "px"),
|
|
103
|
+
m("xs", "py"),
|
|
104
|
+
st("caption"),
|
|
90
105
|
"text-fg-inverse",
|
|
91
106
|
"bg-surface-inverse",
|
|
92
|
-
|
|
93
|
-
|
|
107
|
+
nt("md"),
|
|
108
|
+
at("lg"),
|
|
94
109
|
"whitespace-nowrap"
|
|
95
110
|
),
|
|
96
111
|
{
|
|
97
112
|
variants: {
|
|
98
113
|
position: {
|
|
99
|
-
top:
|
|
114
|
+
top: s(
|
|
100
115
|
"bottom-full",
|
|
101
116
|
"left-1/2",
|
|
102
117
|
"transform",
|
|
103
118
|
"-translate-x-1/2",
|
|
104
|
-
|
|
119
|
+
m("sm", "mb")
|
|
105
120
|
),
|
|
106
|
-
bottom:
|
|
121
|
+
bottom: s(
|
|
107
122
|
"top-full",
|
|
108
123
|
"left-1/2",
|
|
109
124
|
"transform",
|
|
110
125
|
"-translate-x-1/2",
|
|
111
|
-
|
|
126
|
+
m("sm", "mt")
|
|
112
127
|
),
|
|
113
|
-
left:
|
|
128
|
+
left: s(
|
|
114
129
|
"right-full",
|
|
115
130
|
"top-1/2",
|
|
116
131
|
"transform",
|
|
117
132
|
"-translate-y-1/2",
|
|
118
|
-
|
|
133
|
+
m("sm", "mr")
|
|
119
134
|
),
|
|
120
|
-
right:
|
|
135
|
+
right: s(
|
|
121
136
|
"left-full",
|
|
122
137
|
"top-1/2",
|
|
123
138
|
"transform",
|
|
124
139
|
"-translate-y-1/2",
|
|
125
|
-
|
|
140
|
+
m("sm", "ml")
|
|
126
141
|
)
|
|
127
142
|
}
|
|
128
143
|
},
|
|
@@ -130,44 +145,44 @@ const at = J(function(lt, x) {
|
|
|
130
145
|
position: "top"
|
|
131
146
|
}
|
|
132
147
|
}
|
|
133
|
-
),
|
|
134
|
-
|
|
148
|
+
), q = I(
|
|
149
|
+
s(
|
|
135
150
|
"absolute",
|
|
136
151
|
"w-0",
|
|
137
152
|
"h-0",
|
|
138
|
-
|
|
153
|
+
ot("thick"),
|
|
139
154
|
"border-transparent"
|
|
140
155
|
),
|
|
141
156
|
{
|
|
142
157
|
variants: {
|
|
143
158
|
position: {
|
|
144
|
-
top:
|
|
159
|
+
top: s(
|
|
145
160
|
"top-full",
|
|
146
161
|
"left-1/2",
|
|
147
162
|
"transform",
|
|
148
163
|
"-translate-x-1/2",
|
|
149
|
-
|
|
164
|
+
h("top")
|
|
150
165
|
),
|
|
151
|
-
bottom:
|
|
166
|
+
bottom: s(
|
|
152
167
|
"bottom-full",
|
|
153
168
|
"left-1/2",
|
|
154
169
|
"transform",
|
|
155
170
|
"-translate-x-1/2",
|
|
156
|
-
|
|
171
|
+
h("bottom")
|
|
157
172
|
),
|
|
158
|
-
left:
|
|
173
|
+
left: s(
|
|
159
174
|
"left-full",
|
|
160
175
|
"top-1/2",
|
|
161
176
|
"transform",
|
|
162
177
|
"-translate-y-1/2",
|
|
163
|
-
|
|
178
|
+
h("left")
|
|
164
179
|
),
|
|
165
|
-
right:
|
|
180
|
+
right: s(
|
|
166
181
|
"right-full",
|
|
167
182
|
"top-1/2",
|
|
168
183
|
"transform",
|
|
169
184
|
"-translate-y-1/2",
|
|
170
|
-
|
|
185
|
+
h("right")
|
|
171
186
|
)
|
|
172
187
|
}
|
|
173
188
|
},
|
|
@@ -175,53 +190,61 @@ const at = J(function(lt, x) {
|
|
|
175
190
|
position: "top"
|
|
176
191
|
}
|
|
177
192
|
}
|
|
178
|
-
),
|
|
179
|
-
const
|
|
180
|
-
return
|
|
181
|
-
ref:
|
|
182
|
-
"aria-describedby":
|
|
183
|
-
onMouseEnter: (
|
|
184
|
-
var
|
|
185
|
-
|
|
193
|
+
), G = et(r) ? (() => {
|
|
194
|
+
const o = r, t = o.props, v = t.ref;
|
|
195
|
+
return rt(o, {
|
|
196
|
+
ref: it(p, v),
|
|
197
|
+
"aria-describedby": b ? E : t["aria-describedby"],
|
|
198
|
+
onMouseEnter: (u) => {
|
|
199
|
+
var a;
|
|
200
|
+
K(), (a = t.onMouseEnter) == null || a.call(t, u);
|
|
186
201
|
},
|
|
187
|
-
onMouseLeave: (
|
|
188
|
-
var
|
|
189
|
-
|
|
202
|
+
onMouseLeave: (u) => {
|
|
203
|
+
var a;
|
|
204
|
+
j(), (a = t.onMouseLeave) == null || a.call(t, u);
|
|
190
205
|
},
|
|
191
|
-
onFocus: (
|
|
192
|
-
var
|
|
193
|
-
|
|
206
|
+
onFocus: (u) => {
|
|
207
|
+
var a;
|
|
208
|
+
W(), (a = t.onFocus) == null || a.call(t, u);
|
|
194
209
|
},
|
|
195
|
-
onBlur: (
|
|
196
|
-
var
|
|
197
|
-
|
|
210
|
+
onBlur: (u) => {
|
|
211
|
+
var a;
|
|
212
|
+
z(u), (a = t.onBlur) == null || a.call(t, u);
|
|
198
213
|
},
|
|
199
|
-
onKeyDown: (
|
|
200
|
-
var
|
|
201
|
-
|
|
214
|
+
onKeyDown: (u) => {
|
|
215
|
+
var a;
|
|
216
|
+
A(u), (a = t.onKeyDown) == null || a.call(t, u);
|
|
202
217
|
}
|
|
203
218
|
});
|
|
204
|
-
})() : r,
|
|
205
|
-
return /* @__PURE__ */
|
|
206
|
-
|
|
207
|
-
|
|
219
|
+
})() : r, H = S ? s("static", "inline-block", T) : s("relative", "inline-block", T);
|
|
220
|
+
return /* @__PURE__ */ k("div", B(R({ ref: F, className: H }, D), { children: [
|
|
221
|
+
G,
|
|
222
|
+
b && /* @__PURE__ */ k(
|
|
208
223
|
"div",
|
|
209
224
|
{
|
|
210
|
-
ref:
|
|
211
|
-
id:
|
|
212
|
-
className:
|
|
225
|
+
ref: d,
|
|
226
|
+
id: E,
|
|
227
|
+
className: s(
|
|
228
|
+
$({ position: l }),
|
|
229
|
+
// Interactive tooltips contain rich / wrappable content — override
|
|
230
|
+
// the CVA whitespace-nowrap with whitespace-normal and cap the width.
|
|
231
|
+
f && "whitespace-normal max-w-xs"
|
|
232
|
+
),
|
|
213
233
|
role: "tooltip",
|
|
214
234
|
"aria-live": "polite",
|
|
235
|
+
onMouseEnter: f ? O : void 0,
|
|
236
|
+
onMouseLeave: f ? Z : void 0,
|
|
237
|
+
onBlur: f ? _ : void 0,
|
|
215
238
|
children: [
|
|
216
|
-
|
|
217
|
-
/* @__PURE__ */
|
|
239
|
+
n,
|
|
240
|
+
/* @__PURE__ */ X("div", { className: s(q({ position: l })), "aria-hidden": "true" })
|
|
218
241
|
]
|
|
219
242
|
}
|
|
220
243
|
)
|
|
221
244
|
] }));
|
|
222
245
|
});
|
|
223
|
-
|
|
246
|
+
ut.displayName = "Tooltip";
|
|
224
247
|
export {
|
|
225
|
-
|
|
248
|
+
ut as default
|
|
226
249
|
};
|
|
227
250
|
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sources":["../../../../../src/ui/primitives/Tooltip/Tooltip.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n HTMLAttributes,\n ReactNode,\n KeyboardEvent,\n FocusEvent,\n ReactElement,\n} from \"react\";\nimport {\n forwardRef,\n useState,\n useRef,\n useEffect,\n useId,\n cloneElement,\n isValidElement,\n} from \"react\";\nimport { getBorderWidthClass } from \"../../tokens/borders\";\nimport { getRadiusClass } from \"../../tokens/radius\";\nimport { getShadowClass } from \"../../tokens/shadows\";\nimport { getSpacingClass } from \"../../tokens/spacing\";\nimport { getTypographySize } from \"../../tokens/typography\";\nimport { getZIndexClass } from \"../../tokens/z-index\";\nimport { cn, cva, mergeRefs } from \"../../utils\";\n\nexport interface TooltipProps extends HTMLAttributes<HTMLDivElement> {\n content: string;\n children: ReactNode;\n position?: \"top\" | \"bottom\" | \"left\" | \"right\";\n delay?: number;\n \"aria-label\"?: string;\n /**\n * When true, the tooltip wrapper won't interfere with absolute positioning of children.\n * The wrapper will use `position: static` instead of `position: relative`.\n */\n preservePositioning?: boolean;\n}\n\n/**\n * Tooltip Component\n *\n * A tooltip component for displaying additional information on hover.\n *\n * @example\n * ```tsx\n * <Tooltip content=\"This is a tooltip\">\n * <Button>Hover me</Button>\n * </Tooltip>\n * ```\n */\nconst Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip(\n {\n content,\n children,\n position = \"top\",\n delay = 200,\n className = \"\",\n \"aria-label\": _ariaLabel,\n preservePositioning = false,\n ...props\n },\n ref,\n) {\n const [isVisible, setIsVisible] = useState(false);\n const timeoutIdRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const tooltipRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n\n // Stable per-instance ID for the tooltip popup. useId is SSR-safe and\n // stable across renders — the previous Math.random() approach generated\n // a fresh ID on every render, which silently breaks the\n // aria-describedby <-> tooltip id pairing observed by assistive tech\n // across re-renders.\n const tooltipId = `tooltip-${useId()}`;\n\n const handleMouseEnter = () => {\n const id = setTimeout(() => {\n setIsVisible(true);\n }, delay);\n timeoutIdRef.current = id;\n };\n\n const handleMouseLeave = () => {\n if (timeoutIdRef.current) {\n clearTimeout(timeoutIdRef.current);\n timeoutIdRef.current = null;\n }\n setIsVisible(false);\n };\n\n const handleFocus = () => {\n // Show tooltip immediately on focus (no delay for keyboard users)\n setIsVisible(true);\n };\n\n const handleBlur = () => {\n setIsVisible(false);\n };\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n setIsVisible(false);\n triggerRef.current?.blur();\n }\n };\n\n // Cleanup timeout on unmount\n useEffect(() => {\n return () => {\n if (timeoutIdRef.current) {\n clearTimeout(timeoutIdRef.current);\n timeoutIdRef.current = null;\n }\n };\n }, []);\n\n // Close tooltip when clicking outside\n useEffect(() => {\n if (!isVisible) return;\n\n const handleClickOutside = (event: MouseEvent) => {\n if (\n tooltipRef.current &&\n !tooltipRef.current.contains(event.target as Node) &&\n triggerRef.current &&\n !triggerRef.current.contains(event.target as Node)\n ) {\n setIsVisible(false);\n }\n };\n\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [isVisible]);\n\n // Helper to get arrow border color\n // Uses complete classes that Tailwind can detect\n const getArrowBorderColor = (\n position: \"top\" | \"bottom\" | \"left\" | \"right\",\n ): string => {\n // Arrow follows the tooltip body's surface-inverse color so the\n // triangle's point visually merges into the body.\n const borderMap: Record<\"top\" | \"bottom\" | \"left\" | \"right\", string> = {\n top: \"border-t-surface-inverse\",\n bottom: \"border-b-surface-inverse\",\n left: \"border-l-surface-inverse\",\n right: \"border-r-surface-inverse\",\n };\n return borderMap[position];\n };\n\n // Tooltip variants using CVA\n const tooltipVariants = cva(\n cn(\n \"absolute\",\n getZIndexClass(\"tooltip\"),\n getSpacingClass(\"sm\", \"px\"),\n getSpacingClass(\"xs\", \"py\"),\n getTypographySize(\"caption\"),\n \"text-fg-inverse\",\n \"bg-surface-inverse\",\n getRadiusClass(\"md\"),\n getShadowClass(\"lg\"),\n \"whitespace-nowrap\",\n ),\n {\n variants: {\n position: {\n top: cn(\n \"bottom-full\",\n \"left-1/2\",\n \"transform\",\n \"-translate-x-1/2\",\n getSpacingClass(\"sm\", \"mb\"),\n ),\n bottom: cn(\n \"top-full\",\n \"left-1/2\",\n \"transform\",\n \"-translate-x-1/2\",\n getSpacingClass(\"sm\", \"mt\"),\n ),\n left: cn(\n \"right-full\",\n \"top-1/2\",\n \"transform\",\n \"-translate-y-1/2\",\n getSpacingClass(\"sm\", \"mr\"),\n ),\n right: cn(\n \"left-full\",\n \"top-1/2\",\n \"transform\",\n \"-translate-y-1/2\",\n getSpacingClass(\"sm\", \"ml\"),\n ),\n },\n },\n defaultVariants: {\n position: \"top\",\n },\n },\n );\n\n const arrowVariants = cva(\n cn(\n \"absolute\",\n \"w-0\",\n \"h-0\",\n getBorderWidthClass(\"thick\"),\n \"border-transparent\",\n ),\n {\n variants: {\n position: {\n top: cn(\n \"top-full\",\n \"left-1/2\",\n \"transform\",\n \"-translate-x-1/2\",\n getArrowBorderColor(\"top\"),\n ),\n bottom: cn(\n \"bottom-full\",\n \"left-1/2\",\n \"transform\",\n \"-translate-x-1/2\",\n getArrowBorderColor(\"bottom\"),\n ),\n left: cn(\n \"left-full\",\n \"top-1/2\",\n \"transform\",\n \"-translate-y-1/2\",\n getArrowBorderColor(\"left\"),\n ),\n right: cn(\n \"right-full\",\n \"top-1/2\",\n \"transform\",\n \"-translate-y-1/2\",\n getArrowBorderColor(\"right\"),\n ),\n },\n },\n defaultVariants: {\n position: \"top\",\n },\n },\n );\n\n // Clone children to add accessibility props\n const childrenWithProps = isValidElement(children)\n ? (() => {\n const childElement = children as ReactElement<\n HTMLAttributes<HTMLElement> & { ref?: React.Ref<HTMLElement> }\n >;\n const existingProps = childElement.props;\n const existingRef = existingProps.ref;\n\n return cloneElement(childElement, {\n ref: mergeRefs<HTMLElement>(triggerRef, existingRef),\n \"aria-describedby\": isVisible\n ? tooltipId\n : existingProps[\"aria-describedby\"],\n onMouseEnter: (e: React.MouseEvent<HTMLElement>) => {\n handleMouseEnter();\n existingProps.onMouseEnter?.(e);\n },\n onMouseLeave: (e: React.MouseEvent<HTMLElement>) => {\n handleMouseLeave();\n existingProps.onMouseLeave?.(e);\n },\n onFocus: (e: FocusEvent<HTMLElement>) => {\n handleFocus();\n existingProps.onFocus?.(e);\n },\n onBlur: (e: FocusEvent<HTMLElement>) => {\n handleBlur();\n existingProps.onBlur?.(e);\n },\n onKeyDown: (e: KeyboardEvent<HTMLElement>) => {\n handleKeyDown(e);\n existingProps.onKeyDown?.(e);\n },\n } as Partial<typeof existingProps>);\n })()\n : children;\n\n // When preservePositioning is true, use static positioning to avoid interfering\n // with absolute positioned children. The tooltip will still be positioned correctly\n // using absolute positioning relative to the viewport/nearest positioned ancestor.\n const wrapperClassName = preservePositioning\n ? cn(\"static\", \"inline-block\", className)\n : cn(\"relative\", \"inline-block\", className);\n\n return (\n <div ref={ref} className={wrapperClassName} {...props}>\n {childrenWithProps}\n {isVisible && (\n <div\n ref={tooltipRef}\n id={tooltipId}\n className={cn(tooltipVariants({ position }))}\n role=\"tooltip\"\n aria-live=\"polite\"\n >\n {content}\n <div className={cn(arrowVariants({ position }))} aria-hidden=\"true\" />\n </div>\n )}\n </div>\n );\n});\n\nTooltip.displayName = \"Tooltip\";\n\nexport default Tooltip;\n"],"names":["Tooltip","forwardRef","_a","ref","_b","content","children","position","delay","className","_ariaLabel","preservePositioning","props","__objRest","isVisible","setIsVisible","useState","timeoutIdRef","useRef","tooltipRef","triggerRef","tooltipId","useId","handleMouseEnter","id","handleMouseLeave","handleFocus","handleBlur","handleKeyDown","e","useEffect","handleClickOutside","event","getArrowBorderColor","tooltipVariants","cva","cn","getZIndexClass","getSpacingClass","getTypographySize","getRadiusClass","getShadowClass","arrowVariants","getBorderWidthClass","childrenWithProps","isValidElement","childElement","existingProps","existingRef","cloneElement","mergeRefs","wrapperClassName","__spreadProps","__spreadValues","jsxs","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAMA,KAAUC,EAAyC,SACvDC,IAUAC,GACA;AAXA,MAAAC,IAAAF,IACE;AAAA,aAAAG;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,OAAAC,IAAQ;AAAA,IACR,WAAAC,IAAY;AAAA,IACZ,cAAcC;AAAA,IACd,qBAAAC,IAAsB;AAAA,MAPxBP,GAQKQ,IAAAC,EARLT,GAQK;AAAA,IAPH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAKF,QAAM,CAACU,GAAWC,CAAY,IAAIC,EAAS,EAAK,GAC1CC,IAAeC,EAA6C,IAAI,GAChEC,IAAaD,EAAuB,IAAI,GACxCE,IAAaF,EAA2B,IAAI,GAO5CG,IAAY,W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EACE,UAAA;AAAA,IAAAgC;AAAA,IACA9B,KACC,gBAAAwC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAKnC;AAAA,QACL,IAAIE;AAAA,QACJ,WAAWe,EAAGF,EAAgB,EAAE,UAAA3B,EAAA,CAAU,CAAC;AAAA,QAC3C,MAAK;AAAA,QACL,aAAU;AAAA,QAET,UAAA;AAAA,UAAAF;AAAA,UACD,gBAAAkD,EAAC,OAAA,EAAI,WAAWnB,EAAGM,EAAc,EAAE,UAAAnC,GAAU,CAAC,GAAG,eAAY,OAAA,CAAO;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACtE,IAEJ;AAEJ,CAAC;AAEDP,GAAQ,cAAc;"}
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sources":["../../../../../src/ui/primitives/Tooltip/Tooltip.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n HTMLAttributes,\n ReactNode,\n KeyboardEvent,\n FocusEvent,\n ReactElement,\n} from \"react\";\nimport {\n forwardRef,\n useState,\n useRef,\n useEffect,\n useId,\n cloneElement,\n isValidElement,\n} from \"react\";\nimport { getBorderWidthClass } from \"../../tokens/borders\";\nimport { getRadiusClass } from \"../../tokens/radius\";\nimport { getShadowClass } from \"../../tokens/shadows\";\nimport { getSpacingClass } from \"../../tokens/spacing\";\nimport { getTypographySize } from \"../../tokens/typography\";\nimport { getZIndexClass } from \"../../tokens/z-index\";\nimport { cn, cva, mergeRefs } from \"../../utils\";\n\n// Omit the native HTML `content` attribute (string | undefined) so we can\n// widen it to ReactNode without a type conflict.\nexport interface TooltipProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n \"content\"\n> {\n content: ReactNode;\n children: ReactNode;\n position?: \"top\" | \"bottom\" | \"left\" | \"right\";\n delay?: number;\n /**\n * When true, the tooltip panel stays open while the pointer hovers over it\n * (150 ms grace-period bridge), and keyboard focus may move into focusable\n * elements inside the panel (e.g. links). Use for educational / rich\n * tooltips that contain interactive content.\n *\n * @default false\n */\n interactive?: boolean;\n \"aria-label\"?: string;\n /**\n * When true, the tooltip wrapper won't interfere with absolute positioning of children.\n * The wrapper will use `position: static` instead of `position: relative`.\n */\n preservePositioning?: boolean;\n}\n\n/**\n * Tooltip Component\n *\n * A tooltip component for displaying additional information on hover.\n *\n * Pass `content` as a plain string for simple labels, or as a `ReactNode`\n * for rich / educational content. Set `interactive` when the panel contains\n * clickable elements (links, buttons) — the tooltip then stays open while\n * the pointer is over the panel and while keyboard focus is inside it.\n *\n * @example\n * ```tsx\n * // Simple string\n * <Tooltip content=\"This is a tooltip\">\n * <Button>Hover me</Button>\n * </Tooltip>\n *\n * // Rich interactive content\n * <Tooltip\n * interactive\n * content={\n * <>\n * <strong>Pirâmide de Confiança L2</strong>\n * <p>Dados verificados por fonte oficial.</p>\n * <a href=\"/ajuda/piramide\">Saiba mais</a>\n * </>\n * }\n * >\n * <Badge>L2</Badge>\n * </Tooltip>\n * ```\n */\nconst Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip(\n {\n content,\n children,\n position = \"top\",\n delay = 200,\n interactive = false,\n className = \"\",\n \"aria-label\": _ariaLabel,\n preservePositioning = false,\n ...props\n },\n ref,\n) {\n const [isVisible, setIsVisible] = useState(false);\n const timeoutIdRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const tooltipRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n\n // Stable per-instance ID for the tooltip popup. useId is SSR-safe and\n // stable across renders — the previous Math.random() approach generated\n // a fresh ID on every render, which silently breaks the\n // aria-describedby <-> tooltip id pairing observed by assistive tech\n // across re-renders.\n const tooltipId = `tooltip-${useId()}`;\n\n const handleMouseEnter = () => {\n const id = setTimeout(() => {\n setIsVisible(true);\n }, delay);\n timeoutIdRef.current = id;\n };\n\n const handleMouseLeave = () => {\n if (timeoutIdRef.current) {\n clearTimeout(timeoutIdRef.current);\n timeoutIdRef.current = null;\n }\n if (!interactive) {\n setIsVisible(false);\n return;\n }\n // Grace period — allows the pointer to travel from the trigger to the\n // tooltip panel without the tooltip closing in between.\n const id = setTimeout(() => setIsVisible(false), 150);\n timeoutIdRef.current = id;\n };\n\n const handleFocus = () => {\n // Show tooltip immediately on focus (no delay for keyboard users)\n setIsVisible(true);\n };\n\n const handleBlur = (e: FocusEvent<HTMLElement>) => {\n // When interactive, keep the tooltip open if focus moves into the panel.\n if (interactive && tooltipRef.current?.contains(e.relatedTarget as Node)) {\n return;\n }\n setIsVisible(false);\n };\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n setIsVisible(false);\n triggerRef.current?.blur();\n }\n };\n\n // --- Interactive tooltip panel handlers ---\n\n const handleTooltipMouseEnter = () => {\n // Cancel the pending close started by handleMouseLeave's grace period.\n if (timeoutIdRef.current) {\n clearTimeout(timeoutIdRef.current);\n timeoutIdRef.current = null;\n }\n };\n\n const handleTooltipMouseLeave = () => {\n setIsVisible(false);\n };\n\n const handleTooltipBlur = (e: React.FocusEvent<HTMLDivElement>) => {\n // Close only when focus leaves both the panel AND the trigger.\n if (\n !tooltipRef.current?.contains(e.relatedTarget as Node) &&\n !triggerRef.current?.contains(e.relatedTarget as Node)\n ) {\n setIsVisible(false);\n }\n };\n\n // Cleanup timeout on unmount\n useEffect(() => {\n return () => {\n if (timeoutIdRef.current) {\n clearTimeout(timeoutIdRef.current);\n timeoutIdRef.current = null;\n }\n };\n }, []);\n\n // Close tooltip when clicking outside\n useEffect(() => {\n if (!isVisible) return;\n\n const handleClickOutside = (event: MouseEvent) => {\n if (\n tooltipRef.current &&\n !tooltipRef.current.contains(event.target as Node) &&\n triggerRef.current &&\n !triggerRef.current.contains(event.target as Node)\n ) {\n setIsVisible(false);\n }\n };\n\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [isVisible]);\n\n // Helper to get arrow border color\n // Uses complete classes that Tailwind can detect\n const getArrowBorderColor = (\n pos: \"top\" | \"bottom\" | \"left\" | \"right\",\n ): string => {\n // Arrow follows the tooltip body's surface-inverse color so the\n // triangle's point visually merges into the body.\n const borderMap: Record<\"top\" | \"bottom\" | \"left\" | \"right\", string> = {\n top: \"border-t-surface-inverse\",\n bottom: \"border-b-surface-inverse\",\n left: \"border-l-surface-inverse\",\n right: \"border-r-surface-inverse\",\n };\n return borderMap[pos];\n };\n\n // Tooltip variants using CVA\n const tooltipVariants = cva(\n cn(\n \"absolute\",\n getZIndexClass(\"tooltip\"),\n getSpacingClass(\"sm\", \"px\"),\n getSpacingClass(\"xs\", \"py\"),\n getTypographySize(\"caption\"),\n \"text-fg-inverse\",\n \"bg-surface-inverse\",\n getRadiusClass(\"md\"),\n getShadowClass(\"lg\"),\n \"whitespace-nowrap\",\n ),\n {\n variants: {\n position: {\n top: cn(\n \"bottom-full\",\n \"left-1/2\",\n \"transform\",\n \"-translate-x-1/2\",\n getSpacingClass(\"sm\", \"mb\"),\n ),\n bottom: cn(\n \"top-full\",\n \"left-1/2\",\n \"transform\",\n \"-translate-x-1/2\",\n getSpacingClass(\"sm\", \"mt\"),\n ),\n left: cn(\n \"right-full\",\n \"top-1/2\",\n \"transform\",\n \"-translate-y-1/2\",\n getSpacingClass(\"sm\", \"mr\"),\n ),\n right: cn(\n \"left-full\",\n \"top-1/2\",\n \"transform\",\n \"-translate-y-1/2\",\n getSpacingClass(\"sm\", \"ml\"),\n ),\n },\n },\n defaultVariants: {\n position: \"top\",\n },\n },\n );\n\n const arrowVariants = cva(\n cn(\n \"absolute\",\n \"w-0\",\n \"h-0\",\n getBorderWidthClass(\"thick\"),\n \"border-transparent\",\n ),\n {\n variants: {\n position: {\n top: cn(\n \"top-full\",\n \"left-1/2\",\n \"transform\",\n \"-translate-x-1/2\",\n getArrowBorderColor(\"top\"),\n ),\n bottom: cn(\n \"bottom-full\",\n \"left-1/2\",\n \"transform\",\n \"-translate-x-1/2\",\n getArrowBorderColor(\"bottom\"),\n ),\n left: cn(\n \"left-full\",\n \"top-1/2\",\n \"transform\",\n \"-translate-y-1/2\",\n getArrowBorderColor(\"left\"),\n ),\n right: cn(\n \"right-full\",\n \"top-1/2\",\n \"transform\",\n \"-translate-y-1/2\",\n getArrowBorderColor(\"right\"),\n ),\n },\n },\n defaultVariants: {\n position: \"top\",\n },\n },\n );\n\n // Clone children to add accessibility props\n const childrenWithProps = isValidElement(children)\n ? (() => {\n const childElement = children as ReactElement<\n HTMLAttributes<HTMLElement> & { ref?: React.Ref<HTMLElement> }\n >;\n const existingProps = childElement.props;\n const existingRef = existingProps.ref;\n\n return cloneElement(childElement, {\n ref: mergeRefs<HTMLElement>(triggerRef, existingRef),\n \"aria-describedby\": isVisible\n ? tooltipId\n : existingProps[\"aria-describedby\"],\n onMouseEnter: (e: React.MouseEvent<HTMLElement>) => {\n handleMouseEnter();\n existingProps.onMouseEnter?.(e);\n },\n onMouseLeave: (e: React.MouseEvent<HTMLElement>) => {\n handleMouseLeave();\n existingProps.onMouseLeave?.(e);\n },\n onFocus: (e: FocusEvent<HTMLElement>) => {\n handleFocus();\n existingProps.onFocus?.(e);\n },\n onBlur: (e: FocusEvent<HTMLElement>) => {\n handleBlur(e);\n existingProps.onBlur?.(e);\n },\n onKeyDown: (e: KeyboardEvent<HTMLElement>) => {\n handleKeyDown(e);\n existingProps.onKeyDown?.(e);\n },\n } as Partial<typeof existingProps>);\n })()\n : children;\n\n // When preservePositioning is true, use static positioning to avoid interfering\n // with absolute positioned children. The tooltip will still be positioned correctly\n // using absolute positioning relative to the viewport/nearest positioned ancestor.\n const wrapperClassName = preservePositioning\n ? cn(\"static\", \"inline-block\", className)\n : cn(\"relative\", \"inline-block\", className);\n\n return (\n <div ref={ref} className={wrapperClassName} {...props}>\n {childrenWithProps}\n {isVisible && (\n <div\n ref={tooltipRef}\n id={tooltipId}\n className={cn(\n tooltipVariants({ position }),\n // Interactive tooltips contain rich / wrappable content — override\n // the CVA whitespace-nowrap with whitespace-normal and cap the width.\n interactive && \"whitespace-normal max-w-xs\",\n )}\n role=\"tooltip\"\n aria-live=\"polite\"\n onMouseEnter={interactive ? handleTooltipMouseEnter : undefined}\n onMouseLeave={interactive ? handleTooltipMouseLeave : undefined}\n onBlur={interactive ? handleTooltipBlur : undefined}\n >\n {content}\n <div className={cn(arrowVariants({ position }))} aria-hidden=\"true\" />\n </div>\n )}\n </div>\n );\n});\n\nTooltip.displayName = \"Tooltip\";\n\nexport default Tooltip;\n"],"names":["Tooltip","forwardRef","_a","ref","_b","content","children","position","delay","interactive","className","_ariaLabel","preservePositioning","props","__objRest","isVisible","setIsVisible","useState","timeoutIdRef","useRef","tooltipRef","triggerRef","tooltipId","useId","handleMouseEnter","id","handleMouseLeave","handleFocus","handleBlur","e","handleKeyDown","handleTooltipMouseEnter","handleTooltipMouseLeave","handleTooltipBlur","useEffect","handleClickOutside","event","getArrowBorderColor","pos","tooltipVariants","cva","cn","getZIndexClass","getSpacingClass","getTypographySize","getRadiusClass","getShadowClass","arrowVariants","getBorderWidthClass","childrenWithProps","isValidElement","childElement","existingProps","existingRef","cloneElement","mergeRefs","wrapperClassName","__spreadProps","__spreadValues","jsxs","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,MAAMA,KAAUC,EAAyC,SACvDC,IAWAC,GACA;AAZA,MAAAC,IAAAF,IACE;AAAA,aAAAG;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,OAAAC,IAAQ;AAAA,IACR,aAAAC,IAAc;AAAA,IACd,WAAAC,IAAY;AAAA,IACZ,cAAcC;AAAA,IACd,qBAAAC,IAAsB;AAAA,MARxBR,GASKS,IAAAC,EATLV,GASK;AAAA,IARH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAKF,QAAM,CAACW,GAAWC,CAAY,IAAIC,EAAS,EAAK,GAC1CC,IAAeC,EAA6C,IAAI,GAChEC,IAAaD,EAAuB,IA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