ConceptPortal-public/rsconcept/frontend/src/components/DataTable/SelectAll.tsx

29 lines
702 B
TypeScript
Raw Normal View History

'use no memo';
2023-09-10 20:17:18 +03:00
import { Table } from '@tanstack/react-table';
import { CheckboxTristate } from '../Input';
2023-09-10 20:17:18 +03:00
interface SelectAllProps<TData> {
2023-12-28 14:04:44 +03:00
table: Table<TData>;
resetLastSelected: () => void;
2023-09-10 20:17:18 +03:00
}
2025-02-19 23:30:35 +03:00
export function SelectAll<TData>({ table, resetLastSelected }: SelectAllProps<TData>) {
2024-03-25 23:10:29 +03:00
function handleChange(value: boolean | null) {
resetLastSelected();
2024-03-25 23:10:29 +03:00
table.toggleAllPageRowsSelected(value !== false);
}
2023-09-10 20:17:18 +03:00
return (
<CheckboxTristate
2023-12-28 14:04:44 +03:00
tabIndex={-1}
title='Выделить все'
value={
!table.getIsAllPageRowsSelected() && table.getIsSomePageRowsSelected() ? null : table.getIsAllPageRowsSelected()
}
onChange={handleChange}
2023-12-28 14:04:44 +03:00
/>
);
2023-09-10 20:17:18 +03:00
}