@tanstack/table-core 8.0.0-beta.7 → 8.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/features/Pagination.js +6 -12
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/esm/index.js +6 -12
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +308 -308
- package/build/types/features/Pagination.d.ts +1 -1
- package/build/umd/index.development.js +6 -12
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/features/Pagination.ts +15 -18
|
@@ -3,7 +3,6 @@ import { OnChangeFn, TableGenerics, TableInstance, RowModel, Updater } from '../
|
|
|
3
3
|
export declare type PaginationState = {
|
|
4
4
|
pageIndex: number;
|
|
5
5
|
pageSize: number;
|
|
6
|
-
pageCount?: number;
|
|
7
6
|
};
|
|
8
7
|
export declare type PaginationTableState = {
|
|
9
8
|
pagination: PaginationState;
|
|
@@ -12,6 +11,7 @@ export declare type PaginationInitialTableState = {
|
|
|
12
11
|
pagination?: Partial<PaginationState>;
|
|
13
12
|
};
|
|
14
13
|
export declare type PaginationOptions<TGenerics extends TableGenerics> = {
|
|
14
|
+
pageCount?: number;
|
|
15
15
|
manualPagination?: boolean;
|
|
16
16
|
onPaginationChange?: OnChangeFn<PaginationState>;
|
|
17
17
|
autoResetPageIndex?: boolean;
|
|
@@ -1689,7 +1689,7 @@
|
|
|
1689
1689
|
setPageIndex: updater => {
|
|
1690
1690
|
instance.setPagination(old => {
|
|
1691
1691
|
let pageIndex = functionalUpdate(updater, old.pageIndex);
|
|
1692
|
-
const maxPageIndex = typeof
|
|
1692
|
+
const maxPageIndex = typeof instance.options.pageCount !== 'undefined' ? instance.options.pageCount - 1 : Number.MAX_SAFE_INTEGER;
|
|
1693
1693
|
pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
|
|
1694
1694
|
return { ...old,
|
|
1695
1695
|
pageIndex
|
|
@@ -1718,9 +1718,9 @@
|
|
|
1718
1718
|
});
|
|
1719
1719
|
},
|
|
1720
1720
|
setPageCount: updater => instance.setPagination(old => {
|
|
1721
|
-
var
|
|
1721
|
+
var _instance$options$pag;
|
|
1722
1722
|
|
|
1723
|
-
let newPageCount = functionalUpdate(updater, (
|
|
1723
|
+
let newPageCount = functionalUpdate(updater, (_instance$options$pag = instance.options.pageCount) != null ? _instance$options$pag : -1);
|
|
1724
1724
|
|
|
1725
1725
|
if (typeof newPageCount === 'number') {
|
|
1726
1726
|
newPageCount = Math.max(-1, newPageCount);
|
|
@@ -1730,7 +1730,7 @@
|
|
|
1730
1730
|
pageCount: newPageCount
|
|
1731
1731
|
};
|
|
1732
1732
|
}),
|
|
1733
|
-
getPageOptions: memo(() => [instance.
|
|
1733
|
+
getPageOptions: memo(() => [instance.getPageCount()], pageCount => {
|
|
1734
1734
|
let pageOptions = [];
|
|
1735
1735
|
|
|
1736
1736
|
if (pageCount && pageCount > 0) {
|
|
@@ -1784,15 +1784,9 @@
|
|
|
1784
1784
|
return instance._getPaginationRowModel();
|
|
1785
1785
|
},
|
|
1786
1786
|
getPageCount: () => {
|
|
1787
|
-
|
|
1788
|
-
pageCount
|
|
1789
|
-
} = instance.getState().pagination;
|
|
1790
|
-
|
|
1791
|
-
if (typeof pageCount !== 'undefined') {
|
|
1792
|
-
return pageCount;
|
|
1793
|
-
}
|
|
1787
|
+
var _instance$options$pag2;
|
|
1794
1788
|
|
|
1795
|
-
return Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
|
|
1789
|
+
return (_instance$options$pag2 = instance.options.pageCount) != null ? _instance$options$pag2 : Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
|
|
1796
1790
|
}
|
|
1797
1791
|
};
|
|
1798
1792
|
}
|