@m4l/graphics 6.0.2-alpha.2 → 6.0.3

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.
Files changed (36) hide show
  1. package/components/GlobalStyles/index.d.ts +7 -0
  2. package/contexts/FormatterContext/index.d.ts +4 -7
  3. package/contexts/FormatterContext/types.d.ts +5 -2
  4. package/contexts/HostThemeContext/index.d.ts +7 -0
  5. package/contexts/HostThemeContext/index.js +22 -21
  6. package/contexts/HostThemeContext/types.d.ts +11 -3
  7. package/contexts/LocalesContext/helper.d.ts +21 -0
  8. package/contexts/LocalesContext/index.d.ts +7 -0
  9. package/contexts/ResponsiveContainerContext/index.d.ts +7 -0
  10. package/contexts/ResponsiveContainerContext/store.d.ts +7 -0
  11. package/contexts/ResponsiveContainerContext/store.js +7 -0
  12. package/contexts/ThemeSettingsContext/ThemeSettingsContext.d.ts +8 -1
  13. package/contexts/ThemeSettingsContext/ThemeSettingsContext.js +24 -24
  14. package/contexts/ThemeSettingsContext/constants.d.ts +2 -2
  15. package/contexts/ThemeSettingsContext/constants.js +2 -3
  16. package/contexts/ThemeSettingsContext/index.d.ts +1 -1
  17. package/contexts/ThemeSettingsContext/store.d.ts +7 -0
  18. package/contexts/ThemeSettingsContext/store.js +125 -66
  19. package/contexts/ThemeSettingsContext/types.d.ts +43 -22
  20. package/hooks/useFirstRender/index.d.ts +7 -0
  21. package/hooks/useFormatter/index.d.ts +7 -0
  22. package/hooks/useHostTheme/index.d.ts +7 -0
  23. package/hooks/useIsMobile/index.d.ts +8 -1
  24. package/hooks/useIsMobile/index.js +11 -9
  25. package/hooks/useIsMountedRef/index.d.ts +7 -0
  26. package/hooks/useLocales/index.d.ts +7 -0
  27. package/hooks/useOffSetTop.d.ts +7 -0
  28. package/hooks/useResizeObserver/index.d.ts +7 -0
  29. package/hooks/useResponsive/index.d.ts +7 -0
  30. package/hooks/useResponsiveContainer/index.d.ts +7 -0
  31. package/hooks/useThemSettingsStore/index.d.ts +7 -0
  32. package/index.js +8 -8
  33. package/package.json +11 -6
  34. package/utils/anchorEl.d.ts +7 -0
  35. package/utils/strings.d.ts +1 -1
  36. package/utils/strings.js +1 -1
@@ -1 +1,8 @@
1
+ /**
2
+ * Estilos globales
3
+ * @author Juan Escobar - automatic
4
+ * @createdAt 2024-10-06 20:07:17 - automatic
5
+ * @updatedAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedUser Juan Escobar - automatic
7
+ */
1
8
  export declare function GlobalStyles(): import("react").JSX.Element;
@@ -1,15 +1,12 @@
1
1
  import { FormatterProviderProps, Formatters } from './types';
2
2
  declare const FormatterContext: import('react').Context<Formatters | null>;
3
3
  /**
4
- * @function
5
4
  * Componente encargado de proveer un contexto que permita saber los diferentes forrmatos,
6
5
  * Segunda linea
7
- * @param props Objeto de propiedades
8
- * @version 1.0.0
9
- * @author Juan Andrés Escobar
10
- * @date 2023-02-11
11
- * @beta
12
- * @link
6
+ * @author Juan Escobar - automatic
7
+ * @createdAt 2024-10-06 20:07:18 - automatic
8
+ * @updatedAt 2024-10-06 20:07:18 - automatic
9
+ * @updatedUser Juan Escobar - automatic
13
10
  */
14
11
  declare function FormatterProvider(props: FormatterProviderProps): import("react").JSX.Element;
15
12
  export { FormatterProvider, FormatterContext };
@@ -9,7 +9,11 @@ export interface NumberFormatter {
9
9
  thousandsSymbol: string;
10
10
  }
11
11
  /**
12
- * @author
12
+ * Formateador de fechas
13
+ * @author Juan Escobar - automatic
14
+ * @createdAt 2024-10-06 20:07:18 - automatic
15
+ * @updatedAt 2024-10-06 20:07:18 - automatic
16
+ * @updatedUser Juan Escobar - automatic
13
17
  */
14
18
  export interface DateFormatter {
15
19
  dateFormat: string;
@@ -46,7 +50,6 @@ export interface OptionalFormatters {
46
50
  numberFormatter?: NumberFormatter;
47
51
  }
48
52
  /**
49
- * @interface
50
53
  */
51
54
  export interface FormatterProviderProps extends OptionalFormatters {
52
55
  isMicroFrontEnd: boolean;
@@ -1,4 +1,11 @@
1
1
  import { HostThemeProviderProps } from './types';
2
2
  declare const HostThemeContext: import('react').Context<import('./types').HostThemeType | null>;
3
+ /**
4
+ * Host theme provider
5
+ * @author Juan Escobar - automatic
6
+ * @createdAt 2024-10-06 20:07:18 - automatic
7
+ * @updatedAt 2024-10-08 13:22:53 - automatic
8
+ * @updatedUser Juan Escobar - automatic
9
+ */
3
10
  declare function HostThemeProvider(props: HostThemeProviderProps): import("react").JSX.Element;
4
11
  export { HostThemeProvider, HostThemeContext };
@@ -1,15 +1,15 @@
1
- import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
- import { createContext as h, useMemo as d } from "react";
3
- import { CssBaseline as p } from "@mui/material";
1
+ import { jsxs as l, jsx as o } from "react/jsx-runtime";
2
+ import { createContext as h, useMemo as p } from "react";
3
+ import { CssBaseline as f } from "@mui/material";
4
4
  import { deepmerge as t } from "@mui/utils";
5
- import { G as f } from "../../components/GlobalStyles/index.js";
6
- import { createTheme as u, experimental_extendTheme as x, Experimental_CssVarsProvider as T, StyledEngineProvider as v } from "@mui/material/styles";
7
- const C = h(null);
8
- function y(l) {
9
- const { children: c, hostThemeOptions: n, fnComponentsOverrides: s, isMobile: m } = l, a = d(() => {
5
+ import { G as u } from "../../components/GlobalStyles/index.js";
6
+ import { experimental_extendTheme as x, Experimental_CssVarsProvider as v, StyledEngineProvider as C } from "@mui/material/styles";
7
+ import { u as S } from "../../hooks/useIsMobile/index.js";
8
+ const T = h(null);
9
+ function E(c) {
10
+ const { children: a, hostThemeOptions: s, fnComponentsOverrides: n, isMobileForced: i } = c, m = S(i), d = p(() => {
10
11
  const e = {
11
- ...u(),
12
- ...n
12
+ ...s
13
13
  }, r = x({
14
14
  cssVarPrefix: "m4l",
15
15
  colorSchemes: {
@@ -21,26 +21,27 @@ function y(l) {
21
21
  isMobile: m
22
22
  }
23
23
  });
24
- return r.components = s(r), r;
24
+ return r.components = n(r), r;
25
25
  }, [m]);
26
- return /* @__PURE__ */ i(T, { theme: a, children: [
27
- /* @__PURE__ */ o(f, {}),
26
+ return /* @__PURE__ */ l(v, { theme: d, children: [
27
+ /* @__PURE__ */ o(u, {}),
28
28
  /* @__PURE__ */ o(
29
- C.Provider,
29
+ T.Provider,
30
30
  {
31
31
  value: {
32
- hostThemeOptions: n,
33
- fnComponentsOverrides: s
32
+ hostThemeOptions: s,
33
+ fnComponentsOverrides: n,
34
+ isMobileForced: i
34
35
  },
35
- children: /* @__PURE__ */ i(v, { injectFirst: !0, children: [
36
- /* @__PURE__ */ o(p, { enableColorScheme: !0 }),
37
- c
36
+ children: /* @__PURE__ */ l(C, { injectFirst: !0, children: [
37
+ /* @__PURE__ */ o(f, { enableColorScheme: !0 }),
38
+ a
38
39
  ] })
39
40
  }
40
41
  )
41
42
  ] });
42
43
  }
43
44
  export {
44
- C as H,
45
- y as a
45
+ T as H,
46
+ E as a
46
47
  };
@@ -1,14 +1,22 @@
1
- import { OurTheme } from '@m4l/styles';
2
1
  import { Theme, CssVarsTheme } from '@mui/material/styles';
3
2
  import { ReactNode } from 'react';
4
3
  export type EventFunListener = (...args: any[]) => void;
5
4
  export interface HostThemeType {
6
- hostThemeOptions: OurTheme;
5
+ /**
6
+ * "dataTestId" es una variable que se encarga de asignar un id a un componente
7
+ * @createdAt 2024-10-08 18:52:29 - automatic
8
+ */
9
+ dataTestId?: string;
10
+ /**
11
+ * "isMobileForced" es una variable que se encarga de forzar el modo mobile en la plataforma
12
+ * @createdAt 2024-10-08 13:22:53 - automatic
13
+ */
14
+ isMobileForced?: boolean | undefined;
15
+ hostThemeOptions: Theme;
7
16
  fnComponentsOverrides: (theme: Omit<Theme, 'palette' | 'applyStyles'> & CssVarsTheme) => any;
8
17
  }
9
18
  export interface HostThemeProviderProps extends HostThemeType {
10
19
  isMicroFrontEnd: boolean;
11
20
  children: ReactNode;
12
- isMobile: boolean;
13
21
  }
14
22
  export type HostThemeContextType = HostThemeType;
@@ -1,4 +1,25 @@
1
1
  import { BaseLocale, LocaleType, NetworkLocaleType } from './types';
2
+ /**
3
+ * Obtiene el locale de la red
4
+ * @author Juan Escobar - automatic
5
+ * @createdAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedAt 2024-10-06 20:07:18 - automatic
7
+ * @updatedUser Juan Escobar - automatic
8
+ */
2
9
  export declare function getLocaleFromNetwork(locale: NetworkLocaleType, host_static_assets: string, environment_assets: string): Promise<LocaleType>;
10
+ /**
11
+ * Une los elementos de un locale
12
+ * @author Juan Escobar - automatic
13
+ * @createdAt 2024-10-06 20:07:18 - automatic
14
+ * @updatedAt 2024-10-06 20:07:18 - automatic
15
+ * @updatedUser Juan Escobar - automatic
16
+ */
3
17
  export declare function joinLocale(baseLocale: BaseLocale): string;
18
+ /**
19
+ * Divide un locale en sus partes
20
+ * @author Juan Escobar - automatic
21
+ * @createdAt 2024-10-06 20:07:18 - automatic
22
+ * @updatedAt 2024-10-06 20:07:18 - automatic
23
+ * @updatedUser Juan Escobar - automatic
24
+ */
4
25
  export declare function splitLocale(locale: string): BaseLocale;
@@ -1,4 +1,11 @@
1
1
  import { LocalesProviderProps, LocalesContextProps } from './types';
2
2
  declare const LocalesContext: import('react').Context<LocalesContextProps | null>;
3
+ /**
4
+ * Proveedor de locales
5
+ * @author Juan Escobar - automatic
6
+ * @createdAt 2024-10-06 20:07:18 - automatic
7
+ * @updatedAt 2024-10-06 20:07:18 - automatic
8
+ * @updatedUser Juan Escobar - automatic
9
+ */
3
10
  declare function LocalesProvider(props: LocalesProviderProps): import("react").JSX.Element | null;
4
11
  export { LocalesProvider, LocalesContext };
@@ -8,5 +8,12 @@ declare const ResponsiveContainerContext: import('react').Context<(Omit<Omit<imp
8
8
  type: unknown;
9
9
  } | undefined): void;
10
10
  }) | null>;
11
+ /**
12
+ * Proveedor de contenedor responsivo
13
+ * @author Juan Escobar - automatic
14
+ * @createdAt 2024-10-06 20:07:18 - automatic
15
+ * @updatedAt 2024-10-08 13:22:54 - automatic
16
+ * @updatedUser Juan Escobar - automatic
17
+ */
11
18
  declare const ResponsiveContainerProvider: (props: ResponsiveContainerProviderProps) => import("react").JSX.Element;
12
19
  export { ResponsiveContainerProvider, ResponsiveContainerContext };
@@ -1,4 +1,11 @@
1
1
  import { InitialResponsiveContainerProps, ResponsiveContainerStateWithActions } from './types';
2
+ /**
3
+ * Crea la tienda de contenedor responsivo
4
+ * @author Juan Escobar - automatic
5
+ * @createdAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedAt 2024-10-06 20:07:18 - automatic
7
+ * @updatedUser Juan Escobar - automatic
8
+ */
2
9
  export declare const createResponsiveContainerStore: (initProps: InitialResponsiveContainerProps) => Omit<Omit<import('zustand').StoreApi<ResponsiveContainerStateWithActions>, "setState"> & {
3
10
  setState<A extends string | {
4
11
  type: unknown;
@@ -10,6 +10,13 @@ const S = (r) => {
10
10
  n((t, p) => ({
11
11
  ...s,
12
12
  responsiveContainerActions: {
13
+ /**
14
+ * Establece el punto de interrupción
15
+ * @author Juan Escobar - automatic
16
+ * @createdAt 2024-10-06 20:07:18 - automatic
17
+ * @updatedAt 2024-10-06 20:07:18 - automatic
18
+ * @updatedUser Juan Escobar - automatic
19
+ */
13
20
  setBreakpoint: (e) => {
14
21
  t((o) => {
15
22
  o.breakPoint = e, o.isUpSm = e !== "xs" && e !== "sm", o.isXs = e === "xs";
@@ -8,5 +8,12 @@ declare const ThemeSettingsContext: import('react').Context<(Omit<Omit<import('z
8
8
  type: unknown;
9
9
  } | undefined): void;
10
10
  }) | null>;
11
- declare function ThemeSettingsProvider({ children, themeSettings }: ThemeSettingsProviderProps): import("react").JSX.Element;
11
+ /**
12
+ * Theme settings provider
13
+ * @author Juan Escobar - automatic
14
+ * @createdAt 2024-10-06 20:07:18 - automatic
15
+ * @updatedAt 2024-10-08 13:22:54 - automatic
16
+ * @updatedUser Juan Escobar - automatic
17
+ */
18
+ declare function ThemeSettingsProvider({ children, themeSettingsForced }: ThemeSettingsProviderProps): import("react").JSX.Element;
12
19
  export { ThemeSettingsProvider, ThemeSettingsContext };
@@ -1,32 +1,32 @@
1
1
  import { jsx as m } from "react/jsx-runtime";
2
- import { createContext as c, useRef as a, useEffect as u } from "react";
3
- import { useNetwork as f, useLocalStorageWithListener as g } from "@m4l/core";
4
- import { OUR_THEME as p, presetsOptions as S } from "@m4l/styles";
2
+ import { createContext as a, useRef as c } from "react";
3
+ import { useLocalStorageWithListener as p } from "@m4l/core";
4
+ import { getUserThemeOptions as f, presetsOptionsMainColor as g } from "@m4l/styles";
5
5
  import { c as h } from "./store.js";
6
- import { d as l } from "./constants.js";
7
- import { u as T } from "../../hooks/useIsMobile/index.js";
8
- const d = c(null);
9
- function b({ children: o, themeSettings: t }) {
10
- const { networkOperation: s } = f(), r = T(), [n, i] = g(
6
+ import { d as r } from "./constants.js";
7
+ const l = a(null);
8
+ function x({ children: s, themeSettingsForced: t }) {
9
+ const [n, i] = p(
11
10
  "theme_setting",
12
- {}
13
- ), e = a();
11
+ r
12
+ ), o = {
13
+ ...r,
14
+ //Por si hay algo en el local storage incopatible con el default
15
+ ...n,
16
+ ...t || {}
17
+ //Si es forzado, se sobreescribe y por eso es el último
18
+ }, e = c();
14
19
  return e.current || (e.current = h({
15
- networkOperation: s,
16
- currentThemeSettings: {
17
- ...l,
18
- ...t,
19
- ...n
20
- },
21
- themeOptions: p,
22
- colorOption: S,
20
+ themeUserSettings: o,
21
+ themeOptions: f(o.themeMode, o.themeColor),
22
+ presetsOptionsColorMain: g,
23
+ //Para visibilidad de los colores en el radiogroup de SettingsLayout
23
24
  open: !1,
24
- setterThemeSettings: t ? void 0 : i
25
- }), e.current.getState().settingsActions.init()), u(() => {
26
- e.current?.getState().settingsActions.setThemeSettings({ isMobile: r });
27
- }, [r]), /* @__PURE__ */ m(d.Provider, { value: e.current, children: o });
25
+ themeSettingsPersistFn: t ? void 0 : i
26
+ // Solo se instancia cuando esta en host, cuando esta storybook no se instancia, evitando guardar en localStorage
27
+ }), e.current.getState().settingsActions.init()), /* @__PURE__ */ m(l.Provider, { value: e.current, children: s });
28
28
  }
29
29
  export {
30
- d as T,
31
- b as a
30
+ l as T,
31
+ x as a
32
32
  };
@@ -1,2 +1,2 @@
1
- import { ThemeSettingsType } from './types';
2
- export declare const defaultThemeSettings: ThemeSettingsType;
1
+ import { ThemeUserSettings } from './types';
2
+ export declare const defaultThemeSettings: ThemeUserSettings;
@@ -1,10 +1,9 @@
1
1
  const e = {
2
2
  themeMode: "light",
3
3
  themeDirection: "ltr",
4
- themeColorPresets: "patronus",
4
+ themeColor: "patronus",
5
5
  themeLayout: "horizontal",
6
- themeStretch: !1,
7
- isMobile: !1
6
+ themeStretch: !1
8
7
  };
9
8
  export {
10
9
  e as d
@@ -1,3 +1,3 @@
1
1
  export * from './ThemeSettingsContext';
2
- export type { ThemeSettingsType, ThemeMode } from './types';
2
+ export type { ThemeUserSettings as ThemeSettingsType, ThemeUserMode as ThemeMode } from './types';
3
3
  export { defaultThemeSettings } from './constants';
@@ -1,5 +1,12 @@
1
1
  import { InitialThemeSettingsStoreProps, ThemeSettingsStateWithActions } from './types';
2
2
  import { WritableDraft } from 'immer/dist/internal';
3
+ /**
4
+ * Crea la tienda de configuración del tema
5
+ * @author Juan Escobar - automatic
6
+ * @createdAt 2024-10-06 20:07:18 - automatic
7
+ * @updatedAt 2024-10-08 13:22:54 - automatic
8
+ * @updatedUser Juan Escobar - automatic
9
+ */
3
10
  export declare const createThemeSettingsStore: (initialState: InitialThemeSettingsStoreProps) => Omit<Omit<import('zustand').StoreApi<ThemeSettingsStateWithActions>, "setState"> & {
4
11
  setState<A extends string | {
5
12
  type: unknown;
@@ -1,111 +1,170 @@
1
- import { createStore as l } from "zustand";
2
- import { devtools as u } from "zustand/middleware";
3
- import { immer as S } from "zustand/middleware/immer";
4
- import { getPaletteByPreset as p, typography as T, shadows as h, getColorPresets as a, createCustomShadows as d } from "@m4l/styles";
5
- import { alpha as f } from "@mui/system";
6
- import { d as c } from "./constants.js";
7
- function g(n, r = "m4l") {
1
+ import { createStore as c } from "zustand";
2
+ import { devtools as l } from "zustand/middleware";
3
+ import { immer as p } from "zustand/middleware/immer";
4
+ import { getPaletteByPreset as a, typography as u, shadows as h, getColorPresets as d, createCustomShadows as f } from "@m4l/styles";
5
+ import { alpha as U } from "@mui/system";
6
+ import { d as s } from "./constants.js";
7
+ function g(r, o = "m4l") {
8
8
  const m = document.querySelector('[data-mui-color-scheme="light"]');
9
- if (!m) {
10
- console.error('Element with data-mui-color-scheme="light" not found.');
11
- return;
12
- }
13
- Object.keys(n).forEach((t) => {
14
- const e = n[t];
9
+ m && Object.keys(r).forEach((t) => {
10
+ const e = r[t];
15
11
  if (typeof e == "string" || typeof e == "number") {
16
- const s = `--${r}-${t}`;
17
- m.style.setProperty(s, e.toString());
18
- } else typeof e == "object" && e !== null && g(e, `${r}-${t}`);
12
+ const S = `--${o}-${t}`;
13
+ m.style.setProperty(S, e.toString());
14
+ } else typeof e == "object" && e !== null && g(e, `${o}-${t}`);
19
15
  });
20
16
  }
21
- const o = (n) => {
22
- const r = n.currentThemeSettings || c, m = r.themeMode === "light", t = p(r.themeColorPresets), e = m ? t.light : t.dark;
23
- n.themeOptions = {
24
- ...n.themeOptions,
25
- typography: T,
17
+ const n = (r) => {
18
+ const o = r.themeUserSettings || s, m = o.themeMode === "light", t = a(o.themeColor), e = m ? t.light : t.dark;
19
+ r.themeOptions = {
20
+ ...r.themeOptions,
21
+ typography: u,
26
22
  palette: {
27
- ...n.themeOptions?.palette ?? {},
23
+ ...r.themeOptions?.palette ?? {},
28
24
  ...e
29
25
  },
30
26
  shape: { borderRadius: 8 },
31
- direction: r.themeDirection,
27
+ direction: o.themeDirection,
32
28
  shadows: m ? h.light : h.dark,
33
29
  customShadows: {
34
- primary: `0 8px 16px 0 ${f(
35
- a(r.themeColorPresets)?.main || "#fff",
30
+ primary: `0 8px 16px 0 ${U(
31
+ d(o.themeColor)?.main || "#fff",
36
32
  0.2
37
33
  )}`,
38
- ...d(r.themeMode)
34
+ ...f(o.themeMode)
39
35
  },
40
- stretch: r.themeStretch
41
- }, g(n.themeOptions);
42
- }, i = (n) => {
43
- n.setterThemeSettings && n.setterThemeSettings(n.currentThemeSettings);
44
- }, b = (n) => l(
45
- u(
46
- S((r, m) => ({
47
- ...n,
36
+ stretch: o.themeStretch
37
+ }, g(r.themeOptions);
38
+ }, i = (r) => {
39
+ r.themeSettingsPersistFn && r.themeSettingsPersistFn(r.themeUserSettings);
40
+ }, P = (r) => c(
41
+ l(
42
+ p((o, m) => ({
43
+ ...r,
48
44
  settingsActions: {
45
+ /**
46
+ * Inicializa la tienda de configuración del tema
47
+ * @author Juan Escobar - automatic
48
+ * @createdAt 2024-10-06 20:07:18 - automatic
49
+ * @updatedAt 2024-10-08 13:22:54 - automatic
50
+ * @updatedUser Juan Escobar - automatic
51
+ */
49
52
  init: () => {
50
- r((t) => {
51
- o(t);
53
+ o((t) => {
54
+ n(t);
52
55
  });
53
56
  },
57
+ /**
58
+ * Establece la configuración del tema
59
+ * @author Juan Escobar - automatic
60
+ * @createdAt 2024-10-06 20:07:18 - automatic
61
+ * @updatedAt 2024-10-08 13:22:54 - automatic
62
+ * @updatedUser Juan Escobar - automatic
63
+ */
54
64
  setThemeSettings: (t) => {
55
- r((e) => {
56
- e.currentThemeSettings = { ...e.currentThemeSettings, ...t }, i(e), o(e);
65
+ o((e) => {
66
+ e.themeUserSettings = { ...e.themeUserSettings, ...t }, i(e), n(e);
57
67
  });
58
68
  },
69
+ /**
70
+ * Cambia el modo del tema
71
+ * @author Juan Escobar - automatic
72
+ * @createdAt 2024-10-06 20:07:18 - automatic
73
+ * @updatedAt 2024-10-08 13:22:54 - automatic
74
+ * @updatedUser Juan Escobar - automatic
75
+ */
59
76
  onChangeMode: (t) => {
60
- r((e) => {
61
- e.currentThemeSettings = {
62
- ...e.currentThemeSettings,
77
+ o((e) => {
78
+ e.themeUserSettings = {
79
+ ...e.themeUserSettings,
63
80
  themeMode: t.target.value
64
- }, i(e), o(e);
81
+ }, i(e), n(e);
65
82
  });
66
83
  },
84
+ /**
85
+ * Abre o cierra el panel de configuración del tema
86
+ * @author Juan Escobar - automatic
87
+ * @createdAt 2024-10-06 20:07:18 - automatic
88
+ * @updatedAt 2024-10-08 13:22:54 - automatic
89
+ * @updatedUser Juan Escobar - automatic
90
+ */
67
91
  handleOpen: () => {
68
- r((t) => {
92
+ o((t) => {
69
93
  t.open = !t.open;
70
94
  });
71
95
  },
96
+ /**
97
+ * Cambia la dirección del tema
98
+ * @author Juan Escobar - automatic
99
+ * @createdAt 2024-10-06 20:07:18 - automatic
100
+ * @updatedAt 2024-10-08 13:22:54 - automatic
101
+ * @updatedUser Juan Escobar - automatic
102
+ */
72
103
  onChangeDirection: (t) => {
73
- r((e) => {
74
- e.currentThemeSettings = {
75
- ...e.currentThemeSettings,
104
+ o((e) => {
105
+ e.themeUserSettings = {
106
+ ...e.themeUserSettings,
76
107
  themeDirection: t.target.value
77
- }, i(e), o(e);
108
+ }, i(e), n(e);
78
109
  });
79
110
  },
111
+ /**
112
+ * Cambia el color del tema
113
+ * @author Juan Escobar - automatic
114
+ * @createdAt 2024-10-06 20:07:18 - automatic
115
+ * @updatedAt 2024-10-08 13:22:54 - automatic
116
+ * @updatedUser Juan Escobar - automatic
117
+ */
80
118
  onChangeColor: (t) => {
81
- r((e) => {
82
- e.currentThemeSettings = {
83
- ...e.currentThemeSettings,
84
- themeColorPresets: t.target.value
85
- }, i(e), o(e);
119
+ o((e) => {
120
+ e.themeUserSettings = {
121
+ ...e.themeUserSettings,
122
+ themeColor: t.target.value
123
+ }, i(e), n(e);
86
124
  });
87
125
  },
126
+ /**
127
+ * Cambia el diseño del tema
128
+ * @author Juan Escobar - automatic
129
+ * @createdAt 2024-10-06 20:07:18 - automatic
130
+ * @updatedAt 2024-10-08 13:22:54 - automatic
131
+ * @updatedUser Juan Escobar - automatic
132
+ */
88
133
  onChangeLayout: (t) => {
89
- r((e) => {
90
- e.currentThemeSettings = {
91
- ...e.currentThemeSettings,
134
+ o((e) => {
135
+ e.themeUserSettings = {
136
+ ...e.themeUserSettings,
92
137
  themeLayout: t.target.value
93
- }, i(e), o(e);
138
+ }, i(e), n(e);
94
139
  });
95
140
  },
141
+ /**
142
+ * Cambia el estiramiento del tema
143
+ * @author Juan Escobar - automatic
144
+ * @createdAt 2024-10-06 20:07:18 - automatic
145
+ * @updatedAt 2024-10-08 13:22:54 - automatic
146
+ * @updatedUser Juan Escobar - automatic
147
+ */
96
148
  onToggleStretch: () => {
97
- r((t) => {
98
- t.currentThemeSettings = {
99
- ...t.currentThemeSettings,
100
- themeStretch: !t.currentThemeSettings.themeStretch
101
- }, i(t), o(t);
149
+ o((t) => {
150
+ t.themeUserSettings = {
151
+ ...t.themeUserSettings,
152
+ themeStretch: !t.themeUserSettings.themeStretch
153
+ }, i(t), n(t);
102
154
  });
103
155
  },
156
+ /**
157
+ * Resetea la configuración del tema
158
+ * @author Juan Escobar - automatic
159
+ * @createdAt 2024-10-06 20:07:18 - automatic
160
+ * @updatedAt 2024-10-08 13:22:54 - automatic
161
+ * @updatedUser Juan Escobar - automatic
162
+ */
104
163
  onResetSetting: () => {
105
- r((t) => {
106
- t.currentThemeSettings = {
107
- ...c
108
- }, i(t), o(t);
164
+ o((t) => {
165
+ t.themeUserSettings = {
166
+ ...s
167
+ }, i(t), n(t);
109
168
  });
110
169
  }
111
170
  }
@@ -114,5 +173,5 @@ const o = (n) => {
114
173
  )
115
174
  );
116
175
  export {
117
- b as c
176
+ P as c
118
177
  };
@@ -1,32 +1,50 @@
1
- import { NetworkProps } from '@m4l/core';
2
- import { OurTheme, PresetsOptions, ThemeColorOptionsType } from '@m4l/styles';
3
- import { CssVarsTheme, Theme } from '@mui/material/styles';
1
+ import { PresetsOptionsColorMain, ThemeUserColor } from '@m4l/styles';
2
+ import { Theme } from '@mui/material/styles';
4
3
  import { ReactNode } from 'react';
5
- export type ThemeMode = 'light' | 'dark';
6
- export type ThemeDirection = 'rtl' | 'ltr';
7
- export type ThemeLayout = 'vertical' | 'horizontal';
8
- export type ThemeStretch = boolean;
9
- export type ThemeSettingsType = {
10
- themeMode: ThemeMode;
11
- themeDirection: ThemeDirection;
12
- themeColorPresets: ThemeColorOptionsType;
13
- themeStretch: ThemeStretch;
14
- themeLayout: ThemeLayout;
15
- isMobile: boolean;
4
+ export type ThemeUserMode = 'light' | 'dark';
5
+ export type ThemeUserDirection = 'rtl' | 'ltr';
6
+ export type ThemeUserLayout = 'vertical' | 'horizontal';
7
+ export type ThemeUserStretch = boolean;
8
+ /**
9
+ * "ThemeSettingsType" son las configuraciones que el usuario escoge para ver la plataforma
10
+ * @createdAt 2024-10-08 13:22:53 - automatic
11
+ */
12
+ export type ThemeUserSettings = {
13
+ themeMode: ThemeUserMode;
14
+ themeDirection: ThemeUserDirection;
15
+ themeColor: ThemeUserColor;
16
+ themeStretch: ThemeUserStretch;
17
+ themeLayout: ThemeUserLayout;
16
18
  };
17
19
  export interface ThemeSettingsStore {
18
- networkOperation: (props: NetworkProps) => Promise<any>;
19
- currentThemeSettings: ThemeSettingsType;
20
+ /**
21
+ * Configuraciones seleccionadas por el usuario, modo, dirección, color, estiramiento y layout
22
+ * @createdAt 2024-10-08 13:22:53 - automatic
23
+ */
24
+ themeUserSettings: ThemeUserSettings;
20
25
  /**
21
26
  * Contiene la configuración incial del tema como la paleta, tipografía, sombras, etc. También puede contener el tema convertido a css vars.
27
+ * @createdAt 2024-10-06 20:07:18 - automatic
28
+ */
29
+ themeOptions: Theme;
30
+ /**
31
+ * "presetsOptionsColorMain" es un array de objetos que contiene el nombre y el valor de los colores principales
32
+ * @createdAt 2024-10-08 13:22:53 - automatic
22
33
  */
23
- themeOptions: (Omit<Theme, 'palette' | 'applyStyles'> & CssVarsTheme) | OurTheme;
24
- colorOption: PresetsOptions;
34
+ presetsOptionsColorMain: PresetsOptionsColorMain;
25
35
  /**
26
- * "setterThemeSettings" es una función que se encarga de persistir en local storage los cambios de los settings
36
+ * "themeSettingsPersistFn" es una función que se encarga de persistir en local storage los cambios de los settings
27
37
  * Solo se instancia cuando esta en host, cuando esta storybook no se instancia
38
+ * @author Juan Escobar - automatic
39
+ * @createdAt 2024-10-06 20:07:18 - automatic
40
+ * @updatedAt 2024-10-08 13:26:41 - automatic
41
+ * @updatedUser Juan Escobar - automatic
42
+ */
43
+ themeSettingsPersistFn?: (newValue: ThemeUserSettings) => void;
44
+ /**
45
+ * "open" es una variable que se encarga de abrir o cerrar el formulario
46
+ * @createdAt 2024-10-08 13:22:53 - automatic
28
47
  */
29
- setterThemeSettings?: (newValue: ThemeSettingsType) => void;
30
48
  open: boolean;
31
49
  }
32
50
  export type DefaultThemeSettingsStoreProps = ThemeSettingsStore;
@@ -41,10 +59,13 @@ export interface ThemeSettingsStateWithActions extends ThemeSettingsStore {
41
59
  onChangeColor: (event: React.ChangeEvent<HTMLInputElement>) => void;
42
60
  onChangeLayout: (event: React.ChangeEvent<HTMLInputElement>) => void;
43
61
  handleOpen: () => void;
44
- setThemeSettings: (newValue: Partial<ThemeSettingsType>) => void;
62
+ setThemeSettings: (newValue: Partial<ThemeUserSettings>) => void;
45
63
  };
46
64
  }
47
65
  export type ThemeSettingsProviderProps = {
48
- themeSettings?: ThemeSettingsType;
66
+ /**
67
+ * "themeSettingsForced" es una variable que se encarga de forzar las configuraciones del tema, normalmente en storybook
68
+ */
69
+ themeSettingsForced?: ThemeUserSettings;
49
70
  children: ReactNode;
50
71
  };
@@ -1,2 +1,9 @@
1
1
  import { DependencyList } from 'react';
2
+ /**
3
+ * Hook to use the first render
4
+ * @author Juan Escobar - automatic
5
+ * @createdAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedAt 2024-10-06 20:07:18 - automatic
7
+ * @updatedUser Juan Escobar - automatic
8
+ */
2
9
  export declare function useFirstRender(dependencies?: DependencyList): boolean;
@@ -1 +1,8 @@
1
+ /**
2
+ * Hook to use the formatter context
3
+ * @author Juan Escobar - automatic
4
+ * @createdAt 2024-10-06 20:07:18 - automatic
5
+ * @updatedAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedUser Juan Escobar - automatic
7
+ */
1
8
  export declare const useFormatter: () => import('../..').Formatters;
@@ -1 +1,8 @@
1
+ /**
2
+ * Hook to use the host theme context
3
+ * @author Juan Escobar - automatic
4
+ * @createdAt 2024-10-06 20:07:18 - automatic
5
+ * @updatedAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedUser Juan Escobar - automatic
7
+ */
1
8
  export declare const useHostTheme: () => import('../..').HostThemeType;
@@ -1 +1,8 @@
1
- export declare const useIsMobile: () => boolean;
1
+ /**
2
+ * Hook to check if the device is a mobile device
3
+ * @author Juan Escobar - automatic
4
+ * @createdAt 2024-10-06 20:07:18 - automatic
5
+ * @updatedAt 2024-10-08 13:22:54 - automatic
6
+ * @updatedUser Juan Escobar - automatic
7
+ */
8
+ export declare const useIsMobile: (isMobileForced?: boolean) => boolean;
@@ -1,11 +1,13 @@
1
- import { useState as n, useEffect as o } from "react";
2
- import s from "lodash/throttle";
3
- const i = () => typeof navigator > "u" ? !1 : /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), l = () => {
4
- const [t, r] = n(i());
5
- return o(() => {
6
- const e = s(
1
+ import { useState as o, useEffect as s } from "react";
2
+ import a from "lodash/throttle";
3
+ const i = () => typeof navigator > "u" ? !1 : /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), f = (t) => {
4
+ const [r, n] = o(t || i());
5
+ return s(() => {
6
+ if (t === void 0)
7
+ return;
8
+ const e = a(
7
9
  () => {
8
- r(i());
10
+ n(i());
9
11
  },
10
12
  200,
11
13
  {
@@ -15,8 +17,8 @@ const i = () => typeof navigator > "u" ? !1 : /Android|webOS|iPhone|iPad|iPod|Bl
15
17
  return window.addEventListener("resize", e), e(), () => {
16
18
  window.removeEventListener("resize", e), e.cancel();
17
19
  };
18
- }, []), t;
20
+ }, [t]), r;
19
21
  };
20
22
  export {
21
- l as u
23
+ f as u
22
24
  };
@@ -1 +1,8 @@
1
+ /**
2
+ * Hook to use the is mounted ref
3
+ * @author Juan Escobar - automatic
4
+ * @createdAt 2024-10-06 20:07:18 - automatic
5
+ * @updatedAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedUser Juan Escobar - automatic
7
+ */
1
8
  export declare function useIsMountedRef(): import('react').MutableRefObject<boolean>;
@@ -1 +1,8 @@
1
+ /**
2
+ * Hook to use the locales context
3
+ * @author Juan Escobar - automatic
4
+ * @createdAt 2024-10-06 20:07:18 - automatic
5
+ * @updatedAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedUser Juan Escobar - automatic
7
+ */
1
8
  export declare const useLocales: () => import('../../contexts/LocalesContext/types').LocalesContextProps;
@@ -1 +1,8 @@
1
+ /**
2
+ * Hook to use the offset top
3
+ * @author Juan Escobar - automatic
4
+ * @createdAt 2024-10-06 20:07:18 - automatic
5
+ * @updatedAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedUser Juan Escobar - automatic
7
+ */
1
8
  export declare function useOffSetTop(top: number): boolean;
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Hook to use the resize observer
3
+ * @author Juan Escobar - automatic
4
+ * @createdAt 2024-10-06 20:07:18 - automatic
5
+ * @updatedAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedUser Juan Escobar - automatic
7
+ */
1
8
  export declare function useResizeObserver<T extends HTMLElement>(callback: (target: T, entry: ResizeObserverEntry) => void): import('react').RefObject<T>;
2
9
  export default useResizeObserver;
@@ -1 +1,8 @@
1
+ /**
2
+ * Returns true if the screen size is desktop.
3
+ * @author Juan Escobar - automatic
4
+ * @createdAt 2024-10-06 20:07:18 - automatic
5
+ * @updatedAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedUser Juan Escobar - automatic
7
+ */
1
8
  export declare function useResponsiveDesktop(): boolean | undefined;
@@ -1,2 +1,9 @@
1
1
  import { ResponsiveContainerStateWithActions } from '../../contexts/ResponsiveContainerContext/types';
2
+ /**
3
+ * Hook to use the responsive container store
4
+ * @author Juan Escobar - automatic
5
+ * @createdAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedAt 2024-10-06 20:07:18 - automatic
7
+ * @updatedUser Juan Escobar - automatic
8
+ */
2
9
  export declare function useResponsiveContainerStore<T>(selector: (state: ResponsiveContainerStateWithActions) => T, equalityFn?: (left: T, right: T) => boolean): T;
@@ -1,2 +1,9 @@
1
1
  import { ThemeSettingsStateWithActions } from '../../contexts/ThemeSettingsContext/types';
2
+ /**
3
+ * Hook to use the settings store
4
+ * @author Juan Escobar - automatic
5
+ * @createdAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedAt 2024-10-06 20:07:18 - automatic
7
+ * @updatedUser Juan Escobar - automatic
8
+ */
2
9
  export declare function useThemeSettingsStore<T>(selector: (state: ThemeSettingsStateWithActions) => T, equalityFn?: (left: T, right: T) => boolean): T;
package/index.js CHANGED
@@ -3,10 +3,10 @@ import { g as s } from "./contexts/LocalesContext/helper.js";
3
3
  import { F as m, a as p } from "./contexts/FormatterContext/index.js";
4
4
  import { L as f, a as i } from "./contexts/LocalesContext/index.js";
5
5
  import { R as u, a as l } from "./contexts/ResponsiveContainerContext/index.js";
6
- import { H as v, a as C } from "./contexts/HostThemeContext/index.js";
7
- import { d as g } from "./contexts/ThemeSettingsContext/constants.js";
6
+ import { H as v, a as T } from "./contexts/HostThemeContext/index.js";
7
+ import { d as h } from "./contexts/ThemeSettingsContext/constants.js";
8
8
  import { T as R, a as S } from "./contexts/ThemeSettingsContext/ThemeSettingsContext.js";
9
- import { u as P } from "./hooks/useFirstRender/index.js";
9
+ import { u as F } from "./hooks/useFirstRender/index.js";
10
10
  import { u as L } from "./hooks/useFormatter/index.js";
11
11
  import { u as b } from "./hooks/useIsMountedRef/index.js";
12
12
  import { u as w } from "./hooks/useLocales/index.js";
@@ -17,25 +17,25 @@ import { u as D } from "./hooks/useHostTheme/index.js";
17
17
  import { u as N } from "./hooks/useResizeObserver/index.js";
18
18
  import { u as j } from "./hooks/useResponsive/index.js";
19
19
  import { u as B } from "./hooks/useThemSettingsStore/index.js";
20
- import { C as K } from "./utils/strings.js";
20
+ import { c as K } from "./utils/strings.js";
21
21
  import { g as U } from "./utils/anchorEl.js";
22
22
  export {
23
- K as Capitalize,
24
23
  m as FormatterContext,
25
24
  p as FormatterProvider,
26
25
  r as GlobalStyles,
27
26
  v as HostThemeContext,
28
- C as HostThemeProvider,
27
+ T as HostThemeProvider,
29
28
  f as LocalesContext,
30
29
  i as LocalesProvider,
31
30
  u as ResponsiveContainerContext,
32
31
  l as ResponsiveContainerProvider,
33
32
  R as ThemeSettingsContext,
34
33
  S as ThemeSettingsProvider,
35
- g as defaultThemeSettings,
34
+ K as capitalize,
35
+ h as defaultThemeSettings,
36
36
  U as getAnchorElPositionWindow,
37
37
  s as getLocaleFromNetwork,
38
- P as useFirstRender,
38
+ F as useFirstRender,
39
39
  L as useFormatter,
40
40
  D as useHostTheme,
41
41
  M as useIsMobile,
package/package.json CHANGED
@@ -1,16 +1,24 @@
1
1
  {
2
2
  "name": "@m4l/graphics",
3
- "version": "6.0.2-alpha.2",
3
+ "version": "6.0.3",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team*",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "lint-staged": {
10
+ "**/*.{js,jsx,ts,tsx,json}": [
11
+ "eslint . --fix"
12
+ ]
13
+ },
6
14
  "dependencies": {
7
15
  "date-fns": "^2.30.0",
8
16
  "immer": "^9.0.21",
9
17
  "zustand": "4.3.6"
10
18
  },
11
19
  "peerDependencies": {
12
- "@m4l/core": "^2.0.9-alpha.0",
13
- "@m4l/styles": "^6.4.1",
20
+ "@m4l/core": "^2.0.9",
21
+ "@m4l/styles": "^7.0.0",
14
22
  "@mui/material": "^5.15.19",
15
23
  "@mui/x-date-pickers": "^6.11.1",
16
24
  "@types/react": "^18.0.0",
@@ -70,9 +78,6 @@
70
78
  "type": "module",
71
79
  "types": "./index.d.ts",
72
80
  "sideEffects": false,
73
- "publishConfig": {
74
- "access": "public"
75
- },
76
81
  "engines": {
77
82
  "node": ">=12.0.0"
78
83
  },
@@ -7,6 +7,13 @@ export interface AnchorPosition {
7
7
  top: number;
8
8
  left: number;
9
9
  }
10
+ /**
11
+ * Get the position of the element based on the anchor element
12
+ * @author Juan Escobar - automatic
13
+ * @createdAt 2024-10-06 20:06:37 - automatic
14
+ * @updatedAt 2024-10-06 20:06:38 - automatic
15
+ * @updatedUser Juan Escobar - automatic
16
+ */
10
17
  export declare const getAnchorElPositionWindow: (anchorElement: HTMLElement, newWindowRect: Pick<DOMRect, "width" | "height">, anchorOrigin: AnchorOrigin, transformOrigin: AnchorOrigin, marginThreshold?: number) => {
11
18
  top: number;
12
19
  left: number;
@@ -1 +1 @@
1
- export declare const Capitalize: (s: string) => string;
1
+ export declare const capitalize: (s: string) => string;
package/utils/strings.js CHANGED
@@ -1,4 +1,4 @@
1
1
  const a = (e) => e && e[0].toUpperCase() + e.slice(1) || "";
2
2
  export {
3
- a as C
3
+ a as c
4
4
  };