@@ -18,6 +18,13 @@ interface PaginationProps {
1818 pageSize : number ;
1919 onChange : ( page : number ) => void ;
2020 className ?: string ;
21+ classNames ?: {
22+ control ?: string ;
23+ list ?: string ;
24+ navigation ?: string ;
25+ ellipsis ?: string ;
26+ active ?: string ;
27+ } ;
2128}
2229
2330const getPageNumbers = ( currentPageNo : number , totalPages : number ) => {
@@ -45,7 +52,7 @@ const getPageNumbers = (currentPageNo: number, totalPages: number) => {
4552} ;
4653
4754function Pagination ( props : PaginationProps ) {
48- const { defaultPage = 1 , total, pageSize, onChange, className } = props ;
55+ const { defaultPage = 1 , total, pageSize, onChange, className, classNames } = props ;
4956 const totalPages = Math . ceil ( total / pageSize ) ;
5057 const [ currentPage , setCurrentPage ] = useState ( defaultPage ) ;
5158 const [ pageNumbers , setPageNumbers ] = useState < ( number | 'ellipsis' ) [ ] > (
@@ -56,7 +63,7 @@ function Pagination(props: PaginationProps) {
5663 setPageNumbers ( getPageNumbers ( currentPage , totalPages ) ) ;
5764 } , [ currentPage , totalPages ] ) ;
5865 return (
59- < PaginationUnit className = { cn ( 'select-none' , className ) } >
66+ < PaginationUnit className = { cn ( 'select-none' , className , classNames ?. control ) } >
6067 < PaginationContent >
6168 < PaginationItem >
6269 < PaginationPrevious
@@ -68,6 +75,7 @@ function Pagination(props: PaginationProps) {
6875 } }
6976 className = { cn (
7077 'cursor-pointer' ,
78+ classNames ?. navigation ,
7179 currentPage <= 1 && 'cursor-not-allowed pointer-events-none opacity-35' ,
7280 ) }
7381 />
@@ -76,7 +84,7 @@ function Pagination(props: PaginationProps) {
7684 { pageNumbers . map ( ( page , index ) => (
7785 < PaginationItem key = { index } >
7886 { page === 'ellipsis' ? (
79- < PaginationEllipsis />
87+ < PaginationEllipsis className = { classNames ?. ellipsis } />
8088 ) : (
8189 < PaginationLink
8290 onClick = { ( ) => {
@@ -85,8 +93,11 @@ function Pagination(props: PaginationProps) {
8593 } }
8694 className = { cn (
8795 'cursor-pointer w-[32px] h-[32px] flex items-center justify-center rounded-full hover:bg-primary-gray-300' ,
88- page === currentPage &&
89- 'bg-primary-blue-600 hover:bg-primary-blue-700 dark:bg-primary-blue-500 dark:hover:bg-primary-blue-400 hover:text-primary-wite text-primary-white' ,
96+ classNames ?. list ,
97+ page === currentPage && [
98+ 'bg-primary-blue-600 hover:bg-primary-blue-700 dark:bg-primary-blue-500 dark:hover:bg-primary-blue-400 hover:text-primary-white text-primary-white' ,
99+ classNames ?. active ,
100+ ] ,
90101 ) }
91102 >
92103 { page }
@@ -105,6 +116,7 @@ function Pagination(props: PaginationProps) {
105116 } }
106117 className = { cn (
107118 'cursor-pointer' ,
119+ classNames ?. navigation ,
108120 currentPage >= totalPages && 'cursor-not-allowed pointer-events-none opacity-35' ,
109121 ) }
110122 />
0 commit comments