@chimera-pe/react-saas 3.0.5 → 3.0.6
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/react-saas.js +92 -96
- package/dist/react-saas.umd.cjs +1 -1
- package/package.json +11 -11
package/dist/react-saas.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as p, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import o from "prop-types";
|
|
3
3
|
import { useEffect as g, useContext as x } from "react";
|
|
4
4
|
import { AuthProvider as w, AuthContext as A } from "react-oauth2-code-pkce";
|
|
5
5
|
import { create as f } from "zustand";
|
|
6
6
|
import { useTranslate as h, I18n as C } from "react-polyglot";
|
|
7
7
|
import { union as I } from "lodash";
|
|
8
|
-
import
|
|
9
|
-
const O = "https://saas.chimera.com.pe/backend",
|
|
8
|
+
import q from "navigator-languages";
|
|
9
|
+
const O = "https://saas.chimera.com.pe/backend", E = "https://saas.chimera.com.pe/v3", R = "http://localhost:7000", T = "http://localhost:7777", u = {
|
|
10
10
|
primary: "#1C6CCC",
|
|
11
11
|
secondary: "#17A7FF",
|
|
12
12
|
info: "#2196f3",
|
|
@@ -24,10 +24,11 @@ const O = "https://saas.chimera.com.pe/backend", R = "https://saas.chimera.com.p
|
|
|
24
24
|
nombre: null,
|
|
25
25
|
abreviatura: null,
|
|
26
26
|
requiereLogin: !1,
|
|
27
|
+
redirectUri: null,
|
|
27
28
|
logo: null,
|
|
28
29
|
color: u
|
|
29
30
|
},
|
|
30
|
-
inicializar: async (
|
|
31
|
+
inicializar: async (r, i) => {
|
|
31
32
|
e({
|
|
32
33
|
estado: {
|
|
33
34
|
inicializando: !0,
|
|
@@ -35,10 +36,10 @@ const O = "https://saas.chimera.com.pe/backend", R = "https://saas.chimera.com.p
|
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
38
|
try {
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
40
|
-
throw new Error(`inicializar.error.${
|
|
41
|
-
const
|
|
39
|
+
const n = await fetch(`${r || O}/identidad/?codigoAplicacion=${i}`);
|
|
40
|
+
if (!n.ok)
|
|
41
|
+
throw new Error(`inicializar.error.${n.status}`);
|
|
42
|
+
const t = await n.json();
|
|
42
43
|
e({
|
|
43
44
|
inicializado: !0,
|
|
44
45
|
estado: {
|
|
@@ -46,29 +47,31 @@ const O = "https://saas.chimera.com.pe/backend", R = "https://saas.chimera.com.p
|
|
|
46
47
|
error: null
|
|
47
48
|
},
|
|
48
49
|
instancia: {
|
|
49
|
-
identificador:
|
|
50
|
-
nombre:
|
|
51
|
-
abreviatura:
|
|
52
|
-
requiereLogin:
|
|
53
|
-
|
|
50
|
+
identificador: t.identificador,
|
|
51
|
+
nombre: t.nombre,
|
|
52
|
+
abreviatura: t.nombre.match(/\b([A-Z])/g).join(""),
|
|
53
|
+
requiereLogin: t.requiereLogin,
|
|
54
|
+
redirectUri: t.redirectUri,
|
|
55
|
+
logo: t.logo,
|
|
54
56
|
color: {
|
|
55
57
|
...u,
|
|
56
|
-
...
|
|
58
|
+
...t.color
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
});
|
|
60
|
-
} catch (
|
|
62
|
+
} catch (n) {
|
|
61
63
|
e({
|
|
62
64
|
inicializado: !1,
|
|
63
65
|
estado: {
|
|
64
66
|
inicializando: !1,
|
|
65
|
-
error:
|
|
67
|
+
error: n.message
|
|
66
68
|
},
|
|
67
69
|
instancia: {
|
|
68
70
|
identificador: null,
|
|
69
71
|
nombre: null,
|
|
70
72
|
abreviatura: null,
|
|
71
73
|
requiereLogin: !1,
|
|
74
|
+
redirectUri: null,
|
|
72
75
|
logo: null,
|
|
73
76
|
color: u
|
|
74
77
|
}
|
|
@@ -77,7 +80,7 @@ const O = "https://saas.chimera.com.pe/backend", R = "https://saas.chimera.com.p
|
|
|
77
80
|
}
|
|
78
81
|
})), L = "data:image/svg+xml,%3csvg%20width='24'%20height='24'%20stroke='%23000'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3cstyle%3e.spinner_V8m1{transform-origin:center;animation:spinner_zKoa%202s%20linear%20infinite}.spinner_V8m1%20circle{stroke-linecap:round;animation:spinner_YpZS%201.5s%20ease-in-out%20infinite}@keyframes%20spinner_zKoa{100%25{transform:rotate(360deg)}}@keyframes%20spinner_YpZS{0%25{stroke-dasharray:0%20150;stroke-dashoffset:0}47.5%25{stroke-dasharray:42%20150;stroke-dashoffset:-16}95%25,100%25{stroke-dasharray:42%20150;stroke-dashoffset:-59}}%3c/style%3e%3cg%20class='spinner_V8m1'%3e%3ccircle%20cx='12'%20cy='12'%20r='9.5'%20fill='none'%20stroke-width='3'%3e%3c/circle%3e%3c/g%3e%3c/svg%3e", S = () => {
|
|
79
82
|
const e = h();
|
|
80
|
-
return /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ p(
|
|
81
84
|
"div",
|
|
82
85
|
{
|
|
83
86
|
style: {
|
|
@@ -99,9 +102,9 @@ const O = "https://saas.chimera.com.pe/backend", R = "https://saas.chimera.com.p
|
|
|
99
102
|
]
|
|
100
103
|
}
|
|
101
104
|
);
|
|
102
|
-
}, b = ({ titulo: e, texto:
|
|
103
|
-
const
|
|
104
|
-
return /* @__PURE__ */
|
|
105
|
+
}, b = ({ titulo: e, texto: r }) => {
|
|
106
|
+
const i = h();
|
|
107
|
+
return /* @__PURE__ */ p(
|
|
105
108
|
"div",
|
|
106
109
|
{
|
|
107
110
|
style: {
|
|
@@ -120,10 +123,10 @@ const O = "https://saas.chimera.com.pe/backend", R = "https://saas.chimera.com.p
|
|
|
120
123
|
marginTop: 0,
|
|
121
124
|
marginBottom: "0.3rem"
|
|
122
125
|
},
|
|
123
|
-
children:
|
|
126
|
+
children: i(e)
|
|
124
127
|
}
|
|
125
128
|
),
|
|
126
|
-
|
|
129
|
+
r && /* @__PURE__ */ a("p", { children: i(r) })
|
|
127
130
|
]
|
|
128
131
|
}
|
|
129
132
|
);
|
|
@@ -132,19 +135,19 @@ b.propTypes = {
|
|
|
132
135
|
titulo: o.string.isRequired,
|
|
133
136
|
texto: o.string
|
|
134
137
|
};
|
|
135
|
-
const v = ({ devAuthUrl: e,
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
const n = e ||
|
|
138
|
+
const v = ({ devAuthUrl: e, children: r }) => {
|
|
139
|
+
const i = d((n) => n.instancia);
|
|
140
|
+
if (i.requiereLogin) {
|
|
141
|
+
const n = e || E;
|
|
139
142
|
return /* @__PURE__ */ a(
|
|
140
143
|
w,
|
|
141
144
|
{
|
|
142
145
|
authConfig: {
|
|
143
|
-
clientId:
|
|
146
|
+
clientId: i.identificador,
|
|
144
147
|
authorizationEndpoint: `${n}/oauth2/authorize`,
|
|
145
148
|
tokenEndpoint: `${n}/oauth2/token`,
|
|
146
149
|
logoutEndpoint: `${n}/connect/logout`,
|
|
147
|
-
redirectUri: i,
|
|
150
|
+
redirectUri: i.redirectUri,
|
|
148
151
|
scope: "openid profile"
|
|
149
152
|
},
|
|
150
153
|
children: r
|
|
@@ -155,14 +158,13 @@ const v = ({ devAuthUrl: e, redirectUri: i, children: r }) => {
|
|
|
155
158
|
};
|
|
156
159
|
v.propTypes = {
|
|
157
160
|
devAuthUrl: o.string,
|
|
158
|
-
redirectUri: o.string.isRequired,
|
|
159
161
|
children: o.element.isRequired
|
|
160
162
|
};
|
|
161
|
-
const y = ({ aplicacion: e, devBackendUrl:
|
|
162
|
-
const
|
|
163
|
+
const y = ({ aplicacion: e, devBackendUrl: r }) => {
|
|
164
|
+
const i = d((t) => t.estado), n = d((t) => t.inicializar);
|
|
163
165
|
return g(() => {
|
|
164
|
-
|
|
165
|
-
}, [
|
|
166
|
+
n(r, e);
|
|
167
|
+
}, [n, r, e]), /* @__PURE__ */ a(
|
|
166
168
|
"div",
|
|
167
169
|
{
|
|
168
170
|
style: {
|
|
@@ -174,7 +176,7 @@ const y = ({ aplicacion: e, devBackendUrl: i }) => {
|
|
|
174
176
|
backgroundColor: "#141316",
|
|
175
177
|
color: "#e6e1e6"
|
|
176
178
|
},
|
|
177
|
-
children:
|
|
179
|
+
children: i.inicializando ? /* @__PURE__ */ a(S, {}) : i.error && /* @__PURE__ */ a(b, { titulo: "saas.error.titulo", texto: i.error })
|
|
178
180
|
}
|
|
179
181
|
);
|
|
180
182
|
};
|
|
@@ -182,31 +184,28 @@ y.propTypes = {
|
|
|
182
184
|
aplicacion: o.string.isRequired,
|
|
183
185
|
devBackendUrl: o.string
|
|
184
186
|
};
|
|
185
|
-
const
|
|
187
|
+
const k = ({
|
|
186
188
|
aplicacion: e,
|
|
187
|
-
devBackendUrl:
|
|
188
|
-
devAuthUrl:
|
|
189
|
-
redirectUri: t,
|
|
189
|
+
devBackendUrl: r,
|
|
190
|
+
devAuthUrl: i,
|
|
190
191
|
children: n
|
|
191
|
-
}) => d((
|
|
192
|
+
}) => d((c) => c.inicializado) ? /* @__PURE__ */ a(
|
|
192
193
|
v,
|
|
193
194
|
{
|
|
194
|
-
devAuthUrl:
|
|
195
|
-
redirectUri: t,
|
|
195
|
+
devAuthUrl: i,
|
|
196
196
|
children: n
|
|
197
197
|
}
|
|
198
198
|
) : /* @__PURE__ */ a(
|
|
199
199
|
y,
|
|
200
200
|
{
|
|
201
201
|
aplicacion: e,
|
|
202
|
-
devBackendUrl:
|
|
202
|
+
devBackendUrl: r
|
|
203
203
|
}
|
|
204
204
|
);
|
|
205
|
-
|
|
205
|
+
k.propTypes = {
|
|
206
206
|
aplicacion: o.string.isRequired,
|
|
207
207
|
devBackendUrl: o.string,
|
|
208
208
|
devAuthUrl: o.string,
|
|
209
|
-
redirectUri: o.string.isRequired,
|
|
210
209
|
children: o.element.isRequired
|
|
211
210
|
};
|
|
212
211
|
const _ = {
|
|
@@ -221,106 +220,103 @@ const _ = {
|
|
|
221
220
|
error: {
|
|
222
221
|
titulo: "Error iniciando aplicación"
|
|
223
222
|
}
|
|
224
|
-
},
|
|
223
|
+
}, m = {
|
|
225
224
|
en: _,
|
|
226
225
|
es: B
|
|
227
|
-
},
|
|
226
|
+
}, z = f((e) => ({
|
|
228
227
|
idiomasDisponibles: ["en", "es"],
|
|
229
228
|
idiomaActual: "en",
|
|
230
|
-
cambiarIdioma: (
|
|
229
|
+
cambiarIdioma: (r) => {
|
|
231
230
|
e({
|
|
232
|
-
idiomaActual:
|
|
231
|
+
idiomaActual: r
|
|
233
232
|
});
|
|
234
233
|
}
|
|
235
|
-
})),
|
|
236
|
-
const
|
|
237
|
-
return /* @__PURE__ */ a(C, { locale:
|
|
234
|
+
})), U = ({ mensajes: e, children: r }) => {
|
|
235
|
+
const i = z((n) => n.idiomaActual);
|
|
236
|
+
return /* @__PURE__ */ a(C, { locale: i, messages: e[i], children: r });
|
|
238
237
|
};
|
|
239
|
-
|
|
238
|
+
U.propTypes = {
|
|
240
239
|
mensajes: o.object,
|
|
241
240
|
children: o.element.isRequired
|
|
242
241
|
};
|
|
243
|
-
const
|
|
244
|
-
const e =
|
|
245
|
-
if (!
|
|
242
|
+
const D = () => {
|
|
243
|
+
const e = q();
|
|
244
|
+
if (!e?.length)
|
|
246
245
|
return;
|
|
247
|
-
const
|
|
248
|
-
return
|
|
249
|
-
},
|
|
250
|
-
const
|
|
246
|
+
const r = e[0];
|
|
247
|
+
return r.indexOf("-") ? r.substring(0, r.indexOf("-")) : r;
|
|
248
|
+
}, j = ({ mensajes: e, idiomaDefecto: r, children: i }) => {
|
|
249
|
+
const n = z((s) => s.cambiarIdioma), t = D(), c = I(Object.keys(e), Object.keys(m));
|
|
251
250
|
g(() => {
|
|
252
251
|
let s = c[0];
|
|
253
|
-
|
|
254
|
-
}, [c, e,
|
|
252
|
+
t && Object.hasOwn(e, t) ? s = t : r && Object.hasOwn(e, r) && (s = r), n(s);
|
|
253
|
+
}, [c, e, r, t, n]);
|
|
255
254
|
const l = {};
|
|
256
255
|
return c.forEach((s) => {
|
|
257
256
|
l[s] = {
|
|
258
257
|
...Object.hasOwn(e, s) ? e[s] : {},
|
|
259
|
-
saas: Object.hasOwn(
|
|
258
|
+
saas: Object.hasOwn(m, s) ? m[s] : {}
|
|
260
259
|
};
|
|
261
|
-
}), /* @__PURE__ */ a(
|
|
260
|
+
}), /* @__PURE__ */ a(U, { mensajes: l, children: i });
|
|
262
261
|
};
|
|
263
|
-
|
|
262
|
+
j.propTypes = {
|
|
264
263
|
mensajes: o.object,
|
|
265
264
|
idiomaDefecto: o.string,
|
|
266
265
|
children: o.element.isRequired
|
|
267
266
|
};
|
|
268
|
-
const
|
|
267
|
+
const P = ({
|
|
269
268
|
aplicacion: e,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
mensajes: l = {
|
|
269
|
+
dev: r = !1,
|
|
270
|
+
devBackendUrl: i = R,
|
|
271
|
+
devAuthUrl: n = T,
|
|
272
|
+
idiomaDefecto: t = "en",
|
|
273
|
+
mensajes: c = {
|
|
276
274
|
en: {},
|
|
277
275
|
es: {}
|
|
278
276
|
},
|
|
279
|
-
children:
|
|
280
|
-
}) => /* @__PURE__ */ a(
|
|
281
|
-
|
|
277
|
+
children: l
|
|
278
|
+
}) => /* @__PURE__ */ a(j, { mensajes: c, children: /* @__PURE__ */ a(
|
|
279
|
+
k,
|
|
282
280
|
{
|
|
283
281
|
aplicacion: e,
|
|
284
|
-
devBackendUrl:
|
|
285
|
-
devAuthUrl:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
children: s
|
|
282
|
+
devBackendUrl: r ? i : null,
|
|
283
|
+
devAuthUrl: r ? n : null,
|
|
284
|
+
idiomaDefecto: t,
|
|
285
|
+
children: l
|
|
289
286
|
}
|
|
290
287
|
) });
|
|
291
|
-
|
|
288
|
+
P.propTypes = {
|
|
292
289
|
aplicacion: o.string.isRequired,
|
|
290
|
+
dev: o.bool,
|
|
293
291
|
devBackendUrl: o.string,
|
|
294
292
|
devAuthUrl: o.string,
|
|
295
|
-
dev: o.bool,
|
|
296
|
-
redirectUri: o.string.isRequired,
|
|
297
293
|
idiomaDefecto: o.string,
|
|
298
294
|
mensajes: o.object,
|
|
299
295
|
children: o.element.isRequired
|
|
300
296
|
};
|
|
301
|
-
const
|
|
297
|
+
const W = () => {
|
|
302
298
|
const {
|
|
303
299
|
loginInProgress: e,
|
|
304
|
-
token:
|
|
305
|
-
tokenData:
|
|
306
|
-
logIn:
|
|
307
|
-
logOut:
|
|
300
|
+
token: r,
|
|
301
|
+
tokenData: i,
|
|
302
|
+
logIn: n,
|
|
303
|
+
logOut: t,
|
|
308
304
|
error: c
|
|
309
305
|
} = x(A);
|
|
310
306
|
return {
|
|
311
307
|
loginInProgress: e,
|
|
312
|
-
token:
|
|
313
|
-
logIn:
|
|
314
|
-
logOut:
|
|
308
|
+
token: r,
|
|
309
|
+
logIn: n,
|
|
310
|
+
logOut: t,
|
|
315
311
|
error: c,
|
|
316
|
-
correo:
|
|
317
|
-
nombre:
|
|
318
|
-
perfiles:
|
|
312
|
+
correo: i?.sub,
|
|
313
|
+
nombre: i?.name,
|
|
314
|
+
perfiles: i?.profiles
|
|
319
315
|
};
|
|
320
316
|
};
|
|
321
317
|
export {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
318
|
+
P as SaasApp,
|
|
319
|
+
W as useAuth,
|
|
320
|
+
z as useLangStore,
|
|
325
321
|
d as useSaasStore
|
|
326
322
|
};
|
package/dist/react-saas.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("prop-types"),require("react"),require("react-oauth2-code-pkce"),require("zustand"),require("react-polyglot"),require("lodash"),require("navigator-languages")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","prop-types","react","react-oauth2-code-pkce","zustand","react-polyglot","lodash","navigator-languages"],o):(s=typeof globalThis<"u"?globalThis:s||self,o(s["react-saas"]={},s.ReactJSX,s.PropTypes,s.React,s.ReactOauth2CodePkce,s.Zustand,s.ReactPolyglot,s.Lodash,s.NavigatorLanguages))})(this,function(s,o,t,g,b,v,f,C
|
|
1
|
+
(function(s,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("prop-types"),require("react"),require("react-oauth2-code-pkce"),require("zustand"),require("react-polyglot"),require("lodash"),require("navigator-languages")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","prop-types","react","react-oauth2-code-pkce","zustand","react-polyglot","lodash","navigator-languages"],o):(s=typeof globalThis<"u"?globalThis:s||self,o(s["react-saas"]={},s.ReactJSX,s.PropTypes,s.React,s.ReactOauth2CodePkce,s.Zustand,s.ReactPolyglot,s.Lodash,s.NavigatorLanguages))})(this,(function(s,o,t,g,b,v,f,x,C){"use strict";const I="https://saas.chimera.com.pe/backend",y="https://saas.chimera.com.pe/v3",O="http://localhost:7000",S="http://localhost:7777",h={primary:"#1C6CCC",secondary:"#17A7FF",info:"#2196f3",success:"#4caf50",error:"#f44336",warning:"#ff9800"},d=v.create(e=>({inicializado:!1,estado:{inicializando:!0,error:null},instancia:{identificador:null,nombre:null,abreviatura:null,requiereLogin:!1,redirectUri:null,logo:null,color:h},inicializar:async(i,r)=>{e({estado:{inicializando:!0,error:null}});try{const n=await fetch(`${i||I}/identidad/?codigoAplicacion=${r}`);if(!n.ok)throw new Error(`inicializar.error.${n.status}`);const a=await n.json();e({inicializado:!0,estado:{inicializando:!1,error:null},instancia:{identificador:a.identificador,nombre:a.nombre,abreviatura:a.nombre.match(/\b([A-Z])/g).join(""),requiereLogin:a.requiereLogin,redirectUri:a.redirectUri,logo:a.logo,color:{...h,...a.color}}})}catch(n){e({inicializado:!1,estado:{inicializando:!1,error:n.message},instancia:{identificador:null,nombre:null,abreviatura:null,requiereLogin:!1,redirectUri:null,logo:null,color:h}})}}})),E="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20stroke='%23000'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3cstyle%3e.spinner_V8m1{transform-origin:center;animation:spinner_zKoa%202s%20linear%20infinite}.spinner_V8m1%20circle{stroke-linecap:round;animation:spinner_YpZS%201.5s%20ease-in-out%20infinite}@keyframes%20spinner_zKoa{100%25{transform:rotate(360deg)}}@keyframes%20spinner_YpZS{0%25{stroke-dasharray:0%20150;stroke-dashoffset:0}47.5%25{stroke-dasharray:42%20150;stroke-dashoffset:-16}95%25,100%25{stroke-dasharray:42%20150;stroke-dashoffset:-59}}%3c/style%3e%3cg%20class='spinner_V8m1'%3e%3ccircle%20cx='12'%20cy='12'%20r='9.5'%20fill='none'%20stroke-width='3'%3e%3c/circle%3e%3c/g%3e%3c/svg%3e",L=()=>{const e=f.useTranslate();return o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("img",{src:E,alt:e("saas.cargando"),style:{filter:"invert(99%) sepia(2%) saturate(740%) hue-rotate(250deg) brightness(93%) contrast(93%)"}}),o.jsx("span",{children:e("saas.cargando")})]})},k=({titulo:e,texto:i})=>{const r=f.useTranslate();return o.jsxs("div",{style:{borderWidth:"2px",borderStyle:"solid",borderRadius:"7px",backgroundColor:"#f44336",padding:"0.5rem",borderColor:"#8d1108"},children:[o.jsx("h4",{style:{marginTop:0,marginBottom:"0.3rem"},children:r(e)}),i&&o.jsx("p",{children:r(i)})]})};k.propTypes={titulo:t.string.isRequired,texto:t.string};const z=({devAuthUrl:e,children:i})=>{const r=d(n=>n.instancia);if(r.requiereLogin){const n=e||y;return o.jsx(b.AuthProvider,{authConfig:{clientId:r.identificador,authorizationEndpoint:`${n}/oauth2/authorize`,tokenEndpoint:`${n}/oauth2/token`,logoutEndpoint:`${n}/connect/logout`,redirectUri:r.redirectUri,scope:"openid profile"},children:i})}return i};z.propTypes={devAuthUrl:t.string,children:t.element.isRequired};const q=({aplicacion:e,devBackendUrl:i})=>{const r=d(a=>a.estado),n=d(a=>a.inicializar);return g.useEffect(()=>{n(i,e)},[n,i,e]),o.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"100vh",backgroundColor:"#141316",color:"#e6e1e6"},children:r.inicializando?o.jsx(L,{}):r.error&&o.jsx(k,{titulo:"saas.error.titulo",texto:r.error})})};q.propTypes={aplicacion:t.string.isRequired,devBackendUrl:t.string};const j=({aplicacion:e,devBackendUrl:i,devAuthUrl:r,children:n})=>d(l=>l.inicializado)?o.jsx(z,{devAuthUrl:r,children:n}):o.jsx(q,{aplicacion:e,devBackendUrl:i});j.propTypes={aplicacion:t.string.isRequired,devBackendUrl:t.string,devAuthUrl:t.string,children:t.element.isRequired};const m={en:{nombre:"English",cargando:"Loading...",error:{titulo:"Could not initialize application"}},es:{nombre:"Castellano",cargando:"Cargando...",error:{titulo:"Error iniciando aplicación"}}},p=v.create(e=>({idiomasDisponibles:["en","es"],idiomaActual:"en",cambiarIdioma:i=>{e({idiomaActual:i})}})),U=({mensajes:e,children:i})=>{const r=p(n=>n.idiomaActual);return o.jsx(f.I18n,{locale:r,messages:e[r],children:i})};U.propTypes={mensajes:t.object,children:t.element.isRequired};const _=()=>{const e=C();if(!e?.length)return;const i=e[0];return i.indexOf("-")?i.substring(0,i.indexOf("-")):i},A=({mensajes:e,idiomaDefecto:i,children:r})=>{const n=p(c=>c.cambiarIdioma),a=_(),l=x.union(Object.keys(e),Object.keys(m));g.useEffect(()=>{let c=l[0];a&&Object.hasOwn(e,a)?c=a:i&&Object.hasOwn(e,i)&&(c=i),n(c)},[l,e,i,a,n]);const u={};return l.forEach(c=>{u[c]={...Object.hasOwn(e,c)?e[c]:{},saas:Object.hasOwn(m,c)?m[c]:{}}}),o.jsx(U,{mensajes:u,children:r})};A.propTypes={mensajes:t.object,idiomaDefecto:t.string,children:t.element.isRequired};const w=({aplicacion:e,dev:i=!1,devBackendUrl:r=O,devAuthUrl:n=S,idiomaDefecto:a="en",mensajes:l={en:{},es:{}},children:u})=>o.jsx(A,{mensajes:l,children:o.jsx(j,{aplicacion:e,devBackendUrl:i?r:null,devAuthUrl:i?n:null,idiomaDefecto:a,children:u})});w.propTypes={aplicacion:t.string.isRequired,dev:t.bool,devBackendUrl:t.string,devAuthUrl:t.string,idiomaDefecto:t.string,mensajes:t.object,children:t.element.isRequired};const B=()=>{const{loginInProgress:e,token:i,tokenData:r,logIn:n,logOut:a,error:l}=g.useContext(b.AuthContext);return{loginInProgress:e,token:i,logIn:n,logOut:a,error:l,correo:r?.sub,nombre:r?.name,perfiles:r?.profiles}};s.SaasApp=w,s.useAuth=B,s.useLangStore=p,s.useSaasStore=d,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@chimera-pe/react-saas",
|
|
3
3
|
"description": "Componente integrador con SaaS",
|
|
4
4
|
"author": "Germán Enríquez",
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.6",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -34,21 +34,21 @@
|
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
36
|
"navigator-languages": "^2.0.2",
|
|
37
|
-
"react": "^19.1.
|
|
38
|
-
"react-dom": "^19.1.
|
|
39
|
-
"react-oauth2-code-pkce": "^1.23.
|
|
37
|
+
"react": "^19.1.1",
|
|
38
|
+
"react-dom": "^19.1.1",
|
|
39
|
+
"react-oauth2-code-pkce": "^1.23.1",
|
|
40
40
|
"react-polyglot": "^0.7.2",
|
|
41
|
-
"zustand": "^5.0.
|
|
41
|
+
"zustand": "^5.0.8"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@eslint/js": "^9.25.0",
|
|
45
|
-
"@types/react": "^19.1.
|
|
46
|
-
"@types/react-dom": "^19.1.
|
|
47
|
-
"@vitejs/plugin-react": "^4.
|
|
48
|
-
"eslint": "^9.
|
|
45
|
+
"@types/react": "^19.1.11",
|
|
46
|
+
"@types/react-dom": "^19.1.7",
|
|
47
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
48
|
+
"eslint": "^9.34.0",
|
|
49
49
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
50
50
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
51
|
-
"globals": "^16.
|
|
52
|
-
"vite": "^
|
|
51
|
+
"globals": "^16.3.0",
|
|
52
|
+
"vite": "^7.1.3"
|
|
53
53
|
}
|
|
54
54
|
}
|