wca-designsystem 0.0.10 → 0.0.11
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
|
@@ -5,11 +5,7 @@ import { render } from "../../../test/render";
|
|
|
5
5
|
describe("Paginação", () => {
|
|
6
6
|
test("Renderizando corretamente", () => {
|
|
7
7
|
const { getByText } = render(
|
|
8
|
-
<Paginacao
|
|
9
|
-
handlePaginationChange={() => console.log("aqui")}
|
|
10
|
-
setTabelaPaginacaoProps={() => console.log("aqui")}
|
|
11
|
-
tabelaPaginacao={{ pageIndex: 30, pageSize: 100 }}
|
|
12
|
-
/>
|
|
8
|
+
<Paginacao tabelaPaginacao={{ pageIndex: 30, pageSize: 100 }} />
|
|
13
9
|
);
|
|
14
10
|
|
|
15
11
|
expect(getByText("Anterior")).toBeDefined();
|
|
@@ -1,31 +1,23 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import * as S from
|
|
3
|
-
import { theme } from
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { useSearchParams } from "react-router-dom";
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as S from './styles';
|
|
3
|
+
import { theme } from '../../../styles/theme';
|
|
4
|
+
import { useSearchParams } from 'react-router-dom';
|
|
5
|
+
import Botao from '../../atomos/Botao';
|
|
6
|
+
import SelectCustomizado from '../../atomos/Select';
|
|
8
7
|
|
|
9
8
|
export type PaginacaoProps = {
|
|
10
9
|
tamanhoPaginacao?: number;
|
|
10
|
+
quantidadeRegistros?: number;
|
|
11
11
|
tabelaPaginacao: {
|
|
12
12
|
pageIndex: number;
|
|
13
13
|
pageSize: number;
|
|
14
14
|
};
|
|
15
|
-
setTabelaPaginacaoProps: React.Dispatch<
|
|
16
|
-
React.SetStateAction<{
|
|
17
|
-
pageIndex: number;
|
|
18
|
-
pageSize: number;
|
|
19
|
-
}>
|
|
20
|
-
>;
|
|
21
|
-
handlePaginationChange: (updater: MRT_Updater<MRT_PaginationState>) => void;
|
|
22
15
|
};
|
|
23
16
|
|
|
24
17
|
const Paginacao = ({
|
|
25
|
-
handlePaginationChange,
|
|
26
18
|
tabelaPaginacao,
|
|
27
19
|
tamanhoPaginacao,
|
|
28
|
-
|
|
20
|
+
quantidadeRegistros,
|
|
29
21
|
}: PaginacaoProps) => {
|
|
30
22
|
const [, setSearchParams] = useSearchParams();
|
|
31
23
|
|
|
@@ -33,39 +25,33 @@ const Paginacao = ({
|
|
|
33
25
|
if (tabelaPaginacao.pageIndex + 1 > tabelaPaginacao.pageSize) {
|
|
34
26
|
return;
|
|
35
27
|
}
|
|
36
|
-
setSearchParams(params => {
|
|
37
|
-
params.set(
|
|
28
|
+
setSearchParams((params) => {
|
|
29
|
+
params.set('pagina', String(tabelaPaginacao.pageIndex + 1));
|
|
38
30
|
return params;
|
|
39
31
|
});
|
|
40
|
-
setTabelaPaginacaoProps({
|
|
41
|
-
pageIndex: tabelaPaginacao.pageIndex + 1,
|
|
42
|
-
pageSize: 10
|
|
43
|
-
});
|
|
44
32
|
}
|
|
45
33
|
|
|
46
34
|
function previousPage() {
|
|
47
35
|
if (tabelaPaginacao.pageIndex <= 0) {
|
|
48
36
|
return;
|
|
49
37
|
}
|
|
50
|
-
setSearchParams(params => {
|
|
51
|
-
params.set(
|
|
38
|
+
setSearchParams((params) => {
|
|
39
|
+
params.set('pagina', String(tabelaPaginacao.pageIndex - 1));
|
|
52
40
|
return params;
|
|
53
41
|
});
|
|
54
|
-
setTabelaPaginacaoProps({
|
|
55
|
-
pageIndex: tabelaPaginacao.pageIndex - 1,
|
|
56
|
-
pageSize: 10
|
|
57
|
-
});
|
|
58
42
|
}
|
|
59
43
|
|
|
60
44
|
function changePage(e: number) {
|
|
61
|
-
setSearchParams(params => {
|
|
62
|
-
params.set(
|
|
45
|
+
setSearchParams((params) => {
|
|
46
|
+
params.set('pagina', String(e));
|
|
63
47
|
return params;
|
|
64
48
|
});
|
|
49
|
+
}
|
|
65
50
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
function changeLinhas(e: string) {
|
|
52
|
+
setSearchParams((params) => {
|
|
53
|
+
params.set('linhas', String(e));
|
|
54
|
+
return params;
|
|
69
55
|
});
|
|
70
56
|
}
|
|
71
57
|
|
|
@@ -73,19 +59,16 @@ const Paginacao = ({
|
|
|
73
59
|
<S.PaginacaoWrapper>
|
|
74
60
|
<div className="pagination-header">
|
|
75
61
|
<p>
|
|
76
|
-
Exibindo
|
|
62
|
+
Exibindo{' '}
|
|
63
|
+
{tabelaPaginacao.pageIndex === 0 ? 1 : tabelaPaginacao.pageIndex} de{' '}
|
|
64
|
+
{quantidadeRegistros}
|
|
77
65
|
</p>
|
|
78
66
|
<div className="select-wrapper">
|
|
79
67
|
<SelectCustomizado
|
|
80
68
|
tipo="round"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
pageIndex: tabelaPaginacao.pageIndex,
|
|
85
|
-
pageSize: Number(e)
|
|
86
|
-
})}
|
|
87
|
-
defaultValue={"10"}
|
|
88
|
-
data={["10", "20", "30"]}
|
|
69
|
+
onChange={(e) => changeLinhas(e!)}
|
|
70
|
+
defaultValue={'10'}
|
|
71
|
+
data={['10', '20', '30']}
|
|
89
72
|
/>
|
|
90
73
|
</div>
|
|
91
74
|
</div>
|
|
@@ -94,14 +77,16 @@ const Paginacao = ({
|
|
|
94
77
|
data-testid="Anterior"
|
|
95
78
|
className="button-pagination"
|
|
96
79
|
tipo="default"
|
|
97
|
-
disabled={tabelaPaginacao.pageIndex ===
|
|
80
|
+
disabled={tabelaPaginacao.pageIndex === 1}
|
|
98
81
|
onClick={() => previousPage()}
|
|
99
82
|
>
|
|
100
83
|
Anterior
|
|
101
84
|
</Botao>
|
|
102
85
|
<S.PaginationMantine
|
|
103
|
-
value={
|
|
104
|
-
|
|
86
|
+
value={
|
|
87
|
+
tabelaPaginacao.pageIndex === 0 ? 1 : tabelaPaginacao.pageIndex
|
|
88
|
+
}
|
|
89
|
+
onChange={(e) => {
|
|
105
90
|
changePage(e);
|
|
106
91
|
}}
|
|
107
92
|
total={tamanhoPaginacao!}
|
|
@@ -110,8 +95,8 @@ const Paginacao = ({
|
|
|
110
95
|
/>
|
|
111
96
|
<Botao
|
|
112
97
|
data-testid="Proximo"
|
|
113
|
-
tipo={
|
|
114
|
-
disabled={tamanhoPaginacao === tabelaPaginacao.pageIndex
|
|
98
|
+
tipo={'default'}
|
|
99
|
+
disabled={tamanhoPaginacao === tabelaPaginacao.pageIndex}
|
|
115
100
|
onClick={() => nextPage()}
|
|
116
101
|
className="button-pagination"
|
|
117
102
|
>
|
|
@@ -33,7 +33,7 @@ describe('Tabela', () => {
|
|
|
33
33
|
it('Renderiza corretamente', () => {
|
|
34
34
|
const { getByText } = render(
|
|
35
35
|
<Tabela<any>
|
|
36
|
-
|
|
36
|
+
loading={false}
|
|
37
37
|
data={[]}
|
|
38
38
|
tituloTabela="Usuário"
|
|
39
39
|
enableExpanding={false}
|
|
@@ -51,7 +51,7 @@ describe('Tabela', () => {
|
|
|
51
51
|
const { getByText } = render(
|
|
52
52
|
<Tabela<any>
|
|
53
53
|
data={[]}
|
|
54
|
-
|
|
54
|
+
loading={false}
|
|
55
55
|
enableExpanding={false}
|
|
56
56
|
enableRowSelection={false}
|
|
57
57
|
tituloTabela="Usuário"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import {
|
|
3
3
|
type MRT_ColumnDef,
|
|
4
4
|
useMantineReactTable,
|
|
5
5
|
MRT_RowData,
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
MRT_ColumnFilterFnsState,
|
|
8
8
|
MRT_ColumnFiltersState,
|
|
9
9
|
MRT_SortingState,
|
|
@@ -11,127 +11,128 @@ import {
|
|
|
11
11
|
MRT_RowSelectionState,
|
|
12
12
|
MRT_Cell,
|
|
13
13
|
MRT_Row,
|
|
14
|
-
MRT_TableInstance
|
|
15
|
-
} from
|
|
16
|
-
import * as S from
|
|
17
|
-
import { useCallback, useMemo, useState } from
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
import { utils, writeFileXLSX } from
|
|
21
|
-
import { Table } from
|
|
22
|
-
import SkeletonTable from
|
|
23
|
-
import HeaderTable from
|
|
24
|
-
import BodyTable from
|
|
25
|
-
import FooterTable from
|
|
26
|
-
import {
|
|
27
|
-
import
|
|
14
|
+
MRT_TableInstance,
|
|
15
|
+
} from 'mantine-react-table'
|
|
16
|
+
import * as S from './styles'
|
|
17
|
+
import { useCallback, useMemo, useState } from 'react'
|
|
18
|
+
import { MRT_Localization_PT_BR } from '../../../utils/tableLocale'
|
|
19
|
+
|
|
20
|
+
import { utils, writeFileXLSX } from 'xlsx'
|
|
21
|
+
import { Table } from '@mantine/core'
|
|
22
|
+
import SkeletonTable from './SkeletonTable'
|
|
23
|
+
import HeaderTable from './HeaderTable'
|
|
24
|
+
import BodyTable from './BodyTable'
|
|
25
|
+
import FooterTable from './FooterTable'
|
|
26
|
+
import { useSearchParams } from 'react-router-dom'
|
|
27
|
+
import Paginacao from '../../molecules/Paginacao'
|
|
28
|
+
import TabelaHeader, { SelectDataProps } from '../../molecules/TabelaHeader'
|
|
28
29
|
|
|
29
30
|
export interface TabelaProps<T extends MRT_RowData> {
|
|
30
31
|
data: Array<T>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
rowSelection?: MRT_RowSelectionState | undefined
|
|
45
|
-
enableExpanding: boolean
|
|
46
|
-
fixedPosition?: Array<string
|
|
47
|
-
enableRowActions?: boolean
|
|
48
|
-
hasTotalFooter?: boolean
|
|
32
|
+
acoes?:
|
|
33
|
+
| ((props: {
|
|
34
|
+
cell: MRT_Cell<T, unknown>
|
|
35
|
+
renderedRowIndex?: number
|
|
36
|
+
row: MRT_Row<T>
|
|
37
|
+
table: MRT_TableInstance<T>
|
|
38
|
+
}) => React.ReactNode)
|
|
39
|
+
| undefined
|
|
40
|
+
handleAdicionar?: (() => void) | undefined
|
|
41
|
+
columns: MRT_ColumnDef<T>[]
|
|
42
|
+
tituloTabela?: string
|
|
43
|
+
enableRowSelection: boolean
|
|
44
|
+
setRowSelection?: React.Dispatch<React.SetStateAction<MRT_RowSelectionState>>
|
|
45
|
+
rowSelection?: MRT_RowSelectionState | undefined
|
|
46
|
+
enableExpanding: boolean
|
|
47
|
+
fixedPosition?: Array<string>
|
|
48
|
+
enableRowActions?: boolean
|
|
49
|
+
hasTotalFooter?: boolean
|
|
50
|
+
tamanhoPaginacao?: number
|
|
51
|
+
quantidadeRegistros?: number
|
|
52
|
+
loading?: boolean
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
function Tabela<T extends MRT_RowData>({
|
|
52
|
-
data,
|
|
53
56
|
columns,
|
|
54
|
-
isLoading,
|
|
55
57
|
tituloTabela,
|
|
56
|
-
tamanhoPaginacao,
|
|
57
58
|
setRowSelection,
|
|
58
|
-
handleAdicionar,
|
|
59
59
|
enableRowSelection,
|
|
60
|
-
enableRowActions,
|
|
61
60
|
acoes,
|
|
61
|
+
tamanhoPaginacao,
|
|
62
|
+
enableRowActions,
|
|
63
|
+
quantidadeRegistros,
|
|
62
64
|
hasTotalFooter,
|
|
65
|
+
loading,
|
|
66
|
+
handleAdicionar,
|
|
67
|
+
data,
|
|
63
68
|
enableExpanding,
|
|
64
69
|
rowSelection = {},
|
|
65
|
-
fixedPosition
|
|
70
|
+
fixedPosition,
|
|
66
71
|
}: TabelaProps<T>) {
|
|
72
|
+
const [searchParams] = useSearchParams()
|
|
73
|
+
const pagina = searchParams.get('pagina') ? Number(searchParams.get('pagina')) : 0
|
|
74
|
+
const linhas = searchParams.get('linhas')? Number(searchParams.get('linhas')) : 10
|
|
75
|
+
|
|
67
76
|
|
|
68
|
-
const [searchParams, ] = useSearchParams();
|
|
69
77
|
|
|
70
78
|
const filtrosPelaTabela = useMemo(() => {
|
|
71
79
|
return columns.map((header) => {
|
|
72
80
|
return {
|
|
73
81
|
value: String(header.accessorKey),
|
|
74
|
-
label: header.header
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
}, [])
|
|
82
|
+
label: header.header,
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
}, [])
|
|
86
|
+
|
|
87
|
+
const [columnFilters, setColunaFiltros] = useState<MRT_ColumnFiltersState>([])
|
|
78
88
|
|
|
79
|
-
const [columnFilters, setColunaFiltros] = useState<MRT_ColumnFiltersState>(
|
|
80
|
-
[]
|
|
81
|
-
);
|
|
82
89
|
const [columnFilterFns, setFiltrosDeColunaFn] =
|
|
83
90
|
useState<MRT_ColumnFilterFnsState>(
|
|
84
91
|
Object.fromEntries(
|
|
85
|
-
columns.map(({ accessorKey }) => [accessorKey,
|
|
92
|
+
columns.map(({ accessorKey }) => [accessorKey, 'contains'])
|
|
86
93
|
)
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
const [
|
|
90
|
-
const [sorting, setSorting] = useState<MRT_SortingState>([]);
|
|
91
|
-
|
|
92
|
-
const [pagination, setPagination] = useState<MRT_PaginationState>({
|
|
93
|
-
pageIndex: Number(searchParams.get('page')) || 1,
|
|
94
|
-
pageSize: 10
|
|
95
|
-
});
|
|
94
|
+
)
|
|
95
|
+
const [globalFilter, setGlobalFilter] = useState('')
|
|
96
|
+
const [sorting, setSorting] = useState<MRT_SortingState>([])
|
|
96
97
|
const [ordenarPor, setOrdenarPor] = useState<SelectDataProps>({
|
|
97
|
-
label:
|
|
98
|
-
value:
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
const [
|
|
102
|
-
const [
|
|
103
|
-
const [toogleBuscarColuna, setToogleBuscarColuna] = useState(false);
|
|
104
|
-
|
|
98
|
+
label: 'Ordenar por: Maior',
|
|
99
|
+
value: 'Maior',
|
|
100
|
+
})
|
|
101
|
+
const [columnOrder, setColumnOrder] = useState<MRT_ColumnOrderState>([])
|
|
102
|
+
const [filtrosPor, setFiltrosPor] = useState(filtrosPelaTabela[0] ?? [])
|
|
103
|
+
const [toogleBuscarColuna, setToogleBuscarColuna] = useState(false)
|
|
105
104
|
|
|
106
105
|
const calcStickPosition = useCallback(
|
|
107
106
|
(index: number) => {
|
|
108
107
|
if (enableExpanding) {
|
|
109
|
-
index = index - 1
|
|
108
|
+
index = index - 1
|
|
110
109
|
}
|
|
111
110
|
if (enableRowSelection) {
|
|
112
|
-
index = index - 1
|
|
111
|
+
index = index - 1
|
|
113
112
|
}
|
|
114
|
-
const expanding = enableExpanding ? 50 : 0
|
|
115
|
-
const selection = enableRowSelection ? 50 : 0
|
|
116
|
-
const newIndex = index * 200
|
|
117
|
-
const total = expanding + selection + newIndex
|
|
113
|
+
const expanding = enableExpanding ? 50 : 0
|
|
114
|
+
const selection = enableRowSelection ? 50 : 0
|
|
115
|
+
const newIndex = index * 200
|
|
116
|
+
const total = expanding + selection + newIndex
|
|
118
117
|
|
|
119
|
-
return total
|
|
118
|
+
return total
|
|
120
119
|
},
|
|
121
120
|
[enableRowSelection]
|
|
122
|
-
)
|
|
121
|
+
)
|
|
123
122
|
|
|
124
123
|
const onFilterColunas = useCallback(
|
|
125
124
|
(id: string, value: unknown) => {
|
|
126
|
-
setColunaFiltros([{ id, value }])
|
|
125
|
+
setColunaFiltros([{ id, value }])
|
|
127
126
|
},
|
|
128
127
|
[columnFilters]
|
|
129
|
-
)
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
const fetchData = data ?? []
|
|
130
131
|
|
|
131
132
|
|
|
132
133
|
const table = useMantineReactTable({
|
|
133
|
-
data: data,
|
|
134
134
|
columns: columns,
|
|
135
|
+
data: fetchData,
|
|
135
136
|
enableRowSelection: enableRowSelection,
|
|
136
137
|
onRowSelectionChange: setRowSelection,
|
|
137
138
|
getRowId: (row) => row.id,
|
|
@@ -145,8 +146,8 @@ function Tabela<T extends MRT_RowData>({
|
|
|
145
146
|
enableRowVirtualization: false,
|
|
146
147
|
enableColumnFilters: true,
|
|
147
148
|
enableSorting: true,
|
|
148
|
-
positionActionsColumn:
|
|
149
|
-
positionGlobalFilter:
|
|
149
|
+
positionActionsColumn: 'last',
|
|
150
|
+
positionGlobalFilter: 'right',
|
|
150
151
|
enableDensityToggle: false,
|
|
151
152
|
enableFullScreenToggle: false,
|
|
152
153
|
enablePinning: true,
|
|
@@ -158,17 +159,17 @@ function Tabela<T extends MRT_RowData>({
|
|
|
158
159
|
onColumnFilterFnsChange: setFiltrosDeColunaFn,
|
|
159
160
|
onColumnFiltersChange: setColunaFiltros,
|
|
160
161
|
initialState: {
|
|
161
|
-
isLoading:
|
|
162
|
+
isLoading: loading,
|
|
162
163
|
showColumnFilters: false,
|
|
163
164
|
showGlobalFilter: false,
|
|
164
|
-
|
|
165
|
-
pageIndex:
|
|
166
|
-
pageSize:
|
|
167
|
-
}
|
|
165
|
+
/* pagination: {
|
|
166
|
+
pageIndex: 0,
|
|
167
|
+
pageSize: 10,
|
|
168
|
+
}, */
|
|
168
169
|
},
|
|
169
170
|
state: {
|
|
170
|
-
isLoading,
|
|
171
|
-
showProgressBars:
|
|
171
|
+
isLoading: loading,
|
|
172
|
+
showProgressBars: loading,
|
|
172
173
|
columnFilterFns,
|
|
173
174
|
columnFilters,
|
|
174
175
|
rowSelection: enableRowSelection ? rowSelection : {},
|
|
@@ -176,80 +177,59 @@ function Tabela<T extends MRT_RowData>({
|
|
|
176
177
|
globalFilter,
|
|
177
178
|
sorting: sorting,
|
|
178
179
|
pagination: {
|
|
179
|
-
pageIndex:
|
|
180
|
-
pageSize:
|
|
181
|
-
}
|
|
180
|
+
pageIndex: 0,
|
|
181
|
+
pageSize: linhas,
|
|
182
|
+
},
|
|
182
183
|
},
|
|
183
184
|
onColumnOrderChange: setColumnOrder,
|
|
184
185
|
localization: MRT_Localization_PT_BR,
|
|
185
186
|
|
|
186
187
|
mantineTableBodyCellProps: ({ row }) => ({
|
|
187
|
-
align:
|
|
188
|
-
onClick: row.getToggleSelectedHandler()
|
|
188
|
+
align: 'center',
|
|
189
|
+
onClick: row.getToggleSelectedHandler(),
|
|
189
190
|
}),
|
|
190
191
|
mantineTableHeadCellProps: {
|
|
191
|
-
align:
|
|
192
|
+
align: 'center',
|
|
192
193
|
},
|
|
193
194
|
mantineTableProps: {
|
|
194
195
|
highlightOnHover: true,
|
|
195
|
-
striped:
|
|
196
|
-
bga:
|
|
197
|
-
fz:
|
|
196
|
+
striped: 'odd',
|
|
197
|
+
bga: 'white',
|
|
198
|
+
fz: 'xs',
|
|
198
199
|
},
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
<S.TabelaAcoes>
|
|
202
|
-
<IconeBotao
|
|
203
|
-
tipo="table"
|
|
204
|
-
onClick={() => console.log("edit", row.original)}
|
|
205
|
-
>
|
|
206
|
-
<Icone svg={editar} fill={theme.colors.blue} width={20} height={20} />
|
|
207
|
-
</IconeBotao>
|
|
208
|
-
<IconeBotao
|
|
209
|
-
tipo="table"
|
|
210
|
-
onClick={() => console.log("delete", row.original)}
|
|
211
|
-
>
|
|
212
|
-
<Icone
|
|
213
|
-
svg={deletar}
|
|
214
|
-
fill={theme.colors.blue}
|
|
215
|
-
width={20}
|
|
216
|
-
height={20}
|
|
217
|
-
/>
|
|
218
|
-
</IconeBotao>
|
|
219
|
-
</S.TabelaAcoes>
|
|
220
|
-
) */
|
|
221
|
-
});
|
|
200
|
+
renderRowActions: acoes,
|
|
201
|
+
})
|
|
222
202
|
|
|
223
203
|
const exportarXlsx = useCallback(() => {
|
|
224
|
-
const ws = utils.json_to_sheet(data)
|
|
225
|
-
const wb = utils.book_new()
|
|
226
|
-
utils.book_append_sheet(wb, ws,
|
|
227
|
-
writeFileXLSX(wb,
|
|
228
|
-
}, [data])
|
|
204
|
+
const ws = utils.json_to_sheet(data)
|
|
205
|
+
const wb = utils.book_new()
|
|
206
|
+
utils.book_append_sheet(wb, ws, 'Data')
|
|
207
|
+
writeFileXLSX(wb, 'SheetJSReactAoO.xlsx')
|
|
208
|
+
}, [data])
|
|
229
209
|
|
|
230
210
|
const getValorTotalSelecionados = useMemo(() => {
|
|
231
|
-
const columnsWithFooter = columns.find((column) => column.footer)
|
|
211
|
+
const columnsWithFooter = columns.find((column) => column.footer)
|
|
232
212
|
if (columnsWithFooter?.accessorKey) {
|
|
233
|
-
let total = 0
|
|
213
|
+
let total = 0
|
|
234
214
|
data?.forEach((dado: T) => {
|
|
235
215
|
if (rowSelection[dado.id]) {
|
|
236
|
-
total += dado[columnsWithFooter?.accessorKey!]
|
|
216
|
+
total += dado[columnsWithFooter?.accessorKey!]
|
|
237
217
|
}
|
|
238
|
-
})
|
|
239
|
-
return total
|
|
218
|
+
})
|
|
219
|
+
return total
|
|
240
220
|
}
|
|
241
221
|
|
|
242
|
-
return
|
|
243
|
-
}, [rowSelection])
|
|
222
|
+
return 0
|
|
223
|
+
}, [rowSelection])
|
|
244
224
|
|
|
245
225
|
return (
|
|
246
226
|
<S.TabelaWrapper>
|
|
247
227
|
{/* Filtros e titulo */}
|
|
248
228
|
<TabelaHeader<T>
|
|
249
229
|
table={table}
|
|
250
|
-
handleAdicionar={handleAdicionar}
|
|
251
230
|
toogleBuscarColuna={toogleBuscarColuna}
|
|
252
231
|
setToogleBuscarColuna={setToogleBuscarColuna}
|
|
232
|
+
handleAdicionar={handleAdicionar}
|
|
253
233
|
setGlobalFilter={setGlobalFilter}
|
|
254
234
|
filtrosPelaTabela={filtrosPelaTabela}
|
|
255
235
|
filtrosPor={filtrosPor}
|
|
@@ -260,13 +240,13 @@ function Tabela<T extends MRT_RowData>({
|
|
|
260
240
|
exportarXlsx={exportarXlsx}
|
|
261
241
|
/>
|
|
262
242
|
{/* Tabela com dados */}
|
|
263
|
-
<S.TabelaContainer style={{ height: hasTotalFooter ?
|
|
243
|
+
<S.TabelaContainer style={{ height: hasTotalFooter ? '540px' : '100%' }}>
|
|
264
244
|
<Table
|
|
265
245
|
highlightOnHover
|
|
266
246
|
horizontalSpacing="xs"
|
|
267
247
|
striped
|
|
268
|
-
highlightOnHoverColor={
|
|
269
|
-
fz={
|
|
248
|
+
highlightOnHoverColor={'blue'}
|
|
249
|
+
fz={'xs'}
|
|
270
250
|
>
|
|
271
251
|
<HeaderTable
|
|
272
252
|
calcStickPosition={calcStickPosition}
|
|
@@ -275,7 +255,7 @@ function Tabela<T extends MRT_RowData>({
|
|
|
275
255
|
table={table}
|
|
276
256
|
toogleBuscarColuna={toogleBuscarColuna}
|
|
277
257
|
/>
|
|
278
|
-
{
|
|
258
|
+
{loading ? (
|
|
279
259
|
/* Skeleton */
|
|
280
260
|
<SkeletonTable table={table} />
|
|
281
261
|
) : (
|
|
@@ -292,7 +272,7 @@ function Tabela<T extends MRT_RowData>({
|
|
|
292
272
|
data={data}
|
|
293
273
|
enableExpanding={enableExpanding}
|
|
294
274
|
enableRowSelection={enableRowSelection}
|
|
295
|
-
getValorTotalSelecionados={getValorTotalSelecionados
|
|
275
|
+
getValorTotalSelecionados={getValorTotalSelecionados}
|
|
296
276
|
hasTotalFooter={hasTotalFooter}
|
|
297
277
|
/>
|
|
298
278
|
</Table>
|
|
@@ -300,18 +280,17 @@ function Tabela<T extends MRT_RowData>({
|
|
|
300
280
|
|
|
301
281
|
{/* Paginação */}
|
|
302
282
|
<S.TabelaPaginationWrapper>
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
)}
|
|
283
|
+
<Paginacao
|
|
284
|
+
tamanhoPaginacao={tamanhoPaginacao}
|
|
285
|
+
quantidadeRegistros={quantidadeRegistros}
|
|
286
|
+
tabelaPaginacao={{
|
|
287
|
+
pageIndex: pagina,
|
|
288
|
+
pageSize:linhas
|
|
289
|
+
}}
|
|
290
|
+
/>
|
|
312
291
|
</S.TabelaPaginationWrapper>
|
|
313
292
|
</S.TabelaWrapper>
|
|
314
|
-
)
|
|
293
|
+
)
|
|
315
294
|
}
|
|
316
295
|
|
|
317
|
-
export default Tabela
|
|
296
|
+
export default Tabela
|