@gustavo-valsechi/client 1.3.22 → 1.3.24

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,488 @@
1
1
  "use client";
2
2
  "use client";
3
- export * from "./icon";
4
- export * from "./theme";
5
- export * from "./tooltip";
6
- export * from "./modal";
3
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
4
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
5
+ }) : x)(function(x) {
6
+ if (typeof require !== "undefined") return require.apply(this, arguments);
7
+ throw Error('Dynamic require of "' + x + '" is not supported');
8
+ });
9
+
10
+ // contexts/icon/index.tsx
11
+ import { createContext as createContext2, useContext as useContext2, useEffect as useEffect2, useState as useState2 } from "react";
12
+
13
+ // contexts/theme/index.tsx
14
+ import { createContext, useContext, useState } from "react";
15
+ import { ThemeProvider } from "styled-components";
16
+
17
+ // contexts/theme/styles.tsx
18
+ import styled from "styled-components";
19
+ var Switcher = styled.div`
20
+ width: 3rem;
21
+ height: 1.5rem;
22
+ border-radius: 1rem;
23
+ border: 2px solid ${({ theme }) => theme.t05};
24
+ overflow: hidden;
25
+ display: flex;
26
+ align-items: center;
27
+ cursor: pointer;
28
+ position: relative;
29
+
30
+ i {
31
+ color: ${({ theme }) => theme.t6};
32
+ position: absolute;
33
+ transform: translateY(-50%);
34
+ font-size: .9rem;
35
+ z-index: 0;
36
+ transition: ease .8s;
37
+
38
+ &:first-child {
39
+ left: .2rem;
40
+ top: 50%;
41
+ opacity: ${(props) => props["data-theme"] === "light" ? 0 : 1};
42
+ }
43
+
44
+ &:last-child {
45
+ right: .2rem;
46
+ top: 50%;
47
+ opacity: ${(props) => props["data-theme"] === "light" ? 1 : 0};
48
+ }
49
+ }
50
+
51
+ .switcher {
52
+ width: 1rem;
53
+ height: 1rem;
54
+ border-radius: 1rem;
55
+ position: relative;
56
+ transition: ease .3s;
57
+ transform: ${(props) => props["data-theme"] === "light" ? "transform: translateX(.2rem)" : "translateX(1.6rem)"};
58
+ z-index: 1;
59
+
60
+ div {
61
+ width: 100%;
62
+ height: 100%;
63
+ background: ${({ theme }) => theme.primary};
64
+ border-radius: 1rem;
65
+ position: relative;
66
+ z-index: 2;
67
+ }
68
+
69
+ &:after {
70
+ content: "";
71
+ position: absolute;
72
+ width: 100%;
73
+ height: 100%;
74
+ border-radius: 1rem;
75
+ transform: scale(1.8);
76
+ background: ${({ theme }) => theme.t05};
77
+ top: 0;
78
+ left: 0;
79
+ z-index: 1;
80
+ }
81
+
82
+ &:before {
83
+ content: "";
84
+ position: absolute;
85
+ width: 100%;
86
+ height: 100%;
87
+ border-radius: 1rem;
88
+ transform: scale(3);
89
+ background: ${({ theme }) => theme.t05};
90
+ top: 0;
91
+ left: 0;
92
+ z-index: 0;
93
+ }
94
+ }
95
+ `;
96
+
97
+ // contexts/theme/content.tsx
98
+ var CommonTheme = {
99
+ secondary: "#5869da",
100
+ tertiary: "#629dfd33",
101
+ positive: "#65c965",
102
+ negative: "#FF334E",
103
+ mobileMaxWidth: "650px",
104
+ mobileMinWidth: "315px"
105
+ };
106
+ var Themes = {
107
+ light: {
108
+ primary: "#ffffff",
109
+ reverse: "#353535",
110
+ tooltip: "#f2f2f2",
111
+ t8: "#000000cc",
112
+ t7: "#000000b3",
113
+ t6: "#00000099",
114
+ t5: "#00000080",
115
+ t4: "#00000066",
116
+ t3: "#0000004d",
117
+ t2: "#00000033",
118
+ t1: "#0000001a",
119
+ t08: "#00000014",
120
+ t05: "#0000000d",
121
+ t03: "#00000007",
122
+ t02: "#00000005",
123
+ t01: "#00000002",
124
+ lgrad: `linear-gradient(
125
+ to right,
126
+ #dadef7 0%,
127
+ #dee2f8 5%,
128
+ #e2e5f9 10%,
129
+ #e6e9fa 20%,
130
+ #eaedfb 30%,
131
+ #eff0fb 60%,
132
+ #f3f4fc 80%,
133
+ #f7f8fd 90%,
134
+ #fbfbfe 100%
135
+ )`,
136
+ maingrad: "linear-gradient(330deg, #b9c0ff7a 0%, #ffffff 100%)",
137
+ ...CommonTheme
138
+ },
139
+ dark: {
140
+ primary: "#333333",
141
+ reverse: "#b45252",
142
+ tooltip: "#3d3d3d",
143
+ t8: "#ffffffcc",
144
+ t7: "#ffffffb3",
145
+ t6: "#ffffff99",
146
+ t5: "#ffffff80",
147
+ t4: "#ffffff66",
148
+ t3: "#ffffff4d",
149
+ t2: "#ffffff33",
150
+ t1: "#ffffff1a",
151
+ t08: "#ffffff14",
152
+ t05: "#ffffff0d",
153
+ t03: "#ffffff07",
154
+ t02: "#ffffff05",
155
+ t01: "#ffffff02",
156
+ lgrad: `linear-gradient(
157
+ to right,
158
+ #3d485c 0%,
159
+ #3c4657 5%,
160
+ #3b4353 10%,
161
+ #3a414e 20%,
162
+ #393f4a 30%,
163
+ #373c45 60%,
164
+ #363a41 80%,
165
+ #35383c 90%,
166
+ #343538 100%
167
+ )`,
168
+ maingrad: "linear-gradient(330deg, #1d1e27 0%, #333333 100%)",
169
+ ...CommonTheme
170
+ }
171
+ };
172
+
173
+ // contexts/theme/index.tsx
174
+ import { jsx, jsxs } from "react/jsx-runtime";
175
+ var ThemeContext = createContext({});
176
+ var ThemeProviderContainer = (props) => {
177
+ const [theme, setTheme] = useState("light");
178
+ const [defaultTheme] = useState("light");
179
+ const SwitcherComponent = () => {
180
+ return /* @__PURE__ */ jsxs(
181
+ Switcher,
182
+ {
183
+ onClick: () => setTheme(theme === "light" ? "dark" : "light"),
184
+ "data-theme": theme || defaultTheme,
185
+ children: [
186
+ /* @__PURE__ */ jsx("i", { "aria-hidden": true, className: "fa-solid fa-moon" }),
187
+ /* @__PURE__ */ jsx("div", { className: "switcher", children: /* @__PURE__ */ jsx("div", {}) }),
188
+ /* @__PURE__ */ jsx("i", { "aria-hidden": true, className: "fa-solid fa-sun" })
189
+ ]
190
+ }
191
+ );
192
+ };
193
+ return /* @__PURE__ */ jsx(
194
+ ThemeContext.Provider,
195
+ {
196
+ value: {
197
+ theme: props.theme || defaultTheme,
198
+ setTheme,
199
+ content: Themes[props.theme || defaultTheme],
200
+ Switcher: SwitcherComponent
201
+ },
202
+ children: /* @__PURE__ */ jsx(ThemeProvider, { theme: Themes[props.theme || defaultTheme], children: props.children })
203
+ }
204
+ );
205
+ };
206
+ var useTheme = () => useContext(ThemeContext);
207
+
208
+ // contexts/icon/index.tsx
209
+ import _ from "lodash";
210
+
211
+ // contexts/icon/assets/brands/index.tsx
212
+ var req = __require.context("./", false, /\.svg$/);
213
+ var brands = {};
214
+ req.keys().forEach((key) => {
215
+ const name = key.replace("./", "").replace(".svg", "");
216
+ brands[name] = req(key).default;
217
+ });
218
+ var brands_default = brands;
219
+
220
+ // contexts/icon/assets/regular/index.tsx
221
+ var req2 = __require.context("./", false, /\.svg$/);
222
+ var regular = {};
223
+ req2.keys().forEach((key) => {
224
+ const name = key.replace("./", "").replace(".svg", "");
225
+ regular[name] = req2(key).default;
226
+ });
227
+ var regular_default = regular;
228
+
229
+ // contexts/icon/assets/solid/index.tsx
230
+ var req3 = __require.context("./", false, /\.svg$/);
231
+ var solid = {};
232
+ req3.keys().forEach((key) => {
233
+ const name = key.replace("./", "").replace(".svg", "");
234
+ solid[name] = req3(key).default;
235
+ });
236
+ var solid_default = solid;
237
+
238
+ // contexts/icon/assets/index.tsx
239
+ var assets_default = {
240
+ brands: brands_default,
241
+ regular: regular_default,
242
+ solid: solid_default
243
+ };
244
+
245
+ // contexts/icon/index.tsx
246
+ import { jsx as jsx2 } from "react/jsx-runtime";
247
+ var IconContext = createContext2({});
248
+ var IconProviderContainer = ({ children }) => {
249
+ const { content } = useTheme();
250
+ const [isClient, setIsClient] = useState2(false);
251
+ const [matches, setMatches] = useState2(0);
252
+ useEffect2(() => {
253
+ setIsClient(true);
254
+ }, []);
255
+ useEffect2(() => {
256
+ const firstMediaQuery = window.matchMedia(`(max-width: ${content.mobileMaxWidth})`);
257
+ const secoundMediaQuery = window.matchMedia(`(max-width: ${content.mobileMinWidth})`);
258
+ const firstHandler = (event) => setMatches(event.matches ? 1 : 0);
259
+ const secoundHandler = (event) => setMatches(event.matches ? 2 : 1);
260
+ if (firstMediaQuery.matches) setMatches(1);
261
+ if (secoundMediaQuery.matches) setMatches(2);
262
+ firstMediaQuery.addEventListener("change", firstHandler);
263
+ secoundMediaQuery.addEventListener("change", secoundHandler);
264
+ return () => {
265
+ firstMediaQuery.removeEventListener("change", firstHandler);
266
+ secoundMediaQuery.removeEventListener("change", secoundHandler);
267
+ };
268
+ }, []);
269
+ useEffect2(() => {
270
+ if (!isClient) return;
271
+ const processElement = (element) => {
272
+ var _a, _b, _c, _d, _e;
273
+ const name = element.getAttribute("class");
274
+ if (!name) return;
275
+ const icon = _.split(_.replace(name, /fa-/g, ""), " ");
276
+ if (!icon.length) return;
277
+ let svg = (_d = (_c = (_a = assets_default[icon[0]]) == null ? void 0 : _a[icon[1]]) != null ? _c : (_b = assets_default["solid"]) == null ? void 0 : _b[icon[0]]) != null ? _d : "";
278
+ if (!svg) return;
279
+ svg = svg.replace(/fill=".*?"/g, 'fill="currentColor"');
280
+ const styles = window.getComputedStyle(element);
281
+ const size = Number((_e = _.split(styles.fontSize, "px")) == null ? void 0 : _e[0]) + 2;
282
+ element.style.width = `${size}px`;
283
+ element.style.height = `${size}px`;
284
+ element.textContent = "";
285
+ element.innerHTML = svg;
286
+ };
287
+ document.querySelectorAll("i").forEach((el) => processElement(el));
288
+ const observer = new MutationObserver((mutations) => {
289
+ mutations.forEach((mutation) => {
290
+ mutation.addedNodes.forEach((node) => {
291
+ if (node.nodeType === 1) {
292
+ const el = node;
293
+ if (el.tagName.toLowerCase() === "i") processElement(el);
294
+ el.querySelectorAll("i").forEach((child) => processElement(child));
295
+ }
296
+ });
297
+ });
298
+ });
299
+ observer.observe(document.body, {
300
+ childList: true,
301
+ subtree: true
302
+ });
303
+ return () => observer.disconnect();
304
+ }, [isClient, matches]);
305
+ return /* @__PURE__ */ jsx2(IconContext.Provider, { value: {}, children });
306
+ };
307
+ var useIcon = () => useContext2(IconContext);
308
+
309
+ // contexts/tooltip/index.tsx
310
+ import { createContext as createContext3, useContext as useContext3, useEffect as useEffect3, useState as useState3 } from "react";
311
+
312
+ // contexts/tooltip/styles.tsx
313
+ import styled2 from "styled-components";
314
+ var Tooltip = styled2.div`
315
+ position: fixed;
316
+ background: ${({ theme }) => theme.tooltip};
317
+ color: ${({ theme }) => theme.t6};
318
+ font-size: .8rem;
319
+ font-weight: 500;
320
+ text-align: center;
321
+ padding: .3rem .8rem;
322
+ border-radius: 5px;
323
+ transform: translateX(-50%);
324
+ z-index: 10;
325
+ border: 1px solid ${({ theme }) => theme.t05};
326
+
327
+ &::before {
328
+ content: "";
329
+ position: absolute;
330
+ bottom: -9px;
331
+ left: 50%;
332
+ transform: translateX(-50%);
333
+ width: 0;
334
+ height: 0;
335
+ border-left: 8px solid transparent;
336
+ border-right: 8px solid transparent;
337
+ border-top: 8px solid ${({ theme }) => theme.t05};
338
+ }
339
+
340
+ &::after {
341
+ content: "";
342
+ position: absolute;
343
+ bottom: -8px;
344
+ left: 50%;
345
+ transform: translateX(-50%);
346
+ width: 0;
347
+ height: 0;
348
+ border-left: 8px solid transparent;
349
+ border-right: 8px solid transparent;
350
+ border-top: 8px solid ${({ theme }) => theme.tooltip};
351
+ }
352
+ `;
353
+
354
+ // contexts/tooltip/index.tsx
355
+ import _2 from "lodash";
356
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
357
+ var TooltipContext = createContext3({});
358
+ var TooltipProviderContainer = ({ children }) => {
359
+ const [tooltips, setTooltips] = useState3([]);
360
+ const getContent = (target) => {
361
+ var _a;
362
+ const rect = target.getBoundingClientRect();
363
+ return {
364
+ top: rect.top + window.scrollY - (target.offsetHeight + 8),
365
+ left: rect.left + window.scrollX + target.offsetWidth / 2,
366
+ content: ((_a = target.dataset) == null ? void 0 : _a.tooltip) || ""
367
+ };
368
+ };
369
+ useEffect3(() => {
370
+ const processElement = (element) => {
371
+ element.addEventListener("mouseenter", (event) => {
372
+ const target = event == null ? void 0 : event.target;
373
+ if (!target) return;
374
+ setTooltips(_2.concat(tooltips, [getContent(target)]));
375
+ });
376
+ element.addEventListener("mouseleave", (event) => {
377
+ const target = event == null ? void 0 : event.target;
378
+ if (!target) return;
379
+ setTooltips(_2.filter(tooltips, (data) => JSON.stringify(data) === JSON.stringify(getContent(target))));
380
+ });
381
+ };
382
+ document.querySelectorAll("[data-tooltip]").forEach((el) => processElement(el));
383
+ const observer = new MutationObserver((mutations) => {
384
+ mutations.forEach((mutation) => {
385
+ mutation.addedNodes.forEach((node) => {
386
+ if (node.nodeType === 1) {
387
+ const el = node;
388
+ if (el.getAttribute("data-tooltip")) processElement(el);
389
+ el.querySelectorAll("[data-tooltip]").forEach((child) => processElement(child));
390
+ }
391
+ });
392
+ });
393
+ });
394
+ observer.observe(document.body, {
395
+ childList: true,
396
+ subtree: true
397
+ });
398
+ return () => observer.disconnect();
399
+ }, []);
400
+ return /* @__PURE__ */ jsxs2(TooltipContext.Provider, { value: {}, children: [
401
+ _2.map(
402
+ tooltips,
403
+ (data, index) => /* @__PURE__ */ jsx3(
404
+ Tooltip,
405
+ {
406
+ style: {
407
+ top: data.top,
408
+ left: data.left
409
+ },
410
+ children: data.content
411
+ },
412
+ index
413
+ )
414
+ ),
415
+ children
416
+ ] });
417
+ };
418
+ var useTooltip = () => useContext3(TooltipContext);
419
+
420
+ // contexts/modal/index.tsx
421
+ import { createContext as createContext4, useContext as useContext4, useEffect as useEffect4, useState as useState4 } from "react";
422
+ import { usePathname } from "next/navigation";
423
+
424
+ // contexts/modal/styles.tsx
425
+ import styled3 from "styled-components";
426
+ var Container = styled3.div`
427
+
428
+ `;
429
+
430
+ // contexts/modal/index.tsx
431
+ import _3 from "lodash";
432
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
433
+ var ModalContext = createContext4({});
434
+ var memory = [];
435
+ var ModalProviderContainer = ({ children }) => {
436
+ const pathname = usePathname();
437
+ const [modals, setModals] = useState4([]);
438
+ useEffect4(() => {
439
+ setModals(_3.filter(memory, (modal) => modal.type === "fixed"));
440
+ }, [pathname]);
441
+ const add = (modal) => {
442
+ if (_3.some(memory, (data) => data.name === modal.name)) return;
443
+ memory.push(modal);
444
+ setModals(memory);
445
+ };
446
+ const remove = (modalName) => {
447
+ const index = _3.findIndex(memory, (data) => data.name === modalName);
448
+ memory.slice(index, 1);
449
+ setModals(memory);
450
+ };
451
+ const setProps = (modalName, props) => {
452
+ const index = _3.findIndex(modals, (modal) => modal.name === modalName);
453
+ const content = _3.find(modals, (modal) => modal.name === modalName);
454
+ if (!content) return;
455
+ let settedModals = [...modals];
456
+ settedModals.splice(index, 1, { ...content, props: { ...content.props, ...props } });
457
+ setModals(settedModals);
458
+ };
459
+ return /* @__PURE__ */ jsxs3(
460
+ ModalContext.Provider,
461
+ {
462
+ value: {
463
+ value: modals,
464
+ add,
465
+ remove,
466
+ setProps
467
+ },
468
+ children: [
469
+ /* @__PURE__ */ jsx4(Container, { children: _3.map(modals, (modal, index) => {
470
+ const ModalComponent = modal.component;
471
+ return /* @__PURE__ */ jsx4(ModalComponent, { ...modal.props }, index);
472
+ }) }),
473
+ children
474
+ ]
475
+ }
476
+ );
477
+ };
478
+ var useModal = () => useContext4(ModalContext);
479
+ export {
480
+ IconProviderContainer as IconProvider,
481
+ ModalProviderContainer as ModalProvider,
482
+ ThemeProviderContainer as ThemeProvider,
483
+ TooltipProviderContainer as TooltipProvider,
484
+ useIcon,
485
+ useModal,
486
+ useTheme,
487
+ useTooltip
488
+ };