@m4l/graphics 3.0.0 → 3.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/contexts/HostThemeContext/index-L-9XyXob.js +45 -0
- package/contexts/HostThemeContext/types.d.ts +1 -0
- package/contexts/ThemeSettingsContext/types.d.ts +1 -0
- package/contexts/{index-lSin3toV.js → index-B5tlaHe1.js} +74 -65
- package/hooks/{index-BFpjMXdG.js → index-Ds71tnc2.js} +2 -2
- package/hooks/useResponsive/{index-CH-gd9zy.js → index-2q6r6mFX.js} +1 -1
- package/index.js +4 -4
- package/package.json +1 -1
- package/vite-env.d.ts +1 -1
- package/contexts/HostThemeContext/index-KkaEtH_8.js +0 -44
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createContext as a, 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 s, jsx as o } from "react/jsx-runtime";
|
|
6
|
+
const v = a(null);
|
|
7
|
+
function H(i) {
|
|
8
|
+
const {
|
|
9
|
+
children: m,
|
|
10
|
+
hostThemeOptions: t,
|
|
11
|
+
fnComponentsOverrides: n,
|
|
12
|
+
isMobile: l
|
|
13
|
+
} = i, c = h(() => {
|
|
14
|
+
const e = x({
|
|
15
|
+
...t
|
|
16
|
+
}), r = f({
|
|
17
|
+
cssVarPrefix: "m4l",
|
|
18
|
+
colorSchemes: {
|
|
19
|
+
light: e,
|
|
20
|
+
finalTheme: e,
|
|
21
|
+
dark: e
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return r.components = n(r), r;
|
|
25
|
+
}, [l]);
|
|
26
|
+
return /* @__PURE__ */ s(u, {
|
|
27
|
+
theme: c,
|
|
28
|
+
children: [/* @__PURE__ */ o(p, {}), /* @__PURE__ */ o(v.Provider, {
|
|
29
|
+
value: {
|
|
30
|
+
hostThemeOptions: t,
|
|
31
|
+
fnComponentsOverrides: n
|
|
32
|
+
},
|
|
33
|
+
children: /* @__PURE__ */ s(T, {
|
|
34
|
+
injectFirst: !0,
|
|
35
|
+
children: [/* @__PURE__ */ o(d, {
|
|
36
|
+
enableColorScheme: !0
|
|
37
|
+
}), m]
|
|
38
|
+
})
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
v as H,
|
|
44
|
+
H as a
|
|
45
|
+
};
|
|
@@ -12,6 +12,7 @@ export declare type ThemeSettingsType = {
|
|
|
12
12
|
themeColorPresets: ThemeColorPresets;
|
|
13
13
|
themeStretch: ThemeStretch;
|
|
14
14
|
themeLayout: ThemeLayout;
|
|
15
|
+
isMobile: boolean;
|
|
15
16
|
};
|
|
16
17
|
export interface ThemeSettingsStore {
|
|
17
18
|
networkOperation: (props: NetworkProps) => Promise<any>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { createContext as S, useRef as f, useMemo as
|
|
2
|
-
import { c as T, d as C, i as v, l as
|
|
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
3
|
import { jsx as y } from "react/jsx-runtime";
|
|
4
|
-
import { useNetwork as
|
|
5
|
-
import { getPaletteByPreset as w, typography as E, shadows as d, getColorPresets as L, createCustomShadows as
|
|
6
|
-
import { alpha as
|
|
7
|
-
|
|
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) => {
|
|
8
9
|
const n = {
|
|
9
10
|
...r
|
|
10
11
|
};
|
|
@@ -14,8 +15,8 @@ const g = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, z = (r) => {
|
|
|
14
15
|
...n,
|
|
15
16
|
responsiveContainerActions: {
|
|
16
17
|
setBreakpoint: (e) => {
|
|
17
|
-
o((
|
|
18
|
-
|
|
18
|
+
o((i) => {
|
|
19
|
+
i.breakPoint = e, i.isUpSm = e !== "xs" && e !== "sm", i.isXs = e == "xs";
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
}
|
|
@@ -23,45 +24,45 @@ const g = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, z = (r) => {
|
|
|
23
24
|
{ name: "Responsive Relative Store" }
|
|
24
25
|
)
|
|
25
26
|
);
|
|
26
|
-
},
|
|
27
|
+
}, W = S(null), F = (r) => {
|
|
27
28
|
const {
|
|
28
29
|
children: n,
|
|
29
30
|
observedDivRef: o
|
|
30
31
|
} = r, t = f();
|
|
31
|
-
t.current || (t.current =
|
|
32
|
+
t.current || (t.current = j({
|
|
32
33
|
breakPoint: "md",
|
|
33
34
|
isUpSm: !1,
|
|
34
35
|
isXs: !1
|
|
35
36
|
}));
|
|
36
37
|
const e = () => {
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
for (let h = 0; h <
|
|
41
|
-
const u =
|
|
42
|
-
if (
|
|
38
|
+
const s = o;
|
|
39
|
+
if (s instanceof HTMLElement && s.clientWidth) {
|
|
40
|
+
const a = Object.keys(g);
|
|
41
|
+
for (let h = 0; h < a.length; h++) {
|
|
42
|
+
const u = a[h];
|
|
43
|
+
if (s.clientWidth <= g[u]) {
|
|
43
44
|
t.current?.getState().responsiveContainerActions.setBreakpoint(u);
|
|
44
45
|
break;
|
|
45
|
-
} else h ===
|
|
46
|
+
} else h === a.length - 1 && s.clientWidth >= g[u] && t.current?.getState().responsiveContainerActions.setBreakpoint(u);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
},
|
|
49
|
+
}, i = R(() => O.throttle(e, 200, {
|
|
49
50
|
leading: !1,
|
|
50
51
|
trailing: !0
|
|
51
52
|
}), [e]);
|
|
52
53
|
return k(() => {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
if (
|
|
54
|
+
const s = () => {
|
|
55
|
+
i();
|
|
56
|
+
}, a = o;
|
|
57
|
+
if (a && a instanceof Element) {
|
|
57
58
|
const h = new ResizeObserver((u) => {
|
|
58
|
-
|
|
59
|
+
s();
|
|
59
60
|
});
|
|
60
|
-
return h.observe(
|
|
61
|
+
return h.observe(a), () => {
|
|
61
62
|
h.disconnect();
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
|
-
}, [o]), /* @__PURE__ */ y(
|
|
65
|
+
}, [o]), /* @__PURE__ */ y(W.Provider, {
|
|
65
66
|
value: t.current,
|
|
66
67
|
children: n
|
|
67
68
|
});
|
|
@@ -70,9 +71,10 @@ const g = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, z = (r) => {
|
|
|
70
71
|
themeDirection: "ltr",
|
|
71
72
|
themeColorPresets: "patronus",
|
|
72
73
|
themeLayout: "horizontal",
|
|
73
|
-
themeStretch: !1
|
|
74
|
+
themeStretch: !1,
|
|
75
|
+
isMobile: !1
|
|
74
76
|
};
|
|
75
|
-
function
|
|
77
|
+
function b(r, n = "m4l") {
|
|
76
78
|
const o = document.querySelector('[data-mui-color-scheme="light"]');
|
|
77
79
|
if (!o) {
|
|
78
80
|
console.error('Element with data-mui-color-scheme="light" not found.');
|
|
@@ -81,47 +83,50 @@ function R(r, n = "m4l") {
|
|
|
81
83
|
Object.keys(r).forEach((t) => {
|
|
82
84
|
const e = r[t];
|
|
83
85
|
if (typeof e == "string" || typeof e == "number") {
|
|
84
|
-
const
|
|
85
|
-
o.style.setProperty(
|
|
86
|
-
} else typeof e == "object" && e !== null &&
|
|
86
|
+
const i = `--${n}-${t}`;
|
|
87
|
+
o.style.setProperty(i, e.toString());
|
|
88
|
+
} else typeof e == "object" && e !== null && b(e, `${n}-${t}`);
|
|
87
89
|
});
|
|
88
90
|
}
|
|
89
|
-
const
|
|
91
|
+
const m = {
|
|
90
92
|
mainChannel: "",
|
|
91
93
|
lightChannel: "",
|
|
92
94
|
darkChannel: "",
|
|
93
95
|
contrastTextChannel: ""
|
|
94
|
-
},
|
|
95
|
-
const n = r.currentThemeSettings || p, o = n.themeMode === "light", t = w(n.themeColorPresets), e = o ? t.light : t.dark;
|
|
96
|
+
}, c = (r) => {
|
|
97
|
+
const n = r.currentThemeSettings || p, o = n.themeMode === "light", t = w(n.themeColorPresets), e = o ? t.light : t.dark, i = n.isMobile;
|
|
96
98
|
r.themeOptions = {
|
|
97
99
|
...r.themeOptions,
|
|
98
100
|
typography: E,
|
|
101
|
+
generalSettings: {
|
|
102
|
+
isMobile: i
|
|
103
|
+
},
|
|
99
104
|
palette: {
|
|
100
105
|
...r.themeOptions?.palette ?? {},
|
|
101
106
|
...e,
|
|
102
107
|
primary: {
|
|
103
108
|
...e.primary,
|
|
104
|
-
...
|
|
109
|
+
...m
|
|
105
110
|
},
|
|
106
111
|
secondary: {
|
|
107
112
|
...e.secondary,
|
|
108
|
-
...
|
|
113
|
+
...m
|
|
109
114
|
},
|
|
110
115
|
info: {
|
|
111
116
|
...e.info,
|
|
112
|
-
...
|
|
117
|
+
...m
|
|
113
118
|
},
|
|
114
119
|
error: {
|
|
115
120
|
...e.error,
|
|
116
|
-
...
|
|
121
|
+
...m
|
|
117
122
|
},
|
|
118
123
|
success: {
|
|
119
124
|
...e.success,
|
|
120
|
-
...
|
|
125
|
+
...m
|
|
121
126
|
},
|
|
122
127
|
warning: {
|
|
123
128
|
...e.warning,
|
|
124
|
-
...
|
|
129
|
+
...m
|
|
125
130
|
},
|
|
126
131
|
text: {
|
|
127
132
|
...e.text,
|
|
@@ -150,29 +155,29 @@ const l = {
|
|
|
150
155
|
direction: n.themeDirection,
|
|
151
156
|
shadows: o ? d.light : d.dark,
|
|
152
157
|
customShadows: {
|
|
153
|
-
primary: `0 8px 16px 0 ${
|
|
158
|
+
primary: `0 8px 16px 0 ${z(
|
|
154
159
|
L(n.themeColorPresets)?.main || "#fff",
|
|
155
160
|
0.2
|
|
156
161
|
)}`,
|
|
157
|
-
...
|
|
162
|
+
...B(n.themeMode)
|
|
158
163
|
},
|
|
159
164
|
stretch: n.themeStretch
|
|
160
|
-
},
|
|
161
|
-
},
|
|
165
|
+
}, b(r.themeOptions);
|
|
166
|
+
}, l = (r) => {
|
|
162
167
|
r.setterThemeSettings && r.setterThemeSettings(r.currentThemeSettings);
|
|
163
|
-
},
|
|
168
|
+
}, _ = (r) => T(
|
|
164
169
|
C(
|
|
165
170
|
v((n, o) => ({
|
|
166
171
|
...r,
|
|
167
172
|
settingsActions: {
|
|
168
173
|
init: () => {
|
|
169
174
|
n((t) => {
|
|
170
|
-
|
|
175
|
+
c(t);
|
|
171
176
|
});
|
|
172
177
|
},
|
|
173
178
|
setThemeSettings: (t) => {
|
|
174
179
|
n((e) => {
|
|
175
|
-
e.currentThemeSettings = { ...e.currentThemeSettings, ...t },
|
|
180
|
+
e.currentThemeSettings = { ...e.currentThemeSettings, ...t }, l(e), c(e);
|
|
176
181
|
});
|
|
177
182
|
},
|
|
178
183
|
onChangeMode: (t) => {
|
|
@@ -180,7 +185,7 @@ const l = {
|
|
|
180
185
|
e.currentThemeSettings = {
|
|
181
186
|
...e.currentThemeSettings,
|
|
182
187
|
themeMode: t.target.value
|
|
183
|
-
},
|
|
188
|
+
}, l(e), c(e);
|
|
184
189
|
});
|
|
185
190
|
},
|
|
186
191
|
handleOpen: () => {
|
|
@@ -193,7 +198,7 @@ const l = {
|
|
|
193
198
|
e.currentThemeSettings = {
|
|
194
199
|
...e.currentThemeSettings,
|
|
195
200
|
themeDirection: t.target.value
|
|
196
|
-
},
|
|
201
|
+
}, l(e), c(e);
|
|
197
202
|
});
|
|
198
203
|
},
|
|
199
204
|
onChangeColor: (t) => {
|
|
@@ -201,7 +206,7 @@ const l = {
|
|
|
201
206
|
e.currentThemeSettings = {
|
|
202
207
|
...e.currentThemeSettings,
|
|
203
208
|
themeColorPresets: t.target.value
|
|
204
|
-
},
|
|
209
|
+
}, l(e), c(e);
|
|
205
210
|
});
|
|
206
211
|
},
|
|
207
212
|
onChangeLayout: (t) => {
|
|
@@ -209,7 +214,7 @@ const l = {
|
|
|
209
214
|
e.currentThemeSettings = {
|
|
210
215
|
...e.currentThemeSettings,
|
|
211
216
|
themeLayout: t.target.value
|
|
212
|
-
},
|
|
217
|
+
}, l(e), c(e);
|
|
213
218
|
});
|
|
214
219
|
},
|
|
215
220
|
onToggleStretch: () => {
|
|
@@ -217,48 +222,52 @@ const l = {
|
|
|
217
222
|
t.currentThemeSettings = {
|
|
218
223
|
...t.currentThemeSettings,
|
|
219
224
|
themeStretch: !t.currentThemeSettings.themeStretch
|
|
220
|
-
},
|
|
225
|
+
}, l(t), c(t);
|
|
221
226
|
});
|
|
222
227
|
},
|
|
223
228
|
onResetSetting: () => {
|
|
224
229
|
n((t) => {
|
|
225
230
|
t.currentThemeSettings = {
|
|
226
231
|
...p
|
|
227
|
-
},
|
|
232
|
+
}, l(t), c(t);
|
|
228
233
|
});
|
|
229
234
|
}
|
|
230
235
|
}
|
|
231
236
|
})),
|
|
232
237
|
{ name: "ThemeSettingsStore" }
|
|
233
238
|
)
|
|
234
|
-
),
|
|
235
|
-
function
|
|
239
|
+
), N = S(null);
|
|
240
|
+
function G({
|
|
236
241
|
children: r,
|
|
237
242
|
themeSettings: n
|
|
238
243
|
}) {
|
|
239
244
|
const {
|
|
240
245
|
networkOperation: o
|
|
241
|
-
} =
|
|
242
|
-
return s.current || (s.current =
|
|
246
|
+
} = x(), t = $(), [e, i] = M("theme_setting", {}), s = f();
|
|
247
|
+
return s.current || (s.current = _({
|
|
243
248
|
networkOperation: o,
|
|
244
249
|
currentThemeSettings: {
|
|
245
250
|
...p,
|
|
246
251
|
...n,
|
|
247
|
-
...
|
|
252
|
+
...e
|
|
248
253
|
},
|
|
249
|
-
themeOptions:
|
|
250
|
-
colorOption:
|
|
254
|
+
themeOptions: A,
|
|
255
|
+
colorOption: D,
|
|
251
256
|
open: !1,
|
|
252
|
-
setterThemeSettings: n ? void 0 :
|
|
253
|
-
}), s.current.getState().settingsActions.init()),
|
|
257
|
+
setterThemeSettings: n ? void 0 : i
|
|
258
|
+
}), s.current.getState().settingsActions.init()), P(() => {
|
|
259
|
+
s.current?.getState().settingsActions.setThemeSettings({
|
|
260
|
+
isMobile: t
|
|
261
|
+
});
|
|
262
|
+
}, [t]), /* @__PURE__ */ y(N.Provider, {
|
|
254
263
|
value: s.current,
|
|
255
264
|
children: r
|
|
256
265
|
});
|
|
257
266
|
}
|
|
258
267
|
export {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
268
|
+
W as R,
|
|
269
|
+
N as T,
|
|
270
|
+
F as a,
|
|
271
|
+
G as b,
|
|
263
272
|
p as d
|
|
264
273
|
};
|
|
@@ -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-
|
|
2
|
+
import { H as m } from "../contexts/HostThemeContext/index-L-9XyXob.js";
|
|
3
3
|
import { u as a } from "../node_modules-BHhXVwYT.js";
|
|
4
|
-
import { T as l } from "../contexts/index-
|
|
4
|
+
import { T as l } from "../contexts/index-B5tlaHe1.js";
|
|
5
5
|
function S() {
|
|
6
6
|
const e = n(!0);
|
|
7
7
|
return r(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext as t } from "react";
|
|
2
2
|
import { u as r } from "../../node_modules-BHhXVwYT.js";
|
|
3
|
-
import { R as n } from "../../contexts/index-
|
|
3
|
+
import { R as n } from "../../contexts/index-B5tlaHe1.js";
|
|
4
4
|
import { useResponsive as i } from "@m4l/styles";
|
|
5
5
|
function f(e, s) {
|
|
6
6
|
const o = t(n);
|
package/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { G as s } from "./components/GlobalStyle/index-BwMNLyTC.js";
|
|
2
2
|
import { L as r, a, g as i } from "./contexts/LocalesContext/index--VwMF60R.js";
|
|
3
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-
|
|
5
|
-
import { H as T, a as g } from "./contexts/HostThemeContext/index-
|
|
4
|
+
import { R as x, a as f, T as d, b as l, d as v } from "./contexts/index-B5tlaHe1.js";
|
|
5
|
+
import { H as T, a as g } from "./contexts/HostThemeContext/index-L-9XyXob.js";
|
|
6
6
|
import { u as R } from "./hooks/useFirstRender/index-B-Q0TTn0.js";
|
|
7
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-
|
|
8
|
+
import { b as P, u as b, a as L, c as H, d as k } from "./hooks/index-Ds71tnc2.js";
|
|
9
9
|
import { u as z } from "./hooks/useLocales/index-mTHn9nqY.js";
|
|
10
|
-
import { u as I, a as M } from "./hooks/useResponsive/index-
|
|
10
|
+
import { u as I, a as M } from "./hooks/useResponsive/index-2q6r6mFX.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
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-BwMNLyTC.js";
|
|
4
|
-
import { createTheme as p, experimental_extendTheme as x, Experimental_CssVarsProvider as f, StyledEngineProvider as u } from "@mui/material/styles";
|
|
5
|
-
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
6
|
-
const T = c(null);
|
|
7
|
-
function H(m) {
|
|
8
|
-
const {
|
|
9
|
-
children: i,
|
|
10
|
-
hostThemeOptions: o,
|
|
11
|
-
fnComponentsOverrides: n
|
|
12
|
-
} = m, l = a(() => {
|
|
13
|
-
const e = p({
|
|
14
|
-
...o
|
|
15
|
-
}), r = x({
|
|
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 /* @__PURE__ */ s(f, {
|
|
26
|
-
theme: l,
|
|
27
|
-
children: [/* @__PURE__ */ t(d, {}), /* @__PURE__ */ t(T.Provider, {
|
|
28
|
-
value: {
|
|
29
|
-
hostThemeOptions: o,
|
|
30
|
-
fnComponentsOverrides: n
|
|
31
|
-
},
|
|
32
|
-
children: /* @__PURE__ */ s(u, {
|
|
33
|
-
injectFirst: !0,
|
|
34
|
-
children: [/* @__PURE__ */ t(h, {
|
|
35
|
-
enableColorScheme: !0
|
|
36
|
-
}), i]
|
|
37
|
-
})
|
|
38
|
-
})]
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
export {
|
|
42
|
-
T as H,
|
|
43
|
-
H as a
|
|
44
|
-
};
|