@credithub/harlan-components 1.13.9 → 1.14.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.
Files changed (143) hide show
  1. package/lib/cjs/components/chart/chartContent.d.ts +3 -4
  2. package/lib/cjs/components/chart/chartContent.js +40 -72
  3. package/lib/cjs/components/chart/chartSystem.d.ts +6 -0
  4. package/lib/cjs/components/chart/chartSystem.js +50 -0
  5. package/lib/cjs/components/chart/components/MixedChart.d.ts +7 -0
  6. package/lib/cjs/components/chart/components/MixedChart.js +55 -0
  7. package/lib/cjs/components/chart/components/PieChart.d.ts +7 -0
  8. package/lib/cjs/components/chart/components/PieChart.js +14 -0
  9. package/lib/cjs/components/chart/components/categoryProtestos.d.ts +7 -0
  10. package/lib/cjs/components/chart/components/categoryProtestos.js +22 -0
  11. package/lib/cjs/components/chart/hooks/useCategoryProtestos.d.ts +6 -0
  12. package/lib/cjs/components/chart/hooks/useCategoryProtestos.js +75 -0
  13. package/lib/cjs/components/chart/hooks/useChartData.d.ts +8 -0
  14. package/lib/cjs/components/chart/hooks/useChartData.js +61 -0
  15. package/lib/cjs/components/chart/hooks/useMixedChartData.d.ts +10 -0
  16. package/lib/cjs/components/chart/hooks/useMixedChartData.js +47 -0
  17. package/lib/cjs/components/chart/hooks/usePieChartData.d.ts +6 -0
  18. package/lib/cjs/components/chart/hooks/usePieChartData.js +93 -0
  19. package/lib/cjs/components/chart/quantityResult.js +22 -21
  20. package/lib/cjs/components/chart/types/iChart.d.ts +58 -0
  21. package/lib/cjs/components/chart/utils/chartCustomization.d.ts +7 -0
  22. package/lib/cjs/components/chart/utils/chartCustomization.js +159 -0
  23. package/lib/cjs/components/chart/utils/chartUtils.d.ts +11 -0
  24. package/lib/cjs/components/chart/utils/chartUtils.js +46 -0
  25. package/lib/cjs/components/chart/utils/dataManipulation.d.ts +10 -0
  26. package/lib/cjs/components/chart/utils/dataManipulation.js +106 -0
  27. package/lib/cjs/components/chart/utils/dataProcessing.d.ts +3 -0
  28. package/lib/cjs/components/chart/utils/dataProcessing.js +94 -0
  29. package/lib/cjs/consultaSimples.js +3 -1
  30. package/lib/cjs/hooks/useWindowSize.d.ts +4 -0
  31. package/lib/cjs/hooks/useWindowSize.js +23 -0
  32. package/lib/cjs/index.d.ts +1 -1
  33. package/lib/cjs/index.js +5 -4
  34. package/lib/cjs/utils/fillMissingData.d.ts +6 -0
  35. package/lib/cjs/utils/fillMissingData.js +16 -0
  36. package/lib/cjs/utils/getUniqueDates.d.ts +5 -0
  37. package/lib/cjs/utils/getUniqueDates.js +13 -0
  38. package/lib/esm/components/chart/chartContent.d.ts +3 -4
  39. package/lib/esm/components/chart/chartContent.js +41 -50
  40. package/lib/esm/components/chart/chartSystem.d.ts +6 -0
  41. package/lib/esm/components/chart/chartSystem.js +45 -0
  42. package/lib/esm/components/chart/components/MixedChart.d.ts +7 -0
  43. package/lib/esm/components/chart/components/MixedChart.js +30 -0
  44. package/lib/esm/components/chart/components/PieChart.d.ts +7 -0
  45. package/lib/esm/components/chart/components/PieChart.js +9 -0
  46. package/lib/esm/components/chart/components/categoryProtestos.d.ts +7 -0
  47. package/lib/esm/components/chart/components/categoryProtestos.js +17 -0
  48. package/lib/esm/components/chart/hooks/useCategoryProtestos.d.ts +6 -0
  49. package/lib/esm/components/chart/hooks/useCategoryProtestos.js +71 -0
  50. package/lib/esm/components/chart/hooks/useChartData.d.ts +8 -0
  51. package/lib/esm/components/chart/hooks/useChartData.js +59 -0
  52. package/lib/esm/components/chart/hooks/useMixedChartData.d.ts +10 -0
  53. package/lib/esm/components/chart/hooks/useMixedChartData.js +43 -0
  54. package/lib/esm/components/chart/hooks/usePieChartData.d.ts +6 -0
  55. package/lib/esm/components/chart/hooks/usePieChartData.js +89 -0
  56. package/lib/esm/components/chart/quantityResult.js +23 -22
  57. package/lib/esm/components/chart/types/iChart.d.ts +58 -0
  58. package/lib/esm/components/chart/utils/chartCustomization.d.ts +7 -0
  59. package/lib/esm/components/chart/utils/chartCustomization.js +154 -0
  60. package/lib/esm/components/chart/utils/chartUtils.d.ts +11 -0
  61. package/lib/esm/components/chart/utils/chartUtils.js +37 -0
  62. package/lib/esm/components/chart/utils/dataManipulation.d.ts +10 -0
  63. package/lib/esm/components/chart/utils/dataManipulation.js +97 -0
  64. package/lib/esm/components/chart/utils/dataProcessing.d.ts +3 -0
  65. package/lib/esm/components/chart/utils/dataProcessing.js +86 -0
  66. package/lib/esm/consultaSimples.js +5 -3
  67. package/lib/esm/hooks/useWindowSize.d.ts +4 -0
  68. package/lib/esm/hooks/useWindowSize.js +19 -0
  69. package/lib/esm/index.d.ts +1 -1
  70. package/lib/esm/index.js +4 -1
  71. package/lib/esm/utils/fillMissingData.d.ts +6 -0
  72. package/lib/esm/utils/fillMissingData.js +12 -0
  73. package/lib/esm/utils/getUniqueDates.d.ts +5 -0
  74. package/lib/esm/utils/getUniqueDates.js +9 -0
  75. package/package.json +8 -1
  76. package/lib/cjs/components/chart/categoryProtestos.d.ts +0 -4
  77. package/lib/cjs/components/chart/categoryProtestos.js +0 -97
  78. package/lib/cjs/components/chart/chartHelper.d.ts +0 -7
  79. package/lib/cjs/components/chart/chartHelper.js +0 -66
  80. package/lib/cjs/components/chart/customChart.d.ts +0 -10
  81. package/lib/cjs/components/chart/customChart.js +0 -142
  82. package/lib/cjs/components/chart/getUniqueDates.d.ts +0 -2
  83. package/lib/cjs/components/chart/getUniqueDates.js +0 -8
  84. package/lib/cjs/components/chart/plotly/barChartDataStrategy.d.ts +0 -14
  85. package/lib/cjs/components/chart/plotly/barChartDataStrategy.js +0 -152
  86. package/lib/cjs/components/chart/plotly/baseChartDataStrategy.d.ts +0 -8
  87. package/lib/cjs/components/chart/plotly/baseChartDataStrategy.js +0 -31
  88. package/lib/cjs/components/chart/plotly/getSeries.d.ts +0 -3
  89. package/lib/cjs/components/chart/plotly/getSeries.js +0 -35
  90. package/lib/cjs/components/chart/plotly/iChartDataStrategy.d.ts +0 -35
  91. package/lib/cjs/components/chart/plotly/index.d.ts +0 -5
  92. package/lib/cjs/components/chart/plotly/index.js +0 -20
  93. package/lib/cjs/components/chart/plotly/layoutLineBarChart.d.ts +0 -39
  94. package/lib/cjs/components/chart/plotly/layoutLineBarChart.js +0 -67
  95. package/lib/cjs/components/chart/plotly/lineChartDataStrategy.d.ts +0 -17
  96. package/lib/cjs/components/chart/plotly/lineChartDataStrategy.js +0 -198
  97. package/lib/cjs/components/chart/plotly/pieChartDataStrategy.d.ts +0 -5
  98. package/lib/cjs/components/chart/plotly/pieChartDataStrategy.js +0 -45
  99. package/lib/cjs/components/chart/plotly/types.d.ts +0 -40
  100. package/lib/cjs/components/chart/plotly/types.js +0 -2
  101. package/lib/cjs/components/chart/processChartData.d.ts +0 -5
  102. package/lib/cjs/components/chart/processChartData.js +0 -41
  103. package/lib/cjs/components/chart/useCalculation.d.ts +0 -6
  104. package/lib/cjs/components/chart/useCalculation.js +0 -12
  105. package/lib/cjs/components/chart/useDividasPublicas.d.ts +0 -5
  106. package/lib/cjs/components/chart/useDividasPublicas.js +0 -26
  107. package/lib/cjs/components/chart/useUltimaOcorrenciaCCF.d.ts +0 -2
  108. package/lib/cjs/components/chart/useUltimaOcorrenciaCCF.js +0 -20
  109. package/lib/esm/components/chart/categoryProtestos.d.ts +0 -4
  110. package/lib/esm/components/chart/categoryProtestos.js +0 -69
  111. package/lib/esm/components/chart/chartHelper.d.ts +0 -7
  112. package/lib/esm/components/chart/chartHelper.js +0 -60
  113. package/lib/esm/components/chart/customChart.d.ts +0 -10
  114. package/lib/esm/components/chart/customChart.js +0 -112
  115. package/lib/esm/components/chart/getUniqueDates.d.ts +0 -2
  116. package/lib/esm/components/chart/getUniqueDates.js +0 -4
  117. package/lib/esm/components/chart/plotly/barChartDataStrategy.d.ts +0 -14
  118. package/lib/esm/components/chart/plotly/barChartDataStrategy.js +0 -149
  119. package/lib/esm/components/chart/plotly/baseChartDataStrategy.d.ts +0 -8
  120. package/lib/esm/components/chart/plotly/baseChartDataStrategy.js +0 -28
  121. package/lib/esm/components/chart/plotly/getSeries.d.ts +0 -3
  122. package/lib/esm/components/chart/plotly/getSeries.js +0 -31
  123. package/lib/esm/components/chart/plotly/iChartDataStrategy.d.ts +0 -35
  124. package/lib/esm/components/chart/plotly/index.d.ts +0 -5
  125. package/lib/esm/components/chart/plotly/index.js +0 -5
  126. package/lib/esm/components/chart/plotly/layoutLineBarChart.d.ts +0 -39
  127. package/lib/esm/components/chart/plotly/layoutLineBarChart.js +0 -64
  128. package/lib/esm/components/chart/plotly/lineChartDataStrategy.d.ts +0 -17
  129. package/lib/esm/components/chart/plotly/lineChartDataStrategy.js +0 -195
  130. package/lib/esm/components/chart/plotly/pieChartDataStrategy.d.ts +0 -5
  131. package/lib/esm/components/chart/plotly/pieChartDataStrategy.js +0 -42
  132. package/lib/esm/components/chart/plotly/types.d.ts +0 -40
  133. package/lib/esm/components/chart/plotly/types.js +0 -1
  134. package/lib/esm/components/chart/processChartData.d.ts +0 -5
  135. package/lib/esm/components/chart/processChartData.js +0 -37
  136. package/lib/esm/components/chart/useCalculation.d.ts +0 -6
  137. package/lib/esm/components/chart/useCalculation.js +0 -8
  138. package/lib/esm/components/chart/useDividasPublicas.d.ts +0 -5
  139. package/lib/esm/components/chart/useDividasPublicas.js +0 -21
  140. package/lib/esm/components/chart/useUltimaOcorrenciaCCF.d.ts +0 -2
  141. package/lib/esm/components/chart/useUltimaOcorrenciaCCF.js +0 -15
  142. /package/lib/cjs/components/chart/{plotly/iChartDataStrategy.js → types/iChart.js} +0 -0
  143. /package/lib/esm/components/chart/{plotly/iChartDataStrategy.js → types/iChart.js} +0 -0
@@ -16,30 +16,31 @@ var styled_components_1 = __importDefault(require("styled-components"));
16
16
  var theme_1 = __importDefault(require("../interface/theme"));
17
17
  var QuantityContainer = function (_a) {
18
18
  var children = _a.children;
19
- return react_1.default.createElement("div", { className: "t" }, children);
19
+ return (react_1.default.createElement("div", { className: "t" }, children));
20
20
  };
21
- var QuantidadeResultadosWrapper = (0, styled_components_1.default)(result_1.ResultContent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 18px 0px;\n row-gap: 20px;\n > * {\n row-gap: 10px;\n }\n @media only screen and (max-width: 768px) {\n > * {\n :not(:last-child) {\n border-bottom: 1px solid ", ";\n }\n }\n }\n \n"], ["\n padding: 18px 0px;\n row-gap: 20px;\n > * {\n row-gap: 10px;\n }\n @media only screen and (max-width: 768px) {\n > * {\n :not(:last-child) {\n border-bottom: 1px solid ", ";\n }\n }\n }\n \n"])), theme_1.default.colors.cinzaClaro);
21
+ var QuantidadeResultadosWrapper = (0, styled_components_1.default)(result_1.ResultContent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 18px 20px;\n row-gap: 20px;\n > * {\n row-gap: 10px;\n }\n @media only screen and (max-width: 768px) {\n > * {\n :not(:last-child) {\n border-bottom: 1px solid ", ";\n }\n }\n }\n"], ["\n padding: 18px 20px;\n row-gap: 20px;\n > * {\n row-gap: 10px;\n }\n @media only screen and (max-width: 768px) {\n > * {\n :not(:last-child) {\n border-bottom: 1px solid ", ";\n }\n }\n }\n"])), theme_1.default.colors.cinzaClaro);
22
22
  var QuantidadeResultados = function (_a) {
23
23
  var _b = _a.quantidadeProtestos, quantidadeProtestos = _b === void 0 ? 0 : _b, _c = _a.quantidadeProcessos, quantidadeProcessos = _c === void 0 ? 0 : _c, _d = _a.quantidadeDividas, quantidadeDividas = _d === void 0 ? 0 : _d, _e = _a.quantidadeChequesSemFundos, quantidadeChequesSemFundos = _e === void 0 ? 0 : _e, _f = _a.quantidadeDividasSerasa, quantidadeDividasSerasa = _f === void 0 ? 0 : _f, _g = _a.quantidadeDividasBoaVista, quantidadeDividasBoaVista = _g === void 0 ? 0 : _g, _h = _a.valorTotalProtestos, valorTotalProtestos = _h === void 0 ? 0 : _h, _j = _a.valorTotalDividas, valorTotalDividas = _j === void 0 ? 0 : _j, _k = _a.valorTotalDividasSerasa, valorTotalDividasSerasa = _k === void 0 ? 0 : _k, _l = _a.valorTotalDividasBoaVista, valorTotalDividasBoaVista = _l === void 0 ? 0 : _l, _m = _a.ultimaOcorrenciaProtestos, ultimaOcorrenciaProtestos = _m === void 0 ? null : _m, _o = _a.ultimaOcorrenciaChequesSemFundos, ultimaOcorrenciaChequesSemFundos = _o === void 0 ? null : _o;
24
- return (react_1.default.createElement(QuantidadeResultadosWrapper, { desktop: "repeat(6, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr" },
25
- react_1.default.createElement(QuantityContainer, null,
26
- react_1.default.createElement(addItem_1.default, { name: "Total Protestos", value: (0, number_1.formatValue)(quantidadeProtestos) }),
27
- react_1.default.createElement(addItem_1.default, { name: "Valor Total Protestos", value: (0, number_1.formatMoney)(valorTotalProtestos) }),
28
- react_1.default.createElement(addItem_1.default, { hidden: quantidadeProtestos == 0, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaProtestos })),
29
- react_1.default.createElement(QuantityContainer, null,
30
- react_1.default.createElement(addItem_1.default, { name: "Cheques Sem Fundos", value: (0, number_1.formatValue)(quantidadeChequesSemFundos) }),
31
- react_1.default.createElement(addItem_1.default, { hidden: quantidadeChequesSemFundos == 0, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaChequesSemFundos })),
32
- react_1.default.createElement(QuantityContainer, null,
33
- react_1.default.createElement(addItem_1.default, { name: "Processos Jur\u00EDdicos", value: (0, number_1.formatValue)(quantidadeProcessos) })),
34
- react_1.default.createElement(QuantityContainer, null,
35
- react_1.default.createElement(addItem_1.default, { name: "D\u00EDvidas P\u00FAblicas", value: (0, number_1.formatValue)(quantidadeDividas) }),
36
- react_1.default.createElement(addItem_1.default, { name: "Total D\u00EDvidas P\u00FAblicas", value: (0, number_1.formatMoney)(valorTotalDividas) })),
37
- react_1.default.createElement(QuantityContainer, null,
38
- react_1.default.createElement(addItem_1.default, { name: "Pefin Refin Serasa", value: (0, number_1.formatValue)(quantidadeDividasSerasa) }),
39
- react_1.default.createElement(addItem_1.default, { name: "Total Pefin Refin Serasa", value: (0, number_1.formatMoney)(valorTotalDividasSerasa) })),
40
- react_1.default.createElement(QuantityContainer, null,
41
- react_1.default.createElement(addItem_1.default, { name: "Pefin Refin Boa Vista", value: (0, number_1.formatValue)(quantidadeDividasBoaVista) }),
42
- react_1.default.createElement(addItem_1.default, { name: "Total Pefin Refin Boa Vista", value: (0, number_1.formatMoney)(valorTotalDividasBoaVista) }))));
24
+ return (react_1.default.createElement(result_1.Result, { resultContentStriped: false },
25
+ react_1.default.createElement(QuantidadeResultadosWrapper, { desktop: "repeat(6, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr" },
26
+ react_1.default.createElement(QuantityContainer, null,
27
+ react_1.default.createElement(addItem_1.default, { name: "Total Protestos", value: (0, number_1.formatValue)(quantidadeProtestos) }),
28
+ react_1.default.createElement(addItem_1.default, { name: "Valor Total Protestos", value: (0, number_1.formatMoney)(valorTotalProtestos) }),
29
+ react_1.default.createElement(addItem_1.default, { hidden: quantidadeProtestos == 0, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaProtestos })),
30
+ react_1.default.createElement(QuantityContainer, null,
31
+ react_1.default.createElement(addItem_1.default, { name: "Cheques Sem Fundos", value: (0, number_1.formatValue)(quantidadeChequesSemFundos) }),
32
+ react_1.default.createElement(addItem_1.default, { hidden: quantidadeChequesSemFundos == 0, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaChequesSemFundos })),
33
+ react_1.default.createElement(QuantityContainer, null,
34
+ react_1.default.createElement(addItem_1.default, { name: "Processos Jur\u00EDdicos", value: (0, number_1.formatValue)(quantidadeProcessos) })),
35
+ react_1.default.createElement(QuantityContainer, null,
36
+ react_1.default.createElement(addItem_1.default, { name: "D\u00EDvidas P\u00FAblicas", value: (0, number_1.formatValue)(quantidadeDividas) }),
37
+ react_1.default.createElement(addItem_1.default, { name: "Total D\u00EDvidas P\u00FAblicas", value: (0, number_1.formatMoney)(valorTotalDividas) })),
38
+ react_1.default.createElement(QuantityContainer, null,
39
+ react_1.default.createElement(addItem_1.default, { name: "Pefin Refin Serasa", value: (0, number_1.formatValue)(quantidadeDividasSerasa) }),
40
+ react_1.default.createElement(addItem_1.default, { name: "Total Pefin Refin Serasa", value: (0, number_1.formatMoney)(valorTotalDividasSerasa) })),
41
+ react_1.default.createElement(QuantityContainer, null,
42
+ react_1.default.createElement(addItem_1.default, { name: "Pefin Refin Boa Vista", value: (0, number_1.formatValue)(quantidadeDividasBoaVista) }),
43
+ react_1.default.createElement(addItem_1.default, { name: "Total Pefin Refin Boa Vista", value: (0, number_1.formatMoney)(valorTotalDividasBoaVista) })))));
43
44
  };
44
45
  exports.default = QuantidadeResultados;
45
46
  var templateObject_1;
@@ -0,0 +1,58 @@
1
+ export interface Consulta {
2
+ data: string | Date;
3
+ categoria?: string;
4
+ quantidade?: number | null;
5
+ creation?: string | Date;
6
+ valorTotal?: number | null;
7
+ total?: number | null;
8
+ }
9
+ export interface DataInput {
10
+ ccfs: Consulta[];
11
+ protestos: Consulta[];
12
+ serasa: Consulta[];
13
+ boaVista: Consulta[];
14
+ dividasPublicasGrafico: Consulta[];
15
+ pieChartTotalConfig?: {
16
+ protestos?: {
17
+ total: number | null;
18
+ valorTotal: number | null;
19
+ ultimaOcorrencia: string | null;
20
+ };
21
+ processosJuridicos?: number;
22
+ ccf?: {
23
+ total: number | null;
24
+ ultimaOcorrencia: string | null;
25
+ };
26
+ };
27
+ protestosCategory?: ProtestoData[];
28
+ }
29
+ export interface ProtestoData {
30
+ categoria: string;
31
+ quantidade: number;
32
+ }
33
+ export interface DataSetCommon {
34
+ label: string;
35
+ data: {
36
+ x: string;
37
+ y: number;
38
+ }[];
39
+ borderColor?: string;
40
+ backgroundColor?: string;
41
+ borderWidth?: number;
42
+ yAxisID?: "y" | "y2";
43
+ }
44
+ export interface DataSetLine extends DataSetCommon {
45
+ type: "line";
46
+ tension?: number;
47
+ spanGaps: boolean;
48
+ showLine: boolean;
49
+ pointRadius: number;
50
+ fill?: boolean;
51
+ }
52
+ export interface DataSetBar extends DataSetCommon {
53
+ type: "bar";
54
+ borderRadius?: number;
55
+ categoryPercentage?: number;
56
+ barPercentage?: number;
57
+ }
58
+ export type TimeFilter = "1y" | "6m" | "1m" | "all";
@@ -0,0 +1,7 @@
1
+ import { DataInput, TimeFilter } from "../types/iChart";
2
+ import { ChartDataset, ChartOptions } from "chart.js";
3
+ export declare function createDatasets(data: DataInput, uniqueDates: string[], timeFilter: TimeFilter): ChartDataset<"line" | "bar", (number | {
4
+ x: string;
5
+ y: number;
6
+ })[]>[];
7
+ export declare function getChartOptions(timeFilter: TimeFilter): ChartOptions<"line" | "bar">;
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getChartOptions = exports.createDatasets = void 0;
15
+ var date_fns_1 = require("date-fns");
16
+ var dataManipulation_1 = require("./dataManipulation");
17
+ function createDatasets(data, uniqueDates, timeFilter) {
18
+ var _a = (0, dataManipulation_1.getBarSettings)(timeFilter), categoryPercentage = _a.categoryPercentage, barPercentage = _a.barPercentage;
19
+ var createDataSet = function (entries, label, borderColor, chartType, valueKey, yAxisID) {
20
+ var dateValues = new Map(entries.map(function (entry) {
21
+ var _a;
22
+ return [
23
+ (0, date_fns_1.format)(typeof entry.data === "string" ? (0, date_fns_1.parseISO)(entry.data) : entry.data, "yyyy-MM-dd"),
24
+ (_a = entry[valueKey]) !== null && _a !== void 0 ? _a : 0,
25
+ ];
26
+ }));
27
+ var datasetData = uniqueDates.map(function (date) {
28
+ var _a;
29
+ var value = (_a = dateValues.get(date)) !== null && _a !== void 0 ? _a : 0;
30
+ return { x: date, y: value };
31
+ });
32
+ var datasetConfiguration = __assign({ type: chartType, label: label, data: datasetData, borderColor: borderColor, backgroundColor: chartType === "bar" ? borderColor + "60" : undefined, tension: chartType === "line" ? 0.4 : undefined, spanGaps: true, showLine: chartType === "line", pointRadius: 2, yAxisID: yAxisID }, (chartType === "bar" && {
33
+ categoryPercentage: categoryPercentage,
34
+ barPercentage: barPercentage,
35
+ }));
36
+ return datasetConfiguration;
37
+ };
38
+ return [
39
+ createDataSet(data.protestos, "Protestos - Quantidade", "#ff4081", "line", "quantidade", "y"),
40
+ createDataSet(data.protestos, "Protestos - Valor Total", "#ff4081", "bar", "valorTotal", "y2"),
41
+ createDataSet(data.ccfs, "CCFs - Quantidade", "#3f51b5", "line", "quantidade", "y"),
42
+ createDataSet(data.ccfs, "CCFs - Valor Total", "#3f51b5", "bar", "valorTotal", "y2"),
43
+ createDataSet(data.serasa, "Serasa - Quantidade", "#008cf8", "line", "quantidade", "y"),
44
+ createDataSet(data.serasa, "Serasa - Valor Total", "#008cf8", "bar", "valorTotal", "y2"),
45
+ createDataSet(data.boaVista, "Boa Vista - Quantidade", "#ffc107", "line", "quantidade", "y"),
46
+ createDataSet(data.boaVista, "Boa Vista - Valor Total", "#ffc107", "bar", "valorTotal", "y2"),
47
+ createDataSet(data.dividasPublicasGrafico, "Dívidas Públicas - Quantidade", "#4caf50", "line", "quantidade", "y"),
48
+ createDataSet(data.dividasPublicasGrafico, "Dívidas Públicas - Valor Total", "#4caf50", "bar", "valorTotal", "y2"),
49
+ ];
50
+ }
51
+ exports.createDatasets = createDatasets;
52
+ function getChartOptions(timeFilter) {
53
+ var unit = "day";
54
+ switch (timeFilter) {
55
+ case "1m":
56
+ unit = "day";
57
+ break;
58
+ case "6m":
59
+ unit = "week";
60
+ break;
61
+ case "1y":
62
+ unit = "month";
63
+ break;
64
+ case "all":
65
+ unit = "quarter";
66
+ break;
67
+ }
68
+ return {
69
+ responsive: true,
70
+ maintainAspectRatio: true,
71
+ interaction: {
72
+ mode: "index",
73
+ intersect: false,
74
+ },
75
+ plugins: {
76
+ legend: {
77
+ fullSize: true,
78
+ position: "right",
79
+ labels: {
80
+ boxWidth: 16,
81
+ padding: 16,
82
+ },
83
+ },
84
+ title: {
85
+ display: true,
86
+ text: "Histórico de Consultas",
87
+ },
88
+ },
89
+ scales: {
90
+ y: {
91
+ type: "linear",
92
+ display: true,
93
+ position: "right",
94
+ beginAtZero: true,
95
+ title: {
96
+ display: true,
97
+ text: "Quantidade de Ocorrências por Consulta",
98
+ font: {
99
+ size: 14,
100
+ family: "open sans",
101
+ weight: "bold",
102
+ },
103
+ },
104
+ },
105
+ y2: {
106
+ type: "logarithmic",
107
+ display: true,
108
+ position: "left",
109
+ suggestedMin: 1,
110
+ title: {
111
+ display: true,
112
+ text: "Valor Total de Negativações (R$)",
113
+ font: {
114
+ size: 14,
115
+ family: "open sans",
116
+ weight: "bold",
117
+ },
118
+ },
119
+ grid: {
120
+ drawOnChartArea: false,
121
+ },
122
+ ticks: {
123
+ font: {
124
+ size: 12,
125
+ },
126
+ callback: function (value) {
127
+ return new Intl.NumberFormat("pt-BR", {
128
+ style: "currency",
129
+ currency: "BRL",
130
+ minimumFractionDigits: 2,
131
+ notation: "compact",
132
+ }).format(value);
133
+ },
134
+ },
135
+ },
136
+ x: {
137
+ type: "time",
138
+ time: {
139
+ unit: unit,
140
+ parser: "yyyy-MM-dd",
141
+ },
142
+ title: {
143
+ display: true,
144
+ text: "Data",
145
+ },
146
+ },
147
+ },
148
+ elements: {
149
+ line: {
150
+ fill: false,
151
+ tension: 0.4,
152
+ },
153
+ point: {
154
+ radius: 3,
155
+ },
156
+ },
157
+ };
158
+ }
159
+ exports.getChartOptions = getChartOptions;
@@ -0,0 +1,11 @@
1
+ import { ItemCalculo } from "../../../utils/calculation";
2
+ export declare const useCalculation: (itens: ItemCalculo[]) => {
3
+ quantidade: number;
4
+ valorTotal: number;
5
+ dataMaisRecente: string;
6
+ };
7
+ export declare const useUltimaOcorrenciaCCF: () => string | undefined;
8
+ export declare const useDividasPublicas: () => {
9
+ quantidade: number;
10
+ valorTotal: number;
11
+ };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useDividasPublicas = exports.useUltimaOcorrenciaCCF = exports.useCalculation = void 0;
7
+ /* eslint-disable react-hooks/exhaustive-deps */
8
+ var react_1 = require("react");
9
+ var calculation_1 = require("../../../utils/calculation");
10
+ var webservice_1 = require("../../../components/webservice");
11
+ var xpath_1 = __importDefault(require("../../../utils/xpath"));
12
+ var useCalculation = function (itens) {
13
+ var quantidade = (0, react_1.useMemo)(function () { return (0, calculation_1.somarQuantidades)(itens); }, [itens]);
14
+ var valorTotal = (0, react_1.useMemo)(function () { return (0, calculation_1.somarValoresTotais)(itens); }, [itens]);
15
+ var dataMaisRecente = (0, react_1.useMemo)(function () { return (0, calculation_1.encontrarDataMaisRecente)(itens); }, [itens]);
16
+ return { quantidade: quantidade, valorTotal: valorTotal, dataMaisRecente: dataMaisRecente };
17
+ };
18
+ exports.useCalculation = useCalculation;
19
+ var useUltimaOcorrenciaCCF = function () {
20
+ var ctxCCF = (0, react_1.useContext)(webservice_1.Queries.CCF);
21
+ var ultimaOcorrenciaCCF = (0, react_1.useMemo)(function () {
22
+ if ((ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.type) === webservice_1.RequestStatus.Success) {
23
+ return xpath_1.default.select("string(//ultimaOcorrencia)", ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.document);
24
+ }
25
+ return undefined;
26
+ }, [ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.type]);
27
+ return ultimaOcorrenciaCCF;
28
+ };
29
+ exports.useUltimaOcorrenciaCCF = useUltimaOcorrenciaCCF;
30
+ var useDividasPublicas = function () {
31
+ var ctxFinder = (0, react_1.useContext)(webservice_1.Queries.Finder);
32
+ var dividasPublicasData = (0, react_1.useMemo)(function () {
33
+ if ((ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type) === webservice_1.RequestStatus.Success) {
34
+ return {
35
+ quantidade: xpath_1.default.select("number(//dividas/resumo/quantidade_dividas)", ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.document) || 0,
36
+ valorTotal: xpath_1.default.select("number(//dividas/resumo/valor_total_dividas)", ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.document) || 0,
37
+ };
38
+ }
39
+ return {
40
+ quantidade: 0,
41
+ valorTotal: 0,
42
+ };
43
+ }, [ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type]);
44
+ return dividasPublicasData;
45
+ };
46
+ exports.useDividasPublicas = useDividasPublicas;
@@ -0,0 +1,10 @@
1
+ import { Consulta, DataInput, TimeFilter } from "../types/iChart";
2
+ export declare const addMissingDateEntries: (data: Consulta[], startDate: Date, endDate: Date) => Consulta[];
3
+ export declare const getFilteredStartDate: (timeFilter: TimeFilter, data: DataInput) => Date;
4
+ export declare const getEarliestDate: (data: DataInput) => Date;
5
+ export declare const getEndDate: () => Date;
6
+ export declare function getUniqueDates(data: DataInput): string[];
7
+ export declare const getBarSettings: (timeFilter: TimeFilter) => {
8
+ categoryPercentage: number;
9
+ barPercentage: number;
10
+ };
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.getBarSettings = exports.getUniqueDates = exports.getEndDate = exports.getEarliestDate = exports.getFilteredStartDate = exports.addMissingDateEntries = void 0;
24
+ var underscore_1 = require("underscore");
25
+ var date_fns_1 = require("date-fns");
26
+ var addMissingDateEntries = function (data, startDate, endDate) {
27
+ var datesInRange = (0, date_fns_1.eachDayOfInterval)({
28
+ start: startDate,
29
+ end: endDate,
30
+ }).map(function (date) { return (0, date_fns_1.format)(date, "yyyy-MM-dd"); });
31
+ var lastKnownQuantidade;
32
+ var lastKnownValorTotal;
33
+ var formattedData = data.map(function (entry) { return (__assign(__assign({}, entry), { data: (0, date_fns_1.format)(typeof entry.data === "string" ? (0, date_fns_1.parseISO)(entry.data) : entry.data, "yyyy-MM-dd"), quantidade: entry.quantidade !== null ? entry.quantidade : lastKnownQuantidade, valorTotal: entry.valorTotal !== null ? entry.valorTotal : lastKnownValorTotal })); });
34
+ var dataMap = new Map(formattedData.map(function (entry) { return [entry.data, entry]; }));
35
+ return datesInRange.map(function (dateStr) {
36
+ var existingEntry = dataMap.get(dateStr);
37
+ if (existingEntry) {
38
+ lastKnownQuantidade = existingEntry.quantidade;
39
+ lastKnownValorTotal = existingEntry.valorTotal;
40
+ return existingEntry;
41
+ }
42
+ return {
43
+ data: dateStr,
44
+ quantidade: lastKnownQuantidade,
45
+ valorTotal: null,
46
+ };
47
+ });
48
+ };
49
+ exports.addMissingDateEntries = addMissingDateEntries;
50
+ var getFilteredStartDate = function (timeFilter, data) {
51
+ var now = new Date();
52
+ switch (timeFilter) {
53
+ case "1y":
54
+ return (0, date_fns_1.subYears)(now, 1);
55
+ case "6m":
56
+ return (0, date_fns_1.subMonths)(now, 6);
57
+ case "1m":
58
+ return (0, date_fns_1.subMonths)(now, 1);
59
+ case "all":
60
+ return (0, exports.getEarliestDate)(data);
61
+ default:
62
+ console.warn("TimeFilter not recognized: ".concat(timeFilter, ", defaulting to current date."));
63
+ return now;
64
+ }
65
+ };
66
+ exports.getFilteredStartDate = getFilteredStartDate;
67
+ var getEarliestDate = function (data) {
68
+ var allDates = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], data.protestos, true), data.ccfs, true), data.serasa, true), data.boaVista, true), data.dividasPublicasGrafico, true).map(function (entry) { return entry.data; })
69
+ .filter(function (date) { return date !== undefined; })
70
+ .map(function (date) { return (typeof date === "string" ? (0, date_fns_1.parseISO)(date) : date); })
71
+ .filter(date_fns_1.isValid);
72
+ return allDates.length > 0 ? (0, date_fns_1.min)(allDates) : new Date();
73
+ };
74
+ exports.getEarliestDate = getEarliestDate;
75
+ var getEndDate = function () {
76
+ return new Date();
77
+ };
78
+ exports.getEndDate = getEndDate;
79
+ function getUniqueDates(data) {
80
+ var allEntries = (0, underscore_1.union)(data.protestos, data.ccfs, data.serasa, data.boaVista, data.dividasPublicasGrafico);
81
+ var allDates = allEntries
82
+ .map(function (entry) {
83
+ var dateString = typeof entry.data === "string" ? entry.data : "";
84
+ var date = (0, date_fns_1.parseISO)(dateString);
85
+ return (0, date_fns_1.isValid)(date) ? (0, date_fns_1.format)(date, "yyyy-MM-dd") : "";
86
+ })
87
+ .filter(Boolean);
88
+ var uniqueSortedDates = Array.from(new Set(allDates)).sort();
89
+ return uniqueSortedDates;
90
+ }
91
+ exports.getUniqueDates = getUniqueDates;
92
+ var getBarSettings = function (timeFilter) {
93
+ switch (timeFilter) {
94
+ case "1m":
95
+ return { categoryPercentage: 1.5, barPercentage: 1.5 };
96
+ case "6m":
97
+ return { categoryPercentage: 2.1, barPercentage: 2.1 };
98
+ case "1y":
99
+ return { categoryPercentage: 3.5, barPercentage: 3.5 };
100
+ case "all":
101
+ return { categoryPercentage: 7, barPercentage: 7 };
102
+ default:
103
+ return { categoryPercentage: 1.5, barPercentage: 1.5 };
104
+ }
105
+ };
106
+ exports.getBarSettings = getBarSettings;
@@ -0,0 +1,3 @@
1
+ import { DataInput } from "../../../components/chart/types/iChart";
2
+ export declare const processData: (data: DataInput, quantidadeProcessosJuridicos: number) => DataInput;
3
+ export declare function processProtestData(document: Document): DataInput["protestosCategory"];
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.processProtestData = exports.processData = void 0;
18
+ var string_1 = require("../../../utils/string");
19
+ var underscore_1 = require("underscore");
20
+ var xpath_1 = __importDefault(require("../../../utils/xpath"));
21
+ var regex_1 = require("../../../constants/regex");
22
+ var processData = function (data, quantidadeProcessosJuridicos) {
23
+ var removeZeros = function (current, index, arr) {
24
+ return (index === 0 || index === arr.length - 1 || Number(current.quantidade) > 0);
25
+ };
26
+ var removeSameAsNext = function (current, index, arr) {
27
+ if (index === 0 || index === arr.length - 1)
28
+ return true;
29
+ return current.quantidade !== arr[index + 1].quantidade;
30
+ };
31
+ data.pieChartTotalConfig = {
32
+ processosJuridicos: quantidadeProcessosJuridicos,
33
+ };
34
+ var grouped = (0, underscore_1.groupBy)(data.protestos, function (e) { return e.data; });
35
+ data.protestos = Object.values(grouped)
36
+ .map(function (e) {
37
+ if (e.length === 1)
38
+ return e;
39
+ return e.filter(function (el) { return Number(el.quantidade) > 0; });
40
+ })
41
+ .flat();
42
+ data.protestos = (0, underscore_1.sortBy)((0, underscore_1.unique)(data.protestos, function (x) { return x.data; })
43
+ .filter(removeZeros)
44
+ .filter(removeSameAsNext)
45
+ .map(function (info) { return (__assign(__assign({}, info), { data: (0, string_1.formatDatePtBrToDate)(info.data) })); }), function (info) { return info.data; });
46
+ data.ccfs = (0, underscore_1.sortBy)((0, underscore_1.unique)(data.ccfs, function (x) { return x.data; })
47
+ .filter(removeZeros)
48
+ .filter(removeSameAsNext)
49
+ .map(function (info) { return (__assign(__assign({}, info), { data: (0, string_1.formatDatePtBrToDate)(info.data) })); }), function (info) { return info.data; });
50
+ data.boaVista = data.boaVista
51
+ .map(function (entry) {
52
+ var formattedDate = (0, string_1.formatDatePtBrToDate)(entry.creation);
53
+ return __assign(__assign({}, entry), { data: formattedDate, creation: undefined });
54
+ })
55
+ .filter(function (entry) { return entry.data; });
56
+ data.serasa = data.serasa
57
+ .map(function (entry) {
58
+ var formattedDate = (0, string_1.formatDatePtBrToDate)(entry.creation);
59
+ return __assign(__assign({}, entry), { data: formattedDate, creation: undefined });
60
+ })
61
+ .filter(function (entry) { return entry.data; });
62
+ data.dividasPublicasGrafico = data.dividasPublicasGrafico
63
+ .map(function (info) { return (__assign(__assign({}, info), { data: (0, string_1.formatDatePtBrToDate)(info.data), valorTotal: info.total, total: undefined })); })
64
+ .filter(function (info) { return info.data; });
65
+ return __assign(__assign({}, data), { protestos: data.protestos, ccfs: data.ccfs, boaVista: data.boaVista, serasa: data.serasa, dividasPublicasGrafico: data.dividasPublicasGrafico, pieChartTotalConfig: __assign(__assign({}, data.pieChartTotalConfig), { processosJuridicos: quantidadeProcessosJuridicos }) });
66
+ };
67
+ exports.processData = processData;
68
+ function processProtestData(document) {
69
+ var _a, _b;
70
+ var filterProtestos = function (regex, data) {
71
+ return xpath_1.default.selectArray("//body//protesto", data).filter(function (protesto) {
72
+ return regex.test(xpath_1.default.select("string(./nomeCedente)", protesto));
73
+ });
74
+ };
75
+ return [
76
+ {
77
+ categoria: "Protestos de Crédito",
78
+ quantidade: (_a = filterProtestos(regex_1.REGEX_PROTESTOS_DE_CREDITO, document)) === null || _a === void 0 ? void 0 : _a.length,
79
+ },
80
+ {
81
+ categoria: "Protestos de Impostos",
82
+ quantidade: (_b = filterProtestos(regex_1.REGEX_PROTESTOS_DE_IMPOSTO, document)) === null || _b === void 0 ? void 0 : _b.length,
83
+ },
84
+ {
85
+ categoria: "Protestos Gerais",
86
+ quantidade: xpath_1.default.selectArray("//body//protesto", document).filter(function (protesto) {
87
+ var nomeCedente = xpath_1.default.select("string(./nomeCedente)", protesto);
88
+ return (!regex_1.REGEX_PROTESTOS_DE_IMPOSTO.test(nomeCedente) &&
89
+ !regex_1.REGEX_PROTESTOS_DE_CREDITO.test(nomeCedente));
90
+ }).length,
91
+ },
92
+ ];
93
+ }
94
+ exports.processProtestData = processProtestData;
@@ -16,9 +16,11 @@ var imoveisService_1 = __importDefault(require("./components/imoveis/imoveisServ
16
16
  var globalStyle_1 = __importDefault(require("./components/interface/globalStyle"));
17
17
  var consultaRfb_1 = require("./components/consultaRfb");
18
18
  var styled_components_1 = __importDefault(require("styled-components"));
19
+ var chart_js_1 = require("chart.js");
19
20
  var dominios_1 = __importDefault(require("./components/dominios/dominios"));
20
21
  var liminar_1 = __importDefault(require("./components/liminar/liminar"));
21
22
  var consultaSimplesSection_1 = __importDefault(require("./components/consultaSimplesSection/consultaSimplesSection"));
23
+ chart_js_1.Chart.register.apply(chart_js_1.Chart, chart_js_1.registerables);
22
24
  var Wrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n gap: 20px;\n"], ["\n display: flex;\n flex-direction: column;\n gap: 20px;\n"])));
23
25
  var ConsultaSimples = function (_a) {
24
26
  var _documento = _a.documento, onClickConsultarProcessoJuridico = _a.onClickConsultarProcessoJuridico, apiKey = _a.apiKey, onClose = _a.onClose, hasCredits = _a.hasCredits;
@@ -43,7 +45,7 @@ var ConsultaSimples = function (_a) {
43
45
  react_1.default.createElement(dominios_1.default, null),
44
46
  react_1.default.createElement(_1.BankAccounts, null),
45
47
  react_1.default.createElement(_1.Queries.GraficosAnaliticos.Request, { data: { documento: documento } },
46
- react_1.default.createElement(_1.CustomChartSection, { documento: documento }),
48
+ react_1.default.createElement(_1.ChartSystem, { documento: documento }),
47
49
  react_1.default.createElement(scr_1.default, { documento: documento }),
48
50
  react_1.default.createElement(_1.RefinBoaVista, { documento: documento }),
49
51
  react_1.default.createElement(_1.RefinSerasa, { documento: documento }),
@@ -0,0 +1,4 @@
1
+ export declare function useWindowSize(): {
2
+ width: number;
3
+ height: number;
4
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useWindowSize = void 0;
4
+ var react_1 = require("react");
5
+ function useWindowSize() {
6
+ var _a = (0, react_1.useState)({
7
+ width: 0,
8
+ height: 0,
9
+ }), windowSize = _a[0], setWindowSize = _a[1];
10
+ (0, react_1.useEffect)(function () {
11
+ function handleResize() {
12
+ setWindowSize({
13
+ width: window.innerWidth,
14
+ height: window.innerHeight,
15
+ });
16
+ }
17
+ window.addEventListener("resize", handleResize);
18
+ handleResize();
19
+ return function () { return window.removeEventListener("resize", handleResize); };
20
+ }, []);
21
+ return windowSize;
22
+ }
23
+ exports.useWindowSize = useWindowSize;
@@ -9,7 +9,7 @@ export { default as CCF } from "./components/ccf/ccf";
9
9
  export { default as Dossie } from "./components/dossie/dossie";
10
10
  export { default as ProcessosJuridicos } from "./components/processos-juridicos/processosJuridicos";
11
11
  export { default as Addresses } from "./components/adresses/addresses";
12
- export { default as Chart, ResumoDeNegativacoesChartSection as CustomChartSection, } from "./components/chart/customChart";
12
+ export { default as ChartSystem, } from "./components/chart/chartSystem";
13
13
  export { default as BankAccounts } from "./components/bank-accounts/bank-accounts";
14
14
  export { default as ResultWithoutInformation } from "./components/interface/resultWithoutInformation";
15
15
  export * from "./components/webservice";