@chimera-pe/mui-saas 3.0.6 → 3.0.7

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,9 +1,9 @@
1
- import { jsxs as g, jsx as r, Fragment as D } from "react/jsx-runtime";
1
+ import { jsxs as u, jsx as r, 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
- import { useEffect as b, useMemo as E, useState as x, Children as L, cloneElement as U, useCallback as B } from "react";
5
- import { useMediaQuery as O, 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 v, CardHeader as P, CardContent as S, LinearProgress as Y, Typography as Z, CardActions as _, TablePagination as ee } from "@mui/material";
6
- import { grey as T } from "@mui/material/colors";
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";
6
+ import { grey as x } from "@mui/material/colors";
7
7
  import { create as re } from "zustand";
8
8
  import { useTranslate as C } from "react-polyglot";
9
9
  import { useQuery as ie } from "@tanstack/react-query";
@@ -25,8 +25,8 @@ const f = re((t) => ({
25
25
  notificaciones: i.notificaciones.slice(1)
26
26
  }));
27
27
  }
28
- })), k = ({ children: t }) => {
29
- const i = f((s) => s.cambiarTema), a = O("(prefers-color-scheme: dark)"), o = f((s) => s.tema), e = I((s) => s.instancia);
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);
30
30
  b(() => {
31
31
  i(a ? "dark" : "light");
32
32
  }, [i, a]);
@@ -53,8 +53,8 @@ const f = re((t) => ({
53
53
  },
54
54
  ...o === "light" && {
55
55
  background: {
56
- default: T.A200,
57
- paper: T[100]
56
+ default: x.A200,
57
+ paper: x[100]
58
58
  }
59
59
  }
60
60
  },
@@ -62,16 +62,16 @@ const f = re((t) => ({
62
62
  borderRadius: 6
63
63
  }
64
64
  }), [o, e]);
65
- return /* @__PURE__ */ g(G, { theme: l, children: [
65
+ return /* @__PURE__ */ u(G, { theme: l, children: [
66
66
  /* @__PURE__ */ r(H, {}),
67
67
  t
68
68
  ] });
69
69
  };
70
- k.propTypes = {
70
+ z.propTypes = {
71
71
  children: n.element.isRequired
72
72
  };
73
73
  const ne = () => {
74
- const t = C(), [i, a] = x(!1), o = f((s) => s.ocultarNotificacion), e = f((s) => s.notificaciones[0]);
74
+ const t = C(), [i, a] = v(!1), o = f((s) => s.ocultarNotificacion), e = f((s) => s.notificaciones[0]);
75
75
  b(() => {
76
76
  a(!!e);
77
77
  }, [e]);
@@ -95,8 +95,8 @@ const ne = () => {
95
95
  }, te = ({
96
96
  aplicacion: t,
97
97
  dev: i = !1,
98
- devBackendUrl: a = defaultDevBackendUrl,
99
- devAuthUrl: o = defaultDevAuthUrl,
98
+ devBackendUrl: a,
99
+ devAuthUrl: o,
100
100
  redirectUri: e,
101
101
  mensajes: l = {
102
102
  en: {},
@@ -112,7 +112,7 @@ const ne = () => {
112
112
  devAuthUrl: o,
113
113
  redirectUri: e,
114
114
  mensajes: l,
115
- children: /* @__PURE__ */ r(k, { children: /* @__PURE__ */ g(D, { children: [
115
+ children: /* @__PURE__ */ r(z, { children: /* @__PURE__ */ u(D, { children: [
116
116
  s,
117
117
  /* @__PURE__ */ r(ne, {})
118
118
  ] }) })
@@ -133,7 +133,7 @@ const fe = () => /* @__PURE__ */ r(j, { sx: {
133
133
  flexGrow: 1,
134
134
  justifyContent: "center",
135
135
  alignItems: "center"
136
- }, children: /* @__PURE__ */ r($, {}) }), z = ({ titulo: t, texto: i, align: a = "center", severity: o = "error" }) => {
136
+ }, children: /* @__PURE__ */ r($, {}) }), k = ({ titulo: t, texto: i, align: a = "center", severity: o = "error" }) => {
137
137
  const e = C();
138
138
  return /* @__PURE__ */ r(j, { sx: {
139
139
  display: "flex",
@@ -141,12 +141,12 @@ const fe = () => /* @__PURE__ */ r(j, { sx: {
141
141
  flexGrow: 1,
142
142
  justifyContent: "center",
143
143
  alignItems: a
144
- }, children: /* @__PURE__ */ g(R, { severity: o, children: [
144
+ }, children: /* @__PURE__ */ u(R, { severity: o, children: [
145
145
  /* @__PURE__ */ r(J, { children: e(t) }),
146
146
  i && e(i)
147
147
  ] }) });
148
148
  };
149
- z.propTypes = {
149
+ k.propTypes = {
150
150
  titulo: n.string.isRequired,
151
151
  texto: n.string,
152
152
  align: n.string,
@@ -161,7 +161,7 @@ const ae = ({
161
161
  initialPageSize: l = 10,
162
162
  children: s
163
163
  }) => {
164
- const u = C(), [p, y] = x({
164
+ const g = C(), [p, y] = v({
165
165
  page: 0,
166
166
  pageSize: l
167
167
  });
@@ -171,35 +171,35 @@ const ae = ({
171
171
  page: 0
172
172
  }));
173
173
  }, [JSON.stringify(o)]);
174
- const { isLoading: h, isError: A, data: d } = ie({
174
+ const { isLoading: h, isError: q, data: d } = ie({
175
175
  queryKey: [`paginable-${t}`, p, o],
176
176
  queryFn: () => a(o, p.page, p.pageSize),
177
177
  keepPreviousData: !0
178
178
  });
179
179
  if (h)
180
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 (A)
182
- return /* @__PURE__ */ g(v, { children: [
183
- /* @__PURE__ */ r(P, { titulo: u(e) }),
184
- /* @__PURE__ */ r(S, { children: /* @__PURE__ */ r(z, { titulo: "main.paginable.error.carga" }) })
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" }) })
185
185
  ] });
186
- const q = (c, m) => {
186
+ const w = (c, m) => {
187
187
  h || m === p.page || y({
188
188
  page: m,
189
189
  pageSize: p.pageSize
190
190
  });
191
- }, w = (c) => {
191
+ }, A = (c) => {
192
192
  const m = c.target.value;
193
193
  h || m === p.pageSize || y({
194
194
  page: 0,
195
195
  pageSize: m
196
196
  });
197
197
  };
198
- return /* @__PURE__ */ g(v, { elevation: i, children: [
199
- e && /* @__PURE__ */ r(P, { titulo: u(e) }),
200
- /* @__PURE__ */ r(S, { children: h ? /* @__PURE__ */ r(Y, {}) : d && d.content.length > 0 ? L.map(s, (c) => U(c, {
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
201
  data: d.content
202
- })) : /* @__PURE__ */ r(Z, { children: u("main.paginable.sinResultados") }) }),
202
+ })) : /* @__PURE__ */ r(Z, { children: g("main.paginable.sinResultados") }) }),
203
203
  d && d.totalElements > 0 && /* @__PURE__ */ r(_, { sx: { justifyContent: "flex-end" }, children: /* @__PURE__ */ r(
204
204
  ee,
205
205
  {
@@ -207,11 +207,11 @@ const ae = ({
207
207
  count: d.totalElements,
208
208
  page: p.page,
209
209
  rowsPerPage: p.pageSize,
210
- labelRowsPerPage: u("main.paginable.filas"),
211
- labelDisplayedRows: ({ from: c, to: m, count: N }) => u("main.paginable.resultados", { inicial: c, final: m, total: N }),
210
+ labelRowsPerPage: g("main.paginable.filas"),
211
+ labelDisplayedRows: ({ from: c, to: m, count: N }) => g("main.paginable.resultados", { inicial: c, final: m, total: N }),
212
212
  rowsPerPageOptions: [5, 10, 15, 20, 25, 50],
213
- onRowsPerPageChange: w,
214
- onPageChange: q
213
+ onRowsPerPageChange: A,
214
+ onPageChange: w
215
215
  }
216
216
  ) })
217
217
  ] });
@@ -233,7 +233,7 @@ const he = () => {
233
233
  };
234
234
  export {
235
235
  fe as Cargando,
236
- z as Mensaje,
236
+ k as Mensaje,
237
237
  te as MuiApp,
238
238
  ae as Paginable,
239
239
  f as useMuiStore,
@@ -1 +1 @@
1
- (function(i,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):(i=typeof globalThis<"u"?globalThis:i||self,r(i["mui-saas"]={},i.ReactJSX,i.PropTypes,i.ReactSaas,i.React,i.MuiMaterial,i.MuiMaterialColors,i.Zustand,i.ReactPolyglot,i.ReactQuery))})(this,function(i,r,t,v,u,n,j,x,m,A){"use strict";const p=x.create(s=>({tema:"light",notificaciones:[],cambiarTema:a=>{s({tema:a})},mostrarNotificacion:a=>{s(o=>({notificaciones:[a,...o.notificaciones]}))},ocultarNotificacion:()=>{s(a=>({notificaciones:a.notificaciones.slice(1)}))}})),M=({children:s})=>{const a=p(l=>l.cambiarTema),o=n.useMediaQuery("(prefers-color-scheme: dark)"),c=p(l=>l.tema),e=v.useSaasStore(l=>l.instancia);u.useEffect(()=>{a(o?"dark":"light")},[a,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(),[a,o]=u.useState(!1),c=p(l=>l.ocultarNotificacion),e=p(l=>l.notificaciones[0]);u.useEffect(()=>{o(!!e)},[e]);const g=()=>{o(!1),c()};return r.jsx(n.Snackbar,{open:a,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)})})},k=({aplicacion:s,dev:a=!1,devBackendUrl:o=defaultDevBackendUrl,devAuthUrl:c=defaultDevAuthUrl,redirectUri:e,mensajes:g={en:{},es:{}},children:l})=>r.jsx(v.SaasApp,{aplicacion:s,dev:a,devBackendUrl:o,devAuthUrl:c,redirectUri:e,mensajes:g,children:r.jsx(M,{children:r.jsxs(r.Fragment,{children:[l,r.jsx(N,{})]})})});k.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:a,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)}),a&&e(a)]})})};q.propTypes={titulo:t.string.isRequired,texto:t.string,align:t.string,severity:t.string};const z=({nombre:s,elevation:a=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:E,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(E)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,h)=>{S||h===f.page||b({page:h,pageSize:f.pageSize})},B=d=>{const h=d.target.value;S||h===f.pageSize||b({page:0,pageSize:h})};return r.jsxs(n.Card,{elevation:a,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:h,count:L})=>y("main.paginable.resultados",{inicial:d,final:h,total:L}),rowsPerPageOptions:[5,10,15,20,25,50],onRowsPerPageChange:B,onPageChange:I})})]})};z.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 D=()=>{const s=p(a=>a.mostrarNotificacion);return u.useCallback((a,o="default",c={vertical:"botton",horizontal:"center"})=>{s({mensaje:a,tipo:o,posicion:c})},[s])};i.Cargando=w,i.Mensaje=q,i.MuiApp=k,i.Paginable=z,i.useMuiStore=p,i.useNotificar=D,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
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"})});
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.6",
4
+ "version": "3.0.7",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",