@m4l/graphics 3.0.3 → 6.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.
@@ -0,0 +1,46 @@
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";
4
+ import { deepmerge as t } from "@mui/utils";
5
+ import { G as f } from "../../components/GlobalStyle/index-C3p7OfnO.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(() => {
10
+ const e = {
11
+ ...u(),
12
+ ...n
13
+ }, r = x({
14
+ cssVarPrefix: "m4l",
15
+ colorSchemes: {
16
+ light: t({}, e),
17
+ finalTheme: t({}, e),
18
+ dark: t({}, e)
19
+ },
20
+ generalSettings: {
21
+ isMobile: m
22
+ }
23
+ });
24
+ return r.components = s(r), r;
25
+ }, [m]);
26
+ return /* @__PURE__ */ i(T, { theme: a, children: [
27
+ /* @__PURE__ */ o(f, {}),
28
+ /* @__PURE__ */ o(
29
+ C.Provider,
30
+ {
31
+ value: {
32
+ hostThemeOptions: n,
33
+ fnComponentsOverrides: s
34
+ },
35
+ children: /* @__PURE__ */ i(v, { injectFirst: !0, children: [
36
+ /* @__PURE__ */ o(p, { enableColorScheme: !0 }),
37
+ c
38
+ ] })
39
+ }
40
+ )
41
+ ] });
42
+ }
43
+ export {
44
+ C as H,
45
+ y as a
46
+ };
@@ -1,8 +1,9 @@
1
+ import { OurTheme } from '@m4l/styles';
1
2
  import type { Theme, CssVarsTheme } from '@mui/material/styles';
2
3
  import type { ReactNode } from 'react';
3
4
  export declare type EventFunListener = (...args: any[]) => void;
4
5
  export interface HostThemeType {
5
- hostThemeOptions: Theme;
6
+ hostThemeOptions: OurTheme;
6
7
  fnComponentsOverrides: (theme: Omit<Theme, 'palette' | 'applyStyles'> & CssVarsTheme) => any;
7
8
  }
8
9
  export interface HostThemeProviderProps extends HostThemeType {
@@ -1,5 +1,5 @@
1
1
  import { NetworkProps } from '@m4l/core';
2
- import { PresetsOptions, ThemeColorPresets } from '@m4l/styles';
2
+ import { OurTheme, PresetsOptions, ThemeColorOptionsType } from '@m4l/styles';
3
3
  import { CssVarsTheme, Theme } from '@mui/material/styles';
4
4
  import { ReactNode } from 'react';
5
5
  export declare type ThemeMode = 'light' | 'dark';
@@ -9,7 +9,7 @@ export declare type ThemeStretch = boolean;
9
9
  export declare type ThemeSettingsType = {
10
10
  themeMode: ThemeMode;
11
11
  themeDirection: ThemeDirection;
12
- themeColorPresets: ThemeColorPresets;
12
+ themeColorPresets: ThemeColorOptionsType;
13
13
  themeStretch: ThemeStretch;
14
14
  themeLayout: ThemeLayout;
15
15
  isMobile: boolean;
@@ -17,7 +17,10 @@ export declare type ThemeSettingsType = {
17
17
  export interface ThemeSettingsStore {
18
18
  networkOperation: (props: NetworkProps) => Promise<any>;
19
19
  currentThemeSettings: ThemeSettingsType;
20
- themeOptions: Omit<Theme, 'palette' | 'applyStyles'> & CssVarsTheme;
20
+ /**
21
+ * 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
+ */
23
+ themeOptions: Omit<Theme, 'palette' | 'applyStyles'> & CssVarsTheme | OurTheme;
21
24
  colorOption: PresetsOptions;
22
25
  /**
23
26
  * "setterThemeSettings" es una función que se encarga de persistir en local storage los cambios de los settings
@@ -1,17 +1,17 @@
1
- import { jsx as S } from "react/jsx-runtime";
2
- import { createContext as f, useRef as T, useMemo as R, useLayoutEffect as k, useEffect as P } from "react";
3
- import { c as C, d as v, i as y, l as O } from "../node_modules-BHhXVwYT.js";
4
- import { useNetwork as x, useLocalStorageWithListener as M } from "@m4l/core";
5
- import { getPaletteByPreset as w, typography as E, shadows as d, getColorPresets as L, createCustomShadows as B, defaultThemeOptions as A, presetsOptions as D } from "@m4l/styles";
6
- import { alpha as z } from "@mui/system";
7
- import { u as $ } from "../hooks/useIsMobile/index-Bro0dV28.js";
8
- const g = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, j = (r) => {
1
+ import { jsx as p } from "react/jsx-runtime";
2
+ import { createContext as f, useRef as d, useMemo as y, useLayoutEffect as b, useEffect as P } from "react";
3
+ import { c as T, d as v, i as C, l as O } from "../node_modules-BHhXVwYT.js";
4
+ import { useNetwork as M, useLocalStorageWithListener as E } from "@m4l/core";
5
+ import { getPaletteByPreset as x, typography as k, shadows as S, getColorPresets as L, createCustomShadows as w, OUR_THEME as A, presetsOptions as B } from "@m4l/styles";
6
+ import { alpha as D } from "@mui/system";
7
+ import { u as z } from "../hooks/useIsMobile/index-Bro0dV28.js";
8
+ const u = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, _ = (r) => {
9
9
  const n = {
10
10
  ...r
11
11
  };
12
- return C(
12
+ return T(
13
13
  v(
14
- y((o, t) => ({
14
+ C((o, t) => ({
15
15
  ...n,
16
16
  responsiveContainerActions: {
17
17
  setBreakpoint: (e) => {
@@ -24,9 +24,9 @@ const g = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, j = (r) => {
24
24
  { name: "Responsive Relative Store" }
25
25
  )
26
26
  );
27
- }, W = f(null), F = (r) => {
28
- const { children: n, observedDivRef: o } = r, t = T();
29
- t.current || (t.current = j({
27
+ }, $ = f(null), V = (r) => {
28
+ const { children: n, observedDivRef: o } = r, t = d();
29
+ t.current || (t.current = _({
30
30
  breakPoint: "md",
31
31
  isUpSm: !1,
32
32
  isXs: !1
@@ -34,38 +34,38 @@ const g = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, j = (r) => {
34
34
  const e = () => {
35
35
  const s = o;
36
36
  if (s instanceof HTMLElement && s.clientWidth) {
37
- const h = Object.keys(
38
- g
37
+ const m = Object.keys(
38
+ u
39
39
  );
40
- for (let a = 0; a < h.length; a++) {
41
- const u = h[a];
42
- if (s.clientWidth <= g[u]) {
43
- t.current?.getState().responsiveContainerActions.setBreakpoint(u);
40
+ for (let h = 0; h < m.length; h++) {
41
+ const a = m[h];
42
+ if (s.clientWidth <= u[a]) {
43
+ t.current?.getState().responsiveContainerActions.setBreakpoint(a);
44
44
  break;
45
- } else a === h.length - 1 && s.clientWidth >= g[u] && t.current?.getState().responsiveContainerActions.setBreakpoint(u);
45
+ } else h === m.length - 1 && s.clientWidth >= u[a] && t.current?.getState().responsiveContainerActions.setBreakpoint(a);
46
46
  }
47
47
  }
48
- }, i = R(
48
+ }, i = y(
49
49
  () => O.throttle(e, 200, {
50
50
  leading: !1,
51
51
  trailing: !0
52
52
  }),
53
53
  [e]
54
54
  );
55
- return k(() => {
55
+ return b(() => {
56
56
  const s = () => {
57
57
  i();
58
- }, h = o;
59
- if (h && h instanceof Element) {
60
- const a = new ResizeObserver((u) => {
58
+ }, m = o;
59
+ if (m && m instanceof Element) {
60
+ const h = new ResizeObserver((a) => {
61
61
  s();
62
62
  });
63
- return a.observe(h), () => {
64
- a.disconnect();
63
+ return h.observe(m), () => {
64
+ h.disconnect();
65
65
  };
66
66
  }
67
- }, [o]), /* @__PURE__ */ S(W.Provider, { value: t.current, children: n });
68
- }, p = {
67
+ }, [o]), /* @__PURE__ */ p($.Provider, { value: t.current, children: n });
68
+ }, g = {
69
69
  themeMode: "light",
70
70
  themeDirection: "ltr",
71
71
  themeColorPresets: "patronus",
@@ -73,7 +73,7 @@ const g = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, j = (r) => {
73
73
  themeStretch: !1,
74
74
  isMobile: !1
75
75
  };
76
- function b(r, n = "m4l") {
76
+ function R(r, n = "m4l") {
77
77
  const o = document.querySelector('[data-mui-color-scheme="light"]');
78
78
  if (!o) {
79
79
  console.error('Element with data-mui-color-scheme="light" not found.');
@@ -84,86 +84,35 @@ function b(r, n = "m4l") {
84
84
  if (typeof e == "string" || typeof e == "number") {
85
85
  const i = `--${n}-${t}`;
86
86
  o.style.setProperty(i, e.toString());
87
- } else typeof e == "object" && e !== null && b(e, `${n}-${t}`);
87
+ } else typeof e == "object" && e !== null && R(e, `${n}-${t}`);
88
88
  });
89
89
  }
90
- const l = {
91
- mainChannel: "",
92
- lightChannel: "",
93
- darkChannel: "",
94
- contrastTextChannel: ""
95
- }, c = (r) => {
96
- const n = r.currentThemeSettings || p, o = n.themeMode === "light", t = w(n.themeColorPresets), e = o ? t.light : t.dark;
90
+ const c = (r) => {
91
+ const n = r.currentThemeSettings || g, o = n.themeMode === "light", t = x(n.themeColorPresets), e = o ? t.light : t.dark;
97
92
  r.themeOptions = {
98
93
  ...r.themeOptions,
99
- typography: E,
94
+ typography: k,
100
95
  palette: {
101
96
  ...r.themeOptions?.palette ?? {},
102
- ...e,
103
- primary: {
104
- ...e.primary,
105
- ...l
106
- },
107
- secondary: {
108
- ...e.secondary,
109
- ...l
110
- },
111
- info: {
112
- ...e.info,
113
- ...l
114
- },
115
- error: {
116
- ...e.error,
117
- ...l
118
- },
119
- success: {
120
- ...e.success,
121
- ...l
122
- },
123
- warning: {
124
- ...e.warning,
125
- ...l
126
- },
127
- text: {
128
- ...e.text,
129
- primaryChannel: "",
130
- secondaryChannel: ""
131
- },
132
- background: {
133
- ...e.background,
134
- defaultChannel: "",
135
- paperChannel: ""
136
- },
137
- common: {
138
- ...e.common,
139
- background: "",
140
- backgroundChannel: "",
141
- onBackground: "",
142
- onBackgroundChannel: ""
143
- },
144
- action: {
145
- ...e.action,
146
- activeChannel: "",
147
- selectedChannel: ""
148
- }
97
+ ...e
149
98
  },
150
99
  shape: { borderRadius: 8 },
151
100
  direction: n.themeDirection,
152
- shadows: o ? d.light : d.dark,
101
+ shadows: o ? S.light : S.dark,
153
102
  customShadows: {
154
- primary: `0 8px 16px 0 ${z(
103
+ primary: `0 8px 16px 0 ${D(
155
104
  L(n.themeColorPresets)?.main || "#fff",
156
105
  0.2
157
106
  )}`,
158
- ...B(n.themeMode)
107
+ ...w(n.themeMode)
159
108
  },
160
109
  stretch: n.themeStretch
161
- }, b(r.themeOptions);
162
- }, m = (r) => {
110
+ }, R(r.themeOptions);
111
+ }, l = (r) => {
163
112
  r.setterThemeSettings && r.setterThemeSettings(r.currentThemeSettings);
164
- }, _ = (r) => C(
113
+ }, j = (r) => T(
165
114
  v(
166
- y((n, o) => ({
115
+ C((n, o) => ({
167
116
  ...r,
168
117
  settingsActions: {
169
118
  init: () => {
@@ -173,7 +122,7 @@ const l = {
173
122
  },
174
123
  setThemeSettings: (t) => {
175
124
  n((e) => {
176
- e.currentThemeSettings = { ...e.currentThemeSettings, ...t }, m(e), c(e);
125
+ e.currentThemeSettings = { ...e.currentThemeSettings, ...t }, l(e), c(e);
177
126
  });
178
127
  },
179
128
  onChangeMode: (t) => {
@@ -181,7 +130,7 @@ const l = {
181
130
  e.currentThemeSettings = {
182
131
  ...e.currentThemeSettings,
183
132
  themeMode: t.target.value
184
- }, m(e), c(e);
133
+ }, l(e), c(e);
185
134
  });
186
135
  },
187
136
  handleOpen: () => {
@@ -194,7 +143,7 @@ const l = {
194
143
  e.currentThemeSettings = {
195
144
  ...e.currentThemeSettings,
196
145
  themeDirection: t.target.value
197
- }, m(e), c(e);
146
+ }, l(e), c(e);
198
147
  });
199
148
  },
200
149
  onChangeColor: (t) => {
@@ -202,7 +151,7 @@ const l = {
202
151
  e.currentThemeSettings = {
203
152
  ...e.currentThemeSettings,
204
153
  themeColorPresets: t.target.value
205
- }, m(e), c(e);
154
+ }, l(e), c(e);
206
155
  });
207
156
  },
208
157
  onChangeLayout: (t) => {
@@ -210,7 +159,7 @@ const l = {
210
159
  e.currentThemeSettings = {
211
160
  ...e.currentThemeSettings,
212
161
  themeLayout: t.target.value
213
- }, m(e), c(e);
162
+ }, l(e), c(e);
214
163
  });
215
164
  },
216
165
  onToggleStretch: () => {
@@ -218,45 +167,45 @@ const l = {
218
167
  t.currentThemeSettings = {
219
168
  ...t.currentThemeSettings,
220
169
  themeStretch: !t.currentThemeSettings.themeStretch
221
- }, m(t), c(t);
170
+ }, l(t), c(t);
222
171
  });
223
172
  },
224
173
  onResetSetting: () => {
225
174
  n((t) => {
226
175
  t.currentThemeSettings = {
227
- ...p
228
- }, m(t), c(t);
176
+ ...g
177
+ }, l(t), c(t);
229
178
  });
230
179
  }
231
180
  }
232
181
  })),
233
182
  { name: "ThemeSettingsStore" }
234
183
  )
235
- ), N = f(null);
236
- function G({ children: r, themeSettings: n }) {
237
- const { networkOperation: o } = x(), t = $(), [e, i] = M(
184
+ ), W = f(null);
185
+ function F({ children: r, themeSettings: n }) {
186
+ const { networkOperation: o } = M(), t = z(), [e, i] = E(
238
187
  "theme_setting",
239
188
  {}
240
- ), s = T();
241
- return s.current || (s.current = _({
189
+ ), s = d();
190
+ return s.current || (s.current = j({
242
191
  networkOperation: o,
243
192
  currentThemeSettings: {
244
- ...p,
193
+ ...g,
245
194
  ...n,
246
195
  ...e
247
196
  },
248
197
  themeOptions: A,
249
- colorOption: D,
198
+ colorOption: B,
250
199
  open: !1,
251
200
  setterThemeSettings: n ? void 0 : i
252
201
  }), s.current.getState().settingsActions.init()), P(() => {
253
202
  s.current?.getState().settingsActions.setThemeSettings({ isMobile: t });
254
- }, [t]), /* @__PURE__ */ S(N.Provider, { value: s.current, children: r });
203
+ }, [t]), /* @__PURE__ */ p(W.Provider, { value: s.current, children: r });
255
204
  }
256
205
  export {
257
- W as R,
258
- N as T,
259
- F as a,
260
- G as b,
261
- p as d
206
+ $ as R,
207
+ W as T,
208
+ V as a,
209
+ F as b,
210
+ g as d
262
211
  };
@@ -1,7 +1,7 @@
1
1
  import { useRef as n, useEffect as r, useState as i, useContext as u, useLayoutEffect as c } from "react";
2
- import { H as m } from "../contexts/HostThemeContext/index-BMSwOCtA.js";
2
+ import { H as m } from "../contexts/HostThemeContext/index-CcHelA1w.js";
3
3
  import { u as a } from "../node_modules-BHhXVwYT.js";
4
- import { T as l } from "../contexts/index-DEyJidab.js";
4
+ import { T as l } from "../contexts/index-DypyrDjq.js";
5
5
  function S() {
6
6
  const e = n(!0);
7
7
  return r(
@@ -1,6 +1,6 @@
1
1
  import { useContext as t } from "react";
2
2
  import { u as r } from "../../node_modules-BHhXVwYT.js";
3
- import { R as n } from "../../contexts/index-DEyJidab.js";
3
+ import { R as n } from "../../contexts/index-DypyrDjq.js";
4
4
  import { useResponsive as i } from "@m4l/styles";
5
5
  function f(e, s) {
6
6
  const o = t(n);
package/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { G as s } from "./components/GlobalStyle/index-C3p7OfnO.js";
2
2
  import { L as r, a, g as i } from "./contexts/LocalesContext/index-C89UlO0s.js";
3
3
  import { F as m, a as p } from "./contexts/FormatterContext/index-Ch6IW7j8.js";
4
- import { R as x, a as f, T as d, b as l, d as v } from "./contexts/index-DEyJidab.js";
5
- import { H as T, a as g } from "./contexts/HostThemeContext/index-BMSwOCtA.js";
4
+ import { R as x, a as f, T as d, b as l, d as v } from "./contexts/index-DypyrDjq.js";
5
+ import { H as T, a as g } from "./contexts/HostThemeContext/index-CcHelA1w.js";
6
6
  import { u as R } from "./hooks/useFirstRender/index-B-Q0TTn0.js";
7
7
  import { u as c } from "./hooks/useFormatter/index-BBgQ4lJL.js";
8
- import { b as P, u as b, a as L, c as H, d as k } from "./hooks/index-Y3uj_IzK.js";
8
+ import { b as P, u as b, a as L, c as H, d as k } from "./hooks/index-DrIHt-va.js";
9
9
  import { u as z } from "./hooks/useLocales/index-_thMBNE7.js";
10
- import { u as I, a as M } from "./hooks/useResponsive/index-Dki-WJi8.js";
10
+ import { u as I, a as M } from "./hooks/useResponsive/index-BEcgN5as.js";
11
11
  import { u as y } from "./hooks/useIsMobile/index-Bro0dV28.js";
12
12
  import { C as D, g as E } from "./utils/index-DZG6QXjf.js";
13
13
  export {
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@m4l/graphics",
3
- "version": "3.0.3",
3
+ "version": "6.0.0",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team*",
6
6
  "dependencies": {
7
- "@m4l/core": "^2.0.0",
8
- "@m4l/styles": "^3.0.0",
9
7
  "date-fns": "^2.30.0",
10
8
  "zustand": "4.3.6",
11
9
  "immer": "^9.0.21"
12
10
  },
13
11
  "peerDependencies": {
12
+ "@m4l/core": "^2.0.0",
13
+ "@m4l/styles": "^6.0.0",
14
14
  "@types/react": "^17.0.0 || ^18.0.0",
15
15
  "react": "^17.0.0 || ^18.0.0",
16
16
  "react-toastify": "10.0.5",
package/vite-env.d.ts CHANGED
@@ -1 +1 @@
1
- /// <reference types="vite/client" />
1
+ /// <reference types="vite/client" />
@@ -1,44 +0,0 @@
1
- import { jsxs as i, jsx as t } from "react/jsx-runtime";
2
- import { createContext as c, useMemo as h } from "react";
3
- import { CssBaseline as d } from "@mui/material";
4
- import { G as p } from "../../components/GlobalStyle/index-C3p7OfnO.js";
5
- import { createTheme as x, experimental_extendTheme as f, Experimental_CssVarsProvider as u, StyledEngineProvider as T } from "@mui/material/styles";
6
- const v = c(null);
7
- function j(m) {
8
- const { children: l, hostThemeOptions: o, fnComponentsOverrides: n, isMobile: s } = m, a = h(() => {
9
- const e = x({
10
- ...o
11
- }), r = f({
12
- cssVarPrefix: "m4l",
13
- colorSchemes: {
14
- light: e,
15
- finalTheme: e,
16
- dark: e
17
- },
18
- generalSettings: {
19
- isMobile: s
20
- }
21
- });
22
- return r.components = n(r), r;
23
- }, [s]);
24
- return /* @__PURE__ */ i(u, { theme: a, children: [
25
- /* @__PURE__ */ t(p, {}),
26
- /* @__PURE__ */ t(
27
- v.Provider,
28
- {
29
- value: {
30
- hostThemeOptions: o,
31
- fnComponentsOverrides: n
32
- },
33
- children: /* @__PURE__ */ i(T, { injectFirst: !0, children: [
34
- /* @__PURE__ */ t(d, { enableColorScheme: !0 }),
35
- l
36
- ] })
37
- }
38
- )
39
- ] });
40
- }
41
- export {
42
- v as H,
43
- j as a
44
- };