@m4l/graphics 3.0.2 → 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,82 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { useTheme as o } from "@mui/material/styles";
3
+ import { GlobalStyles as a } from "@mui/material";
4
+ import { globalRemSize as r } from "@m4l/styles";
5
+ function s() {
6
+ const t = o();
7
+ return /* @__PURE__ */ e(
8
+ a,
9
+ {
10
+ styles: {
11
+ body: {
12
+ textRendering: "geometricPrecision",
13
+ width: "100%",
14
+ height: "100vh",
15
+ "input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, input:-webkit-autofill:active": {
16
+ color: t.vars.palette.text.primary
17
+ },
18
+ "*::-webkit-scrollbar": {
19
+ // camino de la barra con radio
20
+ width: "7px",
21
+ height: "7px",
22
+ borderRadius: "3px",
23
+ backgroundColor: "transparent"
24
+ },
25
+ "*::-webkit-scrollbar-track": {
26
+ // Camino de la barrra sin radio
27
+ backgroundColor: "transparent",
28
+ border: "0px solid transparent"
29
+ },
30
+ "*::-webkit-scrollbar-corner": {
31
+ backgroundColor: "transparent"
32
+ },
33
+ // FireFox
34
+ // scrollbarColor: `${theme.vars.palette.primary.main} white`,
35
+ // scrollbarWidth: 'thin',
36
+ // Chrome
37
+ "*::-webkit-scrollbar-thumb": {
38
+ // barra que se mueve
39
+ background: t.vars.palette.general.scrollBar,
40
+ borderRadius: "2px!important"
41
+ },
42
+ "& #root": {
43
+ width: "100%",
44
+ height: "100%"
45
+ }
46
+ },
47
+ "#nprogress": {
48
+ pointerEvents: "none",
49
+ "& .bar": {
50
+ top: 0,
51
+ left: 0,
52
+ height: 2,
53
+ width: "100%",
54
+ position: "fixed",
55
+ zIndex: t.zIndex.snackbar,
56
+ backgroundColor: t.vars.palette.primary.main,
57
+ boxShadow: `0 0 2px ${t.vars.palette.primary.main}`
58
+ },
59
+ "& .peg": {
60
+ right: 0,
61
+ opacity: 1,
62
+ width: 100,
63
+ height: "100%",
64
+ display: "block",
65
+ position: "absolute",
66
+ transform: "rotate(3deg) translate(0px, -4px)",
67
+ boxShadow: `0 0 10px ${t.vars.palette.primary.main}, 0 0 5px ${t.vars.palette.primary.main}`
68
+ }
69
+ },
70
+ "& html": {
71
+ fontSize: r.desktop,
72
+ [t.breakpoints.down("sm")]: {
73
+ fontSize: r.mobile
74
+ }
75
+ }
76
+ }
77
+ }
78
+ );
79
+ }
80
+ export {
81
+ s as G
82
+ };
@@ -0,0 +1,74 @@
1
+ import { jsx as D } from "react/jsx-runtime";
2
+ import { createContext as C, useState as k, useCallback as p, useEffect as v } from "react";
3
+ import { useHostTools as R, usePropageteMF as h, EmitEvents as f } from "@m4l/core";
4
+ import { u as V } from "../../hooks/useFirstRender/index-B-Q0TTn0.js";
5
+ const x = C(null);
6
+ function I(T) {
7
+ const { children: b, isMicroFrontEnd: F, currencyFormatter: l, numberFormatter: M, dateFormatter: t } = T, r = l?.decimalDigits || 0, o = l?.code || "USD", a = M?.decimalSymbol || 0.1.toLocaleString().substring(1, 2), s = M?.thousandsSymbol || 1e3.toLocaleString().substring(1, 2), m = t?.dateFormat || "yyyy-MM-dd", n = t?.dateMask || "____-__-__", c = t?.datetimeFormat || "yyyy-MM-dd HH:mm:ss", i = t?.datetimeMask || "____-__-__ __:__:__", _ = t?.timeFormat || "HH:mm:ss", d = t?.timeMask || "__:__:__", u = t?.formatDate || (() => {
8
+ throw new Error("Incorrect use of formatDate");
9
+ }), y = V(), { events_emit: g } = R(), [H, E] = k({
10
+ currencyFormatter: {
11
+ decimalDigits: r,
12
+ code: o
13
+ },
14
+ numberFormatter: { decimalSymbol: a, thousandsSymbol: s },
15
+ dateFormatter: {
16
+ dateFormat: m,
17
+ dateMask: n,
18
+ datetimeFormat: c,
19
+ datetimeMask: i,
20
+ timeFormat: _,
21
+ timeMask: d,
22
+ formatDate: u
23
+ }
24
+ }), S = p((e) => {
25
+ E(e);
26
+ }, []);
27
+ return h({
28
+ isMicroFrontEnd: F,
29
+ event: f.EMMIT_EVENT_HOST_FORMATTER_CHANGE,
30
+ setHandler: S
31
+ }), v(() => {
32
+ if (F || y)
33
+ return;
34
+ const e = {
35
+ currencyFormatter: { decimalDigits: r, code: o },
36
+ numberFormatter: { decimalSymbol: a, thousandsSymbol: s },
37
+ dateFormatter: {
38
+ dateFormat: m,
39
+ dateMask: n,
40
+ datetimeFormat: c,
41
+ datetimeMask: i,
42
+ timeFormat: _,
43
+ timeMask: d,
44
+ formatDate: u
45
+ }
46
+ };
47
+ E(e), g(f.EMMIT_EVENT_HOST_FORMATTER_CHANGE, e);
48
+ }, [
49
+ y,
50
+ o,
51
+ r,
52
+ a,
53
+ s,
54
+ m,
55
+ n,
56
+ c,
57
+ i,
58
+ _,
59
+ d,
60
+ u
61
+ ]), /* @__PURE__ */ D(
62
+ x.Provider,
63
+ {
64
+ value: {
65
+ ...H
66
+ },
67
+ children: b
68
+ }
69
+ );
70
+ }
71
+ export {
72
+ x as F,
73
+ I as a
74
+ };
@@ -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,13 +1,13 @@
1
- import { createContext as k, useState as E, useCallback as x, useEffect as _ } from "react";
1
+ import { jsx as E } from "react/jsx-runtime";
2
+ import { createContext as k, useState as _, useCallback as x, useEffect as L } from "react";
2
3
  import { AdapterDateFns as F } from "@mui/x-date-pickers/AdapterDateFns";
3
4
  import { LocalizationProvider as U } from "@mui/x-date-pickers";
4
5
  import { useEnvironment as P, useNetwork as I, useHostTools as j, useLocalStorageWithListener as w, EmitEvents as u } from "@m4l/core";
5
- import L from "date-fns/locale/en-US";
6
- import { jsx as S } from "react/jsx-runtime";
6
+ import S from "date-fns/locale/en-US";
7
7
  async function B(t, e, o) {
8
8
  const s = g(t), r = { ...t };
9
9
  let i;
10
- return s === "es" ? i = (await import("date-fns/locale/es")).default : s === "fr" ? i = (await import("date-fns/locale/fr")).default : s === "en-US" ? i = L : (i = L, r.lang = "en", r.script = void 0, r.region = "US", r.url_icon = `${e}/${o}/frontend/commons/assets/icons/langs/lang_en.svg`, r.name = "English US*"), {
10
+ return s === "es" ? i = (await import("date-fns/locale/es")).default : s === "fr" ? i = (await import("date-fns/locale/fr")).default : s === "en-US" ? i = S : (i = S, r.lang = "en", r.script = void 0, r.region = "US", r.url_icon = `${e}/${o}/frontend/commons/assets/icons/langs/lang_en.svg`, r.name = "English US*"), {
11
11
  ...r,
12
12
  module: i,
13
13
  localeString: g(r)
@@ -35,46 +35,35 @@ function y(t) {
35
35
  }
36
36
  const G = k(null);
37
37
  function J(t) {
38
- const {
39
- children: e,
40
- isMicroFrontEnd: o,
41
- localeHost: s,
42
- getLocaleFromNetwork: r
43
- } = t;
38
+ const { children: e, isMicroFrontEnd: o, localeHost: s, getLocaleFromNetwork: r } = t;
44
39
  if (o && !s)
45
40
  throw Error("Must set localeHost in microfrontend");
46
41
  if (!o && !r)
47
42
  throw Error("Must set getLocaleFromNetwork in host");
48
- const {
49
- domain_token: i,
50
- host_static_assets: v,
51
- environment_assets: h
52
- } = P(), {
53
- networkOperation: C
54
- } = I(), {
55
- events_add_listener: N,
56
- events_remove_listener: T,
57
- events_emit: H
58
- } = j(), [a, f] = E(() => {
43
+ const { domain_token: i, host_static_assets: v, environment_assets: h } = P(), { networkOperation: C } = I(), { events_add_listener: N, events_remove_listener: T, events_emit: H } = j(), [a, f] = _(() => {
59
44
  if (o)
60
45
  return s;
61
- }), [l, m] = w("localeHost", navigator.language), [M, A] = E(""), d = x((n) => {
46
+ }), [l, m] = w(
47
+ "localeHost",
48
+ navigator.language
49
+ ), [M, A] = _(""), d = x((n) => {
62
50
  f(n);
63
51
  }, []);
64
- if (_(() => (o && N(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, d), () => {
52
+ if (L(() => (o && N(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, d), () => {
65
53
  o && T(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, d);
66
- }), []), _(() => {
54
+ }), []), L(() => {
67
55
  let n = !0;
68
56
  if (!o && r && !(l === M && l !== ""))
69
57
  return C({
70
58
  method: "POST",
71
59
  endPoint: "na/locales",
72
- data: {
73
- ...y(l),
74
- domain_token: i
75
- }
60
+ data: { ...y(l), domain_token: i }
76
61
  }).then((p) => {
77
- n && r(p.data, v, h).then((c) => {
62
+ n && r(
63
+ p.data,
64
+ v,
65
+ h
66
+ ).then((c) => {
78
67
  f(c), A(c.localeString), l !== c.localeString && m(c.localeString), H(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, c);
79
68
  });
80
69
  }).finally(() => {
@@ -86,20 +75,24 @@ function J(t) {
86
75
  const O = (n) => {
87
76
  (n.lang !== a.lang || n.script !== a.script || n.region !== a.region) && m(g(n));
88
77
  };
89
- return /* @__PURE__ */ S(G.Provider, {
90
- value: {
91
- currentLocale: a,
92
- onChangeLocale: O
93
- },
94
- children: /* @__PURE__ */ S(U, {
95
- dateAdapter: F,
96
- adapterLocale: a.module,
97
- dateFormats: {
98
- hours24h: "23"
78
+ return /* @__PURE__ */ E(
79
+ G.Provider,
80
+ {
81
+ value: {
82
+ currentLocale: a,
83
+ onChangeLocale: O
99
84
  },
100
- children: e
101
- })
102
- });
85
+ children: /* @__PURE__ */ E(
86
+ U,
87
+ {
88
+ dateAdapter: F,
89
+ adapterLocale: a.module,
90
+ dateFormats: { hours24h: "23" },
91
+ children: e
92
+ }
93
+ )
94
+ }
95
+ );
103
96
  }
104
97
  export {
105
98
  G as L,
@@ -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
@@ -0,0 +1,211 @@
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
+ const n = {
10
+ ...r
11
+ };
12
+ return T(
13
+ v(
14
+ C((o, t) => ({
15
+ ...n,
16
+ responsiveContainerActions: {
17
+ setBreakpoint: (e) => {
18
+ o((i) => {
19
+ i.breakPoint = e, i.isUpSm = e !== "xs" && e !== "sm", i.isXs = e == "xs";
20
+ });
21
+ }
22
+ }
23
+ })),
24
+ { name: "Responsive Relative Store" }
25
+ )
26
+ );
27
+ }, $ = f(null), V = (r) => {
28
+ const { children: n, observedDivRef: o } = r, t = d();
29
+ t.current || (t.current = _({
30
+ breakPoint: "md",
31
+ isUpSm: !1,
32
+ isXs: !1
33
+ }));
34
+ const e = () => {
35
+ const s = o;
36
+ if (s instanceof HTMLElement && s.clientWidth) {
37
+ const m = Object.keys(
38
+ u
39
+ );
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
+ break;
45
+ } else h === m.length - 1 && s.clientWidth >= u[a] && t.current?.getState().responsiveContainerActions.setBreakpoint(a);
46
+ }
47
+ }
48
+ }, i = y(
49
+ () => O.throttle(e, 200, {
50
+ leading: !1,
51
+ trailing: !0
52
+ }),
53
+ [e]
54
+ );
55
+ return b(() => {
56
+ const s = () => {
57
+ i();
58
+ }, m = o;
59
+ if (m && m instanceof Element) {
60
+ const h = new ResizeObserver((a) => {
61
+ s();
62
+ });
63
+ return h.observe(m), () => {
64
+ h.disconnect();
65
+ };
66
+ }
67
+ }, [o]), /* @__PURE__ */ p($.Provider, { value: t.current, children: n });
68
+ }, g = {
69
+ themeMode: "light",
70
+ themeDirection: "ltr",
71
+ themeColorPresets: "patronus",
72
+ themeLayout: "horizontal",
73
+ themeStretch: !1,
74
+ isMobile: !1
75
+ };
76
+ function R(r, n = "m4l") {
77
+ const o = document.querySelector('[data-mui-color-scheme="light"]');
78
+ if (!o) {
79
+ console.error('Element with data-mui-color-scheme="light" not found.');
80
+ return;
81
+ }
82
+ Object.keys(r).forEach((t) => {
83
+ const e = r[t];
84
+ if (typeof e == "string" || typeof e == "number") {
85
+ const i = `--${n}-${t}`;
86
+ o.style.setProperty(i, e.toString());
87
+ } else typeof e == "object" && e !== null && R(e, `${n}-${t}`);
88
+ });
89
+ }
90
+ const c = (r) => {
91
+ const n = r.currentThemeSettings || g, o = n.themeMode === "light", t = x(n.themeColorPresets), e = o ? t.light : t.dark;
92
+ r.themeOptions = {
93
+ ...r.themeOptions,
94
+ typography: k,
95
+ palette: {
96
+ ...r.themeOptions?.palette ?? {},
97
+ ...e
98
+ },
99
+ shape: { borderRadius: 8 },
100
+ direction: n.themeDirection,
101
+ shadows: o ? S.light : S.dark,
102
+ customShadows: {
103
+ primary: `0 8px 16px 0 ${D(
104
+ L(n.themeColorPresets)?.main || "#fff",
105
+ 0.2
106
+ )}`,
107
+ ...w(n.themeMode)
108
+ },
109
+ stretch: n.themeStretch
110
+ }, R(r.themeOptions);
111
+ }, l = (r) => {
112
+ r.setterThemeSettings && r.setterThemeSettings(r.currentThemeSettings);
113
+ }, j = (r) => T(
114
+ v(
115
+ C((n, o) => ({
116
+ ...r,
117
+ settingsActions: {
118
+ init: () => {
119
+ n((t) => {
120
+ c(t);
121
+ });
122
+ },
123
+ setThemeSettings: (t) => {
124
+ n((e) => {
125
+ e.currentThemeSettings = { ...e.currentThemeSettings, ...t }, l(e), c(e);
126
+ });
127
+ },
128
+ onChangeMode: (t) => {
129
+ n((e) => {
130
+ e.currentThemeSettings = {
131
+ ...e.currentThemeSettings,
132
+ themeMode: t.target.value
133
+ }, l(e), c(e);
134
+ });
135
+ },
136
+ handleOpen: () => {
137
+ n((t) => {
138
+ t.open = !t.open;
139
+ });
140
+ },
141
+ onChangeDirection: (t) => {
142
+ n((e) => {
143
+ e.currentThemeSettings = {
144
+ ...e.currentThemeSettings,
145
+ themeDirection: t.target.value
146
+ }, l(e), c(e);
147
+ });
148
+ },
149
+ onChangeColor: (t) => {
150
+ n((e) => {
151
+ e.currentThemeSettings = {
152
+ ...e.currentThemeSettings,
153
+ themeColorPresets: t.target.value
154
+ }, l(e), c(e);
155
+ });
156
+ },
157
+ onChangeLayout: (t) => {
158
+ n((e) => {
159
+ e.currentThemeSettings = {
160
+ ...e.currentThemeSettings,
161
+ themeLayout: t.target.value
162
+ }, l(e), c(e);
163
+ });
164
+ },
165
+ onToggleStretch: () => {
166
+ n((t) => {
167
+ t.currentThemeSettings = {
168
+ ...t.currentThemeSettings,
169
+ themeStretch: !t.currentThemeSettings.themeStretch
170
+ }, l(t), c(t);
171
+ });
172
+ },
173
+ onResetSetting: () => {
174
+ n((t) => {
175
+ t.currentThemeSettings = {
176
+ ...g
177
+ }, l(t), c(t);
178
+ });
179
+ }
180
+ }
181
+ })),
182
+ { name: "ThemeSettingsStore" }
183
+ )
184
+ ), W = f(null);
185
+ function F({ children: r, themeSettings: n }) {
186
+ const { networkOperation: o } = M(), t = z(), [e, i] = E(
187
+ "theme_setting",
188
+ {}
189
+ ), s = d();
190
+ return s.current || (s.current = j({
191
+ networkOperation: o,
192
+ currentThemeSettings: {
193
+ ...g,
194
+ ...n,
195
+ ...e
196
+ },
197
+ themeOptions: A,
198
+ colorOption: B,
199
+ open: !1,
200
+ setterThemeSettings: n ? void 0 : i
201
+ }), s.current.getState().settingsActions.init()), P(() => {
202
+ s.current?.getState().settingsActions.setThemeSettings({ isMobile: t });
203
+ }, [t]), /* @__PURE__ */ p(W.Provider, { value: s.current, children: r });
204
+ }
205
+ export {
206
+ $ as R,
207
+ W as T,
208
+ V as a,
209
+ F as b,
210
+ g as d
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-B8iD1cO8.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-DqxwPAZr.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,5 +1,5 @@
1
1
  import { useContext as r } from "react";
2
- import { F as e } from "../../contexts/FormatterContext/index-BHG3bJJo.js";
2
+ import { F as e } from "../../contexts/FormatterContext/index-Ch6IW7j8.js";
3
3
  const m = () => {
4
4
  const t = r(e);
5
5
  if (!t) throw new Error("useFormatter context must be use inside FormatterProvider");
@@ -1,5 +1,5 @@
1
1
  import { useContext as o } from "react";
2
- import { L as t } from "../../contexts/LocalesContext/index--VwMF60R.js";
2
+ import { L as t } from "../../contexts/LocalesContext/index-C89UlO0s.js";
3
3
  const n = () => {
4
4
  const e = o(t);
5
5
  if (!e) throw new Error("useLocales context must be use inside LocalesProvider");
@@ -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-DqxwPAZr.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
- import { G as s } from "./components/GlobalStyle/index-BwMNLyTC.js";
2
- import { L as r, a, g as i } from "./contexts/LocalesContext/index--VwMF60R.js";
3
- import { F as m, a as p } from "./contexts/FormatterContext/index-BHG3bJJo.js";
4
- import { R as x, a as f, T as d, b as l, d as v } from "./contexts/index-DqxwPAZr.js";
5
- import { H as T, a as g } from "./contexts/HostThemeContext/index-B8iD1cO8.js";
1
+ import { G as s } from "./components/GlobalStyle/index-C3p7OfnO.js";
2
+ import { L as r, a, g as i } from "./contexts/LocalesContext/index-C89UlO0s.js";
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-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
- import { u as c } from "./hooks/useFormatter/index-DfdAcbzw.js";
8
- import { b as P, u as b, a as L, c as H, d as k } from "./hooks/index-jy_ocazP.js";
9
- import { u as z } from "./hooks/useLocales/index-mTHn9nqY.js";
10
- import { u as I, a as M } from "./hooks/useResponsive/index-P9e5eab1.js";
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-DrIHt-va.js";
9
+ import { u as z } from "./hooks/useLocales/index-_thMBNE7.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.2",
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",
@@ -1,79 +0,0 @@
1
- import { useTheme as e } from "@mui/material/styles";
2
- import { GlobalStyles as o } from "@mui/material";
3
- import { globalRemSize as r } from "@m4l/styles";
4
- import { jsx as a } from "react/jsx-runtime";
5
- function s() {
6
- const t = e();
7
- return /* @__PURE__ */ a(o, {
8
- styles: {
9
- body: {
10
- textRendering: "geometricPrecision",
11
- width: "100%",
12
- height: "100vh",
13
- "input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, input:-webkit-autofill:active": {
14
- color: t.vars.palette.text.primary
15
- },
16
- "*::-webkit-scrollbar": {
17
- // camino de la barra con radio
18
- width: "7px",
19
- height: "7px",
20
- borderRadius: "3px",
21
- backgroundColor: "transparent"
22
- },
23
- "*::-webkit-scrollbar-track": {
24
- // Camino de la barrra sin radio
25
- backgroundColor: "transparent",
26
- border: "0px solid transparent"
27
- },
28
- "*::-webkit-scrollbar-corner": {
29
- backgroundColor: "transparent"
30
- },
31
- // FireFox
32
- // scrollbarColor: `${theme.vars.palette.primary.main} white`,
33
- // scrollbarWidth: 'thin',
34
- // Chrome
35
- "*::-webkit-scrollbar-thumb": {
36
- // barra que se mueve
37
- background: t.vars.palette.general.scrollBar,
38
- borderRadius: "2px!important"
39
- },
40
- "& #root": {
41
- width: "100%",
42
- height: "100%"
43
- }
44
- },
45
- "#nprogress": {
46
- pointerEvents: "none",
47
- "& .bar": {
48
- top: 0,
49
- left: 0,
50
- height: 2,
51
- width: "100%",
52
- position: "fixed",
53
- zIndex: t.zIndex.snackbar,
54
- backgroundColor: t.vars.palette.primary.main,
55
- boxShadow: `0 0 2px ${t.vars.palette.primary.main}`
56
- },
57
- "& .peg": {
58
- right: 0,
59
- opacity: 1,
60
- width: 100,
61
- height: "100%",
62
- display: "block",
63
- position: "absolute",
64
- transform: "rotate(3deg) translate(0px, -4px)",
65
- boxShadow: `0 0 10px ${t.vars.palette.primary.main}, 0 0 5px ${t.vars.palette.primary.main}`
66
- }
67
- },
68
- "& html": {
69
- fontSize: r.desktop,
70
- [t.breakpoints.down("sm")]: {
71
- fontSize: r.mobile
72
- }
73
- }
74
- }
75
- });
76
- }
77
- export {
78
- s as G
79
- };
@@ -1,75 +0,0 @@
1
- import { createContext as D, useState as C, useCallback as k, useEffect as p } from "react";
2
- import { useHostTools as v, usePropageteMF as R, EmitEvents as f } from "@m4l/core";
3
- import { u as h } from "../../hooks/useFirstRender/index-B-Q0TTn0.js";
4
- import { jsx as V } from "react/jsx-runtime";
5
- const x = D(null);
6
- function I(T) {
7
- const {
8
- children: b,
9
- isMicroFrontEnd: F,
10
- currencyFormatter: l,
11
- numberFormatter: M,
12
- dateFormatter: t
13
- } = T, r = l?.decimalDigits || 0, o = l?.code || "USD", a = M?.decimalSymbol || 0.1.toLocaleString().substring(1, 2), s = M?.thousandsSymbol || 1e3.toLocaleString().substring(1, 2), m = t?.dateFormat || "yyyy-MM-dd", n = t?.dateMask || "____-__-__", c = t?.datetimeFormat || "yyyy-MM-dd HH:mm:ss", i = t?.datetimeMask || "____-__-__ __:__:__", _ = t?.timeFormat || "HH:mm:ss", d = t?.timeMask || "__:__:__", u = t?.formatDate || (() => {
14
- throw new Error("Incorrect use of formatDate");
15
- }), y = h(), {
16
- events_emit: g
17
- } = v(), [H, E] = C({
18
- currencyFormatter: {
19
- decimalDigits: r,
20
- code: o
21
- },
22
- numberFormatter: {
23
- decimalSymbol: a,
24
- thousandsSymbol: s
25
- },
26
- dateFormatter: {
27
- dateFormat: m,
28
- dateMask: n,
29
- datetimeFormat: c,
30
- datetimeMask: i,
31
- timeFormat: _,
32
- timeMask: d,
33
- formatDate: u
34
- }
35
- }), S = k((e) => {
36
- E(e);
37
- }, []);
38
- return R({
39
- isMicroFrontEnd: F,
40
- event: f.EMMIT_EVENT_HOST_FORMATTER_CHANGE,
41
- setHandler: S
42
- }), p(() => {
43
- if (F || y)
44
- return;
45
- const e = {
46
- currencyFormatter: {
47
- decimalDigits: r,
48
- code: o
49
- },
50
- numberFormatter: {
51
- decimalSymbol: a,
52
- thousandsSymbol: s
53
- },
54
- dateFormatter: {
55
- dateFormat: m,
56
- dateMask: n,
57
- datetimeFormat: c,
58
- datetimeMask: i,
59
- timeFormat: _,
60
- timeMask: d,
61
- formatDate: u
62
- }
63
- };
64
- E(e), g(f.EMMIT_EVENT_HOST_FORMATTER_CHANGE, e);
65
- }, [y, o, r, a, s, m, n, c, i, _, d, u]), /* @__PURE__ */ V(x.Provider, {
66
- value: {
67
- ...H
68
- },
69
- children: b
70
- });
71
- }
72
- export {
73
- x as F,
74
- I as a
75
- };
@@ -1,48 +0,0 @@
1
- import { createContext as c, useMemo as h } from "react";
2
- import { CssBaseline as d } from "@mui/material";
3
- import { G as p } from "../../components/GlobalStyle/index-BwMNLyTC.js";
4
- import { createTheme as x, experimental_extendTheme as f, Experimental_CssVarsProvider as u, StyledEngineProvider as T } from "@mui/material/styles";
5
- import { jsxs as i, jsx as t } from "react/jsx-runtime";
6
- const v = c(null);
7
- function j(m) {
8
- const {
9
- children: l,
10
- hostThemeOptions: o,
11
- fnComponentsOverrides: n,
12
- isMobile: s
13
- } = m, a = h(() => {
14
- const e = x({
15
- ...o
16
- }), r = f({
17
- cssVarPrefix: "m4l",
18
- colorSchemes: {
19
- light: e,
20
- finalTheme: e,
21
- dark: e
22
- },
23
- generalSettings: {
24
- isMobile: s
25
- }
26
- });
27
- return r.components = n(r), r;
28
- }, [s]);
29
- return /* @__PURE__ */ i(u, {
30
- theme: a,
31
- children: [/* @__PURE__ */ t(p, {}), /* @__PURE__ */ t(v.Provider, {
32
- value: {
33
- hostThemeOptions: o,
34
- fnComponentsOverrides: n
35
- },
36
- children: /* @__PURE__ */ i(T, {
37
- injectFirst: !0,
38
- children: [/* @__PURE__ */ t(d, {
39
- enableColorScheme: !0
40
- }), l]
41
- })
42
- })]
43
- });
44
- }
45
- export {
46
- v as H,
47
- j as a
48
- };
@@ -1,270 +0,0 @@
1
- import { createContext as S, useRef as f, useMemo as R, useLayoutEffect as k, useEffect as P } from "react";
2
- import { c as T, d as C, i as v, l as O } from "../node_modules-BHhXVwYT.js";
3
- import { jsx as y } from "react/jsx-runtime";
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) => {
9
- const n = {
10
- ...r
11
- };
12
- return T(
13
- C(
14
- v((o, t) => ({
15
- ...n,
16
- responsiveContainerActions: {
17
- setBreakpoint: (e) => {
18
- o((i) => {
19
- i.breakPoint = e, i.isUpSm = e !== "xs" && e !== "sm", i.isXs = e == "xs";
20
- });
21
- }
22
- }
23
- })),
24
- { name: "Responsive Relative Store" }
25
- )
26
- );
27
- }, W = S(null), F = (r) => {
28
- const {
29
- children: n,
30
- observedDivRef: o
31
- } = r, t = f();
32
- t.current || (t.current = j({
33
- breakPoint: "md",
34
- isUpSm: !1,
35
- isXs: !1
36
- }));
37
- const e = () => {
38
- const s = o;
39
- if (s instanceof HTMLElement && s.clientWidth) {
40
- const h = Object.keys(g);
41
- for (let a = 0; a < h.length; a++) {
42
- const u = h[a];
43
- if (s.clientWidth <= g[u]) {
44
- t.current?.getState().responsiveContainerActions.setBreakpoint(u);
45
- break;
46
- } else a === h.length - 1 && s.clientWidth >= g[u] && t.current?.getState().responsiveContainerActions.setBreakpoint(u);
47
- }
48
- }
49
- }, i = R(() => O.throttle(e, 200, {
50
- leading: !1,
51
- trailing: !0
52
- }), [e]);
53
- return k(() => {
54
- const s = () => {
55
- i();
56
- }, h = o;
57
- if (h && h instanceof Element) {
58
- const a = new ResizeObserver((u) => {
59
- s();
60
- });
61
- return a.observe(h), () => {
62
- a.disconnect();
63
- };
64
- }
65
- }, [o]), /* @__PURE__ */ y(W.Provider, {
66
- value: t.current,
67
- children: n
68
- });
69
- }, p = {
70
- themeMode: "light",
71
- themeDirection: "ltr",
72
- themeColorPresets: "patronus",
73
- themeLayout: "horizontal",
74
- themeStretch: !1,
75
- isMobile: !1
76
- };
77
- function b(r, n = "m4l") {
78
- const o = document.querySelector('[data-mui-color-scheme="light"]');
79
- if (!o) {
80
- console.error('Element with data-mui-color-scheme="light" not found.');
81
- return;
82
- }
83
- Object.keys(r).forEach((t) => {
84
- const e = r[t];
85
- if (typeof e == "string" || typeof e == "number") {
86
- const i = `--${n}-${t}`;
87
- o.style.setProperty(i, e.toString());
88
- } else typeof e == "object" && e !== null && b(e, `${n}-${t}`);
89
- });
90
- }
91
- const l = {
92
- mainChannel: "",
93
- lightChannel: "",
94
- darkChannel: "",
95
- contrastTextChannel: ""
96
- }, c = (r) => {
97
- const n = r.currentThemeSettings || p, o = n.themeMode === "light", t = w(n.themeColorPresets), e = o ? t.light : t.dark;
98
- r.themeOptions = {
99
- ...r.themeOptions,
100
- typography: E,
101
- palette: {
102
- ...r.themeOptions?.palette ?? {},
103
- ...e,
104
- primary: {
105
- ...e.primary,
106
- ...l
107
- },
108
- secondary: {
109
- ...e.secondary,
110
- ...l
111
- },
112
- info: {
113
- ...e.info,
114
- ...l
115
- },
116
- error: {
117
- ...e.error,
118
- ...l
119
- },
120
- success: {
121
- ...e.success,
122
- ...l
123
- },
124
- warning: {
125
- ...e.warning,
126
- ...l
127
- },
128
- text: {
129
- ...e.text,
130
- primaryChannel: "",
131
- secondaryChannel: ""
132
- },
133
- background: {
134
- ...e.background,
135
- defaultChannel: "",
136
- paperChannel: ""
137
- },
138
- common: {
139
- ...e.common,
140
- background: "",
141
- backgroundChannel: "",
142
- onBackground: "",
143
- onBackgroundChannel: ""
144
- },
145
- action: {
146
- ...e.action,
147
- activeChannel: "",
148
- selectedChannel: ""
149
- }
150
- },
151
- shape: { borderRadius: 8 },
152
- direction: n.themeDirection,
153
- shadows: o ? d.light : d.dark,
154
- customShadows: {
155
- primary: `0 8px 16px 0 ${z(
156
- L(n.themeColorPresets)?.main || "#fff",
157
- 0.2
158
- )}`,
159
- ...B(n.themeMode)
160
- },
161
- stretch: n.themeStretch
162
- }, b(r.themeOptions);
163
- }, m = (r) => {
164
- r.setterThemeSettings && r.setterThemeSettings(r.currentThemeSettings);
165
- }, _ = (r) => T(
166
- C(
167
- v((n, o) => ({
168
- ...r,
169
- settingsActions: {
170
- init: () => {
171
- n((t) => {
172
- c(t);
173
- });
174
- },
175
- setThemeSettings: (t) => {
176
- n((e) => {
177
- e.currentThemeSettings = { ...e.currentThemeSettings, ...t }, m(e), c(e);
178
- });
179
- },
180
- onChangeMode: (t) => {
181
- n((e) => {
182
- e.currentThemeSettings = {
183
- ...e.currentThemeSettings,
184
- themeMode: t.target.value
185
- }, m(e), c(e);
186
- });
187
- },
188
- handleOpen: () => {
189
- n((t) => {
190
- t.open = !t.open;
191
- });
192
- },
193
- onChangeDirection: (t) => {
194
- n((e) => {
195
- e.currentThemeSettings = {
196
- ...e.currentThemeSettings,
197
- themeDirection: t.target.value
198
- }, m(e), c(e);
199
- });
200
- },
201
- onChangeColor: (t) => {
202
- n((e) => {
203
- e.currentThemeSettings = {
204
- ...e.currentThemeSettings,
205
- themeColorPresets: t.target.value
206
- }, m(e), c(e);
207
- });
208
- },
209
- onChangeLayout: (t) => {
210
- n((e) => {
211
- e.currentThemeSettings = {
212
- ...e.currentThemeSettings,
213
- themeLayout: t.target.value
214
- }, m(e), c(e);
215
- });
216
- },
217
- onToggleStretch: () => {
218
- n((t) => {
219
- t.currentThemeSettings = {
220
- ...t.currentThemeSettings,
221
- themeStretch: !t.currentThemeSettings.themeStretch
222
- }, m(t), c(t);
223
- });
224
- },
225
- onResetSetting: () => {
226
- n((t) => {
227
- t.currentThemeSettings = {
228
- ...p
229
- }, m(t), c(t);
230
- });
231
- }
232
- }
233
- })),
234
- { name: "ThemeSettingsStore" }
235
- )
236
- ), N = S(null);
237
- function G({
238
- children: r,
239
- themeSettings: n
240
- }) {
241
- const {
242
- networkOperation: o
243
- } = x(), t = $(), [e, i] = M("theme_setting", {}), s = f();
244
- return s.current || (s.current = _({
245
- networkOperation: o,
246
- currentThemeSettings: {
247
- ...p,
248
- ...n,
249
- ...e
250
- },
251
- themeOptions: A,
252
- colorOption: D,
253
- open: !1,
254
- setterThemeSettings: n ? void 0 : i
255
- }), s.current.getState().settingsActions.init()), P(() => {
256
- s.current?.getState().settingsActions.setThemeSettings({
257
- isMobile: t
258
- });
259
- }, [t]), /* @__PURE__ */ y(N.Provider, {
260
- value: s.current,
261
- children: r
262
- });
263
- }
264
- export {
265
- W as R,
266
- N as T,
267
- F as a,
268
- G as b,
269
- p as d
270
- };