@m4l/graphics 0.0.15 → 0.0.19

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 (83) hide show
  1. package/dist/commonjs.js +1 -0
  2. package/dist/components/Page/index.js +31 -0
  3. package/dist/components/ProgressBarStyle/index.js +34 -0
  4. package/dist/components/index.js +4 -1318
  5. package/dist/contexts/HostThemeContext/index.js +71 -0
  6. package/dist/contexts/LocalesContext/index.js +46 -0
  7. package/dist/contexts/index.js +3 -174
  8. package/dist/hooks/index.js +6 -40
  9. package/dist/hooks/useHostTheme/index.js +9 -0
  10. package/dist/hooks/useLocales/index.js +9 -0
  11. package/dist/hooks/useResponsive/index.js +26 -0
  12. package/dist/index.js +19 -1654
  13. package/dist/lib/components/Page/index.d.ts +3 -9
  14. package/dist/lib/components/Page/types.d.ts +7 -0
  15. package/dist/lib/components/{ProgressBar → ProgressBarStyle}/index.d.ts +0 -1
  16. package/dist/lib/components/index.d.ts +1 -6
  17. package/dist/lib/hooks/useHostTheme/index.d.ts +1 -0
  18. package/dist/lib/hooks/useLocales/index.d.ts +1 -0
  19. package/dist/lib/hooks/{useResponsive.d.ts → useResponsive/index.d.ts} +0 -0
  20. package/dist/lib/index.d.ts +0 -1
  21. package/dist/lib/theme/palette.d.ts +1 -2
  22. package/dist/react-helmet-async-invariant.js +19 -0
  23. package/dist/react-helmet-async-react-fast-compare.js +90 -0
  24. package/dist/react-helmet-async-shallowequal.js +32 -0
  25. package/dist/react-helmet-async.js +363 -0
  26. package/dist/theme/index.js +1553 -0
  27. package/dist/utils/index.js +91 -0
  28. package/package.json +3 -9
  29. package/dist/components/mui_extended/index.js +0 -53
  30. package/dist/layouts/index.js +0 -39
  31. package/dist/lib/components/CompanyLogo/index.d.ts +0 -3
  32. package/dist/lib/components/CompanyLogo/styles.d.ts +0 -5
  33. package/dist/lib/components/CompanyLogo/types.d.ts +0 -6
  34. package/dist/lib/components/Image/index.d.ts +0 -3
  35. package/dist/lib/components/Image/styles.d.ts +0 -5
  36. package/dist/lib/components/Image/types.d.ts +0 -19
  37. package/dist/lib/components/LanguagePopover/index.d.ts +0 -3
  38. package/dist/lib/components/LanguagePopover/types.d.ts +0 -3
  39. package/dist/lib/components/LinkWithRoute/index.d.ts +0 -3
  40. package/dist/lib/components/LinkWithRoute/types.d.ts +0 -7
  41. package/dist/lib/components/Loadable/index.d.ts +0 -2
  42. package/dist/lib/components/Typography/index.d.ts +0 -3
  43. package/dist/lib/components/Typography/types.d.ts +0 -5
  44. package/dist/lib/components/animate/DialogAnimate.d.ts +0 -7
  45. package/dist/lib/components/animate/FabButtonAnimate.d.ts +0 -8
  46. package/dist/lib/components/animate/IconButtonAnimate/index.d.ts +0 -4
  47. package/dist/lib/components/animate/MotionContainer.d.ts +0 -10
  48. package/dist/lib/components/animate/MotionInView.d.ts +0 -9
  49. package/dist/lib/components/animate/MotionLazyContainer.d.ts +0 -6
  50. package/dist/lib/components/animate/TextAnimate.d.ts +0 -9
  51. package/dist/lib/components/animate/index.d.ts +0 -8
  52. package/dist/lib/components/animate/type.d.ts +0 -26
  53. package/dist/lib/components/animate/variants/actions.d.ts +0 -5
  54. package/dist/lib/components/animate/variants/background.d.ts +0 -104
  55. package/dist/lib/components/animate/variants/bounce.d.ts +0 -136
  56. package/dist/lib/components/animate/variants/container.d.ts +0 -19
  57. package/dist/lib/components/animate/variants/fade.d.ts +0 -217
  58. package/dist/lib/components/animate/variants/flip.d.ts +0 -75
  59. package/dist/lib/components/animate/variants/index.d.ts +0 -12
  60. package/dist/lib/components/animate/variants/path.d.ts +0 -14
  61. package/dist/lib/components/animate/variants/rotate.d.ts +0 -39
  62. package/dist/lib/components/animate/variants/scale.d.ts +0 -75
  63. package/dist/lib/components/animate/variants/slide.d.ts +0 -155
  64. package/dist/lib/components/animate/variants/transition.d.ts +0 -13
  65. package/dist/lib/components/animate/variants/zoom.d.ts +0 -199
  66. package/dist/lib/components/mui_extended/LoadingButton/index.d.ts +0 -3
  67. package/dist/lib/components/mui_extended/LoadingButton/skeleton.d.ts +0 -2
  68. package/dist/lib/components/mui_extended/LoadingButton/styles.d.ts +0 -2
  69. package/dist/lib/components/mui_extended/LoadingButton/types.d.ts +0 -5
  70. package/dist/lib/components/mui_extended/Typography/index.d.ts +0 -3
  71. package/dist/lib/components/mui_extended/Typography/types.d.ts +0 -5
  72. package/dist/lib/components/mui_extended/index.d.ts +0 -37
  73. package/dist/lib/hooks/useHostTheme.d.ts +0 -1
  74. package/dist/lib/hooks/useLocales.d.ts +0 -1
  75. package/dist/lib/layouts/NoAuthModuleLayout/components/ModuleWrapper/index.d.ts +0 -3
  76. package/dist/lib/layouts/NoAuthModuleLayout/components/ModuleWrapper/styles.d.ts +0 -13
  77. package/dist/lib/layouts/NoAuthModuleLayout/components/ModuleWrapper/types.d.ts +0 -4
  78. package/dist/lib/layouts/NoAuthModuleLayout/contexts/NoAuthModuleContext/index.d.ts +0 -5
  79. package/dist/lib/layouts/NoAuthModuleLayout/contexts/NoAuthModuleContext/types.d.ts +0 -12
  80. package/dist/lib/layouts/NoAuthModuleLayout/index.d.ts +0 -3
  81. package/dist/lib/layouts/NoAuthModuleLayout/types.d.ts +0 -11
  82. package/dist/lib/layouts/index.d.ts +0 -1
  83. package/dist/node_modules.js +0 -150
@@ -0,0 +1,71 @@
1
+ import { createContext, useState, useMemo, useCallback, useEffect } from "react";
2
+ import { CssBaseline } from "@mui/material";
3
+ import { createTheme, StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
4
+ import { voidFunction, useHostTools, EmitEvents } from "@m4l/core";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ const initialValue = {
7
+ hostThemeOptions: {},
8
+ fnComponentsOverrides: voidFunction
9
+ };
10
+ const HostThemeContext = createContext(initialValue);
11
+ function HostThemeProvider(props) {
12
+ const {
13
+ children,
14
+ hostThemeOptions,
15
+ fnComponentsOverrides,
16
+ isMicroFrontEnd
17
+ } = props;
18
+ const [finalThemeOptions, setFinalThemeOptions] = useState(hostThemeOptions);
19
+ const {
20
+ events_add_listener,
21
+ events_remove_listener,
22
+ events_emit
23
+ } = useHostTools();
24
+ const [isFirstTime, setIsFirstTime] = useState(true);
25
+ const finalTheme = useMemo(() => {
26
+ const theme = createTheme(finalThemeOptions);
27
+ theme.components = fnComponentsOverrides(theme);
28
+ return theme;
29
+ }, [finalThemeOptions]);
30
+ const onUpdateOverrides = useCallback((newThemeOptions) => {
31
+ console.debug("Emit HostThemeProvider", newThemeOptions);
32
+ setFinalThemeOptions(newThemeOptions);
33
+ }, []);
34
+ useEffect(() => {
35
+ if (isMicroFrontEnd) {
36
+ events_add_listener(EmitEvents.EMMIT_EVENT_HOST_THEME_CHANGE, onUpdateOverrides);
37
+ }
38
+ return () => {
39
+ if (isMicroFrontEnd) {
40
+ console.log("****** REMOVE LISTENER host_theme_change");
41
+ events_remove_listener("host_theme_change", onUpdateOverrides);
42
+ }
43
+ };
44
+ }, []);
45
+ useEffect(() => {
46
+ if (isFirstTime) {
47
+ setIsFirstTime(false);
48
+ return;
49
+ }
50
+ if (!isMicroFrontEnd) {
51
+ setFinalThemeOptions(hostThemeOptions);
52
+ events_emit(EmitEvents.EMMIT_EVENT_HOST_THEME_CHANGE, hostThemeOptions);
53
+ }
54
+ }, [hostThemeOptions]);
55
+ return /* @__PURE__ */ jsx(HostThemeContext.Provider, {
56
+ value: {
57
+ hostThemeOptions: finalThemeOptions,
58
+ fnComponentsOverrides
59
+ },
60
+ children: /* @__PURE__ */ jsx(StyledEngineProvider, {
61
+ injectFirst: true,
62
+ children: /* @__PURE__ */ jsxs(ThemeProvider, {
63
+ theme: finalTheme,
64
+ children: [/* @__PURE__ */ jsx(CssBaseline, {
65
+ enableColorScheme: true
66
+ }), children]
67
+ })
68
+ })
69
+ });
70
+ }
71
+ export { HostThemeContext as H, HostThemeProvider as a };
@@ -0,0 +1,46 @@
1
+ import { createContext, useMemo, useState } from "react";
2
+ import esLocale from "date-fns/locale/es";
3
+ import frLocale from "date-fns/locale/fr";
4
+ import enLocale from "date-fns/locale/en-US";
5
+ import { useLocalStorage, useEnvironment } from "@m4l/core";
6
+ import { jsx } from "react/jsx-runtime";
7
+ const LocalesContext = createContext(null);
8
+ function LocalesProvider({
9
+ children
10
+ }) {
11
+ const [langStorage, setLangStorage] = useLocalStorage("langStorage", "en");
12
+ const {
13
+ host_static_assets,
14
+ environment
15
+ } = useEnvironment();
16
+ const LANGS = useMemo(() => [{
17
+ label: "English",
18
+ value: "en",
19
+ locale: enLocale,
20
+ icon: `${host_static_assets}/${environment}/frontend/commons/assets/icons/langs/lang_en.svg`
21
+ }, {
22
+ label: "Espa\xF1ol",
23
+ value: "es",
24
+ locale: esLocale,
25
+ icon: `${host_static_assets}/${environment}/frontend/commons/assets/icons/langs/lang_es.svg`
26
+ }, {
27
+ label: "French",
28
+ value: "fr",
29
+ locale: frLocale,
30
+ icon: `${host_static_assets}/${environment}/frontend/commons/assets/icons/langs/lang_fr.svg`
31
+ }], []);
32
+ const [currentLang, setCurrentLang] = useState(LANGS.find((_lang) => _lang.value === langStorage) || LANGS[0]);
33
+ const onChangeLang = (newlang) => {
34
+ setLangStorage(newlang);
35
+ setCurrentLang(LANGS.find((_lang) => _lang.value === newlang) || LANGS[0]);
36
+ };
37
+ return /* @__PURE__ */ jsx(LocalesContext.Provider, {
38
+ value: {
39
+ currentLang,
40
+ onChangeLang,
41
+ allLang: LANGS
42
+ },
43
+ children
44
+ });
45
+ }
46
+ export { LocalesContext as L, LocalesProvider as a };
@@ -1,174 +1,3 @@
1
- import { createContext, useMemo, useState, useCallback, useEffect } from "react";
2
- import { useLocalStorage, useEnvironment, voidFunction, useHostTools, EmitEvents, getLocalStorage, useNetwork, useFlags } from "@m4l/core";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- import esLocale from "date-fns/locale/es";
5
- import frLocale from "date-fns/locale/fr";
6
- import enLocale from "date-fns/locale/en-US";
7
- import { CssBaseline } from "@mui/material";
8
- import { createTheme, StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
9
- import "react-helmet-async";
10
- const LocalesContext = createContext(null);
11
- function LocalesProvider({
12
- children
13
- }) {
14
- const [langStorage, setLangStorage] = useLocalStorage("langStorage", "en");
15
- const {
16
- host_static_assets,
17
- environment
18
- } = useEnvironment();
19
- const LANGS = useMemo(() => [{
20
- label: "English",
21
- value: "en",
22
- locale: enLocale,
23
- icon: `${host_static_assets}/${environment}/frontend/commons/assets/icons/langs/lang_en.svg`
24
- }, {
25
- label: "Espa\xF1ol",
26
- value: "es",
27
- locale: esLocale,
28
- icon: `${host_static_assets}/${environment}/frontend/commons/assets/icons/langs/lang_es.svg`
29
- }, {
30
- label: "French",
31
- value: "fr",
32
- locale: frLocale,
33
- icon: `${host_static_assets}/${environment}/frontend/commons/assets/icons/langs/lang_fr.svg`
34
- }], []);
35
- const [currentLang, setCurrentLang] = useState(LANGS.find((_lang) => _lang.value === langStorage) || LANGS[0]);
36
- const onChangeLang = (newlang) => {
37
- setLangStorage(newlang);
38
- setCurrentLang(LANGS.find((_lang) => _lang.value === newlang) || LANGS[0]);
39
- };
40
- return /* @__PURE__ */ jsx(LocalesContext.Provider, {
41
- value: {
42
- currentLang,
43
- onChangeLang,
44
- allLang: LANGS
45
- },
46
- children
47
- });
48
- }
49
- const initialValue = {
50
- hostThemeOptions: {},
51
- fnComponentsOverrides: voidFunction
52
- };
53
- const HostThemeContext = createContext(initialValue);
54
- function HostThemeProvider(props) {
55
- const {
56
- children,
57
- hostThemeOptions,
58
- fnComponentsOverrides,
59
- isMicroFrontEnd
60
- } = props;
61
- const [finalThemeOptions, setFinalThemeOptions] = useState(hostThemeOptions);
62
- const {
63
- events_add_listener,
64
- events_remove_listener,
65
- events_emit
66
- } = useHostTools();
67
- const [isFirstTime, setIsFirstTime] = useState(true);
68
- const finalTheme = useMemo(() => {
69
- const theme = createTheme(finalThemeOptions);
70
- theme.components = fnComponentsOverrides(theme);
71
- return theme;
72
- }, [finalThemeOptions]);
73
- const onUpdateOverrides = useCallback((newThemeOptions) => {
74
- console.debug("Emit HostThemeProvider", newThemeOptions);
75
- setFinalThemeOptions(newThemeOptions);
76
- }, []);
77
- useEffect(() => {
78
- if (isMicroFrontEnd) {
79
- events_add_listener(EmitEvents.EMMIT_EVENT_HOST_THEME_CHANGE, onUpdateOverrides);
80
- }
81
- return () => {
82
- if (isMicroFrontEnd) {
83
- console.log("****** REMOVE LISTENER host_theme_change");
84
- events_remove_listener("host_theme_change", onUpdateOverrides);
85
- }
86
- };
87
- }, []);
88
- useEffect(() => {
89
- if (isFirstTime) {
90
- setIsFirstTime(false);
91
- return;
92
- }
93
- if (!isMicroFrontEnd) {
94
- setFinalThemeOptions(hostThemeOptions);
95
- events_emit(EmitEvents.EMMIT_EVENT_HOST_THEME_CHANGE, hostThemeOptions);
96
- }
97
- }, [hostThemeOptions]);
98
- return /* @__PURE__ */ jsx(HostThemeContext.Provider, {
99
- value: {
100
- hostThemeOptions: finalThemeOptions,
101
- fnComponentsOverrides
102
- },
103
- children: /* @__PURE__ */ jsx(StyledEngineProvider, {
104
- injectFirst: true,
105
- children: /* @__PURE__ */ jsxs(ThemeProvider, {
106
- theme: finalTheme,
107
- children: [/* @__PURE__ */ jsx(CssBaseline, {
108
- enableColorScheme: true
109
- }), children]
110
- })
111
- })
112
- });
113
- }
114
- const initialState = {
115
- moduleId: 0,
116
- styleOptions: {
117
- company_logo_small_url: "",
118
- company_logo_normal_url: ""
119
- }
120
- };
121
- const ModuleContext = createContext(initialState);
122
- function ModuleProvider(props) {
123
- const {
124
- children,
125
- moduleId
126
- } = props;
127
- const [styleOptions, setStyleOptions] = useState(getLocalStorage("styleOptions", {
128
- company_logo_small_url: "",
129
- company_logo_normal_url: ""
130
- }));
131
- const {
132
- networkOperation
133
- } = useNetwork();
134
- const {
135
- domain_token
136
- } = useEnvironment();
137
- const {
138
- flags,
139
- addFlag
140
- } = useFlags();
141
- useEffect(() => {
142
- let mounted = true;
143
- if (flags.findIndex((f) => f === "dictionary_loaded") < 0 || flags.findIndex((f) => f === "style_loaded") > -1) {
144
- return;
145
- }
146
- networkOperation({
147
- method: "GET",
148
- endPoint: `style`,
149
- parms: {
150
- domain_token
151
- }
152
- }).then((response) => {
153
- if (mounted) {
154
- console.log("Result - ModuleProvider - Load Style", response);
155
- setStyleOptions({
156
- ...response.data
157
- });
158
- addFlag("style_loaded");
159
- }
160
- }).finally(() => {
161
- });
162
- return function cleanUp() {
163
- mounted = false;
164
- };
165
- }, [flags]);
166
- return /* @__PURE__ */ jsx(ModuleContext.Provider, {
167
- value: {
168
- styleOptions,
169
- moduleId
170
- },
171
- children
172
- });
173
- }
174
- export { HostThemeContext as H, LocalesContext as L, ModuleProvider as M, LocalesProvider as a, HostThemeProvider as b };
1
+ import "./LocalesContext/index.js";
2
+ import "./HostThemeContext/index.js";
3
+ import "../react-helmet-async.js";
@@ -1,37 +1,9 @@
1
- import { useContext, useRef, useEffect, useState } from "react";
2
- import { L as LocalesContext, H as HostThemeContext } from "../contexts/index.js";
3
- import { useTheme } from "@mui/material/styles";
4
- import useMediaQuery from "@mui/material/useMediaQuery";
1
+ import { useRef, useEffect, useState } from "react";
2
+ import "@mui/material/styles";
3
+ import "@mui/material/useMediaQuery";
4
+ import "../contexts/LocalesContext/index.js";
5
+ import "../contexts/HostThemeContext/index.js";
5
6
  import "react-hook-form";
6
- const useLocales = () => {
7
- const context = useContext(LocalesContext);
8
- if (!context)
9
- throw new Error("useLocales context must be use inside LocalesProvider");
10
- return context;
11
- };
12
- function useResponsive(query, key, start, end) {
13
- const theme = useTheme();
14
- const mediaUp = useMediaQuery(theme.breakpoints.up(key));
15
- const mediaDown = useMediaQuery(theme.breakpoints.down(key));
16
- const mediaBetween = useMediaQuery(theme.breakpoints.between(start, end));
17
- const mediaOnly = useMediaQuery(theme.breakpoints.only(key));
18
- if (query === "up") {
19
- return mediaUp;
20
- }
21
- if (query === "down") {
22
- return mediaDown;
23
- }
24
- if (query === "between") {
25
- return mediaBetween;
26
- }
27
- if (query === "only") {
28
- return mediaOnly;
29
- }
30
- }
31
- function useResponsiveDesktop() {
32
- const isDesktop = useResponsive("up", "sm");
33
- return isDesktop;
34
- }
35
7
  function useIsMountedRef() {
36
8
  const isMounted = useRef(true);
37
9
  useEffect(() => () => {
@@ -56,10 +28,4 @@ function useOffSetTop(top) {
56
28
  }, [isTop]);
57
29
  return offsetTop;
58
30
  }
59
- const useHostTheme = () => {
60
- const context = useContext(HostThemeContext);
61
- if (!context)
62
- throw new Error("useHostTheme context must be use inside HostThemeProvider");
63
- return context;
64
- };
65
- export { useResponsive as a, useResponsiveDesktop as b, useIsMountedRef as c, useOffSetTop as d, useHostTheme as e, useLocales as u };
31
+ export { useOffSetTop as a, useIsMountedRef as u };
@@ -0,0 +1,9 @@
1
+ import { useContext } from "react";
2
+ import { H as HostThemeContext } from "../../contexts/HostThemeContext/index.js";
3
+ const useHostTheme = () => {
4
+ const context = useContext(HostThemeContext);
5
+ if (!context)
6
+ throw new Error("useHostTheme context must be use inside HostThemeProvider");
7
+ return context;
8
+ };
9
+ export { useHostTheme as u };
@@ -0,0 +1,9 @@
1
+ import { useContext } from "react";
2
+ import { L as LocalesContext } from "../../contexts/LocalesContext/index.js";
3
+ const useLocales = () => {
4
+ const context = useContext(LocalesContext);
5
+ if (!context)
6
+ throw new Error("useLocales context must be use inside LocalesProvider");
7
+ return context;
8
+ };
9
+ export { useLocales as u };
@@ -0,0 +1,26 @@
1
+ import { useTheme } from "@mui/material/styles";
2
+ import useMediaQuery from "@mui/material/useMediaQuery";
3
+ function useResponsive(query, key, start, end) {
4
+ const theme = useTheme();
5
+ const mediaUp = useMediaQuery(theme.breakpoints.up(key));
6
+ const mediaDown = useMediaQuery(theme.breakpoints.down(key));
7
+ const mediaBetween = useMediaQuery(theme.breakpoints.between(start, end));
8
+ const mediaOnly = useMediaQuery(theme.breakpoints.only(key));
9
+ if (query === "up") {
10
+ return mediaUp;
11
+ }
12
+ if (query === "down") {
13
+ return mediaDown;
14
+ }
15
+ if (query === "between") {
16
+ return mediaBetween;
17
+ }
18
+ if (query === "only") {
19
+ return mediaOnly;
20
+ }
21
+ }
22
+ function useResponsiveDesktop() {
23
+ const isDesktop = useResponsive("up", "sm");
24
+ return isDesktop;
25
+ }
26
+ export { useResponsiveDesktop as a, useResponsive as u };