@credithub/harlan-components 1.109.4 → 1.111.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/btnWrapper.js +1 -1
- package/dist/components/common/button.d.ts +1 -0
- package/dist/components/common/button.js +6 -1
- package/dist/components/common/printButton.js +9 -2
- package/dist/components/section.js +39 -1
- package/dist/components/webservice.js +1 -1
- package/dist/consultaSimples.js +40 -38
- package/dist/contexts/printModeContext.js +11 -1
- package/dist/contexts/printReadinessContext.d.ts +29 -0
- package/dist/contexts/printReadinessContext.js +85 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/styles/globalStyle.js +1 -1
- package/lib/cjs/index.js +191 -45
- package/lib/esm/index.js +191 -47
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
5
|
import styled from 'styled-components';
|
|
6
|
-
var BtnWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 30px;\n height: 30px;\n background-color: ", ";\n border-radius: 50%;\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n\n @media print {\n display: none !important;\n visibility: hidden !important;\n pointer-events: none !important;\n }\n"], ["\n width: 30px;\n height: 30px;\n background-color: ", ";\n border-radius: 50%;\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n\n @media print {\n display: none !important;\n visibility: hidden !important;\n pointer-events: none !important;\n }\n"])), function (_a) {
|
|
6
|
+
var BtnWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 30px;\n height: 30px;\n background-color: ", ";\n border-radius: 50%;\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n\n @media print {\n display: none !important;\n visibility: hidden !important;\n pointer-events: none !important;\n }\n\n body.print-mode & {\n display: none !important;\n visibility: hidden !important;\n pointer-events: none !important;\n }\n"], ["\n width: 30px;\n height: 30px;\n background-color: ", ";\n border-radius: 50%;\n display: flex;\n justify-content: center;\n align-items: center;\n cursor: pointer;\n\n @media print {\n display: none !important;\n visibility: hidden !important;\n pointer-events: none !important;\n }\n\n body.print-mode & {\n display: none !important;\n visibility: hidden !important;\n pointer-events: none !important;\n }\n"])), function (_a) {
|
|
7
7
|
var theme = _a.theme;
|
|
8
8
|
return theme.colors.cinza85;
|
|
9
9
|
});
|
|
@@ -3,6 +3,7 @@ import React, { ReactNode } from 'react';
|
|
|
3
3
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
4
4
|
smallContent?: ReactNode;
|
|
5
5
|
isLoading?: boolean;
|
|
6
|
+
showInPrint?: boolean;
|
|
6
7
|
}
|
|
7
8
|
declare const Button: React.FC<ButtonProps>;
|
|
8
9
|
export default Button;
|
|
@@ -24,6 +24,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
24
24
|
}
|
|
25
25
|
return t;
|
|
26
26
|
};
|
|
27
|
+
import { usePrintMode } from '../../contexts/printModeContext';
|
|
27
28
|
import classNames from 'classnames';
|
|
28
29
|
import { SpinnerGap } from 'phosphor-react';
|
|
29
30
|
import React from 'react';
|
|
@@ -68,7 +69,11 @@ var SmallContent = styled.small(templateObject_5 || (templateObject_5 = __makeTe
|
|
|
68
69
|
return theme.colors.alerta;
|
|
69
70
|
});
|
|
70
71
|
var Button = function (_a) {
|
|
71
|
-
var children = _a.children, className = _a.className, smallContent = _a.smallContent, isLoading = _a.isLoading, props = __rest(_a, ["children", "className", "smallContent", "isLoading"]);
|
|
72
|
+
var children = _a.children, className = _a.className, smallContent = _a.smallContent, isLoading = _a.isLoading, _b = _a.showInPrint, showInPrint = _b === void 0 ? false : _b, props = __rest(_a, ["children", "className", "smallContent", "isLoading", "showInPrint"]);
|
|
73
|
+
var printMode = usePrintMode().printMode;
|
|
74
|
+
if (printMode && !showInPrint) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
72
77
|
var buttonClassName = classNames(className);
|
|
73
78
|
return (React.createElement(StyledButton, __assign({ className: buttonClassName, isLoading: isLoading }, props),
|
|
74
79
|
isLoading ? (React.createElement(React.Fragment, null,
|
|
@@ -32,14 +32,21 @@ var SkipButton = styled.button(templateObject_8 || (templateObject_8 = __makeTem
|
|
|
32
32
|
});
|
|
33
33
|
var PrintButton = function (_a) {
|
|
34
34
|
var onClick = _a.onClick, _b = _a.isLoading, isLoading = _b === void 0 ? false : _b, _c = _a.tooltipMessage, tooltipMessage = _c === void 0 ? 'Carregando dados das consultas...' : _c;
|
|
35
|
-
var
|
|
35
|
+
var requestImmediatePrint = function () {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
if (typeof window !== 'undefined') {
|
|
38
|
+
(_b = (_a = window.__harlanPrintState) === null || _a === void 0 ? void 0 : _a.forceReady) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
39
|
+
}
|
|
40
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
41
|
+
};
|
|
42
|
+
var button = (React.createElement(BtnWrapper, { onClick: !isLoading ? requestImmediatePrint : undefined },
|
|
36
43
|
React.createElement(IconContainer, null, isLoading ? React.createElement(Spinner, null) : React.createElement(PrintIcon, null))));
|
|
37
44
|
if (isLoading) {
|
|
38
45
|
return (React.createElement(TooltipWrapper, null,
|
|
39
46
|
React.createElement(Tooltip, { placement: "left", content: React.createElement(TooltipContent, null,
|
|
40
47
|
React.createElement(TooltipTitle, null, "\uD83D\uDCC4 Preparando impress\u00E3o"),
|
|
41
48
|
React.createElement(TooltipMessage, null, tooltipMessage),
|
|
42
|
-
onClick && (React.createElement(SkipButton, { onClick:
|
|
49
|
+
onClick && (React.createElement(SkipButton, { onClick: requestImmediatePrint }, "Imprimir agora"))), icon: button })));
|
|
43
50
|
}
|
|
44
51
|
return button;
|
|
45
52
|
};
|
|
@@ -29,9 +29,10 @@ import BtnWrapper from '../assets/btn/btnWrapper';
|
|
|
29
29
|
import ChevronDown from '../assets/btn/chevronDown';
|
|
30
30
|
import ChevronUp from '../assets/btn/chevronUp';
|
|
31
31
|
import { usePrintMode } from '../contexts/printModeContext';
|
|
32
|
+
import { usePrintReadiness } from '../contexts/printReadinessContext';
|
|
32
33
|
import useToggle from '../hooks/useToggle';
|
|
33
34
|
import cn from 'classnames';
|
|
34
|
-
import React, { forwardRef, useCallback, useMemo } from 'react';
|
|
35
|
+
import React, { forwardRef, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
35
36
|
import styled from 'styled-components';
|
|
36
37
|
import Button from './common/button';
|
|
37
38
|
import { PrintSectionWrapper } from './common/printSectionWrapper';
|
|
@@ -39,6 +40,40 @@ import Header from './interface/header';
|
|
|
39
40
|
import StatusMessage from './interface/statusMessage';
|
|
40
41
|
import { RequestStatus } from './webservice';
|
|
41
42
|
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"])));
|
|
43
|
+
var sectionIdCounter = 0;
|
|
44
|
+
var nextSectionId = function () {
|
|
45
|
+
sectionIdCounter += 1;
|
|
46
|
+
return "section-".concat(sectionIdCounter);
|
|
47
|
+
};
|
|
48
|
+
var stringifyTitle = function (title) {
|
|
49
|
+
if (typeof title === 'string')
|
|
50
|
+
return title;
|
|
51
|
+
return undefined;
|
|
52
|
+
};
|
|
53
|
+
var useSectionPrintBlocker = function (ctx, title, enabled, registerBlocker, resolveBlocker) {
|
|
54
|
+
var blockerIdRef = useRef(nextSectionId());
|
|
55
|
+
useEffect(function () {
|
|
56
|
+
if (!enabled)
|
|
57
|
+
return;
|
|
58
|
+
return function () {
|
|
59
|
+
resolveBlocker(blockerIdRef.current);
|
|
60
|
+
};
|
|
61
|
+
}, [enabled, resolveBlocker]);
|
|
62
|
+
useEffect(function () {
|
|
63
|
+
var _a;
|
|
64
|
+
if (!enabled || !ctx)
|
|
65
|
+
return;
|
|
66
|
+
var shouldBlock = ctx.type === RequestStatus.Loading ||
|
|
67
|
+
ctx.type === RequestStatus.Empty ||
|
|
68
|
+
((_a = ctx.activeRequests) !== null && _a !== void 0 ? _a : 0) > 0;
|
|
69
|
+
if (shouldBlock) {
|
|
70
|
+
registerBlocker(blockerIdRef.current, stringifyTitle(title));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
resolveBlocker(blockerIdRef.current);
|
|
74
|
+
}
|
|
75
|
+
}, [ctx, enabled, registerBlocker, resolveBlocker, title]);
|
|
76
|
+
};
|
|
42
77
|
var Section = forwardRef(function (_a, ref) {
|
|
43
78
|
var onSuccess = _a.onSuccess, _b = _a.isError, isError = _b === void 0 ? function (err, ctx) {
|
|
44
79
|
var shouldPush = (err === null || err === void 0 ? void 0 : err.push) === true;
|
|
@@ -55,6 +90,9 @@ var Section = forwardRef(function (_a, ref) {
|
|
|
55
90
|
} : _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"]);
|
|
56
91
|
var _f = useToggle(!minimized), isOpen = _f[0], toggleOpen = _f[1];
|
|
57
92
|
var printMode = usePrintMode().printMode;
|
|
93
|
+
var printReadiness = usePrintReadiness();
|
|
94
|
+
var readinessEnabled = Boolean(printMode && printReadiness.enabled);
|
|
95
|
+
useSectionPrintBlocker(ctx, headerProps === null || headerProps === void 0 ? void 0 : headerProps.title, readinessEnabled, printReadiness.registerBlocker, printReadiness.resolveBlocker);
|
|
58
96
|
if (!ctx)
|
|
59
97
|
return null;
|
|
60
98
|
var type = ctx.type, progress = ctx.progress, warningMessage = ctx.warningMessage;
|
|
@@ -436,7 +436,7 @@ export function query(query) {
|
|
|
436
436
|
}
|
|
437
437
|
export var Queries = {
|
|
438
438
|
Finder: query("SELECT FROM 'FINDER'.'BILLING'"),
|
|
439
|
-
Protestos: query("SELECT FROM '
|
|
439
|
+
Protestos: query("SELECT FROM 'APICENPROTTESTE'.'CONSULTA'"),
|
|
440
440
|
CCF: query("SELECT FROM 'SEEKLOC'.'CCF'"),
|
|
441
441
|
ProcessosJuridicos: query("SELECT FROM 'PROCESSOSJURIDICOS'.'PROCESSOS'"),
|
|
442
442
|
Liminar: query("SELECT FROM 'LIMINAR'.'CONSULTA'"),
|
package/dist/consultaSimples.js
CHANGED
|
@@ -23,6 +23,7 @@ import { PostHogProvider } from './contexts/PostHogContext';
|
|
|
23
23
|
import { ErrorModalProvider } from './contexts/errorModalContext';
|
|
24
24
|
import { GlobalDataProvider } from './contexts/globalDataContext';
|
|
25
25
|
import { PrintModeProvider } from './contexts/printModeContext';
|
|
26
|
+
import { PrintReadinessProvider } from './contexts/printReadinessContext';
|
|
26
27
|
import useToggle from './hooks/useToggle';
|
|
27
28
|
import GlobalStyle from './styles/globalStyle';
|
|
28
29
|
import theme from './styles/theme';
|
|
@@ -89,44 +90,45 @@ var ConsultaSimples = function (_a) {
|
|
|
89
90
|
React.createElement(ErrorModalProvider, null,
|
|
90
91
|
React.createElement(PostHogProvider, { posthog: posthog },
|
|
91
92
|
React.createElement(PrintModeProvider, { printMode: printMode },
|
|
92
|
-
React.createElement(
|
|
93
|
-
React.createElement(
|
|
94
|
-
React.createElement(
|
|
95
|
-
React.createElement(
|
|
96
|
-
React.createElement(Queries.
|
|
97
|
-
React.createElement(
|
|
98
|
-
React.createElement(
|
|
99
|
-
React.createElement(Queries.
|
|
100
|
-
React.createElement(Queries.
|
|
101
|
-
React.createElement(
|
|
102
|
-
React.createElement(
|
|
103
|
-
React.createElement(
|
|
104
|
-
React.createElement(
|
|
105
|
-
React.createElement(
|
|
106
|
-
React.createElement(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
React.createElement(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
93
|
+
React.createElement(PrintReadinessProvider, { enabled: Boolean(printMode) },
|
|
94
|
+
React.createElement(ConsultasComplementaresProvider, { hasCredits: hasCredits, initRefinBoaVista: initRefinBoaVista, initRefinSerasa: initRefinSerasa, initVeiculos: initVeiculos },
|
|
95
|
+
React.createElement(WebServiceProvider, { credential: apiKey, defaultData: queryParams === null || queryParams === void 0 ? void 0 : queryParams.data, defaultUrlData: queryParams === null || queryParams === void 0 ? void 0 : queryParams.urlData },
|
|
96
|
+
React.createElement(HasCreditsVerification, { documento: documento, apiKey: apiKey },
|
|
97
|
+
React.createElement(Queries.Dominios.Request, { data: { documento: documento, cnpj: documento } },
|
|
98
|
+
React.createElement(Queries.Finder.Request, { data: { documento: documento } },
|
|
99
|
+
React.createElement(FinderDependency, { documento: documento },
|
|
100
|
+
React.createElement(Queries.ProcessosJuridicos.Request, { data: { documento: documento } },
|
|
101
|
+
React.createElement(Queries.Liminar.Request, { data: { documento: documento } },
|
|
102
|
+
React.createElement(Queries.LiminarCenprot.Request, { data: { documento: documento } },
|
|
103
|
+
React.createElement(EditalQueryWrapper, { hasDiamanteAccess: hasDiamanteAccess, documento: documento },
|
|
104
|
+
React.createElement(Wrapper, null,
|
|
105
|
+
React.createElement(GlobalDataProvider, null,
|
|
106
|
+
React.createElement(ConsultaSimplesSection, { documento: documento, onClose: onClose, onClickPrint: onClickPrint, isFinancial: isFinancial, ctime: ctimeProp, printMode: printMode, tags: tags },
|
|
107
|
+
React.createElement(ConsultaRfbProvider, { documento: documento },
|
|
108
|
+
React.createElement(Dossie, { documento: documento, printMode: printMode, isFinancial: isFinancial }),
|
|
109
|
+
React.createElement(Liminar, { isFinancial: isFinancial, hasCredits: hasCredits, tags: tags }),
|
|
110
|
+
React.createElement(Falencia, { documento: documento }),
|
|
111
|
+
React.createElement(Addresses, { apiKey: apiKey }),
|
|
112
|
+
React.createElement(Contacts, null),
|
|
113
|
+
React.createElement(Partners, { onClickQSA: onClickQSA })),
|
|
114
|
+
React.createElement(Dominios, null),
|
|
115
|
+
React.createElement(BankAccounts, null),
|
|
116
|
+
React.createElement(GraficosAnaliticosDependency, { documento: documento },
|
|
117
|
+
React.createElement(ChartSystem, { documento: documento }),
|
|
118
|
+
React.createElement(ConsultaSCR, { documento: documento }),
|
|
119
|
+
React.createElement(RefinBoaVista, { documento: documento }),
|
|
120
|
+
React.createElement(RefinSerasa, { documento: documento }),
|
|
121
|
+
React.createElement(ConsultaScore, { documento: documento }),
|
|
122
|
+
React.createElement(ConsultaScoreSerasa, { documento: documento }),
|
|
123
|
+
React.createElement(ConsultaImoveis, { documento: documento }),
|
|
124
|
+
React.createElement(Veiculos, { documento: documento })),
|
|
125
|
+
React.createElement(ProtestosSP, null),
|
|
126
|
+
React.createElement(Protestos, null),
|
|
127
|
+
React.createElement(Edital, { isFinancial: isFinancial, tags: tags }),
|
|
128
|
+
React.createElement(ProtestosPagosBaixados, { isFinancial: isFinancial }),
|
|
129
|
+
React.createElement(CCF, null),
|
|
130
|
+
React.createElement(DividasPublicas, null),
|
|
131
|
+
React.createElement(ProcessosJuridicos, { onClickConsultarProcessoJuridico: onClickConsultarProcessoJuridico })))))))))))))))))),
|
|
130
132
|
React.createElement(GlobalStyle, null)));
|
|
131
133
|
};
|
|
132
134
|
export default ConsultaSimples;
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import React, { createContext, useContext } from 'react';
|
|
1
|
+
import React, { createContext, useContext, useEffect } from 'react';
|
|
2
2
|
var PrintModeContext = createContext({
|
|
3
3
|
printMode: false
|
|
4
4
|
});
|
|
5
5
|
export var usePrintMode = function () { return useContext(PrintModeContext); };
|
|
6
6
|
export var PrintModeProvider = function (_a) {
|
|
7
7
|
var children = _a.children, printMode = _a.printMode;
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
if (typeof document === 'undefined')
|
|
10
|
+
return;
|
|
11
|
+
document.body.classList.toggle('print-mode', printMode);
|
|
12
|
+
document.body.dataset.printMode = String(printMode);
|
|
13
|
+
return function () {
|
|
14
|
+
document.body.classList.remove('print-mode');
|
|
15
|
+
delete document.body.dataset.printMode;
|
|
16
|
+
};
|
|
17
|
+
}, [printMode]);
|
|
8
18
|
return (React.createElement(PrintModeContext.Provider, { value: { printMode: printMode } }, children));
|
|
9
19
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type BlockerMeta = {
|
|
3
|
+
id: string;
|
|
4
|
+
reason?: string;
|
|
5
|
+
createdAt: number;
|
|
6
|
+
};
|
|
7
|
+
type PrintState = {
|
|
8
|
+
pending: BlockerMeta[];
|
|
9
|
+
isReady: () => boolean;
|
|
10
|
+
forceReady: () => void;
|
|
11
|
+
};
|
|
12
|
+
type PrintReadinessContextValue = {
|
|
13
|
+
registerBlocker: (id: string, reason?: string) => void;
|
|
14
|
+
resolveBlocker: (id: string) => void;
|
|
15
|
+
forceReady: () => void;
|
|
16
|
+
isReady: boolean;
|
|
17
|
+
pending: BlockerMeta[];
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare const PrintReadinessProvider: React.FC<React.PropsWithChildren<{
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
}>>;
|
|
23
|
+
export declare const usePrintReadiness: () => PrintReadinessContextValue;
|
|
24
|
+
declare global {
|
|
25
|
+
interface Window {
|
|
26
|
+
__harlanPrintState?: PrintState;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
var noop = function () { };
|
|
3
|
+
var PrintReadinessContext = createContext({
|
|
4
|
+
registerBlocker: noop,
|
|
5
|
+
resolveBlocker: noop,
|
|
6
|
+
forceReady: noop,
|
|
7
|
+
isReady: true,
|
|
8
|
+
pending: [],
|
|
9
|
+
enabled: false
|
|
10
|
+
});
|
|
11
|
+
var PRINT_STATE_EVENT = 'harlan-print-state-change';
|
|
12
|
+
export var PrintReadinessProvider = function (_a) {
|
|
13
|
+
var enabled = _a.enabled, children = _a.children;
|
|
14
|
+
var _b = useState(function () { return new Map(); }), blockers = _b[0], setBlockers = _b[1];
|
|
15
|
+
var registerBlocker = useCallback(function (id, reason) {
|
|
16
|
+
if (!enabled || !id)
|
|
17
|
+
return;
|
|
18
|
+
setBlockers(function (prev) {
|
|
19
|
+
var _a;
|
|
20
|
+
var existing = prev.get(id);
|
|
21
|
+
if (existing && existing.reason === reason) {
|
|
22
|
+
return prev;
|
|
23
|
+
}
|
|
24
|
+
var next = new Map(prev);
|
|
25
|
+
next.set(id, {
|
|
26
|
+
id: id,
|
|
27
|
+
reason: reason,
|
|
28
|
+
createdAt: (_a = existing === null || existing === void 0 ? void 0 : existing.createdAt) !== null && _a !== void 0 ? _a : Date.now()
|
|
29
|
+
});
|
|
30
|
+
return next;
|
|
31
|
+
});
|
|
32
|
+
}, [enabled]);
|
|
33
|
+
var resolveBlocker = useCallback(function (id) {
|
|
34
|
+
if (!enabled || !id)
|
|
35
|
+
return;
|
|
36
|
+
setBlockers(function (prev) {
|
|
37
|
+
if (!prev.has(id))
|
|
38
|
+
return prev;
|
|
39
|
+
var next = new Map(prev);
|
|
40
|
+
next.delete(id);
|
|
41
|
+
return next;
|
|
42
|
+
});
|
|
43
|
+
}, [enabled]);
|
|
44
|
+
var forceReady = useCallback(function () {
|
|
45
|
+
if (!enabled)
|
|
46
|
+
return;
|
|
47
|
+
setBlockers(new Map());
|
|
48
|
+
}, [enabled]);
|
|
49
|
+
var pending = useMemo(function () { return Array.from(blockers.values()); }, [blockers]);
|
|
50
|
+
var isReady = pending.length === 0;
|
|
51
|
+
useEffect(function () {
|
|
52
|
+
if (typeof window === 'undefined')
|
|
53
|
+
return;
|
|
54
|
+
if (!enabled) {
|
|
55
|
+
delete window
|
|
56
|
+
.__harlanPrintState;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
window
|
|
60
|
+
.__harlanPrintState = {
|
|
61
|
+
pending: pending,
|
|
62
|
+
isReady: function () { return pending.length === 0; },
|
|
63
|
+
forceReady: forceReady
|
|
64
|
+
};
|
|
65
|
+
window.dispatchEvent(new CustomEvent(PRINT_STATE_EVENT, {
|
|
66
|
+
detail: {
|
|
67
|
+
pending: pending
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
return function () {
|
|
71
|
+
delete window
|
|
72
|
+
.__harlanPrintState;
|
|
73
|
+
};
|
|
74
|
+
}, [enabled, pending, forceReady]);
|
|
75
|
+
var value = useMemo(function () { return ({
|
|
76
|
+
registerBlocker: registerBlocker,
|
|
77
|
+
resolveBlocker: resolveBlocker,
|
|
78
|
+
forceReady: forceReady,
|
|
79
|
+
isReady: isReady,
|
|
80
|
+
pending: pending,
|
|
81
|
+
enabled: enabled
|
|
82
|
+
}); }, [registerBlocker, resolveBlocker, forceReady, isReady, pending, enabled]);
|
|
83
|
+
return (React.createElement(PrintReadinessContext.Provider, { value: value }, children));
|
|
84
|
+
};
|
|
85
|
+
export var usePrintReadiness = function () { return useContext(PrintReadinessContext); };
|
package/dist/index.d.ts
CHANGED
|
@@ -26,4 +26,5 @@ export { default as Veiculos } from './components/veiculos/veiculos';
|
|
|
26
26
|
export * from './components/webservice';
|
|
27
27
|
export { default as ConsultaSimples } from './consultaSimples';
|
|
28
28
|
export { PrintModeProvider, usePrintMode } from './contexts/printModeContext';
|
|
29
|
+
export { PrintReadinessProvider, usePrintReadiness } from './contexts/printReadinessContext';
|
|
29
30
|
export { default as usePrintWhenStable } from './hooks/usePrintWhenStable';
|
package/dist/index.js
CHANGED
|
@@ -26,4 +26,5 @@ export { default as Veiculos } from './components/veiculos/veiculos';
|
|
|
26
26
|
export * from './components/webservice';
|
|
27
27
|
export { default as ConsultaSimples } from './consultaSimples';
|
|
28
28
|
export { PrintModeProvider, usePrintMode } from './contexts/printModeContext';
|
|
29
|
+
export { PrintReadinessProvider, usePrintReadiness } from './contexts/printReadinessContext';
|
|
29
30
|
export { default as usePrintWhenStable } from './hooks/usePrintWhenStable';
|
|
@@ -5,7 +5,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
5
5
|
// src/styles/globalStyle.tsx
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { createGlobalStyle } from 'styled-components';
|
|
8
|
-
var GlobalStyle = createGlobalStyle(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n /* Reset + fonte padr\u00E3o para toda a aplica\u00E7\u00E3o (inclui modais e portais) */\n *, *::before, *::after {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n font-family: 'Open Sans Condensed', sans-serif;\n }\n\n body {\n -webkit-font-smoothing: antialiased;\n }\n\n /* Oculta bot\u00F5es e tooltips na impress\u00E3o */\n @media print {\n button,\n [role=\"button\"],\n [class*=\"Button\"],\n [class^=\"Button\"],\n [class*=\"btn\"],\n [class^=\"btn\"],\n .button,\n .btn,\n [class*=\"tooltip\"],\n [class*=\"Tooltip\"],\n [data-tooltip] {\n display: none !important;\n visibility: hidden !important;\n }\n }\n\n /* Anima\u00E7\u00F5es utilit\u00E1rias */\n @keyframes highlight {\n from {\n background-color: rgba(255, 215, 0, 0.35);\n }\n to {\n background-color: transparent;\n }\n }\n\n .highlighted-process {\n animation: highlight 3s ease-out forwards !important;\n }\n\n @keyframes blueHighlight {\n from {\n background-color: rgba(0, 122, 255, 0.35);\n }\n to {\n background-color: rgba(0, 122, 255, 0.15);\n }\n }\n\n .blue-highlighted-process {\n animation: blueHighlight 2.5s ease-in-out;\n background-color: rgba(0, 122, 255, 0.15);\n transition: background-color 0.3s ease-in-out;\n }\n"], ["\n /* Reset + fonte padr\u00E3o para toda a aplica\u00E7\u00E3o (inclui modais e portais) */\n *, *::before, *::after {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n font-family: 'Open Sans Condensed', sans-serif;\n }\n\n body {\n -webkit-font-smoothing: antialiased;\n }\n\n /* Oculta bot\u00F5es e tooltips na impress\u00E3o */\n @media print {\n button,\n [role=\"button\"],\n [class*=\"Button\"],\n [class^=\"Button\"],\n [class*=\"btn\"],\n [class^=\"btn\"],\n .button,\n .btn,\n [class*=\"tooltip\"],\n [class*=\"Tooltip\"],\n [data-tooltip] {\n display: none !important;\n visibility: hidden !important;\n }\n }\n\n /* Anima\u00E7\u00F5es utilit\u00E1rias */\n @keyframes highlight {\n from {\n background-color: rgba(255, 215, 0, 0.35);\n }\n to {\n background-color: transparent;\n }\n }\n\n .highlighted-process {\n animation: highlight 3s ease-out forwards !important;\n }\n\n @keyframes blueHighlight {\n from {\n background-color: rgba(0, 122, 255, 0.35);\n }\n to {\n background-color: rgba(0, 122, 255, 0.15);\n }\n }\n\n .blue-highlighted-process {\n animation: blueHighlight 2.5s ease-in-out;\n background-color: rgba(0, 122, 255, 0.15);\n transition: background-color 0.3s ease-in-out;\n }\n"])));
|
|
8
|
+
var GlobalStyle = createGlobalStyle(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n /* Reset + fonte padr\u00E3o para toda a aplica\u00E7\u00E3o (inclui modais e portais) */\n *, *::before, *::after {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n font-family: 'Open Sans Condensed', sans-serif;\n }\n\n body {\n -webkit-font-smoothing: antialiased;\n }\n\n /* Oculta bot\u00F5es e tooltips na impress\u00E3o */\n @media print {\n button,\n [role=\"button\"],\n [class*=\"Button\"],\n [class^=\"Button\"],\n [class*=\"btn\"],\n [class^=\"btn\"],\n .button,\n .btn,\n [class*=\"tooltip\"],\n [class*=\"Tooltip\"],\n [data-tooltip] {\n display: none !important;\n visibility: hidden !important;\n }\n }\n\n body.print-mode,\n body[data-print-mode='true'] {\n button,\n [role=\"button\"],\n [class*=\"Button\"],\n [class^=\"Button\"],\n [class*=\"btn\"],\n [class^=\"btn\"],\n .button,\n .btn,\n [class*=\"tooltip\"],\n [class*=\"Tooltip\"],\n [data-tooltip] {\n display: none !important;\n visibility: hidden !important;\n }\n }\n\n /* Anima\u00E7\u00F5es utilit\u00E1rias */\n @keyframes highlight {\n from {\n background-color: rgba(255, 215, 0, 0.35);\n }\n to {\n background-color: transparent;\n }\n }\n\n .highlighted-process {\n animation: highlight 3s ease-out forwards !important;\n }\n\n @keyframes blueHighlight {\n from {\n background-color: rgba(0, 122, 255, 0.35);\n }\n to {\n background-color: rgba(0, 122, 255, 0.15);\n }\n }\n\n .blue-highlighted-process {\n animation: blueHighlight 2.5s ease-in-out;\n background-color: rgba(0, 122, 255, 0.15);\n transition: background-color 0.3s ease-in-out;\n }\n"], ["\n /* Reset + fonte padr\u00E3o para toda a aplica\u00E7\u00E3o (inclui modais e portais) */\n *, *::before, *::after {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n font-family: 'Open Sans Condensed', sans-serif;\n }\n\n body {\n -webkit-font-smoothing: antialiased;\n }\n\n /* Oculta bot\u00F5es e tooltips na impress\u00E3o */\n @media print {\n button,\n [role=\"button\"],\n [class*=\"Button\"],\n [class^=\"Button\"],\n [class*=\"btn\"],\n [class^=\"btn\"],\n .button,\n .btn,\n [class*=\"tooltip\"],\n [class*=\"Tooltip\"],\n [data-tooltip] {\n display: none !important;\n visibility: hidden !important;\n }\n }\n\n body.print-mode,\n body[data-print-mode='true'] {\n button,\n [role=\"button\"],\n [class*=\"Button\"],\n [class^=\"Button\"],\n [class*=\"btn\"],\n [class^=\"btn\"],\n .button,\n .btn,\n [class*=\"tooltip\"],\n [class*=\"Tooltip\"],\n [data-tooltip] {\n display: none !important;\n visibility: hidden !important;\n }\n }\n\n /* Anima\u00E7\u00F5es utilit\u00E1rias */\n @keyframes highlight {\n from {\n background-color: rgba(255, 215, 0, 0.35);\n }\n to {\n background-color: transparent;\n }\n }\n\n .highlighted-process {\n animation: highlight 3s ease-out forwards !important;\n }\n\n @keyframes blueHighlight {\n from {\n background-color: rgba(0, 122, 255, 0.35);\n }\n to {\n background-color: rgba(0, 122, 255, 0.15);\n }\n }\n\n .blue-highlighted-process {\n animation: blueHighlight 2.5s ease-in-out;\n background-color: rgba(0, 122, 255, 0.15);\n transition: background-color 0.3s ease-in-out;\n }\n"])));
|
|
9
9
|
// Componente que aplica os estilos globais da aplicação.
|
|
10
10
|
// A fonte "Open Sans Condensed" já é carregada via index.html.
|
|
11
11
|
var GlobalStyleProvider = function () { return (React.createElement(React.Fragment, null,
|