@m4l/graphics 7.0.11-beta.1 → 7.0.12

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.
@@ -10,10 +10,6 @@ declare const DeviceTypeContext: import('react').Context<(Omit<Omit<import('zust
10
10
  }) | null>;
11
11
  /**
12
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
13
  */
18
14
  declare const DeviceTypeProvider: (props: DeviceTypePrivderProps) => import("react").JSX.Element;
19
15
  export { DeviceTypeProvider, DeviceTypeContext };
@@ -1,17 +1,18 @@
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(() => {
1
+ import { jsx as p } from "react/jsx-runtime";
2
+ import { createContext as a, useRef as u, useEffect as v } from "react";
3
+ import { c as f } from "./store.js";
4
+ import { g as m } from "./helper.js";
5
+ import { u as d } from "../../hooks/useUserAgent/index.js";
6
+ const y = a(null), S = (r) => {
7
+ const { children: o, forcedDeviceType: c, storeId: s, storeDevtoolsEnabled: i } = r, n = d(), e = u(), t = c ?? m(n);
8
+ return e.current || (e.current = f({
9
+ deviceType: t,
10
+ storeId: s
11
+ }, i)), v(() => {
11
12
  e.current?.getState().deviceType !== t && e.current?.getState().actions.setDeviceType(t);
12
- }, [t]), /* @__PURE__ */ n(m.Provider, { value: e.current, children: c });
13
+ }, [t]), /* @__PURE__ */ p(y.Provider, { value: e.current, children: o });
13
14
  };
14
15
  export {
15
- m as D,
16
- l as a
16
+ y as D,
17
+ S as a
17
18
  };
@@ -6,7 +6,7 @@ import { InitialDeviceTypeProps, DeviceTypeWithActions } from './types';
6
6
  * @updatedAt 2024-10-06 20:07:18 - automatic
7
7
  * @updatedUser Juan Escobar - automatic
8
8
  */
9
- export declare const createDeviceTypeStore: (initProps: InitialDeviceTypeProps) => Omit<Omit<import('zustand').StoreApi<DeviceTypeWithActions>, "setState"> & {
9
+ export declare const createDeviceTypeStore: (initProps: InitialDeviceTypeProps, storeDevtoolsEnabled?: boolean) => Omit<Omit<import('zustand').StoreApi<DeviceTypeWithActions>, "setState"> & {
10
10
  setState<A extends string | {
11
11
  type: unknown;
12
12
  }>(partial: DeviceTypeWithActions | Partial<DeviceTypeWithActions> | ((state: DeviceTypeWithActions) => DeviceTypeWithActions | Partial<DeviceTypeWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
@@ -1,14 +1,17 @@
1
- import { createStore as i } from "zustand";
2
- import { devtools as m } from "zustand/middleware";
1
+ import { createStore as a } from "zustand";
2
+ import { devtools as n } from "zustand/middleware";
3
3
  import { immer as p } from "zustand/middleware/immer";
4
- const y = (e) => {
5
- const t = {
4
+ const m = (e, t) => {
5
+ const { enabled: o = !1 } = t;
6
+ return o && process.env.NODE_ENV === "development" ? n(e, t) : e;
7
+ }, D = (e, t = !1) => {
8
+ const o = {
6
9
  ...e
7
10
  };
8
- return i(
11
+ return a(
9
12
  m(
10
- p((r, s) => ({
11
- ...t,
13
+ p((r, v) => ({
14
+ ...o,
12
15
  actions: {
13
16
  /**
14
17
  * Establece el punto de interrupción
@@ -17,17 +20,17 @@ const y = (e) => {
17
20
  * @updatedAt 2024-10-06 20:07:18 - automatic
18
21
  * @updatedUser Juan Escobar - automatic
19
22
  */
20
- setDeviceType: (o) => {
23
+ setDeviceType: (s) => {
21
24
  r((c) => {
22
- c.deviceType = o;
25
+ c.deviceType = s;
23
26
  });
24
27
  }
25
28
  }
26
29
  })),
27
- { name: "DeviceType Store" }
30
+ { name: `DeviceTypeStore: ${e.storeId}`, enabled: t }
28
31
  )
29
32
  );
30
33
  };
31
34
  export {
32
- y as c
35
+ D as c
33
36
  };
@@ -1,11 +1,32 @@
1
1
  import { default as React } from 'react';
2
2
  export type DeviceType = 'mobile' | 'desktop';
3
3
  export interface DeviceTypeState {
4
+ /**
5
+ * "storeId" Id del store
6
+ */
7
+ storeId?: string;
8
+ /**
9
+ * "deviceType" Tipo de dispositivo detectado
10
+ */
4
11
  deviceType: DeviceType;
5
12
  }
6
- export type InitialDeviceTypeProps = Pick<DeviceTypeState, 'deviceType'>;
13
+ export type InitialDeviceTypeProps = Pick<DeviceTypeState, 'deviceType' | 'storeId'>;
7
14
  export interface DeviceTypePrivderProps {
15
+ /**
16
+ * "storeId" Id del store
17
+ */
18
+ storeId?: string;
19
+ /**
20
+ * "storeDevtoolsEnabled" Determina si se debe usar devtools para el store
21
+ */
22
+ storeDevtoolsEnabled?: boolean;
23
+ /**
24
+ * "forcedDeviceType" Tipo de dispositivo forzado, para no usar el detectado del userAgent
25
+ */
8
26
  forcedDeviceType?: DeviceType;
27
+ /**
28
+ * "children" Componentes hijos
29
+ */
9
30
  children: React.ReactNode;
10
31
  }
11
32
  export interface DeviceTypeWithActions extends DeviceTypeState {
@@ -10,10 +10,7 @@ declare const ResponsiveContainerContext: import('react').Context<(Omit<Omit<imp
10
10
  }) | null>;
11
11
  /**
12
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
13
+ * @deprecated usar useIsMobile
17
14
  */
18
15
  declare const ResponsiveContainerProvider: (props: ResponsiveContainerProviderProps) => import("react").JSX.Element;
19
16
  export { ResponsiveContainerProvider, ResponsiveContainerContext };
@@ -1,7 +1,7 @@
1
1
  import { createStore as S } from "zustand";
2
2
  import { devtools as c } from "zustand/middleware";
3
3
  import { immer as p } from "zustand/middleware/immer";
4
- import { getPaletteByPreset as a, createCustomShadows as d, shadows as h, typographyOld as u, getColorPresets as f } from "@m4l/styles";
4
+ import { getPaletteByPreset as a, typographyOld as d, shadows as h, getColorPresets as u, createCustomShadows as f } from "@m4l/styles";
5
5
  import { alpha as U } from "@mui/system";
6
6
  import { d as s } from "./constants.js";
7
7
  function g(r, o = "m4l") {
@@ -18,7 +18,7 @@ const n = (r) => {
18
18
  const o = r.themeUserSettings || s, m = o.themeMode === "light", t = a(o.themeColor), e = m ? t.light : t.dark;
19
19
  r.themeOptions = {
20
20
  ...r.themeOptions,
21
- ...u,
21
+ ...d,
22
22
  palette: {
23
23
  ...r.themeOptions?.palette ?? {},
24
24
  ...e
@@ -28,10 +28,10 @@ const n = (r) => {
28
28
  shadows: m ? h.light : h.dark,
29
29
  customShadows: {
30
30
  primary: `0 8px 16px 0 ${U(
31
- f(o.themeColor)?.main || "#fff",
31
+ u(o.themeColor)?.main || "#fff",
32
32
  0.2
33
33
  )}`,
34
- ...d(o.themeMode)
34
+ ...f(o.themeMode)
35
35
  },
36
36
  stretch: o.themeStretch
37
37
  }, g(r.themeOptions);
@@ -1,7 +1,7 @@
1
- import { useState as n, useRef as H, useCallback as L, useEffect as m } from "react";
1
+ import { useState as n, useRef as H, useCallback as U, useEffect as m } from "react";
2
2
  import { i as s } from "./types.js";
3
- import { useHostTools as U, useNetwork as j } from "@m4l/core";
4
- const J = (h) => {
3
+ import { useHostTools as j, useNetwork as v } from "@m4l/core";
4
+ const K = (h) => {
5
5
  const {
6
6
  endPoint: w,
7
7
  timeout: C = 5e3,
@@ -16,15 +16,16 @@ const J = (h) => {
16
16
  isRemote: k = !0,
17
17
  bodyToSnakeCase: y = !1,
18
18
  responseToCamelCase: T = !1,
19
- initialRows: E = [],
19
+ initialRows: b = [],
20
20
  externalCondition: c = !0,
21
- onNetworkError: f
22
- } = h, [p, g] = n(i ? 1 : 0), [O, a] = n(E), [b, o] = n({ ...s, rowsPerPage: u }), t = H({ ...s, rowsPerPage: u }), [x, F] = n(R), { startProgress: N, stopProgress: Q } = U(), { networkOperation: q } = j(), l = L(() => {
21
+ onNetworkError: f,
22
+ getLabel: E
23
+ } = h, [p, g] = n(i ? 1 : 0), [O, a] = n(b), [x, o] = n({ ...s, rowsPerPage: u }), t = H({ ...s, rowsPerPage: u }), [F, L] = n(R), { startProgress: N, stopProgress: Q } = j(), { networkOperation: q } = v(), l = U(() => {
23
24
  g((r) => r + 1);
24
25
  }, []);
25
26
  return m(() => {
26
- if (x) {
27
- F(!1);
27
+ if (F) {
28
+ L(!1);
28
29
  return;
29
30
  }
30
31
  t.current.page = 0, i && l();
@@ -59,14 +60,14 @@ const J = (h) => {
59
60
  }), function() {
60
61
  r = !1;
61
62
  };
62
- }, [p, c]), { onPageChange: (r) => {
63
+ }, [p, c, E]), { onPageChange: (r) => {
63
64
  t.current.page = r, g((e) => e + 1);
64
65
  }, onRowsPerPageChange: (r) => {
65
66
  t.current.rowsPerPage = r, o((e) => ({ ...e, rowsPerPage: r })), g((e) => e + 1);
66
- }, pagerState: b, rows: O, clearRows: () => {
67
+ }, pagerState: x, rows: O, clearRows: () => {
67
68
  a([]), o(s);
68
69
  }, Refresh: l, setRows: a };
69
70
  };
70
71
  export {
71
- J as u
72
+ K as u
72
73
  };
@@ -1 +1,35 @@
1
- export {};
1
+ import { ReactNode } from 'react';
2
+ import { HostToolsType } from '@m4l/core';
3
+ import { Id, ToastOptions } from 'react-toastify';
4
+ export declare const mock_addFlag: import('vitest').Mock<(...args: any[]) => any>;
5
+ export declare const mock_networkOperation: import('vitest').Mock<(...args: any[]) => any>;
6
+ export declare const mock_events_add_listener: import('vitest').Mock<(...args: any[]) => any>;
7
+ export declare const mock_events_remove_listener: import('vitest').Mock<(...args: any[]) => any>;
8
+ export declare const mock_events_emit: import('vitest').Mock<(...args: any[]) => any>;
9
+ export declare const mock_startProgress: import('vitest').Mock<(...args: any[]) => any>;
10
+ export declare const mock_stopProgress: import('vitest').Mock<(...args: any[]) => any>;
11
+ export interface ToasterFunctionProps {
12
+ title: ReactNode;
13
+ description?: ReactNode;
14
+ }
15
+ export type Toaster = {
16
+ (props: ToasterFunctionProps, toastOptions?: ToastOptions): Id;
17
+ success(props: ToasterFunctionProps, toastOptions?: ToastOptions): Id;
18
+ info(props: ToasterFunctionProps, toastOptions?: ToastOptions): Id;
19
+ warning(props: ToasterFunctionProps, toastOptions?: ToastOptions): Id;
20
+ error(props: ToasterFunctionProps, toastOptions?: ToastOptions): Id;
21
+ };
22
+ export declare const mock_toaster: Toaster;
23
+ export declare const environmentDataForTesting: {
24
+ isLocalhost: boolean;
25
+ host: string;
26
+ domain_token: string;
27
+ host_api_local: string;
28
+ host_api_remote: string;
29
+ host_static_assets: string;
30
+ environment_assets: string;
31
+ isMicroFrontend: boolean;
32
+ isIsolatation: boolean;
33
+ database: string;
34
+ };
35
+ export declare const hostToolsDataForTesting: HostToolsType;
@@ -1,4 +1,4 @@
1
- import { AxiosOptions, NetworkProps } from '@m4l/core';
1
+ import { AxiosOptions, GetLabelType, NetworkProps } from '@m4l/core';
2
2
  export declare interface PagerState {
3
3
  page: number;
4
4
  rowsPerPage: number;
@@ -13,4 +13,5 @@ export interface UsePaginateProps<TRow> extends Pick<NetworkProps, 'endPoint' |
13
13
  initialRows?: TRow[];
14
14
  externalCondition?: boolean;
15
15
  onNetworkError?: (code: number) => void;
16
+ getLabel?: GetLabelType;
16
17
  }
@@ -1,8 +1,5 @@
1
1
  /**
2
2
  * Returns true if the screen size is desktop.
3
- * @author Juan Escobar - automatic
4
- * @createdAt 2024-10-06 20:07:18 - automatic
5
- * @updatedAt 2024-10-06 20:07:18 - automatic
6
- * @updatedUser Juan Escobar - automatic
3
+ * @deprecated usar useIsMobile
7
4
  */
8
5
  export declare function useResponsiveDesktop(): boolean | undefined;
@@ -1,9 +1,6 @@
1
1
  import { ResponsiveContainerStateWithActions } from '../../contexts/ResponsiveContainerContext/types';
2
2
  /**
3
3
  * Hook to use the responsive container store
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
4
+ * @deprecated usa use
8
5
  */
9
6
  export declare function useResponsiveContainerStore<T>(selector: (state: ResponsiveContainerStateWithActions) => T, equalityFn?: (left: T, right: T) => boolean): T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/graphics",
3
- "version": "7.0.11-beta.1",
3
+ "version": "7.0.12",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team*",
6
6
  "type": "module",
@@ -17,8 +17,8 @@
17
17
  "zustand": "4.3.6"
18
18
  },
19
19
  "peerDependencies": {
20
- "@m4l/core": "2.0.20-beta.1",
21
- "@m4l/styles": "^7.1.18",
20
+ "@m4l/core": "^2.0.0",
21
+ "@m4l/styles": "^7.0.0",
22
22
  "@mui/material": "5.16.7",
23
23
  "@mui/x-date-pickers": "6.20.2",
24
24
  "@types/react": "^18.0.0",
File without changes
@@ -0,0 +1,9 @@
1
+ import { cleanup, screen } from '@testing-library/react';
2
+ import { renderHook } from '@testing-library/react-hooks';
3
+ import { default as React, act } from 'react';
4
+ /**
5
+ * customRender
6
+ */
7
+ declare const customRender: (ui: React.ReactElement, options?: {}) => import('@testing-library/react').RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
8
+ export { default as userEvent } from '@testing-library/user-event';
9
+ export { customRender as render, renderHook, screen, cleanup, act };