wca-designsystem 0.0.93 → 0.0.95
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
|
import React from 'react';
|
|
2
|
-
import { Switch } from '@mantine/core';
|
|
2
|
+
import { Checkbox, Switch } from '@mantine/core';
|
|
3
3
|
import * as S from './styles';
|
|
4
4
|
import { Column } from '.';
|
|
5
5
|
import buscar from '../../../assets/imagens/icons/Busca.svg';
|
|
@@ -14,7 +14,10 @@ type HeaderOptions = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
type HeaderTabelaProps<T> = {
|
|
17
|
+
data: Array<T>;
|
|
17
18
|
columns: Column<T>[];
|
|
19
|
+
rowSelection?: Array<T>;
|
|
20
|
+
setRowSelection?: React.Dispatch<React.SetStateAction<Array<T>>> | undefined;
|
|
18
21
|
fixedPosition: Array<String>;
|
|
19
22
|
calcStickPosition?: (index: number) => number;
|
|
20
23
|
headerSelection?: Array<String>;
|
|
@@ -34,6 +37,9 @@ type HeaderTabelaProps<T> = {
|
|
|
34
37
|
>;
|
|
35
38
|
};
|
|
36
39
|
const HeaderTabela = <T,>({
|
|
40
|
+
data,
|
|
41
|
+
rowSelection,
|
|
42
|
+
setRowSelection,
|
|
37
43
|
columns,
|
|
38
44
|
fixedPosition,
|
|
39
45
|
color,
|
|
@@ -67,6 +73,17 @@ const HeaderTabela = <T,>({
|
|
|
67
73
|
[headerSelection]
|
|
68
74
|
);
|
|
69
75
|
|
|
76
|
+
const handleSelectAll = useCallback(
|
|
77
|
+
(checked: boolean) => {
|
|
78
|
+
if (checked) {
|
|
79
|
+
setRowSelection!(data); // Seleciona todos os dados
|
|
80
|
+
} else {
|
|
81
|
+
setRowSelection!([]); // Desmarca todos
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
[data, setRowSelection]
|
|
85
|
+
);
|
|
86
|
+
|
|
70
87
|
const renderHeaderOptions = useCallback((header: string | number | symbol):
|
|
71
88
|
| string
|
|
72
89
|
| undefined => {
|
|
@@ -80,12 +97,21 @@ const HeaderTabela = <T,>({
|
|
|
80
97
|
<S.TabelaHeader color={color}>
|
|
81
98
|
<tr>
|
|
82
99
|
{hasExpand && <></>}
|
|
83
|
-
{hasSelect &&
|
|
100
|
+
{hasSelect && (
|
|
101
|
+
<td className="select select-all" key={`select-all`}>
|
|
102
|
+
<Checkbox
|
|
103
|
+
size="md"
|
|
104
|
+
color={color}
|
|
105
|
+
type="checkbox"
|
|
106
|
+
checked={rowSelection?.length === data.length}
|
|
107
|
+
onChange={e => handleSelectAll(e.target.checked)}
|
|
108
|
+
/>
|
|
109
|
+
</td>
|
|
110
|
+
)}
|
|
84
111
|
{columns.map((header, index) => {
|
|
85
112
|
if (header.key === 'expand')
|
|
86
113
|
return <th key={index} className="expand"></th>;
|
|
87
|
-
if (header.key === 'select')
|
|
88
|
-
return <th key={index} className="select"></th>;
|
|
114
|
+
if (header.key === 'select') return <></>;
|
|
89
115
|
if (header.key !== 'acoes') {
|
|
90
116
|
return (
|
|
91
117
|
<th
|
|
@@ -75,6 +75,17 @@ export const TabelaHeader = styled.thead<ColorsProp>`
|
|
|
75
75
|
font-weight: bold;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
.select-all {
|
|
79
|
+
z-index: 10;
|
|
80
|
+
background-color: ${color};
|
|
81
|
+
border: none;
|
|
82
|
+
min-height: 53px;
|
|
83
|
+
background-color: ${color};
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
}
|
|
88
|
+
|
|
78
89
|
th.expand {
|
|
79
90
|
width: 50px;
|
|
80
91
|
min-width: 100%;
|