@grapadigital/shared-app-modules 0.0.175 → 0.0.176

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 { jsx as u, jsxs as S } from "react/jsx-runtime";
2
+ import { c as H, a as W, b as j, u as J, d as Q, R as Z, e as G, A as ee, P as te, f as C, g as F, h as oe, i as re, D as ne, C as ae, j as se, k as ie } from "./switch.BF6I8Lqo.js";
3
+ import * as a from "react";
4
+ function Ae({
5
+ className: e,
6
+ ...o
7
+ }) {
8
+ return /* @__PURE__ */ u(
9
+ "div",
10
+ {
11
+ className: H("animate-pulse rounded-md bg-primary/10", e),
12
+ ...o
13
+ }
14
+ );
15
+ }
16
+ var [O] = W("Tooltip", [
17
+ j
18
+ ]), D = j(), z = "TooltipProvider", le = 700, k = "tooltip.open", [ce, L] = O(z), $ = (e) => {
19
+ const {
20
+ __scopeTooltip: o,
21
+ delayDuration: t = le,
22
+ skipDelayDuration: r = 300,
23
+ disableHoverableContent: n = !1,
24
+ children: l
25
+ } = e, i = a.useRef(!0), v = a.useRef(!1), s = a.useRef(0);
26
+ return a.useEffect(() => {
27
+ const p = s.current;
28
+ return () => window.clearTimeout(p);
29
+ }, []), /* @__PURE__ */ u(
30
+ ce,
31
+ {
32
+ scope: o,
33
+ isOpenDelayedRef: i,
34
+ delayDuration: t,
35
+ onOpen: a.useCallback(() => {
36
+ window.clearTimeout(s.current), i.current = !1;
37
+ }, []),
38
+ onClose: a.useCallback(() => {
39
+ window.clearTimeout(s.current), s.current = window.setTimeout(
40
+ () => i.current = !0,
41
+ r
42
+ );
43
+ }, [r]),
44
+ isPointerInTransitRef: v,
45
+ onPointerInTransitChange: a.useCallback((p) => {
46
+ v.current = p;
47
+ }, []),
48
+ disableHoverableContent: n,
49
+ children: l
50
+ }
51
+ );
52
+ };
53
+ $.displayName = z;
54
+ var R = "Tooltip", [ue, _] = O(R), B = (e) => {
55
+ const {
56
+ __scopeTooltip: o,
57
+ children: t,
58
+ open: r,
59
+ defaultOpen: n,
60
+ onOpenChange: l,
61
+ disableHoverableContent: i,
62
+ delayDuration: v
63
+ } = e, s = L(R, e.__scopeTooltip), p = D(o), [c, f] = a.useState(null), h = J(), d = a.useRef(0), g = i ?? s.disableHoverableContent, m = v ?? s.delayDuration, T = a.useRef(!1), [y, x] = Q({
64
+ prop: r,
65
+ defaultProp: n ?? !1,
66
+ onChange: (I) => {
67
+ I ? (s.onOpen(), document.dispatchEvent(new CustomEvent(k))) : s.onClose(), l?.(I);
68
+ },
69
+ caller: R
70
+ }), w = a.useMemo(() => y ? T.current ? "delayed-open" : "instant-open" : "closed", [y]), P = a.useCallback(() => {
71
+ window.clearTimeout(d.current), d.current = 0, T.current = !1, x(!0);
72
+ }, [x]), E = a.useCallback(() => {
73
+ window.clearTimeout(d.current), d.current = 0, x(!1);
74
+ }, [x]), N = a.useCallback(() => {
75
+ window.clearTimeout(d.current), d.current = window.setTimeout(() => {
76
+ T.current = !0, x(!0), d.current = 0;
77
+ }, m);
78
+ }, [m, x]);
79
+ return a.useEffect(() => () => {
80
+ d.current && (window.clearTimeout(d.current), d.current = 0);
81
+ }, []), /* @__PURE__ */ u(Z, { ...p, children: /* @__PURE__ */ u(
82
+ ue,
83
+ {
84
+ scope: o,
85
+ contentId: h,
86
+ open: y,
87
+ stateAttribute: w,
88
+ trigger: c,
89
+ onTriggerChange: f,
90
+ onTriggerEnter: a.useCallback(() => {
91
+ s.isOpenDelayedRef.current ? N() : P();
92
+ }, [s.isOpenDelayedRef, N, P]),
93
+ onTriggerLeave: a.useCallback(() => {
94
+ g ? E() : (window.clearTimeout(d.current), d.current = 0);
95
+ }, [E, g]),
96
+ onOpen: P,
97
+ onClose: E,
98
+ disableHoverableContent: g,
99
+ children: t
100
+ }
101
+ ) });
102
+ };
103
+ B.displayName = R;
104
+ var A = "TooltipTrigger", U = a.forwardRef(
105
+ (e, o) => {
106
+ const { __scopeTooltip: t, ...r } = e, n = _(A, t), l = L(A, t), i = D(t), v = a.useRef(null), s = G(o, v, n.onTriggerChange), p = a.useRef(!1), c = a.useRef(!1), f = a.useCallback(() => p.current = !1, []);
107
+ return a.useEffect(() => () => document.removeEventListener("pointerup", f), [f]), /* @__PURE__ */ u(ee, { asChild: !0, ...i, children: /* @__PURE__ */ u(
108
+ te.button,
109
+ {
110
+ "aria-describedby": n.open ? n.contentId : void 0,
111
+ "data-state": n.stateAttribute,
112
+ ...r,
113
+ ref: s,
114
+ onPointerMove: C(e.onPointerMove, (h) => {
115
+ h.pointerType !== "touch" && !c.current && !l.isPointerInTransitRef.current && (n.onTriggerEnter(), c.current = !0);
116
+ }),
117
+ onPointerLeave: C(e.onPointerLeave, () => {
118
+ n.onTriggerLeave(), c.current = !1;
119
+ }),
120
+ onPointerDown: C(e.onPointerDown, () => {
121
+ n.open && n.onClose(), p.current = !0, document.addEventListener("pointerup", f, { once: !0 });
122
+ }),
123
+ onFocus: C(e.onFocus, () => {
124
+ p.current || n.onOpen();
125
+ }),
126
+ onBlur: C(e.onBlur, n.onClose),
127
+ onClick: C(e.onClick, n.onClose)
128
+ }
129
+ ) });
130
+ }
131
+ );
132
+ U.displayName = A;
133
+ var M = "TooltipPortal", [de, pe] = O(M, {
134
+ forceMount: void 0
135
+ }), V = (e) => {
136
+ const { __scopeTooltip: o, forceMount: t, children: r, container: n } = e, l = _(M, o);
137
+ return /* @__PURE__ */ u(de, { scope: o, forceMount: t, children: /* @__PURE__ */ u(F, { present: t || l.open, children: /* @__PURE__ */ u(oe, { asChild: !0, container: n, children: r }) }) });
138
+ };
139
+ V.displayName = M;
140
+ var b = "TooltipContent", Y = a.forwardRef(
141
+ (e, o) => {
142
+ const t = pe(b, e.__scopeTooltip), { forceMount: r = t.forceMount, side: n = "top", ...l } = e, i = _(b, e.__scopeTooltip);
143
+ return /* @__PURE__ */ u(F, { present: r || i.open, children: i.disableHoverableContent ? /* @__PURE__ */ u(q, { side: n, ...l, ref: o }) : /* @__PURE__ */ u(fe, { side: n, ...l, ref: o }) });
144
+ }
145
+ ), fe = a.forwardRef((e, o) => {
146
+ const t = _(b, e.__scopeTooltip), r = L(b, e.__scopeTooltip), n = a.useRef(null), l = G(o, n), [i, v] = a.useState(null), { trigger: s, onClose: p } = t, c = n.current, { onPointerInTransitChange: f } = r, h = a.useCallback(() => {
147
+ v(null), f(!1);
148
+ }, [f]), d = a.useCallback(
149
+ (g, m) => {
150
+ const T = g.currentTarget, y = { x: g.clientX, y: g.clientY }, x = Te(y, T.getBoundingClientRect()), w = me(y, x), P = xe(m.getBoundingClientRect()), E = Ce([...w, ...P]);
151
+ v(E), f(!0);
152
+ },
153
+ [f]
154
+ );
155
+ return a.useEffect(() => () => h(), [h]), a.useEffect(() => {
156
+ if (s && c) {
157
+ const g = (T) => d(T, c), m = (T) => d(T, s);
158
+ return s.addEventListener("pointerleave", g), c.addEventListener("pointerleave", m), () => {
159
+ s.removeEventListener("pointerleave", g), c.removeEventListener("pointerleave", m);
160
+ };
161
+ }
162
+ }, [s, c, d, h]), a.useEffect(() => {
163
+ if (i) {
164
+ const g = (m) => {
165
+ const T = m.target, y = { x: m.clientX, y: m.clientY }, x = s?.contains(T) || c?.contains(T), w = !ye(y, i);
166
+ x ? h() : w && (h(), p());
167
+ };
168
+ return document.addEventListener("pointermove", g), () => document.removeEventListener("pointermove", g);
169
+ }
170
+ }, [s, c, i, p, h]), /* @__PURE__ */ u(q, { ...e, ref: l });
171
+ }), [ve, he] = O(R, { isInside: !1 }), ge = se("TooltipContent"), q = a.forwardRef(
172
+ (e, o) => {
173
+ const {
174
+ __scopeTooltip: t,
175
+ children: r,
176
+ "aria-label": n,
177
+ onEscapeKeyDown: l,
178
+ onPointerDownOutside: i,
179
+ ...v
180
+ } = e, s = _(b, t), p = D(t), { onClose: c } = s;
181
+ return a.useEffect(() => (document.addEventListener(k, c), () => document.removeEventListener(k, c)), [c]), a.useEffect(() => {
182
+ if (s.trigger) {
183
+ const f = (h) => {
184
+ h.target?.contains(s.trigger) && c();
185
+ };
186
+ return window.addEventListener("scroll", f, { capture: !0 }), () => window.removeEventListener("scroll", f, { capture: !0 });
187
+ }
188
+ }, [s.trigger, c]), /* @__PURE__ */ u(
189
+ ne,
190
+ {
191
+ asChild: !0,
192
+ disableOutsidePointerEvents: !1,
193
+ onEscapeKeyDown: l,
194
+ onPointerDownOutside: i,
195
+ onFocusOutside: (f) => f.preventDefault(),
196
+ onDismiss: c,
197
+ children: /* @__PURE__ */ S(
198
+ ae,
199
+ {
200
+ "data-state": s.stateAttribute,
201
+ ...p,
202
+ ...v,
203
+ ref: o,
204
+ style: {
205
+ ...v.style,
206
+ "--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
207
+ "--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
208
+ "--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
209
+ "--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
210
+ "--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
211
+ },
212
+ children: [
213
+ /* @__PURE__ */ u(ge, { children: r }),
214
+ /* @__PURE__ */ u(ve, { scope: t, isInside: !0, children: /* @__PURE__ */ u(ie, { id: s.contentId, role: "tooltip", children: n || r }) })
215
+ ]
216
+ }
217
+ )
218
+ }
219
+ );
220
+ }
221
+ );
222
+ Y.displayName = b;
223
+ var X = "TooltipArrow", K = a.forwardRef(
224
+ (e, o) => {
225
+ const { __scopeTooltip: t, ...r } = e, n = D(t);
226
+ return he(
227
+ X,
228
+ t
229
+ ).isInside ? null : /* @__PURE__ */ u(re, { ...n, ...r, ref: o });
230
+ }
231
+ );
232
+ K.displayName = X;
233
+ function Te(e, o) {
234
+ const t = Math.abs(o.top - e.y), r = Math.abs(o.bottom - e.y), n = Math.abs(o.right - e.x), l = Math.abs(o.left - e.x);
235
+ switch (Math.min(t, r, n, l)) {
236
+ case l:
237
+ return "left";
238
+ case n:
239
+ return "right";
240
+ case t:
241
+ return "top";
242
+ case r:
243
+ return "bottom";
244
+ default:
245
+ throw new Error("unreachable");
246
+ }
247
+ }
248
+ function me(e, o, t = 5) {
249
+ const r = [];
250
+ switch (o) {
251
+ case "top":
252
+ r.push(
253
+ { x: e.x - t, y: e.y + t },
254
+ { x: e.x + t, y: e.y + t }
255
+ );
256
+ break;
257
+ case "bottom":
258
+ r.push(
259
+ { x: e.x - t, y: e.y - t },
260
+ { x: e.x + t, y: e.y - t }
261
+ );
262
+ break;
263
+ case "left":
264
+ r.push(
265
+ { x: e.x + t, y: e.y - t },
266
+ { x: e.x + t, y: e.y + t }
267
+ );
268
+ break;
269
+ case "right":
270
+ r.push(
271
+ { x: e.x - t, y: e.y - t },
272
+ { x: e.x - t, y: e.y + t }
273
+ );
274
+ break;
275
+ }
276
+ return r;
277
+ }
278
+ function xe(e) {
279
+ const { top: o, right: t, bottom: r, left: n } = e;
280
+ return [
281
+ { x: n, y: o },
282
+ { x: t, y: o },
283
+ { x: t, y: r },
284
+ { x: n, y: r }
285
+ ];
286
+ }
287
+ function ye(e, o) {
288
+ const { x: t, y: r } = e;
289
+ let n = !1;
290
+ for (let l = 0, i = o.length - 1; l < o.length; i = l++) {
291
+ const v = o[l], s = o[i], p = v.x, c = v.y, f = s.x, h = s.y;
292
+ c > r != h > r && t < (f - p) * (r - c) / (h - c) + p && (n = !n);
293
+ }
294
+ return n;
295
+ }
296
+ function Ce(e) {
297
+ const o = e.slice();
298
+ return o.sort((t, r) => t.x < r.x ? -1 : t.x > r.x ? 1 : t.y < r.y ? -1 : t.y > r.y ? 1 : 0), be(o);
299
+ }
300
+ function be(e) {
301
+ if (e.length <= 1) return e.slice();
302
+ const o = [];
303
+ for (let r = 0; r < e.length; r++) {
304
+ const n = e[r];
305
+ for (; o.length >= 2; ) {
306
+ const l = o[o.length - 1], i = o[o.length - 2];
307
+ if ((l.x - i.x) * (n.y - i.y) >= (l.y - i.y) * (n.x - i.x)) o.pop();
308
+ else break;
309
+ }
310
+ o.push(n);
311
+ }
312
+ o.pop();
313
+ const t = [];
314
+ for (let r = e.length - 1; r >= 0; r--) {
315
+ const n = e[r];
316
+ for (; t.length >= 2; ) {
317
+ const l = t[t.length - 1], i = t[t.length - 2];
318
+ if ((l.x - i.x) * (n.y - i.y) >= (l.y - i.y) * (n.x - i.x)) t.pop();
319
+ else break;
320
+ }
321
+ t.push(n);
322
+ }
323
+ return t.pop(), o.length === 1 && t.length === 1 && o[0].x === t[0].x && o[0].y === t[0].y ? o : o.concat(t);
324
+ }
325
+ var we = $, Pe = B, Ee = U, Re = V, _e = Y, Oe = K;
326
+ function Le({
327
+ delayDuration: e = 0,
328
+ ...o
329
+ }) {
330
+ return /* @__PURE__ */ u(
331
+ we,
332
+ {
333
+ "data-slot": "tooltip-provider",
334
+ delayDuration: e,
335
+ ...o
336
+ }
337
+ );
338
+ }
339
+ function Me({
340
+ ...e
341
+ }) {
342
+ return /* @__PURE__ */ u(Pe, { "data-slot": "tooltip", ...e });
343
+ }
344
+ function Ne({
345
+ ...e
346
+ }) {
347
+ return /* @__PURE__ */ u(Ee, { "data-slot": "tooltip-trigger", ...e });
348
+ }
349
+ function Ie({
350
+ className: e,
351
+ sideOffset: o = 0,
352
+ children: t,
353
+ ...r
354
+ }) {
355
+ return /* @__PURE__ */ u(Re, { children: /* @__PURE__ */ S(
356
+ _e,
357
+ {
358
+ "data-slot": "tooltip-content",
359
+ sideOffset: o,
360
+ className: H(
361
+ "z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
362
+ e
363
+ ),
364
+ ...r,
365
+ children: [
366
+ t,
367
+ /* @__PURE__ */ u(Oe, { className: "z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" })
368
+ ]
369
+ }
370
+ ) });
371
+ }
372
+ export {
373
+ Ae as S,
374
+ Me as T,
375
+ Ne as a,
376
+ Ie as b,
377
+ Le as c
378
+ };