@@ -3,6 +3,7 @@ import classNames from 'classnames';
33import { ConfigContext } from '../config-provider/config-context' ;
44import { getPrefixCls } from '../_utils/general' ;
55import { useVirtualScroll } from '../_utils/use-virtual-scroll' ;
6+ import Pagination from '../pagination' ;
67import { TableProps , ColumnType , SortOrder } from './types' ;
78
89const ROW_HEIGHT_MAP = { sm : 40 , md : 48 , lg : 56 } as const ;
@@ -121,7 +122,6 @@ const Table = React.forwardRef<HTMLDivElement, TableProps>((props, ref) => {
121122
122123 const paginationConfig = pagination && typeof pagination === 'object' ? pagination : undefined ;
123124 const totalItems = paginationConfig ?. total ?? dataSource . length ;
124- const totalPages = Math . ceil ( totalItems / pageSize ) ;
125125 const activePage = paginationConfig ?. current ?? currentPage ;
126126
127127 const handleSort = ( col : ColumnType ) => {
@@ -362,37 +362,17 @@ const Table = React.forwardRef<HTMLDivElement, TableProps>((props, ref) => {
362362 </ tbody >
363363 </ table >
364364 </ div >
365- { showPagination && totalPages > 1 && (
366- < div className = { `${ prefixCls } __pagination` } >
367- < button
368- type = "button"
369- className = { `${ prefixCls } __page-btn` }
370- disabled = { activePage <= 1 }
371- onClick = { ( ) => handlePageChange ( activePage - 1 ) }
372- >
373- ‹
374- </ button >
375- { Array . from ( { length : totalPages } , ( _ , i ) => i + 1 ) . map ( ( page ) => (
376- < button
377- key = { page }
378- type = "button"
379- className = { classNames ( `${ prefixCls } __page-btn` , {
380- [ `${ prefixCls } __page-btn_active` ] : page === activePage ,
381- } ) }
382- onClick = { ( ) => handlePageChange ( page ) }
383- >
384- { page }
385- </ button >
386- ) ) }
387- < button
388- type = "button"
389- className = { `${ prefixCls } __page-btn` }
390- disabled = { activePage >= totalPages }
391- onClick = { ( ) => handlePageChange ( activePage + 1 ) }
392- >
393- ›
394- </ button >
395- </ div >
365+ { showPagination && (
366+ < Pagination
367+ current = { activePage }
368+ total = { totalItems }
369+ pageSize = { pageSize }
370+ align = { paginationConfig ?. align ?? 'right' }
371+ size = { paginationConfig ?. size }
372+ disabled = { paginationConfig ?. disabled }
373+ onChange = { ( page ) => handlePageChange ( page ) }
374+ style = { { padding : '16px 0' } }
375+ />
396376 ) }
397377 </ div >
398378 ) ;
0 commit comments