ConceptPortal-public/rsconcept/frontend/src/components/DataTable/SelectAll.tsx
Ivan 536705c00b
Some checks are pending
Frontend CI / build (22.x) (push) Waiting to run
F: Upgrade to tailwind 4. Fix type imports
2025-02-21 21:15:05 +03:00

29 lines
707 B
TypeScript

'use no memo';
import { type Table } from '@tanstack/react-table';
import { CheckboxTristate } from '../Input';
interface SelectAllProps<TData> {
table: Table<TData>;
resetLastSelected: () => void;
}
export 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()
}
onChange={handleChange}
/>
);
}