@m4l/graphics 6.0.2 → 7.0.0
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.
- package/contexts/HostThemeContext/index.d.ts +1 -1
- package/contexts/HostThemeContext/index.js +22 -21
- package/contexts/HostThemeContext/types.d.ts +11 -3
- package/contexts/ResponsiveContainerContext/index.d.ts +1 -1
- package/contexts/ThemeSettingsContext/ThemeSettingsContext.d.ts +2 -2
- package/contexts/ThemeSettingsContext/ThemeSettingsContext.js +24 -24
- package/contexts/ThemeSettingsContext/constants.d.ts +2 -2
- package/contexts/ThemeSettingsContext/constants.js +2 -3
- package/contexts/ThemeSettingsContext/index.d.ts +1 -1
- package/contexts/ThemeSettingsContext/store.d.ts +1 -1
- package/contexts/ThemeSettingsContext/store.js +71 -75
- package/contexts/ThemeSettingsContext/types.d.ts +39 -30
- package/hooks/useIsMobile/index.d.ts +2 -2
- package/hooks/useIsMobile/index.js +11 -9
- package/index.js +8 -8
- package/package.json +2 -2
- package/utils/strings.d.ts +1 -1
- package/utils/strings.js +1 -1
|
@@ -4,7 +4,7 @@ declare const HostThemeContext: import('react').Context<import('./types').HostTh
|
|
|
4
4
|
* Host theme provider
|
|
5
5
|
* @author Juan Escobar - automatic
|
|
6
6
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
7
|
-
* @updatedAt 2024-10-
|
|
7
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
8
8
|
* @updatedUser Juan Escobar - automatic
|
|
9
9
|
*/
|
|
10
10
|
declare function HostThemeProvider(props: HostThemeProviderProps): import("react").JSX.Element;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createContext as h, useMemo as
|
|
3
|
-
import { CssBaseline as
|
|
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
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
...
|
|
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 =
|
|
24
|
+
return r.components = n(r), r;
|
|
25
25
|
}, [m]);
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
/* @__PURE__ */ o(
|
|
26
|
+
return /* @__PURE__ */ l(v, { theme: d, children: [
|
|
27
|
+
/* @__PURE__ */ o(u, {}),
|
|
28
28
|
/* @__PURE__ */ o(
|
|
29
|
-
|
|
29
|
+
T.Provider,
|
|
30
30
|
{
|
|
31
31
|
value: {
|
|
32
|
-
hostThemeOptions:
|
|
33
|
-
fnComponentsOverrides:
|
|
32
|
+
hostThemeOptions: s,
|
|
33
|
+
fnComponentsOverrides: n,
|
|
34
|
+
isMobileForced: i
|
|
34
35
|
},
|
|
35
|
-
children: /* @__PURE__ */
|
|
36
|
-
/* @__PURE__ */ o(
|
|
37
|
-
|
|
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
|
-
|
|
45
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -12,7 +12,7 @@ declare const ResponsiveContainerContext: import('react').Context<(Omit<Omit<imp
|
|
|
12
12
|
* Proveedor de contenedor responsivo
|
|
13
13
|
* @author Juan Escobar - automatic
|
|
14
14
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
15
|
-
* @updatedAt 2024-10-
|
|
15
|
+
* @updatedAt 2024-10-08 19:03:38 - automatic
|
|
16
16
|
* @updatedUser Juan Escobar - automatic
|
|
17
17
|
*/
|
|
18
18
|
declare const ResponsiveContainerProvider: (props: ResponsiveContainerProviderProps) => import("react").JSX.Element;
|
|
@@ -12,8 +12,8 @@ declare const ThemeSettingsContext: import('react').Context<(Omit<Omit<import('z
|
|
|
12
12
|
* Theme settings provider
|
|
13
13
|
* @author Juan Escobar - automatic
|
|
14
14
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
15
|
-
* @updatedAt 2024-10-
|
|
15
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
16
16
|
* @updatedUser Juan Escobar - automatic
|
|
17
17
|
*/
|
|
18
|
-
declare function ThemeSettingsProvider({ children,
|
|
18
|
+
declare function ThemeSettingsProvider({ children, themeSettingsForced }: ThemeSettingsProviderProps): import("react").JSX.Element;
|
|
19
19
|
export { ThemeSettingsProvider, ThemeSettingsContext };
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
),
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
31
|
-
|
|
30
|
+
l as T,
|
|
31
|
+
x as a
|
|
32
32
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const defaultThemeSettings:
|
|
1
|
+
import { ThemeUserSettings } from './types';
|
|
2
|
+
export declare const defaultThemeSettings: ThemeUserSettings;
|
|
@@ -4,7 +4,7 @@ import { WritableDraft } from 'immer/dist/internal';
|
|
|
4
4
|
* Crea la tienda de configuración del tema
|
|
5
5
|
* @author Juan Escobar - automatic
|
|
6
6
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
7
|
-
* @updatedAt 2024-10-
|
|
7
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
8
8
|
* @updatedUser Juan Escobar - automatic
|
|
9
9
|
*/
|
|
10
10
|
export declare const createThemeSettingsStore: (initialState: InitialThemeSettingsStoreProps) => Omit<Omit<import('zustand').StoreApi<ThemeSettingsStateWithActions>, "setState"> & {
|
|
@@ -1,99 +1,95 @@
|
|
|
1
|
-
import { createStore as
|
|
2
|
-
import { devtools as
|
|
3
|
-
import { immer as
|
|
4
|
-
import { getPaletteByPreset as
|
|
5
|
-
import { alpha as
|
|
6
|
-
import { d as
|
|
7
|
-
function g(
|
|
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
|
-
|
|
10
|
-
|
|
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
|
|
17
|
-
m.style.setProperty(
|
|
18
|
-
} else typeof e == "object" && e !== null && g(e, `${
|
|
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
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
...
|
|
25
|
-
typography:
|
|
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
|
-
...
|
|
23
|
+
...r.themeOptions?.palette ?? {},
|
|
28
24
|
...e
|
|
29
25
|
},
|
|
30
26
|
shape: { borderRadius: 8 },
|
|
31
|
-
direction:
|
|
27
|
+
direction: o.themeDirection,
|
|
32
28
|
shadows: m ? h.light : h.dark,
|
|
33
29
|
customShadows: {
|
|
34
|
-
primary: `0 8px 16px 0 ${
|
|
35
|
-
|
|
30
|
+
primary: `0 8px 16px 0 ${U(
|
|
31
|
+
d(o.themeColor)?.main || "#fff",
|
|
36
32
|
0.2
|
|
37
33
|
)}`,
|
|
38
|
-
...
|
|
34
|
+
...f(o.themeMode)
|
|
39
35
|
},
|
|
40
|
-
stretch:
|
|
41
|
-
}, g(
|
|
42
|
-
}, i = (
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
...
|
|
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: {
|
|
49
45
|
/**
|
|
50
46
|
* Inicializa la tienda de configuración del tema
|
|
51
47
|
* @author Juan Escobar - automatic
|
|
52
48
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
53
|
-
* @updatedAt 2024-10-
|
|
49
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
54
50
|
* @updatedUser Juan Escobar - automatic
|
|
55
51
|
*/
|
|
56
52
|
init: () => {
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
o((t) => {
|
|
54
|
+
n(t);
|
|
59
55
|
});
|
|
60
56
|
},
|
|
61
57
|
/**
|
|
62
58
|
* Establece la configuración del tema
|
|
63
59
|
* @author Juan Escobar - automatic
|
|
64
60
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
65
|
-
* @updatedAt 2024-10-
|
|
61
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
66
62
|
* @updatedUser Juan Escobar - automatic
|
|
67
63
|
*/
|
|
68
64
|
setThemeSettings: (t) => {
|
|
69
|
-
|
|
70
|
-
e.
|
|
65
|
+
o((e) => {
|
|
66
|
+
e.themeUserSettings = { ...e.themeUserSettings, ...t }, i(e), n(e);
|
|
71
67
|
});
|
|
72
68
|
},
|
|
73
69
|
/**
|
|
74
70
|
* Cambia el modo del tema
|
|
75
71
|
* @author Juan Escobar - automatic
|
|
76
72
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
77
|
-
* @updatedAt 2024-10-
|
|
73
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
78
74
|
* @updatedUser Juan Escobar - automatic
|
|
79
75
|
*/
|
|
80
76
|
onChangeMode: (t) => {
|
|
81
|
-
|
|
82
|
-
e.
|
|
83
|
-
...e.
|
|
77
|
+
o((e) => {
|
|
78
|
+
e.themeUserSettings = {
|
|
79
|
+
...e.themeUserSettings,
|
|
84
80
|
themeMode: t.target.value
|
|
85
|
-
}, i(e),
|
|
81
|
+
}, i(e), n(e);
|
|
86
82
|
});
|
|
87
83
|
},
|
|
88
84
|
/**
|
|
89
85
|
* Abre o cierra el panel de configuración del tema
|
|
90
86
|
* @author Juan Escobar - automatic
|
|
91
87
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
92
|
-
* @updatedAt 2024-10-
|
|
88
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
93
89
|
* @updatedUser Juan Escobar - automatic
|
|
94
90
|
*/
|
|
95
91
|
handleOpen: () => {
|
|
96
|
-
|
|
92
|
+
o((t) => {
|
|
97
93
|
t.open = !t.open;
|
|
98
94
|
});
|
|
99
95
|
},
|
|
@@ -101,74 +97,74 @@ const o = (n) => {
|
|
|
101
97
|
* Cambia la dirección del tema
|
|
102
98
|
* @author Juan Escobar - automatic
|
|
103
99
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
104
|
-
* @updatedAt 2024-10-
|
|
100
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
105
101
|
* @updatedUser Juan Escobar - automatic
|
|
106
102
|
*/
|
|
107
103
|
onChangeDirection: (t) => {
|
|
108
|
-
|
|
109
|
-
e.
|
|
110
|
-
...e.
|
|
104
|
+
o((e) => {
|
|
105
|
+
e.themeUserSettings = {
|
|
106
|
+
...e.themeUserSettings,
|
|
111
107
|
themeDirection: t.target.value
|
|
112
|
-
}, i(e),
|
|
108
|
+
}, i(e), n(e);
|
|
113
109
|
});
|
|
114
110
|
},
|
|
115
111
|
/**
|
|
116
112
|
* Cambia el color del tema
|
|
117
113
|
* @author Juan Escobar - automatic
|
|
118
114
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
119
|
-
* @updatedAt 2024-10-
|
|
115
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
120
116
|
* @updatedUser Juan Escobar - automatic
|
|
121
117
|
*/
|
|
122
118
|
onChangeColor: (t) => {
|
|
123
|
-
|
|
124
|
-
e.
|
|
125
|
-
...e.
|
|
126
|
-
|
|
127
|
-
}, i(e),
|
|
119
|
+
o((e) => {
|
|
120
|
+
e.themeUserSettings = {
|
|
121
|
+
...e.themeUserSettings,
|
|
122
|
+
themeColor: t.target.value
|
|
123
|
+
}, i(e), n(e);
|
|
128
124
|
});
|
|
129
125
|
},
|
|
130
126
|
/**
|
|
131
127
|
* Cambia el diseño del tema
|
|
132
128
|
* @author Juan Escobar - automatic
|
|
133
129
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
134
|
-
* @updatedAt 2024-10-
|
|
130
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
135
131
|
* @updatedUser Juan Escobar - automatic
|
|
136
132
|
*/
|
|
137
133
|
onChangeLayout: (t) => {
|
|
138
|
-
|
|
139
|
-
e.
|
|
140
|
-
...e.
|
|
134
|
+
o((e) => {
|
|
135
|
+
e.themeUserSettings = {
|
|
136
|
+
...e.themeUserSettings,
|
|
141
137
|
themeLayout: t.target.value
|
|
142
|
-
}, i(e),
|
|
138
|
+
}, i(e), n(e);
|
|
143
139
|
});
|
|
144
140
|
},
|
|
145
141
|
/**
|
|
146
142
|
* Cambia el estiramiento del tema
|
|
147
143
|
* @author Juan Escobar - automatic
|
|
148
144
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
149
|
-
* @updatedAt 2024-10-
|
|
145
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
150
146
|
* @updatedUser Juan Escobar - automatic
|
|
151
147
|
*/
|
|
152
148
|
onToggleStretch: () => {
|
|
153
|
-
|
|
154
|
-
t.
|
|
155
|
-
...t.
|
|
156
|
-
themeStretch: !t.
|
|
157
|
-
}, i(t),
|
|
149
|
+
o((t) => {
|
|
150
|
+
t.themeUserSettings = {
|
|
151
|
+
...t.themeUserSettings,
|
|
152
|
+
themeStretch: !t.themeUserSettings.themeStretch
|
|
153
|
+
}, i(t), n(t);
|
|
158
154
|
});
|
|
159
155
|
},
|
|
160
156
|
/**
|
|
161
157
|
* Resetea la configuración del tema
|
|
162
158
|
* @author Juan Escobar - automatic
|
|
163
159
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
164
|
-
* @updatedAt 2024-10-
|
|
160
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
165
161
|
* @updatedUser Juan Escobar - automatic
|
|
166
162
|
*/
|
|
167
163
|
onResetSetting: () => {
|
|
168
|
-
|
|
169
|
-
t.
|
|
170
|
-
...
|
|
171
|
-
}, i(t),
|
|
164
|
+
o((t) => {
|
|
165
|
+
t.themeUserSettings = {
|
|
166
|
+
...s
|
|
167
|
+
}, i(t), n(t);
|
|
172
168
|
});
|
|
173
169
|
}
|
|
174
170
|
}
|
|
@@ -177,5 +173,5 @@ const o = (n) => {
|
|
|
177
173
|
)
|
|
178
174
|
);
|
|
179
175
|
export {
|
|
180
|
-
|
|
176
|
+
P as c
|
|
181
177
|
};
|
|
@@ -1,50 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
|
6
|
-
export type
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
19
|
-
|
|
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.
|
|
22
27
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
23
28
|
*/
|
|
24
|
-
themeOptions:
|
|
25
|
-
|
|
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
|
|
33
|
+
*/
|
|
34
|
+
presetsOptionsColorMain: PresetsOptionsColorMain;
|
|
26
35
|
/**
|
|
27
|
-
* "
|
|
36
|
+
* "themeSettingsPersistFn" es una función que se encarga de persistir en local storage los cambios de los settings
|
|
28
37
|
* Solo se instancia cuando esta en host, cuando esta storybook no se instancia
|
|
29
38
|
* @author Juan Escobar - automatic
|
|
30
39
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
31
|
-
* @updatedAt 2024-10-
|
|
40
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
32
41
|
* @updatedUser Juan Escobar - automatic
|
|
33
42
|
*/
|
|
34
|
-
|
|
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
|
|
47
|
+
*/
|
|
35
48
|
open: boolean;
|
|
36
49
|
}
|
|
37
50
|
export type DefaultThemeSettingsStoreProps = ThemeSettingsStore;
|
|
38
51
|
export type InitialThemeSettingsStoreProps = DefaultThemeSettingsStoreProps;
|
|
39
52
|
export interface ThemeSettingsStateWithActions extends ThemeSettingsStore {
|
|
40
53
|
settingsActions: {
|
|
41
|
-
/**
|
|
42
|
-
* Inicializa la tienda de configuración del tema
|
|
43
|
-
* @author Juan Escobar - automatic
|
|
44
|
-
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
45
|
-
* @updatedAt 2024-10-06 20:07:18 - automatic
|
|
46
|
-
* @updatedUser Juan Escobar - automatic
|
|
47
|
-
*/
|
|
48
54
|
init: () => void;
|
|
49
55
|
onToggleStretch: VoidFunction;
|
|
50
56
|
onResetSetting: VoidFunction;
|
|
@@ -53,10 +59,13 @@ export interface ThemeSettingsStateWithActions extends ThemeSettingsStore {
|
|
|
53
59
|
onChangeColor: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
54
60
|
onChangeLayout: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
55
61
|
handleOpen: () => void;
|
|
56
|
-
setThemeSettings: (newValue: Partial<
|
|
62
|
+
setThemeSettings: (newValue: Partial<ThemeUserSettings>) => void;
|
|
57
63
|
};
|
|
58
64
|
}
|
|
59
65
|
export type ThemeSettingsProviderProps = {
|
|
60
|
-
|
|
66
|
+
/**
|
|
67
|
+
* "themeSettingsForced" es una variable que se encarga de forzar las configuraciones del tema, normalmente en storybook
|
|
68
|
+
*/
|
|
69
|
+
themeSettingsForced?: ThemeUserSettings;
|
|
61
70
|
children: ReactNode;
|
|
62
71
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Hook to check if the device is a mobile device
|
|
3
3
|
* @author Juan Escobar - automatic
|
|
4
4
|
* @createdAt 2024-10-06 20:07:18 - automatic
|
|
5
|
-
* @updatedAt 2024-10-
|
|
5
|
+
* @updatedAt 2024-10-08 19:28:36 - automatic
|
|
6
6
|
* @updatedUser Juan Escobar - automatic
|
|
7
7
|
*/
|
|
8
|
-
export declare const useIsMobile: () => boolean;
|
|
8
|
+
export declare const useIsMobile: (isMobileForced?: boolean) => boolean;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import
|
|
3
|
-
const i = () => typeof navigator > "u" ? !1 : /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
|
|
4
|
-
const [
|
|
5
|
-
return
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
}, []),
|
|
20
|
+
}, [t]), r;
|
|
19
21
|
};
|
|
20
22
|
export {
|
|
21
|
-
|
|
23
|
+
f as u
|
|
22
24
|
};
|
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
|
|
7
|
-
import { d as
|
|
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
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
34
|
+
K as capitalize,
|
|
35
|
+
h as defaultThemeSettings,
|
|
36
36
|
U as getAnchorElPositionWindow,
|
|
37
37
|
s as getLocaleFromNetwork,
|
|
38
|
-
|
|
38
|
+
F as useFirstRender,
|
|
39
39
|
L as useFormatter,
|
|
40
40
|
D as useHostTheme,
|
|
41
41
|
M as useIsMobile,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/graphics",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "M4L Team*",
|
|
6
6
|
"publishConfig": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@m4l/core": "^2.0.9",
|
|
21
|
-
"@m4l/styles": "^
|
|
21
|
+
"@m4l/styles": "^7.0.0",
|
|
22
22
|
"@mui/material": "^5.15.19",
|
|
23
23
|
"@mui/x-date-pickers": "^6.11.1",
|
|
24
24
|
"@types/react": "^18.0.0",
|
package/utils/strings.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const capitalize: (s: string) => string;
|
package/utils/strings.js
CHANGED