@versini/ui-tooltip 1.0.2 → 1.1.1

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