2023-01-11 08:59:56 +00:00
|
|
|
import clsx from 'clsx';
|
|
|
|
|
2022-01-04 12:16:09 +00:00
|
|
|
import { ItemsPerPageSelector } from './ItemsPerPageSelector';
|
|
|
|
import { PageSelector } from './PageSelector';
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
onPageChange(page: number): void;
|
|
|
|
onPageLimitChange(value: number): void;
|
|
|
|
page: number;
|
|
|
|
pageLimit: number;
|
2022-05-23 07:57:22 +00:00
|
|
|
showAll?: boolean;
|
2022-01-04 12:16:09 +00:00
|
|
|
totalCount: number;
|
2022-05-23 07:57:22 +00:00
|
|
|
isPageInputVisible?: boolean;
|
2023-01-11 08:59:56 +00:00
|
|
|
className?: string;
|
2022-01-04 12:16:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function PaginationControls({
|
|
|
|
pageLimit,
|
|
|
|
page,
|
|
|
|
onPageLimitChange,
|
|
|
|
showAll,
|
|
|
|
onPageChange,
|
|
|
|
totalCount,
|
2022-05-23 07:57:22 +00:00
|
|
|
isPageInputVisible,
|
2023-01-11 08:59:56 +00:00
|
|
|
className,
|
2022-01-04 12:16:09 +00:00
|
|
|
}: Props) {
|
|
|
|
return (
|
2023-01-11 08:59:56 +00:00
|
|
|
<div className={clsx('paginationControls', className)}>
|
2022-05-23 07:57:22 +00:00
|
|
|
<div className="form-inline flex">
|
2022-01-04 12:16:09 +00:00
|
|
|
<ItemsPerPageSelector
|
|
|
|
value={pageLimit}
|
|
|
|
onChange={handlePageLimitChange}
|
|
|
|
showAll={showAll}
|
|
|
|
/>
|
2022-05-23 07:57:22 +00:00
|
|
|
|
2022-01-04 12:16:09 +00:00
|
|
|
{pageLimit !== 0 && (
|
|
|
|
<PageSelector
|
|
|
|
maxSize={5}
|
|
|
|
onPageChange={onPageChange}
|
|
|
|
currentPage={page}
|
|
|
|
itemsPerPage={pageLimit}
|
|
|
|
totalCount={totalCount}
|
2022-05-23 07:57:22 +00:00
|
|
|
isInputVisible={isPageInputVisible}
|
2022-01-04 12:16:09 +00:00
|
|
|
/>
|
|
|
|
)}
|
2022-05-23 07:57:22 +00:00
|
|
|
</div>
|
2022-01-04 12:16:09 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
function handlePageLimitChange(value: number) {
|
|
|
|
onPageLimitChange(value);
|
|
|
|
onPageChange(1);
|
|
|
|
}
|
|
|
|
}
|