wca-designsystem 0.0.64 → 0.0.66
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 -1
- package/src/components/organismos/Tabela/Tabela.stories.tsx +1 -1
- package/src/components/organismos/Tabela/body.tsx +0 -23
- package/src/components/organismos/Tabela/index.tsx +22 -30
- 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
|
>
|
|
@@ -73,7 +73,9 @@ 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
|
-
|
|
76
|
+
allowDeselect={false}
|
|
77
|
+
value={ordenarPor ? ordenarPor.value : 'Maior'}
|
|
78
|
+
clearable={false}
|
|
77
79
|
placeholder={`Ordenar por ${ordenarPor}`}
|
|
78
80
|
color={color}
|
|
79
81
|
maw={200}
|
|
@@ -75,7 +75,6 @@ TabelaProps.args = {
|
|
|
75
75
|
columns: columns,
|
|
76
76
|
color: theme.colors.blue,
|
|
77
77
|
hasFiltersButtons: true,
|
|
78
|
-
|
|
79
78
|
ordenarPor: {
|
|
80
79
|
label: 'Ordenar por: Maior',
|
|
81
80
|
value: 'Maior',
|
|
@@ -90,6 +89,7 @@ TabelaProps.args = {
|
|
|
90
89
|
fetchMoreData: () => console.log('fetchMoreData'),
|
|
91
90
|
hasInfinitScrool: true,
|
|
92
91
|
hasMoreData: true,
|
|
92
|
+
hasOrder: true,
|
|
93
93
|
setGlobalFilter: () => console.log('aqui'),
|
|
94
94
|
setPagination: () => console.log('aqui'),
|
|
95
95
|
quantidadeDeRegistros: 10,
|
|
@@ -70,29 +70,6 @@ function BodyTable<T extends { id: string | number; children: Array<T> }>(
|
|
|
70
70
|
});
|
|
71
71
|
}, []);
|
|
72
72
|
|
|
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
73
|
function renderRows(
|
|
97
74
|
item: T,
|
|
98
75
|
columns: Column<T>[],
|
|
@@ -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>[];
|
|
@@ -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
|
<></>
|
|
@@ -101,18 +101,20 @@ 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};
|
|
109
110
|
position: absolute;
|
|
110
|
-
left: 17px;
|
|
111
|
+
/* left: 17px; */
|
|
111
112
|
}
|
|
112
113
|
|
|
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;
|