@credithub/harlan-components 1.34.0 → 1.35.1

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) {
@@ -38,12 +38,14 @@ import { PrintSectionWrapper } from './common/printSectionWrapper';
38
38
  import Header from './interface/header';
39
39
  import StatusMessage from './interface/statusMessage';
40
40
  import { RequestStatus } from './webservice';
41
+ var ButtonWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n justify-content: center;\n width: 100%;\n height: 40%;\n max-height: 52px;\n max-width: 300px;\n margin: 0 auto;\n"], ["\n justify-content: center;\n width: 100%;\n height: 40%;\n max-height: 52px;\n max-width: 300px;\n margin: 0 auto;\n"])));
41
42
  export var Section = function (_a) {
42
43
  var onSuccess = _a.onSuccess, _b = _a.isError, isError = _b === void 0 ? function (err, ctx) { return ({
43
44
  children: React.createElement(React.Fragment, null),
44
45
  description: (React.createElement(React.Fragment, null,
45
46
  React.createElement(StatusMessage, { type: "error" }, err.message))),
46
- actions: (React.createElement(React.Fragment, null, (ctx === null || ctx === void 0 ? void 0 : ctx.refetch) && (React.createElement(Button, { onClick: function () { return ctx.refetch(); } }, "Tentar Novamente"))))
47
+ actions: (React.createElement(React.Fragment, null, (ctx === null || ctx === void 0 ? void 0 : ctx.refetch) && (React.createElement(ButtonWrapper, null,
48
+ React.createElement(Button, { onClick: function () { return ctx.refetch(); } }, "Tentar Novamente")))))
47
49
  }); } : _b, _c = _a.onLoading, onLoading = _c === void 0 ? function () { return React.createElement(React.Fragment, null); } : _c, ctx = _a.ctx, className = _a.className, _d = _a.hideHeader, hideHeader = _d === void 0 ? false : _d, _e = _a.minimized, minimized = _e === void 0 ? false : _e, headerProps = __rest(_a, ["onSuccess", "isError", "onLoading", "ctx", "className", "hideHeader", "minimized"]);
48
50
  var _f = useToggle(!minimized), isOpen = _f[0], toggleOpen = _f[1];
49
51
  if (!ctx)
@@ -66,7 +68,9 @@ export var Section = function (_a) {
66
68
  var renderHeader = function (props) { return (React.createElement(Header, __assign({ printBar: renderedResponse !== null && isOpen }, props, { className: cn(className, type !== undefined && headerStatus[type]
67
69
  ? headerStatus[type]
68
70
  : '', props.className), variant: type === RequestStatus.Loading ? 'loading' : props.variant, loadingProps: {
69
- percentage: progress !== null && progress !== void 0 ? progress : 0
71
+ percentage: progress !== null && progress !== void 0 ? progress : 0,
72
+ activeRequests: ctx.activeRequests,
73
+ hidden: false
70
74
  }, actions: React.createElement(React.Fragment, null,
71
75
  props.actions,
72
76
  renderedResponse && defaultHeaderActions) }))); };
@@ -81,11 +85,11 @@ export var Section = function (_a) {
81
85
  !hideHeader && renderHeader(unifiedHeaderProps),
82
86
  React.createElement(ShowRenderedChildren, { isOpen: isOpen }, renderedChildren)));
83
87
  };
84
- var ShowRenderedChildren = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: ", ";\n"], ["\n display: ", ";\n"])), function (props) { return (props.isOpen ? 'block' : 'none'); });
88
+ var ShowRenderedChildren = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: ", ";\n"], ["\n display: ", ";\n"])), function (props) { return (props.isOpen ? 'block' : 'none'); });
85
89
  export var headerStatus = (_a = {},
86
90
  _a[RequestStatus === null || RequestStatus === void 0 ? void 0 : RequestStatus.Loading] = 'external-source loading',
87
91
  _a[RequestStatus === null || RequestStatus === void 0 ? void 0 : RequestStatus.Success] = 'success',
88
92
  _a[RequestStatus === null || RequestStatus === void 0 ? void 0 : RequestStatus.Error] = 'external-source error',
89
93
  _a[RequestStatus === null || RequestStatus === void 0 ? void 0 : RequestStatus.Empty] = 'external-source error',
90
94
  _a);
91
- var templateObject_1;
95
+ var templateObject_1, templateObject_2;
@@ -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,33 @@ 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
+ var _h = useState(false), shouldRetry = _h[0], setShouldRetry = _h[1];
27
+ var _j = useState(false), requestCompleted = _j[0], setRequestCompleted = _j[1];
28
+ var simulateProgress = useCallback(function () {
29
+ setProgress(0);
30
+ var currentProgress = 0;
31
+ var interval = setInterval(function () {
32
+ currentProgress += 15;
33
+ setProgress(Math.min(currentProgress, 90));
34
+ if (currentProgress >= 90) {
35
+ clearInterval(interval);
36
+ }
37
+ }, 300);
38
+ return function () { return clearInterval(interval); };
39
+ }, []);
23
40
  var fetchData = useCallback(function () {
41
+ if (loading || requestCompleted)
42
+ return;
24
43
  setLoading(true);
25
44
  setError(null);
45
+ setShowLoadingBar(true);
46
+ simulateProgress();
47
+ var requestId = Date.now();
48
+ setRequestsMap(function (prev) { return new Map(prev.set(requestId, true)); });
26
49
  var abortController = new AbortController();
27
50
  client
28
51
  .request(query, data, urlData, abortController.signal)
@@ -32,24 +55,65 @@ export function CustomProvider(Provider, query) {
32
55
  document: document
33
56
  }); });
34
57
  })
35
- .then(function (parsedResponse) { return setResponse(parsedResponse); })
58
+ .then(function (parsedResponse) {
59
+ setResponse(parsedResponse);
60
+ setError(null);
61
+ setRequestCompleted(true);
62
+ })
36
63
  .catch(function (requestError) {
37
64
  if (requestError.name !== 'AbortError') {
38
65
  setError(requestError instanceof Error
39
66
  ? requestError
40
- : new Error(requestError));
67
+ : new Error(String(requestError)));
41
68
  }
69
+ setRequestCompleted(true);
42
70
  })
43
- .finally(function () { return setLoading(false); });
71
+ .finally(function () {
72
+ setLoading(false);
73
+ setRequestsMap(function (prev) {
74
+ var newMap = new Map(prev);
75
+ newMap.delete(requestId);
76
+ return newMap;
77
+ });
78
+ setProgress(100);
79
+ setTimeout(function () {
80
+ setShowLoadingBar(false);
81
+ }, 500);
82
+ });
44
83
  return function () {
45
84
  abortController.abort();
85
+ setRequestsMap(function (prev) {
86
+ var newMap = new Map(prev);
87
+ newMap.delete(requestId);
88
+ return newMap;
89
+ });
46
90
  };
47
- }, [client, query, data, urlData]);
91
+ }, [
92
+ client,
93
+ query,
94
+ data,
95
+ urlData,
96
+ loading,
97
+ simulateProgress,
98
+ requestCompleted
99
+ ]);
48
100
  useEffect(function () {
49
- var cleanup = fetchData();
50
- return cleanup;
51
- }, [fetchData]);
101
+ if (!response &&
102
+ !loading &&
103
+ requestsMap.size === 0 &&
104
+ !requestCompleted) {
105
+ fetchData();
106
+ }
107
+ }, [fetchData, response, loading, requestsMap, requestCompleted]);
108
+ useEffect(function () {
109
+ if (shouldRetry) {
110
+ setShouldRetry(false);
111
+ setRequestCompleted(false);
112
+ fetchData();
113
+ }
114
+ }, [shouldRetry, fetchData]);
52
115
  var contextValue = useMemo(function () {
116
+ var activeRequestsCount = requestsMap.size;
53
117
  return {
54
118
  type: error
55
119
  ? RequestStatus.Error
@@ -64,9 +128,24 @@ export function CustomProvider(Provider, query) {
64
128
  response: response === null || response === void 0 ? void 0 : response.response,
65
129
  document: response === null || response === void 0 ? void 0 : response.document,
66
130
  Section: Section,
67
- refetch: fetchData
131
+ refetch: function () {
132
+ setShouldRetry(true);
133
+ setRequestCompleted(false);
134
+ },
135
+ progress: progress,
136
+ activeRequests: activeRequestsCount,
137
+ showLoadingBar: showLoadingBar
68
138
  };
69
- }, [error, response, data, urlData, loading, fetchData]);
139
+ }, [
140
+ error,
141
+ response,
142
+ data,
143
+ urlData,
144
+ loading,
145
+ progress,
146
+ requestsMap,
147
+ showLoadingBar
148
+ ]);
70
149
  return (React.createElement(Provider.Provider, { value: contextValue }, children));
71
150
  };
72
151
  }
@@ -181,7 +260,10 @@ export function query(query) {
181
260
  response: undefined,
182
261
  document: undefined,
183
262
  data: undefined,
184
- urlData: undefined
263
+ urlData: undefined,
264
+ progress: 0,
265
+ activeRequests: 0,
266
+ showLoadingBar: false
185
267
  });
186
268
  return Object.assign(RequestContext, {
187
269
  Request: CustomProvider(RequestContext, query)