@m4l/graphics 0.1.34 → 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.
@@ -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 P } from "@mui/x-date-pickers";
4
- import { useEnvironment as U, useNetwork as I, useHostTools as j, useLocalStorageWithListener as w, EmitEvents as u } from "@m4l/core";
5
- import v from "date-fns/locale/en-US";
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, n) {
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 = v : (i = v, r.lang = "en", r.script = void 0, r.region = "US", r.url_icon = `${e}/${n}/frontend/commons/assets/icons/langs/lang_en.svg`, r.name = "English US*"), {
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: n,
40
+ isMicroFrontEnd: o,
41
41
  localeHost: s,
42
42
  getLocaleFromNetwork: r
43
43
  } = t;
44
- if (n && !s)
44
+ if (o && !s)
45
45
  throw Error("Must set localeHost in microfrontend");
46
- if (!n && !r)
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: S,
50
+ host_static_assets: v,
51
51
  environment_assets: h
52
- } = U(), {
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 (n)
59
+ if (o)
60
60
  return s;
61
- }), [l, m] = w("localeHost", navigator.language), [M, A] = _(""), p = x((o) => {
62
- d(o);
61
+ }), [l, m] = w("localeHost", navigator.language), [M, A] = _(""), p = x((n) => {
62
+ d(n);
63
63
  }, []);
64
- if (L(() => (n && N(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, p), console.log("useEffect LocalesProvider"), () => {
65
- n && T(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, p);
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 o = !0;
68
- if (!n && !!r && !(l === M && l !== ""))
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
- o && r(E.data, S, h).then((c) => {
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
- o = !1;
82
+ n = !1;
83
83
  };
84
84
  }, [l]), !a)
85
85
  return /* @__PURE__ */ g("div", {});
86
- const O = (o) => {
87
- (o.lang !== a.lang || o.script !== a.script || o.region !== a.region) && m(f(o));
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(P, {
94
+ children: /* @__PURE__ */ g(U, {
95
95
  dateAdapter: F,
96
96
  adapterLocale: a.module,
97
97
  dateFormats: {
@@ -0,0 +1,4 @@
1
+ import "./FormatterContext/index.92336f4c.js";
2
+ import "./LocalesContext/index.3fcfbe02.js";
3
+ import "date-fns/locale/en-US";
4
+ import "./HostThemeContext/index.a6a62c70.js";
@@ -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.9fe9854f.js";
2
+ import { H as i } from "../contexts/HostThemeContext/index.a6a62c70.js";
3
3
  import "../contexts/FormatterContext/index.92336f4c.js";
4
- import "../contexts/LocalesContext/index.5b555637.js";
4
+ import "../contexts/LocalesContext/index.3fcfbe02.js";
5
5
  import "@mui/material/styles";
6
6
  import "@mui/material/useMediaQuery";
7
7
  function T() {
@@ -1,5 +1,5 @@
1
1
  import { useContext as o } from "react";
2
- import { L as t } from "../../contexts/LocalesContext/index.5b555637.js";
2
+ import { L as t } from "../../contexts/LocalesContext/index.3fcfbe02.js";
3
3
  const n = () => {
4
4
  const e = o(t);
5
5
  if (!e)
package/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { P as x } from "./components/ProgressBarStyle/index.fb6fd9ed.js";
2
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.5b555637.js";
4
- import { H as C, a as L } from "./contexts/HostThemeContext/index.9fe9854f.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
5
  import { u as H } from "./hooks/useFirstRender/index.1e9b02fb.js";
6
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.64cf4fc4.js";
8
- import { u as z } from "./hooks/useLocales/index.f676279e.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
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.e35c6547.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";
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@m4l/graphics",
3
- "version": "0.1.34",
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": "^5.0.0-beta.3",
8
+ "@mui/x-date-pickers": "6.2.0",
9
9
  "date-fns": "^2.29.2"
10
10
  },
11
11
  "peerDependencies": {
12
- "@mui/material": "^5.10.4",
13
- "@mui/system": "^5.10.4",
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,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
+ };
@@ -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
- };
@@ -1,4 +0,0 @@
1
- import "./FormatterContext/index.92336f4c.js";
2
- import "./LocalesContext/index.5b555637.js";
3
- import "date-fns/locale/en-US";
4
- import "./HostThemeContext/index.9fe9854f.js";
@@ -1,56 +0,0 @@
1
- const v = (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 O(t) {
11
- return typeof t == "function" ? t() : t;
12
- }
13
- const b = (t, e) => {
14
- const i = O(t).getBoundingClientRect();
15
- return {
16
- top: i.top + A(i, e.vertical),
17
- left: i.left + C(i, e.horizontal)
18
- };
19
- }, m = (t, e) => ({
20
- vertical: A(t, e.vertical),
21
- horizontal: C(t, e.horizontal)
22
- }), w = (t, e, o, i, s = 16) => {
23
- const l = b(t, o);
24
- console.log("anchoEl", l);
25
- const r = m(e, i);
26
- console.log("elemTransformOrigin", r);
27
- const h = document.getElementById("ContainerAreas")?.getBoundingClientRect() || {
28
- top: 0,
29
- left: 0
30
- };
31
- console.log("getAnchorOffset-container", h);
32
- let n = l.top - r.vertical, c = l.left - r.horizontal;
33
- const g = n + e.height, d = c + e.width, p = window, u = p.innerHeight - s, a = p.innerWidth - s;
34
- if (console.log("Final top,bottom,heightThreshold", n, g, u), n < s) {
35
- const f = n - s;
36
- n -= f;
37
- } else if (g > u) {
38
- const f = g - u;
39
- n -= f;
40
- }
41
- if (c < s) {
42
- const f = c - s;
43
- c -= f;
44
- } else if (d > a) {
45
- const f = d - a;
46
- c -= f;
47
- }
48
- return {
49
- top: Math.round(n) - h.top,
50
- left: Math.round(c) - h.left
51
- };
52
- };
53
- export {
54
- v as C,
55
- w as g
56
- };