@m4l/graphics 0.1.12 → 0.1.14
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/FormatterContext/index.06536651.js +77 -0
- package/contexts/FormatterContext/index.d.ts +16 -0
- package/contexts/FormatterContext/types.d.ts +55 -0
- package/contexts/index.d.ts +2 -0
- package/contexts/{index.7975256a.js → index.f665068e.js} +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.f7923b00.js +37 -0
- package/hooks/useFirstRender/index.d.ts +1 -0
- package/hooks/useFormatter/index.d.ts +1 -0
- package/hooks/useFormatter/index.d30c615c.js +11 -0
- package/hooks/{useIsMountedRef.d.ts → useIsMountedRef/index.d.ts} +0 -0
- package/index.js +38 -33
- package/package.json +1 -1
- package/hooks/index.c9dba2ff.js +0 -26
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createContext as D, useState as k, useCallback as v, useEffect as C } from "react";
|
|
2
|
+
import { useHostTools as p, usePropageteMF as R, EmitEvents as b } from "@m4l/core";
|
|
3
|
+
import { u as h } from "../../hooks/index.f7923b00.js";
|
|
4
|
+
import { jsx as V } from "react/jsx-runtime";
|
|
5
|
+
const x = D(null);
|
|
6
|
+
function w(g) {
|
|
7
|
+
const {
|
|
8
|
+
children: T,
|
|
9
|
+
isMicroFrontEnd: r,
|
|
10
|
+
currencyFormatter: F,
|
|
11
|
+
numberFormatter: y,
|
|
12
|
+
dateFormatter: t
|
|
13
|
+
} = g, o = F?.decimalDigits || 0, a = F?.symbol || "$", s = y?.decimalSymbol || 0.1 .toLocaleString().substring(1, 2), m = 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 || (() => {
|
|
14
|
+
throw new Error("Incorrect use of formatDate");
|
|
15
|
+
}), M = h(), {
|
|
16
|
+
events_emit: H
|
|
17
|
+
} = p(), [f, E] = k({
|
|
18
|
+
currencyFormatter: {
|
|
19
|
+
decimalDigits: o,
|
|
20
|
+
symbol: a
|
|
21
|
+
},
|
|
22
|
+
numberFormatter: {
|
|
23
|
+
decimalSymbol: s,
|
|
24
|
+
thousandsSymbol: m
|
|
25
|
+
},
|
|
26
|
+
dateFormatter: {
|
|
27
|
+
dateFormat: n,
|
|
28
|
+
dateMask: c,
|
|
29
|
+
datetimeFormat: i,
|
|
30
|
+
datetimeMask: _,
|
|
31
|
+
timeFormat: d,
|
|
32
|
+
timeMask: u,
|
|
33
|
+
formatDate: l
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
console.log("FormatterProvider", r, f.dateFormatter.formatDate);
|
|
37
|
+
const S = v((e) => {
|
|
38
|
+
E(e);
|
|
39
|
+
}, []);
|
|
40
|
+
return R({
|
|
41
|
+
isMicroFrontEnd: r,
|
|
42
|
+
event: b.EMMIT_EVENT_HOST_FORMATTER_CHANGE,
|
|
43
|
+
setHandler: S
|
|
44
|
+
}), C(() => {
|
|
45
|
+
if (r || M)
|
|
46
|
+
return;
|
|
47
|
+
const e = {
|
|
48
|
+
currencyFormatter: {
|
|
49
|
+
decimalDigits: o,
|
|
50
|
+
symbol: a
|
|
51
|
+
},
|
|
52
|
+
numberFormatter: {
|
|
53
|
+
decimalSymbol: s,
|
|
54
|
+
thousandsSymbol: m
|
|
55
|
+
},
|
|
56
|
+
dateFormatter: {
|
|
57
|
+
dateFormat: n,
|
|
58
|
+
dateMask: c,
|
|
59
|
+
datetimeFormat: i,
|
|
60
|
+
datetimeMask: _,
|
|
61
|
+
timeFormat: d,
|
|
62
|
+
timeMask: u,
|
|
63
|
+
formatDate: l
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
E(e), H(b.EMMIT_EVENT_HOST_FORMATTER_CHANGE, e);
|
|
67
|
+
}, [M, a, o, s, m, n, c, i, _, d, u, l]), /* @__PURE__ */ V(x.Provider, {
|
|
68
|
+
value: {
|
|
69
|
+
...f
|
|
70
|
+
},
|
|
71
|
+
children: T
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
x as F,
|
|
76
|
+
w as a
|
|
77
|
+
};
|
|
@@ -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;
|
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,37 @@
|
|
|
1
|
+
import { useRef as s, useEffect as t, useState as u } from "react";
|
|
2
|
+
import "../contexts/FormatterContext/index.06536651.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 d() {
|
|
8
|
+
const e = s(!0);
|
|
9
|
+
return t(
|
|
10
|
+
() => () => {
|
|
11
|
+
e.current = !1;
|
|
12
|
+
},
|
|
13
|
+
[]
|
|
14
|
+
), e.current;
|
|
15
|
+
}
|
|
16
|
+
function m() {
|
|
17
|
+
const e = s(!0);
|
|
18
|
+
return t(
|
|
19
|
+
() => () => {
|
|
20
|
+
e.current = !1;
|
|
21
|
+
},
|
|
22
|
+
[]
|
|
23
|
+
), e;
|
|
24
|
+
}
|
|
25
|
+
function w(e) {
|
|
26
|
+
const [n, o] = u(!1), r = e || 100;
|
|
27
|
+
return t(() => (window.onscroll = () => {
|
|
28
|
+
window.pageYOffset > r ? o(!0) : o(!1);
|
|
29
|
+
}, () => {
|
|
30
|
+
window.onscroll = null;
|
|
31
|
+
}), [r]), n;
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
m as a,
|
|
35
|
+
w as b,
|
|
36
|
+
d as u
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFirstRender(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
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.06536651.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
|
+
};
|
|
File without changes
|
package/index.js
CHANGED
|
@@ -1,46 +1,51 @@
|
|
|
1
1
|
import { P as l } from "./components/ProgressBarStyle/index.fb6fd9ed.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { u as
|
|
6
|
-
import { u as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
2
|
+
import { F as n, a as c } from "./contexts/FormatterContext/index.06536651.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 { u as H } from "./hooks/useFormatter/index.d30c615c.js";
|
|
6
|
+
import { u as O, a as R } from "./hooks/useResponsive/index.fc5e1b4f.js";
|
|
7
|
+
import { a as k, b } from "./hooks/index.f7923b00.js";
|
|
8
|
+
import { u as z } from "./hooks/useLocales/index.8154a401.js";
|
|
9
|
+
import { u as D } from "./hooks/useHostTheme/index.1c8e4ad7.js";
|
|
10
|
+
import { d as I } from "./theme/defaultThemeOptions.9b9e7503.js";
|
|
11
|
+
import { c as N, s as V } from "./theme/shadows.bf8dc290.js";
|
|
12
|
+
import { p as q } from "./theme/palette.2baf72f5.js";
|
|
13
|
+
import { C as E, a as J, c as K, d as Q, g as U } from "./utils/index.d8b24456.js";
|
|
14
|
+
import { f as X } from "./theme/overrides.7958c0ab.js";
|
|
13
15
|
import "@mui/material/styles";
|
|
14
16
|
import "@mui/material";
|
|
15
17
|
import "react/jsx-runtime";
|
|
16
18
|
import "react";
|
|
19
|
+
import "@m4l/core";
|
|
17
20
|
import "@mui/x-date-pickers/AdapterDateFns";
|
|
18
21
|
import "@mui/x-date-pickers";
|
|
19
|
-
import "@m4l/core";
|
|
20
22
|
import "date-fns/locale/en-US";
|
|
21
23
|
import "@mui/material/useMediaQuery";
|
|
22
24
|
import "./theme/typography.f5eadf47.js";
|
|
23
25
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
E as Capitalize,
|
|
27
|
+
n as FormatterContext,
|
|
28
|
+
c as FormatterProvider,
|
|
29
|
+
J as GetFontValue,
|
|
30
|
+
g as HostThemeContext,
|
|
31
|
+
L as HostThemeProvider,
|
|
32
|
+
C as LocalesContext,
|
|
33
|
+
h as LocalesProvider,
|
|
30
34
|
l as ProgressBarStyle,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
K as colorPresets,
|
|
36
|
+
N as customShadows,
|
|
37
|
+
Q as defaultPreset,
|
|
38
|
+
I as defaultThemeOptions,
|
|
39
|
+
X as fnComponentsOverrides,
|
|
40
|
+
U as getColorPresets,
|
|
41
|
+
v as getLocaleFromNetwork,
|
|
42
|
+
q as palette,
|
|
43
|
+
V as shadows,
|
|
44
|
+
H as useFormatter,
|
|
45
|
+
D as useHostTheme,
|
|
46
|
+
k as useIsMountedRef,
|
|
47
|
+
z as useLocales,
|
|
48
|
+
b as useOffSetTop,
|
|
49
|
+
O as useResponsive,
|
|
50
|
+
R as useResponsiveDesktop
|
|
46
51
|
};
|
package/package.json
CHANGED
package/hooks/index.c9dba2ff.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.3fcfbe02.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
|
-
};
|