wca-designsystem 0.0.65 → 0.0.67
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 +1 -1
- package/src/components/molecules/CardDestaque/index.tsx +4 -2
- package/src/components/molecules/TabelaHeader/index.tsx +3 -2
- package/src/components/organismos/Tabela/body.tsx +5 -29
- package/src/components/organismos/Tabela/index.tsx +23 -32
- package/src/components/organismos/Tabela/styles.ts +5 -3
package/package.json
CHANGED
|
@@ -27,6 +27,7 @@ export type CardDestaqueProps = {
|
|
|
27
27
|
colorTitulo?: string;
|
|
28
28
|
liberaDownload?: boolean;
|
|
29
29
|
liberaUpload?: boolean;
|
|
30
|
+
color?: string;
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
function CardDestaque({
|
|
@@ -39,6 +40,7 @@ function CardDestaque({
|
|
|
39
40
|
verLogProcesso,
|
|
40
41
|
qtdLinhas,
|
|
41
42
|
ultimaExec,
|
|
43
|
+
color,
|
|
42
44
|
colorTitulo,
|
|
43
45
|
liberaDownload,
|
|
44
46
|
liberaUpload,
|
|
@@ -78,7 +80,7 @@ function CardDestaque({
|
|
|
78
80
|
disabled={!liberaDownload}
|
|
79
81
|
tipo="table"
|
|
80
82
|
toolTipInfo="Download"
|
|
81
|
-
color={theme.colors.gray['300']}
|
|
83
|
+
color={liberaDownload ? color : theme.colors.gray['300']}
|
|
82
84
|
onClick={onClickDownload!}
|
|
83
85
|
>
|
|
84
86
|
<Icone
|
|
@@ -93,7 +95,7 @@ function CardDestaque({
|
|
|
93
95
|
<IconeBotao
|
|
94
96
|
toolTipInfo="Upload"
|
|
95
97
|
tipo="table"
|
|
96
|
-
color={theme.colors.gray['300']}
|
|
98
|
+
color={liberaUpload ? color : theme.colors.gray['300']}
|
|
97
99
|
onClick={onClickUpload!}
|
|
98
100
|
disabled={!liberaUpload}
|
|
99
101
|
>
|
|
@@ -14,7 +14,7 @@ import plus from '../../../assets/imagens/icons/Mais.svg';
|
|
|
14
14
|
import { Menu, Switch } from '@mantine/core';
|
|
15
15
|
|
|
16
16
|
export type TabelaHeaderProps<
|
|
17
|
-
T extends { id: string | number; children
|
|
17
|
+
T extends { id: string | number; children?: Array<T> }
|
|
18
18
|
> = {
|
|
19
19
|
globalFilter: string;
|
|
20
20
|
setGlobalFilter: React.Dispatch<React.SetStateAction<string>>;
|
|
@@ -30,7 +30,7 @@ export type TabelaHeaderProps<
|
|
|
30
30
|
columns: Column<T>[];
|
|
31
31
|
setFormatedColumns: React.Dispatch<React.SetStateAction<Column<T>[]>>;
|
|
32
32
|
};
|
|
33
|
-
const TabelaHeader = <T extends { id: string | number; children
|
|
33
|
+
const TabelaHeader = <T extends { id: string | number; children?: Array<T> }>({
|
|
34
34
|
globalFilter,
|
|
35
35
|
setGlobalFilter,
|
|
36
36
|
setToogleFiltros,
|
|
@@ -73,6 +73,7 @@ const TabelaHeader = <T extends { id: string | number; children: Array<T> }>({
|
|
|
73
73
|
{ value: 'Menor', label: 'Ordenar por: Crescente' },
|
|
74
74
|
]}
|
|
75
75
|
onChange={(_value, option) => setOrdenarPor!(option)}
|
|
76
|
+
allowDeselect={false}
|
|
76
77
|
value={ordenarPor ? ordenarPor.value : 'Maior'}
|
|
77
78
|
clearable={false}
|
|
78
79
|
placeholder={`Ordenar por ${ordenarPor}`}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useCallback, useRef
|
|
1
|
+
import React, { useState, useCallback, useRef } from 'react';
|
|
2
2
|
import { Checkbox } from '@mantine/core';
|
|
3
3
|
import { Column } from '.';
|
|
4
4
|
import * as S from './styles';
|
|
@@ -7,7 +7,7 @@ import SetaBaixo from '../../../assets/imagens/icons/SetaAbaixo.svg';
|
|
|
7
7
|
import Icone from '../../atomos/Icone';
|
|
8
8
|
|
|
9
9
|
export interface BodyTableProps<
|
|
10
|
-
T extends { id: string | number; children
|
|
10
|
+
T extends { id: string | number; children?: Array<T> }
|
|
11
11
|
> {
|
|
12
12
|
data: Array<T>;
|
|
13
13
|
columns: Column<T>[];
|
|
@@ -20,10 +20,9 @@ export interface BodyTableProps<
|
|
|
20
20
|
setRowSelection?: React.Dispatch<React.SetStateAction<Array<T>>> | undefined;
|
|
21
21
|
hasInfinitScrool?: boolean;
|
|
22
22
|
hasMoreData?: boolean;
|
|
23
|
-
fetchMoreData?: () => void;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
function BodyTable<T extends { id: string | number; children
|
|
25
|
+
function BodyTable<T extends { id: string | number; children?: Array<T> }>(
|
|
27
26
|
props: BodyTableProps<T>
|
|
28
27
|
) {
|
|
29
28
|
const {
|
|
@@ -32,7 +31,7 @@ function BodyTable<T extends { id: string | number; children: Array<T> }>(
|
|
|
32
31
|
acoesChildren,
|
|
33
32
|
hasSelect,
|
|
34
33
|
rowSelection,
|
|
35
|
-
|
|
34
|
+
|
|
36
35
|
hasMoreData,
|
|
37
36
|
hasInfinitScrool,
|
|
38
37
|
setRowSelection,
|
|
@@ -70,29 +69,6 @@ function BodyTable<T extends { id: string | number; children: Array<T> }>(
|
|
|
70
69
|
});
|
|
71
70
|
}, []);
|
|
72
71
|
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
if (!fetchMoreData || !hasInfinitScrool || !tableBodyRef.current) return;
|
|
75
|
-
|
|
76
|
-
const handleScroll = () => {
|
|
77
|
-
debugger;
|
|
78
|
-
const element = tableBodyRef.current;
|
|
79
|
-
if (element) {
|
|
80
|
-
const atBottom =
|
|
81
|
-
element.scrollHeight - element.scrollTop === element.clientHeight;
|
|
82
|
-
if (atBottom) {
|
|
83
|
-
fetchMoreData(); // Dispara a função ao atingir o final do scroll
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const currentRef = tableBodyRef.current;
|
|
89
|
-
currentRef?.addEventListener('scroll', handleScroll);
|
|
90
|
-
|
|
91
|
-
return () => {
|
|
92
|
-
currentRef?.removeEventListener('scroll', handleScroll);
|
|
93
|
-
};
|
|
94
|
-
}, [fetchMoreData, hasInfinitScrool]);
|
|
95
|
-
|
|
96
72
|
function renderRows(
|
|
97
73
|
item: T,
|
|
98
74
|
columns: Column<T>[],
|
|
@@ -195,7 +171,7 @@ function BodyTable<T extends { id: string | number; children: Array<T> }>(
|
|
|
195
171
|
})}
|
|
196
172
|
</tr>,
|
|
197
173
|
...(expandedRows.has(item.id)
|
|
198
|
-
? item
|
|
174
|
+
? item?.children!.flatMap(child =>
|
|
199
175
|
renderRows(
|
|
200
176
|
child,
|
|
201
177
|
columns,
|
|
@@ -21,7 +21,7 @@ export type SelectDataProps = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export type CustomTableProps<
|
|
24
|
-
T extends { id: string | number; children
|
|
24
|
+
T extends { id: string | number; children?: Array<T> }
|
|
25
25
|
> = {
|
|
26
26
|
data: T[];
|
|
27
27
|
columns: Column<T>[];
|
|
@@ -65,7 +65,7 @@ export type CustomTableProps<
|
|
|
65
65
|
hasInfinitScrool?: boolean;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
const Tabela = <T extends { id: string | number; children
|
|
68
|
+
const Tabela = <T extends { id: string | number; children?: Array<T> }>({
|
|
69
69
|
data,
|
|
70
70
|
columns,
|
|
71
71
|
setPagination,
|
|
@@ -103,43 +103,37 @@ const Tabela = <T extends { id: string | number; children: Array<T> }>({
|
|
|
103
103
|
}))
|
|
104
104
|
);
|
|
105
105
|
|
|
106
|
-
const [tamScroll, setTamScroll] = useState<number>(0);
|
|
107
106
|
const columnsToShow = formatedColumns.filter(
|
|
108
107
|
column => column.active === true
|
|
109
108
|
);
|
|
110
109
|
|
|
111
110
|
const topScrollRef = useRef<HTMLDivElement>(null);
|
|
112
|
-
const bottomScrollRef = useRef<HTMLDivElement>(null);
|
|
113
111
|
const tabelaRef = useRef<HTMLTableElement>(null);
|
|
112
|
+
const TableContainerRef = useRef<HTMLDivElement>(null);
|
|
114
113
|
|
|
115
114
|
// Sincroniza o scroll horizontal entre os dois scrollbars
|
|
116
115
|
useEffect(() => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const tabela = tabelaRef.current;
|
|
116
|
+
if (!fetchMoreData || !hasInfinitScrool || !TableContainerRef.current)
|
|
117
|
+
return;
|
|
120
118
|
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
const handleScroll = () => {
|
|
120
|
+
const element = TableContainerRef.current;
|
|
121
|
+
if (element) {
|
|
122
|
+
const atBottom =
|
|
123
|
+
element.scrollHeight - element.scrollTop <= element.clientHeight + 10; // Margem de erro
|
|
124
|
+
if (atBottom) {
|
|
125
|
+
fetchMoreData(); // Dispara a função ao atingir o final do scroll
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
125
129
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
};
|
|
129
|
-
topScroll.addEventListener('scroll', onTopScroll);
|
|
130
|
-
bottomScroll.addEventListener('scroll', onBottomScroll);
|
|
130
|
+
const currentRef = TableContainerRef.current;
|
|
131
|
+
currentRef.addEventListener('scroll', handleScroll);
|
|
131
132
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
topScroll.removeEventListener('scroll', onTopScroll);
|
|
137
|
-
bottomScroll.removeEventListener('scroll', onBottomScroll);
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return;
|
|
142
|
-
}, []);
|
|
133
|
+
return () => {
|
|
134
|
+
currentRef.removeEventListener('scroll', handleScroll);
|
|
135
|
+
};
|
|
136
|
+
}, [fetchMoreData, hasInfinitScrool]);
|
|
143
137
|
|
|
144
138
|
return (
|
|
145
139
|
<S.TableWrapper>
|
|
@@ -159,10 +153,8 @@ const Tabela = <T extends { id: string | number; children: Array<T> }>({
|
|
|
159
153
|
setOrdenarPor={setOrdenarPor}
|
|
160
154
|
/>
|
|
161
155
|
{/* Scroll horizontal no topo */}
|
|
162
|
-
<S.ScrollWrapper ref={topScrollRef}>
|
|
163
|
-
|
|
164
|
-
</S.ScrollWrapper>
|
|
165
|
-
<S.TableContainer ref={bottomScrollRef}>
|
|
156
|
+
<S.ScrollWrapper ref={topScrollRef}></S.ScrollWrapper>
|
|
157
|
+
<S.TableContainer ref={TableContainerRef}>
|
|
166
158
|
<S.StyledTable ref={tabelaRef}>
|
|
167
159
|
{data?.length == 0 ? (
|
|
168
160
|
<></>
|
|
@@ -193,7 +185,6 @@ const Tabela = <T extends { id: string | number; children: Array<T> }>({
|
|
|
193
185
|
) : (
|
|
194
186
|
<BodyTable
|
|
195
187
|
color={color}
|
|
196
|
-
fetchMoreData={fetchMoreData}
|
|
197
188
|
hasInfinitScrool={hasInfinitScrool}
|
|
198
189
|
hasSelect={hasSelect}
|
|
199
190
|
hasMoreData={quantidadeRegistros !== data.length}
|
|
@@ -76,7 +76,7 @@ export const TabelaHeader = styled.thead<ColorsProp>`
|
|
|
76
76
|
|
|
77
77
|
th.expand {
|
|
78
78
|
width: 50px;
|
|
79
|
-
min-width:
|
|
79
|
+
min-width: 100%;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
.sticky {
|
|
@@ -101,8 +101,9 @@ export const TabelaHeader = styled.thead<ColorsProp>`
|
|
|
101
101
|
|
|
102
102
|
export const TabelaBody = styled.tbody<ColorsProp>`
|
|
103
103
|
${({ theme, color }) => css`
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
overflow-x: auto;
|
|
105
|
+
overflow-y: auto; /* Habilita o scroll vertical */
|
|
106
|
+
max-height: 500px; /*
|
|
106
107
|
|
|
107
108
|
.select {
|
|
108
109
|
background-color: ${color};
|
|
@@ -113,6 +114,7 @@ export const TabelaBody = styled.tbody<ColorsProp>`
|
|
|
113
114
|
.expand {
|
|
114
115
|
position: relative;
|
|
115
116
|
width: 50px;
|
|
117
|
+
min-height: 53px;
|
|
116
118
|
background-color: ${color};
|
|
117
119
|
display: flex;
|
|
118
120
|
align-items: center;
|