@purpurds/tooltip 3.2.0 → 3.3.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.
@@ -1,6 +1,6 @@
1
1
  import { jsxs as Ue, jsx as I } from "react/jsx-runtime";
2
2
  import * as N from "react";
3
- import { forwardRef as M, useCallback as k, createContext as Ge, useMemo as ye, createElement as _, useContext as Tt, Fragment as $n, Children as se, isValidElement as Ie, cloneElement as Je, useEffect as R, useRef as L, useState as j, useLayoutEffect as Ct, useReducer as wn } from "react";
3
+ import { forwardRef as M, useCallback as H, createContext as Ge, useMemo as ye, createElement as _, useContext as Tt, Fragment as $n, Children as se, isValidElement as Ie, cloneElement as Je, useEffect as R, useRef as L, useState as j, useLayoutEffect as Ct, useReducer as wn } from "react";
4
4
  import * as _n from "react-dom";
5
5
  import An, { flushSync as Rt } from "react-dom";
6
6
  const Pn = {
@@ -263,8 +263,8 @@ var Lt = { exports: {} };
263
263
  e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
264
264
  })();
265
265
  })(Lt);
266
- var kn = Lt.exports;
267
- const Hn = /* @__PURE__ */ Fn(kn), Bn = {
266
+ var Hn = Lt.exports;
267
+ const kn = /* @__PURE__ */ Fn(Hn), Bn = {
268
268
  "purpur-icon": "_purpur-icon_8u1lq_1",
269
269
  "purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
270
270
  "purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
@@ -285,7 +285,7 @@ const Hn = /* @__PURE__ */ Fn(kn), Bn = {
285
285
  }
286
286
  );
287
287
  Mt.displayName = "IconInfo";
288
- const Wn = Hn.bind(Bn), gt = "purpur-icon", Vn = "md", zn = (e) => e.filter((t) => Object.keys(t).length >= 1).map((t) => `${t.name}="${t.value}"`).join(" "), Un = ({ content: e = "", title: t } = {}) => {
288
+ const Wn = kn.bind(Bn), gt = "purpur-icon", Vn = "md", zn = (e) => e.filter((t) => Object.keys(t).length >= 1).map((t) => `${t.name}="${t.value}"`).join(" "), Un = ({ content: e = "", title: t } = {}) => {
289
289
  const n = [
290
290
  { name: "xmlns", value: "http://www.w3.org/2000/svg" },
291
291
  { name: "fill", value: "currentColor" },
@@ -420,15 +420,15 @@ function G(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
420
420
  function Qn(e, t) {
421
421
  typeof e == "function" ? e(t) : e != null && (e.current = t);
422
422
  }
423
- function kt(...e) {
423
+ function Ht(...e) {
424
424
  return (t) => e.forEach(
425
425
  (n) => Qn(n, t)
426
426
  );
427
427
  }
428
428
  function pe(...e) {
429
- return k(kt(...e), e);
429
+ return H(Ht(...e), e);
430
430
  }
431
- function Ht(e, t = []) {
431
+ function kt(e, t = []) {
432
432
  let n = [];
433
433
  function o(r, s) {
434
434
  const a = /* @__PURE__ */ Ge(s), c = n.length;
@@ -529,7 +529,7 @@ const Ye = /* @__PURE__ */ M((e, t) => {
529
529
  const { children: n, ...o } = e;
530
530
  return /* @__PURE__ */ Ie(n) ? /* @__PURE__ */ Je(n, {
531
531
  ...nr(o, n.props),
532
- ref: t ? kt(t, n.ref) : n.ref
532
+ ref: t ? Ht(t, n.ref) : n.ref
533
533
  }) : se.count(n) > 1 ? se.only(null) : null;
534
534
  });
535
535
  Ye.displayName = "SlotClone";
@@ -798,10 +798,10 @@ function yr(e, t, n) {
798
798
  n === void 0 && (n = !1);
799
799
  const o = ge(e), i = tt(e), r = et(i);
800
800
  let s = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
801
- return t.reference[r] > t.floating[r] && (s = ke(s)), [s, ke(s)];
801
+ return t.reference[r] > t.floating[r] && (s = He(s)), [s, He(s)];
802
802
  }
803
803
  function br(e) {
804
- const t = ke(e);
804
+ const t = He(e);
805
805
  return [Ke(e), t, Ke(t)];
806
806
  }
807
807
  function Ke(e) {
@@ -825,7 +825,7 @@ function $r(e, t, n, o) {
825
825
  let r = xr(X(e), n === "start", o);
826
826
  return i && (r = r.map((s) => s + "-" + i), t && (r = r.concat(r.map(Ke)))), r;
827
827
  }
828
- function ke(e) {
828
+ function He(e) {
829
829
  return e.replace(/left|right|bottom|top/g, (t) => mr[t]);
830
830
  }
831
831
  function wr(e) {
@@ -845,7 +845,7 @@ function Vt(e) {
845
845
  left: e
846
846
  };
847
847
  }
848
- function He(e) {
848
+ function ke(e) {
849
849
  return {
850
850
  ...e,
851
851
  top: e.y,
@@ -982,7 +982,7 @@ async function be(e, t) {
982
982
  elementContext: u = "floating",
983
983
  altBoundary: p = !1,
984
984
  padding: f = 0
985
- } = Y(t, e), h = Vt(f), m = a[p ? u === "floating" ? "reference" : "floating" : u], v = He(await r.getClippingRect({
985
+ } = Y(t, e), h = Vt(f), m = a[p ? u === "floating" ? "reference" : "floating" : u], v = ke(await r.getClippingRect({
986
986
  element: (n = await (r.isElement == null ? void 0 : r.isElement(m))) == null || n ? m : m.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(a.floating)),
987
987
  boundary: l,
988
988
  rootBoundary: d,
@@ -997,7 +997,7 @@ async function be(e, t) {
997
997
  } : {
998
998
  x: 1,
999
999
  y: 1
1000
- }, b = He(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
1000
+ }, b = ke(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
1001
1001
  rect: y,
1002
1002
  offsetParent: x,
1003
1003
  strategy: c
@@ -1032,7 +1032,7 @@ const bt = (e) => ({
1032
1032
  }, p = tt(i), f = et(p), h = await s.getDimensions(c), g = p === "y", m = g ? "top" : "left", v = g ? "bottom" : "right", y = g ? "clientHeight" : "clientWidth", x = r.reference[f] + r.reference[p] - u[p] - r.floating[f], $ = u[p] - r.reference[p], b = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(c));
1033
1033
  let w = b ? b[y] : 0;
1034
1034
  (!w || !await (s.isElement == null ? void 0 : s.isElement(b))) && (w = a.floating[y] || r.floating[f]);
1035
- const E = x / 2 - $ / 2, A = w / 2 - h[f] / 2 - 1, C = ee(d[m], A), F = ee(d[v], A), T = C, H = w - h[f] - F, D = w / 2 - h[f] / 2 + E, O = qe(T, D, H), P = ge(i) != null && D != O && r.reference[f] / 2 - (D < T ? C : F) - h[f] / 2 < 0 ? D < T ? T - D : H - D : 0;
1035
+ const E = x / 2 - $ / 2, A = w / 2 - h[f] / 2 - 1, C = ee(d[m], A), F = ee(d[v], A), T = C, k = w - h[f] - F, D = w / 2 - h[f] / 2 + E, O = qe(T, D, k), P = ge(i) != null && D != O && r.reference[f] / 2 - (D < T ? C : F) - h[f] / 2 < 0 ? D < T ? T - D : k - D : 0;
1036
1036
  return {
1037
1037
  [p]: u[p] - P,
1038
1038
  data: {
@@ -1062,7 +1062,7 @@ const bt = (e) => ({
1062
1062
  fallbackAxisSideDirection: f = "none",
1063
1063
  flipAlignment: h = !0,
1064
1064
  ...g
1065
- } = Y(e, t), m = X(o), v = X(s) === s, y = await (a.isRTL == null ? void 0 : a.isRTL(c.floating)), x = u || (v || !h ? [ke(s)] : br(s));
1065
+ } = Y(e, t), m = X(o), v = X(s) === s, y = await (a.isRTL == null ? void 0 : a.isRTL(c.floating)), x = u || (v || !h ? [He(s)] : br(s));
1066
1066
  !u && f !== "none" && x.push(...$r(s, h, f, y));
1067
1067
  const $ = [s, ...x], b = await be(t, g), w = [];
1068
1068
  let E = ((n = i.flip) == null ? void 0 : n.overflows) || [];
@@ -1075,15 +1075,15 @@ const bt = (e) => ({
1075
1075
  overflows: w
1076
1076
  }], !w.every((T) => T <= 0)) {
1077
1077
  var A, C;
1078
- const T = (((A = i.flip) == null ? void 0 : A.index) || 0) + 1, H = $[T];
1079
- if (H)
1078
+ const T = (((A = i.flip) == null ? void 0 : A.index) || 0) + 1, k = $[T];
1079
+ if (k)
1080
1080
  return {
1081
1081
  data: {
1082
1082
  index: T,
1083
1083
  overflows: E
1084
1084
  },
1085
1085
  reset: {
1086
- placement: H
1086
+ placement: k
1087
1087
  }
1088
1088
  };
1089
1089
  let D = (C = E.filter((O) => O.overflows[0] <= 0).sort((O, V) => O.overflows[1] - V.overflows[1])[0]) == null ? void 0 : C.placement;
@@ -1490,7 +1490,7 @@ function ae(e, t, n, o) {
1490
1490
  c *= g.x, l *= g.y, d *= g.x, u *= g.y, c += y, l += x, h = W(h).frameElement;
1491
1491
  }
1492
1492
  }
1493
- return He({
1493
+ return ke({
1494
1494
  width: d,
1495
1495
  height: u,
1496
1496
  x: c,
@@ -1539,7 +1539,7 @@ function Fr(e) {
1539
1539
  y: a
1540
1540
  };
1541
1541
  }
1542
- function kr(e, t) {
1542
+ function Hr(e, t) {
1543
1543
  const n = W(e), o = K(e), i = n.visualViewport;
1544
1544
  let r = o.clientWidth, s = o.clientHeight, a = 0, c = 0;
1545
1545
  if (i) {
@@ -1554,7 +1554,7 @@ function kr(e, t) {
1554
1554
  y: c
1555
1555
  };
1556
1556
  }
1557
- function Hr(e, t) {
1557
+ function kr(e, t) {
1558
1558
  const n = ae(e, !0, t === "fixed"), o = n.top + e.clientTop, i = n.left + e.clientLeft, r = U(e) ? ue(e) : te(1), s = e.clientWidth * r.x, a = e.clientHeight * r.y, c = i * r.x, l = o * r.y;
1559
1559
  return {
1560
1560
  width: s,
@@ -1566,11 +1566,11 @@ function Hr(e, t) {
1566
1566
  function _t(e, t, n) {
1567
1567
  let o;
1568
1568
  if (t === "viewport")
1569
- o = kr(e, n);
1569
+ o = Hr(e, n);
1570
1570
  else if (t === "document")
1571
1571
  o = Fr(K(e));
1572
1572
  else if (q(t))
1573
- o = Hr(t, n);
1573
+ o = kr(t, n);
1574
1574
  else {
1575
1575
  const i = Yt(e);
1576
1576
  o = {
@@ -1579,7 +1579,7 @@ function _t(e, t, n) {
1579
1579
  y: t.y - i.y
1580
1580
  };
1581
1581
  }
1582
- return He(o);
1582
+ return ke(o);
1583
1583
  }
1584
1584
  function qt(e, t) {
1585
1585
  const n = fe(e);
@@ -1880,7 +1880,7 @@ function Zr(e) {
1880
1880
  ...Z,
1881
1881
  isPositioned: !0
1882
1882
  };
1883
- H.current && !Be(A.current, J) && (A.current = J, _n.flushSync(() => {
1883
+ k.current && !Be(A.current, J) && (A.current = J, _n.flushSync(() => {
1884
1884
  u(J);
1885
1885
  }));
1886
1886
  });
@@ -1891,9 +1891,9 @@ function Zr(e) {
1891
1891
  isPositioned: !1
1892
1892
  })));
1893
1893
  }, [l]);
1894
- const H = N.useRef(!1);
1895
- Me(() => (H.current = !0, () => {
1896
- H.current = !1;
1894
+ const k = N.useRef(!1);
1895
+ Me(() => (k.current = !0, () => {
1896
+ k.current = !1;
1897
1897
  }), []), Me(() => {
1898
1898
  if ($ && (w.current = $), b && (E.current = b), $ && b) {
1899
1899
  if (C.current)
@@ -1982,7 +1982,7 @@ function eo(e) {
1982
1982
  e
1983
1983
  ]), t;
1984
1984
  }
1985
- const Jt = "Popper", [Qt, en] = Ht(Jt), [to, tn] = Qt(Jt), no = (e) => {
1985
+ const Jt = "Popper", [Qt, en] = kt(Jt), [to, tn] = Qt(Jt), no = (e) => {
1986
1986
  const { __scopePopper: t, children: n } = e, [o, i] = j(null);
1987
1987
  return /* @__PURE__ */ _(to, {
1988
1988
  scope: t,
@@ -2001,7 +2001,7 @@ const Jt = "Popper", [Qt, en] = Ht(Jt), [to, tn] = Qt(Jt), no = (e) => {
2001
2001
  const { __scopePopper: d, side: u = "bottom", sideOffset: p = 0, align: f = "center", alignOffset: h = 0, arrowPadding: g = 0, avoidCollisions: m = !0, collisionBoundary: v = [], collisionPadding: y = 0, sticky: x = "partial", hideWhenDetached: $ = !1, updatePositionStrategy: b = "optimized", onPlaced: w, ...E } = e, A = tn(nn, d), [C, F] = j(null), T = pe(
2002
2002
  t,
2003
2003
  (ve) => F(ve)
2004
- ), [H, D] = j(null), O = eo(H), V = (n = O == null ? void 0 : O.width) !== null && n !== void 0 ? n : 0, P = (o = O == null ? void 0 : O.height) !== null && o !== void 0 ? o : 0, Z = u + (f !== "center" ? "-" + f : ""), J = typeof y == "number" ? y : {
2004
+ ), [k, D] = j(null), O = eo(k), V = (n = O == null ? void 0 : O.width) !== null && n !== void 0 ? n : 0, P = (o = O == null ? void 0 : O.height) !== null && o !== void 0 ? o : 0, Z = u + (f !== "center" ? "-" + f : ""), J = typeof y == "number" ? y : {
2005
2005
  top: 0,
2006
2006
  right: 0,
2007
2007
  bottom: 0,
@@ -2045,8 +2045,8 @@ const Jt = "Popper", [Qt, en] = Ht(Jt), [to, tn] = Qt(Jt), no = (e) => {
2045
2045
  Oe.setProperty("--radix-popper-available-width", `${vn}px`), Oe.setProperty("--radix-popper-available-height", `${yn}px`), Oe.setProperty("--radix-popper-anchor-width", `${bn}px`), Oe.setProperty("--radix-popper-anchor-height", `${xn}px`);
2046
2046
  }
2047
2047
  }),
2048
- H && Kr({
2049
- element: H,
2048
+ k && Kr({
2049
+ element: k,
2050
2050
  padding: g
2051
2051
  }),
2052
2052
  po({
@@ -2250,7 +2250,7 @@ function xo(e) {
2250
2250
  "mounted",
2251
2251
  "unmountSuspended"
2252
2252
  ].includes(a),
2253
- ref: k((l) => {
2253
+ ref: H((l) => {
2254
2254
  l && (o.current = getComputedStyle(l)), n(l);
2255
2255
  }, [])
2256
2256
  };
@@ -2263,7 +2263,7 @@ function $o({ prop: e, defaultProp: t, onChange: n = () => {
2263
2263
  const [o, i] = wo({
2264
2264
  defaultProp: t,
2265
2265
  onChange: n
2266
- }), r = e !== void 0, s = r ? e : o, a = he(n), c = k((l) => {
2266
+ }), r = e !== void 0, s = r ? e : o, a = he(n), c = H((l) => {
2267
2267
  if (r) {
2268
2268
  const u = typeof l == "function" ? l(e) : l;
2269
2269
  u !== e && a(u);
@@ -2306,7 +2306,7 @@ const _o = /* @__PURE__ */ M((e, t) => /* @__PURE__ */ _(ce.span, S({}, e, {
2306
2306
  wordWrap: "normal",
2307
2307
  ...e.style
2308
2308
  }
2309
- }))), Ao = _o, [Ve, hi] = Ht("Tooltip", [
2309
+ }))), Ao = _o, [Ve, hi] = kt("Tooltip", [
2310
2310
  en
2311
2311
  ]), ze = en(), Po = "TooltipProvider", Eo = 700, Ze = "tooltip.open", [Oo, st] = Ve(Po), To = (e) => {
2312
2312
  const { __scopeTooltip: t, delayDuration: n = Eo, skipDelayDuration: o = 300, disableHoverableContent: i = !1, children: r } = e, [s, a] = j(!0), c = L(!1), l = L(0);
@@ -2317,10 +2317,10 @@ const _o = /* @__PURE__ */ M((e, t) => /* @__PURE__ */ _(ce.span, S({}, e, {
2317
2317
  scope: t,
2318
2318
  isOpenDelayed: s,
2319
2319
  delayDuration: n,
2320
- onOpen: k(() => {
2320
+ onOpen: H(() => {
2321
2321
  window.clearTimeout(l.current), a(!1);
2322
2322
  }, []),
2323
- onClose: k(() => {
2323
+ onClose: H(() => {
2324
2324
  window.clearTimeout(l.current), l.current = window.setTimeout(
2325
2325
  () => a(!0),
2326
2326
  o
@@ -2329,7 +2329,7 @@ const _o = /* @__PURE__ */ M((e, t) => /* @__PURE__ */ _(ce.span, S({}, e, {
2329
2329
  o
2330
2330
  ]),
2331
2331
  isPointerInTransitRef: c,
2332
- onPointerInTransitChange: k((d) => {
2332
+ onPointerInTransitChange: H((d) => {
2333
2333
  c.current = d;
2334
2334
  }, []),
2335
2335
  disableHoverableContent: i
@@ -2343,15 +2343,15 @@ const _o = /* @__PURE__ */ M((e, t) => /* @__PURE__ */ _(ce.span, S({}, e, {
2343
2343
  }
2344
2344
  }), x = ye(() => v ? m.current ? "delayed-open" : "instant-open" : "closed", [
2345
2345
  v
2346
- ]), $ = k(() => {
2346
+ ]), $ = H(() => {
2347
2347
  window.clearTimeout(f.current), m.current = !1, y(!0);
2348
2348
  }, [
2349
2349
  y
2350
- ]), b = k(() => {
2350
+ ]), b = H(() => {
2351
2351
  window.clearTimeout(f.current), y(!1);
2352
2352
  }, [
2353
2353
  y
2354
- ]), w = k(() => {
2354
+ ]), w = H(() => {
2355
2355
  window.clearTimeout(f.current), f.current = window.setTimeout(() => {
2356
2356
  m.current = !0, y(!0);
2357
2357
  }, g);
@@ -2366,14 +2366,14 @@ const _o = /* @__PURE__ */ M((e, t) => /* @__PURE__ */ _(ce.span, S({}, e, {
2366
2366
  stateAttribute: x,
2367
2367
  trigger: d,
2368
2368
  onTriggerChange: u,
2369
- onTriggerEnter: k(() => {
2369
+ onTriggerEnter: H(() => {
2370
2370
  c.isOpenDelayed ? w() : $();
2371
2371
  }, [
2372
2372
  c.isOpenDelayed,
2373
2373
  w,
2374
2374
  $
2375
2375
  ]),
2376
- onTriggerLeave: k(() => {
2376
+ onTriggerLeave: H(() => {
2377
2377
  h ? b() : window.clearTimeout(f.current);
2378
2378
  }, [
2379
2379
  b,
@@ -2384,7 +2384,7 @@ const _o = /* @__PURE__ */ M((e, t) => /* @__PURE__ */ _(ce.span, S({}, e, {
2384
2384
  disableHoverableContent: h
2385
2385
  }, n));
2386
2386
  }, Ot = "TooltipTrigger", So = /* @__PURE__ */ M((e, t) => {
2387
- const { __scopeTooltip: n, ...o } = e, i = _e(Ot, n), r = st(Ot, n), s = ze(n), a = L(null), c = pe(t, a, i.onTriggerChange), l = L(!1), d = L(!1), u = k(
2387
+ const { __scopeTooltip: n, ...o } = e, i = _e(Ot, n), r = st(Ot, n), s = ze(n), a = L(null), c = pe(t, a, i.onTriggerChange), l = L(!1), d = L(!1), u = H(
2388
2388
  () => l.current = !1,
2389
2389
  []
2390
2390
  );
@@ -2443,11 +2443,11 @@ const _o = /* @__PURE__ */ M((e, t) => /* @__PURE__ */ _(ce.span, S({}, e, {
2443
2443
  ref: t
2444
2444
  })));
2445
2445
  }), Io = /* @__PURE__ */ M((e, t) => {
2446
- const n = _e($e, e.__scopeTooltip), o = st($e, e.__scopeTooltip), i = L(null), r = pe(t, i), [s, a] = j(null), { trigger: c, onClose: l } = n, d = i.current, { onPointerInTransitChange: u } = o, p = k(() => {
2446
+ const n = _e($e, e.__scopeTooltip), o = st($e, e.__scopeTooltip), i = L(null), r = pe(t, i), [s, a] = j(null), { trigger: c, onClose: l } = n, d = i.current, { onPointerInTransitChange: u } = o, p = H(() => {
2447
2447
  a(null), u(!1);
2448
2448
  }, [
2449
2449
  u
2450
- ]), f = k((h, g) => {
2450
+ ]), f = H((h, g) => {
2451
2451
  const m = h.currentTarget, v = {
2452
2452
  x: h.clientX,
2453
2453
  y: h.clientY
@@ -2493,7 +2493,7 @@ const _o = /* @__PURE__ */ M((e, t) => /* @__PURE__ */ _(ce.span, S({}, e, {
2493
2493
  ]), /* @__PURE__ */ _(sn, S({}, e, {
2494
2494
  ref: r
2495
2495
  }));
2496
- }), [Fo, ko] = Ve(at, {
2496
+ }), [Fo, Ho] = Ve(at, {
2497
2497
  isInside: !1
2498
2498
  }), sn = /* @__PURE__ */ M((e, t) => {
2499
2499
  const { __scopeTooltip: n, children: o, "aria-label": i, onEscapeKeyDown: r, onPointerDownOutside: s, ...a } = e, c = _e($e, n), l = ze(n), { onClose: d } = c;
@@ -2540,9 +2540,9 @@ const _o = /* @__PURE__ */ M((e, t) => /* @__PURE__ */ _(ce.span, S({}, e, {
2540
2540
  id: c.contentId,
2541
2541
  role: "tooltip"
2542
2542
  }, i || o))));
2543
- }), Ho = "TooltipArrow", Bo = /* @__PURE__ */ M((e, t) => {
2543
+ }), ko = "TooltipArrow", Bo = /* @__PURE__ */ M((e, t) => {
2544
2544
  const { __scopeTooltip: n, ...o } = e, i = ze(n);
2545
- return ko(Ho, n).isInside ? null : /* @__PURE__ */ _(vo, S({}, i, o, {
2545
+ return Ho(ko, n).isInside ? null : /* @__PURE__ */ _(vo, S({}, i, o, {
2546
2546
  ref: t
2547
2547
  }));
2548
2548
  });