mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
chore: adjust parameter order (#41037)
This commit is contained in:
parent
a268fdde8f
commit
39c645bbb7
@ -359,8 +359,8 @@ function InternalTable<RecordType extends object = any>(
|
||||
|
||||
const [mergedPagination, resetPagination] = usePagination(
|
||||
mergedData.length,
|
||||
pagination,
|
||||
onPaginationChange,
|
||||
pagination,
|
||||
);
|
||||
|
||||
changeEventInfo.pagination =
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import type { PaginationProps } from '../../pagination';
|
||||
import type { TablePaginationConfig } from '../interface';
|
||||
import extendsObject from '../../_util/extendsObject';
|
||||
import type { TablePaginationConfig } from '../interface';
|
||||
|
||||
export const DEFAULT_PAGE_SIZE = 10;
|
||||
|
||||
@ -13,10 +13,11 @@ export function getPaginationParam(
|
||||
current: mergedPagination.current,
|
||||
pageSize: mergedPagination.pageSize,
|
||||
};
|
||||
|
||||
const paginationObj = pagination && typeof pagination === 'object' ? pagination : {};
|
||||
|
||||
Object.keys(paginationObj).forEach((pageProp) => {
|
||||
const value = (mergedPagination as any)[pageProp];
|
||||
Object.keys(paginationObj).forEach((pageProp: keyof typeof paginationObj) => {
|
||||
const value = mergedPagination[pageProp];
|
||||
|
||||
if (typeof value !== 'function') {
|
||||
param[pageProp] = value;
|
||||
@ -26,22 +27,21 @@ export function getPaginationParam(
|
||||
return param;
|
||||
}
|
||||
|
||||
export default function usePagination(
|
||||
function usePagination(
|
||||
total: number,
|
||||
pagination: TablePaginationConfig | false | undefined,
|
||||
onChange: (current: number, pageSize: number) => void,
|
||||
): [TablePaginationConfig, () => void] {
|
||||
pagination?: TablePaginationConfig | false,
|
||||
): readonly [TablePaginationConfig, () => void] {
|
||||
const { total: paginationTotal = 0, ...paginationObj } =
|
||||
pagination && typeof pagination === 'object' ? pagination : {};
|
||||
|
||||
const [innerPagination, setInnerPagination] = useState<{
|
||||
current?: number;
|
||||
pageSize?: number;
|
||||
}>(() => ({
|
||||
current: 'defaultCurrent' in paginationObj ? paginationObj.defaultCurrent : 1,
|
||||
pageSize:
|
||||
'defaultPageSize' in paginationObj ? paginationObj.defaultPageSize : DEFAULT_PAGE_SIZE,
|
||||
}));
|
||||
const [innerPagination, setInnerPagination] = useState<{ current?: number; pageSize?: number }>(
|
||||
() => ({
|
||||
current: 'defaultCurrent' in paginationObj ? paginationObj.defaultCurrent : 1,
|
||||
pageSize:
|
||||
'defaultPageSize' in paginationObj ? paginationObj.defaultPageSize : DEFAULT_PAGE_SIZE,
|
||||
}),
|
||||
);
|
||||
|
||||
// ============ Basic Pagination Config ============
|
||||
const mergedPagination = extendsObject<Partial<TablePaginationConfig>>(
|
||||
@ -75,7 +75,7 @@ export default function usePagination(
|
||||
};
|
||||
|
||||
if (pagination === false) {
|
||||
return [{}, () => {}];
|
||||
return [{}, () => {}] as const;
|
||||
}
|
||||
|
||||
return [
|
||||
@ -84,5 +84,7 @@ export default function usePagination(
|
||||
onChange: onInternalChange,
|
||||
},
|
||||
refreshPagination,
|
||||
];
|
||||
] as const;
|
||||
}
|
||||
|
||||
export default usePagination;
|
||||
|
Loading…
Reference in New Issue
Block a user