@caseparts-org/caseblocks 0.0.101 → 0.0.102

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.
@@ -11,6 +11,7 @@ export type TooltipProps = {
11
11
  closeDelay?: number;
12
12
  disabled?: boolean;
13
13
  leaveGraceMs?: number;
14
+ tooltipOffset?: number;
14
15
  };
15
16
  export declare const Tooltip: React.FC<TooltipProps>;
16
17
  export {};
@@ -1,78 +1,79 @@
1
- import { jsxs as N, Fragment as O, jsx as M } from "react/jsx-runtime";
1
+ import { jsxs as W, Fragment as A, jsx as S } from "react/jsx-runtime";
2
2
  import * as i from "react";
3
- import { c as S } from "../../clsx-OuTLNxxd.js";
4
- import { r as W } from "../../index-B4KbmMH3.js";
5
- import '../../assets/Tooltip.css';const A = "_tooltip_17o7a_1", D = "_content_17o7a_11", j = {
6
- tooltip: A,
7
- content: D
3
+ import { c as j } from "../../clsx-OuTLNxxd.js";
4
+ import { r as D } from "../../index-B4KbmMH3.js";
5
+ import '../../assets/Tooltip.css';const I = "_tooltip_17o7a_1", O = "_content_17o7a_11", H = {
6
+ tooltip: I,
7
+ content: O
8
8
  };
9
- function I(l) {
10
- return l ? l.includes(" ") ? l : `${l} center` : "top center";
9
+ function $(u) {
10
+ return u ? u.includes(" ") ? u : `${u} center` : "top center";
11
11
  }
12
- function $(l) {
13
- const v = I(l).toLowerCase(), [s, t] = v.split(" ");
12
+ function q(u) {
13
+ const w = $(u).toLowerCase(), [s, t] = w.split(" ");
14
14
  return { side: ["top", "right", "bottom", "left"].includes(s) ? s : "top", align: t === "left" || t === "top" ? "start" : t === "right" || t === "bottom" ? "end" : "center" };
15
15
  }
16
- function q(l, v, s, t, d = 8) {
17
- const n = l.getBoundingClientRect(), u = v.getBoundingClientRect();
18
- let f = 0, c = 0;
19
- s === "top" ? f = n.top - u.height - d : s === "bottom" ? f = n.bottom + d : s === "left" ? c = n.left - u.width - d : s === "right" && (c = n.right + d), s === "top" || s === "bottom" ? t === "start" ? c = n.left : t === "end" ? c = n.right - u.width : c = n.left + n.width / 2 - u.width / 2 : t === "start" ? f = n.top : t === "end" ? f = n.bottom - u.height : f = n.top + n.height / 2 - u.height / 2;
20
- const E = window.innerWidth, R = window.innerHeight;
21
- return f = Math.max(4, Math.min(R - u.height - 4, f)), c = Math.max(4, Math.min(E - u.width - 4, c)), { top: f, left: c };
16
+ function G(u, w, s, t, d = 0) {
17
+ const n = u.getBoundingClientRect(), f = w.getBoundingClientRect();
18
+ let a = 0, c = 0;
19
+ s === "top" ? a = n.top - f.height - d : s === "bottom" ? a = n.bottom + d : s === "left" ? c = n.left - f.width - d : s === "right" && (c = n.right + d), s === "top" || s === "bottom" ? t === "start" ? c = n.left : t === "end" ? c = n.right - f.width : c = n.left + n.width / 2 - f.width / 2 : t === "start" ? a = n.top : t === "end" ? a = n.bottom - f.height : a = n.top + n.height / 2 - f.height / 2;
20
+ const E = window.innerWidth, v = window.innerHeight;
21
+ return a = Math.max(4, Math.min(v - f.height - 4, a)), c = Math.max(4, Math.min(E - f.width - 4, c)), { top: a, left: c };
22
22
  }
23
- const Q = ({
24
- tooltipClassName: l,
25
- contentClassName: v,
23
+ const U = ({
24
+ tooltipClassName: u,
25
+ contentClassName: w,
26
26
  children: s,
27
27
  trigger: t,
28
28
  position: d,
29
29
  disabled: n,
30
- openDelay: u = 150,
31
- closeDelay: f = 100,
32
- leaveGraceMs: c = 0
30
+ openDelay: f = 150,
31
+ closeDelay: a = 100,
32
+ leaveGraceMs: c = 0,
33
+ tooltipOffset: E = 4
33
34
  }) => {
34
- const { side: E, align: R } = $(d), [o, y] = i.useState(!1), [m, C] = i.useState(null), T = i.useRef(null), g = i.useRef(null), x = i.useRef(null), L = i.useRef(null), P = i.useRef(null), w = i.useRef(!1), a = (e) => {
35
+ const { side: v, align: b } = q(d), [o, R] = i.useState(!1), [m, C] = i.useState(null), T = i.useRef(null), g = i.useRef(null), x = i.useRef(null), y = i.useRef(null), L = i.useRef(null), h = i.useRef(!1), p = (e) => {
35
36
  e.current && (window.clearTimeout(e.current), e.current = null);
36
37
  }, B = () => {
37
- a(x), a(L), a(P);
38
+ p(x), p(y), p(L);
38
39
  };
39
40
  i.useEffect(() => () => B(), []);
40
41
  const k = () => {
41
- n || o || (a(x), x.current = window.setTimeout(() => y(!0), u));
42
+ n || o || (p(x), x.current = window.setTimeout(() => R(!0), f));
42
43
  }, _ = () => {
43
- o && (a(L), L.current = window.setTimeout(() => {
44
- w.current || y(!1);
45
- }, f));
44
+ o && (p(y), y.current = window.setTimeout(() => {
45
+ h.current || R(!1);
46
+ }, a));
46
47
  }, z = () => {
47
48
  if (o) {
48
- if (a(P), c <= 0) {
49
+ if (p(L), c <= 0) {
49
50
  _();
50
51
  return;
51
52
  }
52
- P.current = window.setTimeout(() => {
53
- w.current || _();
53
+ L.current = window.setTimeout(() => {
54
+ h.current || _();
54
55
  }, c);
55
56
  }
56
- }, b = (e, r) => (h) => {
57
- e == null || e(h), r == null || r(h);
58
- }, H = i.cloneElement(t, {
57
+ }, P = (e, r) => (l) => {
58
+ e == null || e(l), r == null || r(l);
59
+ }, N = i.cloneElement(t, {
59
60
  ref: (e) => {
60
61
  const { ref: r } = t;
61
62
  typeof r == "function" ? r(e) : r && (r.current = e), T.current = e;
62
63
  },
63
- onPointerEnter: b(t.props.onPointerEnter, k),
64
- onPointerLeave: b(t.props.onPointerLeave, z),
65
- onFocus: b(t.props.onFocus, k),
66
- onBlur: b(t.props.onBlur, _),
64
+ onPointerEnter: P(t.props.onPointerEnter, k),
65
+ onPointerLeave: P(t.props.onPointerLeave, z),
66
+ onFocus: P(t.props.onFocus, k),
67
+ onBlur: P(t.props.onBlur, _),
67
68
  "aria-describedby": o ? "tooltip-popup" : void 0,
68
69
  style: { ...t.props.style || {}, outline: "none" }
69
70
  });
70
71
  return i.useEffect(() => {
71
- n && o && (B(), y(!1));
72
+ n && o && (B(), R(!1));
72
73
  }, [n]), i.useEffect(() => {
73
74
  if (!o) return;
74
75
  const e = (r) => {
75
- r.key === "Escape" && y(!1);
76
+ r.key === "Escape" && R(!1);
76
77
  };
77
78
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
78
79
  }, [o]), i.useLayoutEffect(() => {
@@ -82,36 +83,36 @@ const Q = ({
82
83
  }
83
84
  const e = T.current, r = g.current;
84
85
  if (!e || !r) return;
85
- const h = 8, p = () => {
86
- C(q(e, r, E, R, h));
86
+ const l = () => {
87
+ C(G(e, r, v, b, E));
87
88
  };
88
- return p(), window.addEventListener("resize", p), window.addEventListener("scroll", p, !0), () => {
89
- window.removeEventListener("resize", p), window.removeEventListener("scroll", p, !0);
89
+ return l(), window.addEventListener("resize", l), window.addEventListener("scroll", l, !0), () => {
90
+ window.removeEventListener("resize", l), window.removeEventListener("scroll", l, !0);
90
91
  };
91
- }, [o, E, R, s]), i.useEffect(() => {
92
+ }, [o, v, b, s, E]), i.useEffect(() => {
92
93
  if (!o) return;
93
94
  const e = (r) => {
94
- const h = T.current, p = g.current;
95
- if (!h || !p) return;
96
- const F = r.target;
97
- !h.contains(F) && !p.contains(F) && (w.current = !1, z());
95
+ const l = T.current, F = g.current;
96
+ if (!l || !F) return;
97
+ const M = r.target;
98
+ !l.contains(M) && !F.contains(M) && (h.current = !1, z());
98
99
  };
99
100
  return document.addEventListener("pointermove", e), () => document.removeEventListener("pointermove", e);
100
101
  }, [o]), i.useEffect(() => {
101
- o || (w.current = !1);
102
- }, [o]), /* @__PURE__ */ N(O, { children: [
103
- H,
104
- o && typeof document < "u" && W.createPortal(
105
- /* @__PURE__ */ M(
102
+ o || (h.current = !1);
103
+ }, [o]), /* @__PURE__ */ W(A, { children: [
104
+ N,
105
+ o && typeof document < "u" && D.createPortal(
106
+ /* @__PURE__ */ S(
106
107
  "div",
107
108
  {
108
109
  id: "tooltip-popup",
109
110
  ref: g,
110
111
  role: "tooltip",
111
112
  "aria-hidden": !o,
112
- "data-side": E,
113
- "data-align": R,
114
- className: S(j.tooltip, l),
113
+ "data-side": v,
114
+ "data-align": b,
115
+ className: j(H.tooltip, u),
115
116
  style: {
116
117
  position: "absolute",
117
118
  top: (m == null ? void 0 : m.top) ?? 0,
@@ -120,12 +121,12 @@ const Q = ({
120
121
  zIndex: 10
121
122
  },
122
123
  onPointerEnter: () => {
123
- w.current = !0, a(L), a(P);
124
+ h.current = !0, p(y), p(L);
124
125
  },
125
126
  onPointerLeave: () => {
126
- w.current = !1, z();
127
+ h.current = !1, z();
127
128
  },
128
- children: /* @__PURE__ */ M("div", { className: S(j.content, v), children: s })
129
+ children: /* @__PURE__ */ S("div", { className: j(H.content, w), children: s })
129
130
  }
130
131
  ),
131
132
  document.body
@@ -133,5 +134,5 @@ const Q = ({
133
134
  ] });
134
135
  };
135
136
  export {
136
- Q as Tooltip
137
+ U as Tooltip
137
138
  };
@@ -19,6 +19,7 @@ function z({
19
19
  {
20
20
  openDelay: 180,
21
21
  closeDelay: 0,
22
+ tooltipOffset: 0,
22
23
  trigger: /* @__PURE__ */ e("li", { className: o.category, tabIndex: 0, children: /* @__PURE__ */ t(s, { href: i.route, children: [
23
24
  /* @__PURE__ */ e(n, { size: "sm", weight: "semibold", children: i.label }),
24
25
  i.showChevron && /* @__PURE__ */ e(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caseparts-org/caseblocks",
3
3
  "private": false,
4
- "version": "0.0.101",
4
+ "version": "0.0.102",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",