@chimera-pe/react-saas 3.0.2 → 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.
@@ -6,7 +6,7 @@ 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
8
  import U from "navigator-languages";
9
- const O = "https://saas.chimera.com.pe/backend/v3", R = "https://saas.chimera.com.pe/oauth/v3", E = "http://localhost:7000", T = "http://localhost:7777", u = {
9
+ const O = "https://saas.chimera.com.pe/backend", R = "https://saas.chimera.com.pe/v3", E = "http://localhost:7000", T = "http://localhost:7777", u = {
10
10
  primary: "#1C6CCC",
11
11
  secondary: "#17A7FF",
12
12
  info: "#2196f3",
@@ -226,7 +226,7 @@ const _ = {
226
226
  es: B
227
227
  }, j = f((e) => ({
228
228
  idiomasDisponibles: ["en", "es"],
229
- idiomanActual: "en",
229
+ idiomaActual: "en",
230
230
  cambiarIdioma: (i) => {
231
231
  e({
232
232
  idiomaActual: i
@@ -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,h,C,I){"use strict";const U="https://saas.chimera.com.pe/backend/v3",O="https://saas.chimera.com.pe/oauth/v3",S="http://localhost:7000",y="http://localhost:7777",f={primary:"#1C6CCC",secondary:"#17A7FF",info:"#2196f3",success:"#4caf50",error:"#f44336",warning:"#ff9800"},u=v.create(e=>({inicializado:!1,estado:{inicializando:!0,error:null},instancia:{identificador:null,nombre:null,abreviatura:null,requiereLogin:!1,logo:null,color:f},inicializar:async(r,i)=>{e({estado:{inicializando:!0,error:null}});try{const a=await fetch(`${r||U}/identidad/?codigoAplicacion=${i}`);if(!a.ok)throw new Error(`inicializar.error.${a.status}`);const n=await a.json();e({inicializado:!0,estado:{inicializando:!1,error:null},instancia:{identificador:n.identificador,nombre:n.nombre,abreviatura:n.nombre.match(/\b([A-Z])/g).join(""),requiereLogin:n.requiereLogin,logo:n.logo,color:{...f,...n.color}}})}catch(a){e({inicializado:!1,estado:{inicializando:!1,error:a.message},instancia:{identificador:null,nombre:null,abreviatura:null,requiereLogin:!1,logo:null,color:f}})}}})),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=h.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")})]})},q=({titulo:e,texto:r})=>{const i=h.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:i(e)}),r&&o.jsx("p",{children:i(r)})]})};q.propTypes={titulo:t.string.isRequired,texto:t.string};const z=({devAuthUrl:e,redirectUri:r,children:i})=>{const a=u(n=>n.instancia);if(a.requiereLogin){const n=e||O;return o.jsx(b.AuthProvider,{authConfig:{clientId:a.identificador,authorizationEndpoint:`${n}/oauth2/authorize`,tokenEndpoint:`${n}/oauth2/token`,logoutEndpoint:`${n}/connect/logout`,redirectUri:r,scope:"openid profile"},children:i})}return i};z.propTypes={devAuthUrl:t.string,redirectUri:t.string.isRequired,children:t.element.isRequired};const j=({aplicacion:e,devBackendUrl:r})=>{const i=u(n=>n.estado),a=u(n=>n.inicializar);return g.useEffect(()=>{a(r,e)},[a,r,e]),o.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"100vh",backgroundColor:"#141316",color:"#e6e1e6"},children:i.inicializando?o.jsx(L,{}):i.error&&o.jsx(q,{titulo:"saas.error.titulo",texto:i.error})})};j.propTypes={aplicacion:t.string.isRequired,devBackendUrl:t.string};const k=({aplicacion:e,devBackendUrl:r,devAuthUrl:i,redirectUri:a,children:n})=>u(d=>d.inicializado)?o.jsx(z,{devAuthUrl:i,redirectUri:a,children:n}):o.jsx(j,{aplicacion:e,devBackendUrl:r});k.propTypes={aplicacion:t.string.isRequired,devBackendUrl:t.string,devAuthUrl:t.string,redirectUri:t.string.isRequired,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"],idiomanActual:"en",cambiarIdioma:r=>{e({idiomaActual:r})}})),A=({mensajes:e,children:r})=>{const i=p(a=>a.idiomaActual);return o.jsx(h.I18n,{locale:i,messages:e[i],children:r})};A.propTypes={mensajes:t.object,children:t.element.isRequired};const _=()=>{const e=I();if(!(e!=null&&e.length))return;const r=e[0];return r.indexOf("-")?r.substring(0,r.indexOf("-")):r},w=({mensajes:e,idiomaDefecto:r,children:i})=>{const a=p(c=>c.cambiarIdioma),n=_(),l=C.union(Object.keys(e),Object.keys(m));g.useEffect(()=>{let c=l[0];n&&Object.hasOwn(e,n)?c=n:r&&Object.hasOwn(e,r)&&(c=r),a(c)},[l,e,r,n,a]);const d={};return l.forEach(c=>{d[c]={...Object.hasOwn(e,c)?e[c]:{},saas:Object.hasOwn(m,c)?m[c]:{}}}),o.jsx(A,{mensajes:d,children:i})};w.propTypes={mensajes:t.object,idiomaDefecto:t.string,children:t.element.isRequired};const x=({aplicacion:e,devBackendUrl:r=S,devAuthUrl:i=y,dev:a=!1,redirectUri:n,idiomaDefecto:l="en",mensajes:d={en:{},es:{}},children:c})=>o.jsx(w,{mensajes:d,children:o.jsx(k,{aplicacion:e,devBackendUrl:a&&r,devAuthUrl:a&&i,redirectUri:n,idiomaDefecto:l,children:c})});x.propTypes={aplicacion:t.string.isRequired,devBackendUrl:t.string,devAuthUrl:t.string,dev:t.bool,redirectUri:t.string.isRequired,idiomaDefecto:t.string,mensajes:t.object,children:t.element.isRequired};const B=()=>{const{loginInProgress:e,token:r,tokenData:i,logIn:a,logOut:n,error:l}=g.useContext(b.AuthContext);return{loginInProgress:e,token:r,logIn:a,logOut:n,error:l,correo:i==null?void 0:i.sub,nombre:i==null?void 0:i.name,perfiles:i==null?void 0:i.profiles}};s.SaasApp=x,s.useAuth=B,s.useLangStore=p,s.useSaasStore=u,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
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,I){"use strict";const U="https://saas.chimera.com.pe/backend",O="https://saas.chimera.com.pe/v3",S="http://localhost:7000",y="http://localhost:7777",h={primary:"#1C6CCC",secondary:"#17A7FF",info:"#2196f3",success:"#4caf50",error:"#f44336",warning:"#ff9800"},u=v.create(e=>({inicializado:!1,estado:{inicializando:!0,error:null},instancia:{identificador:null,nombre:null,abreviatura:null,requiereLogin:!1,logo:null,color:h},inicializar:async(r,i)=>{e({estado:{inicializando:!0,error:null}});try{const a=await fetch(`${r||U}/identidad/?codigoAplicacion=${i}`);if(!a.ok)throw new Error(`inicializar.error.${a.status}`);const n=await a.json();e({inicializado:!0,estado:{inicializando:!1,error:null},instancia:{identificador:n.identificador,nombre:n.nombre,abreviatura:n.nombre.match(/\b([A-Z])/g).join(""),requiereLogin:n.requiereLogin,logo:n.logo,color:{...h,...n.color}}})}catch(a){e({inicializado:!1,estado:{inicializando:!1,error:a.message},instancia:{identificador:null,nombre:null,abreviatura:null,requiereLogin:!1,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")})]})},q=({titulo:e,texto:r})=>{const i=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:i(e)}),r&&o.jsx("p",{children:i(r)})]})};q.propTypes={titulo:t.string.isRequired,texto:t.string};const z=({devAuthUrl:e,redirectUri:r,children:i})=>{const a=u(n=>n.instancia);if(a.requiereLogin){const n=e||O;return o.jsx(b.AuthProvider,{authConfig:{clientId:a.identificador,authorizationEndpoint:`${n}/oauth2/authorize`,tokenEndpoint:`${n}/oauth2/token`,logoutEndpoint:`${n}/connect/logout`,redirectUri:r,scope:"openid profile"},children:i})}return i};z.propTypes={devAuthUrl:t.string,redirectUri:t.string.isRequired,children:t.element.isRequired};const j=({aplicacion:e,devBackendUrl:r})=>{const i=u(n=>n.estado),a=u(n=>n.inicializar);return g.useEffect(()=>{a(r,e)},[a,r,e]),o.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"100vh",backgroundColor:"#141316",color:"#e6e1e6"},children:i.inicializando?o.jsx(L,{}):i.error&&o.jsx(q,{titulo:"saas.error.titulo",texto:i.error})})};j.propTypes={aplicacion:t.string.isRequired,devBackendUrl:t.string};const k=({aplicacion:e,devBackendUrl:r,devAuthUrl:i,redirectUri:a,children:n})=>u(d=>d.inicializado)?o.jsx(z,{devAuthUrl:i,redirectUri:a,children:n}):o.jsx(j,{aplicacion:e,devBackendUrl:r});k.propTypes={aplicacion:t.string.isRequired,devBackendUrl:t.string,devAuthUrl:t.string,redirectUri:t.string.isRequired,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:r=>{e({idiomaActual:r})}})),A=({mensajes:e,children:r})=>{const i=p(a=>a.idiomaActual);return o.jsx(f.I18n,{locale:i,messages:e[i],children:r})};A.propTypes={mensajes:t.object,children:t.element.isRequired};const _=()=>{const e=I();if(!(e!=null&&e.length))return;const r=e[0];return r.indexOf("-")?r.substring(0,r.indexOf("-")):r},w=({mensajes:e,idiomaDefecto:r,children:i})=>{const a=p(c=>c.cambiarIdioma),n=_(),l=C.union(Object.keys(e),Object.keys(m));g.useEffect(()=>{let c=l[0];n&&Object.hasOwn(e,n)?c=n:r&&Object.hasOwn(e,r)&&(c=r),a(c)},[l,e,r,n,a]);const d={};return l.forEach(c=>{d[c]={...Object.hasOwn(e,c)?e[c]:{},saas:Object.hasOwn(m,c)?m[c]:{}}}),o.jsx(A,{mensajes:d,children:i})};w.propTypes={mensajes:t.object,idiomaDefecto:t.string,children:t.element.isRequired};const x=({aplicacion:e,devBackendUrl:r=S,devAuthUrl:i=y,dev:a=!1,redirectUri:n,idiomaDefecto:l="en",mensajes:d={en:{},es:{}},children:c})=>o.jsx(w,{mensajes:d,children:o.jsx(k,{aplicacion:e,devBackendUrl:a&&r,devAuthUrl:a&&i,redirectUri:n,idiomaDefecto:l,children:c})});x.propTypes={aplicacion:t.string.isRequired,devBackendUrl:t.string,devAuthUrl:t.string,dev:t.bool,redirectUri:t.string.isRequired,idiomaDefecto:t.string,mensajes:t.object,children:t.element.isRequired};const B=()=>{const{loginInProgress:e,token:r,tokenData:i,logIn:a,logOut:n,error:l}=g.useContext(b.AuthContext);return{loginInProgress:e,token:r,logIn:a,logOut:n,error:l,correo:i==null?void 0:i.sub,nombre:i==null?void 0:i.name,perfiles:i==null?void 0:i.profiles}};s.SaasApp=x,s.useAuth=B,s.useLangStore=p,s.useSaasStore=u,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.2",
5
+ "version": "3.0.4",
6
6
  "type": "module",
7
7
  "repository": {
8
8
  "type": "git",
@@ -42,13 +42,13 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@eslint/js": "^9.22.0",
45
- "@types/react": "^19.1.3",
46
- "@types/react-dom": "^19.1.3",
45
+ "@types/react": "^19.1.4",
46
+ "@types/react-dom": "^19.1.5",
47
47
  "@vitejs/plugin-react": "^4.4.1",
48
- "eslint": "^9.26.0",
48
+ "eslint": "^9.27.0",
49
49
  "eslint-plugin-react-hooks": "^5.2.0",
50
50
  "eslint-plugin-react-refresh": "^0.4.20",
51
- "globals": "^16.0.0",
51
+ "globals": "^16.1.0",
52
52
  "vite": "^6.3.5"
53
53
  }
54
54
  }