@m4l/graphics 7.5.0 → 7.6.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../../../packages/graphics/src/contexts/ThemeSettingsContext/store.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAI9B,MAAM,SAAS,CAAC;AAwGjB;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,cAAc,8BAA8B;;;;;;;;CAwKpF,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../../../packages/graphics/src/contexts/ThemeSettingsContext/store.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAI9B,MAAM,SAAS,CAAC;AAkHjB;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,cAAc,8BAA8B;;;;;;;;CA2LpF,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
@@ -1,46 +1,54 @@
1
- import { createStore as c } from "zustand";
2
- import { devtools as d } from "zustand/middleware";
3
- import { immer as u } from "zustand/middleware/immer";
4
- import { getPaletteByPreset as a, createCustomShadows as x, shadows as s, typographyOld as U, getColorPresets as m } from "@m4l/styles";
5
- import { alpha as p } from "@mui/system";
6
- import { defaultThemeSettings as g } from "./constants.js";
7
- function l(o, r = "m4l") {
1
+ import { createStore as d } from "zustand";
2
+ import { devtools as u } from "zustand/middleware";
3
+ import { immer as U } from "zustand/middleware/immer";
4
+ import { EmitEvents as f } from "@m4l/core";
5
+ import { getPaletteByPreset as x, createCustomShadows as C, shadows as l, typographyOld as T, getColorPresets as i } from "@m4l/styles";
6
+ import { alpha as s } from "@mui/system";
7
+ import { defaultThemeSettings as S } from "./constants.js";
8
+ function c(r, o = "m4l") {
8
9
  const n = document.querySelector("[data-mui-color-scheme]");
9
- n && Object.keys(o).forEach((t) => {
10
- const e = o[t];
10
+ n && Object.keys(r).forEach((t) => {
11
+ const e = r[t];
11
12
  if (typeof e == "string" || typeof e == "number") {
12
- const S = `--${r}-${t}`;
13
- n.style.setProperty(S, e.toString());
14
- } else typeof e == "object" && e !== null && l(e, `${r}-${t}`);
13
+ const p = `--${o}-${t}`;
14
+ n.style.setProperty(p, e.toString());
15
+ } else typeof e == "object" && e !== null && c(e, `${o}-${t}`);
15
16
  });
16
17
  }
17
- const h = (o) => {
18
- const r = o.themeUserSettings || g, n = r.themeMode === "light", t = a(r.themeColor), e = n ? t.light : t.dark;
19
- o.themeOptions = {
20
- ...o.themeOptions,
21
- ...U,
18
+ const m = (r) => {
19
+ const o = r.themeUserSettings || S, n = o.themeMode === "light", t = x(o.themeColor), e = n ? t.light : t.dark;
20
+ r.themeOptions = {
21
+ ...r.themeOptions,
22
+ ...T,
22
23
  palette: {
23
- ...o.themeOptions?.palette ?? {},
24
+ ...r.themeOptions?.palette ?? {},
24
25
  ...e
25
26
  },
26
27
  shape: { borderRadius: 8 },
27
- direction: r.themeDirection,
28
- shadows: n ? s.light : s.dark,
28
+ direction: o.themeDirection,
29
+ shadows: n ? l.light : l.dark,
29
30
  customShadows: {
30
- primary: n ? `0 4px 8px -4px ${p(m(r.themeColor)?.enabledLight, 0.12)},
31
- 0 2px 27px 2px ${p(m(r.themeColor)?.enabledLight, 0.02)}` : `0 4px 8px -4px ${p(m(r.themeColor)?.enabledDark, 0.12)},
32
- 0 2px 27px 2px ${p(m(r.themeColor)?.enabledDark, 0.02)}`,
33
- ...x(r.themeMode),
34
- primary2: n ? `0px 2px 3px 0px ${p(m(r.themeColor)?.hoverOpacityLight, 0.2)}` : `0px 2px 3px 0px ${p(m(r.themeColor)?.hoverOpacityDark, 0.2)}`
31
+ primary: n ? `0 4px 8px -4px ${s(i(o.themeColor)?.enabledLight, 0.12)},
32
+ 0 2px 27px 2px ${s(i(o.themeColor)?.enabledLight, 0.02)}` : `0 4px 8px -4px ${s(i(o.themeColor)?.enabledDark, 0.12)},
33
+ 0 2px 27px 2px ${s(i(o.themeColor)?.enabledDark, 0.02)}`,
34
+ ...C(o.themeMode),
35
+ primary2: n ? `0px 2px 3px 0px ${s(i(o.themeColor)?.hoverOpacityLight, 0.2)}` : `0px 2px 3px 0px ${s(i(o.themeColor)?.hoverOpacityDark, 0.2)}`
35
36
  },
36
- stretch: r.themeStretch
37
- }, l(o.themeOptions);
38
- }, i = (o) => {
39
- o.themeSettingsPersistFn?.(o.themeUserSettings);
40
- }, T = (o) => c(
41
- d(
42
- u((r, n) => ({
43
- ...o,
37
+ stretch: o.themeStretch
38
+ }, c(r.themeOptions);
39
+ }, h = (r) => {
40
+ r.themeSettingsPersistFn?.(r.themeUserSettings);
41
+ };
42
+ function g(r) {
43
+ r.hostToolsEventsEmit?.(
44
+ f.EMMIT_EVENT_HOST_THEME_CHANGE,
45
+ r.themeUserSettings.themeMode
46
+ );
47
+ }
48
+ const b = (r) => d(
49
+ u(
50
+ U((o, n) => ({
51
+ ...r,
44
52
  settingsActions: {
45
53
  /**
46
54
  * Inicializa la tienda de configuración del tema
@@ -50,8 +58,8 @@ const h = (o) => {
50
58
  * @updatedUser Juan Escobar - automatic
51
59
  */
52
60
  init: () => {
53
- r((t) => {
54
- h(t);
61
+ o((t) => {
62
+ m(t);
55
63
  });
56
64
  },
57
65
  /**
@@ -62,8 +70,9 @@ const h = (o) => {
62
70
  * @updatedUser Juan Escobar - automatic
63
71
  */
64
72
  setThemeSettings: (t) => {
65
- r((e) => {
66
- e.themeUserSettings = { ...e.themeUserSettings, ...t }, i(e), h(e);
73
+ o((e) => {
74
+ const p = e.themeUserSettings.themeMode;
75
+ e.themeUserSettings = { ...e.themeUserSettings, ...t }, h(e), m(e), p !== e.themeUserSettings.themeMode && g(e);
67
76
  });
68
77
  },
69
78
  /**
@@ -74,11 +83,19 @@ const h = (o) => {
74
83
  * @updatedUser Juan Escobar - automatic
75
84
  */
76
85
  onChangeMode: (t) => {
77
- r((e) => {
86
+ o((e) => {
78
87
  t !== e.themeUserSettings.themeMode && (e.themeUserSettings = {
79
88
  ...e.themeUserSettings,
80
89
  themeMode: t
81
- }, i(e), h(e));
90
+ }, h(e), m(e), g(e));
91
+ });
92
+ },
93
+ /**
94
+ * Register the host-tools emitter used to broadcast theme-mode changes.
95
+ */
96
+ registerHostToolsEventsEmit: (t) => {
97
+ o((e) => {
98
+ e.hostToolsEventsEmit = t;
82
99
  });
83
100
  },
84
101
  /**
@@ -89,7 +106,7 @@ const h = (o) => {
89
106
  * @updatedUser Juan Escobar - automatic
90
107
  */
91
108
  handleOpen: () => {
92
- r((t) => {
109
+ o((t) => {
93
110
  t.open = !t.open;
94
111
  });
95
112
  },
@@ -101,11 +118,11 @@ const h = (o) => {
101
118
  * @updatedUser Juan Escobar - automatic
102
119
  */
103
120
  onChangeDirection: (t) => {
104
- r((e) => {
121
+ o((e) => {
105
122
  t !== e.themeUserSettings.themeDirection && (e.themeUserSettings = {
106
123
  ...e.themeUserSettings,
107
124
  themeDirection: t
108
- }, i(e), h(e));
125
+ }, h(e), m(e));
109
126
  });
110
127
  },
111
128
  /**
@@ -116,11 +133,11 @@ const h = (o) => {
116
133
  * @updatedUser Juan Escobar - automatic
117
134
  */
118
135
  onChangeColor: (t) => {
119
- r((e) => {
136
+ o((e) => {
120
137
  t !== e.themeUserSettings.themeColor && (e.themeUserSettings = {
121
138
  ...e.themeUserSettings,
122
139
  themeColor: t
123
- }, i(e), h(e));
140
+ }, h(e), m(e));
124
141
  });
125
142
  },
126
143
  /**
@@ -131,11 +148,11 @@ const h = (o) => {
131
148
  * @updatedUser Juan Escobar - automatic
132
149
  */
133
150
  onChangeLayout: (t) => {
134
- r((e) => {
151
+ o((e) => {
135
152
  e.themeUserSettings = {
136
153
  ...e.themeUserSettings,
137
154
  themeLayout: t.target.value
138
- }, i(e), h(e);
155
+ }, h(e), m(e);
139
156
  });
140
157
  },
141
158
  /**
@@ -146,11 +163,11 @@ const h = (o) => {
146
163
  * @updatedUser Juan Escobar - automatic
147
164
  */
148
165
  onToggleStretch: () => {
149
- r((t) => {
166
+ o((t) => {
150
167
  t.themeUserSettings = {
151
168
  ...t.themeUserSettings,
152
169
  themeStretch: !t.themeUserSettings.themeStretch
153
- }, i(t), h(t);
170
+ }, h(t), m(t);
154
171
  });
155
172
  },
156
173
  /**
@@ -161,10 +178,11 @@ const h = (o) => {
161
178
  * @updatedUser Juan Escobar - automatic
162
179
  */
163
180
  onResetSetting: () => {
164
- r((t) => {
181
+ o((t) => {
182
+ const e = t.themeUserSettings.themeMode;
165
183
  t.themeUserSettings = {
166
- ...g
167
- }, i(t), h(t);
184
+ ...S
185
+ }, h(t), m(t), e !== t.themeUserSettings.themeMode && g(t);
168
186
  });
169
187
  }
170
188
  }
@@ -173,5 +191,5 @@ const h = (o) => {
173
191
  )
174
192
  );
175
193
  export {
176
- T as createThemeSettingsStore
194
+ b as createThemeSettingsStore
177
195
  };
@@ -1,3 +1,4 @@
1
+ import { EmmitFunction } from '@m4l/core';
1
2
  import { PresetsOptionsColorMain, ThemeUserColor } from '@m4l/styles';
2
3
  import { Theme } from '@mui/material/styles';
3
4
  import { ReactNode } from 'react';
@@ -41,6 +42,11 @@ export interface ThemeSettingsStore {
41
42
  * @updatedUser Juan Escobar - automatic
42
43
  */
43
44
  themeSettingsPersistFn?: (newValue: ThemeUserSettings) => void;
45
+ /**
46
+ * Host-owned event emitter injected when this store should broadcast mode changes
47
+ * through the shared host-tools contract.
48
+ */
49
+ hostToolsEventsEmit?: EmmitFunction;
44
50
  /**
45
51
  * "open" es una variable que se encarga de abrir o cerrar el formulario
46
52
  * @createdAt 2024-10-08 13:22:53 - automatic
@@ -59,6 +65,7 @@ export interface ThemeSettingsStateWithActions extends ThemeSettingsStore {
59
65
  onChangeColor: (color: ThemeUserColor) => void;
60
66
  onChangeLayout: (event: React.ChangeEvent<HTMLInputElement>) => void;
61
67
  handleOpen: () => void;
68
+ registerHostToolsEventsEmit: (eventsEmit?: EmmitFunction) => void;
62
69
  setThemeSettings: (newValue: Partial<ThemeUserSettings>) => void;
63
70
  };
64
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/graphics/src/contexts/ThemeSettingsContext/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,uBAAuB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAG,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC;AAC7C,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,KAAK,CAAC;AAC/C,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,YAAY,CAAC;AACxD,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAEvC;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,aAAa,CAAC;IACzB,cAAc,EAAE,kBAAkB,CAAC;IACnC,UAAU,EAAE,cAAc,CAAC;IAC3B,YAAY,EAAE,gBAAgB,CAAC;IAC/B,WAAW,EAAE,eAAe,CAAC;CAE9B,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,iBAAiB,EAAE,iBAAiB,CAAC;IACrC;;;OAGG;IACH,YAAY,EAAE,KAAK,CAAC;IACpB;;;OAGG;IACH,uBAAuB,EAAE,uBAAuB,CAAC;IACjD;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC/D;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,MAAM,8BAA8B,GAAG,kBAAkB,CAAC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