@m4l/graphics 0.1.11 → 0.1.13
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/ProgressBarStyle/index.d.ts +2 -1
- package/contexts/FormatterContext/index.d.ts +16 -0
- package/contexts/FormatterContext/types.d.ts +55 -0
- package/contexts/HostThemeContext/index.d.ts +1 -1
- package/contexts/LocalesContext/index.3fcfbe02.js +108 -0
- package/contexts/LocalesContext/index.d.ts +1 -1
- package/contexts/index.bd12693a.js +80 -0
- package/contexts/index.d.ts +2 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.de62e8aa.js +44 -0
- package/hooks/useFirstRender/index.d.ts +1 -0
- package/hooks/useFormatter/index.d.ts +1 -0
- package/hooks/{useIsMountedRef.d.ts → useIsMountedRef/index.d.ts} +0 -0
- package/hooks/useLocales/{index.ca679977.js → index.8154a401.js} +1 -1
- package/index.js +36 -32
- package/package.json +1 -1
- package/contexts/LocalesContext/index.ca1e2149.js +0 -111
- package/contexts/index.a0e7894e.js +0 -3
- package/hooks/index.2942e1ab.js +0 -26
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare function ProgressBarStyle(): JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormatterProviderProps, Formatters } from './types';
|
|
3
|
+
declare const FormatterContext: import("react").Context<Formatters | null>;
|
|
4
|
+
/**
|
|
5
|
+
* @function
|
|
6
|
+
* Componente encargado de proveer un contexto que permita saber los diferentes forrmatos,
|
|
7
|
+
* Segunda linea
|
|
8
|
+
* @param props Objeto de propiedades
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
* @author Juan Andrés Escobar
|
|
11
|
+
* @date 2023-02-11
|
|
12
|
+
* @beta
|
|
13
|
+
* @link
|
|
14
|
+
*/
|
|
15
|
+
declare function FormatterProvider(props: FormatterProviderProps): JSX.Element;
|
|
16
|
+
export { FormatterProvider, FormatterContext };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Locale } from 'date-fns';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export interface CurrencyFormatter {
|
|
4
|
+
symbol: string;
|
|
5
|
+
decimalDigits: number;
|
|
6
|
+
}
|
|
7
|
+
export interface NumberFormatter {
|
|
8
|
+
decimalSymbol: string;
|
|
9
|
+
thousandsSymbol: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @author
|
|
13
|
+
*/
|
|
14
|
+
export interface DateFormatter {
|
|
15
|
+
dateFormat: string;
|
|
16
|
+
datetimeFormat: string;
|
|
17
|
+
dateMask: string;
|
|
18
|
+
datetimeMask: string;
|
|
19
|
+
timeFormat: string;
|
|
20
|
+
timeMask: string;
|
|
21
|
+
formatDate: (date: Date | number, format: string, options?: any) => string;
|
|
22
|
+
}
|
|
23
|
+
export interface OptionalDateFormatter {
|
|
24
|
+
dateFormat?: string;
|
|
25
|
+
datetimeFormat?: string;
|
|
26
|
+
dateMask?: string;
|
|
27
|
+
datetimeMask?: string;
|
|
28
|
+
timeFormat?: string;
|
|
29
|
+
timeMask?: string;
|
|
30
|
+
formatDate: (date: Date | number, format: string, options?: {
|
|
31
|
+
locale?: Locale;
|
|
32
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
33
|
+
firstWeekContainsDate?: number;
|
|
34
|
+
useAdditionalWeekYearTokens?: boolean;
|
|
35
|
+
useAdditionalDayOfYearTokens?: boolean;
|
|
36
|
+
}) => string;
|
|
37
|
+
}
|
|
38
|
+
export interface Formatters {
|
|
39
|
+
currencyFormatter: CurrencyFormatter;
|
|
40
|
+
dateFormatter: DateFormatter;
|
|
41
|
+
numberFormatter: NumberFormatter;
|
|
42
|
+
}
|
|
43
|
+
export interface OptionalFormatters {
|
|
44
|
+
currencyFormatter?: CurrencyFormatter;
|
|
45
|
+
dateFormatter?: OptionalDateFormatter;
|
|
46
|
+
numberFormatter?: NumberFormatter;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @interface
|
|
50
|
+
*/
|
|
51
|
+
export interface FormatterProviderProps extends OptionalFormatters {
|
|
52
|
+
isMicroFrontEnd: boolean;
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
}
|
|
55
|
+
export declare type FormatterContextProps = Formatters;
|
|
@@ -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):
|
|
4
|
+
declare function HostThemeProvider(props: HostThemeProviderProps): JSX.Element;
|
|
5
5
|
export { HostThemeProvider, HostThemeContext };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createContext as k, useState as _, useCallback as x, useEffect as L } from "react";
|
|
2
|
+
import { AdapterDateFns as F } from "@mui/x-date-pickers/AdapterDateFns";
|
|
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
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
7
|
+
async function B(t, e, o) {
|
|
8
|
+
const s = f(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: f(r)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function f(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 {
|
|
39
|
+
children: e,
|
|
40
|
+
isMicroFrontEnd: o,
|
|
41
|
+
localeHost: s,
|
|
42
|
+
getLocaleFromNetwork: r
|
|
43
|
+
} = t;
|
|
44
|
+
if (o && !s)
|
|
45
|
+
throw Error("Must set localeHost in microfrontend");
|
|
46
|
+
if (!o && !r)
|
|
47
|
+
throw Error("Must set getLocaleFromNetwork in host");
|
|
48
|
+
const {
|
|
49
|
+
domain_token: i,
|
|
50
|
+
host_static_assets: v,
|
|
51
|
+
environment_assets: h
|
|
52
|
+
} = P(), {
|
|
53
|
+
networkOperation: C
|
|
54
|
+
} = I(), {
|
|
55
|
+
events_add_listener: N,
|
|
56
|
+
events_remove_listener: T,
|
|
57
|
+
events_emit: H
|
|
58
|
+
} = j(), [a, d] = _(() => {
|
|
59
|
+
if (o)
|
|
60
|
+
return s;
|
|
61
|
+
}), [l, m] = w("localeHost", navigator.language), [M, A] = _(""), p = x((n) => {
|
|
62
|
+
d(n);
|
|
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(() => {
|
|
67
|
+
let n = !0;
|
|
68
|
+
if (!o && !!r && !(l === M && l !== ""))
|
|
69
|
+
return C({
|
|
70
|
+
method: "POST",
|
|
71
|
+
endPoint: "na/locales",
|
|
72
|
+
data: {
|
|
73
|
+
...y(l),
|
|
74
|
+
domain_token: i
|
|
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);
|
|
79
|
+
});
|
|
80
|
+
}).finally(() => {
|
|
81
|
+
}), function() {
|
|
82
|
+
n = !1;
|
|
83
|
+
};
|
|
84
|
+
}, [l]), !a)
|
|
85
|
+
return /* @__PURE__ */ g("div", {});
|
|
86
|
+
const O = (n) => {
|
|
87
|
+
(n.lang !== a.lang || n.script !== a.script || n.region !== a.region) && m(f(n));
|
|
88
|
+
};
|
|
89
|
+
return /* @__PURE__ */ g(G.Provider, {
|
|
90
|
+
value: {
|
|
91
|
+
currentLocale: a,
|
|
92
|
+
onChangeLocale: O
|
|
93
|
+
},
|
|
94
|
+
children: /* @__PURE__ */ g(U, {
|
|
95
|
+
dateAdapter: F,
|
|
96
|
+
adapterLocale: a.module,
|
|
97
|
+
dateFormats: {
|
|
98
|
+
hours24h: "23"
|
|
99
|
+
},
|
|
100
|
+
children: e
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
G as L,
|
|
106
|
+
J as a,
|
|
107
|
+
B as g
|
|
108
|
+
};
|
|
@@ -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):
|
|
4
|
+
declare function LocalesProvider(props: LocalesProviderProps): JSX.Element;
|
|
5
5
|
export { LocalesProvider, LocalesContext };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createContext as p, useState as D, useCallback as k, useEffect as v } from "react";
|
|
2
|
+
import { useHostTools as C, usePropageteMF as R, EmitEvents as b } from "@m4l/core";
|
|
3
|
+
import { u as h } from "../hooks/index.de62e8aa.js";
|
|
4
|
+
import { jsx as V } from "react/jsx-runtime";
|
|
5
|
+
import "./LocalesContext/index.3fcfbe02.js";
|
|
6
|
+
import "date-fns/locale/en-US";
|
|
7
|
+
import "./HostThemeContext/index.a6a62c70.js";
|
|
8
|
+
const x = p(null);
|
|
9
|
+
function L(g) {
|
|
10
|
+
const {
|
|
11
|
+
children: T,
|
|
12
|
+
isMicroFrontEnd: r,
|
|
13
|
+
currencyFormatter: F,
|
|
14
|
+
numberFormatter: y,
|
|
15
|
+
dateFormatter: t
|
|
16
|
+
} = g, o = F?.decimalDigits || 0, a = F?.symbol || "$", m = y?.decimalSymbol || 0.1 .toLocaleString().substring(1, 2), s = y?.thousandsSymbol || 1e3 .toLocaleString().substring(1, 2), n = t?.dateFormat || "yyyy-MM-dd", c = t?.dateMask || "____-__-__", i = t?.datetimeFormat || "yyyy-MM-dd HH:mm:ss", _ = t?.datetimeMask || "____-__-__ __:__:__", d = t?.timeFormat || "HH:mm:ss", u = t?.timeMask || "__:__:__", l = t?.formatDate || (() => {
|
|
17
|
+
throw new Error("Incorrect use of formatDate");
|
|
18
|
+
}), M = h(), {
|
|
19
|
+
events_emit: H
|
|
20
|
+
} = C(), [f, E] = D({
|
|
21
|
+
currencyFormatter: {
|
|
22
|
+
decimalDigits: o,
|
|
23
|
+
symbol: a
|
|
24
|
+
},
|
|
25
|
+
numberFormatter: {
|
|
26
|
+
decimalSymbol: m,
|
|
27
|
+
thousandsSymbol: s
|
|
28
|
+
},
|
|
29
|
+
dateFormatter: {
|
|
30
|
+
dateFormat: n,
|
|
31
|
+
dateMask: c,
|
|
32
|
+
datetimeFormat: i,
|
|
33
|
+
datetimeMask: _,
|
|
34
|
+
timeFormat: d,
|
|
35
|
+
timeMask: u,
|
|
36
|
+
formatDate: l
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
console.log("FormatterProvider", r, f.dateFormatter.formatDate);
|
|
40
|
+
const S = k((e) => {
|
|
41
|
+
E(e);
|
|
42
|
+
}, []);
|
|
43
|
+
return R({
|
|
44
|
+
isMicroFrontEnd: r,
|
|
45
|
+
event: b.EMMIT_EVENT_HOST_FORMATTER_CHANGE,
|
|
46
|
+
setHandler: S
|
|
47
|
+
}), v(() => {
|
|
48
|
+
if (r || M)
|
|
49
|
+
return;
|
|
50
|
+
const e = {
|
|
51
|
+
currencyFormatter: {
|
|
52
|
+
decimalDigits: o,
|
|
53
|
+
symbol: a
|
|
54
|
+
},
|
|
55
|
+
numberFormatter: {
|
|
56
|
+
decimalSymbol: m,
|
|
57
|
+
thousandsSymbol: s
|
|
58
|
+
},
|
|
59
|
+
dateFormatter: {
|
|
60
|
+
dateFormat: n,
|
|
61
|
+
dateMask: c,
|
|
62
|
+
datetimeFormat: i,
|
|
63
|
+
datetimeMask: _,
|
|
64
|
+
timeFormat: d,
|
|
65
|
+
timeMask: u,
|
|
66
|
+
formatDate: l
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
E(e), H(b.EMMIT_EVENT_HOST_FORMATTER_CHANGE, e);
|
|
70
|
+
}, [M, a, o, m, s, n, c, i, _, d, u, l]), /* @__PURE__ */ V(x.Provider, {
|
|
71
|
+
value: {
|
|
72
|
+
...f
|
|
73
|
+
},
|
|
74
|
+
children: T
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
x as F,
|
|
79
|
+
L as a
|
|
80
|
+
};
|
package/contexts/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export * from './FormatterContext';
|
|
2
|
+
export type { Formatters, DateFormatter, NumberFormatter, CurrencyFormatter, } from './FormatterContext/types';
|
|
1
3
|
export * from './LocalesContext';
|
|
2
4
|
export type { NetworkLocaleType, LocaleType } from './LocalesContext/types';
|
|
3
5
|
export { getLocaleFromNetwork } from './LocalesContext/helper';
|
package/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useRef as s, useEffect as e, useContext as u, useState as f } from "react";
|
|
2
|
+
import { F as i } from "../contexts/index.bd12693a.js";
|
|
3
|
+
import "@mui/material/styles";
|
|
4
|
+
import "@mui/material/useMediaQuery";
|
|
5
|
+
import "../contexts/LocalesContext/index.3fcfbe02.js";
|
|
6
|
+
import "../contexts/HostThemeContext/index.a6a62c70.js";
|
|
7
|
+
function w() {
|
|
8
|
+
const t = s(!0);
|
|
9
|
+
return e(
|
|
10
|
+
() => () => {
|
|
11
|
+
t.current = !1;
|
|
12
|
+
},
|
|
13
|
+
[]
|
|
14
|
+
), t.current;
|
|
15
|
+
}
|
|
16
|
+
const F = () => {
|
|
17
|
+
const t = u(i);
|
|
18
|
+
if (!t)
|
|
19
|
+
throw new Error("useFormatter context must be use inside FormatterProvider");
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
function x() {
|
|
23
|
+
const t = s(!0);
|
|
24
|
+
return e(
|
|
25
|
+
() => () => {
|
|
26
|
+
t.current = !1;
|
|
27
|
+
},
|
|
28
|
+
[]
|
|
29
|
+
), t;
|
|
30
|
+
}
|
|
31
|
+
function T(t) {
|
|
32
|
+
const [n, r] = f(!1), o = t || 100;
|
|
33
|
+
return e(() => (window.onscroll = () => {
|
|
34
|
+
window.pageYOffset > o ? r(!0) : r(!1);
|
|
35
|
+
}, () => {
|
|
36
|
+
window.onscroll = null;
|
|
37
|
+
}), [o]), n;
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
F as a,
|
|
41
|
+
x as b,
|
|
42
|
+
T as c,
|
|
43
|
+
w as u
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFirstRender(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useFormatter: () => import("../..").Formatters;
|
|
File without changes
|
package/index.js
CHANGED
|
@@ -1,46 +1,50 @@
|
|
|
1
1
|
import { P as l } from "./components/ProgressBarStyle/index.fb6fd9ed.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { u as S } from "./hooks/
|
|
7
|
-
import { u as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
2
|
+
import { F as n, a as c } from "./contexts/index.bd12693a.js";
|
|
3
|
+
import { L as C, a as h, g as v } from "./contexts/LocalesContext/index.3fcfbe02.js";
|
|
4
|
+
import { H as g, a as L } from "./contexts/HostThemeContext/index.a6a62c70.js";
|
|
5
|
+
import { a as H, b as w, c as O } from "./hooks/index.de62e8aa.js";
|
|
6
|
+
import { u as S, a as k } from "./hooks/useResponsive/index.fc5e1b4f.js";
|
|
7
|
+
import { u as y } from "./hooks/useLocales/index.8154a401.js";
|
|
8
|
+
import { u as B } from "./hooks/useHostTheme/index.1c8e4ad7.js";
|
|
9
|
+
import { d as G } from "./theme/defaultThemeOptions.9b9e7503.js";
|
|
10
|
+
import { c as M, s as N } from "./theme/shadows.bf8dc290.js";
|
|
11
|
+
import { p as j } from "./theme/palette.2baf72f5.js";
|
|
12
|
+
import { C as A, a as E, c as J, d as K, g as Q } from "./utils/index.d8b24456.js";
|
|
13
|
+
import { f as W } from "./theme/overrides.7958c0ab.js";
|
|
13
14
|
import "@mui/material/styles";
|
|
14
15
|
import "@mui/material";
|
|
15
16
|
import "react/jsx-runtime";
|
|
16
17
|
import "react";
|
|
17
|
-
import "@mui/x-date-pickers/AdapterDateFns";
|
|
18
|
-
import "@mui/x-date-pickers";
|
|
19
18
|
import "@m4l/core";
|
|
20
19
|
import "date-fns/locale/en-US";
|
|
20
|
+
import "@mui/x-date-pickers/AdapterDateFns";
|
|
21
|
+
import "@mui/x-date-pickers";
|
|
21
22
|
import "@mui/material/useMediaQuery";
|
|
22
23
|
import "./theme/typography.f5eadf47.js";
|
|
23
24
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
A as Capitalize,
|
|
26
|
+
n as FormatterContext,
|
|
27
|
+
c as FormatterProvider,
|
|
28
|
+
E as GetFontValue,
|
|
29
|
+
g as HostThemeContext,
|
|
30
|
+
L as HostThemeProvider,
|
|
31
|
+
C as LocalesContext,
|
|
32
|
+
h as LocalesProvider,
|
|
30
33
|
l as ProgressBarStyle,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
J as colorPresets,
|
|
35
|
+
M as customShadows,
|
|
36
|
+
K as defaultPreset,
|
|
37
|
+
G as defaultThemeOptions,
|
|
38
|
+
W as fnComponentsOverrides,
|
|
39
|
+
Q as getColorPresets,
|
|
40
|
+
v as getLocaleFromNetwork,
|
|
41
|
+
j as palette,
|
|
42
|
+
N as shadows,
|
|
43
|
+
H as useFormatter,
|
|
44
|
+
B as useHostTheme,
|
|
41
45
|
w as useIsMountedRef,
|
|
42
|
-
|
|
46
|
+
y as useLocales,
|
|
43
47
|
O as useOffSetTop,
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
S as useResponsive,
|
|
49
|
+
k as useResponsiveDesktop
|
|
46
50
|
};
|
package/package.json
CHANGED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { createContext as T, useState as k, useCallback as w, useEffect as E } from "react";
|
|
2
|
-
import { AdapterDateFns as A } from "@mui/x-date-pickers/AdapterDateFns";
|
|
3
|
-
import { LocalizationProvider as F } from "@mui/x-date-pickers";
|
|
4
|
-
import { useEnvironment as O, useNetwork as P, useHostTools as U, useLocalStorage as j, EmitEvents as h, setLocalStorage as x } from "@m4l/core";
|
|
5
|
-
import v from "date-fns/locale/en-US";
|
|
6
|
-
import { jsx as g } from "react/jsx-runtime";
|
|
7
|
-
async function q(o, t, n) {
|
|
8
|
-
const l = u(o), e = { ...o };
|
|
9
|
-
console.log("baseLocale initia", o, t, n);
|
|
10
|
-
let i;
|
|
11
|
-
return l === "es" ? i = (await import("date-fns/locale/es")).default : l === "fr" ? i = (await import("date-fns/locale/fr")).default : l === "en-US" ? i = v : (i = v, e.lang = "en", e.script = void 0, e.region = "US", e.url_icon = `${t}/${n}/frontend/commons/assets/icons/langs/lang_en.svg`, e.name = "English US*"), console.log("getLocale", l, e, i), {
|
|
12
|
-
...e,
|
|
13
|
-
module: i,
|
|
14
|
-
localeString: u(e)
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function u(o) {
|
|
18
|
-
let t = o.lang;
|
|
19
|
-
return o.script && o.script !== "" && (t = t + "-" + o.script), o.region && o.region !== "" && (t = t + "-" + o.region), console.log(
|
|
20
|
-
"joinLocale",
|
|
21
|
-
o.region && o.region !== "",
|
|
22
|
-
o.region,
|
|
23
|
-
t + "-" + o.region,
|
|
24
|
-
t,
|
|
25
|
-
o
|
|
26
|
-
), t;
|
|
27
|
-
}
|
|
28
|
-
function $(o) {
|
|
29
|
-
console.log("splitLocale", o);
|
|
30
|
-
const t = new Intl.Locale(o);
|
|
31
|
-
return {
|
|
32
|
-
lang: t.language || "",
|
|
33
|
-
script: t.script,
|
|
34
|
-
region: t.region
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
const I = T(null);
|
|
38
|
-
function B(o) {
|
|
39
|
-
const {
|
|
40
|
-
children: t,
|
|
41
|
-
isMicroFrontEnd: n,
|
|
42
|
-
localeHost: l,
|
|
43
|
-
getLocaleFromNetwork: e
|
|
44
|
-
} = o;
|
|
45
|
-
if (n && !l)
|
|
46
|
-
throw Error("Must set localeHost in microfrontend");
|
|
47
|
-
if (!n && !e)
|
|
48
|
-
throw Error("Must set getLocaleFromNetwork in host");
|
|
49
|
-
const {
|
|
50
|
-
domain_token: i,
|
|
51
|
-
host_static_assets: f,
|
|
52
|
-
environment_assets: d
|
|
53
|
-
} = O(), {
|
|
54
|
-
networkOperation: S
|
|
55
|
-
} = P(), {
|
|
56
|
-
events_add_listener: L,
|
|
57
|
-
events_remove_listener: H,
|
|
58
|
-
events_emit: C
|
|
59
|
-
} = U(), [s, m] = k(() => {
|
|
60
|
-
if (n)
|
|
61
|
-
return l;
|
|
62
|
-
}), [p, N] = j("localeHost", navigator.language), _ = w((r) => {
|
|
63
|
-
m(r);
|
|
64
|
-
}, []);
|
|
65
|
-
if (E(() => (n && L(h.EMMIT_EVENT_HOST_LOCALE_CHANGE, _), () => {
|
|
66
|
-
n && H("host_theme_change", _);
|
|
67
|
-
}), []), E(() => {
|
|
68
|
-
let r = !0;
|
|
69
|
-
if (!n && !!e)
|
|
70
|
-
return console.log("newLocaleString", `${f}/${d}/frontend/commons/assets/icons/langs/lang_en.svg`), S({
|
|
71
|
-
method: "POST",
|
|
72
|
-
endPoint: "na/locales",
|
|
73
|
-
data: {
|
|
74
|
-
...$(p),
|
|
75
|
-
domain_token: i
|
|
76
|
-
}
|
|
77
|
-
}).then((c) => {
|
|
78
|
-
console.log("Response", c), r && e(c.data, f, d).then((a) => {
|
|
79
|
-
m(a), x("localeHost", a.localeString), console.log("Set localeHost", a.localeString), C(h.EMMIT_EVENT_HOST_LOCALE_CHANGE, a);
|
|
80
|
-
});
|
|
81
|
-
}).finally(() => {
|
|
82
|
-
}), function() {
|
|
83
|
-
r = !1;
|
|
84
|
-
};
|
|
85
|
-
}, [p]), !s)
|
|
86
|
-
return /* @__PURE__ */ g("div", {
|
|
87
|
-
children: "Cargando localeHost"
|
|
88
|
-
});
|
|
89
|
-
const M = (r) => {
|
|
90
|
-
(r.lang !== s.lang || r.script !== s.script || r.region !== s.region) && N(u(r));
|
|
91
|
-
};
|
|
92
|
-
return /* @__PURE__ */ g(I.Provider, {
|
|
93
|
-
value: {
|
|
94
|
-
currentLocale: s,
|
|
95
|
-
onChangeLocale: M
|
|
96
|
-
},
|
|
97
|
-
children: /* @__PURE__ */ g(F, {
|
|
98
|
-
dateAdapter: A,
|
|
99
|
-
adapterLocale: s.module,
|
|
100
|
-
dateFormats: {
|
|
101
|
-
hours24h: "23"
|
|
102
|
-
},
|
|
103
|
-
children: t
|
|
104
|
-
})
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
export {
|
|
108
|
-
I as L,
|
|
109
|
-
B as a,
|
|
110
|
-
q as g
|
|
111
|
-
};
|
package/hooks/index.2942e1ab.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useRef as n, useEffect as s, useState as r } from "react";
|
|
2
|
-
import "@mui/material/styles";
|
|
3
|
-
import "@mui/material/useMediaQuery";
|
|
4
|
-
import "../contexts/LocalesContext/index.ca1e2149.js";
|
|
5
|
-
import "../contexts/HostThemeContext/index.a6a62c70.js";
|
|
6
|
-
function a() {
|
|
7
|
-
const e = n(!0);
|
|
8
|
-
return s(
|
|
9
|
-
() => () => {
|
|
10
|
-
e.current = !1;
|
|
11
|
-
},
|
|
12
|
-
[]
|
|
13
|
-
), e;
|
|
14
|
-
}
|
|
15
|
-
function m(e) {
|
|
16
|
-
const [f, t] = r(!1), o = e || 100;
|
|
17
|
-
return s(() => (window.onscroll = () => {
|
|
18
|
-
window.pageYOffset > o ? t(!0) : t(!1);
|
|
19
|
-
}, () => {
|
|
20
|
-
window.onscroll = null;
|
|
21
|
-
}), [o]), f;
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
m as a,
|
|
25
|
-
a as u
|
|
26
|
-
};
|