@chimera-pe/react-saas 3.0.8 → 3.0.10

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.
@@ -1,9 +1,9 @@
1
- import { jsxs as p, jsx as a } from "react/jsx-runtime";
1
+ import { jsxs as g, jsx as a } from "react/jsx-runtime";
2
2
  import o from "prop-types";
3
- import { useEffect as g, useContext as x } from "react";
4
- import { AuthProvider as w, AuthContext as A } from "react-oauth2-code-pkce";
5
- import { create as f } from "zustand";
6
- import { useTranslate as h, I18n as C } from "react-polyglot";
3
+ import { useContext as j, useEffect as f } from "react";
4
+ import { AuthContext as w, AuthProvider as A } from "react-oauth2-code-pkce";
5
+ import { create as h } from "zustand";
6
+ import { useTranslate as b, I18n as C } from "react-polyglot";
7
7
  import { union as I } from "lodash";
8
8
  import q from "navigator-languages";
9
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 = {
@@ -13,7 +13,7 @@ const O = "https://saas.chimera.com.pe/backend", E = "https://saas.chimera.com.p
13
13
  success: "#4caf50",
14
14
  error: "#f44336",
15
15
  warning: "#ff9800"
16
- }, d = f((e) => ({
16
+ }, d = h((e) => ({
17
17
  inicializado: !1,
18
18
  estado: {
19
19
  inicializando: !0,
@@ -79,8 +79,8 @@ const O = "https://saas.chimera.com.pe/backend", E = "https://saas.chimera.com.p
79
79
  }
80
80
  }
81
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 = () => {
82
- const e = h();
83
- return /* @__PURE__ */ p(
82
+ const e = b();
83
+ return /* @__PURE__ */ g(
84
84
  "div",
85
85
  {
86
86
  style: {
@@ -102,9 +102,9 @@ const O = "https://saas.chimera.com.pe/backend", E = "https://saas.chimera.com.p
102
102
  ]
103
103
  }
104
104
  );
105
- }, b = ({ titulo: e, texto: r }) => {
106
- const i = h();
107
- return /* @__PURE__ */ p(
105
+ }, p = ({ titulo: e, texto: r }) => {
106
+ const i = b();
107
+ return /* @__PURE__ */ g(
108
108
  "div",
109
109
  {
110
110
  style: {
@@ -131,16 +131,38 @@ const O = "https://saas.chimera.com.pe/backend", E = "https://saas.chimera.com.p
131
131
  }
132
132
  );
133
133
  };
134
- b.propTypes = {
134
+ p.propTypes = {
135
135
  titulo: o.string.isRequired,
136
136
  texto: o.string
137
137
  };
138
- const v = ({ devAuthUrl: e, children: r }) => {
138
+ const _ = () => {
139
+ const {
140
+ loginInProgress: e,
141
+ token: r,
142
+ tokenData: i,
143
+ logIn: n,
144
+ logOut: t,
145
+ error: c
146
+ } = j(w);
147
+ return {
148
+ loginInProgress: e,
149
+ token: r,
150
+ logIn: n,
151
+ logOut: t,
152
+ error: c,
153
+ correo: i?.sub,
154
+ nombre: i?.name,
155
+ perfiles: i?.profiles
156
+ };
157
+ }, B = ({ children: e }) => {
158
+ const { error: r } = _();
159
+ return r ? /* @__PURE__ */ a(p, { titulo: "saas.login.error", texto: r }) : e;
160
+ }, v = ({ devAuthUrl: e, children: r }) => {
139
161
  const i = d((n) => n.instancia);
140
162
  if (i.requiereLogin) {
141
163
  const n = e || E;
142
164
  return /* @__PURE__ */ a(
143
- w,
165
+ A,
144
166
  {
145
167
  authConfig: {
146
168
  clientId: i.identificador,
@@ -148,9 +170,10 @@ const v = ({ devAuthUrl: e, children: r }) => {
148
170
  tokenEndpoint: `${n}/oauth2/token`,
149
171
  logoutEndpoint: `${n}/connect/logout`,
150
172
  redirectUri: i.redirectUri,
151
- scope: "openid profile"
173
+ scope: "openid profile",
174
+ storage: "session"
152
175
  },
153
- children: r
176
+ children: /* @__PURE__ */ a(B, { children: r })
154
177
  }
155
178
  );
156
179
  }
@@ -162,7 +185,7 @@ v.propTypes = {
162
185
  };
163
186
  const y = ({ aplicacion: e, devBackendUrl: r }) => {
164
187
  const i = d((t) => t.estado), n = d((t) => t.inicializar);
165
- return g(() => {
188
+ return f(() => {
166
189
  n(r, e);
167
190
  }, [n, r, e]), /* @__PURE__ */ a(
168
191
  "div",
@@ -176,7 +199,7 @@ const y = ({ aplicacion: e, devBackendUrl: r }) => {
176
199
  backgroundColor: "#141316",
177
200
  color: "#e6e1e6"
178
201
  },
179
- children: i.inicializando ? /* @__PURE__ */ a(S, {}) : i.error && /* @__PURE__ */ a(b, { titulo: "saas.error.titulo", texto: i.error })
202
+ children: i.inicializando ? /* @__PURE__ */ a(S, {}) : i.error && /* @__PURE__ */ a(p, { titulo: "saas.error.titulo", texto: i.error })
180
203
  }
181
204
  );
182
205
  };
@@ -208,22 +231,22 @@ k.propTypes = {
208
231
  devAuthUrl: o.string,
209
232
  children: o.element.isRequired
210
233
  };
211
- const _ = {
234
+ const D = {
212
235
  nombre: "English",
213
236
  cargando: "Loading...",
214
237
  error: {
215
238
  titulo: "Could not initialize application"
216
239
  }
217
- }, B = {
240
+ }, V = {
218
241
  nombre: "Castellano",
219
242
  cargando: "Cargando...",
220
243
  error: {
221
244
  titulo: "Error iniciando aplicación"
222
245
  }
223
246
  }, m = {
224
- en: _,
225
- es: B
226
- }, z = f((e) => ({
247
+ en: D,
248
+ es: V
249
+ }, z = h((e) => ({
227
250
  idiomasDisponibles: ["en", "es"],
228
251
  idiomaActual: "en",
229
252
  cambiarIdioma: (r) => {
@@ -231,23 +254,23 @@ const _ = {
231
254
  idiomaActual: r
232
255
  });
233
256
  }
234
- })), U = ({ mensajes: e, children: r }) => {
257
+ })), x = ({ mensajes: e, children: r }) => {
235
258
  const i = z((n) => n.idiomaActual);
236
259
  return /* @__PURE__ */ a(C, { locale: i, messages: e[i], children: r });
237
260
  };
238
- U.propTypes = {
261
+ x.propTypes = {
239
262
  mensajes: o.object,
240
263
  children: o.element.isRequired
241
264
  };
242
- const D = () => {
265
+ const P = () => {
243
266
  const e = q();
244
267
  if (!e?.length)
245
268
  return;
246
269
  const r = e[0];
247
270
  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));
250
- g(() => {
271
+ }, U = ({ mensajes: e, idiomaDefecto: r, children: i }) => {
272
+ const n = z((s) => s.cambiarIdioma), t = P(), c = I(Object.keys(e), Object.keys(m));
273
+ f(() => {
251
274
  let s = c[0];
252
275
  t && Object.hasOwn(e, t) ? s = t : r && Object.hasOwn(e, r) && (s = r), n(s);
253
276
  }, [c, e, r, t, n]);
@@ -257,14 +280,14 @@ const D = () => {
257
280
  ...Object.hasOwn(e, s) ? e[s] : {},
258
281
  saas: Object.hasOwn(m, s) ? m[s] : {}
259
282
  };
260
- }), /* @__PURE__ */ a(U, { mensajes: l, children: i });
283
+ }), /* @__PURE__ */ a(x, { mensajes: l, children: i });
261
284
  };
262
- j.propTypes = {
285
+ U.propTypes = {
263
286
  mensajes: o.object,
264
287
  idiomaDefecto: o.string,
265
288
  children: o.element.isRequired
266
289
  };
267
- const P = ({
290
+ const Z = ({
268
291
  aplicacion: e,
269
292
  dev: r = !1,
270
293
  devBackendUrl: i = R,
@@ -275,7 +298,7 @@ const P = ({
275
298
  es: {}
276
299
  },
277
300
  children: l
278
- }) => /* @__PURE__ */ a(j, { mensajes: c, children: /* @__PURE__ */ a(
301
+ }) => /* @__PURE__ */ a(U, { mensajes: c, children: /* @__PURE__ */ a(
279
302
  k,
280
303
  {
281
304
  aplicacion: e,
@@ -285,7 +308,7 @@ const P = ({
285
308
  children: l
286
309
  }
287
310
  ) });
288
- P.propTypes = {
311
+ Z.propTypes = {
289
312
  aplicacion: o.string.isRequired,
290
313
  dev: o.bool,
291
314
  devBackendUrl: o.string,
@@ -294,29 +317,9 @@ P.propTypes = {
294
317
  mensajes: o.object,
295
318
  children: o.element.isRequired
296
319
  };
297
- const W = () => {
298
- const {
299
- loginInProgress: e,
300
- token: r,
301
- tokenData: i,
302
- logIn: n,
303
- logOut: t,
304
- error: c
305
- } = x(A);
306
- return {
307
- loginInProgress: e,
308
- token: r,
309
- logIn: n,
310
- logOut: t,
311
- error: c,
312
- correo: i?.sub,
313
- nombre: i?.name,
314
- perfiles: i?.profiles
315
- };
316
- };
317
320
  export {
318
- P as SaasApp,
319
- W as useAuth,
321
+ Z as SaasApp,
322
+ _ as useAuth,
320
323
  z as useLangStore,
321
324
  d as useSaasStore
322
325
  };
@@ -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,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"})}));
1
+ (function(s,t){typeof exports=="object"&&typeof module<"u"?t(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"],t):(s=typeof globalThis<"u"?globalThis:s||self,t(s["react-saas"]={},s.ReactJSX,s.PropTypes,s.React,s.ReactOauth2CodePkce,s.Zustand,s.ReactPolyglot,s.Lodash,s.NavigatorLanguages))})(this,(function(s,t,a,g,v,k,f,C,I){"use strict";const y="https://saas.chimera.com.pe/backend",O="https://saas.chimera.com.pe/v3",S="http://localhost:7000",E="http://localhost:7777",h={primary:"#1C6CCC",secondary:"#17A7FF",info:"#2196f3",success:"#4caf50",error:"#f44336",warning:"#ff9800"},d=k.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(r,i)=>{e({estado:{inicializando:!0,error:null}});try{const n=await fetch(`${r||y}/identidad/?codigoAplicacion=${i}`);if(!n.ok)throw new Error(`inicializar.error.${n.status}`);const o=await n.json();e({inicializado:!0,estado:{inicializando:!1,error:null},instancia:{identificador:o.identificador,nombre:o.nombre,abreviatura:o.nombre.match(/\b([A-Z])/g).join(""),requiereLogin:o.requiereLogin,redirectUri:o.redirectUri,logo:o.logo,color:{...h,...o.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}})}}})),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",_=()=>{const e=f.useTranslate();return t.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[t.jsx("img",{src:L,alt:e("saas.cargando"),style:{filter:"invert(99%) sepia(2%) saturate(740%) hue-rotate(250deg) brightness(93%) contrast(93%)"}}),t.jsx("span",{children:e("saas.cargando")})]})},m=({titulo:e,texto:r})=>{const i=f.useTranslate();return t.jsxs("div",{style:{borderWidth:"2px",borderStyle:"solid",borderRadius:"7px",backgroundColor:"#f44336",padding:"0.5rem",borderColor:"#8d1108"},children:[t.jsx("h4",{style:{marginTop:0,marginBottom:"0.3rem"},children:i(e)}),r&&t.jsx("p",{children:i(r)})]})};m.propTypes={titulo:a.string.isRequired,texto:a.string};const z=()=>{const{loginInProgress:e,token:r,tokenData:i,logIn:n,logOut:o,error:l}=g.useContext(v.AuthContext);return{loginInProgress:e,token:r,logIn:n,logOut:o,error:l,correo:i?.sub,nombre:i?.name,perfiles:i?.profiles}},B=({children:e})=>{const{error:r}=z();return r?t.jsx(m,{titulo:"saas.login.error",texto:r}):e},q=({devAuthUrl:e,children:r})=>{const i=d(n=>n.instancia);if(i.requiereLogin){const n=e||O;return t.jsx(v.AuthProvider,{authConfig:{clientId:i.identificador,authorizationEndpoint:`${n}/oauth2/authorize`,tokenEndpoint:`${n}/oauth2/token`,logoutEndpoint:`${n}/connect/logout`,redirectUri:i.redirectUri,scope:"openid profile",storage:"session"},children:t.jsx(B,{children:r})})}return r};q.propTypes={devAuthUrl:a.string,children:a.element.isRequired};const j=({aplicacion:e,devBackendUrl:r})=>{const i=d(o=>o.estado),n=d(o=>o.inicializar);return g.useEffect(()=>{n(r,e)},[n,r,e]),t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"100vh",backgroundColor:"#141316",color:"#e6e1e6"},children:i.inicializando?t.jsx(_,{}):i.error&&t.jsx(m,{titulo:"saas.error.titulo",texto:i.error})})};j.propTypes={aplicacion:a.string.isRequired,devBackendUrl:a.string};const U=({aplicacion:e,devBackendUrl:r,devAuthUrl:i,children:n})=>d(l=>l.inicializado)?t.jsx(q,{devAuthUrl:i,children:n}):t.jsx(j,{aplicacion:e,devBackendUrl:r});U.propTypes={aplicacion:a.string.isRequired,devBackendUrl:a.string,devAuthUrl:a.string,children:a.element.isRequired};const p={en:{nombre:"English",cargando:"Loading...",error:{titulo:"Could not initialize application"}},es:{nombre:"Castellano",cargando:"Cargando...",error:{titulo:"Error iniciando aplicación"}}},b=k.create(e=>({idiomasDisponibles:["en","es"],idiomaActual:"en",cambiarIdioma:r=>{e({idiomaActual:r})}})),x=({mensajes:e,children:r})=>{const i=b(n=>n.idiomaActual);return t.jsx(f.I18n,{locale:i,messages:e[i],children:r})};x.propTypes={mensajes:a.object,children:a.element.isRequired};const D=()=>{const e=I();if(!e?.length)return;const r=e[0];return r.indexOf("-")?r.substring(0,r.indexOf("-")):r},A=({mensajes:e,idiomaDefecto:r,children:i})=>{const n=b(c=>c.cambiarIdioma),o=D(),l=C.union(Object.keys(e),Object.keys(p));g.useEffect(()=>{let c=l[0];o&&Object.hasOwn(e,o)?c=o:r&&Object.hasOwn(e,r)&&(c=r),n(c)},[l,e,r,o,n]);const u={};return l.forEach(c=>{u[c]={...Object.hasOwn(e,c)?e[c]:{},saas:Object.hasOwn(p,c)?p[c]:{}}}),t.jsx(x,{mensajes:u,children:i})};A.propTypes={mensajes:a.object,idiomaDefecto:a.string,children:a.element.isRequired};const w=({aplicacion:e,dev:r=!1,devBackendUrl:i=S,devAuthUrl:n=E,idiomaDefecto:o="en",mensajes:l={en:{},es:{}},children:u})=>t.jsx(A,{mensajes:l,children:t.jsx(U,{aplicacion:e,devBackendUrl:r?i:null,devAuthUrl:r?n:null,idiomaDefecto:o,children:u})});w.propTypes={aplicacion:a.string.isRequired,dev:a.bool,devBackendUrl:a.string,devAuthUrl:a.string,idiomaDefecto:a.string,mensajes:a.object,children:a.element.isRequired},s.SaasApp=w,s.useAuth=z,s.useLangStore=b,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.8",
5
+ "version": "3.0.10",
6
6
  "type": "module",
7
7
  "repository": {
8
8
  "type": "git",
@@ -32,23 +32,23 @@
32
32
  "prepare": "npm run build"
33
33
  },
34
34
  "peerDependencies": {
35
- "lodash": "^4.17.21",
35
+ "lodash": "^4.17.23",
36
36
  "navigator-languages": "^2.0.2",
37
- "react": "^19.1.1",
38
- "react-dom": "^19.1.1",
39
- "react-oauth2-code-pkce": "^1.23.2",
37
+ "react": "^19.2.4",
38
+ "react-dom": "^19.2.4",
39
+ "react-oauth2-code-pkce": "^1.24.0",
40
40
  "react-polyglot": "^0.7.2",
41
- "zustand": "^5.0.8"
41
+ "zustand": "^5.0.11"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@eslint/js": "^9.33.0",
45
- "@types/react": "^19.1.13",
46
- "@types/react-dom": "^19.1.9",
47
- "@vitejs/plugin-react": "^5.0.3",
48
- "eslint": "^9.35.0",
49
- "eslint-plugin-react-hooks": "^5.2.0",
50
- "eslint-plugin-react-refresh": "^0.4.20",
51
- "globals": "^16.4.0",
52
- "vite": "^7.1.5"
45
+ "@types/react": "^19.2.14",
46
+ "@types/react-dom": "^19.2.3",
47
+ "@vitejs/plugin-react": "^5.1.4",
48
+ "eslint": "^9.39.3",
49
+ "eslint-plugin-react-hooks": "^7.0.1",
50
+ "eslint-plugin-react-refresh": "^0.4.26",
51
+ "globals": "^16.5.0",
52
+ "vite": "^7.3.1"
53
53
  }
54
54
  }