@@ -12,7 +12,7 @@ export interface PaginationState {
12
12
pageSize : Writable < number > ;
13
13
pageIndex : Writable < number > ;
14
14
pageCount : Readable < number > ;
15
- serverItemsCount : Writable < number > ;
15
+ serverItemCount : Writable < number > ;
16
16
hasPreviousPage : Readable < boolean > ;
17
17
hasNextPage : Readable < boolean > ;
18
18
}
@@ -36,11 +36,11 @@ export const createPageStore = ({
36
36
37
37
const pageIndex = writable ( initialPageIndex ) ;
38
38
39
- function calcPageCountAndLimitIndex ( [ $pageSize , $itemsCount ] : [
39
+ function calcPageCountAndLimitIndex ( [ $pageSize , $itemCount ] : [
40
40
$pageSize : number ,
41
- $itemsCount : number
41
+ $itemCount : number
42
42
] ) {
43
- const $pageCount = Math . ceil ( $itemsCount / $pageSize ) ;
43
+ const $pageCount = Math . ceil ( $itemCount / $pageSize ) ;
44
44
pageIndex . update ( ( $pageIndex ) => {
45
45
if ( $pageCount > 0 && $pageIndex >= $pageCount ) {
46
46
return $pageCount - 1 ;
@@ -50,10 +50,10 @@ export const createPageStore = ({
50
50
return $pageCount ;
51
51
}
52
52
53
- const serverItemsCount = writable ( 0 ) ;
53
+ const serverItemCount = writable ( 0 ) ;
54
54
let pageCount ;
55
55
if ( serverSide ) {
56
- pageCount = derived ( [ pageSize , serverItemsCount ] , calcPageCountAndLimitIndex ) ;
56
+ pageCount = derived ( [ pageSize , serverItemCount ] , calcPageCountAndLimitIndex ) ;
57
57
} else {
58
58
const itemCount = derived ( items , ( $items ) => $items . length ) ;
59
59
pageCount = derived ( [ pageSize , itemCount ] , calcPageCountAndLimitIndex ) ;
@@ -74,7 +74,7 @@ export const createPageStore = ({
74
74
} ,
75
75
pageIndex,
76
76
pageCount,
77
- serverItemsCount ,
77
+ serverItemCount ,
78
78
hasPreviousPage,
79
79
hasNextPage,
80
80
} ;
@@ -101,7 +101,7 @@ export const addPagination =
101
101
( ) => {
102
102
const prePaginatedRows = writable < BodyRow < Item > [ ] > ( [ ] ) ;
103
103
const paginatedRows = writable < BodyRow < Item > [ ] > ( [ ] ) ;
104
- const { pageSize, pageIndex, pageCount, serverItemsCount , hasPreviousPage, hasNextPage } =
104
+ const { pageSize, pageIndex, pageCount, serverItemCount , hasPreviousPage, hasNextPage } =
105
105
createPageStore ( {
106
106
items : prePaginatedRows ,
107
107
initialPageIndex,
@@ -112,7 +112,7 @@ export const addPagination =
112
112
pageSize,
113
113
pageIndex,
114
114
pageCount,
115
- serverItemsCount ,
115
+ serverItemCount ,
116
116
hasPreviousPage,
117
117
hasNextPage,
118
118
} ;
0 commit comments