@chimera-pe/mui-saas 3.0.4 → 3.0.5
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 +59 -59
- package/dist/mui-saas.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/mui-saas.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as g, jsx as r, Fragment as D } from "react/jsx-runtime";
|
|
2
|
+
import a from "prop-types";
|
|
3
3
|
import { useSaasStore as I, SaasApp as M } from "@chimera-pe/react-saas";
|
|
4
4
|
import { useEffect as b, useMemo as E, useState as v, Children as L, cloneElement as O, useCallback as B } from "react";
|
|
5
5
|
import { useMediaQuery as F, createTheme as G, ThemeProvider as H, CssBaseline as Q, Snackbar as $, Alert as R, Box as j, CircularProgress as J, AlertTitle as K, List as U, ListItem as V, ListItemText as W, Skeleton as X, Card as P, CardHeader as S, CardContent as T, LinearProgress as Y, Typography as Z, CardActions as _, TablePagination as ee } from "@mui/material";
|
|
@@ -16,8 +16,8 @@ const f = re((n) => ({
|
|
|
16
16
|
});
|
|
17
17
|
},
|
|
18
18
|
mostrarNotificacion: (i) => {
|
|
19
|
-
n((
|
|
20
|
-
notificaciones: [i, ...
|
|
19
|
+
n((t) => ({
|
|
20
|
+
notificaciones: [i, ...t.notificaciones]
|
|
21
21
|
}));
|
|
22
22
|
},
|
|
23
23
|
ocultarNotificacion: () => {
|
|
@@ -26,10 +26,10 @@ const f = re((n) => ({
|
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
28
28
|
})), z = ({ children: n }) => {
|
|
29
|
-
const i = f((s) => s.cambiarTema),
|
|
29
|
+
const i = f((s) => s.cambiarTema), t = F("(prefers-color-scheme: dark)"), o = f((s) => s.tema), e = I((s) => s.instancia);
|
|
30
30
|
b(() => {
|
|
31
|
-
i(
|
|
32
|
-
}, [i,
|
|
31
|
+
i(t ? "dark" : "light");
|
|
32
|
+
}, [i, t]);
|
|
33
33
|
const m = E(() => G({
|
|
34
34
|
palette: {
|
|
35
35
|
mode: o,
|
|
@@ -62,21 +62,21 @@ const f = re((n) => ({
|
|
|
62
62
|
borderRadius: 6
|
|
63
63
|
}
|
|
64
64
|
}), [o, e]);
|
|
65
|
-
return /* @__PURE__ */
|
|
65
|
+
return /* @__PURE__ */ g(H, { theme: m, children: [
|
|
66
66
|
/* @__PURE__ */ r(Q, {}),
|
|
67
67
|
n
|
|
68
68
|
] });
|
|
69
69
|
};
|
|
70
70
|
z.propTypes = {
|
|
71
|
-
children:
|
|
71
|
+
children: a.element.isRequired
|
|
72
72
|
};
|
|
73
73
|
const ne = () => {
|
|
74
|
-
const n = C(), [i,
|
|
74
|
+
const n = C(), [i, t] = v(!1), o = f((s) => s.ocultarNotificacion), e = f((s) => s.notificaciones[0]);
|
|
75
75
|
b(() => {
|
|
76
|
-
|
|
76
|
+
t(!!e);
|
|
77
77
|
}, [e]);
|
|
78
78
|
const m = () => {
|
|
79
|
-
|
|
79
|
+
t(!1), o();
|
|
80
80
|
};
|
|
81
81
|
return /* @__PURE__ */ r(
|
|
82
82
|
$,
|
|
@@ -92,10 +92,10 @@ const ne = () => {
|
|
|
92
92
|
children: e && (e == null ? void 0 : e.tipo) !== "default" && /* @__PURE__ */ r(R, { severity: e.tipo, children: n(e.mensaje) })
|
|
93
93
|
}
|
|
94
94
|
);
|
|
95
|
-
},
|
|
95
|
+
}, ae = ({
|
|
96
96
|
aplicacion: n,
|
|
97
97
|
dev: i = !1,
|
|
98
|
-
redirectUri:
|
|
98
|
+
redirectUri: t,
|
|
99
99
|
mensajes: o = {
|
|
100
100
|
en: {},
|
|
101
101
|
es: {}
|
|
@@ -106,20 +106,20 @@ const ne = () => {
|
|
|
106
106
|
{
|
|
107
107
|
aplicacion: n,
|
|
108
108
|
dev: i,
|
|
109
|
-
redirectUri:
|
|
109
|
+
redirectUri: t,
|
|
110
110
|
mensajes: o,
|
|
111
|
-
children: /* @__PURE__ */ r(z, { children: /* @__PURE__ */
|
|
111
|
+
children: /* @__PURE__ */ r(z, { children: /* @__PURE__ */ g(D, { children: [
|
|
112
112
|
e,
|
|
113
113
|
/* @__PURE__ */ r(ne, {})
|
|
114
114
|
] }) })
|
|
115
115
|
}
|
|
116
116
|
);
|
|
117
|
-
|
|
118
|
-
aplicacion:
|
|
119
|
-
dev:
|
|
120
|
-
redirectUri:
|
|
121
|
-
mensajes:
|
|
122
|
-
children:
|
|
117
|
+
ae.propTypes = {
|
|
118
|
+
aplicacion: a.string.isRequired,
|
|
119
|
+
dev: a.bool,
|
|
120
|
+
redirectUri: a.string.isRequired,
|
|
121
|
+
mensajes: a.object,
|
|
122
|
+
children: a.element.isRequired
|
|
123
123
|
};
|
|
124
124
|
const fe = () => /* @__PURE__ */ r(j, { sx: {
|
|
125
125
|
display: "flex",
|
|
@@ -127,35 +127,35 @@ const fe = () => /* @__PURE__ */ r(j, { sx: {
|
|
|
127
127
|
flexGrow: 1,
|
|
128
128
|
justifyContent: "center",
|
|
129
129
|
alignItems: "center"
|
|
130
|
-
}, children: /* @__PURE__ */ r(J, {}) }),
|
|
130
|
+
}, children: /* @__PURE__ */ r(J, {}) }), k = ({ titulo: n, texto: i, align: t = "center", severity: o = "error" }) => {
|
|
131
131
|
const e = C();
|
|
132
132
|
return /* @__PURE__ */ r(j, { sx: {
|
|
133
133
|
display: "flex",
|
|
134
134
|
flexDirection: "column",
|
|
135
135
|
flexGrow: 1,
|
|
136
136
|
justifyContent: "center",
|
|
137
|
-
alignItems:
|
|
138
|
-
}, children: /* @__PURE__ */
|
|
137
|
+
alignItems: t
|
|
138
|
+
}, children: /* @__PURE__ */ g(R, { severity: o, children: [
|
|
139
139
|
/* @__PURE__ */ r(K, { children: e(n) }),
|
|
140
140
|
i && e(i)
|
|
141
141
|
] }) });
|
|
142
142
|
};
|
|
143
|
-
|
|
144
|
-
titulo:
|
|
145
|
-
texto:
|
|
146
|
-
align:
|
|
147
|
-
severity:
|
|
143
|
+
k.propTypes = {
|
|
144
|
+
titulo: a.string.isRequired,
|
|
145
|
+
texto: a.string,
|
|
146
|
+
align: a.string,
|
|
147
|
+
severity: a.string
|
|
148
148
|
};
|
|
149
|
-
const
|
|
149
|
+
const te = ({
|
|
150
150
|
nombre: n,
|
|
151
151
|
elevation: i = 1,
|
|
152
|
-
api:
|
|
152
|
+
api: t,
|
|
153
153
|
filtros: o,
|
|
154
154
|
titulo: e,
|
|
155
155
|
initialPageSize: m = 10,
|
|
156
156
|
children: s
|
|
157
157
|
}) => {
|
|
158
|
-
const
|
|
158
|
+
const d = C(), [l, y] = v({
|
|
159
159
|
page: 0,
|
|
160
160
|
pageSize: m
|
|
161
161
|
});
|
|
@@ -165,19 +165,19 @@ const ae = ({
|
|
|
165
165
|
page: 0
|
|
166
166
|
}));
|
|
167
167
|
}, [JSON.stringify(o)]);
|
|
168
|
-
const { isLoading: h, isError:
|
|
168
|
+
const { isLoading: h, isError: q, data: u } = ie({
|
|
169
169
|
queryKey: [`paginable-${n}`, l, o],
|
|
170
|
-
queryFn: () =>
|
|
170
|
+
queryFn: () => t(o, l.page, l.pageSize),
|
|
171
171
|
keepPreviousData: !0
|
|
172
172
|
});
|
|
173
173
|
if (h)
|
|
174
174
|
return /* @__PURE__ */ r(U, { children: Array.from(Array(m).keys()).map((c) => /* @__PURE__ */ r(V, { children: /* @__PURE__ */ r(W, { primary: /* @__PURE__ */ r(X, {}) }) }, `row-${c}`)) });
|
|
175
|
-
if (
|
|
176
|
-
return /* @__PURE__ */
|
|
177
|
-
/* @__PURE__ */ r(S, { titulo:
|
|
178
|
-
/* @__PURE__ */ r(T, { children: /* @__PURE__ */ r(
|
|
175
|
+
if (q)
|
|
176
|
+
return /* @__PURE__ */ g(P, { children: [
|
|
177
|
+
/* @__PURE__ */ r(S, { titulo: d(e) }),
|
|
178
|
+
/* @__PURE__ */ r(T, { children: /* @__PURE__ */ r(k, { titulo: "main.paginable.error.carga" }) })
|
|
179
179
|
] });
|
|
180
|
-
const
|
|
180
|
+
const w = (c, p) => {
|
|
181
181
|
h || p === l.page || y({
|
|
182
182
|
page: p,
|
|
183
183
|
pageSize: l.pageSize
|
|
@@ -189,11 +189,11 @@ const ae = ({
|
|
|
189
189
|
pageSize: p
|
|
190
190
|
});
|
|
191
191
|
};
|
|
192
|
-
return /* @__PURE__ */
|
|
193
|
-
e && /* @__PURE__ */ r(S, { titulo:
|
|
192
|
+
return /* @__PURE__ */ g(P, { elevation: i, children: [
|
|
193
|
+
e && /* @__PURE__ */ r(S, { titulo: d(e) }),
|
|
194
194
|
/* @__PURE__ */ r(T, { children: h ? /* @__PURE__ */ r(Y, {}) : u && u.content.length > 0 ? L.map(s, (c) => O(c, {
|
|
195
195
|
data: u.content
|
|
196
|
-
})) : /* @__PURE__ */ r(Z, { children:
|
|
196
|
+
})) : /* @__PURE__ */ r(Z, { children: d("main.paginable.sinResultados") }) }),
|
|
197
197
|
u && u.totalElements > 0 && /* @__PURE__ */ r(_, { sx: { justifyContent: "flex-end" }, children: /* @__PURE__ */ r(
|
|
198
198
|
ee,
|
|
199
199
|
{
|
|
@@ -201,35 +201,35 @@ const ae = ({
|
|
|
201
201
|
count: u.totalElements,
|
|
202
202
|
page: l.page,
|
|
203
203
|
rowsPerPage: l.pageSize,
|
|
204
|
-
labelRowsPerPage:
|
|
205
|
-
labelDisplayedRows: ({ from: c, to: p, count: A }) =>
|
|
204
|
+
labelRowsPerPage: d("main.paginable.filas"),
|
|
205
|
+
labelDisplayedRows: ({ from: c, to: p, count: A }) => d("main.paginable.resultados", { inicial: c, final: p, total: A }),
|
|
206
206
|
rowsPerPageOptions: [5, 10, 15, 20, 25, 50],
|
|
207
207
|
onRowsPerPageChange: N,
|
|
208
|
-
onPageChange:
|
|
208
|
+
onPageChange: w
|
|
209
209
|
}
|
|
210
210
|
) })
|
|
211
211
|
] });
|
|
212
212
|
};
|
|
213
|
-
|
|
214
|
-
nombre:
|
|
215
|
-
elevation:
|
|
216
|
-
api:
|
|
217
|
-
filtros:
|
|
218
|
-
titulo:
|
|
219
|
-
initialPageSize:
|
|
220
|
-
children:
|
|
213
|
+
te.propTypes = {
|
|
214
|
+
nombre: a.string.isRequired,
|
|
215
|
+
elevation: a.number,
|
|
216
|
+
api: a.func.isRequired,
|
|
217
|
+
filtros: a.object,
|
|
218
|
+
titulo: a.string,
|
|
219
|
+
initialPageSize: a.number,
|
|
220
|
+
children: a.element
|
|
221
221
|
};
|
|
222
222
|
const he = () => {
|
|
223
223
|
const n = f((i) => i.mostrarNotificacion);
|
|
224
|
-
return B((i,
|
|
225
|
-
n({ mensaje: i, tipo:
|
|
224
|
+
return B((i, t = "default", o = { vertical: "botton", horizontal: "center" }) => {
|
|
225
|
+
n({ mensaje: i, tipo: t, posicion: o });
|
|
226
226
|
}, [n]);
|
|
227
227
|
};
|
|
228
228
|
export {
|
|
229
229
|
fe as Cargando,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
k as Mensaje,
|
|
231
|
+
ae as MuiApp,
|
|
232
|
+
te as Paginable,
|
|
233
233
|
f as useMuiStore,
|
|
234
234
|
he as useNotificar
|
|
235
235
|
};
|
package/dist/mui-saas.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("react/jsx-runtime"),require("prop-types"),require("@chimera-pe/react-saas"),require("react"),require("@mui/material"),require("@mui/material/colors"),require("zustand"),require("react-polyglot"),require("@tanstack/react-query")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","prop-types","@chimera-pe/react-saas","react","@mui/material","@mui/material/colors","zustand","react-polyglot","@tanstack/react-query"],r):(a=typeof globalThis<"u"?globalThis:a||self,r(a["mui-saas"]={},a.ReactJSX,a.PropTypes,a.ReactSaas,a.React,a.MuiMaterial,a.MuiMaterialColors,a.Zustand,a.ReactPolyglot,a.ReactQuery))})(this,function(a,r,t,j,u,n,M,k,
|
|
1
|
+
(function(a,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("react/jsx-runtime"),require("prop-types"),require("@chimera-pe/react-saas"),require("react"),require("@mui/material"),require("@mui/material/colors"),require("zustand"),require("react-polyglot"),require("@tanstack/react-query")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","prop-types","@chimera-pe/react-saas","react","@mui/material","@mui/material/colors","zustand","react-polyglot","@tanstack/react-query"],r):(a=typeof globalThis<"u"?globalThis:a||self,r(a["mui-saas"]={},a.ReactJSX,a.PropTypes,a.ReactSaas,a.React,a.MuiMaterial,a.MuiMaterialColors,a.Zustand,a.ReactPolyglot,a.ReactQuery))})(this,function(a,r,t,j,u,n,M,k,m,A){"use strict";const p=k.create(s=>({tema:"light",notificaciones:[],cambiarTema:i=>{s({tema:i})},mostrarNotificacion:i=>{s(o=>({notificaciones:[i,...o.notificaciones]}))},ocultarNotificacion:()=>{s(i=>({notificaciones:i.notificaciones.slice(1)}))}})),v=({children:s})=>{const i=p(l=>l.cambiarTema),o=n.useMediaQuery("(prefers-color-scheme: dark)"),c=p(l=>l.tema),e=j.useSaasStore(l=>l.instancia);u.useEffect(()=>{i(o?"dark":"light")},[i,o]);const h=u.useMemo(()=>n.createTheme({palette:{mode:c,primary:{main:e.color.primary},secondary:{main:e.color.secondary},error:{main:e.color.error},warning:{main:e.color.warning},info:{main:e.color.info},success:{main:e.color.success},...c==="light"&&{background:{default:M.grey.A200,paper:M.grey[100]}}},shape:{borderRadius:6}}),[c,e]);return r.jsxs(n.ThemeProvider,{theme:h,children:[r.jsx(n.CssBaseline,{}),s]})};v.propTypes={children:t.element.isRequired};const N=()=>{const s=m.useTranslate(),[i,o]=u.useState(!1),c=p(l=>l.ocultarNotificacion),e=p(l=>l.notificaciones[0]);u.useEffect(()=>{o(!!e)},[e]);const h=()=>{o(!1),c()};return r.jsx(n.Snackbar,{open:i,message:e?e.tipo==="default"&&s(e==null?void 0:e.mensaje):null,autoHideDuration:5e3,onClose:h,anchorOrigin:e&&{vertical:e==null?void 0:e.posicion.vertical,horizontal:e==null?void 0:e.posicion.horizontal},children:e&&(e==null?void 0:e.tipo)!=="default"&&r.jsx(n.Alert,{severity:e.tipo,children:s(e.mensaje)})})},z=({aplicacion:s,dev:i=!1,redirectUri:o,mensajes:c={en:{},es:{}},children:e})=>r.jsx(j.SaasApp,{aplicacion:s,dev:i,redirectUri:o,mensajes:c,children:r.jsx(v,{children:r.jsxs(r.Fragment,{children:[e,r.jsx(N,{})]})})});z.propTypes={aplicacion:t.string.isRequired,dev:t.bool,redirectUri:t.string.isRequired,mensajes:t.object,children:t.element.isRequired};const w=()=>r.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center"},children:r.jsx(n.CircularProgress,{})}),q=({titulo:s,texto:i,align:o="center",severity:c="error"})=>{const e=m.useTranslate();return r.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:o},children:r.jsxs(n.Alert,{severity:c,children:[r.jsx(n.AlertTitle,{children:e(s)}),i&&e(i)]})})};q.propTypes={titulo:t.string.isRequired,texto:t.string,align:t.string,severity:t.string};const x=({nombre:s,elevation:i=1,api:o,filtros:c,titulo:e,initialPageSize:h=10,children:l})=>{const C=m.useTranslate(),[g,b]=u.useState({page:0,pageSize:h});u.useEffect(()=>{b(d=>({...d,page:0}))},[JSON.stringify(c)]);const{isLoading:S,isError:D,data:y}=A.useQuery({queryKey:[`paginable-${s}`,g,c],queryFn:()=>o(c,g.page,g.pageSize),keepPreviousData:!0});if(S)return r.jsx(n.List,{children:Array.from(Array(h).keys()).map(d=>r.jsx(n.ListItem,{children:r.jsx(n.ListItemText,{primary:r.jsx(n.Skeleton,{})})},`row-${d}`))});if(D)return r.jsxs(n.Card,{children:[r.jsx(n.CardHeader,{titulo:C(e)}),r.jsx(n.CardContent,{children:r.jsx(q,{titulo:"main.paginable.error.carga"})})]});const I=(d,f)=>{S||f===g.page||b({page:f,pageSize:g.pageSize})},L=d=>{const f=d.target.value;S||f===g.pageSize||b({page:0,pageSize:f})};return r.jsxs(n.Card,{elevation:i,children:[e&&r.jsx(n.CardHeader,{titulo:C(e)}),r.jsx(n.CardContent,{children:S?r.jsx(n.LinearProgress,{}):y&&y.content.length>0?u.Children.map(l,d=>u.cloneElement(d,{data:y.content})):r.jsx(n.Typography,{children:C("main.paginable.sinResultados")})}),y&&y.totalElements>0&&r.jsx(n.CardActions,{sx:{justifyContent:"flex-end"},children:r.jsx(n.TablePagination,{component:"div",count:y.totalElements,page:g.page,rowsPerPage:g.pageSize,labelRowsPerPage:C("main.paginable.filas"),labelDisplayedRows:({from:d,to:f,count:O})=>C("main.paginable.resultados",{inicial:d,final:f,total:O}),rowsPerPageOptions:[5,10,15,20,25,50],onRowsPerPageChange:L,onPageChange:I})})]})};x.propTypes={nombre:t.string.isRequired,elevation:t.number,api:t.func.isRequired,filtros:t.object,titulo:t.string,initialPageSize:t.number,children:t.element};const E=()=>{const s=p(i=>i.mostrarNotificacion);return u.useCallback((i,o="default",c={vertical:"botton",horizontal:"center"})=>{s({mensaje:i,tipo:o,posicion:c})},[s])};a.Cargando=w,a.Mensaje=q,a.MuiApp=z,a.Paginable=x,a.useMuiStore=p,a.useNotificar=E,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|