@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.
@@ -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;
@@ -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';
@@ -1,3 +1,4 @@
1
+ import "./FormatterContext/index.06536651.js";
1
2
  import "./LocalesContext/index.3fcfbe02.js";
2
3
  import "date-fns/locale/en-US";
3
4
  import "./HostThemeContext/index.a6a62c70.js";
package/hooks/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { useFormatter } from './useFormatter';
1
2
  export { useResponsive, useResponsiveDesktop } from './useResponsive';
2
3
  export { useIsMountedRef } from './useIsMountedRef';
3
4
  export { useLocales } from './useLocales';
@@ -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
+ };
package/index.js CHANGED
@@ -1,46 +1,51 @@
1
1
  import { P as l } from "./components/ProgressBarStyle/index.fb6fd9ed.js";
2
- import { L as n, a as c, g as P } from "./contexts/LocalesContext/index.3fcfbe02.js";
3
- import { H as C, a as g } from "./contexts/HostThemeContext/index.a6a62c70.js";
4
- import { u as L, a as T } from "./hooks/useResponsive/index.fc5e1b4f.js";
5
- import { u as w, a as O } from "./hooks/index.c9dba2ff.js";
6
- import { u as S } from "./hooks/useLocales/index.8154a401.js";
7
- import { u as F } from "./hooks/useHostTheme/index.1c8e4ad7.js";
8
- import { d as z } from "./theme/defaultThemeOptions.9b9e7503.js";
9
- import { c as D, s as G } from "./theme/shadows.bf8dc290.js";
10
- import { p as M } from "./theme/palette.2baf72f5.js";
11
- import { C as V, a as b, c as j, d as q, g as A } from "./utils/index.d8b24456.js";
12
- import { f as J } from "./theme/overrides.7958c0ab.js";
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
- V as Capitalize,
25
- b as GetFontValue,
26
- C as HostThemeContext,
27
- g as HostThemeProvider,
28
- n as LocalesContext,
29
- c as LocalesProvider,
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
- j as colorPresets,
32
- D as customShadows,
33
- q as defaultPreset,
34
- z as defaultThemeOptions,
35
- J as fnComponentsOverrides,
36
- A as getColorPresets,
37
- P as getLocaleFromNetwork,
38
- M as palette,
39
- G as shadows,
40
- F as useHostTheme,
41
- w as useIsMountedRef,
42
- S as useLocales,
43
- O as useOffSetTop,
44
- L as useResponsive,
45
- T as useResponsiveDesktop
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/graphics",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team",
6
6
  "dependencies": {
@@ -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
- };