@chimera-pe/mui-saas 3.0.7 → 3.0.8

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 CHANGED
@@ -1,38 +1,38 @@
1
- import { jsxs as u, jsx as r, Fragment as D } from "react/jsx-runtime";
1
+ import { jsxs as u, jsx as i, Fragment as D } from "react/jsx-runtime";
2
2
  import n 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
- import { useMediaQuery as U, createTheme as F, ThemeProvider as G, CssBaseline as H, Snackbar as Q, Alert as R, Box as j, CircularProgress as $, AlertTitle as J, List as K, 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";
5
+ import { useMediaQuery as F, createTheme as G, ThemeProvider as H, CssBaseline as Q, Snackbar as U, Alert as j, Box as z, CircularProgress as $, AlertTitle as J, List as K, 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";
6
6
  import { grey as x } from "@mui/material/colors";
7
- import { create as re } from "zustand";
7
+ import { create as ie } from "zustand";
8
8
  import { useTranslate as C } from "react-polyglot";
9
- import { useQuery as ie } from "@tanstack/react-query";
10
- const f = re((t) => ({
9
+ import { useQuery as re } from "@tanstack/react-query";
10
+ const f = ie((o) => ({
11
11
  tema: "light",
12
12
  notificaciones: [],
13
- cambiarTema: (i) => {
14
- t({
15
- tema: i
13
+ cambiarTema: (r) => {
14
+ o({
15
+ tema: r
16
16
  });
17
17
  },
18
- mostrarNotificacion: (i) => {
19
- t((a) => ({
20
- notificaciones: [i, ...a.notificaciones]
18
+ mostrarNotificacion: (r) => {
19
+ o((a) => ({
20
+ notificaciones: [r, ...a.notificaciones]
21
21
  }));
22
22
  },
23
23
  ocultarNotificacion: () => {
24
- t((i) => ({
25
- notificaciones: i.notificaciones.slice(1)
24
+ o((r) => ({
25
+ notificaciones: r.notificaciones.slice(1)
26
26
  }));
27
27
  }
28
- })), z = ({ children: t }) => {
29
- const i = f((s) => s.cambiarTema), a = U("(prefers-color-scheme: dark)"), o = f((s) => s.tema), e = I((s) => s.instancia);
28
+ })), R = ({ children: o }) => {
29
+ const r = f((s) => s.cambiarTema), a = F("(prefers-color-scheme: dark)"), t = f((s) => s.tema), e = I((s) => s.instancia);
30
30
  b(() => {
31
- i(a ? "dark" : "light");
32
- }, [i, a]);
33
- const l = E(() => F({
31
+ r(a ? "dark" : "light");
32
+ }, [r, a]);
33
+ const l = E(() => G({
34
34
  palette: {
35
- mode: o,
35
+ mode: t,
36
36
  primary: {
37
37
  main: e.color.primary
38
38
  },
@@ -51,7 +51,7 @@ const f = re((t) => ({
51
51
  success: {
52
52
  main: e.color.success
53
53
  },
54
- ...o === "light" && {
54
+ ...t === "light" && {
55
55
  background: {
56
56
  default: x.A200,
57
57
  paper: x[100]
@@ -61,89 +61,86 @@ const f = re((t) => ({
61
61
  shape: {
62
62
  borderRadius: 6
63
63
  }
64
- }), [o, e]);
65
- return /* @__PURE__ */ u(G, { theme: l, children: [
66
- /* @__PURE__ */ r(H, {}),
67
- t
64
+ }), [t, e]);
65
+ return /* @__PURE__ */ u(H, { theme: l, children: [
66
+ /* @__PURE__ */ i(Q, {}),
67
+ o
68
68
  ] });
69
69
  };
70
- z.propTypes = {
70
+ R.propTypes = {
71
71
  children: n.element.isRequired
72
72
  };
73
73
  const ne = () => {
74
- const t = C(), [i, a] = v(!1), o = f((s) => s.ocultarNotificacion), e = f((s) => s.notificaciones[0]);
74
+ const o = C(), [r, a] = v(!1), t = f((s) => s.ocultarNotificacion), e = f((s) => s.notificaciones[0]);
75
75
  b(() => {
76
76
  a(!!e);
77
77
  }, [e]);
78
78
  const l = () => {
79
- a(!1), o();
79
+ a(!1), t();
80
80
  };
81
- return /* @__PURE__ */ r(
82
- Q,
81
+ return /* @__PURE__ */ i(
82
+ U,
83
83
  {
84
- open: i,
85
- message: e ? e.tipo === "default" && t(e == null ? void 0 : e.mensaje) : null,
84
+ open: r,
85
+ message: e ? e.tipo === "default" && o(e?.mensaje) : null,
86
86
  autoHideDuration: 5e3,
87
87
  onClose: l,
88
88
  anchorOrigin: e && {
89
- vertical: e == null ? void 0 : e.posicion.vertical,
90
- horizontal: e == null ? void 0 : e.posicion.horizontal
89
+ vertical: e?.posicion.vertical,
90
+ horizontal: e?.posicion.horizontal
91
91
  },
92
- children: e && (e == null ? void 0 : e.tipo) !== "default" && /* @__PURE__ */ r(R, { severity: e.tipo, children: t(e.mensaje) })
92
+ children: e && e?.tipo !== "default" && /* @__PURE__ */ i(j, { severity: e.tipo, children: o(e.mensaje) })
93
93
  }
94
94
  );
95
- }, te = ({
96
- aplicacion: t,
97
- dev: i = !1,
95
+ }, oe = ({
96
+ aplicacion: o,
97
+ dev: r = !1,
98
98
  devBackendUrl: a,
99
- devAuthUrl: o,
100
- redirectUri: e,
101
- mensajes: l = {
99
+ devAuthUrl: t,
100
+ mensajes: e = {
102
101
  en: {},
103
102
  es: {}
104
103
  },
105
- children: s
106
- }) => /* @__PURE__ */ r(
104
+ children: l
105
+ }) => /* @__PURE__ */ i(
107
106
  M,
108
107
  {
109
- aplicacion: t,
110
- dev: i,
108
+ aplicacion: o,
109
+ dev: r,
111
110
  devBackendUrl: a,
112
- devAuthUrl: o,
113
- redirectUri: e,
114
- mensajes: l,
115
- children: /* @__PURE__ */ r(z, { children: /* @__PURE__ */ u(D, { children: [
116
- s,
117
- /* @__PURE__ */ r(ne, {})
111
+ devAuthUrl: t,
112
+ mensajes: e,
113
+ children: /* @__PURE__ */ i(R, { children: /* @__PURE__ */ u(D, { children: [
114
+ l,
115
+ /* @__PURE__ */ i(ne, {})
118
116
  ] }) })
119
117
  }
120
118
  );
121
- te.propTypes = {
119
+ oe.propTypes = {
122
120
  aplicacion: n.string.isRequired,
123
121
  dev: n.bool,
124
122
  devBackendUrl: n.string,
125
123
  devAuthUrl: n.string,
126
- redirectUri: n.string.isRequired,
127
124
  mensajes: n.object,
128
125
  children: n.element.isRequired
129
126
  };
130
- const fe = () => /* @__PURE__ */ r(j, { sx: {
127
+ const fe = () => /* @__PURE__ */ i(z, { sx: {
131
128
  display: "flex",
132
129
  flexDirection: "column",
133
130
  flexGrow: 1,
134
131
  justifyContent: "center",
135
132
  alignItems: "center"
136
- }, children: /* @__PURE__ */ r($, {}) }), k = ({ titulo: t, texto: i, align: a = "center", severity: o = "error" }) => {
133
+ }, children: /* @__PURE__ */ i($, {}) }), k = ({ titulo: o, texto: r, align: a = "center", severity: t = "error" }) => {
137
134
  const e = C();
138
- return /* @__PURE__ */ r(j, { sx: {
135
+ return /* @__PURE__ */ i(z, { sx: {
139
136
  display: "flex",
140
137
  flexDirection: "column",
141
138
  flexGrow: 1,
142
139
  justifyContent: "center",
143
140
  alignItems: a
144
- }, children: /* @__PURE__ */ u(R, { severity: o, children: [
145
- /* @__PURE__ */ r(J, { children: e(t) }),
146
- i && e(i)
141
+ }, children: /* @__PURE__ */ u(j, { severity: t, children: [
142
+ /* @__PURE__ */ i(J, { children: e(o) }),
143
+ r && e(r)
147
144
  ] }) });
148
145
  };
149
146
  k.propTypes = {
@@ -153,10 +150,10 @@ k.propTypes = {
153
150
  severity: n.string
154
151
  };
155
152
  const ae = ({
156
- nombre: t,
157
- elevation: i = 1,
153
+ nombre: o,
154
+ elevation: r = 1,
158
155
  api: a,
159
- filtros: o,
156
+ filtros: t,
160
157
  titulo: e,
161
158
  initialPageSize: l = 10,
162
159
  children: s
@@ -170,37 +167,37 @@ const ae = ({
170
167
  ...c,
171
168
  page: 0
172
169
  }));
173
- }, [JSON.stringify(o)]);
174
- const { isLoading: h, isError: q, data: d } = ie({
175
- queryKey: [`paginable-${t}`, p, o],
176
- queryFn: () => a(o, p.page, p.pageSize),
170
+ }, [JSON.stringify(t)]);
171
+ const { isLoading: h, isError: w, data: d } = re({
172
+ queryKey: [`paginable-${o}`, p, t],
173
+ queryFn: () => a(t, p.page, p.pageSize),
177
174
  keepPreviousData: !0
178
175
  });
179
176
  if (h)
180
- return /* @__PURE__ */ r(K, { children: Array.from(Array(l).keys()).map((c) => /* @__PURE__ */ r(V, { children: /* @__PURE__ */ r(W, { primary: /* @__PURE__ */ r(X, {}) }) }, `row-${c}`)) });
181
- if (q)
177
+ return /* @__PURE__ */ i(K, { children: Array.from(Array(l).keys()).map((c) => /* @__PURE__ */ i(V, { children: /* @__PURE__ */ i(W, { primary: /* @__PURE__ */ i(X, {}) }) }, `row-${c}`)) });
178
+ if (w)
182
179
  return /* @__PURE__ */ u(P, { children: [
183
- /* @__PURE__ */ r(S, { titulo: g(e) }),
184
- /* @__PURE__ */ r(T, { children: /* @__PURE__ */ r(k, { titulo: "main.paginable.error.carga" }) })
180
+ /* @__PURE__ */ i(S, { titulo: g(e) }),
181
+ /* @__PURE__ */ i(T, { children: /* @__PURE__ */ i(k, { titulo: "main.paginable.error.carga" }) })
185
182
  ] });
186
- const w = (c, m) => {
183
+ const A = (c, m) => {
187
184
  h || m === p.page || y({
188
185
  page: m,
189
186
  pageSize: p.pageSize
190
187
  });
191
- }, A = (c) => {
188
+ }, N = (c) => {
192
189
  const m = c.target.value;
193
190
  h || m === p.pageSize || y({
194
191
  page: 0,
195
192
  pageSize: m
196
193
  });
197
194
  };
198
- return /* @__PURE__ */ u(P, { elevation: i, children: [
199
- e && /* @__PURE__ */ r(S, { titulo: g(e) }),
200
- /* @__PURE__ */ r(T, { children: h ? /* @__PURE__ */ r(Y, {}) : d && d.content.length > 0 ? L.map(s, (c) => O(c, {
195
+ return /* @__PURE__ */ u(P, { elevation: r, children: [
196
+ e && /* @__PURE__ */ i(S, { titulo: g(e) }),
197
+ /* @__PURE__ */ i(T, { children: h ? /* @__PURE__ */ i(Y, {}) : d && d.content.length > 0 ? L.map(s, (c) => O(c, {
201
198
  data: d.content
202
- })) : /* @__PURE__ */ r(Z, { children: g("main.paginable.sinResultados") }) }),
203
- d && d.totalElements > 0 && /* @__PURE__ */ r(_, { sx: { justifyContent: "flex-end" }, children: /* @__PURE__ */ r(
199
+ })) : /* @__PURE__ */ i(Z, { children: g("main.paginable.sinResultados") }) }),
200
+ d && d.totalElements > 0 && /* @__PURE__ */ i(_, { sx: { justifyContent: "flex-end" }, children: /* @__PURE__ */ i(
204
201
  ee,
205
202
  {
206
203
  component: "div",
@@ -208,10 +205,10 @@ const ae = ({
208
205
  page: p.page,
209
206
  rowsPerPage: p.pageSize,
210
207
  labelRowsPerPage: g("main.paginable.filas"),
211
- labelDisplayedRows: ({ from: c, to: m, count: N }) => g("main.paginable.resultados", { inicial: c, final: m, total: N }),
208
+ labelDisplayedRows: ({ from: c, to: m, count: q }) => g("main.paginable.resultados", { inicial: c, final: m, total: q }),
212
209
  rowsPerPageOptions: [5, 10, 15, 20, 25, 50],
213
- onRowsPerPageChange: A,
214
- onPageChange: w
210
+ onRowsPerPageChange: N,
211
+ onPageChange: A
215
212
  }
216
213
  ) })
217
214
  ] });
@@ -226,15 +223,15 @@ ae.propTypes = {
226
223
  children: n.element
227
224
  };
228
225
  const he = () => {
229
- const t = f((i) => i.mostrarNotificacion);
230
- return B((i, a = "default", o = { vertical: "botton", horizontal: "center" }) => {
231
- t({ mensaje: i, tipo: a, posicion: o });
232
- }, [t]);
226
+ const o = f((r) => r.mostrarNotificacion);
227
+ return B((r, a = "default", t = { vertical: "botton", horizontal: "center" }) => {
228
+ o({ mensaje: r, tipo: a, posicion: t });
229
+ }, [o]);
233
230
  };
234
231
  export {
235
232
  fe as Cargando,
236
233
  k as Mensaje,
237
- te as MuiApp,
234
+ oe as MuiApp,
238
235
  ae as Paginable,
239
236
  f as useMuiStore,
240
237
  he as useNotificar
@@ -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,v,u,n,j,x,m,A){"use strict";const h=x.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)}))}})),M=({children:s})=>{const i=h(l=>l.cambiarTema),o=n.useMediaQuery("(prefers-color-scheme: dark)"),c=h(l=>l.tema),e=v.useSaasStore(l=>l.instancia);u.useEffect(()=>{i(o?"dark":"light")},[i,o]);const g=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:j.grey.A200,paper:j.grey[100]}}},shape:{borderRadius:6}}),[c,e]);return r.jsxs(n.ThemeProvider,{theme:g,children:[r.jsx(n.CssBaseline,{}),s]})};M.propTypes={children:t.element.isRequired};const N=()=>{const s=m.useTranslate(),[i,o]=u.useState(!1),c=h(l=>l.ocultarNotificacion),e=h(l=>l.notificaciones[0]);u.useEffect(()=>{o(!!e)},[e]);const g=()=>{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:g,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,devBackendUrl:o,devAuthUrl:c,redirectUri:e,mensajes:g={en:{},es:{}},children:l})=>r.jsx(v.SaasApp,{aplicacion:s,dev:i,devBackendUrl:o,devAuthUrl:c,redirectUri:e,mensajes:g,children:r.jsx(M,{children:r.jsxs(r.Fragment,{children:[l,r.jsx(N,{})]})})});z.propTypes={aplicacion:t.string.isRequired,dev:t.bool,devBackendUrl:t.string,devAuthUrl:t.string,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 k=({nombre:s,elevation:i=1,api:o,filtros:c,titulo:e,initialPageSize:g=10,children:l})=>{const y=m.useTranslate(),[f,b]=u.useState({page:0,pageSize:g});u.useEffect(()=>{b(d=>({...d,page:0}))},[JSON.stringify(c)]);const{isLoading:S,isError:D,data:C}=A.useQuery({queryKey:[`paginable-${s}`,f,c],queryFn:()=>o(c,f.page,f.pageSize),keepPreviousData:!0});if(S)return r.jsx(n.List,{children:Array.from(Array(g).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:y(e)}),r.jsx(n.CardContent,{children:r.jsx(q,{titulo:"main.paginable.error.carga"})})]});const I=(d,p)=>{S||p===f.page||b({page:p,pageSize:f.pageSize})},L=d=>{const p=d.target.value;S||p===f.pageSize||b({page:0,pageSize:p})};return r.jsxs(n.Card,{elevation:i,children:[e&&r.jsx(n.CardHeader,{titulo:y(e)}),r.jsx(n.CardContent,{children:S?r.jsx(n.LinearProgress,{}):C&&C.content.length>0?u.Children.map(l,d=>u.cloneElement(d,{data:C.content})):r.jsx(n.Typography,{children:y("main.paginable.sinResultados")})}),C&&C.totalElements>0&&r.jsx(n.CardActions,{sx:{justifyContent:"flex-end"},children:r.jsx(n.TablePagination,{component:"div",count:C.totalElements,page:f.page,rowsPerPage:f.pageSize,labelRowsPerPage:y("main.paginable.filas"),labelDisplayedRows:({from:d,to:p,count:O})=>y("main.paginable.resultados",{inicial:d,final:p,total:O}),rowsPerPageOptions:[5,10,15,20,25,50],onRowsPerPageChange:L,onPageChange:I})})]})};k.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=h(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=k,a.useMuiStore=h,a.useNotificar=E,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
1
+ (function(a,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("@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"],e):(a=typeof globalThis<"u"?globalThis:a||self,e(a["mui-saas"]={},a.ReactJSX,a.PropTypes,a.ReactSaas,a.React,a.MuiMaterial,a.MuiMaterialColors,a.Zustand,a.ReactPolyglot,a.ReactQuery))})(this,(function(a,e,t,v,u,i,j,x,m,A){"use strict";const h=x.create(o=>({tema:"light",notificaciones:[],cambiarTema:r=>{o({tema:r})},mostrarNotificacion:r=>{o(s=>({notificaciones:[r,...s.notificaciones]}))},ocultarNotificacion:()=>{o(r=>({notificaciones:r.notificaciones.slice(1)}))}})),M=({children:o})=>{const r=h(l=>l.cambiarTema),s=i.useMediaQuery("(prefers-color-scheme: dark)"),c=h(l=>l.tema),n=v.useSaasStore(l=>l.instancia);u.useEffect(()=>{r(s?"dark":"light")},[r,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 N=()=>{const o=m.useTranslate(),[r,s]=u.useState(!1),c=h(l=>l.ocultarNotificacion),n=h(l=>l.notificaciones[0]);u.useEffect(()=>{s(!!n)},[n]);const f=()=>{s(!1),c()};return e.jsx(i.Snackbar,{open:r,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:r=!1,devBackendUrl:s,devAuthUrl:c,mensajes:n={en:{},es:{}},children:f})=>e.jsx(v.SaasApp,{aplicacion:o,dev:r,devBackendUrl:s,devAuthUrl:c,mensajes:n,children:e.jsx(M,{children:e.jsxs(e.Fragment,{children:[f,e.jsx(N,{})]})})});z.propTypes={aplicacion:t.string.isRequired,dev:t.bool,devBackendUrl:t.string,devAuthUrl:t.string,mensajes:t.object,children:t.element.isRequired};const w=()=>e.jsx(i.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center"},children:e.jsx(i.CircularProgress,{})}),q=({titulo:o,texto:r,align:s="center",severity:c="error"})=>{const n=m.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)}),r&&n(r)]})})};q.propTypes={titulo:t.string.isRequired,texto:t.string,align:t.string,severity:t.string};const k=({nombre:o,elevation:r=1,api:s,filtros:c,titulo:n,initialPageSize:f=10,children:l})=>{const y=m.useTranslate(),[g,b]=u.useState({page:0,pageSize:f});u.useEffect(()=>{b(d=>({...d,page:0}))},[JSON.stringify(c)]);const{isLoading:S,isError:D,data:C}=A.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(D)return e.jsxs(i.Card,{children:[e.jsx(i.CardHeader,{titulo:y(n)}),e.jsx(i.CardContent,{children:e.jsx(q,{titulo:"main.paginable.error.carga"})})]});const I=(d,p)=>{S||p===g.page||b({page:p,pageSize:g.pageSize})},L=d=>{const p=d.target.value;S||p===g.pageSize||b({page:0,pageSize:p})};return e.jsxs(i.Card,{elevation:r,children:[n&&e.jsx(i.CardHeader,{titulo:y(n)}),e.jsx(i.CardContent,{children:S?e.jsx(i.LinearProgress,{}):C&&C.content.length>0?u.Children.map(l,d=>u.cloneElement(d,{data:C.content})):e.jsx(i.Typography,{children:y("main.paginable.sinResultados")})}),C&&C.totalElements>0&&e.jsx(i.CardActions,{sx:{justifyContent:"flex-end"},children:e.jsx(i.TablePagination,{component:"div",count:C.totalElements,page:g.page,rowsPerPage:g.pageSize,labelRowsPerPage:y("main.paginable.filas"),labelDisplayedRows:({from:d,to:p,count:O})=>y("main.paginable.resultados",{inicial:d,final:p,total:O}),rowsPerPageOptions:[5,10,15,20,25,50],onRowsPerPageChange:L,onPageChange:I})})]})};k.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 o=h(r=>r.mostrarNotificacion);return u.useCallback((r,s="default",c={vertical:"botton",horizontal:"center"})=>{o({mensaje:r,tipo:s,posicion:c})},[o])};a.Cargando=w,a.Mensaje=q,a.MuiApp=z,a.Paginable=k,a.useMuiStore=h,a.useNotificar=E,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
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.7",
4
+ "version": "3.0.8",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -32,25 +32,25 @@
32
32
  "prepare": "npm run build"
33
33
  },
34
34
  "peerDependencies": {
35
- "@chimera-pe/react-saas": "^3.0.4",
35
+ "@chimera-pe/react-saas": "^3.0.6",
36
36
  "@emotion/react": "^11.14.0",
37
- "@emotion/styled": "^11.14.0",
38
- "@mui/material": "^7.1.1",
39
- "@tanstack/react-query": "^5.80.6",
40
- "react": "^19.1.0",
41
- "react-dom": "^19.1.0",
37
+ "@emotion/styled": "^11.14.1",
38
+ "@mui/material": "^7.3.1",
39
+ "@tanstack/react-query": "^5.85.5",
40
+ "react": "^19.1.1",
41
+ "react-dom": "^19.1.1",
42
42
  "react-polyglot": "^0.7.2",
43
- "zustand": "^5.0.5"
43
+ "zustand": "^5.0.8"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@eslint/js": "^9.22.0",
47
- "@types/react": "^19.1.6",
48
- "@types/react-dom": "^19.1.6",
49
- "@vitejs/plugin-react": "^4.5.1",
50
- "eslint": "^9.28.0",
47
+ "@types/react": "^19.1.11",
48
+ "@types/react-dom": "^19.1.7",
49
+ "@vitejs/plugin-react": "^4.7.0",
50
+ "eslint": "^9.34.0",
51
51
  "eslint-plugin-react-hooks": "^5.2.0",
52
52
  "eslint-plugin-react-refresh": "^0.4.20",
53
- "globals": "^16.2.0",
54
- "vite": "^6.3.5"
53
+ "globals": "^16.3.0",
54
+ "vite": "^7.1.3"
55
55
  }
56
56
  }