jclib-ui 1.0.287 → 1.0.288

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.
@@ -458,7 +458,7 @@
458
458
  padding-top: 8px;
459
459
  }
460
460
  }
461
- `;function Ze(){return Qt.jsxs(Ke,{children:[Qt.jsx("div",{className:"alert alert-danger",children:"Falha na conexão!"}),Qt.jsxs("div",{children:["Possíveis causas:",Qt.jsx("ul",{children:navigator.onLine?Qt.jsxs(Qt.Fragment,{children:[Qt.jsx("li",{children:"Você está sem conexão com a internet;"}),Qt.jsx("li",{children:"O servidor pode estar passando por uma atualização. Por favor, tente novamente em alguns instantes."}),Qt.jsx("li",{children:"O servidor pode estar temporariamente indisponível."})]}):Qt.jsx("li",{children:"Você está sem conexão com a internet;"})}),Qt.jsxs("div",{children:["Se o erro persistir, por favor, entre em contato com nosso suporte técnico:",Qt.jsxs("ul",{children:[Qt.jsxs("li",{children:["Fone e WhatsApp:"," ",Qt.jsx($e,{className:"numeros",children:"(27) 9 9774-2904"})]}),Qt.jsxs("li",{children:["E-mail:"," ",Qt.jsx(Ye,{href:"suporte@jcinfoes.com.br?subject="+encodeURI("SIPAR - Sem conexão com o servidor!"),children:"suporte@jcinfoes.com.br"})]})]})]})]})]})}const Qe={isError:!1,message:null,loading:!1,headers:null,data:null,error:null,code:0,status:503,report:!1,onBefore:null};function Je(t={}){const r=a.useHistory(),n=new AbortController,{globalApiConfig:o}=ee(),[i,s]=e.useState(Qe);return"string"==typeof t&&(t={url:t}),[async function(e){var i,a,l,c,h;let f,d={username:null==(i=o.auth)?void 0:i.username,password:null==(a=o.auth)?void 0:a.password};if(t.headers={...t.headers,...null==e?void 0:e.headers},o.getToken){let e=o.getToken();e&&(o.auth.prefix&&(e=`${o.auth.prefix} ${e}`),t.headers[o.auth.header]=e)}o.version&&(t.headers["x-ver"]=encodeURIComponent(o.version)),o.ident&&(t.headers["x-identify"]=encodeURIComponent(o.ident));let p={baseURL:o.baseURL,timeout:o.timeout,auth:d,validateStatus:t=>t>=200&&t<400,...t,...e,headers:t.headers};p.report&&(p={...p,responseType:"blob",timeout:0}),s({...Qe,loading:!0}),p.onBefore&&p.onBefore(p);try{const t=await u({...p,signal:n.signal});o.afterRequest&&o.afterRequest(t),f={...Qe,data:t.data,message:t.statusText,status:t.status,headers:t.headers}}catch(m){const{ERR_NETWORK:t,ECONNABORTED:e,ETIMEDOUT:n}=u.AxiosError;if([t,e,n].includes(null==m?void 0:m.code))f={...Qe,isError:!0,status:400,message:Qt.jsx(Ze,{})};else if(m.response)switch(f={...Qe,isError:!0,status:m.response.status,message:(null==(l=m.response.data)?void 0:l.error)||m.response.data,code:null==(c=m.response.data)?void 0:c.code},m.response.status){case 400:case 500:if("blob"==(null==p?void 0:p.responseType)){let t=await m.response.data.text();t=JSON.parse(t),f.message=t.error||"Ocorreu um erro ao consultar o servidor!"}break;case 401:f.message="Servidor requer autenticação!",o.setToken&&o.setToken(""),r.push(o.loginRoute);break;case 404:f.message="Servidor não possui este recurso!";break;case 405:f.message=`Método [${(null==(h=p.method)?void 0:h.toUpperCase())||"GET"}] indisponível!`;break;case 429:f.message="Muitos acessos. Tente novamente mais tarde!"}else f={...Qe,isError:!0,message:m.message}}const g=`timeout of ${o.timeout}ms exceeded`;return f.message!=g&&"Network Error"!=f.message||(f.message="Sem conexão com o servidor!"),f.isError?f.error=f.message:f.error=null,f={...f,loading:!1},s(f),(null==t?void 0:t.onTerminated)&&t.onTerminated(f),f},i,function(){n&&n.abort("Cancelado pelo usuário!")}]}let tr=null;function er({url:t,file:n,fileTo:o,setLoading:i}){const[a,u]=e.useState(""),[l,c]=e.useState(!1),[h,f]=e.useState(0),[d,p]=e.useState(n),[g,m]=e.useState(""),[v,,y]=Je({url:t,method:"post",data:{file:d},report:!0,onDownloadProgress:t=>{c(t.loaded>0),f(t.loaded/t.total*100)},onTerminated:t=>{if(204===t.status)return w(3);if(t.error)u(t.error),_();else{const[,n]=o.split(".");r.isDesktop()&&"pdf"==n.toLowerCase()?(e=t.data,m(URL.createObjectURL(e))):(s(t.data,function(){let t=o.split("."),e=`-${r.getDateTimeStr().replace(/\D/g,"")}-${r.getHash(o)}`;return t[0]+=e,t=t.join("."),t}()),p(""))}var e}});function _(){tr&&clearTimeout(tr)}function w(t){_(),tr=setTimeout(()=>v(),1e3*t)}return e.useEffect(()=>()=>_(),[]),e.useEffect(()=>()=>g&&URL.revokeObjectURL(g),[g]),e.useEffect(()=>{d?(i(!0),w(2)):i(!1)},[d]),Qt.jsxs(Qt.Fragment,{children:[Qt.jsxs("div",{className:"loading-report--area",children:[Qt.jsxs("div",{className:"loading-box",style:{display:g?"none":"block"},children:[Qt.jsx("button",{className:"btn-loading-close",title:"Cancelar",onClick:function(){l?y():u(""),i(!1)},children:Qt.jsx("i",{className:"fas fa-times"})}),Qt.jsxs("div",{className:"line",children:[l?Qt.jsx("i",{className:"fa-solid fa-file-arrow-down pulse"}):Qt.jsx("div",{className:"spinner"}),Qt.jsx("span",{children:l?"Baixando relatório...":"Gerando relatório..."})]}),Qt.jsx("div",{className:"pbar",children:Qt.jsx("div",{style:{width:`${h}%`}})})]}),g&&Qt.jsx(Xe,{fileTo:o,previewUrl:g,setVisible:()=>p(""),visible:!0})]}),a&&Qt.jsx(se,{onConfirm:()=>i(!1),children:a})]})}function rr({search:t,setSearch:n,fnSearch:o,fnFilter:a,fnValidateFilter:s,placeHolder:u,...l}){const c=e.useRef();return Qt.jsxs("div",{className:"inp-pesq--input-area",children:[Qt.jsxs(i.InputGroup,{children:[Qt.jsx(i.Input,{innerRef:c,value:t,onChange:t=>n(t.target.value),placeholder:u,...l}),Qt.jsx(i.Button,{color:"outline-secondary",type:"button",onClick:()=>{n(""),r.isDesktop()&&(null==c?void 0:c.current)&&c.current.focus()},title:"Limpar campo de pesquisa",children:Qt.jsx(xe,{})}),Qt.jsx(i.Button,{color:"info",title:"Pesquisar",onClick:o,type:o?"button":"submit",children:Qt.jsx(Se,{})})]}),a&&Qt.jsxs(i.Button,{type:"button",color:"outline-filter",className:"position-relative ip--btn-filter",title:"Filtros avançados",onClick:a,children:[Qt.jsx("i",{className:"fas fa-filter"}),Qt.jsx("span",{className:"ip--btn-caption",children:" Filtros"}),s&&s()&&Qt.jsx("span",{className:"position-absolute top-0 start-100 translate-middle \r\n p-2 bg-danger border border-light rounded-circle",children:Qt.jsx("span",{className:"visually-hidden",children:"Filtro ativo"})})]})]})}const nr=o.div`
461
+ `;function Ze(){return Qt.jsxs(Ke,{children:[Qt.jsx("div",{className:"alert alert-danger",children:"Falha na conexão!"}),Qt.jsxs("div",{children:["Possíveis causas:",Qt.jsx("ul",{children:navigator.onLine?Qt.jsxs(Qt.Fragment,{children:[Qt.jsx("li",{children:"Você está sem conexão com a internet;"}),Qt.jsx("li",{children:"O servidor pode estar passando por uma atualização. Por favor, tente novamente em alguns instantes."}),Qt.jsx("li",{children:"O servidor pode estar temporariamente indisponível."})]}):Qt.jsx("li",{children:"Você está sem conexão com a internet;"})}),Qt.jsxs("div",{children:["Se o erro persistir, por favor, entre em contato com nosso suporte técnico:",Qt.jsxs("ul",{children:[Qt.jsxs("li",{children:["Fone e WhatsApp:"," ",Qt.jsx($e,{className:"numeros",children:"(27) 9 9774-2904"})]}),Qt.jsxs("li",{children:["E-mail:"," ",Qt.jsx(Ye,{href:"suporte@jcinfoes.com.br?subject="+encodeURI("SIPAR - Sem conexão com o servidor!"),children:"suporte@jcinfoes.com.br"})]})]})]})]})]})}const Qe={isError:!1,message:null,loading:!1,headers:null,data:null,error:null,code:0,status:503,report:!1,onBefore:null};function Je(t={}){const r=a.useHistory(),n=new AbortController,{globalApiConfig:o}=ee(),[i,s]=e.useState(Qe);return"string"==typeof t&&(t={url:t}),[async function(e){var i,a,l,c;let h,f=(null==(i=o.auth)?void 0:i.username)?{username:o.auth.username,password:o.auth.password}:void 0;if(t.headers={...t.headers,...null==e?void 0:e.headers},o.getToken){let e=o.getToken();e&&(o.auth.prefix&&(e=`${o.auth.prefix} ${e}`),t.headers[o.auth.header]=e)}o.version&&(t.headers["x-ver"]=encodeURIComponent(o.version)),o.ident&&(t.headers["x-identify"]=encodeURIComponent(o.ident));let d={baseURL:o.baseURL,timeout:o.timeout,auth:f,validateStatus:t=>t>=200&&t<400,...t,...e,headers:t.headers};d.report&&(d={...d,responseType:"blob",timeout:0}),s({...Qe,loading:!0}),d.onBefore&&d.onBefore(d);try{const t=await u({...d,signal:n.signal});o.afterRequest&&o.afterRequest(t),h={...Qe,data:t.data,message:t.statusText,status:t.status,headers:t.headers}}catch(g){const{ERR_NETWORK:t,ECONNABORTED:e,ETIMEDOUT:n}=u.AxiosError;if([t,e,n].includes(null==g?void 0:g.code))h={...Qe,isError:!0,status:400,message:Qt.jsx(Ze,{})};else if(g.response)switch(h={...Qe,isError:!0,status:g.response.status,message:(null==(a=g.response.data)?void 0:a.error)||g.response.data,code:null==(l=g.response.data)?void 0:l.code},g.response.status){case 400:case 500:if("blob"==(null==d?void 0:d.responseType)){let t=await g.response.data.text();t=JSON.parse(t),h.message=t.error||"Ocorreu um erro ao consultar o servidor!"}break;case 401:h.message="Servidor requer autenticação!",o.setToken&&o.setToken(""),r.push(o.loginRoute);break;case 404:h.message="Servidor não possui este recurso!";break;case 405:h.message=`Método [${(null==(c=d.method)?void 0:c.toUpperCase())||"GET"}] indisponível!`;break;case 429:h.message="Muitos acessos. Tente novamente mais tarde!"}else h={...Qe,isError:!0,message:g.message}}const p=`timeout of ${o.timeout}ms exceeded`;return h.message!=p&&"Network Error"!=h.message||(h.message="Sem conexão com o servidor!"),h.isError?h.error=h.message:h.error=null,h={...h,loading:!1},s(h),(null==t?void 0:t.onTerminated)&&t.onTerminated(h),h},i,function(){n&&n.abort("Cancelado pelo usuário!")}]}let tr=null;function er({url:t,file:n,fileTo:o,setLoading:i}){const[a,u]=e.useState(""),[l,c]=e.useState(!1),[h,f]=e.useState(0),[d,p]=e.useState(n),[g,m]=e.useState(""),[v,,y]=Je({url:t,method:"post",data:{file:d},report:!0,onDownloadProgress:t=>{c(t.loaded>0),f(t.loaded/t.total*100)},onTerminated:t=>{if(204===t.status)return w(3);if(t.error)u(t.error),_();else{const[,n]=o.split(".");r.isDesktop()&&"pdf"==n.toLowerCase()?(e=t.data,m(URL.createObjectURL(e))):(s(t.data,function(){let t=o.split("."),e=`-${r.getDateTimeStr().replace(/\D/g,"")}-${r.getHash(o)}`;return t[0]+=e,t=t.join("."),t}()),p(""))}var e}});function _(){tr&&clearTimeout(tr)}function w(t){_(),tr=setTimeout(()=>v(),1e3*t)}return e.useEffect(()=>()=>_(),[]),e.useEffect(()=>()=>g&&URL.revokeObjectURL(g),[g]),e.useEffect(()=>{d?(i(!0),w(2)):i(!1)},[d]),Qt.jsxs(Qt.Fragment,{children:[Qt.jsxs("div",{className:"loading-report--area",children:[Qt.jsxs("div",{className:"loading-box",style:{display:g?"none":"block"},children:[Qt.jsx("button",{className:"btn-loading-close",title:"Cancelar",onClick:function(){l?y():u(""),i(!1)},children:Qt.jsx("i",{className:"fas fa-times"})}),Qt.jsxs("div",{className:"line",children:[l?Qt.jsx("i",{className:"fa-solid fa-file-arrow-down pulse"}):Qt.jsx("div",{className:"spinner"}),Qt.jsx("span",{children:l?"Baixando relatório...":"Gerando relatório..."})]}),Qt.jsx("div",{className:"pbar",children:Qt.jsx("div",{style:{width:`${h}%`}})})]}),g&&Qt.jsx(Xe,{fileTo:o,previewUrl:g,setVisible:()=>p(""),visible:!0})]}),a&&Qt.jsx(se,{onConfirm:()=>i(!1),children:a})]})}function rr({search:t,setSearch:n,fnSearch:o,fnFilter:a,fnValidateFilter:s,placeHolder:u,...l}){const c=e.useRef();return Qt.jsxs("div",{className:"inp-pesq--input-area",children:[Qt.jsxs(i.InputGroup,{children:[Qt.jsx(i.Input,{innerRef:c,value:t,onChange:t=>n(t.target.value),placeholder:u,...l}),Qt.jsx(i.Button,{color:"outline-secondary",type:"button",onClick:()=>{n(""),r.isDesktop()&&(null==c?void 0:c.current)&&c.current.focus()},title:"Limpar campo de pesquisa",children:Qt.jsx(xe,{})}),Qt.jsx(i.Button,{color:"info",title:"Pesquisar",onClick:o,type:o?"button":"submit",children:Qt.jsx(Se,{})})]}),a&&Qt.jsxs(i.Button,{type:"button",color:"outline-filter",className:"position-relative ip--btn-filter",title:"Filtros avançados",onClick:a,children:[Qt.jsx("i",{className:"fas fa-filter"}),Qt.jsx("span",{className:"ip--btn-caption",children:" Filtros"}),s&&s()&&Qt.jsx("span",{className:"position-absolute top-0 start-100 translate-middle \r\n p-2 bg-danger border border-light rounded-circle",children:Qt.jsx("span",{className:"visually-hidden",children:"Filtro ativo"})})]})]})}const nr=o.div`
462
462
  position: fixed;
463
463
  inset: 0 0 0;
464
464
  background-color: var(--jc-overlay-bg);