@grapadigital/shared-app-modules 0.0.196 → 0.0.198

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,38 +0,0 @@
1
- import { useState as s, useEffect as u, useContext as a } from "react";
2
- import { a as c } from "./shared-app-modules.provider.DRJ7n4Cj.js";
3
- import d from "axios";
4
- function h(e, t = 500) {
5
- const [o, r] = s(e);
6
- return u(() => {
7
- const n = setTimeout(() => {
8
- r(e);
9
- }, t);
10
- return () => {
11
- clearTimeout(n);
12
- };
13
- }, [e, t]), o;
14
- }
15
- function l() {
16
- const e = a(c);
17
- if (!e)
18
- throw new Error(
19
- "useSharedAppModules deve ser usando detro de um componente SharedAppModulesProvider"
20
- );
21
- return e;
22
- }
23
- const f = (e) => {
24
- const t = d.create({
25
- baseURL: e,
26
- timeout: 5e3,
27
- headers: { "Content-Type": "application/json" }
28
- });
29
- return t.interceptors.request.use((o) => {
30
- const r = localStorage.getItem("token");
31
- return r && (o.headers.Authorization = `Bearer ${r}`), o;
32
- }), t;
33
- };
34
- export {
35
- h as a,
36
- f as c,
37
- l as u
38
- };
@@ -1,416 +0,0 @@
1
- import { jsx as u, jsxs as H } from "react/jsx-runtime";
2
- import { c as L, a_ as W, a$ as j, b0 as J, b1 as Q, b2 as Z, b3 as G, b4 as ee, b5 as te, b6 as T, b7 as z, b8 as re, b9 as oe, ba as ne, bb as ae, bc as se, bd as ie, a as ce, be as le } from "./switch.D4GUsewk.js";
3
- import * as a from "react";
4
- function Me({
5
- className: e,
6
- ...r
7
- }) {
8
- return /* @__PURE__ */ u(
9
- "div",
10
- {
11
- className: L("animate-pulse rounded-md bg-primary/10", e),
12
- ...r
13
- }
14
- );
15
- }
16
- var [k] = W("Tooltip", [
17
- j
18
- ]), O = j(), B = "TooltipProvider", ue = 700, D = "tooltip.open", [de, N] = k(B), F = (e) => {
19
- const {
20
- __scopeTooltip: r,
21
- delayDuration: t = ue,
22
- skipDelayDuration: o = 300,
23
- disableHoverableContent: n = !1,
24
- children: c
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
- de,
31
- {
32
- scope: r,
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
- o
42
- );
43
- }, [o]),
44
- isPointerInTransitRef: v,
45
- onPointerInTransitChange: a.useCallback((p) => {
46
- v.current = p;
47
- }, []),
48
- disableHoverableContent: n,
49
- children: c
50
- }
51
- );
52
- };
53
- F.displayName = B;
54
- var R = "Tooltip", [pe, _] = k(R), $ = (e) => {
55
- const {
56
- __scopeTooltip: r,
57
- children: t,
58
- open: o,
59
- defaultOpen: n,
60
- onOpenChange: c,
61
- disableHoverableContent: i,
62
- delayDuration: v
63
- } = e, s = N(R, e.__scopeTooltip), p = O(r), [l, f] = a.useState(null), g = J(), d = a.useRef(0), h = i ?? s.disableHoverableContent, x = v ?? s.delayDuration, b = a.useRef(!1), [y, m] = Q({
64
- prop: o,
65
- defaultProp: n ?? !1,
66
- onChange: (S) => {
67
- S ? (s.onOpen(), document.dispatchEvent(new CustomEvent(D))) : s.onClose(), c?.(S);
68
- },
69
- caller: R
70
- }), w = a.useMemo(() => y ? b.current ? "delayed-open" : "instant-open" : "closed", [y]), P = a.useCallback(() => {
71
- window.clearTimeout(d.current), d.current = 0, b.current = !1, m(!0);
72
- }, [m]), E = a.useCallback(() => {
73
- window.clearTimeout(d.current), d.current = 0, m(!1);
74
- }, [m]), I = a.useCallback(() => {
75
- window.clearTimeout(d.current), d.current = window.setTimeout(() => {
76
- b.current = !0, m(!0), d.current = 0;
77
- }, x);
78
- }, [x, m]);
79
- return a.useEffect(() => () => {
80
- d.current && (window.clearTimeout(d.current), d.current = 0);
81
- }, []), /* @__PURE__ */ u(Z, { ...p, children: /* @__PURE__ */ u(
82
- pe,
83
- {
84
- scope: r,
85
- contentId: g,
86
- open: y,
87
- stateAttribute: w,
88
- trigger: l,
89
- onTriggerChange: f,
90
- onTriggerEnter: a.useCallback(() => {
91
- s.isOpenDelayedRef.current ? I() : P();
92
- }, [s.isOpenDelayedRef, I, P]),
93
- onTriggerLeave: a.useCallback(() => {
94
- h ? E() : (window.clearTimeout(d.current), d.current = 0);
95
- }, [E, h]),
96
- onOpen: P,
97
- onClose: E,
98
- disableHoverableContent: h,
99
- children: t
100
- }
101
- ) });
102
- };
103
- $.displayName = R;
104
- var A = "TooltipTrigger", V = a.forwardRef(
105
- (e, r) => {
106
- const { __scopeTooltip: t, ...o } = e, n = _(A, t), c = N(A, t), i = O(t), v = a.useRef(null), s = G(r, v, n.onTriggerChange), p = a.useRef(!1), l = 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
- ...o,
113
- ref: s,
114
- onPointerMove: T(e.onPointerMove, (g) => {
115
- g.pointerType !== "touch" && !l.current && !c.isPointerInTransitRef.current && (n.onTriggerEnter(), l.current = !0);
116
- }),
117
- onPointerLeave: T(e.onPointerLeave, () => {
118
- n.onTriggerLeave(), l.current = !1;
119
- }),
120
- onPointerDown: T(e.onPointerDown, () => {
121
- n.open && n.onClose(), p.current = !0, document.addEventListener("pointerup", f, { once: !0 });
122
- }),
123
- onFocus: T(e.onFocus, () => {
124
- p.current || n.onOpen();
125
- }),
126
- onBlur: T(e.onBlur, n.onClose),
127
- onClick: T(e.onClick, n.onClose)
128
- }
129
- ) });
130
- }
131
- );
132
- V.displayName = A;
133
- var M = "TooltipPortal", [fe, ve] = k(M, {
134
- forceMount: void 0
135
- }), U = (e) => {
136
- const { __scopeTooltip: r, forceMount: t, children: o, container: n } = e, c = _(M, r);
137
- return /* @__PURE__ */ u(fe, { scope: r, forceMount: t, children: /* @__PURE__ */ u(z, { present: t || c.open, children: /* @__PURE__ */ u(re, { asChild: !0, container: n, children: o }) }) });
138
- };
139
- U.displayName = M;
140
- var C = "TooltipContent", Y = a.forwardRef(
141
- (e, r) => {
142
- const t = ve(C, e.__scopeTooltip), { forceMount: o = t.forceMount, side: n = "top", ...c } = e, i = _(C, e.__scopeTooltip);
143
- return /* @__PURE__ */ u(z, { present: o || i.open, children: i.disableHoverableContent ? /* @__PURE__ */ u(q, { side: n, ...c, ref: r }) : /* @__PURE__ */ u(ge, { side: n, ...c, ref: r }) });
144
- }
145
- ), ge = a.forwardRef((e, r) => {
146
- const t = _(C, e.__scopeTooltip), o = N(C, e.__scopeTooltip), n = a.useRef(null), c = G(r, n), [i, v] = a.useState(null), { trigger: s, onClose: p } = t, l = n.current, { onPointerInTransitChange: f } = o, g = a.useCallback(() => {
147
- v(null), f(!1);
148
- }, [f]), d = a.useCallback(
149
- (h, x) => {
150
- const b = h.currentTarget, y = { x: h.clientX, y: h.clientY }, m = me(y, b.getBoundingClientRect()), w = ye(y, m), P = Te(x.getBoundingClientRect()), E = we([...w, ...P]);
151
- v(E), f(!0);
152
- },
153
- [f]
154
- );
155
- return a.useEffect(() => () => g(), [g]), a.useEffect(() => {
156
- if (s && l) {
157
- const h = (b) => d(b, l), x = (b) => d(b, s);
158
- return s.addEventListener("pointerleave", h), l.addEventListener("pointerleave", x), () => {
159
- s.removeEventListener("pointerleave", h), l.removeEventListener("pointerleave", x);
160
- };
161
- }
162
- }, [s, l, d, g]), a.useEffect(() => {
163
- if (i) {
164
- const h = (x) => {
165
- const b = x.target, y = { x: x.clientX, y: x.clientY }, m = s?.contains(b) || l?.contains(b), w = !Ce(y, i);
166
- m ? g() : w && (g(), p());
167
- };
168
- return document.addEventListener("pointermove", h), () => document.removeEventListener("pointermove", h);
169
- }
170
- }, [s, l, i, p, g]), /* @__PURE__ */ u(q, { ...e, ref: c });
171
- }), [he, be] = k(R, { isInside: !1 }), xe = se("TooltipContent"), q = a.forwardRef(
172
- (e, r) => {
173
- const {
174
- __scopeTooltip: t,
175
- children: o,
176
- "aria-label": n,
177
- onEscapeKeyDown: c,
178
- onPointerDownOutside: i,
179
- ...v
180
- } = e, s = _(C, t), p = O(t), { onClose: l } = s;
181
- return a.useEffect(() => (document.addEventListener(D, l), () => document.removeEventListener(D, l)), [l]), a.useEffect(() => {
182
- if (s.trigger) {
183
- const f = (g) => {
184
- g.target?.contains(s.trigger) && l();
185
- };
186
- return window.addEventListener("scroll", f, { capture: !0 }), () => window.removeEventListener("scroll", f, { capture: !0 });
187
- }
188
- }, [s.trigger, l]), /* @__PURE__ */ u(
189
- ne,
190
- {
191
- asChild: !0,
192
- disableOutsidePointerEvents: !1,
193
- onEscapeKeyDown: c,
194
- onPointerDownOutside: i,
195
- onFocusOutside: (f) => f.preventDefault(),
196
- onDismiss: l,
197
- children: /* @__PURE__ */ H(
198
- ae,
199
- {
200
- "data-state": s.stateAttribute,
201
- ...p,
202
- ...v,
203
- ref: r,
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(xe, { children: o }),
214
- /* @__PURE__ */ u(he, { scope: t, isInside: !0, children: /* @__PURE__ */ u(ie, { id: s.contentId, role: "tooltip", children: n || o }) })
215
- ]
216
- }
217
- )
218
- }
219
- );
220
- }
221
- );
222
- Y.displayName = C;
223
- var X = "TooltipArrow", K = a.forwardRef(
224
- (e, r) => {
225
- const { __scopeTooltip: t, ...o } = e, n = O(t);
226
- return be(
227
- X,
228
- t
229
- ).isInside ? null : /* @__PURE__ */ u(oe, { ...n, ...o, ref: r });
230
- }
231
- );
232
- K.displayName = X;
233
- function me(e, r) {
234
- const t = Math.abs(r.top - e.y), o = Math.abs(r.bottom - e.y), n = Math.abs(r.right - e.x), c = Math.abs(r.left - e.x);
235
- switch (Math.min(t, o, n, c)) {
236
- case c:
237
- return "left";
238
- case n:
239
- return "right";
240
- case t:
241
- return "top";
242
- case o:
243
- return "bottom";
244
- default:
245
- throw new Error("unreachable");
246
- }
247
- }
248
- function ye(e, r, t = 5) {
249
- const o = [];
250
- switch (r) {
251
- case "top":
252
- o.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
- o.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
- o.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
- o.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 o;
277
- }
278
- function Te(e) {
279
- const { top: r, right: t, bottom: o, left: n } = e;
280
- return [
281
- { x: n, y: r },
282
- { x: t, y: r },
283
- { x: t, y: o },
284
- { x: n, y: o }
285
- ];
286
- }
287
- function Ce(e, r) {
288
- const { x: t, y: o } = e;
289
- let n = !1;
290
- for (let c = 0, i = r.length - 1; c < r.length; i = c++) {
291
- const v = r[c], s = r[i], p = v.x, l = v.y, f = s.x, g = s.y;
292
- l > o != g > o && t < (f - p) * (o - l) / (g - l) + p && (n = !n);
293
- }
294
- return n;
295
- }
296
- function we(e) {
297
- const r = e.slice();
298
- return r.sort((t, o) => t.x < o.x ? -1 : t.x > o.x ? 1 : t.y < o.y ? -1 : t.y > o.y ? 1 : 0), Pe(r);
299
- }
300
- function Pe(e) {
301
- if (e.length <= 1) return e.slice();
302
- const r = [];
303
- for (let o = 0; o < e.length; o++) {
304
- const n = e[o];
305
- for (; r.length >= 2; ) {
306
- const c = r[r.length - 1], i = r[r.length - 2];
307
- if ((c.x - i.x) * (n.y - i.y) >= (c.y - i.y) * (n.x - i.x)) r.pop();
308
- else break;
309
- }
310
- r.push(n);
311
- }
312
- r.pop();
313
- const t = [];
314
- for (let o = e.length - 1; o >= 0; o--) {
315
- const n = e[o];
316
- for (; t.length >= 2; ) {
317
- const c = t[t.length - 1], i = t[t.length - 2];
318
- if ((c.x - i.x) * (n.y - i.y) >= (c.y - i.y) * (n.x - i.x)) t.pop();
319
- else break;
320
- }
321
- t.push(n);
322
- }
323
- return t.pop(), r.length === 1 && t.length === 1 && r[0].x === t[0].x && r[0].y === t[0].y ? r : r.concat(t);
324
- }
325
- var Ee = F, Re = $, _e = V, ke = U, Oe = Y, De = K;
326
- function Ie({
327
- delayDuration: e = 0,
328
- ...r
329
- }) {
330
- return /* @__PURE__ */ u(
331
- Ee,
332
- {
333
- "data-slot": "tooltip-provider",
334
- delayDuration: e,
335
- ...r
336
- }
337
- );
338
- }
339
- function Se({
340
- ...e
341
- }) {
342
- return /* @__PURE__ */ u(Re, { "data-slot": "tooltip", ...e });
343
- }
344
- function He({
345
- ...e
346
- }) {
347
- return /* @__PURE__ */ u(_e, { "data-slot": "tooltip-trigger", ...e });
348
- }
349
- function je({
350
- className: e,
351
- sideOffset: r = 0,
352
- children: t,
353
- ...o
354
- }) {
355
- return /* @__PURE__ */ u(ke, { children: /* @__PURE__ */ H(
356
- Oe,
357
- {
358
- "data-slot": "tooltip-content",
359
- sideOffset: r,
360
- className: L(
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
- ...o,
365
- children: [
366
- t,
367
- /* @__PURE__ */ u(De, { className: "z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" })
368
- ]
369
- }
370
- ) });
371
- }
372
- const Ae = ce(
373
- "inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",
374
- {
375
- variants: {
376
- variant: {
377
- default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
378
- secondary: "bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
379
- destructive: "bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",
380
- success: "border-transparent bg-green-500 text-destructive-foreground shadow hover:bg-green-500/80",
381
- warning: "border-transparent bg-orange-500 text-destructive-foreground shadow hover:bg-orange-500/80",
382
- outline: "border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
383
- ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
384
- link: "text-primary underline-offset-4 [a&]:hover:underline"
385
- }
386
- },
387
- defaultVariants: {
388
- variant: "default"
389
- }
390
- }
391
- );
392
- function Ge({
393
- className: e,
394
- variant: r = "default",
395
- asChild: t = !1,
396
- ...o
397
- }) {
398
- return /* @__PURE__ */ u(
399
- t ? le : "span",
400
- {
401
- "data-slot": "badge",
402
- "data-variant": r,
403
- className: L(Ae({ variant: r }), e),
404
- ...o
405
- }
406
- );
407
- }
408
- export {
409
- Ge as B,
410
- Me as S,
411
- Se as T,
412
- He as a,
413
- je as b,
414
- Ie as c,
415
- Ae as d
416
- };
@@ -1,33 +0,0 @@
1
- function i(n) {
2
- return Object.keys(n);
3
- }
4
- function s(n) {
5
- return Object.entries(n);
6
- }
7
- function u(n) {
8
- return Object.values(n);
9
- }
10
- function o(n) {
11
- function r(e) {
12
- return !e || !(e in n) ? null : n[e];
13
- }
14
- return {
15
- data: n,
16
- values: i(n),
17
- labels: u(n),
18
- getLabel: r,
19
- options: s(n).map(([e, t]) => ({
20
- value: e,
21
- label: t
22
- })),
23
- is(e) {
24
- return e !== 0 && !e ? !1 : e in n;
25
- }
26
- };
27
- }
28
- export {
29
- o as c,
30
- s as e,
31
- i as k,
32
- u as v
33
- };