wca-designsystem 0.0.41 → 0.0.42

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,5 +1,5 @@
1
1
  {
2
- "version": "0.0.41",
2
+ "version": "0.0.42",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -93,16 +93,15 @@
93
93
  "@fullcalendar/interaction": "^6.1.15",
94
94
  "@fullcalendar/react": "^6.1.15",
95
95
  "@fullcalendar/timegrid": "^6.1.15",
96
- "@mantine/core": "7.13.2",
97
- "@mantine/dates": "^7.13.2",
98
- "@mantine/form": "^7.13.2",
99
- "@mantine/hooks": "7.13.2",
96
+ "@mantine/core": "7.13.4",
97
+ "@mantine/dates": "^7.13.4",
98
+ "@mantine/form": "^7.13.4",
99
+ "@mantine/hooks": "7.13.4",
100
100
  "@tanstack/query-sync-storage-persister": "^5.40.0",
101
101
  "@tanstack/react-query": "^5.40.1",
102
102
  "@tanstack/react-query-persist-client": "^5.40.1",
103
103
  "axios": "^1.7.2",
104
104
  "dayjs": "^1.11.13",
105
- "mantine-react-table": "^2.0.0-beta.1",
106
105
  "react-router-dom": "^6.23.1",
107
106
  "styled-components": "^6.1.11",
108
107
  "xlsx": "^0.18.5"
@@ -1,88 +0,0 @@
1
- import React from 'react';
2
- import { Table } from '@mantine/core';
3
- import * as S from './styles';
4
- import {
5
- MRT_RowData,
6
- MRT_RowSelectionState,
7
- MRT_TableBodyCellValue,
8
- MRT_TableInstance,
9
- } from 'mantine-react-table';
10
-
11
- interface BodyTableProps<T extends MRT_RowData> {
12
- table: MRT_TableInstance<T>;
13
- fixedPosition: string[] | undefined;
14
- calcStickPosition: (index: number) => number;
15
- rowSelection: MRT_RowSelectionState;
16
- setRowSelection:
17
- | React.Dispatch<React.SetStateAction<MRT_RowSelectionState>>
18
- | undefined;
19
- }
20
-
21
- function BodyTable<T extends MRT_RowData>({
22
- table,
23
- fixedPosition,
24
- calcStickPosition,
25
- rowSelection,
26
- setRowSelection,
27
- }: BodyTableProps<T>) {
28
- return (
29
- <S.TabelaBody>
30
- {/* Dados */}
31
- {table.getRowModel().rows.map((row) => {
32
- return (
33
- <Table.Tr
34
- key={row.id}
35
- data-active={row.original.nome === rowSelection.nome}
36
- >
37
- {row.getVisibleCells().map((cell, index) => {
38
- if (
39
- cell.column.id !== 'mrt-row-expand' &&
40
- cell.column.id !== 'mrt-row-select' &&
41
- cell.column.id !== 'mrt-row-actions'
42
- ) {
43
- return (
44
- <Table.Td
45
- key={cell.id}
46
- onClick={() => setRowSelection!(row.original)}
47
- className={
48
- fixedPosition?.some((fixed) => cell.column.id === fixed)
49
- ? 'sticky'
50
- : ''
51
- }
52
- style={{
53
- right:
54
- cell.column.id === 'mrt-row-actions' ? 0 : undefined,
55
- left: fixedPosition?.some(
56
- (fixed) => cell.column.id === fixed
57
- )
58
- ? calcStickPosition(index)
59
- : 0,
60
- }}
61
- >
62
- <MRT_TableBodyCellValue cell={cell} table={table} />
63
- </Table.Td>
64
- );
65
- } else {
66
- return (
67
- <Table.Td
68
- key={cell.id}
69
- className="sticky"
70
- style={{
71
- left: index === 0 ? '0' : '50px',
72
- right:
73
- cell.column.id === 'mrt-row-actions' ? '0' : undefined,
74
- }}
75
- >
76
- <MRT_TableBodyCellValue cell={cell} table={table} />
77
- </Table.Td>
78
- );
79
- }
80
- })}
81
- </Table.Tr>
82
- );
83
- })}
84
- </S.TabelaBody>
85
- );
86
- }
87
-
88
- export default BodyTable;
@@ -1,65 +0,0 @@
1
- import React from 'react';
2
- import { Table } from '@mantine/core';
3
- import * as S from './styles';
4
- import { MRT_ColumnDef, MRT_RowData } from 'mantine-react-table';
5
-
6
- interface FooterTableProps<T extends MRT_RowData> {
7
- enableRowSelection: boolean;
8
- enableExpanding: boolean;
9
- columns: MRT_ColumnDef<T>[];
10
- getValorTotalSelecionados: number | undefined;
11
- hasTotalFooter: boolean | undefined;
12
- data: any;
13
- }
14
-
15
- function FooterTable<T extends MRT_RowData>({
16
- enableRowSelection,
17
- enableExpanding,
18
- getValorTotalSelecionados,
19
- columns,
20
- data,
21
- hasTotalFooter,
22
- }: FooterTableProps<T>) {
23
- return (
24
- <S.TabelaFooter>
25
- {enableRowSelection && (
26
- <Table.Tr className="linhas-selecionadas">
27
- <Table.Td style={{ minWidth: enableExpanding ? 300 : 250 }}>
28
- Soma Linhas Selecionadas
29
- </Table.Td>
30
- <>
31
- {columns.slice(1).map((column) => {
32
- return (
33
- <Table.Td key={column.id}>
34
- {column.footer ? <b>{getValorTotalSelecionados}</b> : '-'}
35
- </Table.Td>
36
- );
37
- })}
38
- </>
39
- </Table.Tr>
40
- )}
41
- {hasTotalFooter && (
42
- <Table.Tr className="soma-total">
43
- <Table.Td
44
- style={{
45
- minWidth: enableRowSelection || enableExpanding ? 250 : 200,
46
- }}
47
- >
48
- Soma Total
49
- </Table.Td>
50
- <>
51
- {columns.slice(1).map((column) => {
52
- return (
53
- <Table.Td key={column.id}>
54
- {column.footer ? <b>{data?.total ?? 0}</b> : <>-</>}
55
- </Table.Td>
56
- );
57
- })}
58
- </>
59
- </Table.Tr>
60
- )}
61
- </S.TabelaFooter>
62
- );
63
- }
64
-
65
- export default FooterTable;
@@ -1,93 +0,0 @@
1
- import React from 'react';
2
- import { Table } from '@mantine/core';
3
- import * as S from './styles';
4
- import { MRT_RowData, MRT_TableInstance } from 'mantine-react-table';
5
- import { theme } from '../../../styles/theme';
6
- import Icone from '../../atomos/Icone';
7
- import InputDeTexto from '../../atomos/InputDeTexto';
8
- import buscar from '../../../assets/imagens/icons/Busca.svg';
9
-
10
- interface HeaderTableProps<T extends MRT_RowData> {
11
- table: MRT_TableInstance<T>;
12
- fixedPosition: string[] | undefined;
13
- calcStickPosition: (index: number) => number;
14
- toogleBuscarColuna: boolean;
15
- onFilterColunas: (id: string, value: unknown) => void;
16
- }
17
-
18
- function HeaderTable<T extends MRT_RowData>({
19
- table,
20
- fixedPosition,
21
- toogleBuscarColuna,
22
- calcStickPosition,
23
- onFilterColunas,
24
- }: HeaderTableProps<T>) {
25
- return (
26
- <S.TabelaHeader>
27
- {table.getHeaderGroups().map((headerGroup) => (
28
- <Table.Tr key={headerGroup.id}>
29
- {headerGroup.headers.map((header, index) => {
30
- if (
31
- header.id !== 'mrt-row-expand' &&
32
- header.id !== 'mrt-row-select' &&
33
- header.id !== 'mrt-row-actions'
34
- ) {
35
- return (
36
- <Table.Th
37
- key={header.id}
38
- className={
39
- fixedPosition?.some((fixed) => header.column.id === fixed)
40
- ? 'sticky'
41
- : ''
42
- }
43
- style={{
44
- left: fixedPosition?.some(
45
- (fixed) => header.column.id === fixed
46
- )
47
- ? calcStickPosition(index)
48
- : 0,
49
- }}
50
- >
51
- {toogleBuscarColuna ? (
52
- <div className="input-header">
53
- <InputDeTexto
54
- tipo="table"
55
- placeholder={`Pesquisar por: ${
56
- header.id.charAt(0).toUpperCase() + header.id.slice(1)
57
- }`}
58
- onChange={(e) =>
59
- onFilterColunas(header.id, e.currentTarget.value)
60
- }
61
- leftSection={
62
- <Icone fill={theme.colors.alert} svg={buscar} />
63
- }
64
- />
65
- </div>
66
- ) : (
67
- <>{header.id}</>
68
- )}
69
- </Table.Th>
70
- );
71
- } else {
72
- return (
73
- <Table.Th
74
- key={header.id}
75
- className={'especial sticky'}
76
- style={{
77
- left: index === 0 ? '0' : '50px',
78
- right:
79
- header.column.id === 'mrt-row-actions' ? '0' : undefined,
80
- }}
81
- >
82
- <></>
83
- </Table.Th>
84
- );
85
- }
86
- })}
87
- </Table.Tr>
88
- ))}
89
- </S.TabelaHeader>
90
- );
91
- }
92
-
93
- export default HeaderTable;
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import { Skeleton, Table } from '@mantine/core';
3
- import * as S from './styles';
4
- import { MRT_RowData, MRT_TableInstance } from 'mantine-react-table';
5
-
6
- interface SkeletonTableProps<T extends MRT_RowData> {
7
- table: MRT_TableInstance<T>;
8
- }
9
-
10
- function SkeletonTable<T extends MRT_RowData>({
11
- table,
12
- }: SkeletonTableProps<T>) {
13
- return (
14
- <S.TabelaBody>
15
- {table.getRowModel().rows.map((row) => {
16
- return (
17
- <Table.Tr key={row.id}>
18
- {row.getVisibleCells().map((cell) => (
19
- <Table.Td key={cell.id}>
20
- <Skeleton height={19} radius="xl" animate={true} />
21
- </Table.Td>
22
- ))}
23
- </Table.Tr>
24
- );
25
- })}
26
- </S.TabelaBody>
27
- );
28
- }
29
-
30
- export default SkeletonTable;
@@ -1,175 +0,0 @@
1
- import React from 'react';
2
- import Tabela, { TabelaProps } from './index';
3
- import { Meta } from '@storybook/react';
4
- import { TabelaAcoes, TabelaStoryContainer } from './styles';
5
- import IconeBotao from '../../atomos/IconeBotao';
6
- import Icone from '../../atomos/Icone';
7
- import { theme } from '../../../styles/theme';
8
- import editar from '../../../assets/imagens/icons/EditarPerfil.svg';
9
- import deletar from '../../../assets/imagens/icons/RemoveFIltro.svg';
10
-
11
- export default {
12
- title: 'Components/organismos/Tabela',
13
- component: Tabela,
14
- } as Meta;
15
-
16
- const columns: any = [
17
- {
18
- accessorKey: 'nome',
19
- header: 'Nome',
20
- filterVariant: 'autocomplete',
21
- },
22
- {
23
- accessorKey: 'email',
24
- header: 'Email',
25
- },
26
- {
27
- accessorKey: 'genero',
28
- header: 'Genero',
29
- },
30
- {
31
- accessorKey: 'rua',
32
- header: 'Rua',
33
- },
34
- {
35
- accessorKey: 'estado',
36
- header: 'Estado',
37
- },
38
- {
39
- accessorKey: 'cidade',
40
- header: 'Cidade',
41
- },
42
- ];
43
-
44
- const data: any = [
45
- {
46
- nome: 'exemplo',
47
- email: 'exemplo@gmail.com',
48
- genero: 'masculino',
49
- rua: 'Alameda Olga',
50
- estado: 'SP',
51
- cidade: 'São Paulo',
52
- },
53
- {
54
- nome: 'exemplo',
55
- email: 'exemplo@gmail.com',
56
- genero: 'masculino',
57
- rua: 'Alameda Olga',
58
- estado: 'SP',
59
- cidade: 'São Paulo',
60
- },
61
- {
62
- nome: 'exemplo',
63
- email: 'exemplo@gmail.com',
64
- genero: 'masculino',
65
- rua: 'Alameda Olga',
66
- estado: 'SP',
67
- cidade: 'São Paulo',
68
- },
69
- {
70
- nome: 'exemplo',
71
- email: 'exemplo@gmail.com',
72
- genero: 'masculino',
73
- rua: 'Alameda Olga',
74
- estado: 'SP',
75
- cidade: 'São Paulo',
76
- },
77
- {
78
- nome: 'exemplo',
79
- email: 'exemplo@gmail.com',
80
- genero: 'masculino',
81
- rua: 'Alameda Olga',
82
- estado: 'SP',
83
- cidade: 'São Paulo',
84
- },
85
- {
86
- nome: 'exemplo',
87
- email: 'exemplo@gmail.com',
88
- genero: 'masculino',
89
- rua: 'Alameda Olga',
90
- estado: 'SP',
91
- cidade: 'São Paulo',
92
- },
93
- {
94
- nome: 'exemplo',
95
- email: 'exemplo@gmail.com',
96
- genero: 'masculino',
97
- rua: 'Alameda Olga',
98
- estado: 'SP',
99
- cidade: 'São Paulo',
100
- },
101
- {
102
- nome: 'exemplo',
103
- email: 'exemplo@gmail.com',
104
- genero: 'masculino',
105
- rua: 'Alameda Olga',
106
- estado: 'SP',
107
- cidade: 'São Paulo',
108
- },
109
- {
110
- nome: 'exemplo',
111
- email: 'exemplo@gmail.com',
112
- genero: 'masculino',
113
- rua: 'Alameda Olga',
114
- estado: 'SP',
115
- cidade: 'São Paulo',
116
- },
117
- {
118
- nome: 'exemplo',
119
- email: 'exemplo@gmail.com',
120
- genero: 'masculino',
121
- rua: 'Alameda Olga',
122
- estado: 'SP',
123
- cidade: 'São Paulo',
124
- },
125
- {
126
- nome: 'exemplo',
127
- email: 'exemplo@gmail.com',
128
- genero: 'masculino',
129
- rua: 'Alameda Olga',
130
- estado: 'SP',
131
- cidade: 'São Paulo',
132
- },
133
- ];
134
-
135
- const props: TabelaProps<any> = {
136
- data: data,
137
- btnAdicionar: false,
138
- columns: columns,
139
- setPagination: () => console.log('aqui'),
140
- enableExpanding: false,
141
- enableRowSelection: false,
142
- enableRowActions: false,
143
- tamanhoPaginacao: 10,
144
- handleAdicionar: () => console.log('adicionar'),
145
- acoes: ({ row }) => (
146
- <TabelaAcoes>
147
- <IconeBotao
148
- tipo="table"
149
- onClick={() => console.log('edit', row.original)}
150
- >
151
- <Icone svg={editar} fill={theme.colors.blue} width={20} height={20} />
152
- </IconeBotao>
153
- <IconeBotao
154
- tipo="table"
155
- onClick={() => console.log('delete', row.original)}
156
- >
157
- <Icone svg={deletar} fill={theme.colors.blue} width={20} height={20} />
158
- </IconeBotao>
159
- </TabelaAcoes>
160
- ),
161
- };
162
-
163
- const Template: any = (args: TabelaProps<any>) => (
164
- <TabelaStoryContainer>
165
- <Tabela {...args} />
166
- </TabelaStoryContainer>
167
- );
168
-
169
- export const TabelaStory = Template.bind({
170
- ...props,
171
- });
172
-
173
- TabelaStory.args = {
174
- ...props,
175
- };
@@ -1,68 +0,0 @@
1
- import React from 'react';
2
- import Tabela from './index';
3
- import { render } from '../../../test/render';
4
-
5
- describe('Tabela', () => {
6
- const columns: any = [
7
- {
8
- accessorKey: 'nome',
9
- header: 'Nome',
10
- filterVariant: 'autocomplete',
11
- },
12
- {
13
- accessorKey: 'email',
14
- header: 'Email',
15
- },
16
- {
17
- accessorKey: 'genero',
18
- header: 'Genero',
19
- },
20
- {
21
- accessorKey: 'rua',
22
- header: 'Rua',
23
- },
24
- {
25
- accessorKey: 'estado',
26
- header: 'Estado',
27
- },
28
- {
29
- accessorKey: 'cidade',
30
- header: 'Cidade',
31
- },
32
- ];
33
- it('Renderiza corretamente', () => {
34
- const { getByText } = render(
35
- <Tabela<any>
36
- btnAdicionar={false}
37
- setPagination={() => console.log('auqi')}
38
- loading={false}
39
- data={[]}
40
- tituloTabela="Usuário"
41
- enableExpanding={false}
42
- enableRowSelection={false}
43
- columns={columns}
44
- />
45
- );
46
-
47
- const titulo = getByText('Usuário');
48
- expect(titulo).toBeDefined();
49
- });
50
- it('Exporta xml', async () => {
51
- jest.mock('xlsx');
52
-
53
- const { getByText } = render(
54
- <Tabela<any>
55
- btnAdicionar={false}
56
- setPagination={() => console.log('auqi')}
57
- data={[]}
58
- loading={false}
59
- enableExpanding={false}
60
- enableRowSelection={false}
61
- tituloTabela="Usuário"
62
- columns={columns}
63
- />
64
- );
65
- const botaoPlanilha = getByText('Baixar Planilha de Dados');
66
- botaoPlanilha.click();
67
- });
68
- });
@@ -1,307 +0,0 @@
1
- import React from 'react';
2
- import {
3
- type MRT_ColumnDef,
4
- useMantineReactTable,
5
- MRT_RowData,
6
- MRT_ColumnFilterFnsState,
7
- MRT_ColumnFiltersState,
8
- MRT_SortingState,
9
- MRT_ColumnOrderState,
10
- MRT_RowSelectionState,
11
- MRT_Cell,
12
- MRT_Row,
13
- MRT_TableInstance,
14
- MRT_PaginationState,
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';
29
-
30
- export interface TabelaProps<T extends MRT_RowData> {
31
- data: Array<T>;
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
- btnAdicionar: boolean;
52
- quantidadeRegistros?: number;
53
- setPagination: React.Dispatch<React.SetStateAction<MRT_PaginationState>>;
54
- loading?: boolean;
55
- }
56
-
57
- function Tabela<T extends MRT_RowData>({
58
- columns,
59
- tituloTabela,
60
- setRowSelection,
61
- enableRowSelection,
62
- acoes,
63
- tamanhoPaginacao,
64
- enableRowActions,
65
- quantidadeRegistros,
66
- hasTotalFooter,
67
- setPagination,
68
- loading,
69
- handleAdicionar,
70
- data,
71
- btnAdicionar,
72
- enableExpanding,
73
- rowSelection = {},
74
- fixedPosition,
75
- }: TabelaProps<T>) {
76
- const [searchParams] = useSearchParams();
77
- const pagina = searchParams.get('pagina')
78
- ? Number(searchParams.get('pagina'))
79
- : 0;
80
- const linhas = searchParams.get('linhas')
81
- ? Number(searchParams.get('linhas'))
82
- : 10;
83
-
84
- const filtrosPelaTabela = useMemo(() => {
85
- return columns.map((header) => {
86
- return {
87
- value: String(header.accessorKey),
88
- label: header.header,
89
- };
90
- });
91
- }, []);
92
-
93
- const [columnFilters, setColunaFiltros] = useState<MRT_ColumnFiltersState>(
94
- []
95
- );
96
-
97
- const [columnFilterFns, setFiltrosDeColunaFn] =
98
- useState<MRT_ColumnFilterFnsState>(
99
- Object.fromEntries(
100
- columns.map(({ accessorKey }) => [accessorKey, 'contains'])
101
- )
102
- );
103
- const [globalFilter, setGlobalFilter] = useState('');
104
- const [sorting, setSorting] = useState<MRT_SortingState>([]);
105
- const [ordenarPor, setOrdenarPor] = useState<SelectDataProps>({
106
- label: 'Ordenar por: Maior',
107
- value: 'Maior',
108
- });
109
- const [columnOrder, setColumnOrder] = useState<MRT_ColumnOrderState>([]);
110
- const [filtrosPor, setFiltrosPor] = useState(filtrosPelaTabela[0] ?? []);
111
- const [toogleBuscarColuna, setToogleBuscarColuna] = useState(false);
112
-
113
- const calcStickPosition = useCallback(
114
- (index: number) => {
115
- if (enableExpanding) {
116
- index = index - 1;
117
- }
118
- if (enableRowSelection) {
119
- index = index - 1;
120
- }
121
- const expanding = enableExpanding ? 50 : 0;
122
- const selection = enableRowSelection ? 50 : 0;
123
- const newIndex = index * 200;
124
- const total = expanding + selection + newIndex;
125
-
126
- return total;
127
- },
128
- [enableRowSelection]
129
- );
130
-
131
- const onFilterColunas = useCallback(
132
- (id: string, value: unknown) => {
133
- setColunaFiltros([{ id, value }]);
134
- },
135
- [columnFilters]
136
- );
137
-
138
- const fetchData = data ?? [];
139
-
140
- const table = useMantineReactTable({
141
- columns: columns,
142
- data: fetchData,
143
- enableRowSelection: enableRowSelection,
144
- onRowSelectionChange: setRowSelection,
145
- getRowId: (row) => row.id,
146
- enableColumnActions: true,
147
- enableRowActions: enableRowActions,
148
- enableGlobalFilterModes: false,
149
- enableColumnFilterModes: true,
150
- columnFilterModeOptions: [],
151
- enableBottomToolbar: false,
152
- enablePagination: true,
153
- enableRowVirtualization: false,
154
- enableColumnFilters: true,
155
- enableSorting: true,
156
- positionActionsColumn: 'last',
157
- positionGlobalFilter: 'right',
158
- enableDensityToggle: false,
159
- enableFullScreenToggle: false,
160
- enablePinning: true,
161
- manualFiltering: true,
162
- enableExpanding: enableExpanding,
163
- enableStickyFooter: false,
164
- onGlobalFilterChange: setGlobalFilter,
165
- onSortingChange: setSorting,
166
- onColumnFilterFnsChange: setFiltrosDeColunaFn,
167
- onColumnFiltersChange: setColunaFiltros,
168
- initialState: {
169
- isLoading: loading,
170
- showColumnFilters: false,
171
- showGlobalFilter: false,
172
- /* pagination: {
173
- pageIndex: 0,
174
- pageSize: 10,
175
- }, */
176
- },
177
- state: {
178
- isLoading: loading,
179
- showProgressBars: loading,
180
- columnFilterFns,
181
- columnFilters,
182
- rowSelection: enableRowSelection ? rowSelection : {},
183
- columnOrder,
184
- globalFilter,
185
- sorting: sorting,
186
- pagination: {
187
- pageIndex: 0,
188
- pageSize: linhas,
189
- },
190
- },
191
- onColumnOrderChange: setColumnOrder,
192
- localization: MRT_Localization_PT_BR,
193
-
194
- mantineTableBodyCellProps: ({ row }) => ({
195
- align: 'center',
196
- onClick: row.getToggleSelectedHandler(),
197
- }),
198
- mantineTableHeadCellProps: {
199
- align: 'center',
200
- },
201
- mantineTableProps: {
202
- highlightOnHover: true,
203
- striped: 'odd',
204
- bga: 'white',
205
- fz: 'xs',
206
- },
207
- renderRowActions: acoes,
208
- });
209
-
210
- const exportarXlsx = useCallback(() => {
211
- const ws = utils.json_to_sheet(data);
212
- const wb = utils.book_new();
213
- utils.book_append_sheet(wb, ws, 'Data');
214
- writeFileXLSX(wb, 'SheetJSReactAoO.xlsx');
215
- }, [data]);
216
-
217
- const getValorTotalSelecionados = useMemo(() => {
218
- const columnsWithFooter = columns.find((column) => column.footer);
219
- if (columnsWithFooter?.accessorKey) {
220
- let total = 0;
221
- data?.forEach((dado: T) => {
222
- if (rowSelection[dado.id]) {
223
- total += dado[columnsWithFooter?.accessorKey!];
224
- }
225
- });
226
- return total;
227
- }
228
-
229
- return 0;
230
- }, [rowSelection]);
231
-
232
- return (
233
- <S.TabelaWrapper>
234
- {/* Filtros e titulo */}
235
- <TabelaHeader<T>
236
- btnAdicionar={btnAdicionar}
237
- setSimples={() => console.log('aqui')}
238
- setPagination={setPagination}
239
- table={table}
240
- toogleBuscarColuna={toogleBuscarColuna}
241
- setToogleBuscarColuna={setToogleBuscarColuna}
242
- handleAdicionar={handleAdicionar}
243
- setGlobalFilter={setGlobalFilter}
244
- filtrosPelaTabela={filtrosPelaTabela}
245
- filtrosPor={filtrosPor}
246
- ordenarPor={ordenarPor}
247
- setFiltrosPor={setFiltrosPor}
248
- setOrdenarPor={setOrdenarPor}
249
- tituloTabela={tituloTabela}
250
- exportarXlsx={exportarXlsx}
251
- />
252
- {/* Tabela com dados */}
253
- <S.TabelaContainer style={{ height: hasTotalFooter ? '540px' : '100%' }}>
254
- <Table
255
- highlightOnHover
256
- horizontalSpacing="xs"
257
- striped
258
- highlightOnHoverColor={'blue'}
259
- fz={'xs'}
260
- >
261
- <HeaderTable
262
- calcStickPosition={calcStickPosition}
263
- fixedPosition={fixedPosition}
264
- onFilterColunas={onFilterColunas}
265
- table={table}
266
- toogleBuscarColuna={toogleBuscarColuna}
267
- />
268
- {loading ? (
269
- /* Skeleton */
270
- <SkeletonTable table={table} />
271
- ) : (
272
- <BodyTable
273
- calcStickPosition={calcStickPosition}
274
- fixedPosition={fixedPosition}
275
- rowSelection={rowSelection}
276
- setRowSelection={setRowSelection}
277
- table={table}
278
- />
279
- )}
280
- <FooterTable
281
- columns={columns}
282
- data={data}
283
- enableExpanding={enableExpanding}
284
- enableRowSelection={enableRowSelection}
285
- getValorTotalSelecionados={getValorTotalSelecionados}
286
- hasTotalFooter={hasTotalFooter}
287
- />
288
- </Table>
289
- </S.TabelaContainer>
290
-
291
- {/* Paginação */}
292
- <S.TabelaPaginationWrapper>
293
- <Paginacao
294
- setPagination={setPagination}
295
- tamanhoPaginacao={tamanhoPaginacao}
296
- quantidadeRegistros={quantidadeRegistros}
297
- tabelaPaginacao={{
298
- pageIndex: pagina,
299
- pageSize: linhas,
300
- }}
301
- />
302
- </S.TabelaPaginationWrapper>
303
- </S.TabelaWrapper>
304
- );
305
- }
306
-
307
- export default Tabela;
@@ -1,191 +0,0 @@
1
- import { Table } from '@mantine/core';
2
- import styled, { css } from 'styled-components';
3
-
4
- export const TabelaWrapper = styled.div`
5
- ${() => css`
6
- max-width: 1500px;
7
- border-radius: 5px;
8
- font-family: 'Open Sans', sans-serif;
9
- `}
10
- `;
11
-
12
- export const TabelaContainer = styled.div`
13
- ${({ theme }) => css`
14
- max-height: 620px;
15
- max-width: 1500px;
16
- overflow: auto;
17
- position: relative;
18
-
19
- .sticky {
20
- position: sticky;
21
- z-index: 3;
22
- max-width: 200px;
23
- }
24
-
25
- .mantine-Table-td {
26
- text-align: center;
27
- overflow: hidden;
28
- white-space: nowrap;
29
- text-overflow: ellipsis;
30
-
31
- p {
32
- font-size: ${theme.sizes.small};
33
- }
34
- }
35
-
36
- .mantine-active {
37
- &:hover {
38
- opacity: 0.7;
39
- color: ${theme.colors.blue};
40
- }
41
- }
42
- `}
43
- `;
44
-
45
- export const TabelaHeader = styled(Table.Thead)`
46
- ${({ theme }) => css`
47
- th {
48
- min-width: 100%;
49
- text-align: center;
50
- text-transform: capitalize;
51
- padding: 5px;
52
- background-color: rgba(53, 50, 164, 0.2);
53
- color: ${theme.colors.blue};
54
- font-weight: bold;
55
- /* border-radius: 5px; */
56
- }
57
-
58
- .sticky {
59
- background-color: ${theme.colors.blue};
60
- color: ${theme.colors.white};
61
- }
62
-
63
- .input-header {
64
- background-color: ${theme.colors.white};
65
- padding: 5px;
66
- border-radius: 5px;
67
- text-align: center;
68
- display: flex;
69
- justify-content: center;
70
- }
71
-
72
- .especial {
73
- min-width: 50px;
74
- }
75
- `}
76
- `;
77
-
78
- export const TabelaAcoes = styled.div`
79
- ${() => css`
80
- display: flex;
81
- gap: 8px;
82
-
83
- td {
84
- border: 1px solid red;
85
- z-index: 3;
86
- position: fixed;
87
- right: 0;
88
- }
89
- `}
90
- `;
91
-
92
- export const TabelaBody = styled(Table.Tbody)`
93
- ${({ theme }) => css`
94
- min-height: 520px;
95
- cursor: pointer;
96
-
97
- tr {
98
- background-color: ${theme.colors.gray['300']};
99
-
100
- td {
101
- max-width: 200px;
102
- color: ${theme.colors.blackWca};
103
- }
104
- &:nth-child(odd) {
105
- background-color: ${theme.colors.white};
106
- }
107
-
108
- &:hover {
109
- opacity: 0.6;
110
- }
111
-
112
- &[data-active='true'] {
113
- background-color: ${theme.colors.gray['700']};
114
- color: ${theme.colors.white};
115
- }
116
- }
117
-
118
- svg {
119
- color: ${theme.colors.white};
120
- }
121
-
122
- .mantine-focus-auto {
123
- &:hover {
124
- opacity: 0.6;
125
- }
126
- }
127
- .sticky {
128
- background-color: rgba(53, 50, 164, 0.9);
129
- color: ${theme.colors.white};
130
- font-weight: bold;
131
- }
132
- `}
133
- `;
134
-
135
- export const TabelaFooter = styled(Table.Tfoot)`
136
- ${({ theme }) => css`
137
- position: absolute;
138
- color: ${theme.colors.blackWca};
139
-
140
- .linhas-selecionadas {
141
- background-color: ${theme.colors.white};
142
-
143
- td:first-child {
144
- left: 0;
145
- position: sticky;
146
- z-index: 3;
147
- text-align: end;
148
- font-weight: 300;
149
- }
150
-
151
- td {
152
- min-width: 200px;
153
- }
154
- }
155
-
156
- .soma-total {
157
- background-color: ${theme.colors.blue};
158
-
159
- td {
160
- min-width: 200px;
161
- color: ${theme.colors.white};
162
- font-weight: bold;
163
- text-transform: uppercase;
164
- }
165
-
166
- td:first-child {
167
- left: 0;
168
- position: sticky;
169
- z-index: 3;
170
- text-align: end;
171
- }
172
- }
173
- `}
174
- `;
175
-
176
- export const TabelaPaginationWrapper = styled.div`
177
- ${() => css`
178
- border: none;
179
- `}
180
- `;
181
-
182
- export const TabelaStoryContainer = styled.div`
183
- ${({ theme }) => css`
184
- background-color: ${theme.colors.gray['300']};
185
- .mrt-table-head-sort-button {
186
- margin-left: 5px;
187
- width: 15px;
188
- height: 15px;
189
- }
190
- `}
191
- `;