@credithub/harlan-components 1.34.0 → 1.35.0

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.
@@ -88,6 +88,6 @@ var Addresses = function () {
88
88
  React.createElement(AddItemField, { name: "Cidade", value: address.city, style: { display: 'inline-block' } }),
89
89
  React.createElement(AddItemField, { name: "Estado", value: address.state, style: { display: 'inline-block' } }))); })));
90
90
  };
91
- return (React.createElement(Section, { title: "Endere\u00E7os", subtitle: "Informa\u00E7\u00F5es de endere\u00E7os do documento pesquisado.", icon: EnderecoIcon, minimized: false, ctx: __assign(__assign({}, ctx), { progress: ctx.progress }), onError: function () { return response(undefined); }, onSuccess: response }));
91
+ return (React.createElement(Section, { title: "Endere\u00E7os", subtitle: "Informa\u00E7\u00F5es de endere\u00E7os do documento pesquisado.", icon: EnderecoIcon, minimized: false, ctx: ctx, onError: function () { return response(undefined); }, onSuccess: response }));
92
92
  };
93
93
  export default Addresses;
@@ -62,6 +62,6 @@ var BankAccounts = function () {
62
62
  }
63
63
  };
64
64
  };
65
- return (React.createElement(Section, { title: 'Informações de Contas Bancárias', subtitle: 'Vejas as informações disponíveis de contas bancárias.', icon: ContasBancariasIcon, ctx: __assign(__assign({}, ctx), { progress: ctx.progress }), minimized: false, onSuccess: response }));
65
+ return (React.createElement(Section, { title: 'Informações de Contas Bancárias', subtitle: 'Vejas as informações disponíveis de contas bancárias.', icon: ContasBancariasIcon, ctx: ctx, minimized: false, onSuccess: response }));
66
66
  };
67
67
  export default BankAccounts;
@@ -29,7 +29,7 @@ var CCF = function () {
29
29
  ultimaOcorrencia: XPathUtils.select('string(./ultimo)', node),
30
30
  motivo: XPathUtils.select('string(./motivo)', node)
31
31
  }); }, []);
32
- return (React.createElement(Section, { ctx: __assign(__assign({}, ctx), { progress: ctx.progress }), title: "Cheques sem Fundos em Institui\u00E7\u00E3o Banc\u00E1ria", subtitle: "Detalhes acerca de cheques sem fundos emitidos.", icon: ChequesSemFundoIcon, onSuccess: function (data) {
32
+ return (React.createElement(Section, { ctx: ctx, title: "Cheques sem Fundos em Institui\u00E7\u00E3o Banc\u00E1ria", subtitle: "Detalhes acerca de cheques sem fundos emitidos.", icon: ChequesSemFundoIcon, onSuccess: function (data) {
33
33
  var allItems = XPathUtils.selectArray('//list/*', data);
34
34
  var filteredItems = allItems.filter(function (node) {
35
35
  return node.nodeName.startsWith('item');
@@ -77,6 +77,9 @@ var ConsultaSimplesSection = function (_a) {
77
77
  React.createElement(StatusMessage, null, format(new Date(), "dd/MM/yyyy 'às' HH:mm")),
78
78
  React.createElement(StatusMessage, { type: "found" }, formatDocument(documento)),
79
79
  isError && (ctx === null || ctx === void 0 ? void 0 : ctx.error) && (React.createElement(StatusMessage, { type: statusType }, ctx.error.message)),
80
- possuiPendenciaText.length ? (possuiPendenciaText.map(function (text) { return (React.createElement(StatusMessage, { key: text, type: "error" }, text)); })) : (React.createElement(StatusMessage, { type: statusType }, "Nenhum registro encontrado"))), onClose: onClose, icon: ConsultaSimplesIcon, variant: isLoading ? 'loading' : 'default', ctx: ctx }, rest), children));
80
+ possuiPendenciaText.length ? (possuiPendenciaText.map(function (text) { return (React.createElement(StatusMessage, { key: text, type: "error" }, text)); })) : (React.createElement(StatusMessage, { type: statusType }, "Nenhum registro encontrado"))), onClose: onClose, icon: ConsultaSimplesIcon, variant: isLoading ? 'loading' : 'default', ctx: ctx, loadingProps: {
81
+ percentage: (ctx === null || ctx === void 0 ? void 0 : ctx.progress) || 0,
82
+ hidden: !isLoading
83
+ } }, rest), children));
81
84
  };
82
85
  export default ConsultaSimplesSection;
@@ -66,7 +66,7 @@ var Contacts = function (_a) {
66
66
  useEffect(function () {
67
67
  updateData();
68
68
  }, [updateData]);
69
- return (React.createElement(Section, { ctx: __assign(__assign({}, ctx), { progress: ctx.progress }), title: "Contato", subtitle: "Informa\u00E7\u00F5es de contato do documento pesquisado.", description: "(Telefone, e-mail e outros)", minimized: false, icon: ContatoIcon, onSuccess: function (data) {
69
+ return (React.createElement(Section, { ctx: ctx, title: "Contato", subtitle: "Informa\u00E7\u00F5es de contato do documento pesquisado.", description: "(Telefone, e-mail e outros)", minimized: false, icon: ContatoIcon, onSuccess: function (data) {
70
70
  var _a;
71
71
  var document = XPathUtils.select('string(//cpf|//cnpj)', data);
72
72
  var telefones = __spreadArray(__spreadArray([], (XPathUtils.selectArray('//telefones/fixos/fixos', data) || []), true), (XPathUtils.selectArray('//telefones/moveis/moveis', data) || []), true).map(function (telefone) { return ({
@@ -59,7 +59,7 @@ var DividasPublicas = function () {
59
59
  setDataUpdated(true);
60
60
  }
61
61
  }, [ctx, dataUpdated, setData]);
62
- return (React.createElement(Section, { ctx: __assign(__assign({}, ctx), { progress: ctx.progress }), title: "D\u00EDvidas P\u00FAblicas", icon: DividasVencidasSerasaIcon, subtitle: "Veja as d\u00EDvidas p\u00FAblicas com a Uni\u00E3o (ativa, FGTS e previdenci\u00E1ria).", onSuccess: function (document) {
62
+ return (React.createElement(Section, { ctx: ctx, title: "D\u00EDvidas P\u00FAblicas", icon: DividasVencidasSerasaIcon, subtitle: "Veja as d\u00EDvidas p\u00FAblicas com a Uni\u00E3o (ativa, FGTS e previdenci\u00E1ria).", onSuccess: function (document) {
63
63
  var dividas = parseDividas(document);
64
64
  var totalOcorrencias = dividas.length;
65
65
  var children = totalOcorrencias ? (React.createElement(Result, null,
@@ -2,17 +2,6 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
2
2
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
3
  return cooked;
4
4
  };
5
- var __assign = (this && this.__assign) || function () {
6
- __assign = Object.assign || function(t) {
7
- for (var s, i = 1, n = arguments.length; i < n; i++) {
8
- s = arguments[i];
9
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
10
- t[p] = s[p];
11
- }
12
- return t;
13
- };
14
- return __assign.apply(this, arguments);
15
- };
16
5
  import DominiosIcon from '../../assets/icones/dominios';
17
6
  import React, { useContext } from 'react';
18
7
  import styled from 'styled-components';
@@ -24,7 +13,7 @@ import { Queries } from '../webservice';
24
13
  var Link = styled.a(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: inherit;\n text-decoration: none;\n"], ["\n color: inherit;\n text-decoration: none;\n"])));
25
14
  var Dominios = function () {
26
15
  var ctx = useContext(Queries.Dominios);
27
- return (React.createElement(Section, { ctx: __assign(__assign({}, ctx), { progress: ctx.progress }), title: "Dom\u00EDnios na Internet", subtitle: "Informa\u00E7\u00F5es de dom\u00EDnios na internet.", icon: DominiosIcon, onSuccess: function (document) {
16
+ return (React.createElement(Section, { ctx: ctx, title: "Dom\u00EDnios na Internet", subtitle: "Informa\u00E7\u00F5es de dom\u00EDnios na internet.", icon: DominiosIcon, onSuccess: function (document) {
28
17
  return {
29
18
  children: document.length ? (React.createElement(Result, { resultContentStriped: false }, document.map(function (data) { return (React.createElement(ResultContent, { desktop: "1fr 1fr 1fr", tablet: "1fr 1fr", mobile: "1fr 1fr", key: data },
30
19
  React.createElement(AddItemField, { name: "Dom\u00EDnio", value: React.createElement(Link, { href: "https://www.".concat(data), target: "_blank", rel: "noreferrer" }, data) }))); }))) : null,
@@ -66,7 +66,7 @@ var Dossie = function (_a) {
66
66
  React.createElement(Summary, { finderResponse: data, rfbResponse: rfbResponse, document: document })),
67
67
  React.createElement(TransactionsTable, { events: XPathUtils.select('//historico/consulta', data) || [] })));
68
68
  };
69
- return (React.createElement(Section, { ctx: __assign(__assign({}, ctx), { progress: ctx.progress }), hideHeader: true, minimized: false, isError: function (e) { return response(e); }, onSuccess: response }));
69
+ return (React.createElement(Section, { ctx: ctx, hideHeader: true, minimized: false, isError: function (e) { return response(e); }, onSuccess: response }));
70
70
  };
71
71
  export default Dossie;
72
72
  var templateObject_1, templateObject_2;
@@ -1,13 +1,17 @@
1
1
  import { IconProps } from '@/@types/icon';
2
- import React, { ComponentProps, ComponentType, DetailedHTMLProps, HTMLAttributes, ReactNode } from 'react';
3
- import LoadingBar from './loadingBar';
2
+ import React, { ComponentType, DetailedHTMLProps, HTMLAttributes, ReactNode } from 'react';
4
3
  export type HeaderProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLElement> & {
5
4
  title?: ReactNode;
6
5
  subtitle?: ReactNode;
7
6
  description?: ReactNode;
8
7
  actions?: ReactNode;
9
8
  className?: string;
10
- loadingProps?: ComponentProps<typeof LoadingBar>;
9
+ loadingProps?: {
10
+ percentage?: number;
11
+ activeRequests?: number;
12
+ hidden?: boolean;
13
+ showLoadingBar?: boolean;
14
+ };
11
15
  icon?: ComponentType<IconProps>;
12
16
  iconProps?: IconProps;
13
17
  titleClassName?: string;
@@ -73,13 +73,17 @@ var Description = styled.div(templateObject_3 || (templateObject_3 = __makeTempl
73
73
  var HeaderUI = styled(function (_a) {
74
74
  var children = _a.children, props = __rest(_a, ["children"]);
75
75
  return React.createElement("header", __assign({}, props), children);
76
- })(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n @media screen {\n background: #ffffff !important;\n box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.15);\n border-radius: 30px;\n // color: ", ";\n }\n\n @media print {\n page-break-before: avoid;\n page-break-after: avoid;\n page-break-inside: avoid;\n padding: 18px;\n print-color-adjust: exact;\n background: #eae9e9;\n border-radius: 18px;\n // color: ", ";\n }\n\n padding: 30px 20px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n\n ", " {\n color: ", ";\n }\n"], ["\n @media screen {\n background: #ffffff !important;\n box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.15);\n border-radius: 30px;\n // color: ", ";\n }\n\n @media print {\n page-break-before: avoid;\n page-break-after: avoid;\n page-break-inside: avoid;\n padding: 18px;\n print-color-adjust: exact;\n background: #eae9e9;\n border-radius: 18px;\n // color: ", ";\n }\n\n padding: 30px 20px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n\n ", " {\n color: ", ";\n }\n"])), function (props) { return props.color; }, function (props) { return props.color; }, Title, function (props) { return props.color; });
76
+ })(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n @media screen {\n background: #ffffff !important;\n box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.15);\n border-radius: 30px;\n }\n\n @media print {\n page-break-before: avoid;\n page-break-after: avoid;\n page-break-inside: avoid;\n padding: 18px;\n print-color-adjust: exact;\n background: #eae9e9;\n border-radius: 18px;\n }\n\n padding: 30px 20px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n\n ", " {\n color: ", ";\n }\n"], ["\n @media screen {\n background: #ffffff !important;\n box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.15);\n border-radius: 30px;\n }\n\n @media print {\n page-break-before: avoid;\n page-break-after: avoid;\n page-break-inside: avoid;\n padding: 18px;\n print-color-adjust: exact;\n background: #eae9e9;\n border-radius: 18px;\n }\n\n padding: 30px 20px;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n\n ", " {\n color: ", ";\n }\n"])), Title, function (props) { return props.color; });
77
77
  var HeaderContainer = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n gap: 20px;\n\n @media print {\n width: 100%;\n }\n"], ["\n display: flex;\n gap: 20px;\n\n @media print {\n width: 100%;\n }\n"])));
78
78
  var ActionsList = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n gap: 10px;\n"], ["\n display: flex;\n flex-direction: row;\n gap: 10px;\n"])));
79
79
  var IconWrapper = styled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: flex;\n align-items: flex-start;\n padding-top: 5px;\n width: 30px;\n"], ["\n display: flex;\n align-items: flex-start;\n padding-top: 5px;\n width: 30px;\n"])));
80
80
  var TextWrapper = styled.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n gap: 10px;\n\n .text-wrapper-subtitle-description {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n gap: 20px;\n align-items: center;\n\n @media (max-width: 768px) {\n align-items: flex-start;\n }\n\n @media print {\n flex-direction: row;\n }\n }\n"], ["\n display: flex;\n flex-direction: column;\n gap: 10px;\n\n .text-wrapper-subtitle-description {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n gap: 20px;\n align-items: center;\n\n @media (max-width: 768px) {\n align-items: flex-start;\n }\n\n @media print {\n flex-direction: row;\n }\n }\n"])));
81
+ var LoadingBarWrapper = styled.div(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n width: 100%;\n max-width: 300px;\n height: 10px;\n opacity: ", ";\n transition: opacity 0.3s ease;\n"], ["\n width: 100%;\n max-width: 300px;\n height: 10px;\n opacity: ", ";\n transition: opacity 0.3s ease;\n"])), function (_a) {
82
+ var hidden = _a.hidden;
83
+ return (hidden ? 0 : 1);
84
+ });
81
85
  var Header = function (_a) {
82
- var title = _a.title, subtitle = _a.subtitle, description = _a.description, actions = _a.actions, Icon = _a.icon, _b = _a.variant, variant = _b === void 0 ? 'default' : _b, iconProps = _a.iconProps, loadingProps = _a.loadingProps, className = _a.className, titleClassName = _a.titleClassName, subtitleClassName = _a.subtitleClassName, descriptionClassName = _a.descriptionClassName, containerClassName = _a.containerClassName, actionsClassName = _a.actionsClassName, innerRef = _a.innerRef, _c = _a.printBar, printBar = _c === void 0 ? true : _c, props = __rest(_a, ["title", "subtitle", "description", "actions", "icon", "variant", "iconProps", "loadingProps", "className", "titleClassName", "subtitleClassName", "descriptionClassName", "containerClassName", "actionsClassName", "innerRef", "printBar"]);
86
+ var title = _a.title, subtitle = _a.subtitle, description = _a.description, actions = _a.actions, Icon = _a.icon, _b = _a.variant, variant = _b === void 0 ? 'default' : _b, iconProps = _a.iconProps, _c = _a.loadingProps, loadingProps = _c === void 0 ? {} : _c, className = _a.className, titleClassName = _a.titleClassName, subtitleClassName = _a.subtitleClassName, descriptionClassName = _a.descriptionClassName, containerClassName = _a.containerClassName, actionsClassName = _a.actionsClassName, innerRef = _a.innerRef, _d = _a.printBar, printBar = _d === void 0 ? true : _d, props = __rest(_a, ["title", "subtitle", "description", "actions", "icon", "variant", "iconProps", "loadingProps", "className", "titleClassName", "subtitleClassName", "descriptionClassName", "containerClassName", "actionsClassName", "innerRef", "printBar"]);
83
87
  var theme = useTheme();
84
88
  var headerClass = classNames(className);
85
89
  var actionsClass = classNames(actionsClassName);
@@ -95,7 +99,8 @@ var Header = function (_a) {
95
99
  React.createElement("div", { className: "text-wrapper-subtitle-description" },
96
100
  React.createElement(Subtitle, { hidden: isLoading || !subtitle, className: subtitleClassName }, subtitle),
97
101
  React.createElement(Description, { hidden: isLoading || !description, className: descriptionClassName }, description)),
98
- React.createElement(LoadingBar, { percentage: (loadingProps === null || loadingProps === void 0 ? void 0 : loadingProps.percentage) || 0, hidden: !isLoading }))),
102
+ React.createElement(LoadingBarWrapper, { hidden: !isLoading },
103
+ React.createElement(LoadingBar, { percentage: (loadingProps === null || loadingProps === void 0 ? void 0 : loadingProps.percentage) || 0 })))),
99
104
  React.createElement(ActionsList, { className: actionsClass }, actions && actions))));
100
105
  };
101
106
  var getVariantColor = function (type, theme) {
@@ -108,4 +113,4 @@ var getVariantColor = function (type, theme) {
108
113
  return options[type];
109
114
  };
110
115
  export default Header;
111
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
116
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
@@ -1,5 +1,6 @@
1
1
  import React, { HTMLAttributes } from 'react';
2
2
  declare const LoadingBar: React.FC<{
3
3
  percentage: number;
4
+ hidden?: boolean;
4
5
  } & HTMLAttributes<HTMLDivElement>>;
5
6
  export default LoadingBar;
@@ -26,20 +26,23 @@ var __rest = (this && this.__rest) || function (s, e) {
26
26
  };
27
27
  import React from 'react';
28
28
  import styled from 'styled-components';
29
- var GreyBar = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n height: 10px;\n background-color: ", ";\n border-radius: 10px;\n position: relative;\n overflow: hidden;\n"], ["\n width: 100%;\n height: 10px;\n background-color: ", ";\n border-radius: 10px;\n position: relative;\n overflow: hidden;\n"])), function (_a) {
29
+ var GreyBar = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 18.75rem;\n height: 0.625rem;\n background-color: ", ";\n border-radius: 10px;\n position: relative;\n overflow: hidden;\n visibility: ", ";\n\n @media (max-width: 600px) {\n width: 12.5rem;\n }\n\n @media (max-width: 400px) {\n width: 9.375rem;\n }\n"], ["\n width: 18.75rem;\n height: 0.625rem;\n background-color: ", ";\n border-radius: 10px;\n position: relative;\n overflow: hidden;\n visibility: ", ";\n\n @media (max-width: 600px) {\n width: 12.5rem;\n }\n\n @media (max-width: 400px) {\n width: 9.375rem;\n }\n"])), function (_a) {
30
30
  var theme = _a.theme;
31
31
  return theme.colors.cinzaClaro;
32
+ }, function (_a) {
33
+ var hidden = _a.hidden;
34
+ return hidden ? 'hidden' : 'visible';
32
35
  });
33
36
  var BlueBar = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: ", "%;\n height: 100%;\n background-color: ", ";\n border-radius: 10px;\n transition: width 0.4s ease-in-out;\n"], ["\n width: ", "%;\n height: 100%;\n background-color: ", ";\n border-radius: 10px;\n transition: width 0.4s ease-in-out;\n"])), function (_a) {
34
37
  var percentage = _a.percentage;
35
- return percentage;
38
+ return Math.min(percentage, 100);
36
39
  }, function (_a) {
37
40
  var theme = _a.theme;
38
41
  return theme.colors.azulCredithub;
39
42
  });
40
43
  var LoadingBar = function (_a) {
41
- var _b = _a.percentage, percentage = _b === void 0 ? 0 : _b, props = __rest(_a, ["percentage"]);
42
- return (React.createElement(GreyBar, __assign({}, props),
44
+ var _b = _a.percentage, percentage = _b === void 0 ? 0 : _b, _c = _a.hidden, hidden = _c === void 0 ? false : _c, props = __rest(_a, ["percentage", "hidden"]);
45
+ return (React.createElement(GreyBar, __assign({ hidden: hidden }, props),
43
46
  React.createElement(BlueBar, { percentage: percentage })));
44
47
  };
45
48
  export default LoadingBar;
@@ -47,6 +47,6 @@ var Liminar = function () {
47
47
  ? 'Encontrado'
48
48
  : 'Não Encontrado'))
49
49
  };
50
- }, ctx: __assign(__assign({}, ctx), { progress: ctx.progress }) }));
50
+ }, ctx: ctx }));
51
51
  };
52
52
  export default Liminar;
@@ -85,6 +85,6 @@ var Partners = function (_a) {
85
85
  description: !(partners === null || partners === void 0 ? void 0 : partners.length) && (React.createElement(StatusMessage, null, "N\u00E3o h\u00E1 informa\u00E7\u00F5es de Quadro Societ\u00E1rio"))
86
86
  };
87
87
  };
88
- return (React.createElement(Section, { ctx: __assign(__assign({}, ctx), { progress: ctx.progress }), title: "Quadro Societ\u00E1rio", minimized: false, subtitle: "Informa\u00E7\u00F5es sobre o quadro societ\u00E1rio da pessoa pesquisada.", icon: QuadroSocietarioIcon, isError: function () { return response(undefined); }, onSuccess: response }));
88
+ return (React.createElement(Section, { ctx: ctx, title: "Quadro Societ\u00E1rio", minimized: false, subtitle: "Informa\u00E7\u00F5es sobre o quadro societ\u00E1rio da pessoa pesquisada.", icon: QuadroSocietarioIcon, isError: function () { return response(undefined); }, onSuccess: response }));
89
89
  };
90
90
  export default Partners;
@@ -20,7 +20,7 @@ var PessoaPoliticamenteExposta = function () {
20
20
  var ctx = useContext(Queries.Finder);
21
21
  var setData = useGlobalData().setData;
22
22
  var _a = useState(false), dataUpdated = _a[0], setDataUpdated = _a[1];
23
- return (React.createElement(Section, { ctx: __assign(__assign({}, ctx), { progress: ctx.progress }), title: "Pessoa Politicamente Exposta", subtitle: "Vejas As Informa\u00E7\u00F5es Dispon\u00EDveis", onSuccess: function (document) {
23
+ return (React.createElement(Section, { ctx: ctx, title: "Pessoa Politicamente Exposta", subtitle: "Vejas As Informa\u00E7\u00F5es Dispon\u00EDveis", onSuccess: function (document) {
24
24
  var _a, _b, _c, _d;
25
25
  if (!(document instanceof Node)) {
26
26
  console.error('O documento não é do tipo Node esperado.');
@@ -34,7 +34,7 @@ var ProcessosJuridicos = function (_a) {
34
34
  }
35
35
  }
36
36
  }, [ctx.type, ctx.document, dataUpdated, setData]);
37
- return (React.createElement(Section, { ctx: __assign(__assign({}, ctx), { progress: ctx.progress }), title: "Processos Jur\u00EDdicos", subtitle: "Veja os processos jur\u00EDdicos para este documento.", icon: ProcessosJuridicosIcon, minimized: false, onSuccess: function (data) {
37
+ return (React.createElement(Section, { ctx: ctx, title: "Processos Jur\u00EDdicos", subtitle: "Veja os processos jur\u00EDdicos para este documento.", icon: ProcessosJuridicosIcon, minimized: false, onSuccess: function (data) {
38
38
  var _a;
39
39
  var qtyProcessos = (_a = data.empresa) === null || _a === void 0 ? void 0 : _a.length;
40
40
  var children = qtyProcessos ? (React.createElement(ProcessosJuridicosList, { processos: data.empresa, onClickConsultarProcessoJuridico: onClickConsultarProcessoJuridico })) : null;
@@ -69,7 +69,7 @@ var Protestos = function () {
69
69
  setData(function (prevState) { return (__assign(__assign({}, prevState), { protestos: registros, protestosData: protestosState })); });
70
70
  setDataUpdated(true);
71
71
  }, [ctx, setData, dataUpdated]);
72
- return (React.createElement(Section, { ctx: __assign(__assign({}, ctx), { progress: ctx.progress }), title: "Apontamentos na Central de Protestos (CENPROT)", subtitle: "Consulta de protestos de cr\u00E9dito, imposto e gerais.", icon: ProtestosIcon, onSuccess: function (data) {
72
+ return (React.createElement(Section, { ctx: ctx, title: "Apontamentos na Central de Protestos (CENPROT)", subtitle: "Consulta de protestos de cr\u00E9dito, imposto e gerais.", icon: ProtestosIcon, onSuccess: function (data) {
73
73
  var registrosText = XPathUtils.select('string(//registros)', data);
74
74
  var registros = extractIntegerFromText(registrosText);
75
75
  var protestosDeCredito = XPathUtils.selectArray('//body//protesto', data).filter(function (protesto) {
@@ -66,7 +66,9 @@ export var Section = function (_a) {
66
66
  var renderHeader = function (props) { return (React.createElement(Header, __assign({ printBar: renderedResponse !== null && isOpen }, props, { className: cn(className, type !== undefined && headerStatus[type]
67
67
  ? headerStatus[type]
68
68
  : '', props.className), variant: type === RequestStatus.Loading ? 'loading' : props.variant, loadingProps: {
69
- percentage: progress !== null && progress !== void 0 ? progress : 0
69
+ percentage: progress !== null && progress !== void 0 ? progress : 0,
70
+ activeRequests: ctx.activeRequests,
71
+ hidden: false
70
72
  }, actions: React.createElement(React.Fragment, null,
71
73
  props.actions,
72
74
  renderedResponse && defaultHeaderActions) }))); };
@@ -26,6 +26,8 @@ export type RequestContext<R> = {
26
26
  response: Response | undefined;
27
27
  document: R | undefined;
28
28
  progress?: number;
29
+ activeRequests?: number;
30
+ showLoadingBar?: boolean;
29
31
  };
30
32
  export type HeaderReplaceResponse = {
31
33
  children: React.ReactNode;
@@ -19,10 +19,32 @@ export function CustomProvider(Provider, query) {
19
19
  var client = useContext(WebService);
20
20
  var _b = useState(null), response = _b[0], setResponse = _b[1];
21
21
  var _c = useState(null), error = _c[0], setError = _c[1];
22
- var _d = useState(true), loading = _d[0], setLoading = _d[1];
22
+ var _d = useState(false), loading = _d[0], setLoading = _d[1];
23
+ var _e = useState(0), progress = _e[0], setProgress = _e[1];
24
+ var _f = useState(new Map()), requestsMap = _f[0], setRequestsMap = _f[1];
25
+ var _g = useState(false), showLoadingBar = _g[0], setShowLoadingBar = _g[1];
26
+ // Simula o progresso da barra de carregamento
27
+ var simulateProgress = useCallback(function () {
28
+ setProgress(0);
29
+ var currentProgress = 0;
30
+ var interval = setInterval(function () {
31
+ currentProgress += 15;
32
+ setProgress(Math.min(currentProgress, 90));
33
+ if (currentProgress >= 90) {
34
+ clearInterval(interval);
35
+ }
36
+ }, 300);
37
+ return function () { return clearInterval(interval); };
38
+ }, []);
23
39
  var fetchData = useCallback(function () {
40
+ if (loading)
41
+ return; // Evita chamadas duplicadas
24
42
  setLoading(true);
25
43
  setError(null);
44
+ setShowLoadingBar(true);
45
+ simulateProgress();
46
+ var requestId = Date.now();
47
+ setRequestsMap(function (prev) { return new Map(prev.set(requestId, true)); });
26
48
  var abortController = new AbortController();
27
49
  client
28
50
  .request(query, data, urlData, abortController.signal)
@@ -32,24 +54,47 @@ export function CustomProvider(Provider, query) {
32
54
  document: document
33
55
  }); });
34
56
  })
35
- .then(function (parsedResponse) { return setResponse(parsedResponse); })
57
+ .then(function (parsedResponse) {
58
+ setResponse(parsedResponse);
59
+ setError(null);
60
+ })
36
61
  .catch(function (requestError) {
37
62
  if (requestError.name !== 'AbortError') {
38
63
  setError(requestError instanceof Error
39
64
  ? requestError
40
- : new Error(requestError));
65
+ : new Error(String(requestError)));
41
66
  }
42
67
  })
43
- .finally(function () { return setLoading(false); });
68
+ .finally(function () {
69
+ setLoading(false);
70
+ setRequestsMap(function (prev) {
71
+ var newMap = new Map(prev);
72
+ newMap.delete(requestId);
73
+ return newMap;
74
+ });
75
+ // Atualiza o progresso para 100% e esconde a barra de carregamento
76
+ setProgress(100);
77
+ setTimeout(function () {
78
+ setShowLoadingBar(false);
79
+ }, 500);
80
+ });
44
81
  return function () {
45
82
  abortController.abort();
83
+ setRequestsMap(function (prev) {
84
+ var newMap = new Map(prev);
85
+ newMap.delete(requestId);
86
+ return newMap;
87
+ });
46
88
  };
47
- }, [client, query, data, urlData]);
89
+ }, [client, query, data, urlData, loading, simulateProgress]); // Adiciona `loading` como dependência
90
+ // `useEffect` para iniciar a busca de dados apenas uma vez
48
91
  useEffect(function () {
49
- var cleanup = fetchData();
50
- return cleanup;
51
- }, [fetchData]);
92
+ if (!response && !loading && requestsMap.size === 0) {
93
+ fetchData();
94
+ }
95
+ }, [fetchData, response, loading, requestsMap]);
52
96
  var contextValue = useMemo(function () {
97
+ var activeRequestsCount = requestsMap.size;
53
98
  return {
54
99
  type: error
55
100
  ? RequestStatus.Error
@@ -64,9 +109,22 @@ export function CustomProvider(Provider, query) {
64
109
  response: response === null || response === void 0 ? void 0 : response.response,
65
110
  document: response === null || response === void 0 ? void 0 : response.document,
66
111
  Section: Section,
67
- refetch: fetchData
112
+ refetch: fetchData,
113
+ progress: progress,
114
+ activeRequests: activeRequestsCount,
115
+ showLoadingBar: showLoadingBar
68
116
  };
69
- }, [error, response, data, urlData, loading, fetchData]);
117
+ }, [
118
+ error,
119
+ response,
120
+ data,
121
+ urlData,
122
+ loading,
123
+ fetchData,
124
+ progress,
125
+ requestsMap,
126
+ showLoadingBar
127
+ ]);
70
128
  return (React.createElement(Provider.Provider, { value: contextValue }, children));
71
129
  };
72
130
  }
@@ -181,7 +239,10 @@ export function query(query) {
181
239
  response: undefined,
182
240
  document: undefined,
183
241
  data: undefined,
184
- urlData: undefined
242
+ urlData: undefined,
243
+ progress: 0,
244
+ activeRequests: 0,
245
+ showLoadingBar: false
185
246
  });
186
247
  return Object.assign(RequestContext, {
187
248
  Request: CustomProvider(RequestContext, query)