@spratch/whtable
Version:
A typescript react accessible table component for WealthHealth
19 lines (18 loc) • 613 B
TypeScript
import { SortDescriptor } from 'react-aria-components';
export default function useTablePagination(items: Record<string, string>[]): {
currentPageData: Record<string, string>[];
allData: Record<string, string>[];
currentPage: number;
pageSize: number;
totalPages: number;
totalItems: number;
goToPage: (page: number) => void;
nextPage: () => void;
prevPage: () => void;
changePageSize: (size: number) => void;
sortDescriptor: {
column: string;
direction: "ascending" | "descending";
};
handleSortChange: (descriptor: SortDescriptor) => void;
};