@m4l/graphics 6.0.0 → 6.0.1
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/components/GlobalStyles/index.d.ts +0 -1
- package/contexts/FormatterContext/index.d.ts +1 -2
- package/contexts/FormatterContext/{index-Ch6IW7j8.js → index.js} +1 -1
- package/contexts/FormatterContext/types.d.ts +2 -2
- package/contexts/HostThemeContext/index.d.ts +1 -2
- package/contexts/HostThemeContext/{index-CcHelA1w.js → index.js} +1 -1
- package/contexts/HostThemeContext/types.d.ts +4 -4
- package/contexts/LocalesContext/helper.js +35 -0
- package/contexts/LocalesContext/index.d.ts +1 -2
- package/contexts/LocalesContext/index.js +69 -0
- package/contexts/LocalesContext/types.d.ts +4 -4
- package/contexts/ResponsiveContainerContext/constants.js +4 -0
- package/contexts/ResponsiveContainerContext/index.d.ts +3 -4
- package/contexts/ResponsiveContainerContext/index.js +51 -0
- package/contexts/ResponsiveContainerContext/store.d.ts +3 -3
- package/contexts/ResponsiveContainerContext/store.js +26 -0
- package/contexts/ResponsiveContainerContext/types.d.ts +4 -5
- package/contexts/ThemeSettingsContext/ThemeSettingsContext.d.ts +4 -5
- package/contexts/ThemeSettingsContext/ThemeSettingsContext.js +32 -0
- package/contexts/ThemeSettingsContext/constants.js +11 -0
- package/contexts/ThemeSettingsContext/index.js +1 -0
- package/contexts/ThemeSettingsContext/store.d.ts +2 -2
- package/contexts/ThemeSettingsContext/store.js +118 -0
- package/contexts/ThemeSettingsContext/types.d.ts +10 -10
- package/contexts/index.js +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useFormatter/index.d.ts +1 -1
- package/hooks/useFormatter/index.js +11 -0
- package/hooks/useHostTheme/index.d.ts +1 -1
- package/hooks/useHostTheme/index.js +11 -0
- package/hooks/useIsMobile/{index-Bro0dV28.js → index.js} +5 -5
- package/hooks/useIsMountedRef/index.d.ts +1 -2
- package/hooks/useIsMountedRef/index.js +13 -0
- package/hooks/useLocales/index.d.ts +1 -1
- package/hooks/useLocales/index.js +11 -0
- package/hooks/useOffSetTop.js +12 -0
- package/hooks/useResizeObserver/index.d.ts +1 -2
- package/hooks/useResizeObserver/index.js +18 -0
- package/hooks/useResponsive/index.js +7 -0
- package/hooks/useResponsiveContainer/index.js +12 -0
- package/hooks/useThemSettingsStore/index.js +12 -0
- package/index.js +44 -35
- package/package.json +55 -11
- package/utils/anchorEl.d.ts +2 -2
- package/utils/anchorEl.js +49 -0
- package/utils/index.js +1 -0
- package/utils/strings.js +4 -0
- package/vite-env.d.ts +1 -1
- package/commonjs-BCz0-aDl.js +0 -9
- package/contexts/LocalesContext/index-C89UlO0s.js +0 -101
- package/contexts/index-DypyrDjq.js +0 -211
- package/hooks/index-DrIHt-va.js +0 -52
- package/hooks/useFormatter/index-BBgQ4lJL.js +0 -10
- package/hooks/useLocales/index-_thMBNE7.js +0 -10
- package/hooks/useResponsive/index-BEcgN5as.js +0 -16
- package/node_modules-BHhXVwYT.js +0 -4569
- package/utils/index-DZG6QXjf.js +0 -51
- /package/components/{GlobalStyle/index-C3p7OfnO.js → GlobalStyles/index.js} +0 -0
- /package/components/{index-l0sNRNKZ.js → index.js} +0 -0
- /package/hooks/useFirstRender/{index-B-Q0TTn0.js → index.js} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { FormatterProviderProps, Formatters } from './types';
|
|
3
|
-
declare const FormatterContext: import(
|
|
2
|
+
declare const FormatterContext: import('react').Context<Formatters | null>;
|
|
4
3
|
/**
|
|
5
4
|
* @function
|
|
6
5
|
* Componente encargado de proveer un contexto que permita saber los diferentes forrmatos,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as D } from "react/jsx-runtime";
|
|
2
2
|
import { createContext as C, useState as k, useCallback as p, useEffect as v } from "react";
|
|
3
3
|
import { useHostTools as R, usePropageteMF as h, EmitEvents as f } from "@m4l/core";
|
|
4
|
-
import { u as V } from "../../hooks/useFirstRender/index
|
|
4
|
+
import { u as V } from "../../hooks/useFirstRender/index.js";
|
|
5
5
|
const x = C(null);
|
|
6
6
|
function I(T) {
|
|
7
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 || (() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Locale } from 'date-fns';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
export interface CurrencyFormatter {
|
|
4
4
|
code: string;
|
|
@@ -52,4 +52,4 @@ export interface FormatterProviderProps extends OptionalFormatters {
|
|
|
52
52
|
isMicroFrontEnd: boolean;
|
|
53
53
|
children: ReactNode;
|
|
54
54
|
}
|
|
55
|
-
export
|
|
55
|
+
export type FormatterContextProps = Formatters;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { HostThemeProviderProps } from './types';
|
|
3
|
-
declare const HostThemeContext: import(
|
|
2
|
+
declare const HostThemeContext: import('react').Context<import('./types').HostThemeType | null>;
|
|
4
3
|
declare function HostThemeProvider(props: HostThemeProviderProps): import("react").JSX.Element;
|
|
5
4
|
export { HostThemeProvider, HostThemeContext };
|
|
@@ -2,7 +2,7 @@ import { jsxs as i, jsx as o } from "react/jsx-runtime";
|
|
|
2
2
|
import { createContext as h, useMemo as d } from "react";
|
|
3
3
|
import { CssBaseline as p } from "@mui/material";
|
|
4
4
|
import { deepmerge as t } from "@mui/utils";
|
|
5
|
-
import { G as f } from "../../components/
|
|
5
|
+
import { G as f } from "../../components/GlobalStyles/index.js";
|
|
6
6
|
import { createTheme as u, experimental_extendTheme as x, Experimental_CssVarsProvider as T, StyledEngineProvider as v } from "@mui/material/styles";
|
|
7
7
|
const C = h(null);
|
|
8
8
|
function y(l) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OurTheme } from '@m4l/styles';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
export
|
|
2
|
+
import { Theme, CssVarsTheme } from '@mui/material/styles';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
export type EventFunListener = (...args: any[]) => void;
|
|
5
5
|
export interface HostThemeType {
|
|
6
6
|
hostThemeOptions: OurTheme;
|
|
7
7
|
fnComponentsOverrides: (theme: Omit<Theme, 'palette' | 'applyStyles'> & CssVarsTheme) => any;
|
|
@@ -11,4 +11,4 @@ export interface HostThemeProviderProps extends HostThemeType {
|
|
|
11
11
|
children: ReactNode;
|
|
12
12
|
isMobile: boolean;
|
|
13
13
|
}
|
|
14
|
-
export
|
|
14
|
+
export type HostThemeContextType = HostThemeType;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import o from "date-fns/locale/en-US";
|
|
2
|
+
async function g(n, e, s) {
|
|
3
|
+
const r = l(n), i = { ...n };
|
|
4
|
+
let t;
|
|
5
|
+
return r === "es" ? t = (await import("date-fns/locale/es")).default : r === "fr" ? t = (await import("date-fns/locale/fr")).default : r === "en-US" ? t = o : (t = o, i.lang = "en", i.script = void 0, i.region = "US", i.url_icon = `${e}/${s}/frontend/commons/assets/icons/langs/lang_en.svg`, i.name = "English US*"), {
|
|
6
|
+
...i,
|
|
7
|
+
module: t,
|
|
8
|
+
localeString: l(i)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function l(n) {
|
|
12
|
+
let e = n.lang;
|
|
13
|
+
return n.script && n.script !== "" && (e = e + "-" + n.script), n.region && n.region !== "" && (e = e + "-" + n.region), e;
|
|
14
|
+
}
|
|
15
|
+
function a(n) {
|
|
16
|
+
try {
|
|
17
|
+
const e = new Intl.Locale(n);
|
|
18
|
+
return {
|
|
19
|
+
lang: e.language || "",
|
|
20
|
+
script: e.script,
|
|
21
|
+
region: e.region
|
|
22
|
+
};
|
|
23
|
+
} catch {
|
|
24
|
+
return {
|
|
25
|
+
lang: "en",
|
|
26
|
+
script: void 0,
|
|
27
|
+
region: "US"
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
g,
|
|
33
|
+
l as j,
|
|
34
|
+
a as s
|
|
35
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { LocalesProviderProps, LocalesContextProps } from './types';
|
|
3
|
-
declare const LocalesContext: import(
|
|
2
|
+
declare const LocalesContext: import('react').Context<LocalesContextProps | null>;
|
|
4
3
|
declare function LocalesProvider(props: LocalesProviderProps): import("react").JSX.Element | null;
|
|
5
4
|
export { LocalesProvider, LocalesContext };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as A, useState as d, useCallback as O, useEffect as E } from "react";
|
|
3
|
+
import { AdapterDateFns as k } from "@mui/x-date-pickers/AdapterDateFns";
|
|
4
|
+
import { LocalizationProvider as x } from "@mui/x-date-pickers";
|
|
5
|
+
import { useEnvironment as F, useNetwork as P, useHostTools as j, useLocalStorageWithListener as G, EmitEvents as i } from "@m4l/core";
|
|
6
|
+
import { s as I, j as V } from "./helper.js";
|
|
7
|
+
const U = A(null);
|
|
8
|
+
function B(_) {
|
|
9
|
+
const { children: g, isMicroFrontEnd: e, localeHost: a, getLocaleFromNetwork: s } = _;
|
|
10
|
+
if (e && !a)
|
|
11
|
+
throw Error("Must set localeHost in microfrontend");
|
|
12
|
+
if (!e && !s)
|
|
13
|
+
throw Error("Must set getLocaleFromNetwork in host");
|
|
14
|
+
const { domain_token: L, host_static_assets: p, environment_assets: h } = F(), { networkOperation: v } = P(), { events_add_listener: S, events_remove_listener: C, events_emit: T } = j(), [r, l] = d(() => {
|
|
15
|
+
if (e)
|
|
16
|
+
return a;
|
|
17
|
+
}), [o, c] = G(
|
|
18
|
+
"localeHost",
|
|
19
|
+
navigator.language
|
|
20
|
+
), [H, N] = d(""), u = O((t) => {
|
|
21
|
+
l(t);
|
|
22
|
+
}, []);
|
|
23
|
+
if (E(() => (e && S(i.EMMIT_EVENT_HOST_LOCALE_CHANGE, u), () => {
|
|
24
|
+
e && C(i.EMMIT_EVENT_HOST_LOCALE_CHANGE, u);
|
|
25
|
+
}), []), E(() => {
|
|
26
|
+
let t = !0;
|
|
27
|
+
if (!e && s && !(o === H && o !== ""))
|
|
28
|
+
return v({
|
|
29
|
+
method: "POST",
|
|
30
|
+
endPoint: "na/locales",
|
|
31
|
+
data: { ...I(o), domain_token: L }
|
|
32
|
+
}).then((f) => {
|
|
33
|
+
t && s(f.data, p, h).then(
|
|
34
|
+
(n) => {
|
|
35
|
+
l(n), N(n.localeString), o !== n.localeString && c(n.localeString), T(i.EMMIT_EVENT_HOST_LOCALE_CHANGE, n);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}).finally(() => {
|
|
39
|
+
}), function() {
|
|
40
|
+
t = !1;
|
|
41
|
+
};
|
|
42
|
+
}, [o]), !r)
|
|
43
|
+
return null;
|
|
44
|
+
const M = (t) => {
|
|
45
|
+
(t.lang !== r.lang || t.script !== r.script || t.region !== r.region) && c(V(t));
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ m(
|
|
48
|
+
U.Provider,
|
|
49
|
+
{
|
|
50
|
+
value: {
|
|
51
|
+
currentLocale: r,
|
|
52
|
+
onChangeLocale: M
|
|
53
|
+
},
|
|
54
|
+
children: /* @__PURE__ */ m(
|
|
55
|
+
x,
|
|
56
|
+
{
|
|
57
|
+
dateAdapter: k,
|
|
58
|
+
adapterLocale: r.module,
|
|
59
|
+
dateFormats: { hours24h: "23" },
|
|
60
|
+
children: g
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
U as L,
|
|
68
|
+
B as a
|
|
69
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import
|
|
3
|
-
export
|
|
2
|
+
import { Locale } from 'date-fns';
|
|
3
|
+
export type SupportedLocales = 'en-US' | 'es' | 'fr';
|
|
4
4
|
export interface BaseLocale {
|
|
5
5
|
lang: string;
|
|
6
6
|
script?: string;
|
|
@@ -14,13 +14,13 @@ export interface LocaleType extends NetworkLocaleType {
|
|
|
14
14
|
module: Locale;
|
|
15
15
|
localeString: string;
|
|
16
16
|
}
|
|
17
|
-
export
|
|
17
|
+
export type LocalesProviderProps = {
|
|
18
18
|
isMicroFrontEnd: boolean;
|
|
19
19
|
localeHost?: LocaleType;
|
|
20
20
|
getLocaleFromNetwork?: (locale: NetworkLocaleType, host_static_assets: string, environment_assets: string) => Promise<LocaleType>;
|
|
21
21
|
children: ReactNode;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type LocalesContextProps = {
|
|
24
24
|
currentLocale?: LocaleType;
|
|
25
25
|
onChangeLocale: (newLocaleString: BaseLocale) => void;
|
|
26
26
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ResponsiveContainerProviderProps } from './types';
|
|
3
|
-
declare const ResponsiveContainerContext: import(
|
|
2
|
+
declare const ResponsiveContainerContext: import('react').Context<(Omit<Omit<import('zustand').StoreApi<import('./types').ResponsiveContainerStateWithActions>, "setState"> & {
|
|
4
3
|
setState<A extends string | {
|
|
5
4
|
type: unknown;
|
|
6
|
-
}>(partial: import(
|
|
5
|
+
}>(partial: import('./types').ResponsiveContainerStateWithActions | Partial<import('./types').ResponsiveContainerStateWithActions> | ((state: import('./types').ResponsiveContainerStateWithActions) => import('./types').ResponsiveContainerStateWithActions | Partial<import('./types').ResponsiveContainerStateWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
|
|
7
6
|
}, "setState"> & {
|
|
8
|
-
setState(nextStateOrUpdater: import(
|
|
7
|
+
setState(nextStateOrUpdater: import('./types').ResponsiveContainerStateWithActions | Partial<import('./types').ResponsiveContainerStateWithActions> | ((state: import('immer/dist/internal').WritableDraft<import('./types').ResponsiveContainerStateWithActions>) => void), shouldReplace?: boolean | undefined, action?: string | {
|
|
9
8
|
type: unknown;
|
|
10
9
|
} | undefined): void;
|
|
11
10
|
}) | null>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as p, useRef as v, useCallback as u, useMemo as d, useLayoutEffect as R } from "react";
|
|
3
|
+
import { B as i } from "./constants.js";
|
|
4
|
+
import b from "lodash.throttle";
|
|
5
|
+
import { c as h } from "./store.js";
|
|
6
|
+
const k = p(null), y = (l) => {
|
|
7
|
+
const { children: f, observedDivRef: s } = l, o = v();
|
|
8
|
+
o.current || (o.current = h({
|
|
9
|
+
breakPoint: "md",
|
|
10
|
+
isUpSm: !1,
|
|
11
|
+
isXs: !1
|
|
12
|
+
}));
|
|
13
|
+
const c = u(() => {
|
|
14
|
+
const n = s;
|
|
15
|
+
if (n instanceof HTMLElement && n.clientWidth) {
|
|
16
|
+
const e = Object.keys(
|
|
17
|
+
i
|
|
18
|
+
);
|
|
19
|
+
for (let t = 0; t < e.length; t++) {
|
|
20
|
+
const r = e[t];
|
|
21
|
+
if (n.clientWidth <= i[r]) {
|
|
22
|
+
o.current?.getState().responsiveContainerActions.setBreakpoint(r);
|
|
23
|
+
break;
|
|
24
|
+
} else t === e.length - 1 && n.clientWidth >= i[r] && o.current?.getState().responsiveContainerActions.setBreakpoint(r);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, [s]), a = d(
|
|
28
|
+
() => b(c, 200, {
|
|
29
|
+
leading: !1,
|
|
30
|
+
trailing: !0
|
|
31
|
+
}),
|
|
32
|
+
[c]
|
|
33
|
+
);
|
|
34
|
+
return R(() => {
|
|
35
|
+
const n = () => {
|
|
36
|
+
a();
|
|
37
|
+
}, e = s;
|
|
38
|
+
if (e && e instanceof Element) {
|
|
39
|
+
const t = new ResizeObserver((r) => {
|
|
40
|
+
n();
|
|
41
|
+
});
|
|
42
|
+
return t.observe(e), () => {
|
|
43
|
+
t.disconnect();
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}, [s, a]), /* @__PURE__ */ m(k.Provider, { value: o.current, children: f });
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
k as R,
|
|
50
|
+
y as a
|
|
51
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { InitialResponsiveContainerProps, ResponsiveContainerStateWithActions } from './types';
|
|
2
|
-
export declare const createResponsiveContainerStore: (initProps: InitialResponsiveContainerProps) => Omit<Omit<import(
|
|
2
|
+
export declare const createResponsiveContainerStore: (initProps: InitialResponsiveContainerProps) => Omit<Omit<import('zustand').StoreApi<ResponsiveContainerStateWithActions>, "setState"> & {
|
|
3
3
|
setState<A extends string | {
|
|
4
4
|
type: unknown;
|
|
5
5
|
}>(partial: ResponsiveContainerStateWithActions | Partial<ResponsiveContainerStateWithActions> | ((state: ResponsiveContainerStateWithActions) => ResponsiveContainerStateWithActions | Partial<ResponsiveContainerStateWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
|
|
6
6
|
}, "setState"> & {
|
|
7
|
-
setState(nextStateOrUpdater: ResponsiveContainerStateWithActions | Partial<ResponsiveContainerStateWithActions> | ((state: import(
|
|
7
|
+
setState(nextStateOrUpdater: ResponsiveContainerStateWithActions | Partial<ResponsiveContainerStateWithActions> | ((state: import('immer/dist/internal').WritableDraft<ResponsiveContainerStateWithActions>) => void), shouldReplace?: boolean | undefined, action?: string | {
|
|
8
8
|
type: unknown;
|
|
9
9
|
} | undefined): void;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type ResponsiveContainerStore = ReturnType<typeof createResponsiveContainerStore>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createStore as i } from "zustand";
|
|
2
|
+
import { devtools as m } from "zustand/middleware";
|
|
3
|
+
import { immer as n } from "zustand/middleware/immer";
|
|
4
|
+
const S = (r) => {
|
|
5
|
+
const s = {
|
|
6
|
+
...r
|
|
7
|
+
};
|
|
8
|
+
return i(
|
|
9
|
+
m(
|
|
10
|
+
n((t, p) => ({
|
|
11
|
+
...s,
|
|
12
|
+
responsiveContainerActions: {
|
|
13
|
+
setBreakpoint: (e) => {
|
|
14
|
+
t((o) => {
|
|
15
|
+
o.breakPoint = e, o.isUpSm = e !== "xs" && e !== "sm", o.isXs = e === "xs";
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
})),
|
|
20
|
+
{ name: "Responsive Relative Store" }
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
S as c
|
|
26
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export declare type BreakPointsType = Record<BreakpointType, number>;
|
|
1
|
+
export type BreakpointType = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
2
|
+
export type BreakPointsType = Record<BreakpointType, number>;
|
|
4
3
|
export interface ResponsiveRelativeContextProps {
|
|
5
4
|
breakPoint: BreakpointType;
|
|
6
5
|
}
|
|
@@ -8,7 +7,7 @@ export interface ResponsiveContainerProviderProps {
|
|
|
8
7
|
observedDivRef: Element | Text | null;
|
|
9
8
|
children: React.ReactNode;
|
|
10
9
|
}
|
|
11
|
-
export
|
|
10
|
+
export type CurrentState = {
|
|
12
11
|
width: number;
|
|
13
12
|
height: number;
|
|
14
13
|
mounted: boolean;
|
|
@@ -19,7 +18,7 @@ export interface ResponsiveContainerState {
|
|
|
19
18
|
isUpSm: boolean;
|
|
20
19
|
isXs: boolean;
|
|
21
20
|
}
|
|
22
|
-
export
|
|
21
|
+
export type InitialResponsiveContainerProps = Pick<ResponsiveContainerState, 'breakPoint' | 'isUpSm' | 'isXs'>;
|
|
23
22
|
export interface ResponsiveContainerStateWithActions extends ResponsiveContainerState {
|
|
24
23
|
responsiveContainerActions: {
|
|
25
24
|
setBreakpoint: (breakPoint: BreakpointType) => void;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const ThemeSettingsContext: import("react").Context<(Omit<Omit<import("zustand").StoreApi<import("./types").ThemeSettingsStateWithActions>, "setState"> & {
|
|
1
|
+
import { ThemeSettingsProviderProps } from './types';
|
|
2
|
+
declare const ThemeSettingsContext: import('react').Context<(Omit<Omit<import('zustand').StoreApi<import('./types').ThemeSettingsStateWithActions>, "setState"> & {
|
|
4
3
|
setState<A extends string | {
|
|
5
4
|
type: unknown;
|
|
6
|
-
}>(partial: import(
|
|
5
|
+
}>(partial: import('./types').ThemeSettingsStateWithActions | Partial<import('./types').ThemeSettingsStateWithActions> | ((state: import('./types').ThemeSettingsStateWithActions) => import('./types').ThemeSettingsStateWithActions | Partial<import('./types').ThemeSettingsStateWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
|
|
7
6
|
}, "setState"> & {
|
|
8
|
-
setState(nextStateOrUpdater: import(
|
|
7
|
+
setState(nextStateOrUpdater: import('./types').ThemeSettingsStateWithActions | Partial<import('./types').ThemeSettingsStateWithActions> | ((state: import('immer/dist/internal').WritableDraft<import('./types').ThemeSettingsStateWithActions>) => void), shouldReplace?: boolean | undefined, action?: string | {
|
|
9
8
|
type: unknown;
|
|
10
9
|
} | undefined): void;
|
|
11
10
|
}) | null>;
|
|
@@ -0,0 +1,32 @@
|
|
|
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";
|
|
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(
|
|
11
|
+
"theme_setting",
|
|
12
|
+
{}
|
|
13
|
+
), e = a();
|
|
14
|
+
return e.current || (e.current = h({
|
|
15
|
+
networkOperation: s,
|
|
16
|
+
currentThemeSettings: {
|
|
17
|
+
...l,
|
|
18
|
+
...t,
|
|
19
|
+
...n
|
|
20
|
+
},
|
|
21
|
+
themeOptions: p,
|
|
22
|
+
colorOption: S,
|
|
23
|
+
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 });
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
d as T,
|
|
31
|
+
b as a
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InitialThemeSettingsStoreProps, ThemeSettingsStateWithActions } from './types';
|
|
2
2
|
import { WritableDraft } from 'immer/dist/internal';
|
|
3
|
-
export declare const createThemeSettingsStore: (initialState: InitialThemeSettingsStoreProps) => Omit<Omit<import(
|
|
3
|
+
export declare const createThemeSettingsStore: (initialState: InitialThemeSettingsStoreProps) => Omit<Omit<import('zustand').StoreApi<ThemeSettingsStateWithActions>, "setState"> & {
|
|
4
4
|
setState<A extends string | {
|
|
5
5
|
type: unknown;
|
|
6
6
|
}>(partial: ThemeSettingsStateWithActions | Partial<ThemeSettingsStateWithActions> | ((state: ThemeSettingsStateWithActions) => ThemeSettingsStateWithActions | Partial<ThemeSettingsStateWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
|
|
@@ -9,4 +9,4 @@ export declare const createThemeSettingsStore: (initialState: InitialThemeSettin
|
|
|
9
9
|
type: unknown;
|
|
10
10
|
} | undefined): void;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type ThemeSettingsStore = ReturnType<typeof createThemeSettingsStore>;
|
|
@@ -0,0 +1,118 @@
|
|
|
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") {
|
|
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];
|
|
15
|
+
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}`);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
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,
|
|
26
|
+
palette: {
|
|
27
|
+
...n.themeOptions?.palette ?? {},
|
|
28
|
+
...e
|
|
29
|
+
},
|
|
30
|
+
shape: { borderRadius: 8 },
|
|
31
|
+
direction: r.themeDirection,
|
|
32
|
+
shadows: m ? h.light : h.dark,
|
|
33
|
+
customShadows: {
|
|
34
|
+
primary: `0 8px 16px 0 ${f(
|
|
35
|
+
a(r.themeColorPresets)?.main || "#fff",
|
|
36
|
+
0.2
|
|
37
|
+
)}`,
|
|
38
|
+
...d(r.themeMode)
|
|
39
|
+
},
|
|
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,
|
|
48
|
+
settingsActions: {
|
|
49
|
+
init: () => {
|
|
50
|
+
r((t) => {
|
|
51
|
+
o(t);
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
setThemeSettings: (t) => {
|
|
55
|
+
r((e) => {
|
|
56
|
+
e.currentThemeSettings = { ...e.currentThemeSettings, ...t }, i(e), o(e);
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
onChangeMode: (t) => {
|
|
60
|
+
r((e) => {
|
|
61
|
+
e.currentThemeSettings = {
|
|
62
|
+
...e.currentThemeSettings,
|
|
63
|
+
themeMode: t.target.value
|
|
64
|
+
}, i(e), o(e);
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
handleOpen: () => {
|
|
68
|
+
r((t) => {
|
|
69
|
+
t.open = !t.open;
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
onChangeDirection: (t) => {
|
|
73
|
+
r((e) => {
|
|
74
|
+
e.currentThemeSettings = {
|
|
75
|
+
...e.currentThemeSettings,
|
|
76
|
+
themeDirection: t.target.value
|
|
77
|
+
}, i(e), o(e);
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
onChangeColor: (t) => {
|
|
81
|
+
r((e) => {
|
|
82
|
+
e.currentThemeSettings = {
|
|
83
|
+
...e.currentThemeSettings,
|
|
84
|
+
themeColorPresets: t.target.value
|
|
85
|
+
}, i(e), o(e);
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
onChangeLayout: (t) => {
|
|
89
|
+
r((e) => {
|
|
90
|
+
e.currentThemeSettings = {
|
|
91
|
+
...e.currentThemeSettings,
|
|
92
|
+
themeLayout: t.target.value
|
|
93
|
+
}, i(e), o(e);
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
onToggleStretch: () => {
|
|
97
|
+
r((t) => {
|
|
98
|
+
t.currentThemeSettings = {
|
|
99
|
+
...t.currentThemeSettings,
|
|
100
|
+
themeStretch: !t.currentThemeSettings.themeStretch
|
|
101
|
+
}, i(t), o(t);
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
onResetSetting: () => {
|
|
105
|
+
r((t) => {
|
|
106
|
+
t.currentThemeSettings = {
|
|
107
|
+
...c
|
|
108
|
+
}, i(t), o(t);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
})),
|
|
113
|
+
{ name: "ThemeSettingsStore" }
|
|
114
|
+
)
|
|
115
|
+
);
|
|
116
|
+
export {
|
|
117
|
+
b as c
|
|
118
|
+
};
|
|
@@ -2,11 +2,11 @@ import { NetworkProps } from '@m4l/core';
|
|
|
2
2
|
import { OurTheme, PresetsOptions, ThemeColorOptionsType } from '@m4l/styles';
|
|
3
3
|
import { CssVarsTheme, Theme } from '@mui/material/styles';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
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
10
|
themeMode: ThemeMode;
|
|
11
11
|
themeDirection: ThemeDirection;
|
|
12
12
|
themeColorPresets: ThemeColorOptionsType;
|
|
@@ -19,8 +19,8 @@ export interface ThemeSettingsStore {
|
|
|
19
19
|
currentThemeSettings: ThemeSettingsType;
|
|
20
20
|
/**
|
|
21
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;
|
|
22
|
+
*/
|
|
23
|
+
themeOptions: (Omit<Theme, 'palette' | 'applyStyles'> & CssVarsTheme) | OurTheme;
|
|
24
24
|
colorOption: PresetsOptions;
|
|
25
25
|
/**
|
|
26
26
|
* "setterThemeSettings" es una función que se encarga de persistir en local storage los cambios de los settings
|
|
@@ -29,8 +29,8 @@ export interface ThemeSettingsStore {
|
|
|
29
29
|
setterThemeSettings?: (newValue: ThemeSettingsType) => void;
|
|
30
30
|
open: boolean;
|
|
31
31
|
}
|
|
32
|
-
export
|
|
33
|
-
export
|
|
32
|
+
export type DefaultThemeSettingsStoreProps = ThemeSettingsStore;
|
|
33
|
+
export type InitialThemeSettingsStoreProps = DefaultThemeSettingsStoreProps;
|
|
34
34
|
export interface ThemeSettingsStateWithActions extends ThemeSettingsStore {
|
|
35
35
|
settingsActions: {
|
|
36
36
|
init: () => void;
|
|
@@ -44,7 +44,7 @@ export interface ThemeSettingsStateWithActions extends ThemeSettingsStore {
|
|
|
44
44
|
setThemeSettings: (newValue: Partial<ThemeSettingsType>) => void;
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
export
|
|
47
|
+
export type ThemeSettingsProviderProps = {
|
|
48
48
|
themeSettings?: ThemeSettingsType;
|
|
49
49
|
children: ReactNode;
|
|
50
50
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/hooks/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useFormatter: () => import(
|
|
1
|
+
export declare const useFormatter: () => import('../..').Formatters;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as r } from "react";
|
|
2
|
+
import { F as e } from "../../contexts/FormatterContext/index.js";
|
|
3
|
+
const m = () => {
|
|
4
|
+
const t = r(e);
|
|
5
|
+
if (!t)
|
|
6
|
+
throw new Error("useFormatter context must be use inside FormatterProvider");
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
m as u
|
|
11
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useHostTheme: () => import(
|
|
1
|
+
export declare const useHostTheme: () => import('../..').HostThemeType;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as t } from "react";
|
|
2
|
+
import { H as o } from "../../contexts/HostThemeContext/index.js";
|
|
3
|
+
const m = () => {
|
|
4
|
+
const e = t(o);
|
|
5
|
+
if (!e)
|
|
6
|
+
throw new Error("useHostTheme context must be use inside HostThemeProvider");
|
|
7
|
+
return e;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
m as u
|
|
11
|
+
};
|