@credithub/harlan-components 1.32.0 → 1.34.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.
- package/dist/assets/btn/buttonAtualizarDadosRfb.d.ts +3 -0
- package/dist/assets/btn/buttonAtualizarDadosRfb.js +10 -0
- package/dist/components/adresses/addresses.d.ts +2 -2
- package/dist/components/adresses/addresses.js +34 -12
- package/dist/components/adresses/map.js +1 -1
- package/dist/components/bank-accounts/bank-accounts.js +32 -28
- package/dist/components/ccf/ccf.js +2 -2
- package/dist/components/chart/chartSystem.js +51 -29
- package/dist/components/chart/hooks/useChartData.d.ts +6 -0
- package/dist/components/chart/hooks/useChartData.js +57 -4
- package/dist/components/chart/utils/chartUtils.d.ts +0 -4
- package/dist/components/chart/utils/chartUtils.js +0 -16
- package/dist/components/common/button.d.ts +1 -0
- package/dist/components/common/button.js +11 -24
- package/dist/components/consultaRfb.d.ts +2 -0
- package/dist/components/consultaRfb.js +17 -14
- package/dist/components/consultaSimplesSection/consultaSimplesSection.js +2 -2
- package/dist/components/contacts/contacts.js +8 -5
- package/dist/components/dividasPublicas/dividasPublicas.js +40 -40
- package/dist/components/dominios/dominios.js +17 -6
- package/dist/components/dossie/dossie.js +20 -10
- package/dist/components/dossie/summary/cardsAndProducts.d.ts +6 -8
- package/dist/components/dossie/summary/cardsAndProducts.js +94 -26
- package/dist/components/dossie/summary/styles.d.ts +12 -0
- package/dist/components/dossie/summary/styles.js +38 -0
- package/dist/components/dossie/summary/summary.js +7 -16
- package/dist/components/dossie/summary/utils.js +12 -2
- package/dist/components/imoveis/imoveisService.js +26 -13
- package/dist/components/interface/header.js +3 -3
- package/dist/components/interface/loadingBar.js +3 -6
- package/dist/components/interface/section.d.ts +2 -0
- package/dist/components/interface/section.js +7 -6
- package/dist/components/liminar/liminar.js +25 -15
- package/dist/components/llama/llama.d.ts +6 -0
- package/dist/components/llama/llama.js +122 -0
- package/dist/components/partners/partnerList.js +1 -1
- package/dist/components/partners/partners.js +28 -8
- package/dist/components/pep/pep.js +13 -6
- package/dist/components/processos-juridicos/processosJuridicos.js +19 -13
- package/dist/components/protestos/protestos.js +54 -39
- package/dist/components/refinBoaVista/refinBoaVista.js +31 -15
- package/dist/components/refinSerasa/refinSerasa.js +25 -38
- package/dist/components/score/scoreService.js +27 -13
- package/dist/components/scr/scr.js +123 -59
- package/dist/components/section.d.ts +3 -0
- package/dist/components/section.js +91 -0
- package/dist/components/veiculos/veiculos.js +28 -12
- package/dist/components/webservice.d.ts +22 -29
- package/dist/components/webservice.js +92 -131
- package/dist/consultaSimples.js +2 -2
- package/dist/hooks/useConsultaRfb.d.ts +1 -0
- package/lib/cjs/index.js +1448 -1030
- package/lib/esm/index.js +1449 -1031
- package/package.json +1 -1
|
@@ -1,42 +1,6 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
-
var t = {};
|
|
18
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
-
t[p] = s[p];
|
|
20
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
-
t[p[i]] = s[p[i]];
|
|
24
|
-
}
|
|
25
|
-
return t;
|
|
26
|
-
};
|
|
27
|
-
var _a;
|
|
28
|
-
import BtnWrapper from '../assets/btn/btnWrapper';
|
|
29
|
-
import ChevronDown from '../assets/btn/chevronDown';
|
|
30
|
-
import ChevronUp from '../assets/btn/chevronUp';
|
|
31
|
-
import useToggle from '../hooks/useToggle';
|
|
32
1
|
import { Client } from '@credithub/webservice';
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import styled from 'styled-components';
|
|
36
|
-
import Button from './common/button';
|
|
37
|
-
import { PrintSectionWrapper } from './common/printSectionWrapper';
|
|
38
|
-
import Header from './interface/header';
|
|
39
|
-
import StatusMessage from './interface/statusMessage';
|
|
2
|
+
import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { Section } from './section';
|
|
40
4
|
export var WebService = createContext(new Client.WebService());
|
|
41
5
|
export var WebServiceProvider = function (_a) {
|
|
42
6
|
var credential = _a.credential, children = _a.children;
|
|
@@ -49,16 +13,17 @@ export var RequestStatus;
|
|
|
49
13
|
RequestStatus[RequestStatus["Success"] = 2] = "Success";
|
|
50
14
|
RequestStatus[RequestStatus["Error"] = 3] = "Error";
|
|
51
15
|
})(RequestStatus || (RequestStatus = {}));
|
|
52
|
-
function CustomProvider(Provider, query) {
|
|
16
|
+
export function CustomProvider(Provider, query) {
|
|
53
17
|
return function (_a) {
|
|
54
18
|
var children = _a.children, data = _a.data, urlData = _a.urlData;
|
|
55
19
|
var client = useContext(WebService);
|
|
56
|
-
var abortController = useMemo(function () { return new AbortController(); }, []);
|
|
57
20
|
var _b = useState(null), response = _b[0], setResponse = _b[1];
|
|
58
21
|
var _c = useState(null), error = _c[0], setError = _c[1];
|
|
22
|
+
var _d = useState(true), loading = _d[0], setLoading = _d[1];
|
|
59
23
|
var fetchData = useCallback(function () {
|
|
24
|
+
setLoading(true);
|
|
60
25
|
setError(null);
|
|
61
|
-
|
|
26
|
+
var abortController = new AbortController();
|
|
62
27
|
client
|
|
63
28
|
.request(query, data, urlData, abortController.signal)
|
|
64
29
|
.then(function (response) {
|
|
@@ -67,46 +32,70 @@ function CustomProvider(Provider, query) {
|
|
|
67
32
|
document: document
|
|
68
33
|
}); });
|
|
69
34
|
})
|
|
70
|
-
.then(function (
|
|
35
|
+
.then(function (parsedResponse) { return setResponse(parsedResponse); })
|
|
71
36
|
.catch(function (requestError) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
37
|
+
if (requestError.name !== 'AbortError') {
|
|
38
|
+
setError(requestError instanceof Error
|
|
39
|
+
? requestError
|
|
40
|
+
: new Error(requestError));
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
.finally(function () { return setLoading(false); });
|
|
44
|
+
return function () {
|
|
45
|
+
abortController.abort();
|
|
46
|
+
};
|
|
47
|
+
}, [client, query, data, urlData]);
|
|
77
48
|
useEffect(function () {
|
|
78
|
-
fetchData();
|
|
79
|
-
return
|
|
49
|
+
var cleanup = fetchData();
|
|
50
|
+
return cleanup;
|
|
80
51
|
}, [fetchData]);
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
52
|
+
var contextValue = useMemo(function () {
|
|
53
|
+
return {
|
|
54
|
+
type: error
|
|
55
|
+
? RequestStatus.Error
|
|
56
|
+
: response
|
|
57
|
+
? RequestStatus.Success
|
|
58
|
+
: loading
|
|
59
|
+
? RequestStatus.Loading
|
|
60
|
+
: RequestStatus.Empty,
|
|
61
|
+
error: error,
|
|
62
|
+
data: data,
|
|
63
|
+
urlData: urlData,
|
|
64
|
+
response: response === null || response === void 0 ? void 0 : response.response,
|
|
65
|
+
document: response === null || response === void 0 ? void 0 : response.document,
|
|
66
|
+
Section: Section,
|
|
67
|
+
refetch: fetchData
|
|
68
|
+
};
|
|
69
|
+
}, [error, response, data, urlData, loading, fetchData]);
|
|
70
|
+
return (React.createElement(Provider.Provider, { value: contextValue }, children));
|
|
99
71
|
};
|
|
100
72
|
}
|
|
101
73
|
export function useQuery(query, data, enabled) {
|
|
102
74
|
if (enabled === void 0) { enabled = true; }
|
|
103
75
|
var client = useContext(WebService);
|
|
104
|
-
var abortController = useMemo(function () { return new AbortController(); }, []);
|
|
105
76
|
var _a = useState(null), response = _a[0], setResponse = _a[1];
|
|
106
77
|
var _b = useState(null), error = _b[0], setError = _b[1];
|
|
107
|
-
var _c = useState(
|
|
78
|
+
var _c = useState(false), isLoading = _c[0], setIsLoading = _c[1];
|
|
79
|
+
var _d = useState(false), shouldFetch = _d[0], setShouldFetch = _d[1];
|
|
80
|
+
var loadingProgressRef = useRef(0);
|
|
81
|
+
var simulateProgress = useCallback(function () {
|
|
82
|
+
loadingProgressRef.current = 0;
|
|
83
|
+
var progress = 0;
|
|
84
|
+
var interval = setInterval(function () {
|
|
85
|
+
progress += 15;
|
|
86
|
+
loadingProgressRef.current = progress;
|
|
87
|
+
if (progress >= 90) {
|
|
88
|
+
clearInterval(interval);
|
|
89
|
+
}
|
|
90
|
+
}, 300);
|
|
91
|
+
return function () { return clearInterval(interval); };
|
|
92
|
+
}, []);
|
|
108
93
|
var fetch = useCallback(function () {
|
|
94
|
+
if (!shouldFetch)
|
|
95
|
+
return;
|
|
109
96
|
setIsLoading(true);
|
|
97
|
+
simulateProgress();
|
|
98
|
+
var abortController = new AbortController();
|
|
110
99
|
client
|
|
111
100
|
.request(query, data, undefined, abortController.signal)
|
|
112
101
|
.then(function (response) {
|
|
@@ -115,23 +104,41 @@ export function useQuery(query, data, enabled) {
|
|
|
115
104
|
document: document
|
|
116
105
|
}); });
|
|
117
106
|
})
|
|
118
|
-
.then(function (
|
|
107
|
+
.then(function (parsedResponse) {
|
|
108
|
+
setResponse(parsedResponse);
|
|
109
|
+
setError(null);
|
|
110
|
+
loadingProgressRef.current = 100;
|
|
111
|
+
})
|
|
119
112
|
.catch(function (requestError) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
if (requestError.name !== 'AbortError') {
|
|
114
|
+
setError(requestError instanceof Error
|
|
115
|
+
? requestError
|
|
116
|
+
: new Error(String(requestError)));
|
|
117
|
+
}
|
|
118
|
+
loadingProgressRef.current = 100;
|
|
123
119
|
})
|
|
124
|
-
.finally(function () {
|
|
125
|
-
|
|
120
|
+
.finally(function () {
|
|
121
|
+
setIsLoading(false);
|
|
122
|
+
setShouldFetch(false);
|
|
123
|
+
});
|
|
124
|
+
return function () { return abortController.abort(); };
|
|
125
|
+
}, [shouldFetch, client, query, data, simulateProgress]);
|
|
126
|
+
useEffect(function () {
|
|
127
|
+
if (enabled && !isLoading && !shouldFetch && !response && !error) {
|
|
128
|
+
setShouldFetch(true);
|
|
129
|
+
}
|
|
130
|
+
}, [enabled, isLoading, shouldFetch, response, error]);
|
|
126
131
|
useEffect(function () {
|
|
127
|
-
if (
|
|
132
|
+
if (shouldFetch) {
|
|
128
133
|
fetch();
|
|
129
|
-
|
|
134
|
+
}
|
|
135
|
+
}, [fetch, shouldFetch]);
|
|
130
136
|
return {
|
|
131
137
|
response: response,
|
|
132
138
|
error: error,
|
|
133
139
|
isLoading: isLoading,
|
|
134
|
-
|
|
140
|
+
loadingProgress: loadingProgressRef.current,
|
|
141
|
+
refetch: useCallback(function () { return setShouldFetch(true); }, [])
|
|
135
142
|
};
|
|
136
143
|
}
|
|
137
144
|
export function useMutation(query, data) {
|
|
@@ -168,11 +175,13 @@ export function useMutation(query, data) {
|
|
|
168
175
|
export function query(query) {
|
|
169
176
|
var RequestContext = createContext({
|
|
170
177
|
type: RequestStatus.Empty,
|
|
171
|
-
Section:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
178
|
+
Section: Section,
|
|
179
|
+
refetch: function () { },
|
|
180
|
+
error: null,
|
|
181
|
+
response: undefined,
|
|
182
|
+
document: undefined,
|
|
183
|
+
data: undefined,
|
|
184
|
+
urlData: undefined
|
|
176
185
|
});
|
|
177
186
|
return Object.assign(RequestContext, {
|
|
178
187
|
Request: CustomProvider(RequestContext, query)
|
|
@@ -188,51 +197,3 @@ export var Queries = {
|
|
|
188
197
|
Dominios: query("SELECT FROM 'DOMINIOS'.'CONSULTA'"),
|
|
189
198
|
GraficosAnaliticos: query("SELECT FROM 'DOCUMENTHISTORY'.'BASICHISTORY'")
|
|
190
199
|
};
|
|
191
|
-
var Section = function (_a) {
|
|
192
|
-
var onSuccess = _a.onSuccess, _b = _a.isError, isError = _b === void 0 ? function (err, ctx) { return ({
|
|
193
|
-
children: React.createElement(React.Fragment, null),
|
|
194
|
-
description: (React.createElement(React.Fragment, null,
|
|
195
|
-
React.createElement(StatusMessage, { type: "warning" }, err.message))),
|
|
196
|
-
actions: (React.createElement(React.Fragment, null,
|
|
197
|
-
React.createElement(Button, { onClick: function () { return ctx.refetch(); } }, "Tentar Novamente")))
|
|
198
|
-
}); } : _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"]);
|
|
199
|
-
var _f = useToggle(!minimized), isOpen = _f[0], toggleOpen = _f[1];
|
|
200
|
-
if (!ctx)
|
|
201
|
-
return null;
|
|
202
|
-
var type = ctx.type;
|
|
203
|
-
var renderResponse = useCallback(function () {
|
|
204
|
-
switch (type) {
|
|
205
|
-
case RequestStatus.Success:
|
|
206
|
-
return onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(ctx.document, ctx);
|
|
207
|
-
case RequestStatus.Error:
|
|
208
|
-
return isError(ctx.error, ctx);
|
|
209
|
-
case RequestStatus.Loading:
|
|
210
|
-
return onLoading(ctx);
|
|
211
|
-
default:
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
}, [type, onSuccess, isError, onLoading, null, ctx]);
|
|
215
|
-
var renderedResponse = renderResponse();
|
|
216
|
-
var defaultHeaderActions = useMemo(function () { return (React.createElement(BtnWrapper, { hidden: type === RequestStatus.Loading, onClick: toggleOpen }, isOpen ? React.createElement(ChevronUp, null) : React.createElement(ChevronDown, null))); }, [type, isOpen, toggleOpen]);
|
|
217
|
-
var renderHeader = function (props) { return (React.createElement(Header, __assign({ printBar: renderedResponse !== null && isOpen }, props, { className: cn(className, headerStatus[type], props.className), variant: type === RequestStatus.Loading ? 'loading' : props.variant, actions: React.createElement(React.Fragment, null,
|
|
218
|
-
props.actions,
|
|
219
|
-
renderedResponse && defaultHeaderActions) }))); };
|
|
220
|
-
if (React.isValidElement(renderedResponse)) {
|
|
221
|
-
return (React.createElement(PrintSectionWrapper, { enabled: !hideHeader },
|
|
222
|
-
!hideHeader && renderHeader(headerProps),
|
|
223
|
-
React.createElement(ShowRenderedChildren, { isOpen: isOpen }, renderedResponse)));
|
|
224
|
-
}
|
|
225
|
-
var _g = renderedResponse, renderedChildren = _g.children, headerReplaceProps = __rest(_g, ["children"]);
|
|
226
|
-
var headerPropsUnified = __assign(__assign(__assign({}, headerProps), headerReplaceProps), { printBar: renderedChildren !== null && isOpen });
|
|
227
|
-
return (React.createElement(PrintSectionWrapper, { enabled: !hideHeader },
|
|
228
|
-
!hideHeader && renderHeader(headerPropsUnified),
|
|
229
|
-
React.createElement(ShowRenderedChildren, { isOpen: isOpen }, renderedChildren)));
|
|
230
|
-
};
|
|
231
|
-
var ShowRenderedChildren = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: ", ";\n"], ["\n display: ", ";\n"])), function (props) { return (props.isOpen ? 'block' : 'none'); });
|
|
232
|
-
export var headerStatus = (_a = {},
|
|
233
|
-
_a[RequestStatus.Loading] = 'external-source loading',
|
|
234
|
-
_a[RequestStatus.Success] = 'success',
|
|
235
|
-
_a[RequestStatus.Error] = 'external-source error',
|
|
236
|
-
_a[RequestStatus.Empty] = 'external-source error',
|
|
237
|
-
_a);
|
|
238
|
-
var templateObject_1;
|
package/dist/consultaSimples.js
CHANGED
|
@@ -11,12 +11,12 @@ import ConsultaSimplesSection from './components/consultaSimplesSection/consulta
|
|
|
11
11
|
import { ConsultasComplementaresProvider } from './components/consultasComplementares';
|
|
12
12
|
import Dominios from './components/dominios/dominios';
|
|
13
13
|
import ConsultaImoveis from './components/imoveis/imoveisService';
|
|
14
|
-
import GlobalStyle from './styles/globalStyle';
|
|
15
|
-
import theme from './styles/theme';
|
|
16
14
|
import Liminar from './components/liminar/liminar';
|
|
17
15
|
import ConsultaScore from './components/score/scoreService';
|
|
18
16
|
import ConsultaSCR from './components/scr/scr';
|
|
19
17
|
import { GlobalDataProvider } from './contexts/globalDataContext';
|
|
18
|
+
import GlobalStyle from './styles/globalStyle';
|
|
19
|
+
import theme from './styles/theme';
|
|
20
20
|
Chart.register.apply(Chart, registerables);
|
|
21
21
|
var Wrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-family: 'Open Sans Condensed';\n display: flex;\n flex-direction: column;\n gap: 20px;\n\n * {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n }\n\n @media print {\n @page {\n size: auto;\n margin: 5mm;\n }\n }\n"], ["\n font-family: 'Open Sans Condensed';\n display: flex;\n flex-direction: column;\n gap: 20px;\n\n * {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n }\n\n @media print {\n @page {\n size: auto;\n margin: 5mm;\n }\n }\n"])));
|
|
22
22
|
var ConsultaSimples = function (_a) {
|