@gustavo-valsechi/client 1.3.49 → 1.3.50

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.
@@ -35,10 +35,23 @@ module.exports = __toCommonJS(avatar_exports);
35
35
  var import_jsx_runtime = require("react/jsx-runtime");
36
36
  var import_react = require("react");
37
37
  var import_styles = require("./styles");
38
+ var import_server = require("@gustavo-valsechi/server");
39
+ var import_randomcolor = __toESM(require("randomcolor"));
38
40
  var import_lodash = __toESM(require("lodash"));
39
41
  function Avatar(props) {
40
42
  const containerRef = (0, import_react.useRef)({});
41
43
  const [color, setColor] = (0, import_react.useState)("");
44
+ (0, import_react.useEffect)(() => {
45
+ if (color) return;
46
+ (async () => {
47
+ const storageKey = process.env.NEXT_PUBLIC_STORAGE_AVATAR;
48
+ const storageColor = await (0, import_server.getStorage)(storageKey);
49
+ if (storageColor) return setColor(storageColor);
50
+ const random = (0, import_randomcolor.default)({ luminosity: "light" });
51
+ await (0, import_server.setStorage)(storageKey, random);
52
+ setColor(random);
53
+ })();
54
+ }, [color]);
42
55
  const name = () => {
43
56
  const [first, secound] = import_lodash.default.split(props.name, " ") || [];
44
57
  if (first && secound) return `${first} ${secound}`;
@@ -1,11 +1,24 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { useRef, useState } from "react";
3
+ import { useEffect, useRef, useState } from "react";
4
4
  import { Container } from "./styles";
5
+ import { getStorage, setStorage } from "@gustavo-valsechi/server";
6
+ import randomColor from "randomcolor";
5
7
  import _ from "lodash";
6
8
  function Avatar(props) {
7
9
  const containerRef = useRef({});
8
10
  const [color, setColor] = useState("");
11
+ useEffect(() => {
12
+ if (color) return;
13
+ (async () => {
14
+ const storageKey = process.env.NEXT_PUBLIC_STORAGE_AVATAR;
15
+ const storageColor = await getStorage(storageKey);
16
+ if (storageColor) return setColor(storageColor);
17
+ const random = randomColor({ luminosity: "light" });
18
+ await setStorage(storageKey, random);
19
+ setColor(random);
20
+ })();
21
+ }, [color]);
9
22
  const name = () => {
10
23
  const [first, secound] = _.split(props.name, " ") || [];
11
24
  if (first && secound) return `${first} ${secound}`;
@@ -0,0 +1,2 @@
1
+ declare const GlobalStyle: import("react").NamedExoticComponent<any>;
2
+ export default GlobalStyle;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var global_styles_exports = {};
21
+ __export(global_styles_exports, {
22
+ default: () => global_styles_default
23
+ });
24
+ module.exports = __toCommonJS(global_styles_exports);
25
+ var import_styled_components = require("styled-components");
26
+ const GlobalStyle = import_styled_components.createGlobalStyle`
27
+ html, body, input, select, textarea, div, button {
28
+ font-family: "Poppins", sans-serif !important;
29
+ -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
30
+ }
31
+
32
+ html, body {
33
+ padding: 0;
34
+ margin: 0;
35
+ background: ${({ theme }) => theme.primary};
36
+ }
37
+
38
+ a {
39
+ color: inherit;
40
+ text-decoration: none;
41
+ }
42
+
43
+ * {
44
+ box-sizing: border-box;
45
+ }
46
+
47
+ div {
48
+ &::-webkit-scrollbar-track {
49
+ background-color: transparent;
50
+ }
51
+
52
+ &::-webkit-scrollbar {
53
+ width: 6px;
54
+ border-radius: 1rem;
55
+ }
56
+
57
+ &::-webkit-scrollbar-thumb {
58
+ background: rgb(0, 0, 0, 0.08);
59
+ width: 6px;
60
+ border-radius: 1rem;
61
+ }
62
+ }
63
+
64
+ ul {
65
+ list-style: none outside none;
66
+ margin: 0;
67
+ padding: 0;
68
+ }
69
+ `;
70
+ var global_styles_default = GlobalStyle;
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { createGlobalStyle } from "styled-components";
3
+ const GlobalStyle = createGlobalStyle`
4
+ html, body, input, select, textarea, div, button {
5
+ font-family: "Poppins", sans-serif !important;
6
+ -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
7
+ }
8
+
9
+ html, body {
10
+ padding: 0;
11
+ margin: 0;
12
+ background: ${({ theme }) => theme.primary};
13
+ }
14
+
15
+ a {
16
+ color: inherit;
17
+ text-decoration: none;
18
+ }
19
+
20
+ * {
21
+ box-sizing: border-box;
22
+ }
23
+
24
+ div {
25
+ &::-webkit-scrollbar-track {
26
+ background-color: transparent;
27
+ }
28
+
29
+ &::-webkit-scrollbar {
30
+ width: 6px;
31
+ border-radius: 1rem;
32
+ }
33
+
34
+ &::-webkit-scrollbar-thumb {
35
+ background: rgb(0, 0, 0, 0.08);
36
+ width: 6px;
37
+ border-radius: 1rem;
38
+ }
39
+ }
40
+
41
+ ul {
42
+ list-style: none outside none;
43
+ margin: 0;
44
+ padding: 0;
45
+ }
46
+ `;
47
+ var global_styles_default = GlobalStyle;
48
+ export {
49
+ global_styles_default as default
50
+ };
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  "use client";
3
+ var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
6
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
10
  for (var name in all)
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
16
18
  }
17
19
  return to;
18
20
  };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
19
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
30
  var theme_exports = {};
21
31
  __export(theme_exports, {
@@ -28,10 +38,17 @@ var import_react = require("react");
28
38
  var import_styled_components = require("styled-components");
29
39
  var import_styles = require("./styles");
30
40
  var import_content = require("./content");
41
+ var import_server = require("@gustavo-valsechi/server");
42
+ var import_registry = __toESM(require("../../contexts/theme/registry"));
43
+ var import_global = __toESM(require("./global.styles"));
31
44
  const ThemeContext = (0, import_react.createContext)({});
32
45
  const ThemeProviderContainer = (props) => {
33
46
  const [theme, setTheme] = (0, import_react.useState)("light");
34
47
  const [defaultTheme] = (0, import_react.useState)("light");
48
+ (0, import_react.useEffect)(() => {
49
+ if (!theme) return;
50
+ (async () => await (0, import_server.setStorage)(process.env.NEXT_PUBLIC_STORAGE_THEME, theme))();
51
+ }, [theme]);
35
52
  const SwitcherComponent = () => {
36
53
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
37
54
  import_styles.Switcher,
@@ -55,7 +72,10 @@ const ThemeProviderContainer = (props) => {
55
72
  content: import_content.Themes[props.theme || defaultTheme],
56
73
  Switcher: SwitcherComponent
57
74
  },
58
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled_components.ThemeProvider, { theme: import_content.Themes[props.theme || defaultTheme], children: props.children })
75
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_registry.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styled_components.ThemeProvider, { theme: import_content.Themes[props.theme || defaultTheme], children: [
76
+ props.children,
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_global.default, {})
78
+ ] }) })
59
79
  }
60
80
  );
61
81
  };
@@ -1,13 +1,20 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { createContext, useContext, useState } from "react";
3
+ import { createContext, useContext, useEffect, useState } from "react";
4
4
  import { ThemeProvider } from "styled-components";
5
5
  import { Switcher } from "./styles";
6
6
  import { Themes } from "./content";
7
+ import { setStorage } from "@gustavo-valsechi/server";
8
+ import StyledComponentsRegistry from "../../contexts/theme/registry";
9
+ import GlobalStyles from "./global.styles";
7
10
  const ThemeContext = createContext({});
8
11
  const ThemeProviderContainer = (props) => {
9
12
  const [theme, setTheme] = useState("light");
10
13
  const [defaultTheme] = useState("light");
14
+ useEffect(() => {
15
+ if (!theme) return;
16
+ (async () => await setStorage(process.env.NEXT_PUBLIC_STORAGE_THEME, theme))();
17
+ }, [theme]);
11
18
  const SwitcherComponent = () => {
12
19
  return /* @__PURE__ */ jsxs(
13
20
  Switcher,
@@ -31,7 +38,10 @@ const ThemeProviderContainer = (props) => {
31
38
  content: Themes[props.theme || defaultTheme],
32
39
  Switcher: SwitcherComponent
33
40
  },
34
- children: /* @__PURE__ */ jsx(ThemeProvider, { theme: Themes[props.theme || defaultTheme], children: props.children })
41
+ children: /* @__PURE__ */ jsx(StyledComponentsRegistry, { children: /* @__PURE__ */ jsxs(ThemeProvider, { theme: Themes[props.theme || defaultTheme], children: [
42
+ props.children,
43
+ /* @__PURE__ */ jsx(GlobalStyles, {})
44
+ ] }) })
35
45
  }
36
46
  );
37
47
  };
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ export default function StyledComponentsRegistry({ children }: {
3
+ children: React.ReactNode;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var registry_exports = {};
31
+ __export(registry_exports, {
32
+ default: () => StyledComponentsRegistry
33
+ });
34
+ module.exports = __toCommonJS(registry_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_react = require("react");
37
+ var import_navigation = require("next/navigation");
38
+ var import_styled_components = require("styled-components");
39
+ var import_is_prop_valid = __toESM(require("@emotion/is-prop-valid"));
40
+ function StyledComponentsRegistry({ children }) {
41
+ const [styledComponentsStyleSheet] = (0, import_react.useState)(() => new import_styled_components.ServerStyleSheet());
42
+ (0, import_navigation.useServerInsertedHTML)(() => {
43
+ const styles = styledComponentsStyleSheet.getStyleElement();
44
+ styledComponentsStyleSheet.instance.clearTag();
45
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: styles });
46
+ });
47
+ const menager = (sheet) => {
48
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
+ import_styled_components.StyleSheetManager,
50
+ {
51
+ sheet,
52
+ enableVendorPrefixes: true,
53
+ shouldForwardProp: (propName, elementToBeRendered) => {
54
+ return typeof elementToBeRendered === "string" ? (0, import_is_prop_valid.default)(propName) && !["height", "width"].includes(propName) : true;
55
+ },
56
+ children
57
+ }
58
+ );
59
+ };
60
+ if (typeof window !== "undefined") return menager();
61
+ return menager(styledComponentsStyleSheet.instance);
62
+ }
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { Fragment, jsx } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { useServerInsertedHTML } from "next/navigation";
5
+ import { ServerStyleSheet, StyleSheetManager } from "styled-components";
6
+ import isPropValid from "@emotion/is-prop-valid";
7
+ function StyledComponentsRegistry({ children }) {
8
+ const [styledComponentsStyleSheet] = useState(() => new ServerStyleSheet());
9
+ useServerInsertedHTML(() => {
10
+ const styles = styledComponentsStyleSheet.getStyleElement();
11
+ styledComponentsStyleSheet.instance.clearTag();
12
+ return /* @__PURE__ */ jsx(Fragment, { children: styles });
13
+ });
14
+ const menager = (sheet) => {
15
+ return /* @__PURE__ */ jsx(
16
+ StyleSheetManager,
17
+ {
18
+ sheet,
19
+ enableVendorPrefixes: true,
20
+ shouldForwardProp: (propName, elementToBeRendered) => {
21
+ return typeof elementToBeRendered === "string" ? isPropValid(propName) && !["height", "width"].includes(propName) : true;
22
+ },
23
+ children
24
+ }
25
+ );
26
+ };
27
+ if (typeof window !== "undefined") return menager();
28
+ return menager(styledComponentsStyleSheet.instance);
29
+ }
30
+ export {
31
+ StyledComponentsRegistry as default
32
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.3.49",
3
+ "version": "1.3.50",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,6 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@emotion/is-prop-valid": "1.3.0",
27
+ "@gustavo-valsechi/server": "1.0.5",
27
28
  "@hookform/resolvers": "5.2.2",
28
29
  "apexcharts": "3.51.0",
29
30
  "lodash": "4.17.21",
@@ -53,7 +54,7 @@
53
54
  "react-dom": "18.3.1",
54
55
  "rimraf": "6.1.0",
55
56
  "styled-components": "6.1.12",
56
- "tsc-alias": "^1.8.16",
57
+ "tsc-alias": "1.8.16",
57
58
  "typescript": "5.5.4"
58
59
  },
59
60
  "publishConfig": {