@m4l/graphics 7.0.10 → 7.0.11-beta.1
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/ThemeSettingsContext/store.js +4 -4
- package/hooks/index.d.ts +1 -0
- package/hooks/usePaginate/index.d.ts +13 -0
- package/hooks/usePaginate/index.js +72 -0
- package/hooks/usePaginate/index.test.d.ts +1 -0
- package/hooks/usePaginate/types.d.ts +16 -0
- package/hooks/usePaginate/types.js +8 -0
- package/index.js +14 -12
- package/package.json +2 -2
|
@@ -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,
|
|
4
|
+
import { getPaletteByPreset as a, createCustomShadows as d, shadows as h, typographyOld as u, getColorPresets 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
|
-
...
|
|
21
|
+
...u,
|
|
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
|
-
|
|
31
|
+
f(o.themeColor)?.main || "#fff",
|
|
32
32
|
0.2
|
|
33
33
|
)}`,
|
|
34
|
-
...
|
|
34
|
+
...d(o.themeMode)
|
|
35
35
|
},
|
|
36
36
|
stretch: o.themeStretch
|
|
37
37
|
}, g(r.themeOptions);
|
package/hooks/index.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export { useHostTheme } from './useHostTheme';
|
|
|
10
10
|
export { useResizeObserver } from './useResizeObserver';
|
|
11
11
|
export { useResponsiveDesktop } from './useResponsive';
|
|
12
12
|
export { useThemeSettingsStore } from './useThemSettingsStore';
|
|
13
|
+
export { usePaginate } from './usePaginate';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UsePaginateProps, PagerState } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook para paginar una lista de elementos
|
|
4
|
+
*/
|
|
5
|
+
export declare const usePaginate: <TRow>(props: UsePaginateProps<TRow>) => {
|
|
6
|
+
onPageChange: (newPage: number) => void;
|
|
7
|
+
onRowsPerPageChange: (newRowsPerPage: number) => void;
|
|
8
|
+
pagerState: PagerState;
|
|
9
|
+
rows: TRow[];
|
|
10
|
+
clearRows: () => void;
|
|
11
|
+
Refresh: () => void;
|
|
12
|
+
setRows: import('react').Dispatch<import('react').SetStateAction<TRow[]>>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useState as n, useRef as H, useCallback as L, useEffect as m } from "react";
|
|
2
|
+
import { i as s } from "./types.js";
|
|
3
|
+
import { useHostTools as U, useNetwork as j } from "@m4l/core";
|
|
4
|
+
const J = (h) => {
|
|
5
|
+
const {
|
|
6
|
+
endPoint: w,
|
|
7
|
+
timeout: C = 5e3,
|
|
8
|
+
queryParams: P,
|
|
9
|
+
fireOnChangeParms: i,
|
|
10
|
+
// Propiedad para permitir que un cambio en los parametros de la consulta dispare la recarga de la red
|
|
11
|
+
fireOnFirstLoad: R = !0,
|
|
12
|
+
// propiedad que evita que se cargue la red la en el primer render del hook
|
|
13
|
+
rowsPerPage: u = s.rowsPerPage,
|
|
14
|
+
startProgress: d,
|
|
15
|
+
stopProgress: S,
|
|
16
|
+
isRemote: k = !0,
|
|
17
|
+
bodyToSnakeCase: y = !1,
|
|
18
|
+
responseToCamelCase: T = !1,
|
|
19
|
+
initialRows: E = [],
|
|
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(() => {
|
|
23
|
+
g((r) => r + 1);
|
|
24
|
+
}, []);
|
|
25
|
+
return m(() => {
|
|
26
|
+
if (x) {
|
|
27
|
+
F(!1);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
t.current.page = 0, i && l();
|
|
31
|
+
}, [P]), m(() => {
|
|
32
|
+
let r = !0;
|
|
33
|
+
if (!(!c || p === 0))
|
|
34
|
+
return q({
|
|
35
|
+
method: "GET",
|
|
36
|
+
endPoint: w,
|
|
37
|
+
timeout: C,
|
|
38
|
+
parms: {
|
|
39
|
+
...P,
|
|
40
|
+
page: t.current.page,
|
|
41
|
+
limit: t.current.rowsPerPage
|
|
42
|
+
},
|
|
43
|
+
bodyToSnakeCase: y,
|
|
44
|
+
responseToCamelCase: T,
|
|
45
|
+
options: {
|
|
46
|
+
startProgress: d || N,
|
|
47
|
+
stopProgress: S || Q
|
|
48
|
+
},
|
|
49
|
+
isRemote: k
|
|
50
|
+
}).then((e) => {
|
|
51
|
+
r && (a(e.data), t.current.page = e.pager.page, o((G) => ({
|
|
52
|
+
...G,
|
|
53
|
+
page: e.pager.page,
|
|
54
|
+
// rowsPerPage: response.pager.limit,
|
|
55
|
+
totalRecords: e.pager.total
|
|
56
|
+
})));
|
|
57
|
+
}).catch((e) => {
|
|
58
|
+
a([]), o(s), f && f(e.status);
|
|
59
|
+
}), function() {
|
|
60
|
+
r = !1;
|
|
61
|
+
};
|
|
62
|
+
}, [p, c]), { onPageChange: (r) => {
|
|
63
|
+
t.current.page = r, g((e) => e + 1);
|
|
64
|
+
}, onRowsPerPageChange: (r) => {
|
|
65
|
+
t.current.rowsPerPage = r, o((e) => ({ ...e, rowsPerPage: r })), g((e) => e + 1);
|
|
66
|
+
}, pagerState: b, rows: O, clearRows: () => {
|
|
67
|
+
a([]), o(s);
|
|
68
|
+
}, Refresh: l, setRows: a };
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
J as u
|
|
72
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AxiosOptions, NetworkProps } from '@m4l/core';
|
|
2
|
+
export declare interface PagerState {
|
|
3
|
+
page: number;
|
|
4
|
+
rowsPerPage: number;
|
|
5
|
+
totalRecords: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const initialPagerState: PagerState;
|
|
8
|
+
export interface UsePaginateProps<TRow> extends Pick<NetworkProps, 'endPoint' | 'timeout' | 'isRemote' | 'bodyToSnakeCase' | 'responseToCamelCase'>, AxiosOptions {
|
|
9
|
+
fireOnChangeParms?: boolean;
|
|
10
|
+
fireOnFirstLoad?: boolean;
|
|
11
|
+
queryParams: Record<string, unknown>;
|
|
12
|
+
rowsPerPage?: number;
|
|
13
|
+
initialRows?: TRow[];
|
|
14
|
+
externalCondition?: boolean;
|
|
15
|
+
onNetworkError?: (code: number) => void;
|
|
16
|
+
}
|
package/index.js
CHANGED
|
@@ -2,11 +2,11 @@ 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
|
|
5
|
+
import { R as n, a as v } from "./contexts/ResponsiveContainerContext/index.js";
|
|
6
6
|
import { H as l, a as T } from "./contexts/HostThemeContext/index.js";
|
|
7
|
-
import { D as
|
|
8
|
-
import { d as
|
|
9
|
-
import { T as
|
|
7
|
+
import { D as c, a as C } from "./contexts/DeviceTypeContext/index.js";
|
|
8
|
+
import { d as P } from "./contexts/ThemeSettingsContext/constants.js";
|
|
9
|
+
import { T as S, a as F } from "./contexts/ThemeSettingsContext/ThemeSettingsContext.js";
|
|
10
10
|
import { u as D } from "./hooks/useFirstRender/index.js";
|
|
11
11
|
import { u as b } from "./hooks/useFormatter/index.js";
|
|
12
12
|
import { u as k } from "./hooks/useIsMountedRef/index.js";
|
|
@@ -19,10 +19,11 @@ import { u as j } from "./hooks/useHostTheme/index.js";
|
|
|
19
19
|
import { u as B } from "./hooks/useResizeObserver/index.js";
|
|
20
20
|
import { u as K } from "./hooks/useResponsive/index.js";
|
|
21
21
|
import { u as V } from "./hooks/useThemSettingsStore/index.js";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
22
|
+
import { u as Y } from "./hooks/usePaginate/index.js";
|
|
23
|
+
import { c as _ } from "./utils/strings.js";
|
|
24
|
+
import { g as ee } from "./utils/anchorEl.js";
|
|
24
25
|
export {
|
|
25
|
-
|
|
26
|
+
c as DeviceTypeContext,
|
|
26
27
|
C as DeviceTypeProvider,
|
|
27
28
|
m as FormatterContext,
|
|
28
29
|
p as FormatterProvider,
|
|
@@ -31,13 +32,13 @@ export {
|
|
|
31
32
|
T as HostThemeProvider,
|
|
32
33
|
f as LocalesContext,
|
|
33
34
|
i as LocalesProvider,
|
|
34
|
-
|
|
35
|
+
n as ResponsiveContainerContext,
|
|
35
36
|
v as ResponsiveContainerProvider,
|
|
36
|
-
|
|
37
|
+
S as ThemeSettingsContext,
|
|
37
38
|
F as ThemeSettingsProvider,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
_ as capitalize,
|
|
40
|
+
P as defaultThemeSettings,
|
|
41
|
+
ee as getAnchorElPositionWindow,
|
|
41
42
|
s as getLocaleFromNetwork,
|
|
42
43
|
D as useFirstRender,
|
|
43
44
|
b as useFormatter,
|
|
@@ -46,6 +47,7 @@ export {
|
|
|
46
47
|
k as useIsMountedRef,
|
|
47
48
|
z as useLocales,
|
|
48
49
|
U as useOffSetTop,
|
|
50
|
+
Y as usePaginate,
|
|
49
51
|
B as useResizeObserver,
|
|
50
52
|
G as useResponsiveContainerStore,
|
|
51
53
|
K as useResponsiveDesktop,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/graphics",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.11-beta.1",
|
|
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": "
|
|
20
|
+
"@m4l/core": "2.0.20-beta.1",
|
|
21
21
|
"@m4l/styles": "^7.1.18",
|
|
22
22
|
"@mui/material": "5.16.7",
|
|
23
23
|
"@mui/x-date-pickers": "6.20.2",
|