@m4l/graphics 0.1.33 → 0.1.35
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/contexts/HostThemeContext/index.a6a62c70.js +50 -0
- package/contexts/LocalesContext/{index.5b555637.js → index.3fcfbe02.js} +22 -22
- package/contexts/index.84089632.js +4 -0
- package/hooks/{index.64cf4fc4.js → index.a4ef9776.js} +2 -2
- package/hooks/useFirstRender/index.d.ts +2 -1
- package/hooks/useLocales/{index.f676279e.js → index.8154a401.js} +1 -1
- package/index.js +24 -23
- package/package.json +4 -4
- package/utils/anchorEl.d.ts +13 -0
- package/utils/index.6909c662.js +51 -0
- package/utils/index.d.ts +1 -0
- package/contexts/HostThemeContext/index.9fe9854f.js +0 -50
- package/contexts/index.8c4de295.js +0 -4
- package/utils/index.54cae015.js +0 -4
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createContext as H, useState as E, useMemo as v, useCallback as M, useEffect as c } from "react";
|
|
2
|
+
import { CssBaseline as C } from "@mui/material";
|
|
3
|
+
import { createTheme as O, StyledEngineProvider as N, ThemeProvider as S } from "@mui/material/styles";
|
|
4
|
+
import { useHostTools as x, EmitEvents as o } from "@m4l/core";
|
|
5
|
+
import { jsx as n, jsxs as F } from "react/jsx-runtime";
|
|
6
|
+
const I = H(null);
|
|
7
|
+
function b(l) {
|
|
8
|
+
const {
|
|
9
|
+
children: h,
|
|
10
|
+
hostThemeOptions: t,
|
|
11
|
+
fnComponentsOverrides: i,
|
|
12
|
+
isMicroFrontEnd: s
|
|
13
|
+
} = l, [r, m] = E(t), {
|
|
14
|
+
events_add_listener: a,
|
|
15
|
+
events_remove_listener: _,
|
|
16
|
+
events_emit: f
|
|
17
|
+
} = x(), [d, u] = E(!0), p = v(() => {
|
|
18
|
+
const e = O(r);
|
|
19
|
+
return e.components = i(e), e;
|
|
20
|
+
}, [r]), T = M((e) => {
|
|
21
|
+
m(e);
|
|
22
|
+
}, []);
|
|
23
|
+
return c(() => (s && a(o.EMMIT_EVENT_HOST_THEME_CHANGE, T), () => {
|
|
24
|
+
s && _(o.EMMIT_EVENT_HOST_THEME_CHANGE, T);
|
|
25
|
+
}), []), c(() => {
|
|
26
|
+
if (d) {
|
|
27
|
+
u(!1);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
s || (m(t), f(o.EMMIT_EVENT_HOST_THEME_CHANGE, t));
|
|
31
|
+
}, [t]), /* @__PURE__ */ n(I.Provider, {
|
|
32
|
+
value: {
|
|
33
|
+
hostThemeOptions: r,
|
|
34
|
+
fnComponentsOverrides: i
|
|
35
|
+
},
|
|
36
|
+
children: /* @__PURE__ */ n(N, {
|
|
37
|
+
injectFirst: !0,
|
|
38
|
+
children: /* @__PURE__ */ F(S, {
|
|
39
|
+
theme: p,
|
|
40
|
+
children: [/* @__PURE__ */ n(C, {
|
|
41
|
+
enableColorScheme: !0
|
|
42
|
+
}), h]
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
I as H,
|
|
49
|
+
b as a
|
|
50
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createContext as k, useState as _, useCallback as x, useEffect as L } from "react";
|
|
2
2
|
import { AdapterDateFns as F } from "@mui/x-date-pickers/AdapterDateFns";
|
|
3
|
-
import { LocalizationProvider as
|
|
4
|
-
import { useEnvironment as
|
|
5
|
-
import
|
|
3
|
+
import { LocalizationProvider as U } from "@mui/x-date-pickers";
|
|
4
|
+
import { useEnvironment as P, useNetwork as I, useHostTools as j, useLocalStorageWithListener as w, EmitEvents as u } from "@m4l/core";
|
|
5
|
+
import S from "date-fns/locale/en-US";
|
|
6
6
|
import { jsx as g } from "react/jsx-runtime";
|
|
7
|
-
async function B(t, e,
|
|
7
|
+
async function B(t, e, o) {
|
|
8
8
|
const s = f(t), r = { ...t };
|
|
9
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 =
|
|
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
11
|
...r,
|
|
12
12
|
module: i,
|
|
13
13
|
localeString: f(r)
|
|
@@ -37,35 +37,35 @@ const G = k(null);
|
|
|
37
37
|
function J(t) {
|
|
38
38
|
const {
|
|
39
39
|
children: e,
|
|
40
|
-
isMicroFrontEnd:
|
|
40
|
+
isMicroFrontEnd: o,
|
|
41
41
|
localeHost: s,
|
|
42
42
|
getLocaleFromNetwork: r
|
|
43
43
|
} = t;
|
|
44
|
-
if (
|
|
44
|
+
if (o && !s)
|
|
45
45
|
throw Error("Must set localeHost in microfrontend");
|
|
46
|
-
if (!
|
|
46
|
+
if (!o && !r)
|
|
47
47
|
throw Error("Must set getLocaleFromNetwork in host");
|
|
48
48
|
const {
|
|
49
49
|
domain_token: i,
|
|
50
|
-
host_static_assets:
|
|
50
|
+
host_static_assets: v,
|
|
51
51
|
environment_assets: h
|
|
52
|
-
} =
|
|
52
|
+
} = P(), {
|
|
53
53
|
networkOperation: C
|
|
54
54
|
} = I(), {
|
|
55
55
|
events_add_listener: N,
|
|
56
56
|
events_remove_listener: T,
|
|
57
57
|
events_emit: H
|
|
58
58
|
} = j(), [a, d] = _(() => {
|
|
59
|
-
if (
|
|
59
|
+
if (o)
|
|
60
60
|
return s;
|
|
61
|
-
}), [l, m] = w("localeHost", navigator.language), [M, A] = _(""), p = x((
|
|
62
|
-
d(
|
|
61
|
+
}), [l, m] = w("localeHost", navigator.language), [M, A] = _(""), p = x((n) => {
|
|
62
|
+
d(n);
|
|
63
63
|
}, []);
|
|
64
|
-
if (L(() => (
|
|
65
|
-
|
|
64
|
+
if (L(() => (o && N(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, p), () => {
|
|
65
|
+
o && T(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, p);
|
|
66
66
|
}), []), L(() => {
|
|
67
|
-
let
|
|
68
|
-
if (!
|
|
67
|
+
let n = !0;
|
|
68
|
+
if (!o && !!r && !(l === M && l !== ""))
|
|
69
69
|
return C({
|
|
70
70
|
method: "POST",
|
|
71
71
|
endPoint: "na/locales",
|
|
@@ -74,24 +74,24 @@ function J(t) {
|
|
|
74
74
|
domain_token: i
|
|
75
75
|
}
|
|
76
76
|
}).then((E) => {
|
|
77
|
-
|
|
77
|
+
n && r(E.data, v, h).then((c) => {
|
|
78
78
|
d(c), A(c.localeString), l !== c.localeString && m(c.localeString), H(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, c);
|
|
79
79
|
});
|
|
80
80
|
}).finally(() => {
|
|
81
81
|
}), function() {
|
|
82
|
-
|
|
82
|
+
n = !1;
|
|
83
83
|
};
|
|
84
84
|
}, [l]), !a)
|
|
85
85
|
return /* @__PURE__ */ g("div", {});
|
|
86
|
-
const O = (
|
|
87
|
-
(
|
|
86
|
+
const O = (n) => {
|
|
87
|
+
(n.lang !== a.lang || n.script !== a.script || n.region !== a.region) && m(f(n));
|
|
88
88
|
};
|
|
89
89
|
return /* @__PURE__ */ g(G.Provider, {
|
|
90
90
|
value: {
|
|
91
91
|
currentLocale: a,
|
|
92
92
|
onChangeLocale: O
|
|
93
93
|
},
|
|
94
|
-
children: /* @__PURE__ */ g(
|
|
94
|
+
children: /* @__PURE__ */ g(U, {
|
|
95
95
|
dateAdapter: F,
|
|
96
96
|
adapterLocale: a.module,
|
|
97
97
|
dateFormats: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRef as n, useEffect as s, useState as u, useContext as f } from "react";
|
|
2
|
-
import { H as i } from "../contexts/HostThemeContext/index.
|
|
2
|
+
import { H as i } from "../contexts/HostThemeContext/index.a6a62c70.js";
|
|
3
3
|
import "../contexts/FormatterContext/index.92336f4c.js";
|
|
4
|
-
import "../contexts/LocalesContext/index.
|
|
4
|
+
import "../contexts/LocalesContext/index.3fcfbe02.js";
|
|
5
5
|
import "@mui/material/styles";
|
|
6
6
|
import "@mui/material/useMediaQuery";
|
|
7
7
|
function T() {
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { DependencyList } from 'react';
|
|
2
|
+
export declare function useFirstRender(dependencies?: DependencyList): boolean;
|
package/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { P as x } from "./components/ProgressBarStyle/index.fb6fd9ed.js";
|
|
2
|
-
import { F as l, a as
|
|
3
|
-
import { L as
|
|
4
|
-
import { H as
|
|
5
|
-
import { u as
|
|
6
|
-
import { u as
|
|
7
|
-
import { b as
|
|
8
|
-
import { u as z } from "./hooks/useLocales/index.
|
|
9
|
-
import { u as
|
|
10
|
-
import { C as
|
|
2
|
+
import { F as l, a as d } from "./contexts/FormatterContext/index.92336f4c.js";
|
|
3
|
+
import { L as P, a as c, g } from "./contexts/LocalesContext/index.3fcfbe02.js";
|
|
4
|
+
import { H as C, a as L } from "./contexts/HostThemeContext/index.a6a62c70.js";
|
|
5
|
+
import { u as H } from "./hooks/useFirstRender/index.1e9b02fb.js";
|
|
6
|
+
import { u as T } from "./hooks/useFormatter/index.57ac8cca.js";
|
|
7
|
+
import { b as w, u as S, a as b } from "./hooks/index.a4ef9776.js";
|
|
8
|
+
import { u as z } from "./hooks/useLocales/index.8154a401.js";
|
|
9
|
+
import { u as B, a as D } from "./hooks/useResponsive/index.fc5e1b4f.js";
|
|
10
|
+
import { C as I, g as M } from "./utils/index.6909c662.js";
|
|
11
11
|
import "@mui/material/styles";
|
|
12
12
|
import "@mui/material";
|
|
13
13
|
import "react/jsx-runtime";
|
|
@@ -18,21 +18,22 @@ import "@mui/x-date-pickers";
|
|
|
18
18
|
import "date-fns/locale/en-US";
|
|
19
19
|
import "@mui/material/useMediaQuery";
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
I as Capitalize,
|
|
22
22
|
l as FormatterContext,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
d as FormatterProvider,
|
|
24
|
+
C as HostThemeContext,
|
|
25
|
+
L as HostThemeProvider,
|
|
26
|
+
P as LocalesContext,
|
|
27
|
+
c as LocalesProvider,
|
|
28
28
|
x as ProgressBarStyle,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
M as getAnchorElPositionWindow,
|
|
30
|
+
g as getLocaleFromNetwork,
|
|
31
|
+
H as useFirstRender,
|
|
32
|
+
T as useFormatter,
|
|
33
|
+
w as useHostTheme,
|
|
34
|
+
S as useIsMountedRef,
|
|
34
35
|
z as useLocales,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
b as useOffSetTop,
|
|
37
|
+
B as useResponsive,
|
|
38
|
+
D as useResponsiveDesktop
|
|
38
39
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/graphics",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "M4L Team",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@m4l/core": "*",
|
|
8
|
-
"@mui/x-date-pickers": "
|
|
8
|
+
"@mui/x-date-pickers": "6.2.0",
|
|
9
9
|
"date-fns": "^2.29.2"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@mui/material": "
|
|
13
|
-
"@mui/system": "
|
|
12
|
+
"@mui/material": "5.10.4",
|
|
13
|
+
"@mui/system": "5.10.4",
|
|
14
14
|
"@types/react": "^17.0.0 || ^18.0.0",
|
|
15
15
|
"react": "^17.0.0 || ^18.0.0",
|
|
16
16
|
"react-toastify": "9.0.5"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare type AnchorEl = HTMLElement | (() => HTMLElement);
|
|
2
|
+
export interface AnchorOrigin {
|
|
3
|
+
vertical: 'top' | 'center' | 'bottom' | number;
|
|
4
|
+
horizontal: 'left' | 'center' | 'right' | number;
|
|
5
|
+
}
|
|
6
|
+
export interface AnchorPosition {
|
|
7
|
+
top: number;
|
|
8
|
+
left: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const getAnchorElPositionWindow: (anchorElement: HTMLElement, newWindowRect: Pick<DOMRect, 'width' | 'height'>, anchorOrigin: AnchorOrigin, transformOrigin: AnchorOrigin, marginThreshold?: number) => {
|
|
11
|
+
top: number;
|
|
12
|
+
left: number;
|
|
13
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const y = (t) => t && t[0].toUpperCase() + t.slice(1) || "";
|
|
2
|
+
function A(t, e) {
|
|
3
|
+
let o = 0;
|
|
4
|
+
return typeof e == "number" ? o = e : e === "center" ? o = t.height / 2 : e === "bottom" && (o = t.height), o;
|
|
5
|
+
}
|
|
6
|
+
function C(t, e) {
|
|
7
|
+
let o = 0;
|
|
8
|
+
return typeof e == "number" ? o = e : e === "center" ? o = t.width / 2 : e === "right" && (o = t.width), o;
|
|
9
|
+
}
|
|
10
|
+
function b(t) {
|
|
11
|
+
return typeof t == "function" ? t() : t;
|
|
12
|
+
}
|
|
13
|
+
const v = (t, e) => {
|
|
14
|
+
const f = b(t).getBoundingClientRect();
|
|
15
|
+
return {
|
|
16
|
+
top: f.top + A(f, e.vertical),
|
|
17
|
+
left: f.left + C(f, e.horizontal)
|
|
18
|
+
};
|
|
19
|
+
}, w = (t, e) => ({
|
|
20
|
+
vertical: A(t, e.vertical),
|
|
21
|
+
horizontal: C(t, e.horizontal)
|
|
22
|
+
}), O = (t, e, o, f, i = 16) => {
|
|
23
|
+
const r = v(t, o), l = w(e, f), h = document.getElementById("ContainerAreas")?.getBoundingClientRect() || {
|
|
24
|
+
top: 0,
|
|
25
|
+
left: 0
|
|
26
|
+
};
|
|
27
|
+
let s = r.top - l.vertical, c = r.left - l.horizontal;
|
|
28
|
+
const u = s + e.height, d = c + e.width, p = window, g = p.innerHeight - i, a = p.innerWidth - i;
|
|
29
|
+
if (s < i) {
|
|
30
|
+
const n = s - i;
|
|
31
|
+
s -= n;
|
|
32
|
+
} else if (u > g) {
|
|
33
|
+
const n = u - g;
|
|
34
|
+
s -= n;
|
|
35
|
+
}
|
|
36
|
+
if (c < i) {
|
|
37
|
+
const n = c - i;
|
|
38
|
+
c -= n;
|
|
39
|
+
} else if (d > a) {
|
|
40
|
+
const n = d - a;
|
|
41
|
+
c -= n;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
top: Math.round(s) - h.top,
|
|
45
|
+
left: Math.round(c) - h.left
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
y as C,
|
|
50
|
+
O as g
|
|
51
|
+
};
|
package/utils/index.d.ts
CHANGED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { createContext as H, useState as E, useMemo as v, useCallback as M, useEffect as c } from "react";
|
|
2
|
-
import { CssBaseline as C } from "@mui/material";
|
|
3
|
-
import { createTheme as O, StyledEngineProvider as N, ThemeProvider as S } from "@mui/material/styles";
|
|
4
|
-
import { useHostTools as x, EmitEvents as n } from "@m4l/core";
|
|
5
|
-
import { jsx as r, jsxs as F } from "react/jsx-runtime";
|
|
6
|
-
const I = H(null);
|
|
7
|
-
function b(h) {
|
|
8
|
-
const {
|
|
9
|
-
children: a,
|
|
10
|
-
hostThemeOptions: t,
|
|
11
|
-
fnComponentsOverrides: i,
|
|
12
|
-
isMicroFrontEnd: o
|
|
13
|
-
} = h, [s, m] = E(t), {
|
|
14
|
-
events_add_listener: f,
|
|
15
|
-
events_remove_listener: _,
|
|
16
|
-
events_emit: d
|
|
17
|
-
} = x(), [u, p] = E(!0), T = v(() => {
|
|
18
|
-
const e = O(s);
|
|
19
|
-
return e.components = i(e), e;
|
|
20
|
-
}, [s]), l = M((e) => {
|
|
21
|
-
m(e);
|
|
22
|
-
}, []);
|
|
23
|
-
return c(() => (o && f(n.EMMIT_EVENT_HOST_THEME_CHANGE, l), () => {
|
|
24
|
-
o && _(n.EMMIT_EVENT_HOST_THEME_CHANGE, l);
|
|
25
|
-
}), []), c(() => {
|
|
26
|
-
if (u) {
|
|
27
|
-
p(!1);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
o || (m(t), d(n.EMMIT_EVENT_HOST_THEME_CHANGE, t));
|
|
31
|
-
}, [t]), console.log("final theme", T), /* @__PURE__ */ r(I.Provider, {
|
|
32
|
-
value: {
|
|
33
|
-
hostThemeOptions: s,
|
|
34
|
-
fnComponentsOverrides: i
|
|
35
|
-
},
|
|
36
|
-
children: /* @__PURE__ */ r(N, {
|
|
37
|
-
injectFirst: !0,
|
|
38
|
-
children: /* @__PURE__ */ F(S, {
|
|
39
|
-
theme: T,
|
|
40
|
-
children: [/* @__PURE__ */ r(C, {
|
|
41
|
-
enableColorScheme: !0
|
|
42
|
-
}), a]
|
|
43
|
-
})
|
|
44
|
-
})
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
I as H,
|
|
49
|
-
b as a
|
|
50
|
-
};
|
package/utils/index.54cae015.js
DELETED