@m4l/graphics 0.1.38 → 0.1.40

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,2 @@
1
- export declare function GlobalStyles(): JSX.Element;
1
+ /// <reference types="react" />
2
+ export declare function GlobalStyles(): import("react").JSX.Element;
@@ -12,5 +12,5 @@ declare const FormatterContext: import("react").Context<Formatters | null>;
12
12
  * @beta
13
13
  * @link
14
14
  */
15
- declare function FormatterProvider(props: FormatterProviderProps): JSX.Element;
15
+ declare function FormatterProvider(props: FormatterProviderProps): import("react").JSX.Element;
16
16
  export { FormatterProvider, FormatterContext };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { HostThemeProviderProps } from './types';
3
3
  declare const HostThemeContext: import("react").Context<import("./types").HostThemeType | null>;
4
- declare function HostThemeProvider(props: HostThemeProviderProps): JSX.Element;
4
+ declare function HostThemeProvider(props: HostThemeProviderProps): import("react").JSX.Element;
5
5
  export { HostThemeProvider, HostThemeContext };
@@ -1,19 +1,19 @@
1
- import { createContext as k, useState as _, useCallback as x, useEffect as L } from "react";
1
+ import { createContext as k, useState as E, useCallback as x, useEffect as _ } from "react";
2
2
  import { AdapterDateFns as F } from "@mui/x-date-pickers/AdapterDateFns";
3
3
  import { LocalizationProvider as U } from "@mui/x-date-pickers";
4
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
- import { jsx as g } from "react/jsx-runtime";
5
+ import L from "date-fns/locale/en-US";
6
+ import { jsx as S } from "react/jsx-runtime";
7
7
  async function B(t, e, o) {
8
- const s = f(t), r = { ...t };
8
+ const s = g(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 = 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*"), {
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 = L : (i = L, 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
- localeString: f(r)
13
+ localeString: g(r)
14
14
  };
15
15
  }
16
- function f(t) {
16
+ function g(t) {
17
17
  let e = t.lang;
18
18
  return t.script && t.script !== "" && (e = e + "-" + t.script), t.region && t.region !== "" && (e = e + "-" + t.region), e;
19
19
  }
@@ -55,15 +55,15 @@ function J(t) {
55
55
  events_add_listener: N,
56
56
  events_remove_listener: T,
57
57
  events_emit: H
58
- } = j(), [a, d] = _(() => {
58
+ } = j(), [a, f] = E(() => {
59
59
  if (o)
60
60
  return s;
61
- }), [l, m] = w("localeHost", navigator.language), [M, A] = _(""), p = x((n) => {
62
- d(n);
61
+ }), [l, m] = w("localeHost", navigator.language), [M, A] = E(""), d = x((n) => {
62
+ f(n);
63
63
  }, []);
64
- if (L(() => (o && N(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, p), () => {
65
- o && T(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, p);
66
- }), []), L(() => {
64
+ if (_(() => (o && N(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, d), () => {
65
+ o && T(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, d);
66
+ }), []), _(() => {
67
67
  let n = !0;
68
68
  if (!o && !!r && !(l === M && l !== ""))
69
69
  return C({
@@ -73,25 +73,25 @@ function J(t) {
73
73
  ...y(l),
74
74
  domain_token: i
75
75
  }
76
- }).then((E) => {
77
- n && r(E.data, v, h).then((c) => {
78
- d(c), A(c.localeString), l !== c.localeString && m(c.localeString), H(u.EMMIT_EVENT_HOST_LOCALE_CHANGE, c);
76
+ }).then((p) => {
77
+ n && r(p.data, v, h).then((c) => {
78
+ f(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
- return /* @__PURE__ */ g("div", {});
85
+ return null;
86
86
  const O = (n) => {
87
- (n.lang !== a.lang || n.script !== a.script || n.region !== a.region) && m(f(n));
87
+ (n.lang !== a.lang || n.script !== a.script || n.region !== a.region) && m(g(n));
88
88
  };
89
- return /* @__PURE__ */ g(G.Provider, {
89
+ return /* @__PURE__ */ S(G.Provider, {
90
90
  value: {
91
91
  currentLocale: a,
92
92
  onChangeLocale: O
93
93
  },
94
- children: /* @__PURE__ */ g(U, {
94
+ children: /* @__PURE__ */ S(U, {
95
95
  dateAdapter: F,
96
96
  adapterLocale: a.module,
97
97
  dateFormats: {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { LocalesProviderProps, LocalesContextProps } from './types';
3
3
  declare const LocalesContext: import("react").Context<LocalesContextProps | null>;
4
- declare function LocalesProvider(props: LocalesProviderProps): JSX.Element;
4
+ declare function LocalesProvider(props: LocalesProviderProps): import("react").JSX.Element | null;
5
5
  export { LocalesProvider, LocalesContext };
@@ -1,4 +1,4 @@
1
1
  import "./FormatterContext/index.92336f4c.js";
2
- import "./LocalesContext/index.3fcfbe02.js";
2
+ import "./LocalesContext/index.53f0b702.js";
3
3
  import "date-fns/locale/en-US";
4
4
  import "./HostThemeContext/index.a6a62c70.js";
@@ -0,0 +1,48 @@
1
+ import { useRef as r, useEffect as n, useState as f, useContext as i, useLayoutEffect as c } from "react";
2
+ import { H as m } from "../contexts/HostThemeContext/index.a6a62c70.js";
3
+ import "../contexts/FormatterContext/index.92336f4c.js";
4
+ import "../contexts/LocalesContext/index.53f0b702.js";
5
+ import "@m4l/styles";
6
+ function T() {
7
+ const e = r(!0);
8
+ return n(
9
+ () => () => {
10
+ e.current = !1;
11
+ },
12
+ []
13
+ ), e;
14
+ }
15
+ function b(e) {
16
+ const [s, t] = f(!1), o = e || 100;
17
+ return n(() => (window.onscroll = () => {
18
+ window.pageYOffset > o ? t(!0) : t(!1);
19
+ }, () => {
20
+ window.onscroll = null;
21
+ }), [o]), s;
22
+ }
23
+ const h = () => {
24
+ const e = i(m);
25
+ if (!e)
26
+ throw new Error("useHostTheme context must be use inside HostThemeProvider");
27
+ return e;
28
+ };
29
+ function v(e) {
30
+ const s = r(null);
31
+ return c(() => {
32
+ const t = s?.current;
33
+ if (!t)
34
+ return;
35
+ const o = new ResizeObserver((u) => {
36
+ e(t, u[0]);
37
+ });
38
+ return o.observe(t), () => {
39
+ o.disconnect();
40
+ };
41
+ }, [e, s.current]), s;
42
+ }
43
+ export {
44
+ b as a,
45
+ h as b,
46
+ v as c,
47
+ T as u
48
+ };
package/hooks/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export { useIsMountedRef } from './useIsMountedRef';
4
4
  export { useLocales } from './useLocales';
5
5
  export { useOffSetTop } from './useOffSetTop';
6
6
  export { useHostTheme } from './useHostTheme';
7
- export { useResponsive, useResponsiveDesktop } from './useResponsive';
7
+ export { useResizeObserver } from './useResizeObserver';
8
+ export { useResponsiveDesktop } from './useResponsive';
@@ -1,5 +1,5 @@
1
1
  import { useContext as o } from "react";
2
- import { L as t } from "../../contexts/LocalesContext/index.3fcfbe02.js";
2
+ import { L as t } from "../../contexts/LocalesContext/index.53f0b702.js";
3
3
  const n = () => {
4
4
  const e = o(t);
5
5
  if (!e)
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare function useResizeObserver<T extends HTMLElement>(callback: (target: T, entry: ResizeObserverEntry) => void): import("react").RefObject<T>;
3
+ export default useResizeObserver;
@@ -0,0 +1,7 @@
1
+ import { useResponsive as s } from "@m4l/styles";
2
+ function p() {
3
+ return s("up", "sm");
4
+ }
5
+ export {
6
+ p as u
7
+ };
@@ -1,8 +1 @@
1
- import { Breakpoint } from '@mui/material';
2
- declare type Query = 'up' | 'down' | 'between' | 'only';
3
- declare type Key = Breakpoint | number;
4
- declare type Start = Breakpoint | number;
5
- declare type End = Breakpoint | number;
6
- export declare function useResponsive(query: Query, key?: Key, start?: Start, end?: End): boolean | undefined;
7
1
  export declare function useResponsiveDesktop(): boolean | undefined;
8
- export {};
package/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import { G as n } from "./components/GlobalStyle/index.30beab6e.js";
2
- import { F as d, a as F } from "./contexts/FormatterContext/index.92336f4c.js";
3
- import { L as v, a as C, g as L } from "./contexts/LocalesContext/index.3fcfbe02.js";
4
- import { H as h, a as H } from "./contexts/HostThemeContext/index.a6a62c70.js";
5
- import { u as R } from "./hooks/useFirstRender/index.1e9b02fb.js";
6
- import { u as b } from "./hooks/useFormatter/index.57ac8cca.js";
7
- import { b as w, u as G, a as S } from "./hooks/index.a4ef9776.js";
8
- import { u as z } from "./hooks/useLocales/index.8154a401.js";
9
- import { u as D, a as E } from "./hooks/useResponsive/index.fc5e1b4f.js";
10
- import { C as M, g as N } from "./utils/index.6909c662.js";
1
+ import { G as x } from "./components/GlobalStyle/index.30beab6e.js";
2
+ import { F as n, a as c } from "./contexts/FormatterContext/index.92336f4c.js";
3
+ import { L as F, a as v, g as C } from "./contexts/LocalesContext/index.53f0b702.js";
4
+ import { H as g, a as h } from "./contexts/HostThemeContext/index.a6a62c70.js";
5
+ import { u as P } from "./hooks/useFirstRender/index.1e9b02fb.js";
6
+ import { u as T } from "./hooks/useFormatter/index.57ac8cca.js";
7
+ import { b as k, u as w, a as z, c as G } from "./hooks/index.5c8cfbbc.js";
8
+ import { u as S } from "./hooks/useLocales/index.d5a80aff.js";
9
+ import { u as A } from "./hooks/useResponsive/index.1409e387.js";
10
+ import { C as E, g as I } from "./utils/index.6909c662.js";
11
11
  import "@mui/material/styles";
12
12
  import "@mui/material";
13
13
  import "@m4l/styles";
@@ -17,24 +17,23 @@ import "@m4l/core";
17
17
  import "@mui/x-date-pickers/AdapterDateFns";
18
18
  import "@mui/x-date-pickers";
19
19
  import "date-fns/locale/en-US";
20
- import "@mui/material/useMediaQuery";
21
20
  export {
22
- M as Capitalize,
23
- d as FormatterContext,
24
- F as FormatterProvider,
25
- n as GlobalStyles,
26
- h as HostThemeContext,
27
- H as HostThemeProvider,
28
- v as LocalesContext,
29
- C as LocalesProvider,
30
- N as getAnchorElPositionWindow,
31
- L as getLocaleFromNetwork,
32
- R as useFirstRender,
33
- b as useFormatter,
34
- w as useHostTheme,
35
- G as useIsMountedRef,
36
- z as useLocales,
37
- S as useOffSetTop,
38
- D as useResponsive,
39
- E as useResponsiveDesktop
21
+ E as Capitalize,
22
+ n as FormatterContext,
23
+ c as FormatterProvider,
24
+ x as GlobalStyles,
25
+ g as HostThemeContext,
26
+ h as HostThemeProvider,
27
+ F as LocalesContext,
28
+ v as LocalesProvider,
29
+ I as getAnchorElPositionWindow,
30
+ C as getLocaleFromNetwork,
31
+ P as useFirstRender,
32
+ T as useFormatter,
33
+ k as useHostTheme,
34
+ w as useIsMountedRef,
35
+ S as useLocales,
36
+ z as useOffSetTop,
37
+ G as useResizeObserver,
38
+ A as useResponsiveDesktop
40
39
  };
package/package.json CHANGED
@@ -1,16 +1,14 @@
1
1
  {
2
2
  "name": "@m4l/graphics",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "license": "UNLICENSED",
5
- "author": "M4L Team",
5
+ "author": "M4L Team*",
6
6
  "dependencies": {
7
7
  "@m4l/core": "*",
8
- "@mui/x-date-pickers": "6.2.0",
9
- "date-fns": "^2.29.2"
8
+ "@m4l/styles": "*",
9
+ "date-fns": "^2.30.0"
10
10
  },
11
11
  "peerDependencies": {
12
- "@mui/material": "5.10.4",
13
- "@mui/system": "5.10.4",
14
12
  "@types/react": "^17.0.0 || ^18.0.0",
15
13
  "react": "^17.0.0 || ^18.0.0",
16
14
  "react-toastify": "9.0.5"
@@ -1,34 +0,0 @@
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.a6a62c70.js";
3
- import "../contexts/FormatterContext/index.92336f4c.js";
4
- import "../contexts/LocalesContext/index.3fcfbe02.js";
5
- import "@mui/material/styles";
6
- import "@mui/material/useMediaQuery";
7
- function T() {
8
- const e = n(!0);
9
- return s(
10
- () => () => {
11
- e.current = !1;
12
- },
13
- []
14
- ), e;
15
- }
16
- function d(e) {
17
- const [r, t] = u(!1), o = e || 100;
18
- return s(() => (window.onscroll = () => {
19
- window.pageYOffset > o ? t(!0) : t(!1);
20
- }, () => {
21
- window.onscroll = null;
22
- }), [o]), r;
23
- }
24
- const h = () => {
25
- const e = f(i);
26
- if (!e)
27
- throw new Error("useHostTheme context must be use inside HostThemeProvider");
28
- return e;
29
- };
30
- export {
31
- d as a,
32
- h as b,
33
- T as u
34
- };
@@ -1,20 +0,0 @@
1
- import { useTheme as m } from "@mui/material/styles";
2
- import o from "@mui/material/useMediaQuery";
3
- function c(e, t, s, i) {
4
- const n = m(), r = o(n.breakpoints.up(t)), p = o(n.breakpoints.down(t)), u = o(n.breakpoints.between(s, i)), a = o(n.breakpoints.only(t));
5
- if (e === "up")
6
- return r;
7
- if (e === "down")
8
- return p;
9
- if (e === "between")
10
- return u;
11
- if (e === "only")
12
- return a;
13
- }
14
- function b() {
15
- return c("up", "sm");
16
- }
17
- export {
18
- b as a,
19
- c as u
20
- };