@chimera-pe/mui-saas 3.0.17 → 3.0.18
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/dist/mui-saas.js +215 -236
- package/dist/mui-saas.umd.cjs +1 -1
- package/package.json +15 -15
package/dist/mui-saas.js
CHANGED
|
@@ -1,243 +1,222 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { useTranslate as
|
|
9
|
-
import { get as
|
|
10
|
-
import { useQuery as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
main: e.color.warning
|
|
48
|
-
},
|
|
49
|
-
info: {
|
|
50
|
-
main: e.color.info
|
|
51
|
-
},
|
|
52
|
-
success: {
|
|
53
|
-
main: e.color.success
|
|
54
|
-
},
|
|
55
|
-
...t === "light" && {
|
|
56
|
-
background: {
|
|
57
|
-
default: j.A200,
|
|
58
|
-
paper: j[100]
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
shape: {
|
|
63
|
-
borderRadius: 6
|
|
64
|
-
}
|
|
65
|
-
}), [t, e]);
|
|
66
|
-
return /* @__PURE__ */ u(V, { theme: c, children: [
|
|
67
|
-
/* @__PURE__ */ n(W, {}),
|
|
68
|
-
a
|
|
69
|
-
] });
|
|
1
|
+
import e from "prop-types";
|
|
2
|
+
import { SaasApp as t, useSaasStore as n } from "@chimera-pe/react-saas";
|
|
3
|
+
import { Children as r, cloneElement as i, useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
|
|
4
|
+
import { Alert as l, AlertTitle as u, Box as d, Card as f, CardActions as p, CardContent as m, CardHeader as h, CircularProgress as g, CssBaseline as _, LinearProgress as v, List as y, ListItem as b, ListItemText as x, Skeleton as S, Snackbar as C, TablePagination as w, ThemeProvider as T, Typography as E, createTheme as D, useMediaQuery as O } from "@mui/material";
|
|
5
|
+
import { grey as k } from "@mui/material/colors";
|
|
6
|
+
import { create as A } from "zustand";
|
|
7
|
+
import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
|
|
8
|
+
import { useTranslate as P } from "react-polyglot";
|
|
9
|
+
import { get as F } from "lodash";
|
|
10
|
+
import { useQuery as I } from "@tanstack/react-query";
|
|
11
|
+
//#region src/store/useMuiStore.jsx
|
|
12
|
+
var L = A((e) => ({
|
|
13
|
+
tema: "light",
|
|
14
|
+
notificaciones: [],
|
|
15
|
+
cambiarTema: (t) => {
|
|
16
|
+
e({ tema: t });
|
|
17
|
+
},
|
|
18
|
+
mostrarNotificacion: (t) => {
|
|
19
|
+
e((e) => ({ notificaciones: [t, ...e.notificaciones] }));
|
|
20
|
+
},
|
|
21
|
+
ocultarNotificacion: () => {
|
|
22
|
+
e((e) => ({ notificaciones: e.notificaciones.slice(1) }));
|
|
23
|
+
}
|
|
24
|
+
})), R = ({ children: e }) => {
|
|
25
|
+
let t = L((e) => e.cambiarTema), r = O("(prefers-color-scheme: dark)"), i = L((e) => e.tema), a = n((e) => e.instancia);
|
|
26
|
+
return o(() => {
|
|
27
|
+
t(r ? "dark" : "light");
|
|
28
|
+
}, [t, r]), /* @__PURE__ */ N(T, {
|
|
29
|
+
theme: s(() => D({
|
|
30
|
+
palette: {
|
|
31
|
+
mode: i,
|
|
32
|
+
primary: { main: a.color.primary },
|
|
33
|
+
secondary: { main: a.color.secondary },
|
|
34
|
+
error: { main: a.color.error },
|
|
35
|
+
warning: { main: a.color.warning },
|
|
36
|
+
info: { main: a.color.info },
|
|
37
|
+
success: { main: a.color.success },
|
|
38
|
+
...i === "light" && { background: {
|
|
39
|
+
default: k.A200,
|
|
40
|
+
paper: k[100]
|
|
41
|
+
} }
|
|
42
|
+
},
|
|
43
|
+
shape: { borderRadius: 6 }
|
|
44
|
+
}), [i, a]),
|
|
45
|
+
children: [/* @__PURE__ */ M(_, {}), e]
|
|
46
|
+
});
|
|
70
47
|
};
|
|
71
|
-
|
|
72
|
-
|
|
48
|
+
R.propTypes = { children: e.element.isRequired };
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/components/Notificacion.jsx
|
|
51
|
+
var z = () => {
|
|
52
|
+
let e = P(), [t, n] = c(!1), r = L((e) => e.ocultarNotificacion), i = L((e) => e.notificaciones[0]);
|
|
53
|
+
return o(() => {
|
|
54
|
+
n(!!i);
|
|
55
|
+
}, [i]), /* @__PURE__ */ M(C, {
|
|
56
|
+
open: t,
|
|
57
|
+
message: i ? i.tipo === "default" && e(i?.mensaje) : null,
|
|
58
|
+
autoHideDuration: 5e3,
|
|
59
|
+
onClose: () => {
|
|
60
|
+
n(!1), r();
|
|
61
|
+
},
|
|
62
|
+
anchorOrigin: i && {
|
|
63
|
+
vertical: i?.posicion.vertical,
|
|
64
|
+
horizontal: i?.posicion.horizontal
|
|
65
|
+
},
|
|
66
|
+
children: i && i?.tipo !== "default" && /* @__PURE__ */ M(l, {
|
|
67
|
+
severity: i.tipo,
|
|
68
|
+
children: e(i.mensaje)
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}, B = ({ aplicacion: e, dev: n = !1, devBackendUrl: r, devAuthUrl: i, mensajes: a = {
|
|
72
|
+
en: {},
|
|
73
|
+
es: {}
|
|
74
|
+
}, children: o }) => /* @__PURE__ */ M(t, {
|
|
75
|
+
aplicacion: e,
|
|
76
|
+
dev: n,
|
|
77
|
+
devBackendUrl: r,
|
|
78
|
+
devAuthUrl: i,
|
|
79
|
+
mensajes: a,
|
|
80
|
+
children: /* @__PURE__ */ M(R, { children: /* @__PURE__ */ N(j, { children: [o, /* @__PURE__ */ M(z, {})] }) })
|
|
81
|
+
});
|
|
82
|
+
B.propTypes = {
|
|
83
|
+
aplicacion: e.string.isRequired,
|
|
84
|
+
dev: e.bool,
|
|
85
|
+
devBackendUrl: e.string,
|
|
86
|
+
devAuthUrl: e.string,
|
|
87
|
+
mensajes: e.object,
|
|
88
|
+
children: e.element.isRequired
|
|
73
89
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
devAuthUrl: t,
|
|
101
|
-
mensajes: e = {
|
|
102
|
-
en: {},
|
|
103
|
-
es: {}
|
|
104
|
-
},
|
|
105
|
-
children: c
|
|
106
|
-
}) => /* @__PURE__ */ n(
|
|
107
|
-
H,
|
|
108
|
-
{
|
|
109
|
-
aplicacion: a,
|
|
110
|
-
dev: r,
|
|
111
|
-
devBackendUrl: o,
|
|
112
|
-
devAuthUrl: t,
|
|
113
|
-
mensajes: e,
|
|
114
|
-
children: /* @__PURE__ */ n(A, { children: /* @__PURE__ */ u(B, { children: [
|
|
115
|
-
c,
|
|
116
|
-
/* @__PURE__ */ n(me, {})
|
|
117
|
-
] }) })
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
ge.propTypes = {
|
|
121
|
-
aplicacion: i.string.isRequired,
|
|
122
|
-
dev: i.bool,
|
|
123
|
-
devBackendUrl: i.string,
|
|
124
|
-
devAuthUrl: i.string,
|
|
125
|
-
mensajes: i.object,
|
|
126
|
-
children: i.element.isRequired
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/components/Cargando.jsx
|
|
92
|
+
var V = () => /* @__PURE__ */ M(d, {
|
|
93
|
+
sx: {
|
|
94
|
+
display: "flex",
|
|
95
|
+
flexDirection: "column",
|
|
96
|
+
flexGrow: 1,
|
|
97
|
+
justifyContent: "center",
|
|
98
|
+
alignItems: "center"
|
|
99
|
+
},
|
|
100
|
+
children: /* @__PURE__ */ M(g, {})
|
|
101
|
+
}), H = ({ titulo: e, texto: t, align: n = "center", severity: r = "error" }) => {
|
|
102
|
+
let i = P();
|
|
103
|
+
return /* @__PURE__ */ M(d, {
|
|
104
|
+
sx: {
|
|
105
|
+
display: "flex",
|
|
106
|
+
flexDirection: "column",
|
|
107
|
+
flexGrow: 1,
|
|
108
|
+
justifyContent: "center",
|
|
109
|
+
alignItems: n
|
|
110
|
+
},
|
|
111
|
+
children: /* @__PURE__ */ N(l, {
|
|
112
|
+
severity: r,
|
|
113
|
+
children: [/* @__PURE__ */ M(u, { children: i(e) }), t && i(t)]
|
|
114
|
+
})
|
|
115
|
+
});
|
|
127
116
|
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
alignItems: "center"
|
|
134
|
-
}, children: /* @__PURE__ */ n(Y, {}) }), N = ({ titulo: a, texto: r, align: o = "center", severity: t = "error" }) => {
|
|
135
|
-
const e = C();
|
|
136
|
-
return /* @__PURE__ */ n(k, { sx: {
|
|
137
|
-
display: "flex",
|
|
138
|
-
flexDirection: "column",
|
|
139
|
-
flexGrow: 1,
|
|
140
|
-
justifyContent: "center",
|
|
141
|
-
alignItems: o
|
|
142
|
-
}, children: /* @__PURE__ */ u(R, { severity: t, children: [
|
|
143
|
-
/* @__PURE__ */ n(Z, { children: e(a) }),
|
|
144
|
-
r && e(r)
|
|
145
|
-
] }) });
|
|
117
|
+
H.propTypes = {
|
|
118
|
+
titulo: e.string.isRequired,
|
|
119
|
+
texto: e.string,
|
|
120
|
+
align: e.string,
|
|
121
|
+
severity: e.string
|
|
146
122
|
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/Util.js
|
|
125
|
+
var U = (e) => (e.match(/(\w+)(\.\w+)+/g) || []).length > 0, W = ({ nombre: e, elevation: t = 1, api: n, filtros: a, titulo: s, subtitulo: l, tamanioInicial: u = 10, ubicacionTotal: d = "totalElements", children: g }) => {
|
|
126
|
+
let _ = P(), [C, T] = c({
|
|
127
|
+
page: 0,
|
|
128
|
+
pageSize: u
|
|
129
|
+
});
|
|
130
|
+
o(() => {
|
|
131
|
+
T((e) => ({
|
|
132
|
+
...e,
|
|
133
|
+
page: 0
|
|
134
|
+
}));
|
|
135
|
+
}, [JSON.stringify(a)]);
|
|
136
|
+
let { isLoading: D, isError: O, data: k } = I({
|
|
137
|
+
queryKey: [
|
|
138
|
+
`paginable-${e}`,
|
|
139
|
+
C,
|
|
140
|
+
a
|
|
141
|
+
],
|
|
142
|
+
queryFn: () => n(a, C.page, C.pageSize),
|
|
143
|
+
keepPreviousData: !0
|
|
144
|
+
}), A = s && U(s) ? _(s) : s, j = l && U(l) ? _(l) : l;
|
|
145
|
+
if (D) return /* @__PURE__ */ M(y, { children: Array.from(Array(u).keys()).map((e) => /* @__PURE__ */ M(b, { children: /* @__PURE__ */ M(x, { primary: /* @__PURE__ */ M(S, {}) }) }, `row-${e}`)) });
|
|
146
|
+
if (O) return /* @__PURE__ */ N(f, { children: [/* @__PURE__ */ M(h, { titulo: _(s) }), /* @__PURE__ */ M(m, { children: /* @__PURE__ */ M(H, { titulo: "main.paginable.error.carga" }) })] });
|
|
147
|
+
let L = (e, t) => {
|
|
148
|
+
D || t === C.page || T({
|
|
149
|
+
page: t,
|
|
150
|
+
pageSize: C.pageSize
|
|
151
|
+
});
|
|
152
|
+
}, R = (e) => {
|
|
153
|
+
let t = e.target.value;
|
|
154
|
+
D || t === C.pageSize || T({
|
|
155
|
+
page: 0,
|
|
156
|
+
pageSize: t
|
|
157
|
+
});
|
|
158
|
+
}, z = F(k, d, 0);
|
|
159
|
+
return /* @__PURE__ */ N(f, {
|
|
160
|
+
elevation: t,
|
|
161
|
+
children: [
|
|
162
|
+
A && /* @__PURE__ */ M(h, {
|
|
163
|
+
title: A,
|
|
164
|
+
subheader: j
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ M(m, { children: D ? /* @__PURE__ */ M(v, {}) : k && k.content.length > 0 ? r.map(g, (e) => i(e, { data: k.content })) : /* @__PURE__ */ M(E, { children: _("main.paginable.sinResultados") }) }),
|
|
167
|
+
k && z > 0 && /* @__PURE__ */ M(p, {
|
|
168
|
+
sx: { justifyContent: "flex-end" },
|
|
169
|
+
children: /* @__PURE__ */ M(w, {
|
|
170
|
+
component: "div",
|
|
171
|
+
count: z,
|
|
172
|
+
page: C.page,
|
|
173
|
+
rowsPerPage: C.pageSize,
|
|
174
|
+
labelRowsPerPage: _("main.paginable.filas"),
|
|
175
|
+
labelDisplayedRows: ({ from: e, to: t, count: n }) => _("main.paginable.resultados", {
|
|
176
|
+
inicial: e,
|
|
177
|
+
final: t,
|
|
178
|
+
total: n
|
|
179
|
+
}),
|
|
180
|
+
rowsPerPageOptions: [
|
|
181
|
+
5,
|
|
182
|
+
10,
|
|
183
|
+
15,
|
|
184
|
+
20,
|
|
185
|
+
25,
|
|
186
|
+
50
|
|
187
|
+
],
|
|
188
|
+
onRowsPerPageChange: R,
|
|
189
|
+
onPageChange: L
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
]
|
|
193
|
+
});
|
|
152
194
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}) => {
|
|
164
|
-
const g = C(), [p, y] = z({
|
|
165
|
-
page: 0,
|
|
166
|
-
pageSize: s
|
|
167
|
-
}), I = JSON.stringify(t);
|
|
168
|
-
b(() => {
|
|
169
|
-
y((l) => ({
|
|
170
|
-
...l,
|
|
171
|
-
page: 0
|
|
172
|
-
}));
|
|
173
|
-
}, [I]);
|
|
174
|
-
const { isLoading: h, isError: M, data: d } = pe({
|
|
175
|
-
queryKey: [`paginable-${a}`, p, t],
|
|
176
|
-
queryFn: () => o(t, p.page, p.pageSize),
|
|
177
|
-
keepPreviousData: !0
|
|
178
|
-
}), T = e && w(e) ? g(e) : e, L = c && w(c) ? g(c) : c;
|
|
179
|
-
if (h)
|
|
180
|
-
return /* @__PURE__ */ n(ee, { children: Array.from(Array(s).keys()).map((l) => /* @__PURE__ */ n(ne, { children: /* @__PURE__ */ n(re, { primary: /* @__PURE__ */ n(ie, {}) }) }, `row-${l}`)) });
|
|
181
|
-
if (M)
|
|
182
|
-
return /* @__PURE__ */ u(S, { children: [
|
|
183
|
-
/* @__PURE__ */ n(x, { titulo: g(e) }),
|
|
184
|
-
/* @__PURE__ */ n(v, { children: /* @__PURE__ */ n(N, { titulo: "main.paginable.error.carga" }) })
|
|
185
|
-
] });
|
|
186
|
-
const E = (l, m) => {
|
|
187
|
-
h || m === p.page || y({
|
|
188
|
-
page: m,
|
|
189
|
-
pageSize: p.pageSize
|
|
190
|
-
});
|
|
191
|
-
}, F = (l) => {
|
|
192
|
-
const m = l.target.value;
|
|
193
|
-
h || m === p.pageSize || y({
|
|
194
|
-
page: 0,
|
|
195
|
-
pageSize: m
|
|
196
|
-
});
|
|
197
|
-
}, P = le(d, q, 0);
|
|
198
|
-
return /* @__PURE__ */ u(S, { elevation: r, children: [
|
|
199
|
-
T && /* @__PURE__ */ n(x, { title: T, subheader: L }),
|
|
200
|
-
/* @__PURE__ */ n(v, { children: h ? /* @__PURE__ */ n(ae, {}) : d && d.content.length > 0 ? U.map(D, (l) => $(l, {
|
|
201
|
-
data: d.content
|
|
202
|
-
})) : /* @__PURE__ */ n(oe, { children: g("main.paginable.sinResultados") }) }),
|
|
203
|
-
d && P > 0 && /* @__PURE__ */ n(te, { sx: { justifyContent: "flex-end" }, children: /* @__PURE__ */ n(
|
|
204
|
-
se,
|
|
205
|
-
{
|
|
206
|
-
component: "div",
|
|
207
|
-
count: P,
|
|
208
|
-
page: p.page,
|
|
209
|
-
rowsPerPage: p.pageSize,
|
|
210
|
-
labelRowsPerPage: g("main.paginable.filas"),
|
|
211
|
-
labelDisplayedRows: ({ from: l, to: m, count: O }) => g("main.paginable.resultados", { inicial: l, final: m, total: O }),
|
|
212
|
-
rowsPerPageOptions: [5, 10, 15, 20, 25, 50],
|
|
213
|
-
onRowsPerPageChange: F,
|
|
214
|
-
onPageChange: E
|
|
215
|
-
}
|
|
216
|
-
) })
|
|
217
|
-
] });
|
|
195
|
+
W.propTypes = {
|
|
196
|
+
nombre: e.string.isRequired,
|
|
197
|
+
elevation: e.number,
|
|
198
|
+
api: e.func.isRequired,
|
|
199
|
+
filtros: e.object,
|
|
200
|
+
titulo: e.string,
|
|
201
|
+
subtitulo: e.string,
|
|
202
|
+
tamanioInicial: e.number,
|
|
203
|
+
ubicacionTotal: e.string,
|
|
204
|
+
children: e.element
|
|
218
205
|
};
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
a({ mensaje: r, tipo: o, posicion: t });
|
|
234
|
-
}, [a]);
|
|
235
|
-
};
|
|
236
|
-
export {
|
|
237
|
-
ve as Cargando,
|
|
238
|
-
N as Mensaje,
|
|
239
|
-
ge as MuiApp,
|
|
240
|
-
de as Paginable,
|
|
241
|
-
f as useMuiStore,
|
|
242
|
-
je as useNotificar
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/hooks/useNotificar.jsx
|
|
208
|
+
var G = () => {
|
|
209
|
+
let e = L((e) => e.mostrarNotificacion);
|
|
210
|
+
return a((t, n = "default", r = {
|
|
211
|
+
vertical: "botton",
|
|
212
|
+
horizontal: "center"
|
|
213
|
+
}) => {
|
|
214
|
+
e({
|
|
215
|
+
mensaje: t,
|
|
216
|
+
tipo: n,
|
|
217
|
+
posicion: r
|
|
218
|
+
});
|
|
219
|
+
}, [e]);
|
|
243
220
|
};
|
|
221
|
+
//#endregion
|
|
222
|
+
export { V as Cargando, H as Mensaje, B as MuiApp, W as Paginable, L as useMuiStore, G as useNotificar };
|
package/dist/mui-saas.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`prop-types`),require(`@chimera-pe/react-saas`),require(`react`),require(`@mui/material`),require(`@mui/material/colors`),require(`zustand`),require(`react/jsx-runtime`),require(`react-polyglot`),require(`lodash`),require(`@tanstack/react-query`)):typeof define==`function`&&define.amd?define([`exports`,`prop-types`,`@chimera-pe/react-saas`,`react`,`@mui/material`,`@mui/material/colors`,`zustand`,`react/jsx-runtime`,`react-polyglot`,`lodash`,`@tanstack/react-query`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`mui-saas`]={},e.PropTypes,e.ReactSaas,e.React,e.MuiMaterial,e.MuiMaterialColors,e.Zustand,e.ReactJSX,e.ReactPolyglot,e.Lodash,e.ReactQuery))})(this,function(e,t,n,r,i,a,o,s,c,l,u){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var d=Object.create,f=Object.defineProperty,p=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,h=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=m(t),a=0,o=i.length,s;a<o;a++)s=i[a],!g.call(e,s)&&s!==n&&f(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=p(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:d(h(e)),_(t||!e||!e.__esModule?f(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var v=(0,o.create)(e=>({tema:`light`,notificaciones:[],cambiarTema:t=>{e({tema:t})},mostrarNotificacion:t=>{e(e=>({notificaciones:[t,...e.notificaciones]}))},ocultarNotificacion:()=>{e(e=>({notificaciones:e.notificaciones.slice(1)}))}})),y=({children:e})=>{let t=v(e=>e.cambiarTema),o=(0,i.useMediaQuery)(`(prefers-color-scheme: dark)`),c=v(e=>e.tema),l=(0,n.useSaasStore)(e=>e.instancia);return(0,r.useEffect)(()=>{t(o?`dark`:`light`)},[t,o]),(0,s.jsxs)(i.ThemeProvider,{theme:(0,r.useMemo)(()=>(0,i.createTheme)({palette:{mode:c,primary:{main:l.color.primary},secondary:{main:l.color.secondary},error:{main:l.color.error},warning:{main:l.color.warning},info:{main:l.color.info},success:{main:l.color.success},...c===`light`&&{background:{default:a.grey.A200,paper:a.grey[100]}}},shape:{borderRadius:6}}),[c,l]),children:[(0,s.jsx)(i.CssBaseline,{}),e]})};y.propTypes={children:t.default.element.isRequired};var b=()=>{let e=(0,c.useTranslate)(),[t,n]=(0,r.useState)(!1),a=v(e=>e.ocultarNotificacion),o=v(e=>e.notificaciones[0]);return(0,r.useEffect)(()=>{n(!!o)},[o]),(0,s.jsx)(i.Snackbar,{open:t,message:o?o.tipo===`default`&&e(o?.mensaje):null,autoHideDuration:5e3,onClose:()=>{n(!1),a()},anchorOrigin:o&&{vertical:o?.posicion.vertical,horizontal:o?.posicion.horizontal},children:o&&o?.tipo!==`default`&&(0,s.jsx)(i.Alert,{severity:o.tipo,children:e(o.mensaje)})})},x=({aplicacion:e,dev:t=!1,devBackendUrl:r,devAuthUrl:i,mensajes:a={en:{},es:{}},children:o})=>(0,s.jsx)(n.SaasApp,{aplicacion:e,dev:t,devBackendUrl:r,devAuthUrl:i,mensajes:a,children:(0,s.jsx)(y,{children:(0,s.jsxs)(s.Fragment,{children:[o,(0,s.jsx)(b,{})]})})});x.propTypes={aplicacion:t.default.string.isRequired,dev:t.default.bool,devBackendUrl:t.default.string,devAuthUrl:t.default.string,mensajes:t.default.object,children:t.default.element.isRequired};var S=()=>(0,s.jsx)(i.Box,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,justifyContent:`center`,alignItems:`center`},children:(0,s.jsx)(i.CircularProgress,{})}),C=({titulo:e,texto:t,align:n=`center`,severity:r=`error`})=>{let a=(0,c.useTranslate)();return(0,s.jsx)(i.Box,{sx:{display:`flex`,flexDirection:`column`,flexGrow:1,justifyContent:`center`,alignItems:n},children:(0,s.jsxs)(i.Alert,{severity:r,children:[(0,s.jsx)(i.AlertTitle,{children:a(e)}),t&&a(t)]})})};C.propTypes={titulo:t.default.string.isRequired,texto:t.default.string,align:t.default.string,severity:t.default.string};var w=e=>(e.match(/(\w+)(\.\w+)+/g)||[]).length>0,T=({nombre:e,elevation:t=1,api:n,filtros:a,titulo:o,subtitulo:d,tamanioInicial:f=10,ubicacionTotal:p=`totalElements`,children:m})=>{let h=(0,c.useTranslate)(),[g,_]=(0,r.useState)({page:0,pageSize:f});(0,r.useEffect)(()=>{_(e=>({...e,page:0}))},[JSON.stringify(a)]);let{isLoading:v,isError:y,data:b}=(0,u.useQuery)({queryKey:[`paginable-${e}`,g,a],queryFn:()=>n(a,g.page,g.pageSize),keepPreviousData:!0}),x=o&&w(o)?h(o):o,S=d&&w(d)?h(d):d;if(v)return(0,s.jsx)(i.List,{children:Array.from(Array(f).keys()).map(e=>(0,s.jsx)(i.ListItem,{children:(0,s.jsx)(i.ListItemText,{primary:(0,s.jsx)(i.Skeleton,{})})},`row-${e}`))});if(y)return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.CardHeader,{titulo:h(o)}),(0,s.jsx)(i.CardContent,{children:(0,s.jsx)(C,{titulo:`main.paginable.error.carga`})})]});let T=(e,t)=>{v||t===g.page||_({page:t,pageSize:g.pageSize})},E=e=>{let t=e.target.value;v||t===g.pageSize||_({page:0,pageSize:t})},D=(0,l.get)(b,p,0);return(0,s.jsxs)(i.Card,{elevation:t,children:[x&&(0,s.jsx)(i.CardHeader,{title:x,subheader:S}),(0,s.jsx)(i.CardContent,{children:v?(0,s.jsx)(i.LinearProgress,{}):b&&b.content.length>0?r.Children.map(m,e=>(0,r.cloneElement)(e,{data:b.content})):(0,s.jsx)(i.Typography,{children:h(`main.paginable.sinResultados`)})}),b&&D>0&&(0,s.jsx)(i.CardActions,{sx:{justifyContent:`flex-end`},children:(0,s.jsx)(i.TablePagination,{component:`div`,count:D,page:g.page,rowsPerPage:g.pageSize,labelRowsPerPage:h(`main.paginable.filas`),labelDisplayedRows:({from:e,to:t,count:n})=>h(`main.paginable.resultados`,{inicial:e,final:t,total:n}),rowsPerPageOptions:[5,10,15,20,25,50],onRowsPerPageChange:E,onPageChange:T})})]})};T.propTypes={nombre:t.default.string.isRequired,elevation:t.default.number,api:t.default.func.isRequired,filtros:t.default.object,titulo:t.default.string,subtitulo:t.default.string,tamanioInicial:t.default.number,ubicacionTotal:t.default.string,children:t.default.element},e.Cargando=S,e.Mensaje=C,e.MuiApp=x,e.Paginable=T,e.useMuiStore=v,e.useNotificar=()=>{let e=v(e=>e.mostrarNotificacion);return(0,r.useCallback)((t,n=`default`,r={vertical:`botton`,horizontal:`center`})=>{e({mensaje:t,tipo:n,posicion:r})},[e])}});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chimera-pe/mui-saas",
|
|
3
3
|
"description": "Librería con componentes comunes para MUI, usando SaaS",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.18",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -32,26 +32,26 @@
|
|
|
32
32
|
"prepare": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@chimera-pe/react-saas": "^3.0.
|
|
35
|
+
"@chimera-pe/react-saas": "^3.0.12",
|
|
36
36
|
"@emotion/react": "^11.14.0",
|
|
37
37
|
"@emotion/styled": "^11.14.1",
|
|
38
|
-
"@mui/material": "^
|
|
39
|
-
"@tanstack/react-query": "^5.
|
|
40
|
-
"lodash": "^4.
|
|
41
|
-
"react": "^19.2.
|
|
42
|
-
"react-dom": "^19.2.
|
|
38
|
+
"@mui/material": "^9.0.0",
|
|
39
|
+
"@tanstack/react-query": "^5.99.2",
|
|
40
|
+
"lodash": "^4.18.1",
|
|
41
|
+
"react": "^19.2.5",
|
|
42
|
+
"react-dom": "^19.2.5",
|
|
43
43
|
"react-polyglot": "^0.7.2",
|
|
44
|
-
"zustand": "^5.0.
|
|
44
|
+
"zustand": "^5.0.12"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@eslint/js": "^9.
|
|
47
|
+
"@eslint/js": "^9.39.4",
|
|
48
48
|
"@types/react": "^19.2.14",
|
|
49
49
|
"@types/react-dom": "^19.2.3",
|
|
50
|
-
"@vitejs/plugin-react": "^
|
|
51
|
-
"eslint": "^9.39.
|
|
52
|
-
"eslint-plugin-react-hooks": "^7.
|
|
53
|
-
"eslint-plugin-react-refresh": "^0.
|
|
54
|
-
"globals": "^
|
|
55
|
-
"vite": "^
|
|
50
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
51
|
+
"eslint": "^9.39.4",
|
|
52
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
53
|
+
"eslint-plugin-react-refresh": "^0.5.2",
|
|
54
|
+
"globals": "^17.5.0",
|
|
55
|
+
"vite": "^8.0.9"
|
|
56
56
|
}
|
|
57
57
|
}
|