@versini/ui-tooltip 1.0.1 → 1.1.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/index.d.ts +1 -1
- package/dist/index.js +96 -64
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ import { TooltipTypes } from '@versini/ui-types';
|
|
|
4
4
|
declare const TOOLTIP_CLASSNAME = "av-tooltip";
|
|
5
5
|
declare const TOOLTIP_ARROW_CLASSNAME = "av-tooltip-arrow";
|
|
6
6
|
|
|
7
|
-
declare const Tooltip: ({ trigger, label, placement, mode, }: TooltipTypes.Props) => react_jsx_runtime.JSX.Element;
|
|
7
|
+
declare const Tooltip: ({ trigger, label, placement, mode, initialOpen, open: controlledOpen, onOpenChange: setControlledOpen, delay, }: TooltipTypes.Props) => react_jsx_runtime.JSX.Element;
|
|
8
8
|
|
|
9
9
|
export { TOOLTIP_ARROW_CLASSNAME, TOOLTIP_CLASSNAME, Tooltip };
|
package/dist/index.js
CHANGED
|
@@ -1,117 +1,149 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useFloating as
|
|
3
|
-
import { useState as
|
|
4
|
-
import
|
|
1
|
+
import { jsxs as T, Fragment as F, jsx as w } from "react/jsx-runtime";
|
|
2
|
+
import { useFloating as L, autoUpdate as N, arrow as M, offset as U, flip as V, shift as D, useTransitionStyles as j, useHover as B, useFocus as H, useDismiss as W, useRole as q, useInteractions as z, FloatingPortal as G, FloatingArrow as J } from "@floating-ui/react";
|
|
3
|
+
import { useState as _, useRef as u, cloneElement as K, useCallback as Q, useEffect as b } from "react";
|
|
4
|
+
import n from "clsx";
|
|
5
5
|
/*!
|
|
6
|
-
@versini/ui-tooltip v1.0
|
|
6
|
+
@versini/ui-tooltip v1.1.0
|
|
7
7
|
© 2025 gizmette.com
|
|
8
8
|
*/
|
|
9
9
|
try {
|
|
10
10
|
window.__VERSINI_UI_TOOLTIP__ || (window.__VERSINI_UI_TOOLTIP__ = {
|
|
11
|
-
version: "1.0
|
|
12
|
-
buildTime: "01/
|
|
11
|
+
version: "1.1.0",
|
|
12
|
+
buildTime: "01/19/2025 01:35 PM EST",
|
|
13
13
|
homepage: "https://github.com/aversini/ui-components",
|
|
14
14
|
license: "MIT"
|
|
15
15
|
});
|
|
16
16
|
} catch {
|
|
17
17
|
}
|
|
18
|
-
const
|
|
18
|
+
const X = "av-tooltip", Y = "av-tooltip-arrow", Z = () => n("w-max py-1 px-2 rounded text-sm"), $ = ({
|
|
19
19
|
mode: t
|
|
20
|
-
}) =>
|
|
20
|
+
}) => n({
|
|
21
21
|
"bg-surface-darker": t === "dark" || t === "system",
|
|
22
22
|
"bg-surface-light": t === "light" || t === "alt-system",
|
|
23
23
|
"dark:bg-surface-light": t === "system",
|
|
24
24
|
"dark:bg-surface-darker": t === "alt-system"
|
|
25
|
-
}),
|
|
25
|
+
}), tt = ({
|
|
26
26
|
mode: t
|
|
27
|
-
}) =>
|
|
27
|
+
}) => n({
|
|
28
28
|
"text-copy-light": t === "dark" || t === "system",
|
|
29
29
|
"text-copy-dark": t === "light" || t === "alt-system",
|
|
30
30
|
"dark:text-copy-dark": t === "system",
|
|
31
31
|
"dark:text-copy-light": t === "alt-system"
|
|
32
|
-
}),
|
|
32
|
+
}), et = ({
|
|
33
33
|
mode: t
|
|
34
|
-
}) =>
|
|
34
|
+
}) => n({
|
|
35
35
|
"fill-surface-darker [&>path:first-of-type]:bg-surface-darker [&>path:last-of-type]:bg-surface-darker": t === "dark" || t === "system",
|
|
36
36
|
"fill-surface-light [&>path:first-of-type]:bg-surface-light [&>path:last-of-type]:bg-surface-light": t === "light" || t === "alt-system",
|
|
37
37
|
"dark:fill-surface-light dark:[&>path:first-of-type]:bg-surface-light dark:[&>path:last-of-type]:bg-surface-light": t === "system",
|
|
38
38
|
"dark:fill-surface-darker dark:[&>path:first-of-type]:bg-surface-darker dark:[&>path:last-of-type]:bg-surface-darker": t === "alt-system"
|
|
39
|
-
}),
|
|
39
|
+
}), st = ({
|
|
40
40
|
mode: t
|
|
41
41
|
}) => {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
),
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
const e = n(
|
|
43
|
+
X,
|
|
44
|
+
Z(),
|
|
45
|
+
$({ mode: t }),
|
|
46
|
+
tt({ mode: t })
|
|
47
|
+
), s = n(
|
|
48
|
+
Y,
|
|
49
|
+
et({ mode: t })
|
|
50
50
|
);
|
|
51
|
-
return { tooltip:
|
|
52
|
-
}
|
|
51
|
+
return { tooltip: e, arrow: s };
|
|
52
|
+
};
|
|
53
|
+
function rt(t, e, s = { active: !0 }) {
|
|
54
|
+
const [p, l] = _(t), o = u(!1), r = u(null), c = u(!1), a = Q(() => {
|
|
55
|
+
const f = r.current;
|
|
56
|
+
f && window.clearTimeout(f);
|
|
57
|
+
}, []);
|
|
58
|
+
return b(() => {
|
|
59
|
+
if (!s.active) {
|
|
60
|
+
l(t);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
o.current && (a(), r.current = window.setTimeout(() => {
|
|
64
|
+
c.current = !1, l(t);
|
|
65
|
+
}, e));
|
|
66
|
+
}, [t, s, e, a]), b(() => (o.current = !0, a), [a]), [p];
|
|
67
|
+
}
|
|
68
|
+
const ct = ({
|
|
53
69
|
trigger: t,
|
|
54
|
-
label:
|
|
55
|
-
placement:
|
|
56
|
-
mode: p = "system"
|
|
70
|
+
label: e,
|
|
71
|
+
placement: s = "top",
|
|
72
|
+
mode: p = "system",
|
|
73
|
+
initialOpen: l = !1,
|
|
74
|
+
open: o,
|
|
75
|
+
onOpenChange: r,
|
|
76
|
+
delay: c = 300
|
|
57
77
|
}) => {
|
|
58
|
-
const [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
78
|
+
const [a, f] = _(l), h = o !== void 0;
|
|
79
|
+
h && o === !1 && (c = 0);
|
|
80
|
+
const [g] = rt(
|
|
81
|
+
o ?? a,
|
|
82
|
+
c,
|
|
83
|
+
{
|
|
84
|
+
active: h
|
|
85
|
+
}
|
|
86
|
+
), x = r ?? f, y = u(null), { refs: k, floatingStyles: I, context: i } = L({
|
|
87
|
+
open: g,
|
|
88
|
+
onOpenChange: (m) => {
|
|
89
|
+
x(m), r == null || r(m);
|
|
90
|
+
},
|
|
91
|
+
placement: s,
|
|
62
92
|
// Make sure the tooltip stays on the screen
|
|
63
|
-
whileElementsMounted:
|
|
93
|
+
whileElementsMounted: N,
|
|
64
94
|
middleware: [
|
|
65
|
-
|
|
66
|
-
element:
|
|
95
|
+
M({
|
|
96
|
+
element: y
|
|
67
97
|
}),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
crossAxis:
|
|
98
|
+
U(11),
|
|
99
|
+
V({
|
|
100
|
+
crossAxis: s.includes("-"),
|
|
71
101
|
fallbackAxisSideDirection: "start"
|
|
72
102
|
}),
|
|
73
|
-
|
|
103
|
+
D()
|
|
74
104
|
]
|
|
75
|
-
}), { styles:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
105
|
+
}), { styles: R } = j(i), d = st({ mode: p }), S = B(i, { move: !1, delay: { open: c } }), C = H(i), v = W(i, {
|
|
106
|
+
referencePress: !0
|
|
107
|
+
}), A = q(i, { role: "tooltip" }), { getReferenceProps: E, getFloatingProps: P } = z([
|
|
108
|
+
S,
|
|
109
|
+
C,
|
|
110
|
+
v,
|
|
111
|
+
A
|
|
112
|
+
]), O = K(
|
|
81
113
|
t,
|
|
82
114
|
{
|
|
83
|
-
"aria-label":
|
|
84
|
-
"data-open": String(
|
|
85
|
-
ref:
|
|
86
|
-
...
|
|
115
|
+
"aria-label": e,
|
|
116
|
+
"data-open": String(g),
|
|
117
|
+
ref: k.setReference,
|
|
118
|
+
...E()
|
|
87
119
|
}
|
|
88
120
|
);
|
|
89
|
-
return /* @__PURE__ */
|
|
90
|
-
|
|
91
|
-
/* @__PURE__ */
|
|
121
|
+
return /* @__PURE__ */ T(F, { children: [
|
|
122
|
+
O,
|
|
123
|
+
/* @__PURE__ */ w(G, { children: g && /* @__PURE__ */ T(
|
|
92
124
|
"div",
|
|
93
125
|
{
|
|
94
|
-
className:
|
|
95
|
-
ref:
|
|
96
|
-
style: { ...
|
|
97
|
-
...
|
|
126
|
+
className: d.tooltip,
|
|
127
|
+
ref: k.setFloating,
|
|
128
|
+
style: { ...I, ...R },
|
|
129
|
+
...P(),
|
|
98
130
|
children: [
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
|
|
131
|
+
/* @__PURE__ */ w(
|
|
132
|
+
J,
|
|
101
133
|
{
|
|
102
|
-
ref:
|
|
103
|
-
context:
|
|
104
|
-
className:
|
|
134
|
+
ref: y,
|
|
135
|
+
context: i,
|
|
136
|
+
className: d.arrow
|
|
105
137
|
}
|
|
106
138
|
),
|
|
107
|
-
|
|
139
|
+
e
|
|
108
140
|
]
|
|
109
141
|
}
|
|
110
142
|
) })
|
|
111
143
|
] });
|
|
112
144
|
};
|
|
113
145
|
export {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
146
|
+
Y as TOOLTIP_ARROW_CLASSNAME,
|
|
147
|
+
X as TOOLTIP_CLASSNAME,
|
|
148
|
+
ct as Tooltip
|
|
117
149
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-tooltip",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"react-dom": "^18.3.1 || ^19.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@versini/ui-types": "4.
|
|
41
|
+
"@versini/ui-types": "4.3.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@floating-ui/react": "0.27.3",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"sideEffects": [
|
|
50
50
|
"**/*.css"
|
|
51
51
|
],
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "bcefcad80e918262a953b30742e66db32b2fefa5"
|
|
53
53
|
}
|