feat: add expand all rows

This commit is contained in:
jialin
2025-03-05 14:05:12 +08:00
parent 3fdde5f8c4
commit fd7ce9027a
12 changed files with 92 additions and 33 deletions
+14 -1
View File
@@ -15,6 +15,18 @@ export default function useExpandedRowKeys(defaultKeys: React.Key[] = []) {
[]
);
const handleExpandAll = useCallback(
(expanded: boolean, keys: React.Key[] = []) => {
if (!expanded) {
setExpandedRowKeys([]);
}
if (expanded) {
setExpandedRowKeys((prevKeys) => [...new Set([...prevKeys, ...keys])]);
}
},
[]
);
const updateExpandedRowKeys = (keys: React.Key[]) => {
setExpandedRowKeys(keys);
};
@@ -36,6 +48,7 @@ export default function useExpandedRowKeys(defaultKeys: React.Key[] = []) {
clearExpandedRowKeys,
updateExpandedRowKeys,
removeExpandedRowKey,
handleExpandChange
handleExpandChange,
handleExpandAll
};
}