@chimera-pe/mui-saas 3.0.9 → 3.0.10
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 +40 -40
- package/dist/mui-saas.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/mui-saas.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as d, jsx as i, Fragment as M } from "react/jsx-runtime";
|
|
2
2
|
import n from "prop-types";
|
|
3
|
-
import { useSaasStore as
|
|
4
|
-
import { useEffect as b, useMemo as O, useState as
|
|
5
|
-
import { useMediaQuery as H, createTheme as Q, ThemeProvider as U, CssBaseline as $, Snackbar as J, Alert as
|
|
6
|
-
import { grey as
|
|
3
|
+
import { useSaasStore as L, SaasApp as E } from "@chimera-pe/react-saas";
|
|
4
|
+
import { useEffect as b, useMemo as O, useState as j, Children as B, cloneElement as F, useCallback as G } from "react";
|
|
5
|
+
import { useMediaQuery as H, createTheme as Q, ThemeProvider as U, CssBaseline as $, Snackbar as J, Alert as z, Box as R, CircularProgress as K, AlertTitle as V, List as W, ListItem as X, ListItemText as Y, Skeleton as Z, Card as P, CardHeader as S, CardContent as x, LinearProgress as _, Typography as ee, CardActions as ie, TablePagination as re } from "@mui/material";
|
|
6
|
+
import { grey as v } from "@mui/material/colors";
|
|
7
7
|
import { create as ne } from "zustand";
|
|
8
8
|
import { useTranslate as C } from "react-polyglot";
|
|
9
9
|
import { get as oe } from "lodash";
|
|
@@ -26,8 +26,8 @@ const f = ne((o) => ({
|
|
|
26
26
|
notificaciones: r.notificaciones.slice(1)
|
|
27
27
|
}));
|
|
28
28
|
}
|
|
29
|
-
})),
|
|
30
|
-
const r = f((s) => s.cambiarTema), t = H("(prefers-color-scheme: dark)"), a = f((s) => s.tema), e =
|
|
29
|
+
})), k = ({ children: o }) => {
|
|
30
|
+
const r = f((s) => s.cambiarTema), t = H("(prefers-color-scheme: dark)"), a = f((s) => s.tema), e = L((s) => s.instancia);
|
|
31
31
|
b(() => {
|
|
32
32
|
r(t ? "dark" : "light");
|
|
33
33
|
}, [r, t]);
|
|
@@ -54,8 +54,8 @@ const f = ne((o) => ({
|
|
|
54
54
|
},
|
|
55
55
|
...a === "light" && {
|
|
56
56
|
background: {
|
|
57
|
-
default:
|
|
58
|
-
paper:
|
|
57
|
+
default: v.A200,
|
|
58
|
+
paper: v[100]
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
},
|
|
@@ -68,11 +68,11 @@ const f = ne((o) => ({
|
|
|
68
68
|
o
|
|
69
69
|
] });
|
|
70
70
|
};
|
|
71
|
-
|
|
71
|
+
k.propTypes = {
|
|
72
72
|
children: n.element.isRequired
|
|
73
73
|
};
|
|
74
74
|
const ae = () => {
|
|
75
|
-
const o = C(), [r, t] =
|
|
75
|
+
const o = C(), [r, t] = j(!1), a = f((s) => s.ocultarNotificacion), e = f((s) => s.notificaciones[0]);
|
|
76
76
|
b(() => {
|
|
77
77
|
t(!!e);
|
|
78
78
|
}, [e]);
|
|
@@ -90,7 +90,7 @@ const ae = () => {
|
|
|
90
90
|
vertical: e?.posicion.vertical,
|
|
91
91
|
horizontal: e?.posicion.horizontal
|
|
92
92
|
},
|
|
93
|
-
children: e && e?.tipo !== "default" && /* @__PURE__ */ i(
|
|
93
|
+
children: e && e?.tipo !== "default" && /* @__PURE__ */ i(z, { severity: e.tipo, children: o(e.mensaje) })
|
|
94
94
|
}
|
|
95
95
|
);
|
|
96
96
|
}, se = ({
|
|
@@ -104,14 +104,14 @@ const ae = () => {
|
|
|
104
104
|
},
|
|
105
105
|
children: l
|
|
106
106
|
}) => /* @__PURE__ */ i(
|
|
107
|
-
|
|
107
|
+
E,
|
|
108
108
|
{
|
|
109
109
|
aplicacion: o,
|
|
110
110
|
dev: r,
|
|
111
111
|
devBackendUrl: t,
|
|
112
112
|
devAuthUrl: a,
|
|
113
113
|
mensajes: e,
|
|
114
|
-
children: /* @__PURE__ */ i(
|
|
114
|
+
children: /* @__PURE__ */ i(k, { children: /* @__PURE__ */ d(M, { children: [
|
|
115
115
|
l,
|
|
116
116
|
/* @__PURE__ */ i(ae, {})
|
|
117
117
|
] }) })
|
|
@@ -125,26 +125,26 @@ se.propTypes = {
|
|
|
125
125
|
mensajes: n.object,
|
|
126
126
|
children: n.element.isRequired
|
|
127
127
|
};
|
|
128
|
-
const Ce = () => /* @__PURE__ */ i(
|
|
128
|
+
const Ce = () => /* @__PURE__ */ i(R, { sx: {
|
|
129
129
|
display: "flex",
|
|
130
130
|
flexDirection: "column",
|
|
131
131
|
flexGrow: 1,
|
|
132
132
|
justifyContent: "center",
|
|
133
133
|
alignItems: "center"
|
|
134
|
-
}, children: /* @__PURE__ */ i(K, {}) }),
|
|
134
|
+
}, children: /* @__PURE__ */ i(K, {}) }), w = ({ titulo: o, texto: r, align: t = "center", severity: a = "error" }) => {
|
|
135
135
|
const e = C();
|
|
136
|
-
return /* @__PURE__ */ i(
|
|
136
|
+
return /* @__PURE__ */ i(R, { sx: {
|
|
137
137
|
display: "flex",
|
|
138
138
|
flexDirection: "column",
|
|
139
139
|
flexGrow: 1,
|
|
140
140
|
justifyContent: "center",
|
|
141
141
|
alignItems: t
|
|
142
|
-
}, children: /* @__PURE__ */ d(
|
|
142
|
+
}, children: /* @__PURE__ */ d(z, { severity: a, children: [
|
|
143
143
|
/* @__PURE__ */ i(V, { children: e(o) }),
|
|
144
144
|
r && e(r)
|
|
145
145
|
] }) });
|
|
146
146
|
};
|
|
147
|
-
|
|
147
|
+
w.propTypes = {
|
|
148
148
|
titulo: n.string.isRequired,
|
|
149
149
|
texto: n.string,
|
|
150
150
|
align: n.string,
|
|
@@ -158,9 +158,9 @@ const ce = ({
|
|
|
158
158
|
titulo: e,
|
|
159
159
|
tamanioInicial: l = 10,
|
|
160
160
|
ubicacionTotal: s = "totalElements",
|
|
161
|
-
children:
|
|
161
|
+
children: A
|
|
162
162
|
}) => {
|
|
163
|
-
const
|
|
163
|
+
const g = C(), [p, y] = j({
|
|
164
164
|
page: 0,
|
|
165
165
|
pageSize: l
|
|
166
166
|
});
|
|
@@ -170,47 +170,47 @@ const ce = ({
|
|
|
170
170
|
page: 0
|
|
171
171
|
}));
|
|
172
172
|
}, [JSON.stringify(a)]);
|
|
173
|
-
const { isLoading: h, isError:
|
|
173
|
+
const { isLoading: h, isError: N, data: u } = te({
|
|
174
174
|
queryKey: [`paginable-${o}`, p, a],
|
|
175
175
|
queryFn: () => t(a, p.page, p.pageSize),
|
|
176
176
|
keepPreviousData: !0
|
|
177
177
|
});
|
|
178
178
|
if (h)
|
|
179
179
|
return /* @__PURE__ */ i(W, { children: Array.from(Array(l).keys()).map((c) => /* @__PURE__ */ i(X, { children: /* @__PURE__ */ i(Y, { primary: /* @__PURE__ */ i(Z, {}) }) }, `row-${c}`)) });
|
|
180
|
-
if (
|
|
181
|
-
return /* @__PURE__ */ d(
|
|
182
|
-
/* @__PURE__ */ i(
|
|
183
|
-
/* @__PURE__ */ i(
|
|
180
|
+
if (N)
|
|
181
|
+
return /* @__PURE__ */ d(P, { children: [
|
|
182
|
+
/* @__PURE__ */ i(S, { titulo: g(e) }),
|
|
183
|
+
/* @__PURE__ */ i(x, { children: /* @__PURE__ */ i(w, { titulo: "main.paginable.error.carga" }) })
|
|
184
184
|
] });
|
|
185
|
-
const
|
|
185
|
+
const q = (c, m) => {
|
|
186
186
|
h || m === p.page || y({
|
|
187
187
|
page: m,
|
|
188
188
|
pageSize: p.pageSize
|
|
189
189
|
});
|
|
190
|
-
},
|
|
190
|
+
}, D = (c) => {
|
|
191
191
|
const m = c.target.value;
|
|
192
192
|
h || m === p.pageSize || y({
|
|
193
193
|
page: 0,
|
|
194
194
|
pageSize: m
|
|
195
195
|
});
|
|
196
|
-
},
|
|
197
|
-
return /* @__PURE__ */ d(
|
|
198
|
-
e && /* @__PURE__ */ i(
|
|
199
|
-
/* @__PURE__ */ i(
|
|
200
|
-
data:
|
|
201
|
-
})) : /* @__PURE__ */ i(ee, { children:
|
|
202
|
-
|
|
196
|
+
}, T = oe(u, s, 0);
|
|
197
|
+
return /* @__PURE__ */ d(P, { elevation: r, children: [
|
|
198
|
+
e && /* @__PURE__ */ i(S, { titulo: g(e) }),
|
|
199
|
+
/* @__PURE__ */ i(x, { children: h ? /* @__PURE__ */ i(_, {}) : u && u.content.length > 0 ? B.map(A, (c) => F(c, {
|
|
200
|
+
data: u.content
|
|
201
|
+
})) : /* @__PURE__ */ i(ee, { children: g("main.paginable.sinResultados") }) }),
|
|
202
|
+
u && T > 0 && /* @__PURE__ */ i(ie, { sx: { justifyContent: "flex-end" }, children: /* @__PURE__ */ i(
|
|
203
203
|
re,
|
|
204
204
|
{
|
|
205
205
|
component: "div",
|
|
206
|
-
count:
|
|
206
|
+
count: T,
|
|
207
207
|
page: p.page,
|
|
208
208
|
rowsPerPage: p.pageSize,
|
|
209
|
-
labelRowsPerPage:
|
|
210
|
-
labelDisplayedRows: ({ from: c, to: m, count: I }) =>
|
|
209
|
+
labelRowsPerPage: g("main.paginable.filas"),
|
|
210
|
+
labelDisplayedRows: ({ from: c, to: m, count: I }) => g("main.paginable.resultados", { inicial: c, final: m, total: I }),
|
|
211
211
|
rowsPerPageOptions: [5, 10, 15, 20, 25, 50],
|
|
212
|
-
onRowsPerPageChange:
|
|
213
|
-
onPageChange:
|
|
212
|
+
onRowsPerPageChange: D,
|
|
213
|
+
onPageChange: q
|
|
214
214
|
}
|
|
215
215
|
) })
|
|
216
216
|
] });
|
|
@@ -233,7 +233,7 @@ const Te = () => {
|
|
|
233
233
|
};
|
|
234
234
|
export {
|
|
235
235
|
Ce as Cargando,
|
|
236
|
-
|
|
236
|
+
w as Mensaje,
|
|
237
237
|
se as MuiApp,
|
|
238
238
|
ce as Paginable,
|
|
239
239
|
f as useMuiStore,
|
package/dist/mui-saas.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(r,e){typeof exports=="object"&&typeof module<"u"?e(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("lodash"),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","lodash","@tanstack/react-query"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r["mui-saas"]={},r.ReactJSX,r.PropTypes,r.ReactSaas,r.React,r.MuiMaterial,r.MuiMaterialColors,r.Zustand,r.ReactPolyglot,r.Lodash,r.ReactQuery))})(this,(function(r,e,t,v,u,i,j,
|
|
1
|
+
(function(r,e){typeof exports=="object"&&typeof module<"u"?e(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("lodash"),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","lodash","@tanstack/react-query"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r["mui-saas"]={},r.ReactJSX,r.PropTypes,r.ReactSaas,r.React,r.MuiMaterial,r.MuiMaterialColors,r.Zustand,r.ReactPolyglot,r.Lodash,r.ReactQuery))})(this,(function(r,e,t,v,u,i,j,A,q,N,w){"use strict";const p=A.create(o=>({tema:"light",notificaciones:[],cambiarTema:a=>{o({tema:a})},mostrarNotificacion:a=>{o(s=>({notificaciones:[a,...s.notificaciones]}))},ocultarNotificacion:()=>{o(a=>({notificaciones:a.notificaciones.slice(1)}))}})),M=({children:o})=>{const a=p(l=>l.cambiarTema),s=i.useMediaQuery("(prefers-color-scheme: dark)"),c=p(l=>l.tema),n=v.useSaasStore(l=>l.instancia);u.useEffect(()=>{a(s?"dark":"light")},[a,s]);const f=u.useMemo(()=>i.createTheme({palette:{mode:c,primary:{main:n.color.primary},secondary:{main:n.color.secondary},error:{main:n.color.error},warning:{main:n.color.warning},info:{main:n.color.info},success:{main:n.color.success},...c==="light"&&{background:{default:j.grey.A200,paper:j.grey[100]}}},shape:{borderRadius:6}}),[c,n]);return e.jsxs(i.ThemeProvider,{theme:f,children:[e.jsx(i.CssBaseline,{}),o]})};M.propTypes={children:t.element.isRequired};const D=()=>{const o=q.useTranslate(),[a,s]=u.useState(!1),c=p(l=>l.ocultarNotificacion),n=p(l=>l.notificaciones[0]);u.useEffect(()=>{s(!!n)},[n]);const f=()=>{s(!1),c()};return e.jsx(i.Snackbar,{open:a,message:n?n.tipo==="default"&&o(n?.mensaje):null,autoHideDuration:5e3,onClose:f,anchorOrigin:n&&{vertical:n?.posicion.vertical,horizontal:n?.posicion.horizontal},children:n&&n?.tipo!=="default"&&e.jsx(i.Alert,{severity:n.tipo,children:o(n.mensaje)})})},z=({aplicacion:o,dev:a=!1,devBackendUrl:s,devAuthUrl:c,mensajes:n={en:{},es:{}},children:f})=>e.jsx(v.SaasApp,{aplicacion:o,dev:a,devBackendUrl:s,devAuthUrl:c,mensajes:n,children:e.jsx(M,{children:e.jsxs(e.Fragment,{children:[f,e.jsx(D,{})]})})});z.propTypes={aplicacion:t.string.isRequired,dev:t.bool,devBackendUrl:t.string,devAuthUrl:t.string,mensajes:t.object,children:t.element.isRequired};const E=()=>e.jsx(i.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center"},children:e.jsx(i.CircularProgress,{})}),m=({titulo:o,texto:a,align:s="center",severity:c="error"})=>{const n=q.useTranslate();return e.jsx(i.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:s},children:e.jsxs(i.Alert,{severity:c,children:[e.jsx(i.AlertTitle,{children:n(o)}),a&&n(a)]})})};m.propTypes={titulo:t.string.isRequired,texto:t.string,align:t.string,severity:t.string};const k=({nombre:o,elevation:a=1,api:s,filtros:c,titulo:n,tamanioInicial:f=10,ubicacionTotal:l="totalElements",children:L})=>{const C=q.useTranslate(),[g,b]=u.useState({page:0,pageSize:f});u.useEffect(()=>{b(d=>({...d,page:0}))},[JSON.stringify(c)]);const{isLoading:S,isError:O,data:y}=w.useQuery({queryKey:[`paginable-${o}`,g,c],queryFn:()=>s(c,g.page,g.pageSize),keepPreviousData:!0});if(S)return e.jsx(i.List,{children:Array.from(Array(f).keys()).map(d=>e.jsx(i.ListItem,{children:e.jsx(i.ListItemText,{primary:e.jsx(i.Skeleton,{})})},`row-${d}`))});if(O)return e.jsxs(i.Card,{children:[e.jsx(i.CardHeader,{titulo:C(n)}),e.jsx(i.CardContent,{children:e.jsx(m,{titulo:"main.paginable.error.carga"})})]});const B=(d,h)=>{S||h===g.page||b({page:h,pageSize:g.pageSize})},T=d=>{const h=d.target.value;S||h===g.pageSize||b({page:0,pageSize:h})},x=N.get(y,l,0);return e.jsxs(i.Card,{elevation:a,children:[n&&e.jsx(i.CardHeader,{titulo:C(n)}),e.jsx(i.CardContent,{children:S?e.jsx(i.LinearProgress,{}):y&&y.content.length>0?u.Children.map(L,d=>u.cloneElement(d,{data:y.content})):e.jsx(i.Typography,{children:C("main.paginable.sinResultados")})}),y&&x>0&&e.jsx(i.CardActions,{sx:{justifyContent:"flex-end"},children:e.jsx(i.TablePagination,{component:"div",count:x,page:g.page,rowsPerPage:g.pageSize,labelRowsPerPage:C("main.paginable.filas"),labelDisplayedRows:({from:d,to:h,count:H})=>C("main.paginable.resultados",{inicial:d,final:h,total:H}),rowsPerPageOptions:[5,10,15,20,25,50],onRowsPerPageChange:T,onPageChange:B})})]})};k.propTypes={nombre:t.string.isRequired,elevation:t.number,api:t.func.isRequired,filtros:t.object,titulo:t.string,tamanioInicial:t.number,ubicacionTotal:t.string,children:t.element};const I=()=>{const o=p(a=>a.mostrarNotificacion);return u.useCallback((a,s="default",c={vertical:"botton",horizontal:"center"})=>{o({mensaje:a,tipo:s,posicion:c})},[o])};r.Cargando=E,r.Mensaje=m,r.MuiApp=z,r.Paginable=k,r.useMuiStore=p,r.useNotificar=I,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
|