@m4l/graphics 3.0.3 → 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.
Files changed (60) hide show
  1. package/components/GlobalStyles/index.d.ts +0 -1
  2. package/contexts/FormatterContext/index.d.ts +1 -2
  3. package/contexts/FormatterContext/{index-Ch6IW7j8.js → index.js} +1 -1
  4. package/contexts/FormatterContext/types.d.ts +2 -2
  5. package/contexts/HostThemeContext/index.d.ts +1 -2
  6. package/contexts/HostThemeContext/index.js +46 -0
  7. package/contexts/HostThemeContext/types.d.ts +6 -5
  8. package/contexts/LocalesContext/helper.js +35 -0
  9. package/contexts/LocalesContext/index.d.ts +1 -2
  10. package/contexts/LocalesContext/index.js +69 -0
  11. package/contexts/LocalesContext/types.d.ts +4 -4
  12. package/contexts/ResponsiveContainerContext/constants.js +4 -0
  13. package/contexts/ResponsiveContainerContext/index.d.ts +3 -4
  14. package/contexts/ResponsiveContainerContext/index.js +51 -0
  15. package/contexts/ResponsiveContainerContext/store.d.ts +3 -3
  16. package/contexts/ResponsiveContainerContext/store.js +26 -0
  17. package/contexts/ResponsiveContainerContext/types.d.ts +4 -5
  18. package/contexts/ThemeSettingsContext/ThemeSettingsContext.d.ts +4 -5
  19. package/contexts/ThemeSettingsContext/ThemeSettingsContext.js +32 -0
  20. package/contexts/ThemeSettingsContext/constants.js +11 -0
  21. package/contexts/ThemeSettingsContext/index.js +1 -0
  22. package/contexts/ThemeSettingsContext/store.d.ts +2 -2
  23. package/contexts/ThemeSettingsContext/store.js +118 -0
  24. package/contexts/ThemeSettingsContext/types.d.ts +14 -11
  25. package/contexts/index.js +1 -0
  26. package/hooks/index.js +1 -0
  27. package/hooks/useFormatter/index.d.ts +1 -1
  28. package/hooks/useFormatter/index.js +11 -0
  29. package/hooks/useHostTheme/index.d.ts +1 -1
  30. package/hooks/useHostTheme/index.js +11 -0
  31. package/hooks/useIsMobile/{index-Bro0dV28.js → index.js} +5 -5
  32. package/hooks/useIsMountedRef/index.d.ts +1 -2
  33. package/hooks/useIsMountedRef/index.js +13 -0
  34. package/hooks/useLocales/index.d.ts +1 -1
  35. package/hooks/useLocales/index.js +11 -0
  36. package/hooks/useOffSetTop.js +12 -0
  37. package/hooks/useResizeObserver/index.d.ts +1 -2
  38. package/hooks/useResizeObserver/index.js +18 -0
  39. package/hooks/useResponsive/index.js +7 -0
  40. package/hooks/useResponsiveContainer/index.js +12 -0
  41. package/hooks/useThemSettingsStore/index.js +12 -0
  42. package/index.js +44 -35
  43. package/package.json +55 -11
  44. package/utils/anchorEl.d.ts +2 -2
  45. package/utils/anchorEl.js +49 -0
  46. package/utils/index.js +1 -0
  47. package/utils/strings.js +4 -0
  48. package/commonjs-BCz0-aDl.js +0 -9
  49. package/contexts/HostThemeContext/index-BMSwOCtA.js +0 -44
  50. package/contexts/LocalesContext/index-C89UlO0s.js +0 -101
  51. package/contexts/index-DEyJidab.js +0 -262
  52. package/hooks/index-Y3uj_IzK.js +0 -52
  53. package/hooks/useFormatter/index-BBgQ4lJL.js +0 -10
  54. package/hooks/useLocales/index-_thMBNE7.js +0 -10
  55. package/hooks/useResponsive/index-Dki-WJi8.js +0 -16
  56. package/node_modules-BHhXVwYT.js +0 -4569
  57. package/utils/index-DZG6QXjf.js +0 -51
  58. /package/components/{GlobalStyle/index-C3p7OfnO.js → GlobalStyles/index.js} +0 -0
  59. /package/components/{index-l0sNRNKZ.js → index.js} +0 -0
  60. /package/hooks/useFirstRender/{index-B-Q0TTn0.js → index.js} +0 -0
@@ -1,262 +0,0 @@
1
- import { jsx as S } from "react/jsx-runtime";
2
- import { createContext as f, useRef as T, useMemo as R, useLayoutEffect as k, useEffect as P } from "react";
3
- import { c as C, d as v, i as y, l as O } from "../node_modules-BHhXVwYT.js";
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) => {
9
- const n = {
10
- ...r
11
- };
12
- return C(
13
- v(
14
- y((o, t) => ({
15
- ...n,
16
- responsiveContainerActions: {
17
- setBreakpoint: (e) => {
18
- o((i) => {
19
- i.breakPoint = e, i.isUpSm = e !== "xs" && e !== "sm", i.isXs = e == "xs";
20
- });
21
- }
22
- }
23
- })),
24
- { name: "Responsive Relative Store" }
25
- )
26
- );
27
- }, W = f(null), F = (r) => {
28
- const { children: n, observedDivRef: o } = r, t = T();
29
- t.current || (t.current = j({
30
- breakPoint: "md",
31
- isUpSm: !1,
32
- isXs: !1
33
- }));
34
- const e = () => {
35
- const s = o;
36
- if (s instanceof HTMLElement && s.clientWidth) {
37
- const h = Object.keys(
38
- g
39
- );
40
- for (let a = 0; a < h.length; a++) {
41
- const u = h[a];
42
- if (s.clientWidth <= g[u]) {
43
- t.current?.getState().responsiveContainerActions.setBreakpoint(u);
44
- break;
45
- } else a === h.length - 1 && s.clientWidth >= g[u] && t.current?.getState().responsiveContainerActions.setBreakpoint(u);
46
- }
47
- }
48
- }, i = R(
49
- () => O.throttle(e, 200, {
50
- leading: !1,
51
- trailing: !0
52
- }),
53
- [e]
54
- );
55
- return k(() => {
56
- const s = () => {
57
- i();
58
- }, h = o;
59
- if (h && h instanceof Element) {
60
- const a = new ResizeObserver((u) => {
61
- s();
62
- });
63
- return a.observe(h), () => {
64
- a.disconnect();
65
- };
66
- }
67
- }, [o]), /* @__PURE__ */ S(W.Provider, { value: t.current, children: n });
68
- }, p = {
69
- themeMode: "light",
70
- themeDirection: "ltr",
71
- themeColorPresets: "patronus",
72
- themeLayout: "horizontal",
73
- themeStretch: !1,
74
- isMobile: !1
75
- };
76
- function b(r, n = "m4l") {
77
- const o = document.querySelector('[data-mui-color-scheme="light"]');
78
- if (!o) {
79
- console.error('Element with data-mui-color-scheme="light" not found.');
80
- return;
81
- }
82
- Object.keys(r).forEach((t) => {
83
- const e = r[t];
84
- if (typeof e == "string" || typeof e == "number") {
85
- const i = `--${n}-${t}`;
86
- o.style.setProperty(i, e.toString());
87
- } else typeof e == "object" && e !== null && b(e, `${n}-${t}`);
88
- });
89
- }
90
- const l = {
91
- mainChannel: "",
92
- lightChannel: "",
93
- darkChannel: "",
94
- contrastTextChannel: ""
95
- }, c = (r) => {
96
- const n = r.currentThemeSettings || p, o = n.themeMode === "light", t = w(n.themeColorPresets), e = o ? t.light : t.dark;
97
- r.themeOptions = {
98
- ...r.themeOptions,
99
- typography: E,
100
- palette: {
101
- ...r.themeOptions?.palette ?? {},
102
- ...e,
103
- primary: {
104
- ...e.primary,
105
- ...l
106
- },
107
- secondary: {
108
- ...e.secondary,
109
- ...l
110
- },
111
- info: {
112
- ...e.info,
113
- ...l
114
- },
115
- error: {
116
- ...e.error,
117
- ...l
118
- },
119
- success: {
120
- ...e.success,
121
- ...l
122
- },
123
- warning: {
124
- ...e.warning,
125
- ...l
126
- },
127
- text: {
128
- ...e.text,
129
- primaryChannel: "",
130
- secondaryChannel: ""
131
- },
132
- background: {
133
- ...e.background,
134
- defaultChannel: "",
135
- paperChannel: ""
136
- },
137
- common: {
138
- ...e.common,
139
- background: "",
140
- backgroundChannel: "",
141
- onBackground: "",
142
- onBackgroundChannel: ""
143
- },
144
- action: {
145
- ...e.action,
146
- activeChannel: "",
147
- selectedChannel: ""
148
- }
149
- },
150
- shape: { borderRadius: 8 },
151
- direction: n.themeDirection,
152
- shadows: o ? d.light : d.dark,
153
- customShadows: {
154
- primary: `0 8px 16px 0 ${z(
155
- L(n.themeColorPresets)?.main || "#fff",
156
- 0.2
157
- )}`,
158
- ...B(n.themeMode)
159
- },
160
- stretch: n.themeStretch
161
- }, b(r.themeOptions);
162
- }, m = (r) => {
163
- r.setterThemeSettings && r.setterThemeSettings(r.currentThemeSettings);
164
- }, _ = (r) => C(
165
- v(
166
- y((n, o) => ({
167
- ...r,
168
- settingsActions: {
169
- init: () => {
170
- n((t) => {
171
- c(t);
172
- });
173
- },
174
- setThemeSettings: (t) => {
175
- n((e) => {
176
- e.currentThemeSettings = { ...e.currentThemeSettings, ...t }, m(e), c(e);
177
- });
178
- },
179
- onChangeMode: (t) => {
180
- n((e) => {
181
- e.currentThemeSettings = {
182
- ...e.currentThemeSettings,
183
- themeMode: t.target.value
184
- }, m(e), c(e);
185
- });
186
- },
187
- handleOpen: () => {
188
- n((t) => {
189
- t.open = !t.open;
190
- });
191
- },
192
- onChangeDirection: (t) => {
193
- n((e) => {
194
- e.currentThemeSettings = {
195
- ...e.currentThemeSettings,
196
- themeDirection: t.target.value
197
- }, m(e), c(e);
198
- });
199
- },
200
- onChangeColor: (t) => {
201
- n((e) => {
202
- e.currentThemeSettings = {
203
- ...e.currentThemeSettings,
204
- themeColorPresets: t.target.value
205
- }, m(e), c(e);
206
- });
207
- },
208
- onChangeLayout: (t) => {
209
- n((e) => {
210
- e.currentThemeSettings = {
211
- ...e.currentThemeSettings,
212
- themeLayout: t.target.value
213
- }, m(e), c(e);
214
- });
215
- },
216
- onToggleStretch: () => {
217
- n((t) => {
218
- t.currentThemeSettings = {
219
- ...t.currentThemeSettings,
220
- themeStretch: !t.currentThemeSettings.themeStretch
221
- }, m(t), c(t);
222
- });
223
- },
224
- onResetSetting: () => {
225
- n((t) => {
226
- t.currentThemeSettings = {
227
- ...p
228
- }, m(t), c(t);
229
- });
230
- }
231
- }
232
- })),
233
- { name: "ThemeSettingsStore" }
234
- )
235
- ), N = f(null);
236
- function G({ children: r, themeSettings: n }) {
237
- const { networkOperation: o } = x(), t = $(), [e, i] = M(
238
- "theme_setting",
239
- {}
240
- ), s = T();
241
- return s.current || (s.current = _({
242
- networkOperation: o,
243
- currentThemeSettings: {
244
- ...p,
245
- ...n,
246
- ...e
247
- },
248
- themeOptions: A,
249
- colorOption: D,
250
- open: !1,
251
- setterThemeSettings: n ? void 0 : i
252
- }), s.current.getState().settingsActions.init()), P(() => {
253
- s.current?.getState().settingsActions.setThemeSettings({ isMobile: t });
254
- }, [t]), /* @__PURE__ */ S(N.Provider, { value: s.current, children: r });
255
- }
256
- export {
257
- W as R,
258
- N as T,
259
- F as a,
260
- G as b,
261
- p as d
262
- };
@@ -1,52 +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-BMSwOCtA.js";
3
- import { u as a } from "../node_modules-BHhXVwYT.js";
4
- import { T as l } from "../contexts/index-DEyJidab.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) throw new Error("useHostTheme context must be use inside HostThemeProvider");
25
- return e;
26
- };
27
- function b(e) {
28
- const s = n(null);
29
- return c(() => {
30
- const t = s?.current;
31
- if (!t)
32
- return;
33
- const o = new ResizeObserver((f) => {
34
- e(t, f[0]);
35
- });
36
- return o.observe(t), () => {
37
- o.disconnect();
38
- };
39
- }, [e, s.current]), s;
40
- }
41
- function g(e, s) {
42
- const t = u(l);
43
- if (!t) throw new Error("useSettingsStore context must be use inside SettignsContext");
44
- return a(t, e, s);
45
- }
46
- export {
47
- x as a,
48
- h as b,
49
- b as c,
50
- g as d,
51
- S as u
52
- };
@@ -1,10 +0,0 @@
1
- import { useContext as r } from "react";
2
- import { F as e } from "../../contexts/FormatterContext/index-Ch6IW7j8.js";
3
- const m = () => {
4
- const t = r(e);
5
- if (!t) throw new Error("useFormatter context must be use inside FormatterProvider");
6
- return t;
7
- };
8
- export {
9
- m as u
10
- };
@@ -1,10 +0,0 @@
1
- import { useContext as o } from "react";
2
- import { L as t } from "../../contexts/LocalesContext/index-C89UlO0s.js";
3
- const n = () => {
4
- const e = o(t);
5
- if (!e) throw new Error("useLocales context must be use inside LocalesProvider");
6
- return e;
7
- };
8
- export {
9
- n as u
10
- };
@@ -1,16 +0,0 @@
1
- import { useContext as t } from "react";
2
- import { u as r } from "../../node_modules-BHhXVwYT.js";
3
- import { R as n } from "../../contexts/index-DEyJidab.js";
4
- import { useResponsive as i } from "@m4l/styles";
5
- function f(e, s) {
6
- const o = t(n);
7
- if (!o) throw new Error("useAreasStore context must be use inside AreasContext");
8
- return r(o, e, s);
9
- }
10
- function c() {
11
- return i("up", "sm");
12
- }
13
- export {
14
- c as a,
15
- f as u
16
- };