@chimera-pe/mui-saas 3.0.3 → 3.0.4

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,883 +1,235 @@
1
- var xe = (t) => {
2
- throw TypeError(t);
3
- };
4
- var ae = (t, e, s) => e.has(t) || xe("Cannot " + s);
5
- var r = (t, e, s) => (ae(t, e, "read from private field"), s ? s.call(t) : e.get(t)), p = (t, e, s) => e.has(t) ? xe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), h = (t, e, s, i) => (ae(t, e, "write to private field"), i ? i.call(t, s) : e.set(t, s), s), R = (t, e, s) => (ae(t, e, "access private method"), s);
6
- import { jsxs as K, jsx as g, Fragment as Xe } from "react/jsx-runtime";
7
- import w from "prop-types";
8
- import { useSaasStore as Ye, SaasApp as Ze } from "@chimera-pe/react-saas";
9
- import * as F from "react";
10
- import { useEffect as ve, useMemo as et, useState as Be, Children as tt, cloneElement as st, useCallback as rt } from "react";
11
- import { useMediaQuery as it, createTheme as nt, ThemeProvider as ot, CssBaseline as at, Snackbar as ct, Alert as He, Box as Ve, CircularProgress as ut, AlertTitle as lt, List as ht, ListItem as ft, ListItemText as dt, Skeleton as pt, Card as Fe, CardHeader as Te, CardContent as Pe, LinearProgress as gt, Typography as yt, CardActions as mt, TablePagination as bt } from "@mui/material";
12
- import { grey as je } from "@mui/material/colors";
13
- import { create as vt } from "zustand";
14
- import { useTranslate as Re } from "react-polyglot";
15
- const X = vt((t) => ({
1
+ import { jsxs as d, jsx as r, Fragment as D } from "react/jsx-runtime";
2
+ import t 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 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";
6
+ import { grey as x } from "@mui/material/colors";
7
+ import { create as re } from "zustand";
8
+ import { useTranslate as C } from "react-polyglot";
9
+ import { useQuery as ie } from "@tanstack/react-query";
10
+ const f = re((n) => ({
16
11
  tema: "light",
17
12
  notificaciones: [],
18
- cambiarTema: (e) => {
19
- t({
20
- tema: e
13
+ cambiarTema: (i) => {
14
+ n({
15
+ tema: i
21
16
  });
22
17
  },
23
- mostrarNotificacion: (e) => {
24
- t((s) => ({
25
- notificaciones: [e, ...s.notificaciones]
18
+ mostrarNotificacion: (i) => {
19
+ n((a) => ({
20
+ notificaciones: [i, ...a.notificaciones]
26
21
  }));
27
22
  },
28
23
  ocultarNotificacion: () => {
29
- t((e) => ({
30
- notificaciones: e.notificaciones.slice(1)
24
+ n((i) => ({
25
+ notificaciones: i.notificaciones.slice(1)
31
26
  }));
32
27
  }
33
- })), $e = ({ children: t }) => {
34
- const e = X((o) => o.cambiarTema), s = it("(prefers-color-scheme: dark)"), i = X((o) => o.tema), n = Ye((o) => o.instancia);
35
- ve(() => {
36
- e(s ? "dark" : "light");
37
- }, [e, s]);
38
- const a = et(() => nt({
28
+ })), z = ({ children: n }) => {
29
+ const i = f((s) => s.cambiarTema), a = F("(prefers-color-scheme: dark)"), o = f((s) => s.tema), e = I((s) => s.instancia);
30
+ b(() => {
31
+ i(a ? "dark" : "light");
32
+ }, [i, a]);
33
+ const m = E(() => G({
39
34
  palette: {
40
- mode: i,
35
+ mode: o,
41
36
  primary: {
42
- main: n.color.primary
37
+ main: e.color.primary
43
38
  },
44
39
  secondary: {
45
- main: n.color.secondary
40
+ main: e.color.secondary
46
41
  },
47
42
  error: {
48
- main: n.color.error
43
+ main: e.color.error
49
44
  },
50
45
  warning: {
51
- main: n.color.warning
46
+ main: e.color.warning
52
47
  },
53
48
  info: {
54
- main: n.color.info
49
+ main: e.color.info
55
50
  },
56
51
  success: {
57
- main: n.color.success
52
+ main: e.color.success
58
53
  },
59
- ...i === "light" && {
54
+ ...o === "light" && {
60
55
  background: {
61
- default: je.A200,
62
- paper: je[100]
56
+ default: x.A200,
57
+ paper: x[100]
63
58
  }
64
59
  }
65
60
  },
66
61
  shape: {
67
62
  borderRadius: 6
68
63
  }
69
- }), [i, n]);
70
- return /* @__PURE__ */ K(ot, { theme: a, children: [
71
- /* @__PURE__ */ g(at, {}),
72
- t
64
+ }), [o, e]);
65
+ return /* @__PURE__ */ d(H, { theme: m, children: [
66
+ /* @__PURE__ */ r(Q, {}),
67
+ n
73
68
  ] });
74
69
  };
75
- $e.propTypes = {
76
- children: w.element.isRequired
70
+ z.propTypes = {
71
+ children: t.element.isRequired
77
72
  };
78
- const Rt = () => {
79
- const t = Re(), [e, s] = Be(!1), i = X((o) => o.ocultarNotificacion), n = X((o) => o.notificaciones[0]);
80
- ve(() => {
81
- s(!!n);
82
- }, [n]);
83
- const a = () => {
84
- s(!1), i();
73
+ const ne = () => {
74
+ const n = C(), [i, a] = v(!1), o = f((s) => s.ocultarNotificacion), e = f((s) => s.notificaciones[0]);
75
+ b(() => {
76
+ a(!!e);
77
+ }, [e]);
78
+ const m = () => {
79
+ a(!1), o();
85
80
  };
86
- return /* @__PURE__ */ g(
87
- ct,
81
+ return /* @__PURE__ */ r(
82
+ $,
88
83
  {
89
- open: e,
90
- message: n ? n.tipo === "default" && t(n == null ? void 0 : n.mensaje) : null,
84
+ open: i,
85
+ message: e ? e.tipo === "default" && n(e == null ? void 0 : e.mensaje) : null,
91
86
  autoHideDuration: 5e3,
92
- onClose: a,
93
- anchorOrigin: n && {
94
- vertical: n == null ? void 0 : n.posicion.vertical,
95
- horizontal: n == null ? void 0 : n.posicion.horizontal
87
+ onClose: m,
88
+ anchorOrigin: e && {
89
+ vertical: e == null ? void 0 : e.posicion.vertical,
90
+ horizontal: e == null ? void 0 : e.posicion.horizontal
96
91
  },
97
- children: n && (n == null ? void 0 : n.tipo) !== "default" && /* @__PURE__ */ g(He, { severity: n.tipo, children: t(n.mensaje) })
92
+ children: e && (e == null ? void 0 : e.tipo) !== "default" && /* @__PURE__ */ r(R, { severity: e.tipo, children: n(e.mensaje) })
98
93
  }
99
94
  );
100
- }, wt = ({
101
- aplicacion: t,
102
- dev: e = !1,
103
- redirectUri: s,
104
- mensajes: i = {
95
+ }, te = ({
96
+ aplicacion: n,
97
+ dev: i = !1,
98
+ redirectUri: a,
99
+ mensajes: o = {
105
100
  en: {},
106
101
  es: {}
107
102
  },
108
- children: n
109
- }) => /* @__PURE__ */ g(
110
- Ze,
103
+ children: e
104
+ }) => /* @__PURE__ */ r(
105
+ M,
111
106
  {
112
- aplicacion: t,
113
- dev: e,
114
- redirectUri: s,
115
- mensajes: i,
116
- children: /* @__PURE__ */ g($e, { children: /* @__PURE__ */ K(Xe, { children: [
117
- n,
118
- /* @__PURE__ */ g(Rt, {})
107
+ aplicacion: n,
108
+ dev: i,
109
+ redirectUri: a,
110
+ mensajes: o,
111
+ children: /* @__PURE__ */ r(z, { children: /* @__PURE__ */ d(D, { children: [
112
+ e,
113
+ /* @__PURE__ */ r(ne, {})
119
114
  ] }) })
120
115
  }
121
116
  );
122
- wt.propTypes = {
123
- aplicacion: w.string.isRequired,
124
- dev: w.bool,
125
- redirectUri: w.string.isRequired,
126
- mensajes: w.object,
127
- children: w.element.isRequired
117
+ te.propTypes = {
118
+ aplicacion: t.string.isRequired,
119
+ dev: t.bool,
120
+ redirectUri: t.string.isRequired,
121
+ mensajes: t.object,
122
+ children: t.element.isRequired
128
123
  };
129
- const os = () => /* @__PURE__ */ g(Ve, { sx: {
124
+ const fe = () => /* @__PURE__ */ r(j, { sx: {
130
125
  display: "flex",
131
126
  flexDirection: "column",
132
127
  flexGrow: 1,
133
128
  justifyContent: "center",
134
129
  alignItems: "center"
135
- }, children: /* @__PURE__ */ g(ut, {}) }), Je = ({ titulo: t, texto: e, align: s = "center", severity: i = "error" }) => {
136
- const n = Re();
137
- return /* @__PURE__ */ g(Ve, { sx: {
130
+ }, children: /* @__PURE__ */ r(J, {}) }), w = ({ titulo: n, texto: i, align: a = "center", severity: o = "error" }) => {
131
+ const e = C();
132
+ return /* @__PURE__ */ r(j, { sx: {
138
133
  display: "flex",
139
134
  flexDirection: "column",
140
135
  flexGrow: 1,
141
136
  justifyContent: "center",
142
- alignItems: s
143
- }, children: /* @__PURE__ */ K(He, { severity: i, children: [
144
- /* @__PURE__ */ g(lt, { children: n(t) }),
145
- e && n(e)
137
+ alignItems: a
138
+ }, children: /* @__PURE__ */ d(R, { severity: o, children: [
139
+ /* @__PURE__ */ r(K, { children: e(n) }),
140
+ i && e(i)
146
141
  ] }) });
147
142
  };
148
- Je.propTypes = {
149
- titulo: w.string.isRequired,
150
- texto: w.string,
151
- align: w.string,
152
- severity: w.string
143
+ w.propTypes = {
144
+ titulo: t.string.isRequired,
145
+ texto: t.string,
146
+ align: t.string,
147
+ severity: t.string
153
148
  };
154
- var we = class {
155
- constructor() {
156
- this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
157
- }
158
- subscribe(t) {
159
- return this.listeners.add(t), this.onSubscribe(), () => {
160
- this.listeners.delete(t), this.onUnsubscribe();
161
- };
162
- }
163
- hasListeners() {
164
- return this.listeners.size > 0;
165
- }
166
- onSubscribe() {
167
- }
168
- onUnsubscribe() {
169
- }
170
- }, Y = typeof window > "u" || "Deno" in globalThis;
171
- function ce() {
172
- }
173
- function Ie(t) {
174
- return typeof t == "number" && t >= 0 && t !== 1 / 0;
175
- }
176
- function Ct(t, e) {
177
- return Math.max(t + (e || 0) - Date.now(), 0);
178
- }
179
- function re(t, e) {
180
- return typeof t == "function" ? t(e) : t;
181
- }
182
- function P(t, e) {
183
- return typeof t == "function" ? t(e) : t;
184
- }
185
- function ue(t, e) {
186
- if (t === e)
187
- return t;
188
- const s = Le(t) && Le(e);
189
- if (s || Qe(t) && Qe(e)) {
190
- const i = s ? t : Object.keys(t), n = i.length, a = s ? e : Object.keys(e), o = a.length, c = s ? [] : {};
191
- let u = 0;
192
- for (let v = 0; v < o; v++) {
193
- const y = s ? v : a[v];
194
- (!s && i.includes(y) || s) && t[y] === void 0 && e[y] === void 0 ? (c[y] = void 0, u++) : (c[y] = ue(t[y], e[y]), c[y] === t[y] && t[y] !== void 0 && u++);
195
- }
196
- return n === o && u === n ? t : c;
197
- }
198
- return e;
199
- }
200
- function le(t, e) {
201
- if (!e || Object.keys(t).length !== Object.keys(e).length)
202
- return !1;
203
- for (const s in t)
204
- if (t[s] !== e[s])
205
- return !1;
206
- return !0;
207
- }
208
- function Le(t) {
209
- return Array.isArray(t) && t.length === Object.keys(t).length;
210
- }
211
- function Qe(t) {
212
- if (!Me(t))
213
- return !1;
214
- const e = t.constructor;
215
- if (e === void 0)
216
- return !0;
217
- const s = e.prototype;
218
- return !(!Me(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(t) !== Object.prototype);
219
- }
220
- function Me(t) {
221
- return Object.prototype.toString.call(t) === "[object Object]";
222
- }
223
- function ke(t, e, s) {
224
- if (typeof s.structuralSharing == "function")
225
- return s.structuralSharing(t, e);
226
- if (s.structuralSharing !== !1) {
227
- if (process.env.NODE_ENV !== "production")
228
- try {
229
- return ue(t, e);
230
- } catch (i) {
231
- throw console.error(
232
- `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${i}`
233
- ), i;
234
- }
235
- return ue(t, e);
236
- }
237
- return e;
238
- }
239
- function St(t, e) {
240
- return typeof t == "function" ? t(...e) : !!t;
241
- }
242
- var q, j, _, ze, Ot = (ze = class extends we {
243
- constructor() {
244
- super();
245
- p(this, q);
246
- p(this, j);
247
- p(this, _);
248
- h(this, _, (e) => {
249
- if (!Y && window.addEventListener) {
250
- const s = () => e();
251
- return window.addEventListener("visibilitychange", s, !1), () => {
252
- window.removeEventListener("visibilitychange", s);
253
- };
254
- }
255
- });
256
- }
257
- onSubscribe() {
258
- r(this, j) || this.setEventListener(r(this, _));
259
- }
260
- onUnsubscribe() {
261
- var e;
262
- this.hasListeners() || ((e = r(this, j)) == null || e.call(this), h(this, j, void 0));
263
- }
264
- setEventListener(e) {
265
- var s;
266
- h(this, _, e), (s = r(this, j)) == null || s.call(this), h(this, j, e((i) => {
267
- typeof i == "boolean" ? this.setFocused(i) : this.onFocus();
268
- }));
269
- }
270
- setFocused(e) {
271
- r(this, q) !== e && (h(this, q, e), this.onFocus());
272
- }
273
- onFocus() {
274
- const e = this.isFocused();
275
- this.listeners.forEach((s) => {
276
- s(e);
277
- });
278
- }
279
- isFocused() {
280
- var e;
281
- return typeof r(this, q) == "boolean" ? r(this, q) : ((e = globalThis.document) == null ? void 0 : e.visibilityState) !== "hidden";
282
- }
283
- }, q = new WeakMap(), j = new WeakMap(), _ = new WeakMap(), ze), Et = new Ot(), B, I, H, Ae, xt = (Ae = class extends we {
284
- constructor() {
285
- super();
286
- p(this, B, !0);
287
- p(this, I);
288
- p(this, H);
289
- h(this, H, (e) => {
290
- if (!Y && window.addEventListener) {
291
- const s = () => e(!0), i = () => e(!1);
292
- return window.addEventListener("online", s, !1), window.addEventListener("offline", i, !1), () => {
293
- window.removeEventListener("online", s), window.removeEventListener("offline", i);
294
- };
295
- }
296
- });
297
- }
298
- onSubscribe() {
299
- r(this, I) || this.setEventListener(r(this, H));
300
- }
301
- onUnsubscribe() {
302
- var e;
303
- this.hasListeners() || ((e = r(this, I)) == null || e.call(this), h(this, I, void 0));
304
- }
305
- setEventListener(e) {
306
- var s;
307
- h(this, H, e), (s = r(this, I)) == null || s.call(this), h(this, I, e(this.setOnline.bind(this)));
308
- }
309
- setOnline(e) {
310
- r(this, B) !== e && (h(this, B, e), this.listeners.forEach((i) => {
311
- i(e);
312
- }));
313
- }
314
- isOnline() {
315
- return r(this, B);
316
- }
317
- }, B = new WeakMap(), I = new WeakMap(), H = new WeakMap(), Ae), Ft = new xt();
318
- function qe() {
319
- let t, e;
320
- const s = new Promise((n, a) => {
321
- t = n, e = a;
322
- });
323
- s.status = "pending", s.catch(() => {
324
- });
325
- function i(n) {
326
- Object.assign(s, n), delete s.resolve, delete s.reject;
327
- }
328
- return s.resolve = (n) => {
329
- i({
330
- status: "fulfilled",
331
- value: n
332
- }), t(n);
333
- }, s.reject = (n) => {
334
- i({
335
- status: "rejected",
336
- reason: n
337
- }), e(n);
338
- }, s;
339
- }
340
- function Tt(t) {
341
- return (t ?? "online") === "online" ? Ft.isOnline() : !0;
342
- }
343
- var Pt = (t) => setTimeout(t, 0);
344
- function jt() {
345
- let t = [], e = 0, s = (c) => {
346
- c();
347
- }, i = (c) => {
348
- c();
349
- }, n = Pt;
350
- const a = (c) => {
351
- e ? t.push(c) : n(() => {
352
- s(c);
353
- });
354
- }, o = () => {
355
- const c = t;
356
- t = [], c.length && n(() => {
357
- i(() => {
358
- c.forEach((u) => {
359
- s(u);
360
- });
361
- });
362
- });
363
- };
364
- return {
365
- batch: (c) => {
366
- let u;
367
- e++;
368
- try {
369
- u = c();
370
- } finally {
371
- e--, e || o();
372
- }
373
- return u;
374
- },
375
- /**
376
- * All calls to the wrapped function will be batched.
377
- */
378
- batchCalls: (c) => (...u) => {
379
- a(() => {
380
- c(...u);
381
- });
382
- },
383
- schedule: a,
384
- /**
385
- * Use this method to set a custom notify function.
386
- * This can be used to for example wrap notifications with `React.act` while running tests.
387
- */
388
- setNotifyFunction: (c) => {
389
- s = c;
390
- },
391
- /**
392
- * Use this method to set a custom function to batch notifications together into a single tick.
393
- * By default React Query will use the batch function provided by ReactDOM or React Native.
394
- */
395
- setBatchNotifyFunction: (c) => {
396
- i = c;
397
- },
398
- setScheduler: (c) => {
399
- n = c;
400
- }
401
- };
402
- }
403
- var We = jt();
404
- function It(t, e) {
405
- return {
406
- fetchFailureCount: 0,
407
- fetchFailureReason: null,
408
- fetchStatus: Tt(e.networkMode) ? "fetching" : "paused",
409
- ...t === void 0 && {
410
- error: null,
411
- status: "pending"
412
- }
413
- };
414
- }
415
- var O, l, Z, S, D, V, L, Q, ee, $, J, N, U, M, W, f, G, he, fe, de, pe, ge, ye, me, Ge, _e, Lt = (_e = class extends we {
416
- constructor(e, s) {
417
- super();
418
- p(this, f);
419
- p(this, O);
420
- p(this, l);
421
- p(this, Z);
422
- p(this, S);
423
- p(this, D);
424
- p(this, V);
425
- p(this, L);
426
- p(this, Q);
427
- p(this, ee);
428
- p(this, $);
429
- // This property keeps track of the last query with defined data.
430
- // It will be used to pass the previous data and query to the placeholder function between renders.
431
- p(this, J);
432
- p(this, N);
433
- p(this, U);
434
- p(this, M);
435
- p(this, W, /* @__PURE__ */ new Set());
436
- this.options = s, h(this, O, e), h(this, Q, null), h(this, L, qe()), this.options.experimental_prefetchInRender || r(this, L).reject(
437
- new Error("experimental_prefetchInRender feature flag is not enabled")
438
- ), this.bindMethods(), this.setOptions(s);
439
- }
440
- bindMethods() {
441
- this.refetch = this.refetch.bind(this);
442
- }
443
- onSubscribe() {
444
- this.listeners.size === 1 && (r(this, l).addObserver(this), De(r(this, l), this.options) ? R(this, f, G).call(this) : this.updateResult(), R(this, f, pe).call(this));
445
- }
446
- onUnsubscribe() {
447
- this.hasListeners() || this.destroy();
448
- }
449
- shouldFetchOnReconnect() {
450
- return be(
451
- r(this, l),
452
- this.options,
453
- this.options.refetchOnReconnect
454
- );
455
- }
456
- shouldFetchOnWindowFocus() {
457
- return be(
458
- r(this, l),
459
- this.options,
460
- this.options.refetchOnWindowFocus
461
- );
462
- }
463
- destroy() {
464
- this.listeners = /* @__PURE__ */ new Set(), R(this, f, ge).call(this), R(this, f, ye).call(this), r(this, l).removeObserver(this);
465
- }
466
- setOptions(e) {
467
- const s = this.options, i = r(this, l);
468
- if (this.options = r(this, O).defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof P(this.options.enabled, r(this, l)) != "boolean")
469
- throw new Error(
470
- "Expected enabled to be a boolean or a callback that returns a boolean"
471
- );
472
- R(this, f, me).call(this), r(this, l).setOptions(this.options), s._defaulted && !le(this.options, s) && r(this, O).getQueryCache().notify({
473
- type: "observerOptionsUpdated",
474
- query: r(this, l),
475
- observer: this
476
- });
477
- const n = this.hasListeners();
478
- n && Ne(
479
- r(this, l),
480
- i,
481
- this.options,
482
- s
483
- ) && R(this, f, G).call(this), this.updateResult(), n && (r(this, l) !== i || P(this.options.enabled, r(this, l)) !== P(s.enabled, r(this, l)) || re(this.options.staleTime, r(this, l)) !== re(s.staleTime, r(this, l))) && R(this, f, he).call(this);
484
- const a = R(this, f, fe).call(this);
485
- n && (r(this, l) !== i || P(this.options.enabled, r(this, l)) !== P(s.enabled, r(this, l)) || a !== r(this, M)) && R(this, f, de).call(this, a);
486
- }
487
- getOptimisticResult(e) {
488
- const s = r(this, O).getQueryCache().build(r(this, O), e), i = this.createResult(s, e);
489
- return Mt(this, i) && (h(this, S, i), h(this, V, this.options), h(this, D, r(this, l).state)), i;
490
- }
491
- getCurrentResult() {
492
- return r(this, S);
493
- }
494
- trackResult(e, s) {
495
- return new Proxy(e, {
496
- get: (i, n) => (this.trackProp(n), s == null || s(n), Reflect.get(i, n))
497
- });
498
- }
499
- trackProp(e) {
500
- r(this, W).add(e);
501
- }
502
- getCurrentQuery() {
503
- return r(this, l);
504
- }
505
- refetch({ ...e } = {}) {
506
- return this.fetch({
507
- ...e
508
- });
509
- }
510
- fetchOptimistic(e) {
511
- const s = r(this, O).defaultQueryOptions(e), i = r(this, O).getQueryCache().build(r(this, O), s);
512
- return i.fetch().then(() => this.createResult(i, s));
513
- }
514
- fetch(e) {
515
- return R(this, f, G).call(this, {
516
- ...e,
517
- cancelRefetch: e.cancelRefetch ?? !0
518
- }).then(() => (this.updateResult(), r(this, S)));
519
- }
520
- createResult(e, s) {
521
- var Ee;
522
- const i = r(this, l), n = this.options, a = r(this, S), o = r(this, D), c = r(this, V), v = e !== i ? e.state : r(this, Z), { state: y } = e;
523
- let d = { ...y }, E = !1, m;
524
- if (s._optimisticResults) {
525
- const x = this.hasListeners(), te = !x && De(e, s), A = x && Ne(e, i, s, n);
526
- (te || A) && (d = {
527
- ...d,
528
- ...It(y.data, e.options)
529
- }), s._optimisticResults === "isRestoring" && (d.fetchStatus = "idle");
530
- }
531
- let { error: k, errorUpdatedAt: C, status: b } = d;
532
- m = d.data;
533
- let z = !1;
534
- if (s.placeholderData !== void 0 && m === void 0 && b === "pending") {
535
- let x;
536
- a != null && a.isPlaceholderData && s.placeholderData === (c == null ? void 0 : c.placeholderData) ? (x = a.data, z = !0) : x = typeof s.placeholderData == "function" ? s.placeholderData(
537
- (Ee = r(this, J)) == null ? void 0 : Ee.state.data,
538
- r(this, J)
539
- ) : s.placeholderData, x !== void 0 && (b = "success", m = ke(
540
- a == null ? void 0 : a.data,
541
- x,
542
- s
543
- ), E = !0);
544
- }
545
- if (s.select && m !== void 0 && !z)
546
- if (a && m === (o == null ? void 0 : o.data) && s.select === r(this, ee))
547
- m = r(this, $);
548
- else
549
- try {
550
- h(this, ee, s.select), m = s.select(m), m = ke(a == null ? void 0 : a.data, m, s), h(this, $, m), h(this, Q, null);
551
- } catch (x) {
552
- h(this, Q, x);
553
- }
554
- r(this, Q) && (k = r(this, Q), m = r(this, $), C = Date.now(), b = "error");
555
- const ie = d.fetchStatus === "fetching", ne = b === "pending", oe = b === "error", Se = ne && ie, Oe = m !== void 0, T = {
556
- status: b,
557
- fetchStatus: d.fetchStatus,
558
- isPending: ne,
559
- isSuccess: b === "success",
560
- isError: oe,
561
- isInitialLoading: Se,
562
- isLoading: Se,
563
- data: m,
564
- dataUpdatedAt: d.dataUpdatedAt,
565
- error: k,
566
- errorUpdatedAt: C,
567
- failureCount: d.fetchFailureCount,
568
- failureReason: d.fetchFailureReason,
569
- errorUpdateCount: d.errorUpdateCount,
570
- isFetched: d.dataUpdateCount > 0 || d.errorUpdateCount > 0,
571
- isFetchedAfterMount: d.dataUpdateCount > v.dataUpdateCount || d.errorUpdateCount > v.errorUpdateCount,
572
- isFetching: ie,
573
- isRefetching: ie && !ne,
574
- isLoadingError: oe && !Oe,
575
- isPaused: d.fetchStatus === "paused",
576
- isPlaceholderData: E,
577
- isRefetchError: oe && Oe,
578
- isStale: Ce(e, s),
579
- refetch: this.refetch,
580
- promise: r(this, L)
581
- };
582
- if (this.options.experimental_prefetchInRender) {
583
- const x = (se) => {
584
- T.status === "error" ? se.reject(T.error) : T.data !== void 0 && se.resolve(T.data);
585
- }, te = () => {
586
- const se = h(this, L, T.promise = qe());
587
- x(se);
588
- }, A = r(this, L);
589
- switch (A.status) {
590
- case "pending":
591
- e.queryHash === i.queryHash && x(A);
592
- break;
593
- case "fulfilled":
594
- (T.status === "error" || T.data !== A.value) && te();
595
- break;
596
- case "rejected":
597
- (T.status !== "error" || T.error !== A.reason) && te();
598
- break;
599
- }
600
- }
601
- return T;
602
- }
603
- updateResult() {
604
- const e = r(this, S), s = this.createResult(r(this, l), this.options);
605
- if (h(this, D, r(this, l).state), h(this, V, this.options), r(this, D).data !== void 0 && h(this, J, r(this, l)), le(s, e))
606
- return;
607
- h(this, S, s);
608
- const i = () => {
609
- if (!e)
610
- return !0;
611
- const { notifyOnChangeProps: n } = this.options, a = typeof n == "function" ? n() : n;
612
- if (a === "all" || !a && !r(this, W).size)
613
- return !0;
614
- const o = new Set(
615
- a ?? r(this, W)
616
- );
617
- return this.options.throwOnError && o.add("error"), Object.keys(r(this, S)).some((c) => {
618
- const u = c;
619
- return r(this, S)[u] !== e[u] && o.has(u);
620
- });
621
- };
622
- R(this, f, Ge).call(this, { listeners: i() });
623
- }
624
- onQueryUpdate() {
625
- this.updateResult(), this.hasListeners() && R(this, f, pe).call(this);
626
- }
627
- }, O = new WeakMap(), l = new WeakMap(), Z = new WeakMap(), S = new WeakMap(), D = new WeakMap(), V = new WeakMap(), L = new WeakMap(), Q = new WeakMap(), ee = new WeakMap(), $ = new WeakMap(), J = new WeakMap(), N = new WeakMap(), U = new WeakMap(), M = new WeakMap(), W = new WeakMap(), f = new WeakSet(), G = function(e) {
628
- R(this, f, me).call(this);
629
- let s = r(this, l).fetch(
630
- this.options,
631
- e
632
- );
633
- return e != null && e.throwOnError || (s = s.catch(ce)), s;
634
- }, he = function() {
635
- R(this, f, ge).call(this);
636
- const e = re(
637
- this.options.staleTime,
638
- r(this, l)
639
- );
640
- if (Y || r(this, S).isStale || !Ie(e))
641
- return;
642
- const i = Ct(r(this, S).dataUpdatedAt, e) + 1;
643
- h(this, N, setTimeout(() => {
644
- r(this, S).isStale || this.updateResult();
645
- }, i));
646
- }, fe = function() {
647
- return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(r(this, l)) : this.options.refetchInterval) ?? !1;
648
- }, de = function(e) {
649
- R(this, f, ye).call(this), h(this, M, e), !(Y || P(this.options.enabled, r(this, l)) === !1 || !Ie(r(this, M)) || r(this, M) === 0) && h(this, U, setInterval(() => {
650
- (this.options.refetchIntervalInBackground || Et.isFocused()) && R(this, f, G).call(this);
651
- }, r(this, M)));
652
- }, pe = function() {
653
- R(this, f, he).call(this), R(this, f, de).call(this, R(this, f, fe).call(this));
654
- }, ge = function() {
655
- r(this, N) && (clearTimeout(r(this, N)), h(this, N, void 0));
656
- }, ye = function() {
657
- r(this, U) && (clearInterval(r(this, U)), h(this, U, void 0));
658
- }, me = function() {
659
- const e = r(this, O).getQueryCache().build(r(this, O), this.options);
660
- if (e === r(this, l))
661
- return;
662
- const s = r(this, l);
663
- h(this, l, e), h(this, Z, e.state), this.hasListeners() && (s == null || s.removeObserver(this), e.addObserver(this));
664
- }, Ge = function(e) {
665
- We.batch(() => {
666
- e.listeners && this.listeners.forEach((s) => {
667
- s(r(this, S));
668
- }), r(this, O).getQueryCache().notify({
669
- query: r(this, l),
670
- type: "observerResultsUpdated"
671
- });
672
- });
673
- }, _e);
674
- function Qt(t, e) {
675
- return P(e.enabled, t) !== !1 && t.state.data === void 0 && !(t.state.status === "error" && e.retryOnMount === !1);
676
- }
677
- function De(t, e) {
678
- return Qt(t, e) || t.state.data !== void 0 && be(t, e, e.refetchOnMount);
679
- }
680
- function be(t, e, s) {
681
- if (P(e.enabled, t) !== !1) {
682
- const i = typeof s == "function" ? s(t) : s;
683
- return i === "always" || i !== !1 && Ce(t, e);
684
- }
685
- return !1;
686
- }
687
- function Ne(t, e, s, i) {
688
- return (t !== e || P(i.enabled, t) === !1) && (!s.suspense || t.state.status !== "error") && Ce(t, s);
689
- }
690
- function Ce(t, e) {
691
- return P(e.enabled, t) !== !1 && t.isStaleByTime(re(e.staleTime, t));
692
- }
693
- function Mt(t, e) {
694
- return !le(t.getCurrentResult(), e);
695
- }
696
- var kt = F.createContext(
697
- void 0
698
- ), qt = (t) => {
699
- const e = F.useContext(kt);
700
- if (!e)
701
- throw new Error("No QueryClient set, use QueryClientProvider to set one");
702
- return e;
703
- }, Ke = F.createContext(!1), Dt = () => F.useContext(Ke);
704
- Ke.Provider;
705
- function Nt() {
706
- let t = !1;
707
- return {
708
- clearReset: () => {
709
- t = !1;
710
- },
711
- reset: () => {
712
- t = !0;
713
- },
714
- isReset: () => t
715
- };
716
- }
717
- var Ut = F.createContext(Nt()), zt = () => F.useContext(Ut), At = (t, e) => {
718
- (t.suspense || t.throwOnError || t.experimental_prefetchInRender) && (e.isReset() || (t.retryOnMount = !1));
719
- }, _t = (t) => {
720
- F.useEffect(() => {
721
- t.clearReset();
722
- }, [t]);
723
- }, Bt = ({
724
- result: t,
725
- errorResetBoundary: e,
726
- throwOnError: s,
727
- query: i,
728
- suspense: n
729
- }) => t.isError && !e.isReset() && !t.isFetching && i && (n && t.data === void 0 || St(s, [t.error, i])), Ht = (t) => {
730
- const e = t.staleTime;
731
- t.suspense && (t.staleTime = typeof e == "function" ? (...s) => Math.max(e(...s), 1e3) : Math.max(e ?? 1e3, 1e3), typeof t.gcTime == "number" && (t.gcTime = Math.max(t.gcTime, 1e3)));
732
- }, Vt = (t, e) => t.isLoading && t.isFetching && !e, $t = (t, e) => (t == null ? void 0 : t.suspense) && e.isPending, Ue = (t, e, s) => e.fetchOptimistic(t).catch(() => {
733
- s.clearReset();
734
- });
735
- function Jt(t, e, s) {
736
- var d, E, m, k, C;
737
- if (process.env.NODE_ENV !== "production" && (typeof t != "object" || Array.isArray(t)))
738
- throw new Error(
739
- 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
740
- );
741
- const i = qt(), n = Dt(), a = zt(), o = i.defaultQueryOptions(t);
742
- (E = (d = i.getDefaultOptions().queries) == null ? void 0 : d._experimental_beforeQuery) == null || E.call(
743
- d,
744
- o
745
- ), process.env.NODE_ENV !== "production" && (o.queryFn || console.error(
746
- `[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
747
- )), o._optimisticResults = n ? "isRestoring" : "optimistic", Ht(o), At(o, a), _t(a);
748
- const c = !i.getQueryCache().get(o.queryHash), [u] = F.useState(
749
- () => new e(
750
- i,
751
- o
752
- )
753
- ), v = u.getOptimisticResult(o), y = !n && t.subscribed !== !1;
754
- if (F.useSyncExternalStore(
755
- F.useCallback(
756
- (b) => {
757
- const z = y ? u.subscribe(We.batchCalls(b)) : ce;
758
- return u.updateResult(), z;
759
- },
760
- [u, y]
761
- ),
762
- () => u.getCurrentResult(),
763
- () => u.getCurrentResult()
764
- ), F.useEffect(() => {
765
- u.setOptions(o);
766
- }, [o, u]), $t(o, v))
767
- throw Ue(o, u, a);
768
- if (Bt({
769
- result: v,
770
- errorResetBoundary: a,
771
- throwOnError: o.throwOnError,
772
- query: i.getQueryCache().get(o.queryHash),
773
- suspense: o.suspense
774
- }))
775
- throw v.error;
776
- if ((k = (m = i.getDefaultOptions().queries) == null ? void 0 : m._experimental_afterQuery) == null || k.call(
777
- m,
778
- o,
779
- v
780
- ), o.experimental_prefetchInRender && !Y && Vt(v, n)) {
781
- const b = c ? (
782
- // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
783
- Ue(o, u, a)
784
- ) : (
785
- // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
786
- (C = i.getQueryCache().get(o.queryHash)) == null ? void 0 : C.promise
787
- );
788
- b == null || b.catch(ce).finally(() => {
789
- u.updateResult();
790
- });
791
- }
792
- return o.notifyOnChangeProps ? v : u.trackResult(v);
793
- }
794
- function Wt(t, e) {
795
- return Jt(t, Lt);
796
- }
797
- const Gt = ({
798
- nombre: t,
799
- elevation: e = 1,
800
- api: s,
801
- filtros: i,
802
- titulo: n,
803
- initialPageSize: a = 10,
804
- children: o
149
+ const ae = ({
150
+ nombre: n,
151
+ elevation: i = 1,
152
+ api: a,
153
+ filtros: o,
154
+ titulo: e,
155
+ initialPageSize: m = 10,
156
+ children: s
805
157
  }) => {
806
- const c = Re(), [u, v] = Be({
158
+ const g = C(), [l, y] = v({
807
159
  page: 0,
808
- pageSize: a
160
+ pageSize: m
809
161
  });
810
- ve(() => {
811
- v((C) => ({
812
- ...C,
162
+ b(() => {
163
+ y((c) => ({
164
+ ...c,
813
165
  page: 0
814
166
  }));
815
- }, [JSON.stringify(i)]);
816
- const { isLoading: y, isError: d, data: E } = Wt({
817
- queryKey: [`paginable-${t}`, u, i],
818
- queryFn: () => s(i, u.page, u.pageSize),
167
+ }, [JSON.stringify(o)]);
168
+ const { isLoading: h, isError: k, data: u } = ie({
169
+ queryKey: [`paginable-${n}`, l, o],
170
+ queryFn: () => a(o, l.page, l.pageSize),
819
171
  keepPreviousData: !0
820
172
  });
821
- if (y)
822
- return /* @__PURE__ */ g(ht, { children: Array.from(Array(a).keys()).map((C) => /* @__PURE__ */ g(ft, { children: /* @__PURE__ */ g(dt, { primary: /* @__PURE__ */ g(pt, {}) }) }, `row-${C}`)) });
823
- if (d)
824
- return /* @__PURE__ */ K(Fe, { children: [
825
- /* @__PURE__ */ g(Te, { titulo: c(n) }),
826
- /* @__PURE__ */ g(Pe, { children: /* @__PURE__ */ g(Je, { titulo: "error.carga" }) })
173
+ if (h)
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 (k)
176
+ return /* @__PURE__ */ d(P, { children: [
177
+ /* @__PURE__ */ r(S, { titulo: g(e) }),
178
+ /* @__PURE__ */ r(T, { children: /* @__PURE__ */ r(w, { titulo: "error.carga" }) })
827
179
  ] });
828
- const m = (C, b) => {
829
- y || b === u.page || v({
830
- page: b,
831
- pageSize: u.pageSize
180
+ const q = (c, p) => {
181
+ h || p === l.page || y({
182
+ page: p,
183
+ pageSize: l.pageSize
832
184
  });
833
- }, k = (C) => {
834
- const b = C.target.value;
835
- y || b === u.pageSize || v({
185
+ }, N = (c) => {
186
+ const p = c.target.value;
187
+ h || p === l.pageSize || y({
836
188
  page: 0,
837
- pageSize: b
189
+ pageSize: p
838
190
  });
839
191
  };
840
- return /* @__PURE__ */ K(Fe, { elevation: e, children: [
841
- n && /* @__PURE__ */ g(Te, { titulo: c(n) }),
842
- /* @__PURE__ */ g(Pe, { children: y ? /* @__PURE__ */ g(gt, {}) : E && E.content.length > 0 ? tt.map(o, (C) => st(C, {
843
- data: E.content
844
- })) : /* @__PURE__ */ g(yt, { children: c("main.pageable.noResults") }) }),
845
- E && E.totalElements > 0 && /* @__PURE__ */ g(mt, { sx: { justifyContent: "flex-end" }, children: /* @__PURE__ */ g(
846
- bt,
192
+ return /* @__PURE__ */ d(P, { elevation: i, children: [
193
+ e && /* @__PURE__ */ r(S, { titulo: g(e) }),
194
+ /* @__PURE__ */ r(T, { children: h ? /* @__PURE__ */ r(Y, {}) : u && u.content.length > 0 ? L.map(s, (c) => O(c, {
195
+ data: u.content
196
+ })) : /* @__PURE__ */ r(Z, { children: g("main.pageable.noResults") }) }),
197
+ u && u.totalElements > 0 && /* @__PURE__ */ r(_, { sx: { justifyContent: "flex-end" }, children: /* @__PURE__ */ r(
198
+ ee,
847
199
  {
848
200
  component: "div",
849
- count: E.totalElements,
850
- page: u.page,
851
- rowsPerPage: u.pageSize,
852
- labelRowsPerPage: c("main.pageable.rows"),
853
- labelDisplayedRows: ({ from: C, to: b, count: z }) => c("main.pageable.results", { inicial: C, final: b, total: z }),
201
+ count: u.totalElements,
202
+ page: l.page,
203
+ rowsPerPage: l.pageSize,
204
+ labelRowsPerPage: g("main.pageable.rows"),
205
+ labelDisplayedRows: ({ from: c, to: p, count: A }) => g("main.pageable.results", { inicial: c, final: p, total: A }),
854
206
  rowsPerPageOptions: [5, 10, 15, 20, 25, 50],
855
- onRowsPerPageChange: k,
856
- onPageChange: m
207
+ onRowsPerPageChange: N,
208
+ onPageChange: q
857
209
  }
858
210
  ) })
859
211
  ] });
860
212
  };
861
- Gt.propTypes = {
862
- nombre: w.string.isRequired,
863
- elevation: w.number,
864
- api: w.func.isRequired,
865
- filtros: w.object,
866
- titulo: w.string,
867
- initialPageSize: w.number,
868
- children: w.element
213
+ ae.propTypes = {
214
+ nombre: t.string.isRequired,
215
+ elevation: t.number,
216
+ api: t.func.isRequired,
217
+ filtros: t.object,
218
+ titulo: t.string,
219
+ initialPageSize: t.number,
220
+ children: t.element
869
221
  };
870
- const as = () => {
871
- const t = X((e) => e.mostrarNotificacion);
872
- return rt((e, s = "default", i = { vertical: "botton", horizontal: "center" }) => {
873
- t({ mensaje: e, tipo: s, posicion: i });
874
- }, [t]);
222
+ const he = () => {
223
+ const n = f((i) => i.mostrarNotificacion);
224
+ return B((i, a = "default", o = { vertical: "botton", horizontal: "center" }) => {
225
+ n({ mensaje: i, tipo: a, posicion: o });
226
+ }, [n]);
875
227
  };
876
228
  export {
877
- os as Cargando,
878
- Je as Mensaje,
879
- wt as MuiApp,
880
- Gt as Paginable,
881
- X as useMuiStore,
882
- as as useNotificar
229
+ fe as Cargando,
230
+ w as Mensaje,
231
+ te as MuiApp,
232
+ ae as Paginable,
233
+ f as useMuiStore,
234
+ he as useNotificar
883
235
  };
@@ -1 +1 @@
1
- (function(h,o){typeof exports=="object"&&typeof module<"u"?o(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")):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"],o):(h=typeof globalThis<"u"?globalThis:h||self,o(h["mui-saas"]={},h.ReactJSX,h.PropTypes,h.ReactSaas,h.React,h.MuiMaterial,h.MuiMaterialColors,h.Zustand,h.ReactPolyglot))})(this,function(h,o,p,Y,I,y,xe,Ge,ae){"use strict";var Je=h=>{throw TypeError(h)};var ve=(h,o,p)=>o.has(h)||Je("Cannot "+p);var r=(h,o,p)=>(ve(h,o,"read from private field"),p?p.call(h):o.get(h)),v=(h,o,p)=>o.has(h)?Je("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(h):o.set(h,p),d=(h,o,p,Y)=>(ve(h,o,"write to private field"),Y?Y.call(h,p):o.set(h,p),p),O=(h,o,p)=>(ve(h,o,"access private method"),p);var P,T,H,Ae,V,Q,$,_e,x,f,te,j,z,J,k,D,se,W,G,U,A,N,K,g,re,me,Ce,Se,we,Oe,Ee,je,We,Be;function Ke(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const M=Ke(I),B=Ge.create(t=>({tema:"light",notificaciones:[],cambiarTema:e=>{t({tema:e})},mostrarNotificacion:e=>{t(s=>({notificaciones:[e,...s.notificaciones]}))},ocultarNotificacion:()=>{t(e=>({notificaciones:e.notificaciones.slice(1)}))}})),Fe=({children:t})=>{const e=B(a=>a.cambiarTema),s=y.useMediaQuery("(prefers-color-scheme: dark)"),i=B(a=>a.tema),n=Y.useSaasStore(a=>a.instancia);I.useEffect(()=>{e(s?"dark":"light")},[e,s]);const c=I.useMemo(()=>y.createTheme({palette:{mode:i,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},...i==="light"&&{background:{default:xe.grey.A200,paper:xe.grey[100]}}},shape:{borderRadius:6}}),[i,n]);return o.jsxs(y.ThemeProvider,{theme:c,children:[o.jsx(y.CssBaseline,{}),t]})};Fe.propTypes={children:p.element.isRequired};const Xe=()=>{const t=ae.useTranslate(),[e,s]=I.useState(!1),i=B(a=>a.ocultarNotificacion),n=B(a=>a.notificaciones[0]);I.useEffect(()=>{s(!!n)},[n]);const c=()=>{s(!1),i()};return o.jsx(y.Snackbar,{open:e,message:n?n.tipo==="default"&&t(n==null?void 0:n.mensaje):null,autoHideDuration:5e3,onClose:c,anchorOrigin:n&&{vertical:n==null?void 0:n.posicion.vertical,horizontal:n==null?void 0:n.posicion.horizontal},children:n&&(n==null?void 0:n.tipo)!=="default"&&o.jsx(y.Alert,{severity:n.tipo,children:t(n.mensaje)})})},Re=({aplicacion:t,dev:e=!1,redirectUri:s,mensajes:i={en:{},es:{}},children:n})=>o.jsx(Y.SaasApp,{aplicacion:t,dev:e,redirectUri:s,mensajes:i,children:o.jsx(Fe,{children:o.jsxs(o.Fragment,{children:[n,o.jsx(Xe,{})]})})});Re.propTypes={aplicacion:p.string.isRequired,dev:p.bool,redirectUri:p.string.isRequired,mensajes:p.object,children:p.element.isRequired};const Ze=()=>o.jsx(y.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center"},children:o.jsx(y.CircularProgress,{})}),ce=({titulo:t,texto:e,align:s="center",severity:i="error"})=>{const n=ae.useTranslate();return o.jsx(y.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:s},children:o.jsxs(y.Alert,{severity:i,children:[o.jsx(y.AlertTitle,{children:n(t)}),e&&n(e)]})})};ce.propTypes={titulo:p.string.isRequired,texto:p.string,align:p.string,severity:p.string};var ue=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ee=typeof window>"u"||"Deno"in globalThis;function he(){}function Me(t){return typeof t=="number"&&t>=0&&t!==1/0}function Ye(t,e){return Math.max(t+(e||0)-Date.now(),0)}function ie(t,e){return typeof t=="function"?t(e):t}function q(t,e){return typeof t=="function"?t(e):t}function le(t,e){if(t===e)return t;const s=Ie(t)&&Ie(e);if(s||qe(t)&&qe(e)){const i=s?t:Object.keys(t),n=i.length,c=s?e:Object.keys(e),a=c.length,u=s?[]:{};let l=0;for(let w=0;w<a;w++){const m=s?w:c[w];(!s&&i.includes(m)||s)&&t[m]===void 0&&e[m]===void 0?(u[m]=void 0,l++):(u[m]=le(t[m],e[m]),u[m]===t[m]&&t[m]!==void 0&&l++)}return n===a&&l===n?t:u}return e}function fe(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}function Ie(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function qe(t){if(!Le(t))return!1;const e=t.constructor;if(e===void 0)return!0;const s=e.prototype;return!(!Le(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Le(t){return Object.prototype.toString.call(t)==="[object Object]"}function Te(t,e,s){if(typeof s.structuralSharing=="function")return s.structuralSharing(t,e);if(s.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return le(t,e)}catch(i){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${i}`),i}return le(t,e)}return e}function et(t,e){return typeof t=="function"?t(...e):!!t}var tt=(Ae=class extends ue{constructor(){super();v(this,P);v(this,T);v(this,H);d(this,H,e=>{if(!ee&&window.addEventListener){const s=()=>e();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){r(this,T)||this.setEventListener(r(this,H))}onUnsubscribe(){var e;this.hasListeners()||((e=r(this,T))==null||e.call(this),d(this,T,void 0))}setEventListener(e){var s;d(this,H,e),(s=r(this,T))==null||s.call(this),d(this,T,e(i=>{typeof i=="boolean"?this.setFocused(i):this.onFocus()}))}setFocused(e){r(this,P)!==e&&(d(this,P,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(s=>{s(e)})}isFocused(){var e;return typeof r(this,P)=="boolean"?r(this,P):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},P=new WeakMap,T=new WeakMap,H=new WeakMap,Ae),st=new tt,rt=(_e=class extends ue{constructor(){super();v(this,V,!0);v(this,Q);v(this,$);d(this,$,e=>{if(!ee&&window.addEventListener){const s=()=>e(!0),i=()=>e(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",i,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",i)}}})}onSubscribe(){r(this,Q)||this.setEventListener(r(this,$))}onUnsubscribe(){var e;this.hasListeners()||((e=r(this,Q))==null||e.call(this),d(this,Q,void 0))}setEventListener(e){var s;d(this,$,e),(s=r(this,Q))==null||s.call(this),d(this,Q,e(this.setOnline.bind(this)))}setOnline(e){r(this,V)!==e&&(d(this,V,e),this.listeners.forEach(i=>{i(e)}))}isOnline(){return r(this,V)}},V=new WeakMap,Q=new WeakMap,$=new WeakMap,_e),it=new rt;function Qe(){let t,e;const s=new Promise((n,c)=>{t=n,e=c});s.status="pending",s.catch(()=>{});function i(n){Object.assign(s,n),delete s.resolve,delete s.reject}return s.resolve=n=>{i({status:"fulfilled",value:n}),t(n)},s.reject=n=>{i({status:"rejected",reason:n}),e(n)},s}function nt(t){return(t??"online")==="online"?it.isOnline():!0}var ot=t=>setTimeout(t,0);function at(){let t=[],e=0,s=u=>{u()},i=u=>{u()},n=ot;const c=u=>{e?t.push(u):n(()=>{s(u)})},a=()=>{const u=t;t=[],u.length&&n(()=>{i(()=>{u.forEach(l=>{s(l)})})})};return{batch:u=>{let l;e++;try{l=u()}finally{e--,e||a()}return l},batchCalls:u=>(...l)=>{c(()=>{u(...l)})},schedule:c,setNotifyFunction:u=>{s=u},setBatchNotifyFunction:u=>{i=u},setScheduler:u=>{n=u}}}var ke=at();function ct(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:nt(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}var ut=(Be=class extends ue{constructor(e,s){super();v(this,g);v(this,x);v(this,f);v(this,te);v(this,j);v(this,z);v(this,J);v(this,k);v(this,D);v(this,se);v(this,W);v(this,G);v(this,U);v(this,A);v(this,N);v(this,K,new Set);this.options=s,d(this,x,e),d(this,D,null),d(this,k,Qe()),this.options.experimental_prefetchInRender||r(this,k).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(r(this,f).addObserver(this),De(r(this,f),this.options)?O(this,g,re).call(this):this.updateResult(),O(this,g,we).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return de(r(this,f),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return de(r(this,f),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,O(this,g,Oe).call(this),O(this,g,Ee).call(this),r(this,f).removeObserver(this)}setOptions(e){const s=this.options,i=r(this,f);if(this.options=r(this,x).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof q(this.options.enabled,r(this,f))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");O(this,g,je).call(this),r(this,f).setOptions(this.options),s._defaulted&&!fe(this.options,s)&&r(this,x).getQueryCache().notify({type:"observerOptionsUpdated",query:r(this,f),observer:this});const n=this.hasListeners();n&&Ne(r(this,f),i,this.options,s)&&O(this,g,re).call(this),this.updateResult(),n&&(r(this,f)!==i||q(this.options.enabled,r(this,f))!==q(s.enabled,r(this,f))||ie(this.options.staleTime,r(this,f))!==ie(s.staleTime,r(this,f)))&&O(this,g,me).call(this);const c=O(this,g,Ce).call(this);n&&(r(this,f)!==i||q(this.options.enabled,r(this,f))!==q(s.enabled,r(this,f))||c!==r(this,N))&&O(this,g,Se).call(this,c)}getOptimisticResult(e){const s=r(this,x).getQueryCache().build(r(this,x),e),i=this.createResult(s,e);return lt(this,i)&&(d(this,j,i),d(this,J,this.options),d(this,z,r(this,f).state)),i}getCurrentResult(){return r(this,j)}trackResult(e,s){return new Proxy(e,{get:(i,n)=>(this.trackProp(n),s==null||s(n),Reflect.get(i,n))})}trackProp(e){r(this,K).add(e)}getCurrentQuery(){return r(this,f)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const s=r(this,x).defaultQueryOptions(e),i=r(this,x).getQueryCache().build(r(this,x),s);return i.fetch().then(()=>this.createResult(i,s))}fetch(e){return O(this,g,re).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),r(this,j)))}createResult(e,s){var $e;const i=r(this,f),n=this.options,c=r(this,j),a=r(this,z),u=r(this,J),w=e!==i?e.state:r(this,te),{state:m}=e;let b={...m},F=!1,C;if(s._optimisticResults){const R=this.hasListeners(),ne=!R&&De(e,s),Z=R&&Ne(e,i,s,n);(ne||Z)&&(b={...b,...ct(m.data,e.options)}),s._optimisticResults==="isRestoring"&&(b.fetchStatus="idle")}let{error:_,errorUpdatedAt:E,status:S}=b;C=b.data;let X=!1;if(s.placeholderData!==void 0&&C===void 0&&S==="pending"){let R;c!=null&&c.isPlaceholderData&&s.placeholderData===(u==null?void 0:u.placeholderData)?(R=c.data,X=!0):R=typeof s.placeholderData=="function"?s.placeholderData(($e=r(this,G))==null?void 0:$e.state.data,r(this,G)):s.placeholderData,R!==void 0&&(S="success",C=Te(c==null?void 0:c.data,R,s),F=!0)}if(s.select&&C!==void 0&&!X)if(c&&C===(a==null?void 0:a.data)&&s.select===r(this,se))C=r(this,W);else try{d(this,se,s.select),C=s.select(C),C=Te(c==null?void 0:c.data,C,s),d(this,W,C),d(this,D,null)}catch(R){d(this,D,R)}r(this,D)&&(_=r(this,D),C=r(this,W),E=Date.now(),S="error");const ge=b.fetchStatus==="fetching",ye=S==="pending",be=S==="error",He=ye&&ge,Ve=C!==void 0,L={status:S,fetchStatus:b.fetchStatus,isPending:ye,isSuccess:S==="success",isError:be,isInitialLoading:He,isLoading:He,data:C,dataUpdatedAt:b.dataUpdatedAt,error:_,errorUpdatedAt:E,failureCount:b.fetchFailureCount,failureReason:b.fetchFailureReason,errorUpdateCount:b.errorUpdateCount,isFetched:b.dataUpdateCount>0||b.errorUpdateCount>0,isFetchedAfterMount:b.dataUpdateCount>w.dataUpdateCount||b.errorUpdateCount>w.errorUpdateCount,isFetching:ge,isRefetching:ge&&!ye,isLoadingError:be&&!Ve,isPaused:b.fetchStatus==="paused",isPlaceholderData:F,isRefetchError:be&&Ve,isStale:pe(e,s),refetch:this.refetch,promise:r(this,k)};if(this.options.experimental_prefetchInRender){const R=oe=>{L.status==="error"?oe.reject(L.error):L.data!==void 0&&oe.resolve(L.data)},ne=()=>{const oe=d(this,k,L.promise=Qe());R(oe)},Z=r(this,k);switch(Z.status){case"pending":e.queryHash===i.queryHash&&R(Z);break;case"fulfilled":(L.status==="error"||L.data!==Z.value)&&ne();break;case"rejected":(L.status!=="error"||L.error!==Z.reason)&&ne();break}}return L}updateResult(){const e=r(this,j),s=this.createResult(r(this,f),this.options);if(d(this,z,r(this,f).state),d(this,J,this.options),r(this,z).data!==void 0&&d(this,G,r(this,f)),fe(s,e))return;d(this,j,s);const i=()=>{if(!e)return!0;const{notifyOnChangeProps:n}=this.options,c=typeof n=="function"?n():n;if(c==="all"||!c&&!r(this,K).size)return!0;const a=new Set(c??r(this,K));return this.options.throwOnError&&a.add("error"),Object.keys(r(this,j)).some(u=>{const l=u;return r(this,j)[l]!==e[l]&&a.has(l)})};O(this,g,We).call(this,{listeners:i()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&O(this,g,we).call(this)}},x=new WeakMap,f=new WeakMap,te=new WeakMap,j=new WeakMap,z=new WeakMap,J=new WeakMap,k=new WeakMap,D=new WeakMap,se=new WeakMap,W=new WeakMap,G=new WeakMap,U=new WeakMap,A=new WeakMap,N=new WeakMap,K=new WeakMap,g=new WeakSet,re=function(e){O(this,g,je).call(this);let s=r(this,f).fetch(this.options,e);return e!=null&&e.throwOnError||(s=s.catch(he)),s},me=function(){O(this,g,Oe).call(this);const e=ie(this.options.staleTime,r(this,f));if(ee||r(this,j).isStale||!Me(e))return;const i=Ye(r(this,j).dataUpdatedAt,e)+1;d(this,U,setTimeout(()=>{r(this,j).isStale||this.updateResult()},i))},Ce=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(r(this,f)):this.options.refetchInterval)??!1},Se=function(e){O(this,g,Ee).call(this),d(this,N,e),!(ee||q(this.options.enabled,r(this,f))===!1||!Me(r(this,N))||r(this,N)===0)&&d(this,A,setInterval(()=>{(this.options.refetchIntervalInBackground||st.isFocused())&&O(this,g,re).call(this)},r(this,N)))},we=function(){O(this,g,me).call(this),O(this,g,Se).call(this,O(this,g,Ce).call(this))},Oe=function(){r(this,U)&&(clearTimeout(r(this,U)),d(this,U,void 0))},Ee=function(){r(this,A)&&(clearInterval(r(this,A)),d(this,A,void 0))},je=function(){const e=r(this,x).getQueryCache().build(r(this,x),this.options);if(e===r(this,f))return;const s=r(this,f);d(this,f,e),d(this,te,e.state),this.hasListeners()&&(s==null||s.removeObserver(this),e.addObserver(this))},We=function(e){ke.batch(()=>{e.listeners&&this.listeners.forEach(s=>{s(r(this,j))}),r(this,x).getQueryCache().notify({query:r(this,f),type:"observerResultsUpdated"})})},Be);function ht(t,e){return q(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function De(t,e){return ht(t,e)||t.state.data!==void 0&&de(t,e,e.refetchOnMount)}function de(t,e,s){if(q(e.enabled,t)!==!1){const i=typeof s=="function"?s(t):s;return i==="always"||i!==!1&&pe(t,e)}return!1}function Ne(t,e,s,i){return(t!==e||q(i.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&pe(t,s)}function pe(t,e){return q(e.enabled,t)!==!1&&t.isStaleByTime(ie(e.staleTime,t))}function lt(t,e){return!fe(t.getCurrentResult(),e)}var ft=M.createContext(void 0),dt=t=>{const e=M.useContext(ft);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Pe=M.createContext(!1),pt=()=>M.useContext(Pe);Pe.Provider;function gt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var yt=M.createContext(gt()),bt=()=>M.useContext(yt),vt=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},mt=t=>{M.useEffect(()=>{t.clearReset()},[t])},Ct=({result:t,errorResetBoundary:e,throwOnError:s,query:i,suspense:n})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(n&&t.data===void 0||et(s,[t.error,i])),St=t=>{const e=t.staleTime;t.suspense&&(t.staleTime=typeof e=="function"?(...s)=>Math.max(e(...s),1e3):Math.max(e??1e3,1e3),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3)))},wt=(t,e)=>t.isLoading&&t.isFetching&&!e,Ot=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,ze=(t,e,s)=>e.fetchOptimistic(t).catch(()=>{s.clearReset()});function Et(t,e,s){var b,F,C,_,E;if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const i=dt(),n=pt(),c=bt(),a=i.defaultQueryOptions(t);(F=(b=i.getDefaultOptions().queries)==null?void 0:b._experimental_beforeQuery)==null||F.call(b,a),process.env.NODE_ENV!=="production"&&(a.queryFn||console.error(`[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),a._optimisticResults=n?"isRestoring":"optimistic",St(a),vt(a,c),mt(c);const u=!i.getQueryCache().get(a.queryHash),[l]=M.useState(()=>new e(i,a)),w=l.getOptimisticResult(a),m=!n&&t.subscribed!==!1;if(M.useSyncExternalStore(M.useCallback(S=>{const X=m?l.subscribe(ke.batchCalls(S)):he;return l.updateResult(),X},[l,m]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),M.useEffect(()=>{l.setOptions(a)},[a,l]),Ot(a,w))throw ze(a,l,c);if(Ct({result:w,errorResetBoundary:c,throwOnError:a.throwOnError,query:i.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw w.error;if((_=(C=i.getDefaultOptions().queries)==null?void 0:C._experimental_afterQuery)==null||_.call(C,a,w),a.experimental_prefetchInRender&&!ee&&wt(w,n)){const S=u?ze(a,l,c):(E=i.getQueryCache().get(a.queryHash))==null?void 0:E.promise;S==null||S.catch(he).finally(()=>{l.updateResult()})}return a.notifyOnChangeProps?w:l.trackResult(w)}function jt(t,e){return Et(t,ut)}const Ue=({nombre:t,elevation:e=1,api:s,filtros:i,titulo:n,initialPageSize:c=10,children:a})=>{const u=ae.useTranslate(),[l,w]=I.useState({page:0,pageSize:c});I.useEffect(()=>{w(E=>({...E,page:0}))},[JSON.stringify(i)]);const{isLoading:m,isError:b,data:F}=jt({queryKey:[`paginable-${t}`,l,i],queryFn:()=>s(i,l.page,l.pageSize),keepPreviousData:!0});if(m)return o.jsx(y.List,{children:Array.from(Array(c).keys()).map(E=>o.jsx(y.ListItem,{children:o.jsx(y.ListItemText,{primary:o.jsx(y.Skeleton,{})})},`row-${E}`))});if(b)return o.jsxs(y.Card,{children:[o.jsx(y.CardHeader,{titulo:u(n)}),o.jsx(y.CardContent,{children:o.jsx(ce,{titulo:"error.carga"})})]});const C=(E,S)=>{m||S===l.page||w({page:S,pageSize:l.pageSize})},_=E=>{const S=E.target.value;m||S===l.pageSize||w({page:0,pageSize:S})};return o.jsxs(y.Card,{elevation:e,children:[n&&o.jsx(y.CardHeader,{titulo:u(n)}),o.jsx(y.CardContent,{children:m?o.jsx(y.LinearProgress,{}):F&&F.content.length>0?I.Children.map(a,E=>I.cloneElement(E,{data:F.content})):o.jsx(y.Typography,{children:u("main.pageable.noResults")})}),F&&F.totalElements>0&&o.jsx(y.CardActions,{sx:{justifyContent:"flex-end"},children:o.jsx(y.TablePagination,{component:"div",count:F.totalElements,page:l.page,rowsPerPage:l.pageSize,labelRowsPerPage:u("main.pageable.rows"),labelDisplayedRows:({from:E,to:S,count:X})=>u("main.pageable.results",{inicial:E,final:S,total:X}),rowsPerPageOptions:[5,10,15,20,25,50],onRowsPerPageChange:_,onPageChange:C})})]})};Ue.propTypes={nombre:p.string.isRequired,elevation:p.number,api:p.func.isRequired,filtros:p.object,titulo:p.string,initialPageSize:p.number,children:p.element};const xt=()=>{const t=B(e=>e.mostrarNotificacion);return I.useCallback((e,s="default",i={vertical:"botton",horizontal:"center"})=>{t({mensaje:e,tipo:s,posicion:i})},[t])};h.Cargando=Ze,h.Mensaje=ce,h.MuiApp=Re,h.Paginable=Ue,h.useMuiStore=B,h.useNotificar=xt,Object.defineProperty(h,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,j,u,n,M,k,q,w){"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 A=()=>{const s=q.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(A,{})]})})});z.propTypes={aplicacion:t.string.isRequired,dev:t.bool,redirectUri:t.string.isRequired,mensajes:t.object,children:t.element.isRequired};const N=()=>r.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",flexGrow:1,justifyContent:"center",alignItems:"center"},children:r.jsx(n.CircularProgress,{})}),m=({titulo:s,texto:i,align:o="center",severity:c="error"})=>{const e=q.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)]})})};m.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=q.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}=w.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(m,{titulo:"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.pageable.noResults")})}),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.pageable.rows"),labelDisplayedRows:({from:d,to:f,count:O})=>C("main.pageable.results",{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=N,a.Mensaje=m,a.MuiApp=z,a.Paginable=x,a.useMuiStore=p,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.3",
4
+ "version": "3.0.4",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",