wca-designsystem 1.0.76 → 1.0.78
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
|
@@ -42,9 +42,12 @@ function BodyTable<
|
|
|
42
42
|
} = props;
|
|
43
43
|
|
|
44
44
|
const tableBodyRef = useRef<HTMLTableSectionElement | null>(null);
|
|
45
|
-
const [expandedRows, setExpandedRows] = useState<Set<number | string>>(
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const [expandedRows, setExpandedRows] = useState<Set<number | string>>(() => {
|
|
46
|
+
if (data.length === 1) {
|
|
47
|
+
return new Set([data[0].id]);
|
|
48
|
+
}
|
|
49
|
+
return new Set();
|
|
50
|
+
});
|
|
48
51
|
|
|
49
52
|
const handleRowSelect = useCallback(
|
|
50
53
|
(item: T, checked: boolean) => {
|
|
@@ -61,6 +64,7 @@ function BodyTable<
|
|
|
61
64
|
[rowSelection, setRowSelection]
|
|
62
65
|
);
|
|
63
66
|
|
|
67
|
+
|
|
64
68
|
const toggleExpandRow = useCallback((rowId: string | number) => {
|
|
65
69
|
setExpandedRows(prev => {
|
|
66
70
|
const newSet = new Set(prev);
|
|
@@ -88,6 +92,7 @@ function BodyTable<
|
|
|
88
92
|
): JSX.Element[] {
|
|
89
93
|
const isSelected = rowSelection?.some(row => row.id === item.id);
|
|
90
94
|
const hasChildren = item.children && item.children.length > 0;
|
|
95
|
+
|
|
91
96
|
return [
|
|
92
97
|
<tr
|
|
93
98
|
key={`row-${item.id}`}
|
|
@@ -201,8 +206,8 @@ function BodyTable<
|
|
|
201
206
|
);
|
|
202
207
|
})}
|
|
203
208
|
</tr>,
|
|
204
|
-
...(expandedRows.has(item.id)
|
|
205
|
-
? item
|
|
209
|
+
...(expandedRows.has(item.id) && Array.isArray(item.children)
|
|
210
|
+
? item.children.flatMap(child =>
|
|
206
211
|
renderRows(
|
|
207
212
|
child,
|
|
208
213
|
columns,
|
|
@@ -225,7 +230,7 @@ function BodyTable<
|
|
|
225
230
|
color={color}
|
|
226
231
|
style={{ left: `${hasSelect ? '53px' : '0px'}` }}
|
|
227
232
|
>
|
|
228
|
-
{data
|
|
233
|
+
{data?.flatMap(item =>
|
|
229
234
|
renderRows(
|
|
230
235
|
item,
|
|
231
236
|
columns,
|