ConceptPortal-public/rsconcept/frontend/src/components/ui/DataTable/SelectAll.tsx
Ivan 72634e80fa
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
R: Decouple setters from onChange events
2024-11-21 00:26:16 +03:00

29 lines
726 B
TypeScript

import { Table } from '@tanstack/react-table';
import CheckboxTristate from '@/components/ui/CheckboxTristate';
interface SelectAllProps<TData> {
table: Table<TData>;
resetLastSelected: () => void;
}
function SelectAll<TData>({ table, resetLastSelected }: SelectAllProps<TData>) {
function handleChange(value: boolean | null) {
resetLastSelected();
table.toggleAllPageRowsSelected(value !== false);
}
return (
<CheckboxTristate
tabIndex={-1}
title='Выделить все'
value={
!table.getIsAllPageRowsSelected() && table.getIsSomePageRowsSelected() ? null : table.getIsAllPageRowsSelected()
}
setValue={handleChange}
/>
);
}
export default SelectAll;