@m4l/graphics 3.0.0 → 3.0.2

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,48 @@
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
+ };
@@ -8,5 +8,6 @@ export interface HostThemeType {
8
8
  export interface HostThemeProviderProps extends HostThemeType {
9
9
  isMicroFrontEnd: boolean;
10
10
  children: ReactNode;
11
+ isMobile: boolean;
11
12
  }
12
13
  export declare type HostThemeContextType = HostThemeType;
@@ -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 b, useLayoutEffect as k } from "react";
2
- import { c as T, d as C, i as v, l as P } from "../node_modules-BHhXVwYT.js";
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 O, useLocalStorageWithListener as x } from "@m4l/core";
5
- import { getPaletteByPreset as w, typography as E, shadows as d, getColorPresets as L, createCustomShadows as M, defaultThemeOptions as B, presetsOptions as A } from "@m4l/styles";
6
- import { alpha as D } from "@mui/system";
7
- const g = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, z = (r) => {
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((s) => {
18
- s.breakPoint = e, s.isUpSm = e !== "xs" && e !== "sm", s.isXs = e == "xs";
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
- }, $ = S(null), H = (r) => {
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 = z({
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 m = o;
38
- if (m instanceof HTMLElement && m.clientWidth) {
39
- const c = Object.keys(g);
40
- for (let h = 0; h < c.length; h++) {
41
- const u = c[h];
42
- if (m.clientWidth <= g[u]) {
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]) {
43
44
  t.current?.getState().responsiveContainerActions.setBreakpoint(u);
44
45
  break;
45
- } else h === c.length - 1 && m.clientWidth >= g[u] && t.current?.getState().responsiveContainerActions.setBreakpoint(u);
46
+ } else a === h.length - 1 && s.clientWidth >= g[u] && t.current?.getState().responsiveContainerActions.setBreakpoint(u);
46
47
  }
47
48
  }
48
- }, s = b(() => P.throttle(e, 200, {
49
+ }, i = R(() => O.throttle(e, 200, {
49
50
  leading: !1,
50
51
  trailing: !0
51
52
  }), [e]);
52
53
  return k(() => {
53
- const m = () => {
54
- s();
55
- }, c = o;
56
- if (c && c instanceof Element) {
57
- const h = new ResizeObserver((u) => {
58
- m();
54
+ const s = () => {
55
+ i();
56
+ }, h = o;
57
+ if (h && h instanceof Element) {
58
+ const a = new ResizeObserver((u) => {
59
+ s();
59
60
  });
60
- return h.observe(c), () => {
61
- h.disconnect();
61
+ return a.observe(h), () => {
62
+ a.disconnect();
62
63
  };
63
64
  }
64
- }, [o]), /* @__PURE__ */ y($.Provider, {
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 R(r, n = "m4l") {
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,9 +83,9 @@ 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 s = `--${n}-${t}`;
85
- o.style.setProperty(s, e.toString());
86
- } else typeof e == "object" && e !== null && R(e, `${n}-${t}`);
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
91
  const l = {
@@ -91,7 +93,7 @@ const l = {
91
93
  lightChannel: "",
92
94
  darkChannel: "",
93
95
  contrastTextChannel: ""
94
- }, i = (r) => {
96
+ }, c = (r) => {
95
97
  const n = r.currentThemeSettings || p, o = n.themeMode === "light", t = w(n.themeColorPresets), e = o ? t.light : t.dark;
96
98
  r.themeOptions = {
97
99
  ...r.themeOptions,
@@ -150,29 +152,29 @@ const l = {
150
152
  direction: n.themeDirection,
151
153
  shadows: o ? d.light : d.dark,
152
154
  customShadows: {
153
- primary: `0 8px 16px 0 ${D(
155
+ primary: `0 8px 16px 0 ${z(
154
156
  L(n.themeColorPresets)?.main || "#fff",
155
157
  0.2
156
158
  )}`,
157
- ...M(n.themeMode)
159
+ ...B(n.themeMode)
158
160
  },
159
161
  stretch: n.themeStretch
160
- }, R(r.themeOptions);
161
- }, a = (r) => {
162
+ }, b(r.themeOptions);
163
+ }, m = (r) => {
162
164
  r.setterThemeSettings && r.setterThemeSettings(r.currentThemeSettings);
163
- }, j = (r) => T(
165
+ }, _ = (r) => T(
164
166
  C(
165
167
  v((n, o) => ({
166
168
  ...r,
167
169
  settingsActions: {
168
170
  init: () => {
169
171
  n((t) => {
170
- i(t);
172
+ c(t);
171
173
  });
172
174
  },
173
175
  setThemeSettings: (t) => {
174
176
  n((e) => {
175
- e.currentThemeSettings = { ...e.currentThemeSettings, ...t }, a(e), i(e);
177
+ e.currentThemeSettings = { ...e.currentThemeSettings, ...t }, m(e), c(e);
176
178
  });
177
179
  },
178
180
  onChangeMode: (t) => {
@@ -180,7 +182,7 @@ const l = {
180
182
  e.currentThemeSettings = {
181
183
  ...e.currentThemeSettings,
182
184
  themeMode: t.target.value
183
- }, a(e), i(e);
185
+ }, m(e), c(e);
184
186
  });
185
187
  },
186
188
  handleOpen: () => {
@@ -193,7 +195,7 @@ const l = {
193
195
  e.currentThemeSettings = {
194
196
  ...e.currentThemeSettings,
195
197
  themeDirection: t.target.value
196
- }, a(e), i(e);
198
+ }, m(e), c(e);
197
199
  });
198
200
  },
199
201
  onChangeColor: (t) => {
@@ -201,7 +203,7 @@ const l = {
201
203
  e.currentThemeSettings = {
202
204
  ...e.currentThemeSettings,
203
205
  themeColorPresets: t.target.value
204
- }, a(e), i(e);
206
+ }, m(e), c(e);
205
207
  });
206
208
  },
207
209
  onChangeLayout: (t) => {
@@ -209,7 +211,7 @@ const l = {
209
211
  e.currentThemeSettings = {
210
212
  ...e.currentThemeSettings,
211
213
  themeLayout: t.target.value
212
- }, a(e), i(e);
214
+ }, m(e), c(e);
213
215
  });
214
216
  },
215
217
  onToggleStretch: () => {
@@ -217,48 +219,52 @@ const l = {
217
219
  t.currentThemeSettings = {
218
220
  ...t.currentThemeSettings,
219
221
  themeStretch: !t.currentThemeSettings.themeStretch
220
- }, a(t), i(t);
222
+ }, m(t), c(t);
221
223
  });
222
224
  },
223
225
  onResetSetting: () => {
224
226
  n((t) => {
225
227
  t.currentThemeSettings = {
226
228
  ...p
227
- }, a(t), i(t);
229
+ }, m(t), c(t);
228
230
  });
229
231
  }
230
232
  }
231
233
  })),
232
234
  { name: "ThemeSettingsStore" }
233
235
  )
234
- ), W = S(null);
235
- function I({
236
+ ), N = S(null);
237
+ function G({
236
238
  children: r,
237
239
  themeSettings: n
238
240
  }) {
239
241
  const {
240
242
  networkOperation: o
241
- } = O(), [t, e] = x("theme_setting", {}), s = f();
242
- return s.current || (s.current = j({
243
+ } = x(), t = $(), [e, i] = M("theme_setting", {}), s = f();
244
+ return s.current || (s.current = _({
243
245
  networkOperation: o,
244
246
  currentThemeSettings: {
245
247
  ...p,
246
248
  ...n,
247
- ...t
249
+ ...e
248
250
  },
249
- themeOptions: B,
250
- colorOption: A,
251
+ themeOptions: A,
252
+ colorOption: D,
251
253
  open: !1,
252
- setterThemeSettings: n ? void 0 : e
253
- }), s.current.getState().settingsActions.init()), /* @__PURE__ */ y(W.Provider, {
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, {
254
260
  value: s.current,
255
261
  children: r
256
262
  });
257
263
  }
258
264
  export {
259
- $ as R,
260
- W as T,
261
- H as a,
262
- I as b,
265
+ W as R,
266
+ N as T,
267
+ F as a,
268
+ G as b,
263
269
  p as d
264
270
  };
@@ -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-KkaEtH_8.js";
2
+ import { H as m } from "../contexts/HostThemeContext/index-B8iD1cO8.js";
3
3
  import { u as a } from "../node_modules-BHhXVwYT.js";
4
- import { T as l } from "../contexts/index-lSin3toV.js";
4
+ import { T as l } from "../contexts/index-DqxwPAZr.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-lSin3toV.js";
3
+ import { R as n } from "../../contexts/index-DqxwPAZr.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-lSin3toV.js";
5
- import { H as T, a as g } from "./contexts/HostThemeContext/index-KkaEtH_8.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";
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-BFpjMXdG.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
9
  import { u as z } from "./hooks/useLocales/index-mTHn9nqY.js";
10
- import { u as I, a as M } from "./hooks/useResponsive/index-CH-gd9zy.js";
10
+ import { u as I, a as M } from "./hooks/useResponsive/index-P9e5eab1.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/graphics",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team*",
6
6
  "dependencies": {
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
- };