@@ -4,8 +4,9 @@ import * as React from 'react'
44import { ArrowLeftIcon , ArrowRightIcon , DotsThreeIcon } from '@phosphor-icons/react'
55import { Slot } from '@radix-ui/react-slot'
66import { useControllableState } from '@radix-ui/react-use-controllable-state'
7+ import type { VariantProps } from 'class-variance-authority'
78
8- import { type Button , buttonVariants } from './button'
9+ import { buttonVariants } from './button'
910import { ButtonGroup , buttonGroupVariants } from './button-group'
1011import {
1112 Select ,
@@ -41,83 +42,59 @@ function PaginationContent({ className, ...props }: React.ComponentProps<typeof
4142 )
4243}
4344
44- function PaginationItem ( { ...props } : React . ComponentProps < typeof Slot > ) {
45- return < Slot data-slot = "pagination-item" { ...props } />
46- }
47-
48- type PaginationLinkProps = {
45+ interface PaginationItemProps
46+ extends React . ComponentProps < typeof Slot > ,
47+ VariantProps < typeof buttonVariants > {
4948 isActive ?: boolean
50- } & Pick < React . ComponentProps < typeof Button > , 'size' | ' disabled' > &
51- React . ComponentProps < 'a' >
49+ disabled ?: boolean
50+ }
5251
53- function PaginationLink ( {
52+ function PaginationItem ( {
5453 className,
55- isActive ,
54+ variant = 'outline' ,
5655 size = 'icon' ,
57- asChild ,
56+ isActive ,
5857 ...props
59- } : { asChild ?: boolean } & PaginationLinkProps ) {
60- const Comp = asChild ? Slot : 'a'
61-
58+ } : PaginationItemProps ) {
6259 return (
63- < Comp
64- aria-current = { isActive ? 'page' : undefined }
65- data-slot = "pagination-link"
66- data-active = { isActive }
60+ < Slot
61+ { ...props }
6762 className = { cn (
6863 buttonVariants ( {
69- variant : 'outline' ,
64+ variant,
7065 size,
7166 } ) ,
7267 isActive && 'bg-surface-button-outline-hover' ,
7368 className
7469 ) }
75- { ...props }
70+ data-slot = "pagination-item"
71+ aria-current = { isActive ? 'page' : undefined }
72+ data-active = { isActive }
7673 />
7774 )
7875}
7976
80- function PaginationPrevious ( { className, ...props } : React . ComponentProps < typeof PaginationLink > ) {
77+ type PaginationLinkProps = React . ComponentProps < 'a' >
78+
79+ function PaginationLink ( { asChild, ...props } : { asChild ?: boolean } & PaginationLinkProps ) {
80+ const Comp = asChild ? Slot : 'a'
81+
82+ return < Comp data-slot = "pagination-link" { ...props } />
83+ }
84+
85+ function PaginationPrevious ( props : React . ComponentProps < typeof PaginationLink > ) {
8186 return (
82- < PaginationLink
83- asChild
84- aria-label = "Go to previous page"
85- size = "md"
86- className = { cn (
87- // Strict width since sizing does not enforce the width
88- 'w-18' ,
89- {
90- 'w-16' : props . size === 'sm' ,
91- 'w-20' : props . size === 'lg' ,
92- } ,
93- className
94- ) }
95- { ...props }
96- >
87+ < PaginationLink asChild aria-label = "Go to previous page" { ...props } >
9788 < button >
9889 < ArrowLeftIcon />
9990 </ button >
10091 </ PaginationLink >
10192 )
10293}
10394
104- function PaginationNext ( { className , ... props } : React . ComponentProps < typeof PaginationLink > ) {
95+ function PaginationNext ( props : React . ComponentProps < typeof PaginationLink > ) {
10596 return (
106- < PaginationLink
107- asChild
108- aria-label = "Go to next page"
109- size = "md"
110- className = { cn (
111- // Strict width since sizing does not enforce the width
112- 'w-18' ,
113- {
114- 'w-16' : props . size === 'sm' ,
115- 'w-20' : props . size === 'lg' ,
116- } ,
117- className
118- ) }
119- { ...props }
120- >
97+ < PaginationLink asChild aria-label = "Go to next page" { ...props } >
12198 < button >
12299 < ArrowRightIcon />
123100 </ button >
@@ -128,10 +105,10 @@ function PaginationNext({ className, ...props }: React.ComponentProps<typeof Pag
128105function PaginationEllipsis ( { className, ...props } : React . ComponentProps < 'span' > ) {
129106 return (
130107 < span
108+ { ...props }
109+ className = { cn ( 'flex size-18 items-center justify-center' , className ) }
131110 aria-hidden
132111 data-slot = "pagination-ellipsis"
133- className = { cn ( 'flex size-18 items-center justify-center' , className ) }
134- { ...props }
135112 >
136113 < DotsThreeIcon className = "size-8" />
137114 < span className = "sr-only" > More pages</ span >
0 commit comments