wca-designsystem 1.0.89 → 1.0.91
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback } from 'react'
|
|
1
|
+
import React, { useCallback, useMemo } from 'react'
|
|
2
2
|
import * as S from './styles'
|
|
3
3
|
import InputDeTexto from '../../atomos/InputDeTexto'
|
|
4
4
|
import SelectCustomizado from '../../atomos/Select'
|
|
@@ -54,6 +54,18 @@ const TabelaHeader = <T extends { id: string | number; children?: Array<T> }>({
|
|
|
54
54
|
})
|
|
55
55
|
setFormatedColumns(columnsFormated)
|
|
56
56
|
}, [])
|
|
57
|
+
|
|
58
|
+
const defaultOrderData = [
|
|
59
|
+
{ value: 'Maior', label: 'Ordenar por: Decrescente' },
|
|
60
|
+
{ value: 'Menor', label: 'Ordenar por: Crescente' },
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
const orderData = useMemo(() => {
|
|
64
|
+
if (!ordenarPor) return defaultOrderData;
|
|
65
|
+
return defaultOrderData.map((opt) =>
|
|
66
|
+
opt.value === ordenarPor.value ? { ...opt, label: ordenarPor.label } : opt
|
|
67
|
+
);
|
|
68
|
+
}, [ordenarPor]);
|
|
57
69
|
|
|
58
70
|
const columnsToHide = ['expand', 'select', 'acoes']
|
|
59
71
|
return (
|
|
@@ -70,10 +82,7 @@ const TabelaHeader = <T extends { id: string | number; children?: Array<T> }>({
|
|
|
70
82
|
{hasOrder && (
|
|
71
83
|
<SelectCustomizado
|
|
72
84
|
tipo="table"
|
|
73
|
-
data={
|
|
74
|
-
{ value: 'Maior', label: 'Ordenar por: Decrescente' },
|
|
75
|
-
{ value: 'Menor', label: 'Ordenar por: Crescente' },
|
|
76
|
-
]}
|
|
85
|
+
data={orderData}
|
|
77
86
|
onChange={(_value, option) => setOrdenarPor!(option)}
|
|
78
87
|
allowDeselect={false}
|
|
79
88
|
value={ordenarPor ? ordenarPor.value : 'Maior'}
|
|
@@ -28,10 +28,10 @@ const Paginacao = ({
|
|
|
28
28
|
quantidadeRegistros,
|
|
29
29
|
qtdRegistrosPagina,
|
|
30
30
|
}: PaginacaoProps) => {
|
|
31
|
+
|
|
31
32
|
function nextPage() {
|
|
32
|
-
if (tabelaPaginacao.pageIndex
|
|
33
|
-
|
|
34
|
-
}
|
|
33
|
+
if (tabelaPaginacao.pageIndex >= tamanhoPaginacao!) return;
|
|
34
|
+
|
|
35
35
|
setPagination({
|
|
36
36
|
pageIndex: tabelaPaginacao.pageIndex + 1,
|
|
37
37
|
pageSize: tabelaPaginacao.pageSize ?? 10,
|
|
@@ -39,18 +39,17 @@ const Paginacao = ({
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function previousPage() {
|
|
42
|
-
if (tabelaPaginacao.pageIndex <=
|
|
43
|
-
|
|
44
|
-
}
|
|
42
|
+
if (tabelaPaginacao.pageIndex <= 1) return;
|
|
43
|
+
|
|
45
44
|
setPagination({
|
|
46
45
|
pageIndex: tabelaPaginacao.pageIndex - 1,
|
|
47
46
|
pageSize: tabelaPaginacao.pageSize ?? 10,
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
function changePage(
|
|
50
|
+
function changePage(pagina: number) {
|
|
52
51
|
setPagination({
|
|
53
|
-
pageIndex:
|
|
52
|
+
pageIndex: pagina,
|
|
54
53
|
pageSize: tabelaPaginacao.pageSize ?? 10,
|
|
55
54
|
});
|
|
56
55
|
}
|