@m4l/graphics 2.0.2 → 2.0.4

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