@versaur/react 1.0.14 → 1.0.16

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.
@@ -0,0 +1,378 @@
1
+ import { jsxs as N, jsx as p } from "react/jsx-runtime";
2
+ import { buttonStyles as j, headingStyles as F, textStyles as M, avatarStyles as S, hrStyles as _, loaderStyles as $, badgeStyles as q, bannerStyles as E, dotStyles as O, kbdStyles as U, tooltipStyles as k } from "@versaur/core/primitive";
3
+ import { LoaderIcon as I, UserIcon as z, XIcon as G } from "@versaur/icons";
4
+ import { forwardRef as v, useState as X, useRef as A, useEffect as L } from "react";
5
+ import { u as T, I as w, B as J, f as Q, c as V } from "./helpers-D23F5WBX.js";
6
+ import { c as h } from "./cx-B9vmfsc1.js";
7
+ const W = v(
8
+ ({
9
+ variant: o = "primary",
10
+ size: n = "medium",
11
+ loading: e = !1,
12
+ disabled: t = !1,
13
+ pressed: s = !1,
14
+ leftIcon: c,
15
+ rightIcon: r,
16
+ children: a,
17
+ type: i = "button",
18
+ onClick: l,
19
+ className: d,
20
+ ...u
21
+ }, m) => {
22
+ const g = !!c, f = !!r, b = !!a;
23
+ let y;
24
+ g && f && b ? y = "both-text" : g && b ? y = "left-text" : f && b ? y = "right-text" : g && f ? y = "both" : g ? y = "left" : f && (y = "right");
25
+ const K = T({
26
+ disabled: t || e,
27
+ loading: e,
28
+ size: n,
29
+ variant: o,
30
+ ...y && { iconConfig: y }
31
+ }), C = (B) => {
32
+ if (t || e) {
33
+ B.preventDefault();
34
+ return;
35
+ }
36
+ l == null || l(B);
37
+ };
38
+ return /* @__PURE__ */ N(
39
+ "button",
40
+ {
41
+ ref: m,
42
+ type: i,
43
+ className: h(j.button, d),
44
+ "aria-pressed": s ? "true" : void 0,
45
+ "aria-busy": e ? "true" : void 0,
46
+ "aria-disabled": t || e ? "true" : void 0,
47
+ ...K,
48
+ ...u,
49
+ onClick: C,
50
+ children: [
51
+ e ? /* @__PURE__ */ p(w, { as: I, "aria-label": "Loading", "data-loading-icon": "loader" }) : null,
52
+ c,
53
+ a,
54
+ r
55
+ ]
56
+ }
57
+ );
58
+ }
59
+ );
60
+ W.displayName = "Button";
61
+ const Y = v(
62
+ ({ as: o = "h2", size: n, weight: e, intent: t = "default", case: s, transform: c, children: r, className: a, ...i }, l) => {
63
+ const d = o, u = T({
64
+ as: o,
65
+ case: s,
66
+ intent: t,
67
+ size: n,
68
+ transform: c,
69
+ weight: e
70
+ });
71
+ return /* @__PURE__ */ p(d, { ref: l, className: h(F.heading, a), ...u, ...i, children: r });
72
+ }
73
+ );
74
+ Y.displayName = "Heading";
75
+ const Z = v(
76
+ ({ as: o = "p", size: n, weight: e, intent: t = "default", case: s, transform: c, children: r, className: a, ...i }, l) => {
77
+ const d = o, u = T({
78
+ as: o,
79
+ case: s,
80
+ intent: t,
81
+ size: n,
82
+ transform: c,
83
+ weight: e
84
+ });
85
+ return /* @__PURE__ */ p(d, { ref: l, className: h(M.text, a), ...u, ...i, children: r });
86
+ }
87
+ );
88
+ Z.displayName = "Text";
89
+ const P = v(
90
+ ({ variant: o = "primary", size: n = "md", shape: e = "circle", children: t, className: s, ...c }, r) => {
91
+ const a = T({ shape: e, size: n, variant: o }), i = t || /* @__PURE__ */ p(w, { as: z });
92
+ return /* @__PURE__ */ p("span", { ref: r, className: h(S.avatar, s), role: "img", ...a, ...c, children: i });
93
+ }
94
+ );
95
+ P.displayName = "Avatar";
96
+ const D = v(({ src: o, alt: n, onError: e, className: t, ...s }, c) => {
97
+ const [r, a] = X(!1);
98
+ return r ? null : /* @__PURE__ */ p(
99
+ "img",
100
+ {
101
+ ref: c,
102
+ className: h(S["avatar-image"], t),
103
+ src: o,
104
+ alt: n,
105
+ onError: (i) => {
106
+ a(!0), e == null || e(i);
107
+ },
108
+ ...s
109
+ }
110
+ );
111
+ });
112
+ D.displayName = "Avatar.Image";
113
+ const Te = Object.assign(P, {
114
+ Image: D
115
+ }), ee = v(
116
+ ({ orientation: o, variant: n, size: e, spacing: t, className: s, ...c }, r) => {
117
+ const a = T({
118
+ orientation: o,
119
+ size: e,
120
+ spacing: t,
121
+ variant: n
122
+ });
123
+ return /* @__PURE__ */ p(
124
+ "hr",
125
+ {
126
+ ref: r,
127
+ className: h(_.hr, s),
128
+ role: "separator",
129
+ "aria-orientation": o === "vertical" ? "vertical" : void 0,
130
+ ...a,
131
+ ...c
132
+ }
133
+ );
134
+ }
135
+ );
136
+ ee.displayName = "Hr";
137
+ const te = v(
138
+ ({ type: o = "spinner", size: n = "sm", children: e, className: t, ...s }, c) => {
139
+ const r = T({
140
+ size: n,
141
+ type: o
142
+ });
143
+ return /* @__PURE__ */ N("div", { ref: c, className: h($.loader, t), ...r, ...s, children: [
144
+ o === "spinner" && /* @__PURE__ */ p(w, { as: I, "aria-hidden": "true" }),
145
+ e
146
+ ] });
147
+ }
148
+ );
149
+ te.displayName = "Loader";
150
+ const oe = v(
151
+ ({
152
+ variant: o = "primary",
153
+ size: n = "medium",
154
+ shape: e = "rounded",
155
+ iconLeft: t,
156
+ iconRight: s,
157
+ maxWidth: c,
158
+ children: r,
159
+ style: a,
160
+ className: i,
161
+ ...l
162
+ }, d) => {
163
+ const u = !!t, m = !!s, g = !!r;
164
+ let f;
165
+ u && m && g ? f = "both-text" : u && g ? f = "left-text" : m && g ? f = "right-text" : u && m ? f = "both" : u ? f = "left" : m && (f = "right");
166
+ const b = T({
167
+ shape: e,
168
+ size: n,
169
+ variant: o,
170
+ ...f && { iconConfig: f }
171
+ }), y = {
172
+ ...a,
173
+ ...c && { "--vers-comp-badge-max-width": c }
174
+ };
175
+ return /* @__PURE__ */ N("div", { ref: d, className: h(q.badge, i), ...b, ...l, style: y, children: [
176
+ t,
177
+ r,
178
+ s
179
+ ] });
180
+ }
181
+ );
182
+ oe.displayName = "Badge";
183
+ const ne = v(
184
+ ({ variant: o = "info", icon: n, onDismiss: e, children: t, className: s, ...c }, r) => {
185
+ const a = T({
186
+ variant: o
187
+ });
188
+ return /* @__PURE__ */ N("div", { ref: r, className: h(E.banner, s), ...a, ...c, children: [
189
+ n && /* @__PURE__ */ p("div", { className: E.icon, children: n }),
190
+ /* @__PURE__ */ p("div", { className: E.content, children: t }),
191
+ e && /* @__PURE__ */ p(J, { as: G, variant: "ghost", size: "small", onClick: e, "aria-label": "Dismiss banner" })
192
+ ] });
193
+ }
194
+ );
195
+ ne.displayName = "Banner";
196
+ const re = v(
197
+ ({ variant: o = "primary", size: n = "medium", className: e, ...t }, s) => {
198
+ const c = T({
199
+ size: n,
200
+ variant: o
201
+ });
202
+ return /* @__PURE__ */ p("span", { ref: s, className: h(O.dot, e), ...c, ...t });
203
+ }
204
+ );
205
+ re.displayName = "Dot";
206
+ const se = v(
207
+ ({ variant: o = "filled", size: n = "md", children: e, className: t, ...s }, c) => {
208
+ const r = T({ size: n, variant: o });
209
+ return /* @__PURE__ */ p("kbd", { ref: c, className: h(U.kbd, t), ...r, ...s, children: e });
210
+ }
211
+ );
212
+ se.displayName = "Kbd";
213
+ function ae(...o) {
214
+ return (n) => {
215
+ o.forEach((e) => {
216
+ if (typeof e == "function")
217
+ e(n);
218
+ else if (e && "current" in e)
219
+ try {
220
+ e.current = n;
221
+ } catch {
222
+ }
223
+ });
224
+ };
225
+ }
226
+ function ie(o, n, e) {
227
+ let t = null;
228
+ const s = () => new Promise((i) => {
229
+ o.matches(":popover-open") || o.showPopover(), requestAnimationFrame(() => {
230
+ const l = o.getBoundingClientRect(), d = { width: l.width, height: l.height }, u = e || V(n.getBoundingClientRect(), d);
231
+ i(u);
232
+ });
233
+ }), c = async () => {
234
+ a();
235
+ const i = await s();
236
+ o.dataset.placement = i;
237
+ }, r = (i) => {
238
+ t && (clearTimeout(t), t = null), i ? t = setTimeout(() => {
239
+ o.matches(":popover-open") && o.hidePopover(), t = null;
240
+ }, 100) : o.matches(":popover-open") && o.hidePopover();
241
+ }, a = () => {
242
+ t && (clearTimeout(t), t = null);
243
+ };
244
+ return { showTooltip: c, hideTooltip: r, cancelHide: a, cleanup: () => clearTimeout(t ?? void 0) };
245
+ }
246
+ function ce({ id: o, tooltipRef: n, placement: e, type: t }) {
247
+ const s = A(null), c = A(null);
248
+ L(() => {
249
+ const r = n.current;
250
+ if (!r || !o)
251
+ return;
252
+ const a = Q(r, o);
253
+ if (a)
254
+ return c.current = a, s.current = ie(r, a, e), () => {
255
+ var i;
256
+ (i = s.current) == null || i.cleanup(), s.current = null;
257
+ };
258
+ }, [o, e, n]), L(() => {
259
+ if (t !== "hover" || !s.current || !c.current) return;
260
+ const r = c.current, a = s.current, i = n.current;
261
+ if (!i) return;
262
+ const l = () => {
263
+ a.showTooltip();
264
+ }, d = () => {
265
+ a.hideTooltip(!0);
266
+ }, u = () => {
267
+ a.cancelHide();
268
+ }, m = () => {
269
+ a.hideTooltip(!0);
270
+ };
271
+ return r.addEventListener("mouseenter", l), r.addEventListener("mouseleave", d), i.addEventListener("mouseenter", u), i.addEventListener("mouseleave", m), () => {
272
+ r.removeEventListener("mouseenter", l), r.removeEventListener("mouseleave", d), i.removeEventListener("mouseenter", u), i.removeEventListener("mouseleave", m);
273
+ };
274
+ }, [t, n]), L(() => {
275
+ if (t !== "persisted" || !s.current || !c.current) return;
276
+ const r = c.current, a = s.current, i = n.current;
277
+ if (!i) return;
278
+ const l = (m) => {
279
+ m.stopPropagation(), i.matches(":popover-open") ? a.hideTooltip(!1) : a.showTooltip();
280
+ }, d = (m) => {
281
+ const g = m.target;
282
+ i.matches(":popover-open") && !r.contains(g) && !i.contains(g) && a.hideTooltip(!1);
283
+ }, u = (m) => {
284
+ m.key === "Escape" && i.matches(":popover-open") && a.hideTooltip(!1);
285
+ };
286
+ return r.addEventListener("click", l), document.addEventListener("click", d), document.addEventListener("keydown", u), () => {
287
+ r.removeEventListener("click", l), document.removeEventListener("click", d), document.removeEventListener("keydown", u);
288
+ };
289
+ }, [t, n]), L(() => {
290
+ if (t !== "focus" || !s.current || !c.current) return;
291
+ const r = c.current, a = s.current;
292
+ let i = !1;
293
+ const l = (m) => {
294
+ ["Tab", "Enter", " ", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(m.key) && (i = !0);
295
+ }, d = () => {
296
+ i && (a.showTooltip(), i = !1);
297
+ }, u = () => {
298
+ a.hideTooltip(!1), i = !1;
299
+ };
300
+ return document.addEventListener("keydown", l), r.addEventListener("focus", d), r.addEventListener("blur", u), () => {
301
+ document.removeEventListener("keydown", l), r.removeEventListener("focus", d), r.removeEventListener("blur", u);
302
+ };
303
+ }, [t, n]);
304
+ }
305
+ const le = 8, R = v(
306
+ ({ id: o, children: n, placement: e, gap: t = le, type: s = "hover", style: c, className: r, ...a }, i) => {
307
+ const l = A(null), d = T({
308
+ placement: e
309
+ });
310
+ return ce({
311
+ id: o,
312
+ placement: e,
313
+ tooltipRef: l,
314
+ type: s
315
+ }), /* @__PURE__ */ p(
316
+ "div",
317
+ {
318
+ ref: ae(l, i),
319
+ id: o,
320
+ className: h(k.tooltip, r),
321
+ ...d,
322
+ style: {
323
+ "--_gap": `${t}px`,
324
+ positionAnchor: `--tooltip-${o}`,
325
+ ...c
326
+ },
327
+ ...a,
328
+ popover: "auto",
329
+ children: n
330
+ }
331
+ );
332
+ }
333
+ );
334
+ R.displayName = "Tooltip";
335
+ const H = v(
336
+ ({ children: o, maxWidth: n, maxLines: e = 2, style: t, className: s, ...c }, r) => {
337
+ const a = {
338
+ "--_lines": e,
339
+ "--_max-width": n,
340
+ ...t
341
+ };
342
+ return /* @__PURE__ */ p("div", { ref: r, className: h(k["tooltip-text"], s), style: a, ...c, children: o });
343
+ }
344
+ );
345
+ H.displayName = "Tooltip.Text";
346
+ function ue(o) {
347
+ const { id: n, ...e } = o;
348
+ return {
349
+ "data-tooltip-trigger": n,
350
+ style: { anchorName: `--tooltip-${n}` },
351
+ ...Object.fromEntries(Object.entries(e).map(([t, s]) => [t, String(s)]))
352
+ };
353
+ }
354
+ function de(o) {
355
+ const { id: n } = o, e = document.getElementById(n);
356
+ e && e.matches(":popover-open") && requestAnimationFrame(() => {
357
+ const t = document.querySelector(`[data-tooltip-trigger="${n}"]`);
358
+ t && document.activeElement === t && t.blur(), e.matches(":popover-open") && e.hidePopover();
359
+ });
360
+ }
361
+ const x = R;
362
+ x.Text = H;
363
+ x.getTooltipTriggerProps = ue;
364
+ x.close = de;
365
+ export {
366
+ Te as A,
367
+ oe as B,
368
+ re as D,
369
+ Y as H,
370
+ se as K,
371
+ te as L,
372
+ Z as T,
373
+ ne as a,
374
+ W as b,
375
+ ee as c,
376
+ x as d,
377
+ ae as e
378
+ };
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as v, c as S, b as g, O as D } from "./overlay-parts-CFeD8VN0.js";
1
+ import { b as v, a as S, c as g, O as D } from "./overlay-parts-BtD-Qj_k.js";
2
2
  import { useState as l, useEffect as c } from "react";
3
3
  import { getBreakpointPx as n } from "@versaur/core/utils";
4
4
  function r(e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versaur/react",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "React components for Versaur Design System",
5
5
  "repository": {
6
6
  "type": "git",
@@ -49,7 +49,7 @@
49
49
  "peerDependencies": {
50
50
  "react": "^18.0.0 || ^19.0.0",
51
51
  "react-dom": "^18.0.0 || ^19.0.0",
52
- "@versaur/core": "0.0.10",
52
+ "@versaur/core": "0.0.12",
53
53
  "@versaur/icons": "1.0.0"
54
54
  },
55
55
  "scripts": {
@@ -1,129 +0,0 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import { iconStyles as T, buttonIconStyles as v } from "@versaur/core/primitive";
3
- import { LoaderIcon as C } from "@versaur/icons";
4
- import j, { forwardRef as B } from "react";
5
- import { c as I } from "./cx-B9vmfsc1.js";
6
- function E(e) {
7
- return e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
8
- }
9
- function A(e) {
10
- const n = {};
11
- for (const [o, t] of Object.entries(e)) {
12
- if (t == null)
13
- continue;
14
- const r = E(o);
15
- typeof t == "boolean" ? t && (n[`data-${r}`] = (!!t).toString()) : (typeof t == "string" || typeof t == "number") && (n[`data-${r}`] = String(t));
16
- }
17
- return n;
18
- }
19
- const p = j.forwardRef(function({ intent: n = "inherit", size: o = "inherit", as: t, className: r, ...d }, s) {
20
- const a = A({ intent: n, size: o });
21
- return /* @__PURE__ */ l(t, { ref: s, className: I(T.icon, r), ...a, ...d });
22
- });
23
- p.displayName = "Icon";
24
- const N = B(
25
- ({
26
- as: e,
27
- variant: n = "primary",
28
- size: o = "medium",
29
- loading: t = !1,
30
- disabled: r = !1,
31
- pressed: d = !1,
32
- type: s = "button",
33
- onClick: a,
34
- iconProps: u = {},
35
- "aria-label": b,
36
- className: w,
37
- ...h
38
- }, y) => {
39
- const c = A({
40
- disabled: r || t,
41
- loading: t,
42
- size: o,
43
- variant: n
44
- }), f = (m) => {
45
- if (r || t) {
46
- m.preventDefault();
47
- return;
48
- }
49
- a == null || a(m);
50
- };
51
- return /* @__PURE__ */ l(
52
- "button",
53
- {
54
- ref: y,
55
- type: s,
56
- className: I(v["button-icon"], w),
57
- "aria-label": b,
58
- "aria-pressed": d ? "true" : void 0,
59
- "aria-busy": t ? "true" : void 0,
60
- "aria-disabled": r || t ? "true" : void 0,
61
- ...c,
62
- ...h,
63
- onClick: f,
64
- children: t ? /* @__PURE__ */ l(p, { as: C, "aria-label": "Loading", "data-loading-icon": "loader" }) : /* @__PURE__ */ l(p, { as: e, ...u })
65
- }
66
- );
67
- }
68
- );
69
- N.displayName = "ButtonIcon";
70
- const _ = 100, i = 16;
71
- function F(e, n) {
72
- let o = e.parentElement;
73
- for (; o; ) {
74
- const t = o.querySelector(`[data-tooltip-trigger="${n}"]`);
75
- if (t) return t;
76
- if (o === document.body) break;
77
- o = o.parentElement;
78
- }
79
- return null;
80
- }
81
- function D(e, n, o = _, t) {
82
- const r = window.innerWidth, d = window.innerHeight, s = {
83
- top: e.top,
84
- bottom: d - e.bottom,
85
- left: e.left,
86
- right: r - e.right
87
- };
88
- if (n) {
89
- const a = e.left + e.width / 2, u = e.top + e.height / 2, b = [
90
- // Bottom: check if tooltip fits below trigger
91
- [
92
- "bottom",
93
- s.bottom,
94
- e.bottom + n.height + i <= d && a - n.width / 2 >= i && a + n.width / 2 <= r - i
95
- ],
96
- // Top: check if tooltip fits above trigger
97
- [
98
- "top",
99
- s.top,
100
- e.top - n.height - i >= 0 && a - n.width / 2 >= i && a + n.width / 2 <= r - i
101
- ],
102
- // Right: check if tooltip fits to the right of trigger
103
- [
104
- "right",
105
- s.right,
106
- e.right + n.width + i <= r && u - n.height / 2 >= i && u + n.height / 2 <= d - i
107
- ],
108
- // Left: check if tooltip fits to the left of trigger
109
- [
110
- "left",
111
- s.left,
112
- e.left - n.width - i >= 0 && u - n.height / 2 >= i && u + n.height / 2 <= d - i
113
- ]
114
- ], h = (t ? b.filter(([c]) => t.includes(c)) : b).filter(([c, f, m]) => m);
115
- return h.length > 0 ? h.find(([f]) => f === "bottom") ? "bottom" : h.reduce((f, m) => m[1] > f[1] ? m : f)[0] : (t ? Object.entries(s).filter(
116
- ([c]) => t.includes(c)
117
- ) : Object.entries(s)).reduce((c, f) => f[1] > c[1] ? f : c)[0];
118
- }
119
- return s.bottom >= o ? "bottom" : Object.entries(s).reduce(
120
- (a, u) => u[1] > a[1] ? u : a
121
- )[0];
122
- }
123
- export {
124
- N as B,
125
- p as I,
126
- D as c,
127
- F as f,
128
- A as u
129
- };
@@ -1,170 +0,0 @@
1
- import { jsx as h } from "react/jsx-runtime";
2
- import { hrStyles as k, tooltipStyles as L } from "@versaur/core/primitive";
3
- import { forwardRef as f, useRef as v, useEffect as d } from "react";
4
- import { u as y, f as x, c as A } from "./helpers-DTL6qrTe.js";
5
- import { c as g } from "./cx-B9vmfsc1.js";
6
- const N = f(
7
- ({ orientation: e, variant: n, size: o, spacing: t, className: c, ...a }, s) => {
8
- const r = y({
9
- orientation: e,
10
- size: o,
11
- spacing: t,
12
- variant: n
13
- });
14
- return /* @__PURE__ */ h(
15
- "hr",
16
- {
17
- ref: s,
18
- className: g(k.hr, c),
19
- role: "separator",
20
- "aria-orientation": e === "vertical" ? "vertical" : void 0,
21
- ...r,
22
- ...a
23
- }
24
- );
25
- }
26
- );
27
- N.displayName = "Hr";
28
- function R(...e) {
29
- return (n) => {
30
- e.forEach((o) => {
31
- if (typeof o == "function")
32
- o(n);
33
- else if (o && "current" in o)
34
- try {
35
- o.current = n;
36
- } catch {
37
- }
38
- });
39
- };
40
- }
41
- function S(e, n, o) {
42
- let t = null;
43
- const c = () => new Promise((i) => {
44
- e.matches(":popover-open") || e.showPopover(), requestAnimationFrame(() => {
45
- const l = e.getBoundingClientRect(), u = { width: l.width, height: l.height }, m = o || A(n.getBoundingClientRect(), u);
46
- i(m);
47
- });
48
- }), a = async () => {
49
- r();
50
- const i = await c();
51
- e.dataset.placement = i;
52
- }, s = (i) => {
53
- t && (clearTimeout(t), t = null), i ? t = setTimeout(() => {
54
- e.matches(":popover-open") && e.hidePopover(), t = null;
55
- }, 100) : e.matches(":popover-open") && e.hidePopover();
56
- }, r = () => {
57
- t && (clearTimeout(t), t = null);
58
- };
59
- return { showTooltip: a, hideTooltip: s, cancelHide: r, cleanup: () => clearTimeout(t ?? void 0) };
60
- }
61
- function C({ id: e, tooltipRef: n, placement: o, type: t }) {
62
- const c = v(null), a = v(null);
63
- d(() => {
64
- const s = n.current;
65
- if (!s || !e)
66
- return;
67
- const r = x(s, e);
68
- if (r)
69
- return a.current = r, c.current = S(s, r, o), () => {
70
- var i;
71
- (i = c.current) == null || i.cleanup(), c.current = null;
72
- };
73
- }, [e, o, n]), d(() => {
74
- if (t !== "hover" || !c.current || !a.current) return;
75
- const s = a.current, r = c.current, i = n.current;
76
- if (!i) return;
77
- const l = () => {
78
- r.showTooltip();
79
- }, u = () => {
80
- r.hideTooltip(!0);
81
- }, m = () => {
82
- r.cancelHide();
83
- }, p = () => {
84
- r.hideTooltip(!0);
85
- };
86
- return s.addEventListener("mouseenter", l), s.addEventListener("mouseleave", u), i.addEventListener("mouseenter", m), i.addEventListener("mouseleave", p), () => {
87
- s.removeEventListener("mouseenter", l), s.removeEventListener("mouseleave", u), i.removeEventListener("mouseenter", m), i.removeEventListener("mouseleave", p);
88
- };
89
- }, [t, n]), d(() => {
90
- if (t !== "persisted" || !c.current || !a.current) return;
91
- const s = a.current, r = c.current, i = n.current;
92
- if (!i) return;
93
- const l = (p) => {
94
- p.stopPropagation(), i.matches(":popover-open") ? r.hideTooltip(!1) : r.showTooltip();
95
- }, u = (p) => {
96
- const E = p.target;
97
- i.matches(":popover-open") && !s.contains(E) && !i.contains(E) && r.hideTooltip(!1);
98
- }, m = (p) => {
99
- p.key === "Escape" && i.matches(":popover-open") && r.hideTooltip(!1);
100
- };
101
- return s.addEventListener("click", l), document.addEventListener("click", u), document.addEventListener("keydown", m), () => {
102
- s.removeEventListener("click", l), document.removeEventListener("click", u), document.removeEventListener("keydown", m);
103
- };
104
- }, [t, n]);
105
- }
106
- const H = 8, P = f(
107
- ({ id: e, children: n, placement: o, gap: t = H, type: c = "hover", style: a, className: s, ...r }, i) => {
108
- const l = v(null), u = y({
109
- placement: o
110
- });
111
- return C({
112
- id: e,
113
- placement: o,
114
- tooltipRef: l,
115
- type: c
116
- }), /* @__PURE__ */ h(
117
- "div",
118
- {
119
- ref: R(l, i),
120
- id: e,
121
- className: g(L.tooltip, s),
122
- ...u,
123
- style: {
124
- "--_gap": `${t}px`,
125
- positionAnchor: `--tooltip-${e}`,
126
- ...a
127
- },
128
- ...r,
129
- popover: "auto",
130
- children: n
131
- }
132
- );
133
- }
134
- );
135
- P.displayName = "Tooltip";
136
- const w = f(
137
- ({ children: e, maxWidth: n, maxLines: o = 2, style: t, className: c, ...a }, s) => {
138
- const r = {
139
- "--_lines": o,
140
- "--_max-width": n,
141
- ...t
142
- };
143
- return /* @__PURE__ */ h("div", { ref: s, className: g(L["tooltip-text"], c), style: r, ...a, children: e });
144
- }
145
- );
146
- w.displayName = "Tooltip.Text";
147
- function b(e) {
148
- const { id: n, ...o } = e;
149
- return {
150
- "data-tooltip-trigger": n,
151
- style: { anchorName: `--tooltip-${n}` },
152
- ...Object.fromEntries(Object.entries(o).map(([t, c]) => [t, String(c)]))
153
- };
154
- }
155
- function M(e) {
156
- const { id: n } = e, o = document.getElementById(n);
157
- o && o.matches(":popover-open") && requestAnimationFrame(() => {
158
- const t = document.querySelector(`[data-tooltip-trigger="${n}"]`);
159
- t && document.activeElement === t && t.blur(), o.matches(":popover-open") && o.hidePopover();
160
- });
161
- }
162
- const T = P;
163
- T.Text = w;
164
- T.getTooltipTriggerProps = b;
165
- T.close = M;
166
- export {
167
- N as H,
168
- T,
169
- R as c
170
- };