@@ -11,7 +11,7 @@ export function PagerNav({
1111 pagerInfo,
1212 linkCreator,
1313 ...btnProps
14- } : PagerNavProps & { pagerInfo : PagerInfo , linkCreator : PageLinkCreator } ) {
14+ } : PagerNavProps & { pagerInfo : PagerInfo ; linkCreator : PageLinkCreator } ) {
1515 if ( ! pagerInfo . pageTotal ) {
1616 return ;
1717 }
@@ -26,32 +26,32 @@ export function PagerNav({
2626
2727 const createItem = ( current : number , total : number ) => {
2828 const elements : ComponentChildren [ ] = [ ] ;
29- for ( let i = current ; i <= total ; i ++ ) {
29+ for ( let i = current ; i <= total ; i ++ ) {
3030 newBtnProps . text = i ;
3131 delete newBtnProps . icon ;
3232 newBtnProps . disabled = false ;
3333 const info = updatePagerInfo ( pagerInfo , i ) ;
3434 if ( linkCreator ) {
35- newBtnProps . url = typeof linkCreator === 'function' ? linkCreator ( info ) : formatString ( linkCreator , info ) ;
35+ newBtnProps . url = typeof linkCreator === 'function' ? linkCreator ( info ) : formatString ( linkCreator , info ) ;
3636 }
3737 elements . push ( < Button type = { type } { ...newBtnProps } /> ) ;
3838 }
3939 return elements ;
4040 } ;
4141
4242 let resultElements : ComponentChildren [ ] = [ ] ;
43- resultElements = [ ...createItem ( 1 , 1 ) ] ;
43+ resultElements = [ ...createItem ( 1 , 1 ) ] ;
4444 if ( pagerInfo . pageTotal <= 1 ) {
4545 return resultElements ;
4646 }
4747 if ( pagerInfo . pageTotal <= count ) {
48- resultElements = [ ...resultElements , ...createItem ( 2 , pagerInfo . pageTotal ) ] ;
48+ resultElements = [ ...resultElements , ...createItem ( 2 , pagerInfo . pageTotal ) ] ;
4949 } else if ( pagerInfo . page < ( count - 2 ) ) {
50- resultElements = [ ...resultElements , ...createItem ( 2 , count - 2 ) , createEllipsis ( ) , ...createItem ( pagerInfo . pageTotal , pagerInfo . pageTotal ) ] ;
50+ resultElements = [ ...resultElements , ...createItem ( 2 , count - 2 ) , createEllipsis ( ) , ...createItem ( pagerInfo . pageTotal , pagerInfo . pageTotal ) ] ;
5151 } else if ( pagerInfo . page > ( pagerInfo . pageTotal - count + 3 ) ) {
5252 resultElements = [ ...resultElements , createEllipsis ( ) , ...createItem ( ( pagerInfo . pageTotal - count + 3 ) , pagerInfo . pageTotal ) ] ;
5353 } else {
54- resultElements = [ ...resultElements , createEllipsis ( ) , ...createItem ( pagerInfo . page - Math . ceil ( ( count - 4 ) / 2 ) , pagerInfo . page + Math . floor ( ( count - 4 ) / 2 ) ) , createEllipsis ( ) , ...createItem ( pagerInfo . pageTotal , pagerInfo . pageTotal ) ] ;
54+ resultElements = [ ...resultElements , createEllipsis ( ) , ...createItem ( pagerInfo . page - Math . ceil ( ( count - 4 ) / 2 ) , pagerInfo . page + Math . floor ( ( count - 4 ) / 2 ) ) , createEllipsis ( ) , ...createItem ( pagerInfo . pageTotal , pagerInfo . pageTotal ) ] ;
5555 }
5656 return resultElements ;
5757}
0 commit comments