@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.
- package/components/GlobalStyles/index.d.ts +0 -1
- package/contexts/FormatterContext/index.d.ts +1 -2
- package/contexts/FormatterContext/{index-Ch6IW7j8.js → index.js} +1 -1
- package/contexts/FormatterContext/types.d.ts +2 -2
- package/contexts/HostThemeContext/index.d.ts +1 -2
- package/contexts/HostThemeContext/index.js +46 -0
- package/contexts/HostThemeContext/types.d.ts +6 -5
- package/contexts/LocalesContext/helper.js +35 -0
- package/contexts/LocalesContext/index.d.ts +1 -2
- package/contexts/LocalesContext/index.js +69 -0
- package/contexts/LocalesContext/types.d.ts +4 -4
- package/contexts/ResponsiveContainerContext/constants.js +4 -0
- package/contexts/ResponsiveContainerContext/index.d.ts +3 -4
- package/contexts/ResponsiveContainerContext/index.js +51 -0
- package/contexts/ResponsiveContainerContext/store.d.ts +3 -3
- package/contexts/ResponsiveContainerContext/store.js +26 -0
- package/contexts/ResponsiveContainerContext/types.d.ts +4 -5
- package/contexts/ThemeSettingsContext/ThemeSettingsContext.d.ts +4 -5
- package/contexts/ThemeSettingsContext/ThemeSettingsContext.js +32 -0
- package/contexts/ThemeSettingsContext/constants.js +11 -0
- package/contexts/ThemeSettingsContext/index.js +1 -0
- package/contexts/ThemeSettingsContext/store.d.ts +2 -2
- package/contexts/ThemeSettingsContext/store.js +118 -0
- package/contexts/ThemeSettingsContext/types.d.ts +14 -11
- package/contexts/index.js +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useFormatter/index.d.ts +1 -1
- package/hooks/useFormatter/index.js +11 -0
- package/hooks/useHostTheme/index.d.ts +1 -1
- package/hooks/useHostTheme/index.js +11 -0
- package/hooks/useIsMobile/{index-Bro0dV28.js → index.js} +5 -5
- package/hooks/useIsMountedRef/index.d.ts +1 -2
- package/hooks/useIsMountedRef/index.js +13 -0
- package/hooks/useLocales/index.d.ts +1 -1
- package/hooks/useLocales/index.js +11 -0
- package/hooks/useOffSetTop.js +12 -0
- package/hooks/useResizeObserver/index.d.ts +1 -2
- package/hooks/useResizeObserver/index.js +18 -0
- package/hooks/useResponsive/index.js +7 -0
- package/hooks/useResponsiveContainer/index.js +12 -0
- package/hooks/useThemSettingsStore/index.js +12 -0
- package/index.js +44 -35
- package/package.json +55 -11
- package/utils/anchorEl.d.ts +2 -2
- package/utils/anchorEl.js +49 -0
- package/utils/index.js +1 -0
- package/utils/strings.js +4 -0
- package/commonjs-BCz0-aDl.js +0 -9
- package/contexts/HostThemeContext/index-BMSwOCtA.js +0 -44
- package/contexts/LocalesContext/index-C89UlO0s.js +0 -101
- package/contexts/index-DEyJidab.js +0 -262
- package/hooks/index-Y3uj_IzK.js +0 -52
- package/hooks/useFormatter/index-BBgQ4lJL.js +0 -10
- package/hooks/useLocales/index-_thMBNE7.js +0 -10
- package/hooks/useResponsive/index-Dki-WJi8.js +0 -16
- package/node_modules-BHhXVwYT.js +0 -4569
- package/utils/index-DZG6QXjf.js +0 -51
- /package/components/{GlobalStyle/index-C3p7OfnO.js → GlobalStyles/index.js} +0 -0
- /package/components/{index-l0sNRNKZ.js → index.js} +0 -0
- /package/hooks/useFirstRender/{index-B-Q0TTn0.js → index.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/hooks/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useFormatter: () => import(
|
|
1
|
+
export declare const useFormatter: () => import('../..').Formatters;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as r } from "react";
|
|
2
|
+
import { F as e } from "../../contexts/FormatterContext/index.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 +1 @@
|
|
|
1
|
-
export declare const useHostTheme: () => import(
|
|
1
|
+
export declare const useHostTheme: () => import('../..').HostThemeType;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as t } from "react";
|
|
2
|
+
import { H as o } from "../../contexts/HostThemeContext/index.js";
|
|
3
|
+
const m = () => {
|
|
4
|
+
const e = t(o);
|
|
5
|
+
if (!e)
|
|
6
|
+
throw new Error("useHostTheme context must be use inside HostThemeProvider");
|
|
7
|
+
return e;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
m as u
|
|
11
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useState as n, useEffect as o } from "react";
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
const [
|
|
2
|
+
import s from "lodash/throttle";
|
|
3
|
+
const i = () => typeof navigator > "u" ? !1 : /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), l = () => {
|
|
4
|
+
const [t, r] = n(i());
|
|
5
5
|
return o(() => {
|
|
6
6
|
const e = s(
|
|
7
7
|
() => {
|
|
8
|
-
r(
|
|
8
|
+
r(i());
|
|
9
9
|
},
|
|
10
10
|
200,
|
|
11
11
|
{
|
|
@@ -15,7 +15,7 @@ const t = () => typeof navigator > "u" ? !1 : /Android|webOS|iPhone|iPad|iPod|Bl
|
|
|
15
15
|
return window.addEventListener("resize", e), e(), () => {
|
|
16
16
|
window.removeEventListener("resize", e), e.cancel();
|
|
17
17
|
};
|
|
18
|
-
}, []),
|
|
18
|
+
}, []), t;
|
|
19
19
|
};
|
|
20
20
|
export {
|
|
21
21
|
l as u
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function useIsMountedRef(): import("react").MutableRefObject<boolean>;
|
|
1
|
+
export declare function useIsMountedRef(): import('react').MutableRefObject<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useLocales: () => import(
|
|
1
|
+
export declare const useLocales: () => import('../../contexts/LocalesContext/types').LocalesContextProps;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as o } from "react";
|
|
2
|
+
import { L as t } from "../../contexts/LocalesContext/index.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
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useState as s, useEffect as n } from "react";
|
|
2
|
+
function l(t) {
|
|
3
|
+
const [f, e] = s(!1), o = t || 100;
|
|
4
|
+
return n(() => (window.onscroll = () => {
|
|
5
|
+
window.pageYOffset > o ? e(!0) : e(!1);
|
|
6
|
+
}, () => {
|
|
7
|
+
window.onscroll = null;
|
|
8
|
+
}), [o]), f;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
l as u
|
|
12
|
+
};
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function useResizeObserver<T extends HTMLElement>(callback: (target: T, entry: ResizeObserverEntry) => void): import("react").RefObject<T>;
|
|
1
|
+
export declare function useResizeObserver<T extends HTMLElement>(callback: (target: T, entry: ResizeObserverEntry) => void): import('react').RefObject<T>;
|
|
3
2
|
export default useResizeObserver;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useRef as u, useLayoutEffect as o } from "react";
|
|
2
|
+
function f(n) {
|
|
3
|
+
const e = u(null);
|
|
4
|
+
return o(() => {
|
|
5
|
+
const r = e?.current;
|
|
6
|
+
if (!r)
|
|
7
|
+
return;
|
|
8
|
+
const t = new ResizeObserver((s) => {
|
|
9
|
+
n(r, s[0]);
|
|
10
|
+
});
|
|
11
|
+
return t.observe(r), () => {
|
|
12
|
+
t.disconnect();
|
|
13
|
+
};
|
|
14
|
+
}, [n, e.current]), e;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
f as u
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useContext as r } from "react";
|
|
2
|
+
import { useStore as n } from "zustand";
|
|
3
|
+
import { R as s } from "../../contexts/ResponsiveContainerContext/index.js";
|
|
4
|
+
function a(t, o) {
|
|
5
|
+
const e = r(s);
|
|
6
|
+
if (!e)
|
|
7
|
+
throw new Error("useAreasStore context must be use inside AreasContext");
|
|
8
|
+
return n(e, t, o);
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
a as u
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useContext as r } from "react";
|
|
2
|
+
import { useStore as n } from "zustand";
|
|
3
|
+
import { T as s } from "../../contexts/ThemeSettingsContext/ThemeSettingsContext.js";
|
|
4
|
+
function S(e, o) {
|
|
5
|
+
const t = r(s);
|
|
6
|
+
if (!t)
|
|
7
|
+
throw new Error("useSettingsStore context must be use inside SettignsContext");
|
|
8
|
+
return n(t, e, o);
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
S as u
|
|
12
|
+
};
|
package/index.js
CHANGED
|
@@ -1,40 +1,49 @@
|
|
|
1
|
-
import { G as
|
|
2
|
-
import {
|
|
3
|
-
import { F as m, a as p } from "./contexts/FormatterContext/index
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { u as
|
|
10
|
-
import { u as
|
|
11
|
-
import { u as
|
|
12
|
-
import {
|
|
1
|
+
import { G as r } from "./components/GlobalStyles/index.js";
|
|
2
|
+
import { g as s } from "./contexts/LocalesContext/helper.js";
|
|
3
|
+
import { F as m, a as p } from "./contexts/FormatterContext/index.js";
|
|
4
|
+
import { L as f, a as i } from "./contexts/LocalesContext/index.js";
|
|
5
|
+
import { R as u, a as l } from "./contexts/ResponsiveContainerContext/index.js";
|
|
6
|
+
import { H as v, a as C } from "./contexts/HostThemeContext/index.js";
|
|
7
|
+
import { d as g } from "./contexts/ThemeSettingsContext/constants.js";
|
|
8
|
+
import { T as R, a as S } from "./contexts/ThemeSettingsContext/ThemeSettingsContext.js";
|
|
9
|
+
import { u as P } from "./hooks/useFirstRender/index.js";
|
|
10
|
+
import { u as L } from "./hooks/useFormatter/index.js";
|
|
11
|
+
import { u as b } from "./hooks/useIsMountedRef/index.js";
|
|
12
|
+
import { u as w } from "./hooks/useLocales/index.js";
|
|
13
|
+
import { u as G } from "./hooks/useResponsiveContainer/index.js";
|
|
14
|
+
import { u as M } from "./hooks/useIsMobile/index.js";
|
|
15
|
+
import { u as y } from "./hooks/useOffSetTop.js";
|
|
16
|
+
import { u as D } from "./hooks/useHostTheme/index.js";
|
|
17
|
+
import { u as N } from "./hooks/useResizeObserver/index.js";
|
|
18
|
+
import { u as j } from "./hooks/useResponsive/index.js";
|
|
19
|
+
import { u as B } from "./hooks/useThemSettingsStore/index.js";
|
|
20
|
+
import { C as K } from "./utils/strings.js";
|
|
21
|
+
import { g as U } from "./utils/anchorEl.js";
|
|
13
22
|
export {
|
|
14
|
-
|
|
23
|
+
K as Capitalize,
|
|
15
24
|
m as FormatterContext,
|
|
16
25
|
p as FormatterProvider,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
r as GlobalStyles,
|
|
27
|
+
v as HostThemeContext,
|
|
28
|
+
C as HostThemeProvider,
|
|
29
|
+
f as LocalesContext,
|
|
30
|
+
i as LocalesProvider,
|
|
31
|
+
u as ResponsiveContainerContext,
|
|
32
|
+
l as ResponsiveContainerProvider,
|
|
33
|
+
R as ThemeSettingsContext,
|
|
34
|
+
S as ThemeSettingsProvider,
|
|
35
|
+
g as defaultThemeSettings,
|
|
36
|
+
U as getAnchorElPositionWindow,
|
|
37
|
+
s as getLocaleFromNetwork,
|
|
38
|
+
P as useFirstRender,
|
|
39
|
+
L as useFormatter,
|
|
40
|
+
D as useHostTheme,
|
|
41
|
+
M as useIsMobile,
|
|
33
42
|
b as useIsMountedRef,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
w as useLocales,
|
|
44
|
+
y as useOffSetTop,
|
|
45
|
+
N as useResizeObserver,
|
|
46
|
+
G as useResponsiveContainerStore,
|
|
47
|
+
j as useResponsiveDesktop,
|
|
48
|
+
B as useThemeSettingsStore
|
|
40
49
|
};
|
package/package.json
CHANGED
|
@@ -1,22 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/graphics",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "M4L Team*",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@m4l/core": "^2.0.0",
|
|
8
|
-
"@m4l/styles": "^3.0.0",
|
|
9
7
|
"date-fns": "^2.30.0",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
8
|
+
"immer": "^9.0.21",
|
|
9
|
+
"zustand": "4.3.6"
|
|
12
10
|
},
|
|
13
11
|
"peerDependencies": {
|
|
14
|
-
"@
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"lodash.
|
|
12
|
+
"@m4l/core": "^2.0.8",
|
|
13
|
+
"@m4l/styles": "^6.4.1",
|
|
14
|
+
"@mui/material": "^5.15.19",
|
|
15
|
+
"@mui/x-date-pickers": "^6.11.1",
|
|
16
|
+
"@types/react": "^18.0.0",
|
|
17
|
+
"lodash.clonedeep": "^4.0.0",
|
|
18
|
+
"lodash.debounce": "^4.0.0",
|
|
19
|
+
"lodash.isstring": "^4.0.0",
|
|
20
|
+
"lodash.merge": "^4.0.0",
|
|
21
|
+
"lodash.throttle": "^4.0.0",
|
|
22
|
+
"react": "^18.0.0",
|
|
23
|
+
"react-toastify": "10.0.5"
|
|
24
|
+
},
|
|
25
|
+
"peerDependenciesMeta": {
|
|
26
|
+
"@mui/material": {
|
|
27
|
+
"optional": true
|
|
28
|
+
},
|
|
29
|
+
"@mui/x-date-pickers": {
|
|
30
|
+
"optional": true
|
|
31
|
+
},
|
|
32
|
+
"lodash.clonedeep": {
|
|
33
|
+
"optional": true
|
|
34
|
+
},
|
|
35
|
+
"lodash.debounce": {
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
"lodash.isstring": {
|
|
39
|
+
"optional": true
|
|
40
|
+
},
|
|
41
|
+
"lodash.merge": {
|
|
42
|
+
"optional": true
|
|
43
|
+
},
|
|
44
|
+
"lodash.throttle": {
|
|
45
|
+
"optional": true
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"resolutions": {
|
|
49
|
+
"eslint": "^9.0.0",
|
|
50
|
+
"react": "^18.0.0",
|
|
51
|
+
"@types/react": "^18.0.0",
|
|
52
|
+
"@types/react-dom": "^18.0.0",
|
|
53
|
+
"react-dom": "^18.0.0",
|
|
54
|
+
"vite": "^5.4.7"
|
|
55
|
+
},
|
|
56
|
+
"overrides": {
|
|
57
|
+
"eslint": "^9.0.0",
|
|
58
|
+
"react": "^18.0.0",
|
|
59
|
+
"@types/react": "^18.0.0",
|
|
60
|
+
"@types/react-dom": "^18.0.0",
|
|
61
|
+
"react-dom": "^18.0.0",
|
|
62
|
+
"vite": "^5.4.7"
|
|
20
63
|
},
|
|
21
64
|
"files": [
|
|
22
65
|
"*"
|
|
@@ -33,5 +76,6 @@
|
|
|
33
76
|
"engines": {
|
|
34
77
|
"node": ">=12.0.0"
|
|
35
78
|
},
|
|
79
|
+
"packageManager": "yarn@4.5.0",
|
|
36
80
|
"private": false
|
|
37
81
|
}
|
package/utils/anchorEl.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type AnchorEl = HTMLElement | (() => HTMLElement);
|
|
2
2
|
export interface AnchorOrigin {
|
|
3
3
|
vertical: 'top' | 'center' | 'bottom' | number;
|
|
4
4
|
horizontal: 'left' | 'center' | 'right' | number;
|
|
@@ -7,7 +7,7 @@ export interface AnchorPosition {
|
|
|
7
7
|
top: number;
|
|
8
8
|
left: number;
|
|
9
9
|
}
|
|
10
|
-
export declare const getAnchorElPositionWindow: (anchorElement: HTMLElement, newWindowRect: Pick<DOMRect,
|
|
10
|
+
export declare const getAnchorElPositionWindow: (anchorElement: HTMLElement, newWindowRect: Pick<DOMRect, "width" | "height">, anchorOrigin: AnchorOrigin, transformOrigin: AnchorOrigin, marginThreshold?: number) => {
|
|
11
11
|
top: number;
|
|
12
12
|
left: number;
|
|
13
13
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
function a(e, t) {
|
|
2
|
+
let o = 0;
|
|
3
|
+
return typeof t == "number" ? o = t : t === "center" ? o = e.height / 2 : t === "bottom" && (o = e.height), o;
|
|
4
|
+
}
|
|
5
|
+
function b(e, t) {
|
|
6
|
+
let o = 0;
|
|
7
|
+
return typeof t == "number" ? o = t : t === "center" ? o = e.width / 2 : t === "right" && (o = e.width), o;
|
|
8
|
+
}
|
|
9
|
+
function v(e) {
|
|
10
|
+
return typeof e == "function" ? e() : e;
|
|
11
|
+
}
|
|
12
|
+
const w = (e, t) => {
|
|
13
|
+
const f = v(e).getBoundingClientRect();
|
|
14
|
+
return {
|
|
15
|
+
top: f.top + a(f, t.vertical),
|
|
16
|
+
left: f.left + b(f, t.horizontal)
|
|
17
|
+
};
|
|
18
|
+
}, y = (e, t) => ({
|
|
19
|
+
vertical: a(e, t.vertical),
|
|
20
|
+
horizontal: b(e, t.horizontal)
|
|
21
|
+
}), O = (e, t, o, f, i = 16) => {
|
|
22
|
+
const r = w(e, o), l = y(t, f), h = document.getElementById("ContainerAreas")?.getBoundingClientRect() || {
|
|
23
|
+
top: 0,
|
|
24
|
+
left: 0
|
|
25
|
+
};
|
|
26
|
+
let s = r.top - l.vertical, c = r.left - l.horizontal;
|
|
27
|
+
const u = s + t.height, d = c + t.width, g = window, p = g.innerHeight - i, A = g.innerWidth - i;
|
|
28
|
+
if (s < i) {
|
|
29
|
+
const n = s - i;
|
|
30
|
+
s -= n;
|
|
31
|
+
} else if (u > p) {
|
|
32
|
+
const n = u - p;
|
|
33
|
+
s -= n;
|
|
34
|
+
}
|
|
35
|
+
if (c < i) {
|
|
36
|
+
const n = c - i;
|
|
37
|
+
c -= n;
|
|
38
|
+
} else if (d > A) {
|
|
39
|
+
const n = d - A;
|
|
40
|
+
c -= n;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
top: Math.round(s) - h.top,
|
|
44
|
+
left: Math.round(c) - h.left
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
O as g
|
|
49
|
+
};
|
package/utils/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/utils/strings.js
ADDED
package/commonjs-BCz0-aDl.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import "react";
|
|
2
|
-
var l = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
3
|
-
function t(e) {
|
|
4
|
-
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
5
|
-
}
|
|
6
|
-
export {
|
|
7
|
-
l as c,
|
|
8
|
-
t as g
|
|
9
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as c, useMemo as h } from "react";
|
|
3
|
-
import { CssBaseline as d } from "@mui/material";
|
|
4
|
-
import { G as p } from "../../components/GlobalStyle/index-C3p7OfnO.js";
|
|
5
|
-
import { createTheme as x, experimental_extendTheme as f, Experimental_CssVarsProvider as u, StyledEngineProvider as T } from "@mui/material/styles";
|
|
6
|
-
const v = c(null);
|
|
7
|
-
function j(m) {
|
|
8
|
-
const { children: l, hostThemeOptions: o, fnComponentsOverrides: n, isMobile: s } = m, a = h(() => {
|
|
9
|
-
const e = x({
|
|
10
|
-
...o
|
|
11
|
-
}), r = f({
|
|
12
|
-
cssVarPrefix: "m4l",
|
|
13
|
-
colorSchemes: {
|
|
14
|
-
light: e,
|
|
15
|
-
finalTheme: e,
|
|
16
|
-
dark: e
|
|
17
|
-
},
|
|
18
|
-
generalSettings: {
|
|
19
|
-
isMobile: s
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
return r.components = n(r), r;
|
|
23
|
-
}, [s]);
|
|
24
|
-
return /* @__PURE__ */ i(u, { theme: a, children: [
|
|
25
|
-
/* @__PURE__ */ t(p, {}),
|
|
26
|
-
/* @__PURE__ */ t(
|
|
27
|
-
v.Provider,
|
|
28
|
-
{
|
|
29
|
-
value: {
|
|
30
|
-
hostThemeOptions: o,
|
|
31
|
-
fnComponentsOverrides: n
|
|
32
|
-
},
|
|
33
|
-
children: /* @__PURE__ */ i(T, { injectFirst: !0, children: [
|
|
34
|
-
/* @__PURE__ */ t(d, { enableColorScheme: !0 }),
|
|
35
|
-
l
|
|
36
|
-
] })
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
] });
|
|
40
|
-
}
|
|
41
|
-
export {
|
|
42
|
-
v as H,
|
|
43
|
-
j as a
|
|
44
|
-
};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as k, useState as _, useCallback as x, useEffect as L } from "react";
|
|
3
|
-
import { AdapterDateFns as F } from "@mui/x-date-pickers/AdapterDateFns";
|
|
4
|
-
import { LocalizationProvider as U } from "@mui/x-date-pickers";
|
|
5
|
-
import { useEnvironment as P, useNetwork as I, useHostTools as j, useLocalStorageWithListener as w, EmitEvents as u } from "@m4l/core";
|
|
6
|
-
import S from "date-fns/locale/en-US";
|
|
7
|
-
async function B(t, e, o) {
|
|
8
|
-
const s = g(t), r = { ...t };
|
|
9
|
-
let i;
|
|
10
|
-
return s === "es" ? i = (await import("date-fns/locale/es")).default : s === "fr" ? i = (await import("date-fns/locale/fr")).default : s === "en-US" ? i = S : (i = S, r.lang = "en", r.script = void 0, r.region = "US", r.url_icon = `${e}/${o}/frontend/commons/assets/icons/langs/lang_en.svg`, r.name = "English US*"), {
|
|
11
|
-
...r,
|
|
12
|
-
module: i,
|
|
13
|
-
localeString: g(r)
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function g(t) {
|
|
17
|
-
let e = t.lang;
|
|
18
|
-
return t.script && t.script !== "" && (e = e + "-" + t.script), t.region && t.region !== "" && (e = e + "-" + t.region), e;
|
|
19
|
-
}
|
|
20
|
-
function y(t) {
|
|
21
|
-
try {
|
|
22
|
-
const e = new Intl.Locale(t);
|
|
23
|
-
return {
|
|
24
|
-
lang: e.language || "",
|
|
25
|
-
script: e.script,
|
|
26
|
-
region: e.region
|
|
27
|
-
};
|
|
28
|
-
} catch {
|
|
29
|
-
return {
|
|
30
|
-
lang: "en",
|
|
31
|
-
script: void 0,
|
|
32
|
-
region: "US"
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const G = k(null);
|
|
37
|
-
function J(t) {
|
|
38
|
-
const { children: e, isMicroFrontEnd: o, localeHost: s, getLocaleFromNetwork: r } = t;
|
|
39
|
-
if (o && !s)
|
|
40
|
-
throw Error("Must set localeHost in microfrontend");
|
|
41
|
-
if (!o && !r)
|
|
42
|
-
throw Error("Must set getLocaleFromNetwork in host");
|
|
43
|
-
const { domain_token: i, host_static_assets: v, environment_assets: h } = P(), { networkOperation: C } = I(), { events_add_listener: N, events_remove_listener: T, events_emit: H } = j(), [a, f] = _(() => {
|
|
44
|
-
if (o)
|
|
45
|
-
return s;
|
|
46
|
-
}), [l, m] = w(
|
|
47
|
-
"localeHost",
|
|
48
|
-
navigator.language
|
|
49
|
-
), [M, A] = _(""), d = x((n) => {
|
|
50
|
-
f(n);
|
|
51
|
-
}, []);
|
|
52
|
-
if (L(() => (o && N(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, d), () => {
|
|
53
|
-
o && T(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, d);
|
|
54
|
-
}), []), L(() => {
|
|
55
|
-
let n = !0;
|
|
56
|
-
if (!o && r && !(l === M && l !== ""))
|
|
57
|
-
return C({
|
|
58
|
-
method: "POST",
|
|
59
|
-
endPoint: "na/locales",
|
|
60
|
-
data: { ...y(l), domain_token: i }
|
|
61
|
-
}).then((p) => {
|
|
62
|
-
n && r(
|
|
63
|
-
p.data,
|
|
64
|
-
v,
|
|
65
|
-
h
|
|
66
|
-
).then((c) => {
|
|
67
|
-
f(c), A(c.localeString), l !== c.localeString && m(c.localeString), H(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, c);
|
|
68
|
-
});
|
|
69
|
-
}).finally(() => {
|
|
70
|
-
}), function() {
|
|
71
|
-
n = !1;
|
|
72
|
-
};
|
|
73
|
-
}, [l]), !a)
|
|
74
|
-
return null;
|
|
75
|
-
const O = (n) => {
|
|
76
|
-
(n.lang !== a.lang || n.script !== a.script || n.region !== a.region) && m(g(n));
|
|
77
|
-
};
|
|
78
|
-
return /* @__PURE__ */ E(
|
|
79
|
-
G.Provider,
|
|
80
|
-
{
|
|
81
|
-
value: {
|
|
82
|
-
currentLocale: a,
|
|
83
|
-
onChangeLocale: O
|
|
84
|
-
},
|
|
85
|
-
children: /* @__PURE__ */ E(
|
|
86
|
-
U,
|
|
87
|
-
{
|
|
88
|
-
dateAdapter: F,
|
|
89
|
-
adapterLocale: a.module,
|
|
90
|
-
dateFormats: { hours24h: "23" },
|
|
91
|
-
children: e
|
|
92
|
-
}
|
|
93
|
-
)
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
export {
|
|
98
|
-
G as L,
|
|
99
|
-
J as a,
|
|
100
|
-
B as g
|
|
101
|
-
};
|