@m4l/graphics 7.0.7 → 7.0.8

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,9 @@
1
+ import { DeviceType } from './types';
2
+ /**
3
+ * Check if the device type
4
+ * @author Juan Escobar - automatic
5
+ * @createdAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedAt 2024-10-08 19:28:36 - automatic
7
+ * @updatedUser Juan Escobar - automatic
8
+ */
9
+ export declare const getDeviceType: (userAgent: string | undefined) => DeviceType;
@@ -0,0 +1,4 @@
1
+ const i = (e) => typeof e > "u" ? "desktop" : /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e) ? "mobile" : "desktop";
2
+ export {
3
+ i as g
4
+ };
@@ -0,0 +1,19 @@
1
+ import { DeviceTypePrivderProps } from './types';
2
+ declare const DeviceTypeContext: import('react').Context<(Omit<Omit<import('zustand').StoreApi<import('./types').DeviceTypeWithActions>, "setState"> & {
3
+ setState<A extends string | {
4
+ type: unknown;
5
+ }>(partial: import('./types').DeviceTypeWithActions | Partial<import('./types').DeviceTypeWithActions> | ((state: import('./types').DeviceTypeWithActions) => import('./types').DeviceTypeWithActions | Partial<import('./types').DeviceTypeWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
6
+ }, "setState"> & {
7
+ setState(nextStateOrUpdater: import('./types').DeviceTypeWithActions | Partial<import('./types').DeviceTypeWithActions> | ((state: import('immer/dist/internal').WritableDraft<import('./types').DeviceTypeWithActions>) => void), shouldReplace?: boolean | undefined, action?: string | {
8
+ type: unknown;
9
+ } | undefined): void;
10
+ }) | null>;
11
+ /**
12
+ * Proveedor de contenedor responsivo
13
+ * @author Juan Escobar - automatic
14
+ * @createdAt 2024-10-06 20:07:18 - automatic
15
+ * @updatedAt 2024-10-08 19:03:38 - automatic
16
+ * @updatedUser Juan Escobar - automatic
17
+ */
18
+ declare const DeviceTypeProvider: (props: DeviceTypePrivderProps) => import("react").JSX.Element;
19
+ export { DeviceTypeProvider, DeviceTypeContext };
@@ -0,0 +1,17 @@
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { createContext as s, useRef as p, useEffect as u } from "react";
3
+ import { c as a } from "./store.js";
4
+ import { g as f } from "./helper.js";
5
+ import { u as v } from "../../hooks/useUserAgent/index.js";
6
+ const m = s(null), l = (r) => {
7
+ const { children: c, forcedDeviceType: o } = r, i = v(), e = p(), t = o ?? f(i);
8
+ return e.current || (e.current = a({
9
+ deviceType: t
10
+ })), u(() => {
11
+ e.current?.getState().deviceType !== t && e.current?.getState().actions.setDeviceType(t);
12
+ }, [t]), /* @__PURE__ */ n(m.Provider, { value: e.current, children: c });
13
+ };
14
+ export {
15
+ m as D,
16
+ l as a
17
+ };
@@ -0,0 +1,18 @@
1
+ import { InitialDeviceTypeProps, DeviceTypeWithActions } from './types';
2
+ /**
3
+ * Crea la tienda de contenedor responsivo
4
+ * @author Juan Escobar - automatic
5
+ * @createdAt 2024-10-06 20:07:18 - automatic
6
+ * @updatedAt 2024-10-06 20:07:18 - automatic
7
+ * @updatedUser Juan Escobar - automatic
8
+ */
9
+ export declare const createDeviceTypeStore: (initProps: InitialDeviceTypeProps) => Omit<Omit<import('zustand').StoreApi<DeviceTypeWithActions>, "setState"> & {
10
+ setState<A extends string | {
11
+ type: unknown;
12
+ }>(partial: DeviceTypeWithActions | Partial<DeviceTypeWithActions> | ((state: DeviceTypeWithActions) => DeviceTypeWithActions | Partial<DeviceTypeWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
13
+ }, "setState"> & {
14
+ setState(nextStateOrUpdater: DeviceTypeWithActions | Partial<DeviceTypeWithActions> | ((state: import('immer/dist/internal').WritableDraft<DeviceTypeWithActions>) => void), shouldReplace?: boolean | undefined, action?: string | {
15
+ type: unknown;
16
+ } | undefined): void;
17
+ };
18
+ export type DeviceTypeStore = ReturnType<typeof createDeviceTypeStore>;
@@ -0,0 +1,33 @@
1
+ import { createStore as i } from "zustand";
2
+ import { devtools as m } from "zustand/middleware";
3
+ import { immer as p } from "zustand/middleware/immer";
4
+ const y = (e) => {
5
+ const t = {
6
+ ...e
7
+ };
8
+ return i(
9
+ m(
10
+ p((r, s) => ({
11
+ ...t,
12
+ actions: {
13
+ /**
14
+ * Establece el punto de interrupción
15
+ * @author Juan Escobar - automatic
16
+ * @createdAt 2024-10-06 20:07:18 - automatic
17
+ * @updatedAt 2024-10-06 20:07:18 - automatic
18
+ * @updatedUser Juan Escobar - automatic
19
+ */
20
+ setDeviceType: (o) => {
21
+ r((c) => {
22
+ c.deviceType = o;
23
+ });
24
+ }
25
+ }
26
+ })),
27
+ { name: "DeviceType Store" }
28
+ )
29
+ );
30
+ };
31
+ export {
32
+ y as c
33
+ };
@@ -0,0 +1,15 @@
1
+ import { default as React } from 'react';
2
+ export type DeviceType = 'mobile' | 'desktop';
3
+ export interface DeviceTypeState {
4
+ deviceType: DeviceType;
5
+ }
6
+ export type InitialDeviceTypeProps = Pick<DeviceTypeState, 'deviceType'>;
7
+ export interface DeviceTypePrivderProps {
8
+ forcedDeviceType?: DeviceType;
9
+ children: React.ReactNode;
10
+ }
11
+ export interface DeviceTypeWithActions extends DeviceTypeState {
12
+ actions: {
13
+ setDeviceType: (newDeviceType: DeviceType) => void;
14
+ };
15
+ }
@@ -1,16 +1,16 @@
1
- import { jsxs as l, jsx as o } from "react/jsx-runtime";
2
- import { createContext as h, useMemo as p } from "react";
3
- import { CssBaseline as f } from "@mui/material";
1
+ import { jsxs as m, jsx as o } from "react/jsx-runtime";
2
+ import { createContext as h, useMemo as d } from "react";
3
+ import { CssBaseline as p } from "@mui/material";
4
4
  import { deepmerge as t } from "@mui/utils";
5
- import { G as u } from "../../components/GlobalStyles/index.js";
6
- import { experimental_extendTheme as x, Experimental_CssVarsProvider as v, StyledEngineProvider as C } from "@mui/material/styles";
7
- import { u as S } from "../../hooks/useIsMobile/index.js";
8
- const T = h(null);
9
- function E(c) {
10
- const { children: a, hostThemeOptions: s, fnComponentsOverrides: n, isMobileForced: i } = c, m = S(i), d = p(() => {
5
+ import { G as f } from "../../components/GlobalStyles/index.js";
6
+ import { experimental_extendTheme as u, Experimental_CssVarsProvider as x, StyledEngineProvider as v } from "@mui/material/styles";
7
+ import { u as C } from "../../hooks/useIsMobile/index.js";
8
+ const S = h(null);
9
+ function y(l) {
10
+ const { children: c, hostThemeOptions: s, fnComponentsOverrides: n } = l, i = C(), a = d(() => {
11
11
  const e = {
12
12
  ...s
13
- }, r = x({
13
+ }, r = u({
14
14
  cssVarPrefix: "m4l",
15
15
  colorSchemes: {
16
16
  light: t({}, e),
@@ -18,30 +18,29 @@ function E(c) {
18
18
  dark: t({}, e)
19
19
  },
20
20
  generalSettings: {
21
- isMobile: m
21
+ isMobile: i
22
22
  }
23
23
  });
24
24
  return r.components = n(r), r;
25
- }, [m]);
26
- return /* @__PURE__ */ l(v, { theme: d, children: [
27
- /* @__PURE__ */ o(u, {}),
25
+ }, [i]);
26
+ return /* @__PURE__ */ m(x, { theme: a, children: [
27
+ /* @__PURE__ */ o(f, {}),
28
28
  /* @__PURE__ */ o(
29
- T.Provider,
29
+ S.Provider,
30
30
  {
31
31
  value: {
32
32
  hostThemeOptions: s,
33
- fnComponentsOverrides: n,
34
- isMobileForced: i
33
+ fnComponentsOverrides: n
35
34
  },
36
- children: /* @__PURE__ */ l(C, { injectFirst: !0, children: [
37
- /* @__PURE__ */ o(f, { enableColorScheme: !0 }),
38
- a
35
+ children: /* @__PURE__ */ m(v, { injectFirst: !0, children: [
36
+ /* @__PURE__ */ o(p, { enableColorScheme: !0 }),
37
+ c
39
38
  ] })
40
39
  }
41
40
  )
42
41
  ] });
43
42
  }
44
43
  export {
45
- T as H,
46
- E as a
44
+ S as H,
45
+ y as a
47
46
  };
@@ -7,11 +7,6 @@ export interface HostThemeType {
7
7
  * @createdAt 2024-10-08 18:52:29 - automatic
8
8
  */
9
9
  dataTestId?: string;
10
- /**
11
- * "isMobileForced" es una variable que se encarga de forzar el modo mobile en la plataforma
12
- * @createdAt 2024-10-08 13:22:53 - automatic
13
- */
14
- isMobileForced?: boolean | undefined;
15
10
  hostThemeOptions: Theme;
16
11
  fnComponentsOverrides: (theme: Omit<Theme, 'palette' | 'applyStyles'> & CssVarsTheme) => any;
17
12
  }
@@ -6,5 +6,7 @@ export type { BreakpointType } from './ResponsiveContainerContext/types';
6
6
  export type { NetworkLocaleType, LocaleType } from './LocalesContext/types';
7
7
  export { getLocaleFromNetwork } from './LocalesContext/helper';
8
8
  export * from './HostThemeContext';
9
+ export * from './DeviceTypeContext';
9
10
  export * from './ThemeSettingsContext';
10
11
  export type { HostThemeType } from './HostThemeContext/types';
12
+ export type { DeviceType } from './DeviceTypeContext/types';
package/hooks/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { useFormatter } from './useFormatter';
3
3
  export { useIsMountedRef } from './useIsMountedRef';
4
4
  export { useLocales } from './useLocales';
5
5
  export { useResponsiveContainerStore } from './useResponsiveContainer';
6
+ export { useUserAgent } from './useUserAgent';
6
7
  export { useIsMobile } from './useIsMobile';
7
8
  export { useOffSetTop } from './useOffSetTop';
8
9
  export { useHostTheme } from './useHostTheme';
@@ -1,15 +1,14 @@
1
+ import { DeviceTypeWithActions } from '../../contexts/DeviceTypeContext/types';
1
2
  /**
2
- * Hook para obtener el valor del userAgent
3
- */
4
- export declare const useUserAgent: () => string;
5
- /**
6
- * Hook to check if the device is a mobile device
3
+ * Hook to use the responsive container store
7
4
  * @author Juan Escobar - automatic
8
5
  * @createdAt 2024-10-06 20:07:18 - automatic
9
- * @updatedAt 2024-10-08 19:28:36 - automatic
6
+ * @updatedAt 2024-10-06 20:07:18 - automatic
10
7
  * @updatedUser Juan Escobar - automatic
11
8
  */
9
+ export declare function useIsMobileStore<T>(selector: (state: DeviceTypeWithActions) => T, equalityFn?: (left: T, right: T) => boolean): T;
12
10
  /**
13
- * Hook de verificación de dispositivo móvil
11
+ * hook usado para obtener el valor por defecto para los componentes que usan la prop size
12
+ * @returns objeto con el valor por default del size y la función para cambiarlo
14
13
  */
15
- export declare const useIsMobile: (isMobileForced?: boolean) => boolean;
14
+ export declare function useIsMobile(isMobileForced?: boolean): boolean;
@@ -1,18 +1,16 @@
1
- import { useSyncExternalStore as r } from "react";
2
- const t = () => navigator.userAgent, s = (e) => {
3
- const n = () => e(navigator.userAgent);
4
- return window.addEventListener("userAgentChange", n), () => window.removeEventListener("userAgentChange", n);
5
- }, o = () => r(
6
- s,
7
- // Función de suscripción
8
- t,
9
- // Función para obtener el estado actual
10
- t
11
- // (Opcional) Función para obtener el valor en SSR
12
- ), i = (e) => typeof e > "u" ? !1 : /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e), c = (e) => {
13
- const n = o();
14
- return e || i(n);
15
- };
1
+ import { useContext as r } from "react";
2
+ import { useStore as i } from "zustand";
3
+ import { D as s } from "../../contexts/DeviceTypeContext/index.js";
4
+ function n(o, t) {
5
+ const e = r(s);
6
+ if (!e)
7
+ throw new Error("useIsMobileStore context must be use inside IsMobileContext");
8
+ return i(e, o, t);
9
+ }
10
+ function b(o) {
11
+ const t = n((e) => e.deviceType === "mobile");
12
+ return o || t;
13
+ }
16
14
  export {
17
- c as u
15
+ b as u
18
16
  };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Hook encargado obtener el valor del userAgent, y reaccionar a cambios en el mismo.
3
+ */
4
+ export declare const useUserAgent: () => string;
@@ -0,0 +1,25 @@
1
+ import { debounce as s } from "@mui/material";
2
+ import { useSyncExternalStore as o } from "react";
3
+ const t = () => navigator.userAgent, i = (e) => {
4
+ const n = s(
5
+ () => {
6
+ e(navigator.userAgent);
7
+ },
8
+ 500
9
+ ), r = () => {
10
+ e(navigator.userAgent);
11
+ };
12
+ return window.addEventListener("userAgentChange", r), window.addEventListener("resize", n), () => {
13
+ window.removeEventListener("userAgentChange", r), window.removeEventListener("resize", n);
14
+ };
15
+ }, u = () => o(
16
+ i,
17
+ // Función de suscripción
18
+ t,
19
+ // Función para obtener el estado actual
20
+ t
21
+ // (Opcional) Función para obtener el valor en SSR
22
+ );
23
+ export {
24
+ u
25
+ };
package/index.js CHANGED
@@ -2,48 +2,53 @@ import { G as r } from "./components/GlobalStyles/index.js";
2
2
  import { g as s } from "./contexts/LocalesContext/helper.js";
3
3
  import { F as m, a as p } from "./contexts/FormatterContext/index.js";
4
4
  import { L as f, a as i } from "./contexts/LocalesContext/index.js";
5
- import { R as u, a as l } from "./contexts/ResponsiveContainerContext/index.js";
6
- import { H as v, a as T } from "./contexts/HostThemeContext/index.js";
7
- import { d as h } from "./contexts/ThemeSettingsContext/constants.js";
8
- import { T as R, a as S } from "./contexts/ThemeSettingsContext/ThemeSettingsContext.js";
9
- import { u as F } from "./hooks/useFirstRender/index.js";
10
- import { u as L } from "./hooks/useFormatter/index.js";
11
- import { u as b } from "./hooks/useIsMountedRef/index.js";
12
- import { u as w } from "./hooks/useLocales/index.js";
5
+ import { R as u, a as v } from "./contexts/ResponsiveContainerContext/index.js";
6
+ import { H as l, a as T } from "./contexts/HostThemeContext/index.js";
7
+ import { D as g, a as C } from "./contexts/DeviceTypeContext/index.js";
8
+ import { d as R } from "./contexts/ThemeSettingsContext/constants.js";
9
+ import { T as P, a as F } from "./contexts/ThemeSettingsContext/ThemeSettingsContext.js";
10
+ import { u as D } from "./hooks/useFirstRender/index.js";
11
+ import { u as b } from "./hooks/useFormatter/index.js";
12
+ import { u as k } from "./hooks/useIsMountedRef/index.js";
13
+ import { u as z } from "./hooks/useLocales/index.js";
13
14
  import { u as G } from "./hooks/useResponsiveContainer/index.js";
14
- import { u as M } from "./hooks/useIsMobile/index.js";
15
- import { u as y } from "./hooks/useOffSetTop.js";
16
- import { u as D } from "./hooks/useHostTheme/index.js";
17
- import { u as N } from "./hooks/useResizeObserver/index.js";
18
- import { u as j } from "./hooks/useResponsive/index.js";
19
- import { u as B } from "./hooks/useThemSettingsStore/index.js";
20
- import { c as K } from "./utils/strings.js";
21
- import { g as U } from "./utils/anchorEl.js";
15
+ import { u as M } from "./hooks/useUserAgent/index.js";
16
+ import { u as E } from "./hooks/useIsMobile/index.js";
17
+ import { u as U } from "./hooks/useOffSetTop.js";
18
+ import { u as j } from "./hooks/useHostTheme/index.js";
19
+ import { u as B } from "./hooks/useResizeObserver/index.js";
20
+ import { u as K } from "./hooks/useResponsive/index.js";
21
+ import { u as V } from "./hooks/useThemSettingsStore/index.js";
22
+ import { c as Y } from "./utils/strings.js";
23
+ import { g as _ } from "./utils/anchorEl.js";
22
24
  export {
25
+ g as DeviceTypeContext,
26
+ C as DeviceTypeProvider,
23
27
  m as FormatterContext,
24
28
  p as FormatterProvider,
25
29
  r as GlobalStyles,
26
- v as HostThemeContext,
30
+ l as HostThemeContext,
27
31
  T as HostThemeProvider,
28
32
  f as LocalesContext,
29
33
  i as LocalesProvider,
30
34
  u as ResponsiveContainerContext,
31
- l as ResponsiveContainerProvider,
32
- R as ThemeSettingsContext,
33
- S as ThemeSettingsProvider,
34
- K as capitalize,
35
- h as defaultThemeSettings,
36
- U as getAnchorElPositionWindow,
35
+ v as ResponsiveContainerProvider,
36
+ P as ThemeSettingsContext,
37
+ F as ThemeSettingsProvider,
38
+ Y as capitalize,
39
+ R as defaultThemeSettings,
40
+ _ as getAnchorElPositionWindow,
37
41
  s as getLocaleFromNetwork,
38
- F as useFirstRender,
39
- L as useFormatter,
40
- D as useHostTheme,
41
- M as useIsMobile,
42
- b as useIsMountedRef,
43
- w as useLocales,
44
- y as useOffSetTop,
45
- N as useResizeObserver,
42
+ D as useFirstRender,
43
+ b as useFormatter,
44
+ j as useHostTheme,
45
+ E as useIsMobile,
46
+ k as useIsMountedRef,
47
+ z as useLocales,
48
+ U as useOffSetTop,
49
+ B as useResizeObserver,
46
50
  G as useResponsiveContainerStore,
47
- j as useResponsiveDesktop,
48
- B as useThemeSettingsStore
51
+ K as useResponsiveDesktop,
52
+ V as useThemeSettingsStore,
53
+ M as useUserAgent
49
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/graphics",
3
- "version": "7.0.7",
3
+ "version": "7.0.8",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team*",
6
6
  "type": "module",
@@ -17,7 +17,7 @@
17
17
  "zustand": "4.3.6"
18
18
  },
19
19
  "peerDependencies": {
20
- "@m4l/core": "^2.0.12",
20
+ "@m4l/core": "^2.0.15",
21
21
  "@m4l/styles": "^7.1.18",
22
22
  "@mui/material": "5.16.7",
23
23
  "@mui/x-date-pickers": "6.20.2",