@m4l/core 2.0.1 → 2.0.3
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 { useState as n, useRef as H, useCallback as L, useEffect as m } from "react";
|
|
2
|
+
import { u as U } from "../useHostTools/index-CL3d7qFm.js";
|
|
3
|
+
import { u as j } from "../useNetwork/index--IzMsMJ2.js";
|
|
4
|
+
const s = {
|
|
5
|
+
page: 0,
|
|
6
|
+
rowsPerPage: 25,
|
|
7
|
+
totalRecords: 0
|
|
8
|
+
}, J = (w) => {
|
|
9
|
+
const {
|
|
10
|
+
endPoint: h,
|
|
11
|
+
timeout: R = 5e3,
|
|
12
|
+
queryParams: P,
|
|
13
|
+
fireOnChangeParms: i,
|
|
14
|
+
// Propiedad para permitir que un cambio en los parametros de la consulta dispare la recarga de la red
|
|
15
|
+
fireOnFirstLoad: C = !0,
|
|
16
|
+
// propiedad que evita que se cargue la red la en el primer render del hook
|
|
17
|
+
rowsPerPage: c = s.rowsPerPage,
|
|
18
|
+
startProgress: d,
|
|
19
|
+
stopProgress: S,
|
|
20
|
+
isRemote: k = !0,
|
|
21
|
+
bodyToSnakeCase: y = !1,
|
|
22
|
+
responseToCamelCase: T = !1,
|
|
23
|
+
initialRows: E = [],
|
|
24
|
+
externalCondition: u = !0,
|
|
25
|
+
onNetworkError: f
|
|
26
|
+
} = w, [p, g] = n(i ? 1 : 0), [O, o] = n(E), [b, a] = n({ ...s, rowsPerPage: c }), t = H({ ...s, rowsPerPage: c }), [x, F] = n(C), { startProgress: N, stopProgress: Q } = U(), { networkOperation: q } = j(), l = L(() => {
|
|
27
|
+
g((r) => r + 1);
|
|
28
|
+
}, []);
|
|
29
|
+
return m(() => {
|
|
30
|
+
if (x) {
|
|
31
|
+
F(!1);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
i && l();
|
|
35
|
+
}, [P]), m(() => {
|
|
36
|
+
let r = !0;
|
|
37
|
+
if (!(!u || p === 0))
|
|
38
|
+
return q({
|
|
39
|
+
method: "GET",
|
|
40
|
+
endPoint: h,
|
|
41
|
+
timeout: R,
|
|
42
|
+
parms: {
|
|
43
|
+
...P,
|
|
44
|
+
page: t.current.page,
|
|
45
|
+
limit: t.current.rowsPerPage
|
|
46
|
+
},
|
|
47
|
+
bodyToSnakeCase: y,
|
|
48
|
+
responseToCamelCase: T,
|
|
49
|
+
options: {
|
|
50
|
+
startProgress: d || N,
|
|
51
|
+
stopProgress: S || Q
|
|
52
|
+
},
|
|
53
|
+
isRemote: k
|
|
54
|
+
}).then((e) => {
|
|
55
|
+
r && (o(e.data), t.current.page = e.pager.page, a((G) => ({
|
|
56
|
+
...G,
|
|
57
|
+
page: e.pager.page,
|
|
58
|
+
// rowsPerPage: response.pager.limit,
|
|
59
|
+
totalRecords: e.pager.total
|
|
60
|
+
})));
|
|
61
|
+
}).catch(() => {
|
|
62
|
+
o([]), a(s), f && f();
|
|
63
|
+
}), function() {
|
|
64
|
+
r = !1;
|
|
65
|
+
};
|
|
66
|
+
}, [p, u]), { onPageChange: (r) => {
|
|
67
|
+
t.current.page = r, g((e) => e + 1);
|
|
68
|
+
}, onRowsPerPageChange: (r) => {
|
|
69
|
+
t.current.rowsPerPage = r, a((e) => ({ ...e, rowsPerPage: r })), g((e) => e + 1);
|
|
70
|
+
}, pagerState: b, rows: O, clearRows: () => {
|
|
71
|
+
o([]), a(s);
|
|
72
|
+
}, Refresh: l, setRows: o };
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
s as i,
|
|
76
|
+
J as u
|
|
77
|
+
};
|
package/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import { u as $ } from "./hooks/useModuleDictionary/index-C1BKVxpe.js";
|
|
|
20
20
|
import { u as eo } from "./hooks/useModulePrivileges/index-D14YH0TD.js";
|
|
21
21
|
import { u as ao } from "./hooks/useModuleSkeleton/index-CBPHGKDR.js";
|
|
22
22
|
import { u as so } from "./hooks/useNetwork/index--IzMsMJ2.js";
|
|
23
|
-
import { i as no, u as uo } from "./hooks/usePaginate/index-
|
|
23
|
+
import { i as no, u as uo } from "./hooks/usePaginate/index-DOOXkJPW.js";
|
|
24
24
|
import { u as mo } from "./hooks/usePropageteMF/index-DEVKsg4w.js";
|
|
25
25
|
import { u as lo } from "./hooks/useAuth/index-BmbX0ftD.js";
|
|
26
26
|
import { e as vo, g as go, a as Po, s as Co, v as Mo } from "./utils/index-BNOjc4WT.js";
|
package/package.json
CHANGED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { useState as s, useRef as G, useCallback as H, useEffect as p } from "react";
|
|
2
|
-
import { u as L } from "../useHostTools/index-CL3d7qFm.js";
|
|
3
|
-
import { u as N } from "../useNetwork/index--IzMsMJ2.js";
|
|
4
|
-
const a = {
|
|
5
|
-
page: 0,
|
|
6
|
-
rowsPerPage: 25,
|
|
7
|
-
totalRecords: 0
|
|
8
|
-
}, D = (l) => {
|
|
9
|
-
const {
|
|
10
|
-
endPoint: m,
|
|
11
|
-
timeout: w = 5e3,
|
|
12
|
-
queryParams: P,
|
|
13
|
-
fireOnChangeParms: i,
|
|
14
|
-
fireOnFirstLoad: h = !0,
|
|
15
|
-
rowsPerPage: u = a.rowsPerPage,
|
|
16
|
-
startProgress: R,
|
|
17
|
-
stopProgress: C,
|
|
18
|
-
isRemote: d = !0,
|
|
19
|
-
bodyToSnakeCase: S = !1,
|
|
20
|
-
responseToCamelCase: k = !1,
|
|
21
|
-
initialRows: y = []
|
|
22
|
-
} = l, [c, o] = s(i ? 1 : 0), [T, n] = s(y), [O, g] = s({ ...a, rowsPerPage: u }), t = G({ ...a, rowsPerPage: u }), [b, E] = s(h), { startProgress: F, stopProgress: Q } = L(), { networkOperation: q } = N(), f = H(() => {
|
|
23
|
-
o((r) => r + 1);
|
|
24
|
-
}, []);
|
|
25
|
-
return p(() => {
|
|
26
|
-
if (b) {
|
|
27
|
-
E(!1);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
i && f();
|
|
31
|
-
}, [P]), p(() => {
|
|
32
|
-
let r = !0;
|
|
33
|
-
if (c !== 0)
|
|
34
|
-
return q({
|
|
35
|
-
method: "GET",
|
|
36
|
-
endPoint: m,
|
|
37
|
-
timeout: w,
|
|
38
|
-
parms: {
|
|
39
|
-
...P,
|
|
40
|
-
page: t.current.page,
|
|
41
|
-
limit: t.current.rowsPerPage
|
|
42
|
-
},
|
|
43
|
-
bodyToSnakeCase: S,
|
|
44
|
-
responseToCamelCase: k,
|
|
45
|
-
options: {
|
|
46
|
-
startProgress: R || F,
|
|
47
|
-
stopProgress: C || Q
|
|
48
|
-
},
|
|
49
|
-
isRemote: d
|
|
50
|
-
}).then((e) => {
|
|
51
|
-
r && (n(e.data), t.current.page = e.pager.page, g((x) => ({
|
|
52
|
-
...x,
|
|
53
|
-
page: e.pager.page,
|
|
54
|
-
// rowsPerPage: response.pager.limit,
|
|
55
|
-
totalRecords: e.pager.total
|
|
56
|
-
})));
|
|
57
|
-
}), function() {
|
|
58
|
-
r = !1;
|
|
59
|
-
};
|
|
60
|
-
}, [c]), { onPageChange: (r) => {
|
|
61
|
-
t.current.page = r, o((e) => e + 1);
|
|
62
|
-
}, onRowsPerPageChange: (r) => {
|
|
63
|
-
t.current.rowsPerPage = r, g((e) => ({ ...e, rowsPerPage: r })), o((e) => e + 1);
|
|
64
|
-
}, pagerState: O, rows: T, clearRows: () => {
|
|
65
|
-
n([]), g(a);
|
|
66
|
-
}, Refresh: f, setRows: n };
|
|
67
|
-
};
|
|
68
|
-
export {
|
|
69
|
-
a as i,
|
|
70
|
-
D as u
|
|
71
|
-
};
|