@@ -5,11 +5,23 @@ import { AnyObject } from 'antd/es/_util/type';
55import { RowSortable } from './sortable' ;
66import { TableStyledFunc } from './styles' ;
77import { RdTableProps } from './types' ;
8+ import { useContext , useMemo } from 'react' ;
9+ import { ConfigProvider } from '../../organisms' ;
810
911export const Table = < RecordType extends AnyObject = AnyObject > (
1012 props : RdTableProps < RecordType >
1113) => {
12- const { allowSort = false , onChangeSort, ...antdProps } = props ;
14+ const { allowSort = false , pagination, onChangeSort, ...antdProps } = props ;
15+ const { table : defaultTableProps } = useContext ( ConfigProvider . ConfigContext ) ;
16+ const { pagination : defaultPagination } = defaultTableProps || { } ;
17+
18+ const paginationWithDefault = useMemo ( ( ) => {
19+ return {
20+ ...defaultPagination ,
21+ ...pagination ,
22+ } ;
23+ } , [ pagination , defaultPagination ] ) ;
24+
1325 const TableStyled = TableStyledFunc < RecordType > ( ) ;
1426
1527 if ( allowSort && props . rowKey ) {
@@ -32,11 +44,15 @@ export const Table = <RecordType extends AnyObject = AnyObject>(
3244 items = { dataSource . map ( i => i [ props . rowKey as string ] ) }
3345 strategy = { verticalListSortingStrategy }
3446 >
35- < TableStyled components = { { body : { row : RowSortable } } } { ...antdProps } />
47+ < TableStyled
48+ components = { { body : { row : RowSortable } } }
49+ pagination = { paginationWithDefault }
50+ { ...antdProps }
51+ />
3652 </ SortableContext >
3753 </ DndContext >
3854 ) ;
3955 }
4056
41- return < TableStyled { ...antdProps } /> ;
57+ return < TableStyled pagination = { paginationWithDefault } { ...antdProps } /> ;
4258} ;
0 commit comments