@@ -72,7 +72,8 @@ interface PaginationState {
72
72
pageSize : number ;
73
73
}
74
74
75
- function noop ( ) { }
75
+ function noop ( ) {
76
+ }
76
77
77
78
function isInteger ( v : number ) {
78
79
const value = Number ( v ) ;
@@ -124,6 +125,7 @@ class Pagination extends React.Component<PaginationProps, PaginationState> {
124
125
totalBoundaryShowSizeChanger : 50 ,
125
126
} ;
126
127
paginationNode = React . createRef < HTMLUListElement > ( ) ;
128
+
127
129
constructor ( props : PaginationProps ) {
128
130
super ( props ) ;
129
131
@@ -529,6 +531,7 @@ class Pagination extends React.Component<PaginationProps, PaginationState> {
529
531
) ;
530
532
}
531
533
534
+ const prev = this . renderPrev ( prevPage ) ;
532
535
return (
533
536
< ul
534
537
className = { classNames (
@@ -542,18 +545,22 @@ class Pagination extends React.Component<PaginationProps, PaginationState> {
542
545
{ ...dataOrAriaAttributeProps }
543
546
>
544
547
{ totalText }
545
- < li
546
- title = { showTitle ? locale . prev_page : null }
547
- onClick = { this . prev }
548
- tabIndex = { this . hasPrev ( ) ? 0 : null }
549
- onKeyPress = { this . runIfEnterPrev }
550
- className = { classNames ( `${ prefixCls } -prev` , {
551
- [ `${ prefixCls } -disabled` ] : ! this . hasPrev ( ) ,
552
- } ) }
553
- aria-disabled = { ! this . hasPrev ( ) }
554
- >
555
- { this . renderPrev ( prevPage ) }
556
- </ li >
548
+ {
549
+ prev ? (
550
+ < li
551
+ title = { showTitle ? locale . prev_page : null }
552
+ onClick = { this . prev }
553
+ tabIndex = { this . hasPrev ( ) ? 0 : null }
554
+ onKeyPress = { this . runIfEnterPrev }
555
+ className = { classNames ( `${ prefixCls } -prev` , {
556
+ [ `${ prefixCls } -disabled` ] : ! this . hasPrev ( ) ,
557
+ } ) }
558
+ aria-disabled = { ! this . hasPrev ( ) }
559
+ >
560
+ { prev }
561
+ </ li >
562
+ ) : null
563
+ }
557
564
< li
558
565
title = { showTitle ? `${ current } /${ allPages } ` : null }
559
566
className = { `${ prefixCls } -simple-pager` }
@@ -616,9 +623,20 @@ class Pagination extends React.Component<PaginationProps, PaginationState> {
616
623
} else {
617
624
const prevItemTitle = showLessItems ? locale . prev_3 : locale . prev_5 ;
618
625
const nextItemTitle = showLessItems ? locale . next_3 : locale . next_5 ;
626
+
627
+ const jumpPrevContent = itemRender (
628
+ this . getJumpPrevPage ( ) ,
629
+ 'jump-prev' ,
630
+ this . getItemIcon ( jumpPrevIcon , 'prev page' ) ,
631
+ ) ;
632
+ const jumpNextContent = itemRender (
633
+ this . getJumpNextPage ( ) ,
634
+ 'jump-next' ,
635
+ this . getItemIcon ( jumpNextIcon , 'next page' ) ,
636
+ ) ;
619
637
if ( showPrevNextJumpers ) {
620
638
jumpPrev = (
621
- < li
639
+ jumpPrevContent ? < li
622
640
title = { showTitle ? prevItemTitle : null }
623
641
key = "prev"
624
642
onClick = { this . jumpPrev }
@@ -628,15 +646,11 @@ class Pagination extends React.Component<PaginationProps, PaginationState> {
628
646
[ `${ prefixCls } -jump-prev-custom-icon` ] : ! ! jumpPrevIcon ,
629
647
} ) }
630
648
>
631
- { itemRender (
632
- this . getJumpPrevPage ( ) ,
633
- 'jump-prev' ,
634
- this . getItemIcon ( jumpPrevIcon , 'prev page' ) ,
635
- ) }
636
- </ li >
649
+ { jumpPrevContent }
650
+ </ li > : null
637
651
) ;
638
652
jumpNext = (
639
- < li
653
+ jumpNextContent ? < li
640
654
title = { showTitle ? nextItemTitle : null }
641
655
key = "next"
642
656
tabIndex = { 0 }
@@ -646,12 +660,8 @@ class Pagination extends React.Component<PaginationProps, PaginationState> {
646
660
[ `${ prefixCls } -jump-next-custom-icon` ] : ! ! jumpNextIcon ,
647
661
} ) }
648
662
>
649
- { itemRender (
650
- this . getJumpNextPage ( ) ,
651
- 'jump-next' ,
652
- this . getItemIcon ( jumpNextIcon , 'next page' ) ,
653
- ) }
654
- </ li >
663
+ { jumpNextContent }
664
+ </ li > : null
655
665
) ;
656
666
}
657
667
lastPager = (
@@ -739,6 +749,9 @@ class Pagination extends React.Component<PaginationProps, PaginationState> {
739
749
740
750
const prevDisabled = ! this . hasPrev ( ) || ! allPages ;
741
751
const nextDisabled = ! this . hasNext ( ) || ! allPages ;
752
+
753
+ const prev = this . renderPrev ( prevPage ) ;
754
+ const next = this . renderNext ( nextPage ) ;
742
755
return (
743
756
< ul
744
757
className = { classNames ( prefixCls , className , {
@@ -749,31 +762,39 @@ class Pagination extends React.Component<PaginationProps, PaginationState> {
749
762
{ ...dataOrAriaAttributeProps }
750
763
>
751
764
{ totalText }
752
- < li
753
- title = { showTitle ? locale . prev_page : null }
754
- onClick = { this . prev }
755
- tabIndex = { prevDisabled ? null : 0 }
756
- onKeyPress = { this . runIfEnterPrev }
757
- className = { classNames ( `${ prefixCls } -prev` , {
758
- [ `${ prefixCls } -disabled` ] : prevDisabled ,
759
- } ) }
760
- aria-disabled = { prevDisabled }
761
- >
762
- { this . renderPrev ( prevPage ) }
763
- </ li >
765
+ {
766
+ prev ? (
767
+ < li
768
+ title = { showTitle ? locale . prev_page : null }
769
+ onClick = { this . prev }
770
+ tabIndex = { prevDisabled ? null : 0 }
771
+ onKeyPress = { this . runIfEnterPrev }
772
+ className = { classNames ( `${ prefixCls } -prev` , {
773
+ [ `${ prefixCls } -disabled` ] : prevDisabled ,
774
+ } ) }
775
+ aria-disabled = { prevDisabled }
776
+ >
777
+ { prev }
778
+ </ li >
779
+ ) : null
780
+ }
764
781
{ pagerList }
765
- < li
766
- title = { showTitle ? locale . next_page : null }
767
- onClick = { this . next }
768
- tabIndex = { nextDisabled ? null : 0 }
769
- onKeyPress = { this . runIfEnterNext }
770
- className = { classNames ( `${ prefixCls } -next` , {
771
- [ `${ prefixCls } -disabled` ] : nextDisabled ,
772
- } ) }
773
- aria-disabled = { nextDisabled }
774
- >
775
- { this . renderNext ( nextPage ) }
776
- </ li >
782
+ {
783
+ next ? (
784
+ < li
785
+ title = { showTitle ? locale . next_page : null }
786
+ onClick = { this . next }
787
+ tabIndex = { nextDisabled ? null : 0 }
788
+ onKeyPress = { this . runIfEnterNext }
789
+ className = { classNames ( `${ prefixCls } -next` , {
790
+ [ `${ prefixCls } -disabled` ] : nextDisabled ,
791
+ } ) }
792
+ aria-disabled = { nextDisabled }
793
+ >
794
+ { next }
795
+ </ li >
796
+ ) : null
797
+ }
777
798
< Options
778
799
disabled = { disabled }
779
800
locale = { locale }
0 commit comments