@versini/ui-tooltip 1.1.2 → 1.2.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 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, delay, className, arrowClassName, }: TooltipTypes.Props) => react_jsx_runtime.JSX.Element;
7
+ declare const Tooltip: ({ trigger, label, placement, mode, delay, className, tooltipClassName, arrowClassName, }: TooltipTypes.Props) => react_jsx_runtime.JSX.Element;
8
8
 
9
9
  export { TOOLTIP_ARROW_CLASSNAME, TOOLTIP_CLASSNAME, Tooltip };
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { jsxs as yt, jsx as Vt } from "react/jsx-runtime";
2
2
  import { useRef as lt, useState as Wt, useCallback as Ft, useEffect as $t } from "react";
3
- import W from "clsx";
3
+ import F from "clsx";
4
4
  /*!
5
- @versini/ui-tooltip v1.1.2
5
+ @versini/ui-tooltip v1.2.0
6
6
  © 2025 gizmette.com
7
7
  */
8
8
  try {
9
9
  window.__VERSINI_UI_TOOLTIP__ || (window.__VERSINI_UI_TOOLTIP__ = {
10
- version: "1.1.2",
11
- buildTime: "01/20/2025 01:05 PM EST",
10
+ version: "1.2.0",
11
+ buildTime: "01/20/2025 01:49 PM EST",
12
12
  homepage: "https://github.com/aversini/ui-components",
13
13
  license: "MIT"
14
14
  });
@@ -32,7 +32,7 @@ function ft(t, e, o) {
32
32
  function Q(t, e) {
33
33
  return typeof t == "function" ? t(e) : t;
34
34
  }
35
- function F(t) {
35
+ function $(t) {
36
36
  return t.split("-")[0];
37
37
  }
38
38
  function Z(t) {
@@ -45,16 +45,16 @@ function gt(t) {
45
45
  return t === "y" ? "height" : "width";
46
46
  }
47
47
  function Y(t) {
48
- return ["top", "bottom"].includes(F(t)) ? "y" : "x";
48
+ return ["top", "bottom"].includes($(t)) ? "y" : "x";
49
49
  }
50
50
  function pt(t) {
51
51
  return Ot(Y(t));
52
52
  }
53
53
  function zt(t, e, o) {
54
54
  o === void 0 && (o = !1);
55
- const n = Z(t), i = pt(t), s = gt(i);
56
- let r = i === "x" ? n === (o ? "end" : "start") ? "right" : "left" : n === "start" ? "bottom" : "top";
57
- return e.reference[s] > e.floating[s] && (r = ot(r)), [r, ot(r)];
55
+ const n = Z(t), i = pt(t), r = gt(i);
56
+ let s = i === "x" ? n === (o ? "end" : "start") ? "right" : "left" : n === "start" ? "bottom" : "top";
57
+ return e.reference[r] > e.floating[r] && (s = ot(s)), [s, ot(s)];
58
58
  }
59
59
  function Xt(t) {
60
60
  const e = ot(t);
@@ -64,22 +64,22 @@ function ut(t) {
64
64
  return t.replace(/start|end/g, (e) => Yt[e]);
65
65
  }
66
66
  function Ut(t, e, o) {
67
- const n = ["left", "right"], i = ["right", "left"], s = ["top", "bottom"], r = ["bottom", "top"];
67
+ const n = ["left", "right"], i = ["right", "left"], r = ["top", "bottom"], s = ["bottom", "top"];
68
68
  switch (t) {
69
69
  case "top":
70
70
  case "bottom":
71
71
  return o ? e ? i : n : e ? n : i;
72
72
  case "left":
73
73
  case "right":
74
- return e ? s : r;
74
+ return e ? r : s;
75
75
  default:
76
76
  return [];
77
77
  }
78
78
  }
79
79
  function Kt(t, e, o, n) {
80
80
  const i = Z(t);
81
- let s = Ut(F(t), o === "start", n);
82
- return i && (s = s.map((r) => r + "-" + i), e && (s = s.concat(s.map(ut)))), s;
81
+ let r = Ut($(t), o === "start", n);
82
+ return i && (r = r.map((s) => s + "-" + i), e && (r = r.concat(r.map(ut)))), r;
83
83
  }
84
84
  function ot(t) {
85
85
  return t.replace(/left|right|bottom|top/g, (e) => jt[e]);
@@ -124,7 +124,7 @@ function bt(t, e, o) {
124
124
  reference: n,
125
125
  floating: i
126
126
  } = t;
127
- const s = Y(e), r = pt(e), c = gt(r), l = F(e), a = s === "y", d = n.x + n.width / 2 - i.width / 2, f = n.y + n.height / 2 - i.height / 2, m = n[c] / 2 - i[c] / 2;
127
+ const r = Y(e), s = pt(e), c = gt(s), l = $(e), a = r === "y", d = n.x + n.width / 2 - i.width / 2, f = n.y + n.height / 2 - i.height / 2, m = n[c] / 2 - i[c] / 2;
128
128
  let u;
129
129
  switch (l) {
130
130
  case "top":
@@ -159,10 +159,10 @@ function bt(t, e, o) {
159
159
  }
160
160
  switch (Z(e)) {
161
161
  case "start":
162
- u[r] -= m * (o && a ? -1 : 1);
162
+ u[s] -= m * (o && a ? -1 : 1);
163
163
  break;
164
164
  case "end":
165
- u[r] += m * (o && a ? -1 : 1);
165
+ u[s] += m * (o && a ? -1 : 1);
166
166
  break;
167
167
  }
168
168
  return u;
@@ -171,10 +171,10 @@ const Gt = async (t, e, o) => {
171
171
  const {
172
172
  placement: n = "bottom",
173
173
  strategy: i = "absolute",
174
- middleware: s = [],
175
- platform: r
176
- } = o, c = s.filter(Boolean), l = await (r.isRTL == null ? void 0 : r.isRTL(e));
177
- let a = await r.getElementRects({
174
+ middleware: r = [],
175
+ platform: s
176
+ } = o, c = r.filter(Boolean), l = await (s.isRTL == null ? void 0 : s.isRTL(e));
177
+ let a = await s.getElementRects({
178
178
  reference: t,
179
179
  floating: e,
180
180
  strategy: i
@@ -199,7 +199,7 @@ const Gt = async (t, e, o) => {
199
199
  strategy: i,
200
200
  middlewareData: u,
201
201
  rects: a,
202
- platform: r,
202
+ platform: s,
203
203
  elements: {
204
204
  reference: t,
205
205
  floating: e
@@ -211,7 +211,7 @@ const Gt = async (t, e, o) => {
211
211
  ...u[h],
212
212
  ...v
213
213
  }
214
- }, b && g <= 50 && (g++, typeof b == "object" && (b.placement && (m = b.placement), b.rects && (a = b.rects === !0 ? await r.getElementRects({
214
+ }, b && g <= 50 && (g++, typeof b == "object" && (b.placement && (m = b.placement), b.rects && (a = b.rects === !0 ? await s.getElementRects({
215
215
  reference: t,
216
216
  floating: e,
217
217
  strategy: i
@@ -234,8 +234,8 @@ async function St(t, e) {
234
234
  const {
235
235
  x: n,
236
236
  y: i,
237
- platform: s,
238
- rects: r,
237
+ platform: r,
238
+ rects: s,
239
239
  elements: c,
240
240
  strategy: l
241
241
  } = t, {
@@ -244,23 +244,23 @@ async function St(t, e) {
244
244
  elementContext: f = "floating",
245
245
  altBoundary: m = !1,
246
246
  padding: u = 0
247
- } = Q(e, t), g = Rt(u), h = c[m ? f === "floating" ? "reference" : "floating" : f], w = it(await s.getClippingRect({
248
- element: (o = await (s.isElement == null ? void 0 : s.isElement(h))) == null || o ? h : h.contextElement || await (s.getDocumentElement == null ? void 0 : s.getDocumentElement(c.floating)),
247
+ } = Q(e, t), g = Rt(u), h = c[m ? f === "floating" ? "reference" : "floating" : f], w = it(await r.getClippingRect({
248
+ element: (o = await (r.isElement == null ? void 0 : r.isElement(h))) == null || o ? h : h.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(c.floating)),
249
249
  boundary: a,
250
250
  rootBoundary: d,
251
251
  strategy: l
252
252
  })), x = f === "floating" ? {
253
253
  x: n,
254
254
  y: i,
255
- width: r.floating.width,
256
- height: r.floating.height
257
- } : r.reference, y = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(c.floating)), v = await (s.isElement == null ? void 0 : s.isElement(y)) ? await (s.getScale == null ? void 0 : s.getScale(y)) || {
255
+ width: s.floating.width,
256
+ height: s.floating.height
257
+ } : s.reference, y = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(c.floating)), v = await (r.isElement == null ? void 0 : r.isElement(y)) ? await (r.getScale == null ? void 0 : r.getScale(y)) || {
258
258
  x: 1,
259
259
  y: 1
260
260
  } : {
261
261
  x: 1,
262
262
  y: 1
263
- }, b = it(s.convertOffsetParentRelativeRectToViewportRelativeRect ? await s.convertOffsetParentRelativeRectToViewportRelativeRect({
263
+ }, b = it(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
264
264
  elements: c,
265
265
  rect: x,
266
266
  offsetParent: y,
@@ -281,8 +281,8 @@ const Jt = (t) => ({
281
281
  x: o,
282
282
  y: n,
283
283
  placement: i,
284
- rects: s,
285
- platform: r,
284
+ rects: r,
285
+ platform: s,
286
286
  elements: c,
287
287
  middlewareData: l
288
288
  } = e, {
@@ -294,10 +294,10 @@ const Jt = (t) => ({
294
294
  const f = Rt(d), m = {
295
295
  x: o,
296
296
  y: n
297
- }, u = pt(i), g = gt(u), p = await r.getDimensions(a), h = u === "y", w = h ? "top" : "left", x = h ? "bottom" : "right", y = h ? "clientHeight" : "clientWidth", v = s.reference[g] + s.reference[u] - m[u] - s.floating[g], b = m[u] - s.reference[u], $ = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(a));
298
- let _ = $ ? $[y] : 0;
299
- (!_ || !await (r.isElement == null ? void 0 : r.isElement($))) && (_ = c.floating[y] || s.floating[g]);
300
- const U = v / 2 - b / 2, B = _ / 2 - p[g] / 2 - 1, P = G(f[w], B), K = G(f[x], B), V = P, q = _ - p[g] - K, A = _ / 2 - p[g] / 2 + U, I = ft(V, A, q), E = !l.arrow && Z(i) != null && A !== I && s.reference[g] / 2 - (A < V ? P : K) - p[g] / 2 < 0, R = E ? A < V ? A - V : A - q : 0;
297
+ }, u = pt(i), g = gt(u), p = await s.getDimensions(a), h = u === "y", w = h ? "top" : "left", x = h ? "bottom" : "right", y = h ? "clientHeight" : "clientWidth", v = r.reference[g] + r.reference[u] - m[u] - r.floating[g], b = m[u] - r.reference[u], P = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(a));
298
+ let B = P ? P[y] : 0;
299
+ (!B || !await (s.isElement == null ? void 0 : s.isElement(P))) && (B = c.floating[y] || r.floating[g]);
300
+ const U = v / 2 - b / 2, V = B / 2 - p[g] / 2 - 1, D = G(f[w], V), K = G(f[x], V), W = D, q = B - p[g] - K, A = B / 2 - p[g] / 2 + U, I = ft(W, A, q), E = !l.arrow && Z(i) != null && A !== I && r.reference[g] / 2 - (A < W ? D : K) - p[g] / 2 < 0, R = E ? A < W ? A - W : A - q : 0;
301
301
  return {
302
302
  [u]: m[u] + R,
303
303
  data: {
@@ -318,8 +318,8 @@ const Jt = (t) => ({
318
318
  var o, n;
319
319
  const {
320
320
  placement: i,
321
- middlewareData: s,
322
- rects: r,
321
+ middlewareData: r,
322
+ rects: s,
323
323
  initialPlacement: c,
324
324
  platform: l,
325
325
  elements: a
@@ -332,46 +332,46 @@ const Jt = (t) => ({
332
332
  flipAlignment: p = !0,
333
333
  ...h
334
334
  } = Q(t, e);
335
- if ((o = s.arrow) != null && o.alignmentOffset)
335
+ if ((o = r.arrow) != null && o.alignmentOffset)
336
336
  return {};
337
- const w = F(i), x = Y(c), y = F(c) === c, v = await (l.isRTL == null ? void 0 : l.isRTL(a.floating)), b = m || (y || !p ? [ot(c)] : Xt(c)), $ = g !== "none";
338
- !m && $ && b.push(...Kt(c, p, g, v));
339
- const _ = [c, ...b], U = await St(e, h), B = [];
340
- let P = ((n = s.flip) == null ? void 0 : n.overflows) || [];
341
- if (d && B.push(U[w]), f) {
342
- const A = zt(i, r, v);
343
- B.push(U[A[0]], U[A[1]]);
337
+ const w = $(i), x = Y(c), y = $(c) === c, v = await (l.isRTL == null ? void 0 : l.isRTL(a.floating)), b = m || (y || !p ? [ot(c)] : Xt(c)), P = g !== "none";
338
+ !m && P && b.push(...Kt(c, p, g, v));
339
+ const B = [c, ...b], U = await St(e, h), V = [];
340
+ let D = ((n = r.flip) == null ? void 0 : n.overflows) || [];
341
+ if (d && V.push(U[w]), f) {
342
+ const A = zt(i, s, v);
343
+ V.push(U[A[0]], U[A[1]]);
344
344
  }
345
- if (P = [...P, {
345
+ if (D = [...D, {
346
346
  placement: i,
347
- overflows: B
348
- }], !B.every((A) => A <= 0)) {
349
- var K, V;
350
- const A = (((K = s.flip) == null ? void 0 : K.index) || 0) + 1, I = _[A];
347
+ overflows: V
348
+ }], !V.every((A) => A <= 0)) {
349
+ var K, W;
350
+ const A = (((K = r.flip) == null ? void 0 : K.index) || 0) + 1, I = B[A];
351
351
  if (I)
352
352
  return {
353
353
  data: {
354
354
  index: A,
355
- overflows: P
355
+ overflows: D
356
356
  },
357
357
  reset: {
358
358
  placement: I
359
359
  }
360
360
  };
361
- let E = (V = P.filter((R) => R.overflows[0] <= 0).sort((R, D) => R.overflows[1] - D.overflows[1])[0]) == null ? void 0 : V.placement;
361
+ let E = (W = D.filter((R) => R.overflows[0] <= 0).sort((R, N) => R.overflows[1] - N.overflows[1])[0]) == null ? void 0 : W.placement;
362
362
  if (!E)
363
363
  switch (u) {
364
364
  case "bestFit": {
365
365
  var q;
366
- const R = (q = P.filter((D) => {
367
- if ($) {
368
- const N = Y(D.placement);
369
- return N === x || // Create a bias to the `y` side axis due to horizontal
366
+ const R = (q = D.filter((N) => {
367
+ if (P) {
368
+ const M = Y(N.placement);
369
+ return M === x || // Create a bias to the `y` side axis due to horizontal
370
370
  // reading directions favoring greater width.
371
- N === "y";
371
+ M === "y";
372
372
  }
373
373
  return !0;
374
- }).map((D) => [D.placement, D.overflows.filter((N) => N > 0).reduce((N, Bt) => N + Bt, 0)]).sort((D, N) => D[1] - N[1])[0]) == null ? void 0 : q[0];
374
+ }).map((N) => [N.placement, N.overflows.filter((M) => M > 0).reduce((M, Bt) => M + Bt, 0)]).sort((N, M) => N[1] - M[1])[0]) == null ? void 0 : q[0];
375
375
  R && (E = R);
376
376
  break;
377
377
  }
@@ -395,7 +395,7 @@ async function Zt(t, e) {
395
395
  placement: o,
396
396
  platform: n,
397
397
  elements: i
398
- } = t, s = await (n.isRTL == null ? void 0 : n.isRTL(i.floating)), r = F(o), c = Z(o), l = Y(o) === "y", a = ["left", "top"].includes(r) ? -1 : 1, d = s && l ? -1 : 1, f = Q(e, t);
398
+ } = t, r = await (n.isRTL == null ? void 0 : n.isRTL(i.floating)), s = $(o), c = Z(o), l = Y(o) === "y", a = ["left", "top"].includes(s) ? -1 : 1, d = r && l ? -1 : 1, f = Q(e, t);
399
399
  let {
400
400
  mainAxis: m,
401
401
  crossAxis: u,
@@ -425,16 +425,16 @@ const te = function(t) {
425
425
  var o, n;
426
426
  const {
427
427
  x: i,
428
- y: s,
429
- placement: r,
428
+ y: r,
429
+ placement: s,
430
430
  middlewareData: c
431
431
  } = e, l = await Zt(e, t);
432
- return r === ((o = c.offset) == null ? void 0 : o.placement) && (n = c.arrow) != null && n.alignmentOffset ? {} : {
432
+ return s === ((o = c.offset) == null ? void 0 : o.placement) && (n = c.arrow) != null && n.alignmentOffset ? {} : {
433
433
  x: i + l.x,
434
- y: s + l.y,
434
+ y: r + l.y,
435
435
  data: {
436
436
  ...l,
437
- placement: r
437
+ placement: s
438
438
  }
439
439
  };
440
440
  }
@@ -449,8 +449,8 @@ const te = function(t) {
449
449
  y: n,
450
450
  placement: i
451
451
  } = e, {
452
- mainAxis: s = !0,
453
- crossAxis: r = !1,
452
+ mainAxis: r = !0,
453
+ crossAxis: s = !1,
454
454
  limiter: c = {
455
455
  fn: (h) => {
456
456
  let {
@@ -467,13 +467,13 @@ const te = function(t) {
467
467
  } = Q(t, e), a = {
468
468
  x: o,
469
469
  y: n
470
- }, d = await St(e, l), f = Y(F(i)), m = Ot(f);
470
+ }, d = await St(e, l), f = Y($(i)), m = Ot(f);
471
471
  let u = a[m], g = a[f];
472
- if (s) {
472
+ if (r) {
473
473
  const h = m === "y" ? "top" : "left", w = m === "y" ? "bottom" : "right", x = u + d[h], y = u - d[w];
474
474
  u = ft(x, u, y);
475
475
  }
476
- if (r) {
476
+ if (s) {
477
477
  const h = f === "y" ? "top" : "left", w = f === "y" ? "bottom" : "right", x = g + d[h], y = g - d[w];
478
478
  g = ft(x, g, y);
479
479
  }
@@ -488,8 +488,8 @@ const te = function(t) {
488
488
  x: p.x - o,
489
489
  y: p.y - n,
490
490
  enabled: {
491
- [m]: s,
492
- [f]: r
491
+ [m]: r,
492
+ [f]: s
493
493
  }
494
494
  }
495
495
  };
@@ -548,13 +548,13 @@ function ht(t) {
548
548
  return ["transform", "translate", "scale", "rotate", "perspective"].some((n) => o[n] ? o[n] !== "none" : !1) || (o.containerType ? o.containerType !== "normal" : !1) || !e && (o.backdropFilter ? o.backdropFilter !== "none" : !1) || !e && (o.filter ? o.filter !== "none" : !1) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((n) => (o.willChange || "").includes(n)) || ["paint", "layout", "strict", "content"].some((n) => (o.contain || "").includes(n));
549
549
  }
550
550
  function oe(t) {
551
- let e = M(t);
551
+ let e = _(t);
552
552
  for (; k(e) && !z(e); ) {
553
553
  if (ht(e))
554
554
  return e;
555
555
  if (rt(e))
556
556
  return null;
557
- e = M(e);
557
+ e = _(e);
558
558
  }
559
559
  return null;
560
560
  }
@@ -576,7 +576,7 @@ function ct(t) {
576
576
  scrollTop: t.scrollY
577
577
  };
578
578
  }
579
- function M(t) {
579
+ function _(t) {
580
580
  if (X(t) === "html")
581
581
  return t;
582
582
  const e = (
@@ -589,16 +589,16 @@ function M(t) {
589
589
  return vt(e) ? e.host : e;
590
590
  }
591
591
  function Et(t) {
592
- const e = M(t);
592
+ const e = _(t);
593
593
  return z(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : k(e) && tt(e) ? e : Et(e);
594
594
  }
595
595
  function dt(t, e, o) {
596
596
  var n;
597
597
  e === void 0 && (e = []), o === void 0 && (o = !0);
598
- const i = Et(t), s = i === ((n = t.ownerDocument) == null ? void 0 : n.body), r = T(i);
599
- if (s) {
600
- const c = mt(r);
601
- return e.concat(r, r.visualViewport || [], tt(i) ? i : [], c && o ? dt(c) : []);
598
+ const i = Et(t), r = i === ((n = t.ownerDocument) == null ? void 0 : n.body), s = T(i);
599
+ if (r) {
600
+ const c = mt(s);
601
+ return e.concat(s, s.visualViewport || [], tt(i) ? i : [], c && o ? dt(c) : []);
602
602
  }
603
603
  return e.concat(i, dt(i, [], o));
604
604
  }
@@ -608,8 +608,8 @@ function mt(t) {
608
608
  function Lt(t) {
609
609
  const e = O(t);
610
610
  let o = parseFloat(e.width) || 0, n = parseFloat(e.height) || 0;
611
- const i = k(t), s = i ? t.offsetWidth : o, r = i ? t.offsetHeight : n, c = nt(o) !== s || nt(n) !== r;
612
- return c && (o = s, n = r), {
611
+ const i = k(t), r = i ? t.offsetWidth : o, s = i ? t.offsetHeight : n, c = nt(o) !== r || nt(n) !== s;
612
+ return c && (o = r, n = s), {
613
613
  width: o,
614
614
  height: n,
615
615
  $: c
@@ -625,11 +625,11 @@ function j(t) {
625
625
  const o = e.getBoundingClientRect(), {
626
626
  width: n,
627
627
  height: i,
628
- $: s
628
+ $: r
629
629
  } = Lt(e);
630
- let r = (s ? nt(o.width) : o.width) / n, c = (s ? nt(o.height) : o.height) / i;
631
- return (!r || !Number.isFinite(r)) && (r = 1), (!c || !Number.isFinite(c)) && (c = 1), {
632
- x: r,
630
+ let s = (r ? nt(o.width) : o.width) / n, c = (r ? nt(o.height) : o.height) / i;
631
+ return (!s || !Number.isFinite(s)) && (s = 1), (!c || !Number.isFinite(c)) && (c = 1), {
632
+ x: s,
633
633
  y: c
634
634
  };
635
635
  }
@@ -646,13 +646,13 @@ function se(t, e, o) {
646
646
  }
647
647
  function J(t, e, o, n) {
648
648
  e === void 0 && (e = !1), o === void 0 && (o = !1);
649
- const i = t.getBoundingClientRect(), s = Pt(t);
650
- let r = S(1);
651
- e && (n ? C(n) && (r = j(n)) : r = j(t));
652
- const c = se(s, o, n) ? Dt(s) : S(0);
653
- let l = (i.left + c.x) / r.x, a = (i.top + c.y) / r.y, d = i.width / r.x, f = i.height / r.y;
654
- if (s) {
655
- const m = T(s), u = n && C(n) ? T(n) : n;
649
+ const i = t.getBoundingClientRect(), r = Pt(t);
650
+ let s = S(1);
651
+ e && (n ? C(n) && (s = j(n)) : s = j(t));
652
+ const c = se(r, o, n) ? Dt(r) : S(0);
653
+ let l = (i.left + c.x) / s.x, a = (i.top + c.y) / s.y, d = i.width / s.x, f = i.height / s.y;
654
+ if (r) {
655
+ const m = T(r), u = n && C(n) ? T(n) : n;
656
656
  let g = m, p = mt(g);
657
657
  for (; p && n && u !== g; ) {
658
658
  const h = j(p), w = p.getBoundingClientRect(), x = O(p), y = w.left + (p.clientLeft + parseFloat(x.paddingLeft)) * h.x, v = w.top + (p.clientTop + parseFloat(x.paddingTop)) * h.y;
@@ -675,10 +675,10 @@ function Nt(t, e, o) {
675
675
  const n = t.getBoundingClientRect(), i = n.left + e.scrollLeft - (o ? 0 : (
676
676
  // RTL <body> scrollbar.
677
677
  xt(t, n)
678
- )), s = n.top + e.scrollTop;
678
+ )), r = n.top + e.scrollTop;
679
679
  return {
680
680
  x: i,
681
- y: s
681
+ y: r
682
682
  };
683
683
  }
684
684
  function re(t) {
@@ -688,19 +688,19 @@ function re(t) {
688
688
  offsetParent: n,
689
689
  strategy: i
690
690
  } = t;
691
- const s = i === "fixed", r = L(n), c = e ? rt(e.floating) : !1;
692
- if (n === r || c && s)
691
+ const r = i === "fixed", s = L(n), c = e ? rt(e.floating) : !1;
692
+ if (n === s || c && r)
693
693
  return o;
694
694
  let l = {
695
695
  scrollLeft: 0,
696
696
  scrollTop: 0
697
697
  }, a = S(1);
698
698
  const d = S(0), f = k(n);
699
- if ((f || !f && !s) && ((X(n) !== "body" || tt(r)) && (l = ct(n)), k(n))) {
699
+ if ((f || !f && !r) && ((X(n) !== "body" || tt(s)) && (l = ct(n)), k(n))) {
700
700
  const u = J(n);
701
701
  a = j(n), d.x = u.x + n.clientLeft, d.y = u.y + n.clientTop;
702
702
  }
703
- const m = r && !f && !s ? Nt(r, l, !0) : S(0);
703
+ const m = s && !f && !r ? Nt(s, l, !0) : S(0);
704
704
  return {
705
705
  width: o.width * a.x,
706
706
  height: o.height * a.y,
@@ -712,35 +712,35 @@ function ce(t) {
712
712
  return Array.from(t.getClientRects());
713
713
  }
714
714
  function le(t) {
715
- const e = L(t), o = ct(t), n = t.ownerDocument.body, i = H(e.scrollWidth, e.clientWidth, n.scrollWidth, n.clientWidth), s = H(e.scrollHeight, e.clientHeight, n.scrollHeight, n.clientHeight);
716
- let r = -o.scrollLeft + xt(t);
715
+ const e = L(t), o = ct(t), n = t.ownerDocument.body, i = H(e.scrollWidth, e.clientWidth, n.scrollWidth, n.clientWidth), r = H(e.scrollHeight, e.clientHeight, n.scrollHeight, n.clientHeight);
716
+ let s = -o.scrollLeft + xt(t);
717
717
  const c = -o.scrollTop;
718
- return O(n).direction === "rtl" && (r += H(e.clientWidth, n.clientWidth) - i), {
718
+ return O(n).direction === "rtl" && (s += H(e.clientWidth, n.clientWidth) - i), {
719
719
  width: i,
720
- height: s,
721
- x: r,
720
+ height: r,
721
+ x: s,
722
722
  y: c
723
723
  };
724
724
  }
725
725
  function ae(t, e) {
726
726
  const o = T(t), n = L(t), i = o.visualViewport;
727
- let s = n.clientWidth, r = n.clientHeight, c = 0, l = 0;
727
+ let r = n.clientWidth, s = n.clientHeight, c = 0, l = 0;
728
728
  if (i) {
729
- s = i.width, r = i.height;
729
+ r = i.width, s = i.height;
730
730
  const a = wt();
731
731
  (!a || a && e === "fixed") && (c = i.offsetLeft, l = i.offsetTop);
732
732
  }
733
733
  return {
734
- width: s,
735
- height: r,
734
+ width: r,
735
+ height: s,
736
736
  x: c,
737
737
  y: l
738
738
  };
739
739
  }
740
740
  function fe(t, e) {
741
- const o = J(t, !0, e === "fixed"), n = o.top + t.clientTop, i = o.left + t.clientLeft, s = k(t) ? j(t) : S(1), r = t.clientWidth * s.x, c = t.clientHeight * s.y, l = i * s.x, a = n * s.y;
741
+ const o = J(t, !0, e === "fixed"), n = o.top + t.clientTop, i = o.left + t.clientLeft, r = k(t) ? j(t) : S(1), s = t.clientWidth * r.x, c = t.clientHeight * r.y, l = i * r.x, a = n * r.y;
742
742
  return {
743
- width: r,
743
+ width: s,
744
744
  height: c,
745
745
  x: l,
746
746
  y: a
@@ -766,7 +766,7 @@ function At(t, e, o) {
766
766
  return it(n);
767
767
  }
768
768
  function Mt(t, e) {
769
- const o = M(t);
769
+ const o = _(t);
770
770
  return o === e || !C(o) || z(o) ? !1 : O(o).position === "fixed" || Mt(o, e);
771
771
  }
772
772
  function ue(t, e) {
@@ -774,11 +774,11 @@ function ue(t, e) {
774
774
  if (o)
775
775
  return o;
776
776
  let n = dt(t, [], !1).filter((c) => C(c) && X(c) !== "body"), i = null;
777
- const s = O(t).position === "fixed";
778
- let r = s ? M(t) : t;
779
- for (; C(r) && !z(r); ) {
780
- const c = O(r), l = ht(r);
781
- !l && c.position === "fixed" && (i = null), (s ? !l && !i : !l && c.position === "static" && !!i && ["absolute", "fixed"].includes(i.position) || tt(r) && !l && Mt(t, r)) ? n = n.filter((d) => d !== r) : i = c, r = M(r);
777
+ const r = O(t).position === "fixed";
778
+ let s = r ? _(t) : t;
779
+ for (; C(s) && !z(s); ) {
780
+ const c = O(s), l = ht(s);
781
+ !l && c.position === "fixed" && (i = null), (r ? !l && !i : !l && c.position === "static" && !!i && ["absolute", "fixed"].includes(i.position) || tt(s) && !l && Mt(t, s)) ? n = n.filter((d) => d !== s) : i = c, s = _(s);
782
782
  }
783
783
  return e.set(t, n), n;
784
784
  }
@@ -789,7 +789,7 @@ function de(t) {
789
789
  rootBoundary: n,
790
790
  strategy: i
791
791
  } = t;
792
- const r = [...o === "clippingAncestors" ? rt(e) ? [] : ue(e, this._c) : [].concat(o), n], c = r[0], l = r.reduce((a, d) => {
792
+ const s = [...o === "clippingAncestors" ? rt(e) ? [] : ue(e, this._c) : [].concat(o), n], c = s[0], l = s.reduce((a, d) => {
793
793
  const f = At(e, d, i);
794
794
  return a.top = H(f.top, a.top), a.right = G(f.right, a.right), a.bottom = G(f.bottom, a.bottom), a.left = H(f.left, a.left), a;
795
795
  }, At(e, c, i));
@@ -811,23 +811,23 @@ function me(t) {
811
811
  };
812
812
  }
813
813
  function ge(t, e, o) {
814
- const n = k(e), i = L(e), s = o === "fixed", r = J(t, !0, s, e);
814
+ const n = k(e), i = L(e), r = o === "fixed", s = J(t, !0, r, e);
815
815
  let c = {
816
816
  scrollLeft: 0,
817
817
  scrollTop: 0
818
818
  };
819
819
  const l = S(0);
820
- if (n || !n && !s)
820
+ if (n || !n && !r)
821
821
  if ((X(e) !== "body" || tt(i)) && (c = ct(e)), n) {
822
- const m = J(e, !0, s, e);
822
+ const m = J(e, !0, r, e);
823
823
  l.x = m.x + e.clientLeft, l.y = m.y + e.clientTop;
824
824
  } else i && (l.x = xt(i));
825
- const a = i && !n && !s ? Nt(i, c) : S(0), d = r.left + c.scrollLeft - l.x - a.x, f = r.top + c.scrollTop - l.y - a.y;
825
+ const a = i && !n && !r ? Nt(i, c) : S(0), d = s.left + c.scrollLeft - l.x - a.x, f = s.top + c.scrollTop - l.y - a.y;
826
826
  return {
827
827
  x: d,
828
828
  y: f,
829
- width: r.width,
830
- height: r.height
829
+ width: s.width,
830
+ height: s.height
831
831
  };
832
832
  }
833
833
  function at(t) {
@@ -846,11 +846,11 @@ function _t(t, e) {
846
846
  if (rt(t))
847
847
  return o;
848
848
  if (!k(t)) {
849
- let i = M(t);
849
+ let i = _(t);
850
850
  for (; i && !z(i); ) {
851
851
  if (C(i) && !at(i))
852
852
  return i;
853
- i = M(i);
853
+ i = _(i);
854
854
  }
855
855
  return o;
856
856
  }
@@ -889,46 +889,47 @@ const we = {
889
889
  const n = /* @__PURE__ */ new Map(), i = {
890
890
  platform: we,
891
891
  ...o
892
- }, s = {
892
+ }, r = {
893
893
  ...i.platform,
894
894
  _c: n
895
895
  };
896
896
  return Gt(t, e, {
897
897
  ...i,
898
- platform: s
898
+ platform: r
899
899
  });
900
- }, et = (t, e = "px") => typeof t > "u" ? "" : `${Math.round(t)}${e}`, Te = () => W("absolute top-0 left-0 w-max py-1 px-2 rounded text-sm z-50"), Ct = ({
900
+ }, et = (t, e = "px") => typeof t > "u" ? "" : `${Math.round(t)}${e}`, Te = () => F("absolute top-0 left-0 w-max py-1 px-2 rounded text-sm z-50"), Ct = ({
901
901
  mode: t
902
- }) => W({
902
+ }) => F({
903
903
  "bg-surface-darker": t === "dark" || t === "system",
904
904
  "bg-surface-light": t === "light" || t === "alt-system",
905
905
  "dark:bg-surface-light": t === "system",
906
906
  "dark:bg-surface-darker": t === "alt-system"
907
907
  }), Ce = ({
908
908
  mode: t
909
- }) => W({
909
+ }) => F({
910
910
  "text-copy-light": t === "dark" || t === "system",
911
911
  "text-copy-dark": t === "light" || t === "alt-system",
912
912
  "dark:text-copy-dark": t === "system",
913
913
  "dark:text-copy-light": t === "alt-system"
914
- }), Oe = () => W("absolute", "size-2", "transform rotate-45"), Re = ({
914
+ }), Oe = () => F("absolute", "size-2", "transform rotate-45"), Re = ({
915
915
  mode: t,
916
916
  className: e,
917
- arrowClassName: o
917
+ tooltipClassName: o,
918
+ arrowClassName: n
918
919
  }) => {
919
- const n = W("relative inline-block"), i = W(
920
+ const i = F("relative inline-block", e), r = F(
920
921
  It,
921
922
  Te(),
922
923
  Ct({ mode: t }),
923
924
  Ce({ mode: t }),
924
- e
925
- ), s = W(
925
+ o
926
+ ), s = F(
926
927
  Ht,
927
928
  Oe(),
928
929
  Ct({ mode: t }),
929
- o
930
+ n
930
931
  );
931
- return { tooltip: i, arrow: s, wrapper: n };
932
+ return { tooltip: r, arrow: s, wrapper: i };
932
933
  }, Se = ({ delay: t = 300 }) => ({
933
934
  animation: `av-tooltip-fade-in ${t}ms ease-in-out`
934
935
  }), Pe = ({
@@ -937,18 +938,24 @@ const we = {
937
938
  placement: o = "top",
938
939
  mode: n = "system",
939
940
  delay: i = 300,
940
- className: s,
941
- arrowClassName: r
941
+ className: r,
942
+ tooltipClassName: s,
943
+ arrowClassName: c
942
944
  }) => {
943
- const c = lt(null), l = lt(null), a = lt(null), [d, f] = Wt(!1), m = Re({ mode: n, className: s, arrowClassName: r }), u = Se({ delay: i }), g = Ft(async () => {
944
- var p, h;
945
- if (c.current && l.current && a.current) {
945
+ const l = lt(null), a = lt(null), d = lt(null), [f, m] = Wt(!1), u = Re({
946
+ mode: n,
947
+ className: r,
948
+ tooltipClassName: s,
949
+ arrowClassName: c
950
+ }), g = Se({ delay: i }), p = Ft(async () => {
951
+ var h, w;
952
+ if (l.current && a.current && d.current) {
946
953
  const {
947
- x: w,
948
- y: x,
949
- middlewareData: y,
950
- placement: v
951
- } = await Ae(c.current, l.current, {
954
+ x,
955
+ y,
956
+ middlewareData: v,
957
+ placement: b
958
+ } = await Ae(l.current, a.current, {
952
959
  placement: o,
953
960
  middleware: [
954
961
  xe(10),
@@ -957,50 +964,50 @@ const we = {
957
964
  fallbackAxisSideDirection: "start"
958
965
  }),
959
966
  ye({ padding: 5 }),
960
- ve({ element: a.current })
967
+ ve({ element: d.current })
961
968
  ]
962
969
  });
963
- Object.assign(l.current.style, {
964
- left: et(w),
965
- top: et(x),
966
- ...u
970
+ Object.assign(a.current.style, {
971
+ left: et(x),
972
+ top: et(y),
973
+ ...g
967
974
  });
968
- const b = {
975
+ const P = {
969
976
  top: "bottom",
970
977
  right: "left",
971
978
  bottom: "top",
972
979
  left: "right"
973
- }[v.split("-")[0]];
974
- Object.assign(a.current.style, {
975
- left: et((p = y.arrow) == null ? void 0 : p.x),
976
- top: et((h = y.arrow) == null ? void 0 : h.y),
980
+ }[b.split("-")[0]];
981
+ Object.assign(d.current.style, {
982
+ left: et((h = v.arrow) == null ? void 0 : h.x),
983
+ top: et((w = v.arrow) == null ? void 0 : w.y),
977
984
  right: "",
978
985
  bottom: "",
979
- [b]: "-4px"
986
+ [P]: "-4px"
980
987
  });
981
988
  }
982
- }, [o, u]);
989
+ }, [o, g]);
983
990
  return $t(() => {
984
- (async () => d && await g())();
985
- }, [g, d]), /* @__PURE__ */ yt(
991
+ (async () => f && await p())();
992
+ }, [p, f]), /* @__PURE__ */ yt(
986
993
  "div",
987
994
  {
988
- className: m.wrapper,
989
- ref: c,
990
- onMouseEnter: () => f(!0),
991
- onMouseLeave: () => f(!1),
992
- onClick: () => f(!1),
995
+ className: u.wrapper,
996
+ ref: l,
997
+ onMouseEnter: () => m(!0),
998
+ onMouseLeave: () => m(!1),
999
+ onClick: () => m(!1),
993
1000
  children: [
994
1001
  t,
995
- d && /* @__PURE__ */ yt(
1002
+ f && /* @__PURE__ */ yt(
996
1003
  "div",
997
1004
  {
998
1005
  role: "tooltip",
999
- ref: l,
1000
- className: m.tooltip,
1006
+ ref: a,
1007
+ className: u.tooltip,
1001
1008
  children: [
1002
1009
  e,
1003
- /* @__PURE__ */ Vt("div", { ref: a, className: m.arrow })
1010
+ /* @__PURE__ */ Vt("div", { ref: d, className: u.arrow })
1004
1011
  ]
1005
1012
  }
1006
1013
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/ui-tooltip",
3
- "version": "1.1.2",
3
+ "version": "1.2.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.3.1"
41
+ "@versini/ui-types": "4.4.0"
42
42
  },
43
43
  "dependencies": {
44
44
  "@floating-ui/dom": "1.6.13",
@@ -49,5 +49,5 @@
49
49
  "sideEffects": [
50
50
  "**/*.css"
51
51
  ],
52
- "gitHead": "1542a19c98ab5af85458a93e788576f97549e589"
52
+ "gitHead": "5018e3c37dea17fe8d0635e6d16fd6a3d6f14282"
53
53
  }