@m4l/graphics 2.0.0 → 2.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,4 @@
1
+ import "@mui/material/styles";
2
+ import "@mui/material";
3
+ import "@m4l/styles";
4
+ import "react/jsx-runtime";
@@ -1,11 +1,15 @@
1
+ import "./FormatterContext/index.92336f4c.js";
2
+ import "./LocalesContext/index.53f0b702.js";
1
3
  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 E } from "../node_modules.f4ae204b.js";
4
+ import { c as v, d as R, i as P, l as E } from "../node_modules.9690bbee.js";
3
5
  import { jsx as x } from "react/jsx-runtime";
6
+ import "date-fns/locale/en-US";
7
+ import "./HostThemeContext/index.89c85eb6.js";
4
8
  import { useNetwork as M, 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 B, SUCCESS as $, shadows as p, createCustomShadows as j, defaultThemeOptions as W, defaultPreset as _, colorPresets as F } from "@m4l/styles";
9
+ import { getColorPresets as g, getColorState as d, typography as A, palette as S, SECONDARY as L, COMMON as N, ERROR as D, WARNING as B, INFO as z, SUCCESS as W, shadows as C, createCustomShadows as $, defaultThemeOptions as j, defaultPreset as _, colorPresets as F } from "@m4l/styles";
6
10
  import { alpha as I } from "@mui/system";
7
11
  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) => {
12
+ const u = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, K = (r) => {
9
13
  const t = {
10
14
  ...r
11
15
  };
@@ -15,8 +19,8 @@ const C = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, K = (r) => {
15
19
  ...t,
16
20
  responsiveContainerActions: {
17
21
  setBreakpoint: (e) => {
18
- o((i) => {
19
- i.breakPoint = e, i.isUpSm = e !== "xs" && e !== "sm", i.isXs = e == "xs";
22
+ o((a) => {
23
+ a.breakPoint = e, a.isUpSm = e !== "xs" && e !== "sm", a.isXs = e == "xs";
20
24
  });
21
25
  }
22
26
  }
@@ -24,7 +28,7 @@ const C = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, K = (r) => {
24
28
  { name: "Responsive Relative Store" }
25
29
  )
26
30
  );
27
- }, X = f(null), te = (r) => {
31
+ }, X = f(null), se = (r) => {
28
32
  const {
29
33
  children: t,
30
34
  observedDivRef: o
@@ -37,36 +41,37 @@ const C = { xs: 600, sm: 900, md: 1200, lg: 1536, xl: 1920 }, K = (r) => {
37
41
  const e = () => {
38
42
  const s = o;
39
43
  if (s instanceof HTMLElement && s.clientWidth) {
40
- const a = Object.keys(C);
41
- for (let l = 0; l < a.length; l++) {
42
- const g = a[l];
43
- if (s.clientWidth <= C[g]) {
44
- n.current?.getState().responsiveContainerActions.setBreakpoint(g);
44
+ const i = Object.keys(u);
45
+ for (let h = 0; h < i.length; h++) {
46
+ const m = i[h];
47
+ if (s.clientWidth <= u[m]) {
48
+ n.current?.getState().responsiveContainerActions.setBreakpoint(m);
45
49
  break;
46
- }
50
+ } else
51
+ h === i.length - 1 && s.clientWidth >= u[m] && n.current?.getState().responsiveContainerActions.setBreakpoint(m);
47
52
  }
48
53
  }
49
- }, i = k(() => E.exports.throttle(e, 200, {
54
+ }, a = k(() => E.exports.throttle(e, 200, {
50
55
  leading: !1,
51
56
  trailing: !0
52
57
  }), [e]);
53
58
  return y(() => {
54
59
  const s = () => {
55
- i();
56
- }, a = o;
57
- if (a && a instanceof Element) {
58
- const l = new ResizeObserver((g) => {
60
+ a();
61
+ }, i = o;
62
+ if (i && i instanceof Element) {
63
+ const h = new ResizeObserver((m) => {
59
64
  s();
60
65
  });
61
- return l.observe(a), () => {
62
- l.disconnect();
66
+ return h.observe(i), () => {
67
+ h.disconnect();
63
68
  };
64
69
  }
65
70
  }, [o]), /* @__PURE__ */ x(X.Provider, {
66
71
  value: n.current,
67
72
  children: t
68
73
  });
69
- }, u = {
74
+ }, p = {
70
75
  themeMode: "light",
71
76
  themeDirection: "ltr",
72
77
  themeColorPresets: "patronus",
@@ -82,30 +87,30 @@ function O(r, t = "m4l") {
82
87
  Object.keys(r).forEach((n) => {
83
88
  const e = r[n];
84
89
  if (typeof e == "string" || typeof e == "number") {
85
- const i = `--${t}-${n}`;
86
- o.style.setProperty(i, e.toString());
90
+ const a = `--${t}-${n}`;
91
+ o.style.setProperty(a, e.toString());
87
92
  } else
88
93
  typeof e == "object" && e !== null && O(e, `${t}-${n}`);
89
94
  });
90
95
  }
91
96
  const c = (r) => {
92
- const t = r.currentThemeSettings || u;
93
- console.log("getColorPresets", m(t.themeColorPresets)), console.log(
97
+ const t = r.currentThemeSettings || p;
98
+ console.log("getColorPresets", g(t.themeColorPresets)), console.log(
94
99
  "getColorState",
95
100
  d(t.themeColorPresets, t.themeMode)
96
101
  );
97
102
  const o = t.themeMode === "light";
98
103
  r.themeOptions = {
99
104
  ...r.themeOptions,
100
- typography: L,
105
+ typography: A,
101
106
  palette: {
102
107
  ...r.themeOptions.palette,
103
108
  ...o ? S.light : S.dark,
104
- primary: m(t.themeColorPresets),
109
+ primary: g(t.themeColorPresets),
105
110
  state: d(t.themeColorPresets, t.themeMode),
106
- representative: t.themeMode === "light" ? m(t.themeColorPresets)?.light : m(t.themeColorPresets)?.darker,
111
+ representative: t.themeMode === "light" ? g(t.themeColorPresets)?.light : g(t.themeColorPresets)?.darker,
107
112
  secondary: {
108
- ...A,
113
+ ...L,
109
114
  contrastText: "",
110
115
  mainChannel: "",
111
116
  lightChannel: "",
@@ -130,7 +135,7 @@ const c = (r) => {
130
135
  contrastTextChannel: ""
131
136
  },
132
137
  warning: {
133
- ...z,
138
+ ...B,
134
139
  contrastText: "",
135
140
  mainChannel: "",
136
141
  lightChannel: "",
@@ -138,7 +143,7 @@ const c = (r) => {
138
143
  contrastTextChannel: ""
139
144
  },
140
145
  info: {
141
- ...B,
146
+ ...z,
142
147
  contrastText: "",
143
148
  mainChannel: "",
144
149
  lightChannel: "",
@@ -146,7 +151,7 @@ const c = (r) => {
146
151
  contrastTextChannel: ""
147
152
  },
148
153
  success: {
149
- ...$,
154
+ ...W,
150
155
  contrastText: "",
151
156
  mainChannel: "",
152
157
  lightChannel: "",
@@ -156,17 +161,17 @@ const c = (r) => {
156
161
  },
157
162
  shape: { borderRadius: 8 },
158
163
  direction: t.themeDirection,
159
- shadows: o ? p.light : p.dark,
164
+ shadows: o ? C.light : C.dark,
160
165
  customShadows: {
161
166
  primary: `0 8px 16px 0 ${I(
162
- m(t.themeColorPresets)?.main || "#fff",
167
+ g(t.themeColorPresets)?.main || "#fff",
163
168
  0.2
164
169
  )}`,
165
- ...j(t.themeMode)
170
+ ...$(t.themeMode)
166
171
  },
167
172
  stretch: t.themeStretch
168
173
  }, console.log("state.themeOptions", r.themeOptions), O(r.themeOptions);
169
- }, h = (r) => {
174
+ }, l = (r) => {
170
175
  r.setterThemeSettings && r.setterThemeSettings(r.currentThemeSettings);
171
176
  }, q = (r) => v(
172
177
  R(
@@ -180,7 +185,7 @@ const c = (r) => {
180
185
  },
181
186
  setThemeSettings: (n) => {
182
187
  t((e) => {
183
- e.currentThemeSettings = { ...e.currentThemeSettings, ...n }, h(e), c(e);
188
+ e.currentThemeSettings = { ...e.currentThemeSettings, ...n }, l(e), c(e);
184
189
  });
185
190
  },
186
191
  onChangeMode: (n) => {
@@ -188,7 +193,7 @@ const c = (r) => {
188
193
  e.currentThemeSettings = {
189
194
  ...e.currentThemeSettings,
190
195
  themeMode: n.target.value
191
- }, h(e), c(e);
196
+ }, l(e), c(e);
192
197
  });
193
198
  },
194
199
  handleOpen: () => {
@@ -201,7 +206,7 @@ const c = (r) => {
201
206
  e.currentThemeSettings = {
202
207
  ...e.currentThemeSettings,
203
208
  themeDirection: n.target.value
204
- }, h(e), c(e);
209
+ }, l(e), c(e);
205
210
  });
206
211
  },
207
212
  onChangeColor: (n) => {
@@ -209,7 +214,7 @@ const c = (r) => {
209
214
  e.currentThemeSettings = {
210
215
  ...e.currentThemeSettings,
211
216
  themeColorPresets: n.target.value
212
- }, h(e), c(e);
217
+ }, l(e), c(e);
213
218
  });
214
219
  },
215
220
  onChangeLayout: (n) => {
@@ -217,7 +222,7 @@ const c = (r) => {
217
222
  e.currentThemeSettings = {
218
223
  ...e.currentThemeSettings,
219
224
  themeLayout: n.target.value
220
- }, h(e), c(e);
225
+ }, l(e), c(e);
221
226
  });
222
227
  },
223
228
  onToggleStretch: () => {
@@ -225,14 +230,14 @@ const c = (r) => {
225
230
  n.currentThemeSettings = {
226
231
  ...n.currentThemeSettings,
227
232
  themeStretch: !n.currentThemeSettings.themeStretch
228
- }, h(n), c(n);
233
+ }, l(n), c(n);
229
234
  });
230
235
  },
231
236
  onResetSetting: () => {
232
237
  t((n) => {
233
238
  n.currentThemeSettings = {
234
- ...u
235
- }, h(n), c(n);
239
+ ...p
240
+ }, l(n), c(n);
236
241
  });
237
242
  }
238
243
  }
@@ -240,28 +245,28 @@ const c = (r) => {
240
245
  { name: "ExampleStore" }
241
246
  )
242
247
  ), G = f(null);
243
- function ne({
248
+ function ie({
244
249
  children: r,
245
250
  themeSettings: t
246
251
  }) {
247
252
  const {
248
253
  networkOperation: o
249
- } = M(), [n, e] = w("theme_setting", u), i = U([t]), s = T();
254
+ } = M(), [n, e] = w("theme_setting", p), a = U([t]), s = T();
250
255
  return s.current || (s.current = q({
251
256
  networkOperation: o,
252
257
  currentThemeSettings: {
253
258
  ...t ?? n
254
259
  },
255
- themeOptions: W,
260
+ themeOptions: j,
256
261
  currentPreset: _,
257
- colorOption: F.map((a) => ({
258
- name: a.name,
259
- value: a.main
262
+ colorOption: F.map((i) => ({
263
+ name: i.name,
264
+ value: i.main
260
265
  })),
261
266
  open: !1,
262
267
  setterThemeSettings: t ? void 0 : e
263
268
  }), s.current.getState().settingsActions.init()), b(() => {
264
- !i && s.current && t && s.current.getState().settingsActions.setThemeSettings(t);
269
+ !a && s.current && t && s.current.getState().settingsActions.setThemeSettings(t);
265
270
  }, [t]), /* @__PURE__ */ x(G.Provider, {
266
271
  value: s.current,
267
272
  children: r
@@ -270,7 +275,7 @@ function ne({
270
275
  export {
271
276
  X as R,
272
277
  G as T,
273
- te as a,
274
- ne as b,
275
- u as d
278
+ se as a,
279
+ ie as b,
280
+ p as d
276
281
  };
@@ -0,0 +1,57 @@
1
+ import { useRef as r, useEffect as n, useState as f, useContext as u, useLayoutEffect as c } from "react";
2
+ import { H as m } from "../contexts/HostThemeContext/index.89c85eb6.js";
3
+ import { u as a } from "../node_modules.9690bbee.js";
4
+ import { T as p } from "../contexts/index.d4e2c292.js";
5
+ import "../contexts/FormatterContext/index.92336f4c.js";
6
+ import "../contexts/LocalesContext/index.53f0b702.js";
7
+ import "@m4l/styles";
8
+ function b() {
9
+ const e = r(!0);
10
+ return n(
11
+ () => () => {
12
+ e.current = !1;
13
+ },
14
+ []
15
+ ), e;
16
+ }
17
+ function g(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 v = () => {
26
+ const e = u(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((i) => {
38
+ e(t, i[0]);
39
+ });
40
+ return s.observe(t), () => {
41
+ s.disconnect();
42
+ };
43
+ }, [e, o.current]), o;
44
+ }
45
+ function O(e, o) {
46
+ const t = u(p);
47
+ if (!t)
48
+ throw new Error("useSettingsStore context must be use inside SettignsContext");
49
+ return a(t, e, o);
50
+ }
51
+ export {
52
+ g as a,
53
+ v as b,
54
+ H as c,
55
+ O as d,
56
+ b as u
57
+ };
@@ -1,5 +1,5 @@
1
1
  import { useState as n, useEffect as o } from "react";
2
- import { t as s } from "../../node_modules.f4ae204b.js";
2
+ import { t as s } from "../../node_modules.9690bbee.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(() => {
@@ -1,6 +1,6 @@
1
1
  import { useContext as t } from "react";
2
- import { u as r } from "../../node_modules.f4ae204b.js";
3
- import { R as n } from "../../contexts/index.43eb2431.js";
2
+ import { u as r } from "../../node_modules.9690bbee.js";
3
+ import { R as n } from "../../contexts/index.d4e2c292.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,43 +1,43 @@
1
1
  import { G as l } from "./components/GlobalStyle/index.b7393a44.js";
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.43eb2431.js";
2
+ import { F as C, a as T } from "./contexts/FormatterContext/index.92336f4c.js";
3
+ import { L as h, a as R, g as S } from "./contexts/LocalesContext/index.53f0b702.js";
4
+ import { R as F, a as P, T as b, b as L, d as H } from "./contexts/index.d4e2c292.js";
5
5
  import { H as w, a as z } from "./contexts/HostThemeContext/index.89c85eb6.js";
6
6
  import { u as I } from "./hooks/useFirstRender/index.1e9b02fb.js";
7
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.a56c80bc.js";
8
+ import { b as A, u as D, a as E, c as N, d as W } from "./hooks/index.953df5ed.js";
9
9
  import { u as q } from "./hooks/useLocales/index.d5a80aff.js";
10
- import { u as J, a as K } from "./hooks/useResponsive/index.24a3087b.js";
11
- import { u as U } from "./hooks/useIsMobile/index.a6493a85.js";
10
+ import { u as J, a as K } from "./hooks/useResponsive/index.49db561d.js";
11
+ import { u as U } from "./hooks/useIsMobile/index.54bf37f7.js";
12
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";
18
19
  import "@mui/x-date-pickers/AdapterDateFns";
19
20
  import "@mui/x-date-pickers";
20
- import "@m4l/core";
21
21
  import "date-fns/locale/en-US";
22
- import "./node_modules.f4ae204b.js";
22
+ import "./node_modules.9690bbee.js";
23
23
  import "./commonjs.e3daa2e5.js";
24
24
  import "@mui/system";
25
25
  export {
26
26
  X as Capitalize,
27
- R as FormatterContext,
28
- S as FormatterProvider,
27
+ C as FormatterContext,
28
+ T as FormatterProvider,
29
29
  l as GlobalStyles,
30
30
  w as HostThemeContext,
31
31
  z as HostThemeProvider,
32
- C as LocalesContext,
33
- T as LocalesProvider,
32
+ h as LocalesContext,
33
+ R as LocalesProvider,
34
34
  F as ResponsiveContainerContext,
35
35
  P as ResponsiveContainerProvider,
36
36
  b as ThemeSettingsContext,
37
37
  L as ThemeSettingsProvider,
38
38
  H as defaultThemeSettings,
39
39
  Y as getAnchorElPositionWindow,
40
- g as getLocaleFromNetwork,
40
+ S as getLocaleFromNetwork,
41
41
  I as useFirstRender,
42
42
  O as useFormatter,
43
43
  A as useHostTheme,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/graphics",
3
- "version": "2.0.0",
3
+ "version": "2.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 +0,0 @@
1
-
@@ -1,54 +0,0 @@
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.89c85eb6.js";
3
- import { u as a } from "../node_modules.f4ae204b.js";
4
- import { T as l } from "../contexts/index.43eb2431.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
- };