@chimera-pe/mui-saas 3.0.7 → 3.0.9

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