@m4l/graphics 1.0.7 → 1.0.9
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/index.d8d41b1b.js +1 -0
- package/contexts/HostThemeContext/index.02e36f38.js +44 -0
- package/contexts/HostThemeContext/types.d.ts +1 -1
- package/contexts/ResponsiveContainerContext/constants.d.ts +1 -1
- package/contexts/ResponsiveContainerContext/types.d.ts +2 -1
- package/contexts/ThemeSettingsContext/ThemeSettingsContext.d.ts +13 -0
- package/contexts/ThemeSettingsContext/constants.d.ts +2 -0
- package/contexts/ThemeSettingsContext/index.d.ts +3 -0
- package/contexts/ThemeSettingsContext/store.d.ts +12 -0
- package/contexts/ThemeSettingsContext/types.d.ts +50 -0
- package/contexts/index.1d935da9.js +279 -0
- package/contexts/index.d.ts +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.e4fb3c4e.js +54 -0
- package/hooks/useIsMobile/{index.e9f29b1d.js → index.1afbcd66.js} +4 -10
- package/hooks/useResponsive/{index.b336bec4.js → index.0881f166.js} +2 -2
- package/hooks/useThemSettingsStore/index.d.ts +2 -0
- package/index.js +39 -34
- package/package.json +1 -1
- package/vite-env.d.ts +1 -1
- package/components/index.8083534b.js +0 -4
- package/contexts/HostThemeContext/index.f53d14b8.js +0 -44
- package/contexts/index.68603471.js +0 -73
- package/hooks/index.eebf9e43.js +0 -50
- /package/{node_modules.9eeccca4.js → node_modules.7cdb697c.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createContext as c, useMemo as h } from "react";
|
|
2
|
+
import { CssBaseline as a } from "@mui/material";
|
|
3
|
+
import { G as d } from "../../components/GlobalStyle/index.b7393a44.js";
|
|
4
|
+
import { createTheme as p, experimental_extendTheme as x, Experimental_CssVarsProvider as f, StyledEngineProvider as T } from "@mui/material/styles";
|
|
5
|
+
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
6
|
+
const u = c(null);
|
|
7
|
+
function H(m) {
|
|
8
|
+
const {
|
|
9
|
+
children: i,
|
|
10
|
+
hostThemeOptions: l,
|
|
11
|
+
fnComponentsOverrides: o
|
|
12
|
+
} = m, n = h(() => {
|
|
13
|
+
const e = p({
|
|
14
|
+
...l
|
|
15
|
+
}), r = x({
|
|
16
|
+
cssVarPrefix: "m4l",
|
|
17
|
+
colorSchemes: {
|
|
18
|
+
light: e,
|
|
19
|
+
finalTheme: e,
|
|
20
|
+
dark: e
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return r.components = o(r), r;
|
|
24
|
+
}, []);
|
|
25
|
+
return /* @__PURE__ */ s(f, {
|
|
26
|
+
theme: n,
|
|
27
|
+
children: [/* @__PURE__ */ t(d, {}), /* @__PURE__ */ t(u.Provider, {
|
|
28
|
+
value: {
|
|
29
|
+
hostThemeOptions: n,
|
|
30
|
+
fnComponentsOverrides: o
|
|
31
|
+
},
|
|
32
|
+
children: /* @__PURE__ */ s(T, {
|
|
33
|
+
injectFirst: !0,
|
|
34
|
+
children: [/* @__PURE__ */ t(a, {
|
|
35
|
+
enableColorScheme: !0
|
|
36
|
+
}), i]
|
|
37
|
+
})
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
u as H,
|
|
43
|
+
H as a
|
|
44
|
+
};
|
|
@@ -3,7 +3,7 @@ import type { ReactNode } from 'react';
|
|
|
3
3
|
export declare type EventFunListener = (...args: any[]) => void;
|
|
4
4
|
export interface HostThemeType {
|
|
5
5
|
hostThemeOptions: Theme;
|
|
6
|
-
fnComponentsOverrides: (theme: Omit<Theme,
|
|
6
|
+
fnComponentsOverrides: (theme: Omit<Theme, 'palette' | 'applyStyles'> & CssVarsTheme) => any;
|
|
7
7
|
}
|
|
8
8
|
export interface HostThemeProviderProps extends HostThemeType {
|
|
9
9
|
isMicroFrontEnd: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BreakPointsType } from
|
|
1
|
+
import { BreakPointsType } from "./types";
|
|
2
2
|
export declare const BREAKPOINTS: BreakPointsType;
|
|
@@ -19,7 +19,8 @@ export interface ResponsiveContainerState {
|
|
|
19
19
|
isUpSm: boolean;
|
|
20
20
|
isXs: boolean;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
22
|
+
export interface InitialResponsiveContainerProps extends Pick<ResponsiveContainerState, 'breakPoint' | 'isUpSm' | 'isXs'> {
|
|
23
|
+
}
|
|
23
24
|
export interface ResponsiveContainerStateWithActions extends ResponsiveContainerState {
|
|
24
25
|
responsiveContainerActions: {
|
|
25
26
|
setBreakpoint: (breakPoint: BreakpointType) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ThemeSettingsProviderProps } from './types';
|
|
3
|
+
declare const ThemeSettingsContext: import("react").Context<(Omit<Omit<import("zustand").StoreApi<import("./types").ThemeSettingsStateWithActions>, "setState"> & {
|
|
4
|
+
setState<A extends string | {
|
|
5
|
+
type: unknown;
|
|
6
|
+
}>(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
|
+
}, "setState"> & {
|
|
8
|
+
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
|
+
type: unknown;
|
|
10
|
+
} | undefined): void;
|
|
11
|
+
}) | null>;
|
|
12
|
+
declare function ThemeSettingsProvider({ children, themeSettings }: ThemeSettingsProviderProps): import("react").JSX.Element;
|
|
13
|
+
export { ThemeSettingsProvider, ThemeSettingsContext };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InitialThemeSettingsStoreProps, ThemeSettingsStateWithActions } from './types';
|
|
2
|
+
import { WritableDraft } from 'immer/dist/internal';
|
|
3
|
+
export declare const createThemeSettingsStore: (initialState: InitialThemeSettingsStoreProps) => Omit<Omit<import("zustand").StoreApi<ThemeSettingsStateWithActions>, "setState"> & {
|
|
4
|
+
setState<A extends string | {
|
|
5
|
+
type: unknown;
|
|
6
|
+
}>(partial: ThemeSettingsStateWithActions | Partial<ThemeSettingsStateWithActions> | ((state: ThemeSettingsStateWithActions) => ThemeSettingsStateWithActions | Partial<ThemeSettingsStateWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
|
|
7
|
+
}, "setState"> & {
|
|
8
|
+
setState(nextStateOrUpdater: ThemeSettingsStateWithActions | Partial<ThemeSettingsStateWithActions> | ((state: WritableDraft<ThemeSettingsStateWithActions>) => void), shouldReplace?: boolean | undefined, action?: string | {
|
|
9
|
+
type: unknown;
|
|
10
|
+
} | undefined): void;
|
|
11
|
+
};
|
|
12
|
+
export declare type ThemeSettingsStore = ReturnType<typeof createThemeSettingsStore>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { NetworkProps } from '@m4l/core';
|
|
2
|
+
import { ThemeColorPresets } from '@m4l/styles';
|
|
3
|
+
import { CssVarsTheme, Theme, PaletteColor } from '@mui/material/styles';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
export declare type ThemeMode = 'light' | 'dark';
|
|
6
|
+
export declare type ThemeDirection = 'rtl' | 'ltr';
|
|
7
|
+
export declare type ThemeLayout = 'vertical' | 'horizontal';
|
|
8
|
+
export declare type ThemeStretch = boolean;
|
|
9
|
+
export declare type ThemeSettingsType = {
|
|
10
|
+
themeMode: ThemeMode;
|
|
11
|
+
themeDirection: ThemeDirection;
|
|
12
|
+
themeColorPresets: ThemeColorPresets;
|
|
13
|
+
themeStretch: ThemeStretch;
|
|
14
|
+
themeLayout: ThemeLayout;
|
|
15
|
+
};
|
|
16
|
+
export interface ThemeSettingsStore {
|
|
17
|
+
networkOperation: (props: NetworkProps) => Promise<any>;
|
|
18
|
+
currentThemeSettings: ThemeSettingsType;
|
|
19
|
+
currentPreset: PaletteColor;
|
|
20
|
+
themeOptions: Omit<Theme, 'palette' | 'applyStyles'> & CssVarsTheme;
|
|
21
|
+
colorOption: {
|
|
22
|
+
name: string | undefined;
|
|
23
|
+
value: string;
|
|
24
|
+
}[];
|
|
25
|
+
/**
|
|
26
|
+
* "setterThemeSettings" es una función que se encarga de persistir en local storage los cambios de los settings
|
|
27
|
+
* Solo se instancia cuando esta en host, cuando esta storybook no se instancia
|
|
28
|
+
*/
|
|
29
|
+
setterThemeSettings?: (newValue: ThemeSettingsType) => void;
|
|
30
|
+
open: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare type DefaultThemeSettingsStoreProps = ThemeSettingsStore;
|
|
33
|
+
export declare type InitialThemeSettingsStoreProps = DefaultThemeSettingsStoreProps;
|
|
34
|
+
export interface ThemeSettingsStateWithActions extends ThemeSettingsStore {
|
|
35
|
+
settingsActions: {
|
|
36
|
+
init: () => void;
|
|
37
|
+
onToggleStretch: VoidFunction;
|
|
38
|
+
onResetSetting: VoidFunction;
|
|
39
|
+
onChangeMode: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
40
|
+
onChangeDirection: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
41
|
+
onChangeColor: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
42
|
+
onChangeLayout: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
43
|
+
handleOpen: () => void;
|
|
44
|
+
setThemeSettings: (newValue: Partial<ThemeSettingsType>) => void;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export declare type ThemeSettingsProviderProps = {
|
|
48
|
+
themeSettings?: ThemeSettingsType;
|
|
49
|
+
children: ReactNode;
|
|
50
|
+
};
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { createContext as f, useRef as T, useMemo as k, useLayoutEffect as y, useEffect as b } from "react";
|
|
2
|
+
import { c as v, d as R, i as P, l as M } from "../node_modules.7cdb697c.js";
|
|
3
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
4
|
+
import { useNetwork as E, useLocalStorageWithListener as w } from "@m4l/core";
|
|
5
|
+
import { getColorPresets as m, getColorState as d, typography as L, palette as S, SECONDARY as A, COMMON as N, ERROR as D, WARNING as z, INFO as W, SUCCESS as B, shadows as p, createCustomShadows as $, defaultThemeOptions as j, defaultPreset as _, colorPresets as F } from "@m4l/styles";
|
|
6
|
+
import { alpha as I } from "@mui/system";
|
|
7
|
+
import { u as U } from "../hooks/useFirstRender/index.1e9b02fb.js";
|
|
8
|
+
const C = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, K = (r) => {
|
|
9
|
+
const t = {
|
|
10
|
+
...r
|
|
11
|
+
};
|
|
12
|
+
return v(
|
|
13
|
+
R(
|
|
14
|
+
P((o, n) => ({
|
|
15
|
+
...t,
|
|
16
|
+
responsiveContainerActions: {
|
|
17
|
+
setBreakpoint: (e) => {
|
|
18
|
+
o(
|
|
19
|
+
(i) => {
|
|
20
|
+
console.log("current breakpoint", e), i.breakPoint = e, i.isUpSm = e !== "xs" && e !== "sm", i.isXs = e == "xs";
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
})),
|
|
26
|
+
{ name: "Responsive Relative Store" }
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
}, X = f(null), te = (r) => {
|
|
30
|
+
const {
|
|
31
|
+
children: t,
|
|
32
|
+
observedDivRef: o
|
|
33
|
+
} = r, n = T();
|
|
34
|
+
n.current || (n.current = K({
|
|
35
|
+
breakPoint: "md",
|
|
36
|
+
isUpSm: !1,
|
|
37
|
+
isXs: !1
|
|
38
|
+
}));
|
|
39
|
+
const e = () => {
|
|
40
|
+
const s = o;
|
|
41
|
+
if (s instanceof HTMLElement && s.clientWidth) {
|
|
42
|
+
const c = Object.keys(C);
|
|
43
|
+
for (let l = 0; l < c.length; l++) {
|
|
44
|
+
const g = c[l];
|
|
45
|
+
if (s.clientWidth <= C[g]) {
|
|
46
|
+
n.current?.getState().responsiveContainerActions.setBreakpoint(g);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
console.log("node.clientWidth", s.clientWidth), console.log("onResizeMemo", n.current?.getState().breakPoint);
|
|
51
|
+
}
|
|
52
|
+
}, i = k(() => M.exports.throttle(e, 200, {
|
|
53
|
+
leading: !1,
|
|
54
|
+
trailing: !0
|
|
55
|
+
}), [e]);
|
|
56
|
+
return y(() => {
|
|
57
|
+
const s = () => {
|
|
58
|
+
i();
|
|
59
|
+
}, c = o;
|
|
60
|
+
if (c && c instanceof Element) {
|
|
61
|
+
const l = new ResizeObserver((g) => {
|
|
62
|
+
s();
|
|
63
|
+
});
|
|
64
|
+
return l.observe(c), () => {
|
|
65
|
+
l.disconnect();
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}, [o]), /* @__PURE__ */ x(X.Provider, {
|
|
69
|
+
value: n.current,
|
|
70
|
+
children: t
|
|
71
|
+
});
|
|
72
|
+
}, u = {
|
|
73
|
+
themeMode: "light",
|
|
74
|
+
themeDirection: "ltr",
|
|
75
|
+
themeColorPresets: "patronus",
|
|
76
|
+
themeLayout: "horizontal",
|
|
77
|
+
themeStretch: !1
|
|
78
|
+
};
|
|
79
|
+
function O(r, t = "m4l") {
|
|
80
|
+
const o = document.querySelector('[data-mui-color-scheme="light"]');
|
|
81
|
+
if (!o) {
|
|
82
|
+
console.error('Element with data-mui-color-scheme="light" not found.');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
Object.keys(r).forEach((n) => {
|
|
86
|
+
const e = r[n];
|
|
87
|
+
if (typeof e == "string" || typeof e == "number") {
|
|
88
|
+
const i = `--${t}-${n}`;
|
|
89
|
+
o.style.setProperty(i, e.toString());
|
|
90
|
+
} else
|
|
91
|
+
typeof e == "object" && e !== null && O(e, `${t}-${n}`);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const a = (r) => {
|
|
95
|
+
const t = r.currentThemeSettings || u;
|
|
96
|
+
console.log("getColorPresets", m(t.themeColorPresets)), console.log(
|
|
97
|
+
"getColorState",
|
|
98
|
+
d(t.themeColorPresets, t.themeMode)
|
|
99
|
+
);
|
|
100
|
+
const o = t.themeMode === "light";
|
|
101
|
+
r.themeOptions = {
|
|
102
|
+
...r.themeOptions,
|
|
103
|
+
typography: L,
|
|
104
|
+
palette: {
|
|
105
|
+
...r.themeOptions.palette,
|
|
106
|
+
...o ? S.light : S.dark,
|
|
107
|
+
primary: m(t.themeColorPresets),
|
|
108
|
+
state: d(t.themeColorPresets, t.themeMode),
|
|
109
|
+
representative: t.themeMode === "light" ? m(t.themeColorPresets)?.light : m(t.themeColorPresets)?.darker,
|
|
110
|
+
secondary: {
|
|
111
|
+
...A,
|
|
112
|
+
contrastText: "",
|
|
113
|
+
mainChannel: "",
|
|
114
|
+
lightChannel: "",
|
|
115
|
+
darkChannel: "",
|
|
116
|
+
contrastTextChannel: ""
|
|
117
|
+
},
|
|
118
|
+
common: {
|
|
119
|
+
...N,
|
|
120
|
+
black: "#000",
|
|
121
|
+
white: "#fff",
|
|
122
|
+
background: "",
|
|
123
|
+
backgroundChannel: "",
|
|
124
|
+
onBackground: "",
|
|
125
|
+
onBackgroundChannel: ""
|
|
126
|
+
},
|
|
127
|
+
error: {
|
|
128
|
+
...D,
|
|
129
|
+
contrastText: "",
|
|
130
|
+
mainChannel: "",
|
|
131
|
+
lightChannel: "",
|
|
132
|
+
darkChannel: "",
|
|
133
|
+
contrastTextChannel: ""
|
|
134
|
+
},
|
|
135
|
+
warning: {
|
|
136
|
+
...z,
|
|
137
|
+
contrastText: "",
|
|
138
|
+
mainChannel: "",
|
|
139
|
+
lightChannel: "",
|
|
140
|
+
darkChannel: "",
|
|
141
|
+
contrastTextChannel: ""
|
|
142
|
+
},
|
|
143
|
+
info: {
|
|
144
|
+
...W,
|
|
145
|
+
contrastText: "",
|
|
146
|
+
mainChannel: "",
|
|
147
|
+
lightChannel: "",
|
|
148
|
+
darkChannel: "",
|
|
149
|
+
contrastTextChannel: ""
|
|
150
|
+
},
|
|
151
|
+
success: {
|
|
152
|
+
...B,
|
|
153
|
+
contrastText: "",
|
|
154
|
+
mainChannel: "",
|
|
155
|
+
lightChannel: "",
|
|
156
|
+
darkChannel: "",
|
|
157
|
+
contrastTextChannel: ""
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
shape: { borderRadius: 8 },
|
|
161
|
+
direction: t.themeDirection,
|
|
162
|
+
shadows: o ? p.light : p.dark,
|
|
163
|
+
customShadows: {
|
|
164
|
+
primary: `0 8px 16px 0 ${I(
|
|
165
|
+
m(t.themeColorPresets)?.main || "#fff",
|
|
166
|
+
0.2
|
|
167
|
+
)}`,
|
|
168
|
+
...$(t.themeMode)
|
|
169
|
+
},
|
|
170
|
+
stretch: t.themeStretch
|
|
171
|
+
}, console.log("state.themeOptions", r.themeOptions), O(r.themeOptions);
|
|
172
|
+
}, h = (r) => {
|
|
173
|
+
r.setterThemeSettings && r.setterThemeSettings(r.currentThemeSettings);
|
|
174
|
+
}, q = (r) => v(
|
|
175
|
+
R(
|
|
176
|
+
P((t, o) => ({
|
|
177
|
+
...r,
|
|
178
|
+
settingsActions: {
|
|
179
|
+
init: () => {
|
|
180
|
+
t((n) => {
|
|
181
|
+
a(n);
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
setThemeSettings: (n) => {
|
|
185
|
+
t((e) => {
|
|
186
|
+
e.currentThemeSettings = { ...e.currentThemeSettings, ...n }, h(e), a(e);
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
onChangeMode: (n) => {
|
|
190
|
+
t((e) => {
|
|
191
|
+
e.currentThemeSettings = {
|
|
192
|
+
...e.currentThemeSettings,
|
|
193
|
+
themeMode: n.target.value
|
|
194
|
+
}, h(e), a(e);
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
handleOpen: () => {
|
|
198
|
+
t((n) => {
|
|
199
|
+
n.open = !n.open;
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
onChangeDirection: (n) => {
|
|
203
|
+
t((e) => {
|
|
204
|
+
e.currentThemeSettings = {
|
|
205
|
+
...e.currentThemeSettings,
|
|
206
|
+
themeDirection: n.target.value
|
|
207
|
+
}, h(e), a(e);
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
onChangeColor: (n) => {
|
|
211
|
+
t((e) => {
|
|
212
|
+
e.currentThemeSettings = {
|
|
213
|
+
...e.currentThemeSettings,
|
|
214
|
+
themeColorPresets: n.target.value
|
|
215
|
+
}, h(e), a(e);
|
|
216
|
+
});
|
|
217
|
+
},
|
|
218
|
+
onChangeLayout: (n) => {
|
|
219
|
+
t((e) => {
|
|
220
|
+
e.currentThemeSettings = {
|
|
221
|
+
...e.currentThemeSettings,
|
|
222
|
+
themeLayout: n.target.value
|
|
223
|
+
}, h(e), a(e);
|
|
224
|
+
});
|
|
225
|
+
},
|
|
226
|
+
onToggleStretch: () => {
|
|
227
|
+
t((n) => {
|
|
228
|
+
n.currentThemeSettings = {
|
|
229
|
+
...n.currentThemeSettings,
|
|
230
|
+
themeStretch: !n.currentThemeSettings.themeStretch
|
|
231
|
+
}, h(n), a(n);
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
onResetSetting: () => {
|
|
235
|
+
t((n) => {
|
|
236
|
+
n.currentThemeSettings = {
|
|
237
|
+
...u
|
|
238
|
+
}, h(n), a(n);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
})),
|
|
243
|
+
{ name: "ExampleStore" }
|
|
244
|
+
)
|
|
245
|
+
), G = f(null);
|
|
246
|
+
function ne({
|
|
247
|
+
children: r,
|
|
248
|
+
themeSettings: t
|
|
249
|
+
}) {
|
|
250
|
+
const {
|
|
251
|
+
networkOperation: o
|
|
252
|
+
} = E(), [n, e] = w("theme_setting", u), i = U([t]), s = T();
|
|
253
|
+
return s.current || (s.current = q({
|
|
254
|
+
networkOperation: o,
|
|
255
|
+
currentThemeSettings: {
|
|
256
|
+
...t ?? n
|
|
257
|
+
},
|
|
258
|
+
themeOptions: j,
|
|
259
|
+
currentPreset: _,
|
|
260
|
+
colorOption: F.map((c) => ({
|
|
261
|
+
name: c.name,
|
|
262
|
+
value: c.main
|
|
263
|
+
})),
|
|
264
|
+
open: !1,
|
|
265
|
+
setterThemeSettings: t ? void 0 : e
|
|
266
|
+
}), s.current.getState().settingsActions.init()), b(() => {
|
|
267
|
+
!i && s.current && t && s.current.getState().settingsActions.setThemeSettings(t);
|
|
268
|
+
}, [t]), /* @__PURE__ */ x(G.Provider, {
|
|
269
|
+
value: s.current,
|
|
270
|
+
children: r
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
export {
|
|
274
|
+
X as R,
|
|
275
|
+
G as T,
|
|
276
|
+
te as a,
|
|
277
|
+
ne as b,
|
|
278
|
+
u as d
|
|
279
|
+
};
|
package/contexts/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export type { BreakpointType } from './ResponsiveContainerContext/types';
|
|
|
6
6
|
export type { NetworkLocaleType, LocaleType } from './LocalesContext/types';
|
|
7
7
|
export { getLocaleFromNetwork } from './LocalesContext/helper';
|
|
8
8
|
export * from './HostThemeContext';
|
|
9
|
+
export * from './ThemeSettingsContext';
|
|
9
10
|
export type { HostThemeType } from './HostThemeContext/types';
|
package/hooks/index.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export { useOffSetTop } from './useOffSetTop';
|
|
|
8
8
|
export { useHostTheme } from './useHostTheme';
|
|
9
9
|
export { useResizeObserver } from './useResizeObserver';
|
|
10
10
|
export { useResponsiveDesktop } from './useResponsive';
|
|
11
|
+
export { useThemeSettingsStore } from './useThemSettingsStore';
|
|
@@ -0,0 +1,54 @@
|
|
|
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.02e36f38.js";
|
|
3
|
+
import { u as a } from "../node_modules.7cdb697c.js";
|
|
4
|
+
import { T as l } from "../contexts/index.1d935da9.js";
|
|
5
|
+
function S() {
|
|
6
|
+
const e = n(!0);
|
|
7
|
+
return r(
|
|
8
|
+
() => () => {
|
|
9
|
+
e.current = !1;
|
|
10
|
+
},
|
|
11
|
+
[]
|
|
12
|
+
), e;
|
|
13
|
+
}
|
|
14
|
+
function x(e) {
|
|
15
|
+
const [s, t] = i(!1), o = e || 100;
|
|
16
|
+
return r(() => (window.onscroll = () => {
|
|
17
|
+
window.pageYOffset > o ? t(!0) : t(!1);
|
|
18
|
+
}, () => {
|
|
19
|
+
window.onscroll = null;
|
|
20
|
+
}), [o]), s;
|
|
21
|
+
}
|
|
22
|
+
const h = () => {
|
|
23
|
+
const e = u(m);
|
|
24
|
+
if (!e)
|
|
25
|
+
throw new Error("useHostTheme context must be use inside HostThemeProvider");
|
|
26
|
+
return e;
|
|
27
|
+
};
|
|
28
|
+
function b(e) {
|
|
29
|
+
const s = n(null);
|
|
30
|
+
return c(() => {
|
|
31
|
+
const t = s?.current;
|
|
32
|
+
if (!t)
|
|
33
|
+
return;
|
|
34
|
+
const o = new ResizeObserver((f) => {
|
|
35
|
+
e(t, f[0]);
|
|
36
|
+
});
|
|
37
|
+
return o.observe(t), () => {
|
|
38
|
+
o.disconnect();
|
|
39
|
+
};
|
|
40
|
+
}, [e, s.current]), s;
|
|
41
|
+
}
|
|
42
|
+
function g(e, s) {
|
|
43
|
+
const t = u(l);
|
|
44
|
+
if (!t)
|
|
45
|
+
throw new Error("useSettingsStore context must be use inside SettignsContext");
|
|
46
|
+
return a(t, e, s);
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
x as a,
|
|
50
|
+
h as b,
|
|
51
|
+
b as c,
|
|
52
|
+
g as d,
|
|
53
|
+
S as u
|
|
54
|
+
};
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { useState as n, useEffect as o } from "react";
|
|
2
|
-
import { t as s } from "../../node_modules.
|
|
2
|
+
import { t as s } from "../../node_modules.7cdb697c.js";
|
|
3
3
|
const t = () => typeof navigator > "u" ? !1 : /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), l = () => {
|
|
4
4
|
const [i, r] = n(t());
|
|
5
5
|
return o(() => {
|
|
6
|
-
const e = s(
|
|
7
|
-
()
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
200,
|
|
11
|
-
{
|
|
12
|
-
trailing: !0
|
|
13
|
-
}
|
|
14
|
-
);
|
|
6
|
+
const e = s(() => {
|
|
7
|
+
r(t());
|
|
8
|
+
}, 200);
|
|
15
9
|
return window.addEventListener("resize", e), e(), () => {
|
|
16
10
|
window.removeEventListener("resize", e), e.cancel();
|
|
17
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext as t } from "react";
|
|
2
|
-
import { u as r } from "../../node_modules.
|
|
3
|
-
import { R as n } from "../../contexts/index.
|
|
2
|
+
import { u as r } from "../../node_modules.7cdb697c.js";
|
|
3
|
+
import { R as n } from "../../contexts/index.1d935da9.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,47 +1,52 @@
|
|
|
1
1
|
import { G as l } from "./components/GlobalStyle/index.b7393a44.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { R as
|
|
5
|
-
import { H, a as
|
|
6
|
-
import { u as
|
|
7
|
-
import { u as
|
|
8
|
-
import { b as
|
|
9
|
-
import { u as
|
|
10
|
-
import { u as
|
|
11
|
-
import { u as
|
|
12
|
-
import { C as
|
|
2
|
+
import { L as C, a as T, g } from "./contexts/LocalesContext/index.53f0b702.js";
|
|
3
|
+
import { F as R, a as S } from "./contexts/FormatterContext/index.92336f4c.js";
|
|
4
|
+
import { R as F, a as P, T as b, b as L, d as H } from "./contexts/index.1d935da9.js";
|
|
5
|
+
import { H as w, a as z } from "./contexts/HostThemeContext/index.02e36f38.js";
|
|
6
|
+
import { u as I } from "./hooks/useFirstRender/index.1e9b02fb.js";
|
|
7
|
+
import { u as O } from "./hooks/useFormatter/index.57ac8cca.js";
|
|
8
|
+
import { b as A, u as D, a as E, c as N, d as W } from "./hooks/index.e4fb3c4e.js";
|
|
9
|
+
import { u as q } from "./hooks/useLocales/index.d5a80aff.js";
|
|
10
|
+
import { u as J, a as K } from "./hooks/useResponsive/index.0881f166.js";
|
|
11
|
+
import { u as U } from "./hooks/useIsMobile/index.1afbcd66.js";
|
|
12
|
+
import { C as X, g as Y } from "./utils/index.6909c662.js";
|
|
13
13
|
import "@mui/material/styles";
|
|
14
14
|
import "@mui/material";
|
|
15
15
|
import "@m4l/styles";
|
|
16
16
|
import "react/jsx-runtime";
|
|
17
17
|
import "react";
|
|
18
|
-
import "@m4l/core";
|
|
19
18
|
import "@mui/x-date-pickers/AdapterDateFns";
|
|
20
19
|
import "@mui/x-date-pickers";
|
|
20
|
+
import "@m4l/core";
|
|
21
21
|
import "date-fns/locale/en-US";
|
|
22
|
-
import "./node_modules.
|
|
22
|
+
import "./node_modules.7cdb697c.js";
|
|
23
23
|
import "./commonjs.e3daa2e5.js";
|
|
24
|
+
import "@mui/system";
|
|
24
25
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
X as Capitalize,
|
|
27
|
+
R as FormatterContext,
|
|
28
|
+
S as FormatterProvider,
|
|
28
29
|
l as GlobalStyles,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
L as
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
w as HostThemeContext,
|
|
31
|
+
z as HostThemeProvider,
|
|
32
|
+
C as LocalesContext,
|
|
33
|
+
T as LocalesProvider,
|
|
34
|
+
F as ResponsiveContainerContext,
|
|
35
|
+
P as ResponsiveContainerProvider,
|
|
36
|
+
b as ThemeSettingsContext,
|
|
37
|
+
L as ThemeSettingsProvider,
|
|
38
|
+
H as defaultThemeSettings,
|
|
39
|
+
Y as getAnchorElPositionWindow,
|
|
40
|
+
g as getLocaleFromNetwork,
|
|
41
|
+
I as useFirstRender,
|
|
42
|
+
O as useFormatter,
|
|
43
|
+
A as useHostTheme,
|
|
44
|
+
U as useIsMobile,
|
|
45
|
+
D as useIsMountedRef,
|
|
46
|
+
q as useLocales,
|
|
47
|
+
E as useOffSetTop,
|
|
48
|
+
N as useResizeObserver,
|
|
49
|
+
J as useResponsiveContainerStore,
|
|
50
|
+
K as useResponsiveDesktop,
|
|
51
|
+
W as useThemeSettingsStore
|
|
47
52
|
};
|
package/package.json
CHANGED
package/vite-env.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { createContext as c, useMemo as a } from "react";
|
|
2
|
-
import { CssBaseline as h } from "@mui/material";
|
|
3
|
-
import { G as d } from "../../components/GlobalStyle/index.b7393a44.js";
|
|
4
|
-
import { createTheme as p, experimental_extendTheme as f, Experimental_CssVarsProvider as x, StyledEngineProvider as T } from "@mui/material/styles";
|
|
5
|
-
import { jsxs as m, jsx as o } from "react/jsx-runtime";
|
|
6
|
-
const u = c(null);
|
|
7
|
-
function j(i) {
|
|
8
|
-
const {
|
|
9
|
-
children: l,
|
|
10
|
-
hostThemeOptions: t,
|
|
11
|
-
fnComponentsOverrides: n
|
|
12
|
-
} = i, e = p({
|
|
13
|
-
...t
|
|
14
|
-
}), s = a(() => {
|
|
15
|
-
const r = f({
|
|
16
|
-
cssVarPrefix: "m4l",
|
|
17
|
-
colorSchemes: {
|
|
18
|
-
light: e,
|
|
19
|
-
finalTheme: e,
|
|
20
|
-
dark: e
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
return r.components = n(r), r;
|
|
24
|
-
}, []);
|
|
25
|
-
return console.log("finalTheme", s), /* @__PURE__ */ m(x, {
|
|
26
|
-
theme: s,
|
|
27
|
-
children: [/* @__PURE__ */ o(d, {}), /* @__PURE__ */ o(u.Provider, {
|
|
28
|
-
value: {
|
|
29
|
-
hostThemeOptions: t,
|
|
30
|
-
fnComponentsOverrides: n
|
|
31
|
-
},
|
|
32
|
-
children: /* @__PURE__ */ m(T, {
|
|
33
|
-
injectFirst: !0,
|
|
34
|
-
children: [/* @__PURE__ */ o(h, {
|
|
35
|
-
enableColorScheme: !0
|
|
36
|
-
}), l]
|
|
37
|
-
})
|
|
38
|
-
})]
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
export {
|
|
42
|
-
u as H,
|
|
43
|
-
j as a
|
|
44
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import "./FormatterContext/index.92336f4c.js";
|
|
2
|
-
import "./LocalesContext/index.53f0b702.js";
|
|
3
|
-
import { createContext as p, useRef as v, useMemo as f, useLayoutEffect as d } from "react";
|
|
4
|
-
import { c as R, d as u, i as x, l as h } from "../node_modules.9eeccca4.js";
|
|
5
|
-
import { jsx as S } from "react/jsx-runtime";
|
|
6
|
-
import "date-fns/locale/en-US";
|
|
7
|
-
import "./HostThemeContext/index.f53d14b8.js";
|
|
8
|
-
const m = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, b = (c) => {
|
|
9
|
-
const a = {
|
|
10
|
-
...c
|
|
11
|
-
};
|
|
12
|
-
return R(
|
|
13
|
-
u(
|
|
14
|
-
x((o, n) => ({
|
|
15
|
-
...a,
|
|
16
|
-
responsiveContainerActions: {
|
|
17
|
-
setBreakpoint: (e) => {
|
|
18
|
-
o((r) => {
|
|
19
|
-
r.breakPoint = e, r.isUpSm = e !== "xs" && e !== "sm", r.isXs = e == "xs";
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
})),
|
|
24
|
-
{ name: "Responsive Relative Store" }
|
|
25
|
-
)
|
|
26
|
-
);
|
|
27
|
-
}, C = p(null), B = (c) => {
|
|
28
|
-
const {
|
|
29
|
-
children: a,
|
|
30
|
-
observedDivRef: o
|
|
31
|
-
} = c, n = v();
|
|
32
|
-
n.current || (n.current = b({
|
|
33
|
-
breakPoint: "md",
|
|
34
|
-
isUpSm: !1,
|
|
35
|
-
isXs: !1
|
|
36
|
-
}));
|
|
37
|
-
const e = () => {
|
|
38
|
-
const i = o;
|
|
39
|
-
if (i instanceof HTMLElement && i.clientWidth) {
|
|
40
|
-
const t = Object.keys(m);
|
|
41
|
-
for (let s = 0; s < t.length; s++) {
|
|
42
|
-
const l = t[s];
|
|
43
|
-
if (i.clientWidth <= m[l]) {
|
|
44
|
-
n.current?.getState().responsiveContainerActions.setBreakpoint(l);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}, r = f(() => h.exports.throttle(e, 200, {
|
|
50
|
-
leading: !1,
|
|
51
|
-
trailing: !0
|
|
52
|
-
}), [e]);
|
|
53
|
-
return d(() => {
|
|
54
|
-
const i = () => {
|
|
55
|
-
r();
|
|
56
|
-
}, t = o;
|
|
57
|
-
if (t && t instanceof Element) {
|
|
58
|
-
const s = new ResizeObserver((l) => {
|
|
59
|
-
i();
|
|
60
|
-
});
|
|
61
|
-
return s.observe(t), () => {
|
|
62
|
-
s.disconnect();
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}, [o]), /* @__PURE__ */ S(C.Provider, {
|
|
66
|
-
value: n.current,
|
|
67
|
-
children: a
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
export {
|
|
71
|
-
C as R,
|
|
72
|
-
B as a
|
|
73
|
-
};
|
package/hooks/index.eebf9e43.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { useRef as r, useEffect as n, useState as f, useContext as i, useLayoutEffect as c } from "react";
|
|
2
|
-
import { H as m } from "../contexts/HostThemeContext/index.f53d14b8.js";
|
|
3
|
-
import "../contexts/FormatterContext/index.92336f4c.js";
|
|
4
|
-
import "../contexts/LocalesContext/index.53f0b702.js";
|
|
5
|
-
import "../contexts/index.68603471.js";
|
|
6
|
-
import "../node_modules.9eeccca4.js";
|
|
7
|
-
import "@m4l/styles";
|
|
8
|
-
function h() {
|
|
9
|
-
const e = r(!0);
|
|
10
|
-
return n(
|
|
11
|
-
() => () => {
|
|
12
|
-
e.current = !1;
|
|
13
|
-
},
|
|
14
|
-
[]
|
|
15
|
-
), e;
|
|
16
|
-
}
|
|
17
|
-
function v(e) {
|
|
18
|
-
const [o, t] = f(!1), s = e || 100;
|
|
19
|
-
return n(() => (window.onscroll = () => {
|
|
20
|
-
window.pageYOffset > s ? t(!0) : t(!1);
|
|
21
|
-
}, () => {
|
|
22
|
-
window.onscroll = null;
|
|
23
|
-
}), [s]), o;
|
|
24
|
-
}
|
|
25
|
-
const x = () => {
|
|
26
|
-
const e = i(m);
|
|
27
|
-
if (!e)
|
|
28
|
-
throw new Error("useHostTheme context must be use inside HostThemeProvider");
|
|
29
|
-
return e;
|
|
30
|
-
};
|
|
31
|
-
function H(e) {
|
|
32
|
-
const o = r(null);
|
|
33
|
-
return c(() => {
|
|
34
|
-
const t = o?.current;
|
|
35
|
-
if (!t)
|
|
36
|
-
return;
|
|
37
|
-
const s = new ResizeObserver((u) => {
|
|
38
|
-
e(t, u[0]);
|
|
39
|
-
});
|
|
40
|
-
return s.observe(t), () => {
|
|
41
|
-
s.disconnect();
|
|
42
|
-
};
|
|
43
|
-
}, [e, o.current]), o;
|
|
44
|
-
}
|
|
45
|
-
export {
|
|
46
|
-
v as a,
|
|
47
|
-
x as b,
|
|
48
|
-
H as c,
|
|
49
|
-
h as u
|
|
50
|
-
};
|
|
File without changes
|