@credithub/harlan-components 1.107.0 → 1.108.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/components/consultaSimplesSection/consultaSimplesSection.js +10 -10
- package/dist/components/section.js +20 -10
- package/dist/components/webservice.d.ts +1 -0
- package/dist/components/webservice.js +52 -2
- package/lib/cjs/index.js +85 -25
- package/lib/esm/index.js +85 -25
- package/package.json +1 -1
|
@@ -48,13 +48,13 @@ var ClickableStatusMessage = styled(StatusMessage)(templateObject_3 || (template
|
|
|
48
48
|
// Wrapper para o texto clicável dentro do StatusMessage
|
|
49
49
|
var ClickableText = styled.span(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n cursor: pointer;\n &:hover {\n opacity: 0.85;\n }\n"], ["\n cursor: pointer;\n &:hover {\n opacity: 0.85;\n }\n"])));
|
|
50
50
|
var ConsultaSimplesSection = function (_a) {
|
|
51
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w
|
|
52
|
-
var documento = _a.documento, children = _a.children, onClose = _a.onClose, onClickPrint = _a.onClickPrint, isFinancial = _a.isFinancial, ctime = _a.ctime, printMode = _a.printMode,
|
|
51
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
52
|
+
var documento = _a.documento, children = _a.children, onClose = _a.onClose, onClickPrint = _a.onClickPrint, isFinancial = _a.isFinancial, ctime = _a.ctime, printMode = _a.printMode, _x = _a.tags, tags = _x === void 0 ? [] : _x, rest = __rest(_a, ["documento", "children", "onClose", "onClickPrint", "isFinancial", "ctime", "printMode", "tags"]);
|
|
53
53
|
var ctx = useContext(Queries.Finder);
|
|
54
54
|
var data = useGlobalData().data;
|
|
55
55
|
var posthog = usePostHog().posthog;
|
|
56
56
|
// Hook para observar mutações no DOM e chamar callback quando estável
|
|
57
|
-
var
|
|
57
|
+
var _y = usePrintWhenStable({
|
|
58
58
|
debounceTime: 500,
|
|
59
59
|
maxWaitTime: 30000,
|
|
60
60
|
onStart: function () {
|
|
@@ -65,7 +65,7 @@ var ConsultaSimplesSection = function (_a) {
|
|
|
65
65
|
// Chama o callback externo (Harlan decide como imprimir)
|
|
66
66
|
onClickPrint === null || onClickPrint === void 0 ? void 0 : onClickPrint();
|
|
67
67
|
}
|
|
68
|
-
}), printWhenStable =
|
|
68
|
+
}), printWhenStable = _y.printWhenStable, isWaiting = _y.isWaiting;
|
|
69
69
|
// Handler que usa o observer ao invés de imprimir diretamente
|
|
70
70
|
var handlePrint = function () {
|
|
71
71
|
printWhenStable();
|
|
@@ -136,7 +136,7 @@ var ConsultaSimplesSection = function (_a) {
|
|
|
136
136
|
data.liminar.message === 'Encontrado')
|
|
137
137
|
? 'Indício de Liminar'
|
|
138
138
|
: '', (_q = data.liminar) === null || _q === void 0 ? void 0 : _q.error),
|
|
139
|
-
makeItem('Potenciais Protestos Entrantes', (_r = data.editalData) === null || _r === void 0 ? void 0 : _r.
|
|
139
|
+
makeItem('Potenciais Protestos Entrantes', true, ((_r = data.editalData) === null || _r === void 0 ? void 0 : _r.recentesCount)
|
|
140
140
|
? "".concat(data.editalData.recentesCount === 1 ? '1 Potencial Protesto Entrante' : "".concat(data.editalData.recentesCount, " Potenciais Protestos Entrantes"))
|
|
141
141
|
: ''
|
|
142
142
|
// Não exibe erro de edital - deve falhar silenciosamente
|
|
@@ -155,8 +155,8 @@ var ConsultaSimplesSection = function (_a) {
|
|
|
155
155
|
data.dividasPublicas ||
|
|
156
156
|
data.processosJuridicos ||
|
|
157
157
|
receitaStatus ||
|
|
158
|
-
((
|
|
159
|
-
(((
|
|
158
|
+
((_s = data.liminar) === null || _s === void 0 ? void 0 : _s.message) === 'Encontrado' ||
|
|
159
|
+
(((_t = data.editalData) === null || _t === void 0 ? void 0 : _t.recentesCount) &&
|
|
160
160
|
hasOneOfTags(tags, ['diamante', 'diamante-new']));
|
|
161
161
|
var statusType = isError ? 'warning' : hasPendencias ? 'error' : 'success';
|
|
162
162
|
useEffect(function () {
|
|
@@ -283,13 +283,13 @@ var ConsultaSimplesSection = function (_a) {
|
|
|
283
283
|
}
|
|
284
284
|
return item.text ? (item.label === 'Potenciais Protestos Entrantes' ? (React.createElement(ClickableStatusMessage, { key: item.label, type: "error", onClick: scrollToEditais, title: "Clique para ver detalhes" }, item.text)) : (React.createElement(StatusMessage, { key: item.label, type: "error" }, item.text))) : null;
|
|
285
285
|
}),
|
|
286
|
-
((
|
|
287
|
-
!!((
|
|
286
|
+
((_u = data.editalData) === null || _u === void 0 ? void 0 : _u.isLoaded) &&
|
|
287
|
+
!!((_v = data.editalData) === null || _v === void 0 ? void 0 : _v.vencidosCount) &&
|
|
288
288
|
data.editalData.vencidosCount > 0 &&
|
|
289
289
|
hasOneOfTags(tags, ['diamante', 'diamante-new']) && (React.createElement(StatusMessage, { type: "error" },
|
|
290
290
|
React.createElement(ClickableText, { onClick: scrollToEditais, title: "Clique para ver detalhes" },
|
|
291
291
|
"Cart\u00F3rio com dificuldade para intimar",
|
|
292
|
-
((
|
|
292
|
+
((_w = data.editalData) === null || _w === void 0 ? void 0 : _w.dataEditalMaisAntigo) &&
|
|
293
293
|
" desde o: ".concat(data.editalData.dataEditalMaisAntigo))))), onClose: onClose, icon: ConsultaSimplesIcon, variant: isLoading ? 'loading' : 'default', ctx: ctx, loadingProps: {
|
|
294
294
|
percentage: (ctx === null || ctx === void 0 ? void 0 : ctx.progress) || 0,
|
|
295
295
|
hidden: !isLoading
|
|
@@ -57,7 +57,7 @@ var Section = forwardRef(function (_a, ref) {
|
|
|
57
57
|
var printMode = usePrintMode().printMode;
|
|
58
58
|
if (!ctx)
|
|
59
59
|
return null;
|
|
60
|
-
var type = ctx.type, progress = ctx.progress;
|
|
60
|
+
var type = ctx.type, progress = ctx.progress, warningMessage = ctx.warningMessage;
|
|
61
61
|
var renderResponse = useCallback(function () {
|
|
62
62
|
switch (type) {
|
|
63
63
|
case RequestStatus.Success:
|
|
@@ -79,18 +79,28 @@ var Section = forwardRef(function (_a, ref) {
|
|
|
79
79
|
}
|
|
80
80
|
}, [type, onSuccess, isError, onLoading, ctx, printMode]);
|
|
81
81
|
var renderedResponse = renderResponse();
|
|
82
|
+
var descriptionWithWarning = useCallback(function (description) {
|
|
83
|
+
if (!warningMessage)
|
|
84
|
+
return description;
|
|
85
|
+
return (React.createElement(React.Fragment, null,
|
|
86
|
+
React.createElement(StatusMessage, { type: "warning" }, warningMessage),
|
|
87
|
+
description));
|
|
88
|
+
}, [warningMessage]);
|
|
82
89
|
var defaultHeaderActions = useMemo(function () {
|
|
83
90
|
return !printMode ? (React.createElement(BtnWrapper, { hidden: type === RequestStatus.Loading, onClick: toggleOpen }, isOpen ? React.createElement(ChevronUp, null) : React.createElement(ChevronDown, null))) : null;
|
|
84
91
|
}, [type, isOpen, toggleOpen, printMode]);
|
|
85
|
-
var renderHeader = function (props) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
var renderHeader = function (props) {
|
|
93
|
+
var description = props.description, actions = props.actions, rest = __rest(props, ["description", "actions"]);
|
|
94
|
+
return (React.createElement(Header, __assign({ printBar: renderedResponse !== null && isOpen }, rest, { description: descriptionWithWarning(description), className: cn(className, type !== undefined && headerStatus[type]
|
|
95
|
+
? headerStatus[type]
|
|
96
|
+
: '', props.className), variant: type === RequestStatus.Loading ? 'loading' : props.variant, loadingProps: {
|
|
97
|
+
percentage: progress !== null && progress !== void 0 ? progress : 0,
|
|
98
|
+
activeRequests: ctx.activeRequests,
|
|
99
|
+
hidden: false
|
|
100
|
+
}, actions: React.createElement(React.Fragment, null,
|
|
101
|
+
actions,
|
|
102
|
+
renderedResponse && defaultHeaderActions) })));
|
|
103
|
+
};
|
|
94
104
|
if (React.isValidElement(renderedResponse)) {
|
|
95
105
|
return (React.createElement(PrintSectionWrapper, { enabled: !hideHeader },
|
|
96
106
|
!hideHeader && renderHeader(headerProps),
|
|
@@ -62,6 +62,53 @@ export var RequestStatus;
|
|
|
62
62
|
RequestStatus[RequestStatus["Success"] = 2] = "Success";
|
|
63
63
|
RequestStatus[RequestStatus["Error"] = 3] = "Error";
|
|
64
64
|
})(RequestStatus || (RequestStatus = {}));
|
|
65
|
+
var isDocument = function (value) {
|
|
66
|
+
return typeof Document !== 'undefined' && value instanceof Document;
|
|
67
|
+
};
|
|
68
|
+
var extractWarningFromDocument = function (document) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
if (!document)
|
|
71
|
+
return null;
|
|
72
|
+
if (isDocument(document)) {
|
|
73
|
+
var header = document.querySelector('header');
|
|
74
|
+
if (!header)
|
|
75
|
+
return null;
|
|
76
|
+
var warningElement = (_a = header.querySelector('warning, Warning, WARNING')) !== null && _a !== void 0 ? _a : null;
|
|
77
|
+
if (warningElement === null || warningElement === void 0 ? void 0 : warningElement.textContent) {
|
|
78
|
+
var text = warningElement.textContent.trim();
|
|
79
|
+
if (text)
|
|
80
|
+
return text;
|
|
81
|
+
}
|
|
82
|
+
var attributeWarning = (_b = header.getAttribute('_warning')) !== null && _b !== void 0 ? _b : header.getAttribute('warning');
|
|
83
|
+
if (attributeWarning) {
|
|
84
|
+
var trimmed = attributeWarning.trim();
|
|
85
|
+
if (trimmed)
|
|
86
|
+
return trimmed;
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
if (typeof document === 'object') {
|
|
91
|
+
var warning = document._warning;
|
|
92
|
+
if (typeof warning === 'string') {
|
|
93
|
+
var trimmed = warning.trim();
|
|
94
|
+
return trimmed ? trimmed : null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (typeof document === 'string') {
|
|
98
|
+
try {
|
|
99
|
+
var parsed = JSON.parse(document);
|
|
100
|
+
var warning = parsed === null || parsed === void 0 ? void 0 : parsed._warning;
|
|
101
|
+
if (typeof warning === 'string') {
|
|
102
|
+
var trimmed = warning.trim();
|
|
103
|
+
return trimmed ? trimmed : null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (_c) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
};
|
|
65
112
|
export function CustomProvider(Provider, query) {
|
|
66
113
|
return function (_a) {
|
|
67
114
|
var children = _a.children, data = _a.data, urlData = _a.urlData, _b = _a.depends, depends = _b === void 0 ? [] : _b;
|
|
@@ -181,6 +228,7 @@ export function CustomProvider(Provider, query) {
|
|
|
181
228
|
}, [shouldRetry, fetchData]);
|
|
182
229
|
var contextValue = useMemo(function () {
|
|
183
230
|
var activeRequestsCount = requestsMap.size;
|
|
231
|
+
var warningMessage = extractWarningFromDocument(response === null || response === void 0 ? void 0 : response.document);
|
|
184
232
|
return {
|
|
185
233
|
type: error
|
|
186
234
|
? RequestStatus.Error
|
|
@@ -201,7 +249,8 @@ export function CustomProvider(Provider, query) {
|
|
|
201
249
|
},
|
|
202
250
|
progress: progress,
|
|
203
251
|
activeRequests: activeRequestsCount,
|
|
204
|
-
showLoadingBar: showLoadingBar
|
|
252
|
+
showLoadingBar: showLoadingBar,
|
|
253
|
+
warningMessage: warningMessage
|
|
205
254
|
};
|
|
206
255
|
}, [
|
|
207
256
|
error,
|
|
@@ -378,7 +427,8 @@ export function query(query) {
|
|
|
378
427
|
urlData: undefined,
|
|
379
428
|
progress: 0,
|
|
380
429
|
activeRequests: 0,
|
|
381
|
-
showLoadingBar: false
|
|
430
|
+
showLoadingBar: false,
|
|
431
|
+
warningMessage: null
|
|
382
432
|
});
|
|
383
433
|
return Object.assign(RequestContext, {
|
|
384
434
|
Request: CustomProvider(RequestContext, query)
|