Skip to content

Commit 681b60f

Browse files
fix: type check from pagination component.
1 parent be40555 commit 681b60f

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

examples/ui-playground/src/app/playground/shadcn/pagination-section.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,13 @@ function WithEllipsisPagination() {
194194
<div className="space-y-4">
195195
<Pagination>
196196
<PaginationContent>
197-
<PaginationItem>
197+
<PaginationItem disabled={currentPage === 1}>
198198
<PaginationPrevious
199199
href="#"
200200
onClick={(e) => {
201201
e.preventDefault()
202202
setCurrentPage(Math.max(1, currentPage - 1))
203203
}}
204-
className={currentPage === 1 ? 'pointer-events-none opacity-50' : ''}
205204
/>
206205
</PaginationItem>
207206

@@ -261,14 +260,13 @@ function WithEllipsisPagination() {
261260
</>
262261
)}
263262

264-
<PaginationItem>
263+
<PaginationItem disabled={currentPage === totalPages}>
265264
<PaginationNext
266265
href="#"
267266
onClick={(e) => {
268267
e.preventDefault()
269268
setCurrentPage(Math.min(totalPages, currentPage + 1))
270269
}}
271-
className={currentPage === totalPages ? 'pointer-events-none opacity-50' : ''}
272270
/>
273271
</PaginationItem>
274272
</PaginationContent>

packages/ui/src/components/primitives/pagination.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import * as React from 'react'
44
import { ArrowLeftIcon, ArrowRightIcon, DotsThreeIcon } from '@phosphor-icons/react'
55
import { Slot } from '@radix-ui/react-slot'
66
import { 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'
910
import { ButtonGroup, buttonGroupVariants } from './button-group'
1011
import {
1112
Select,
@@ -41,13 +42,20 @@ function PaginationContent({ className, ...props }: React.ComponentProps<typeof
4142
)
4243
}
4344

45+
interface PaginationItemProps
46+
extends React.ComponentProps<typeof Slot>,
47+
VariantProps<typeof buttonVariants> {
48+
isActive?: boolean
49+
disabled?: boolean
50+
}
51+
4452
function PaginationItem({
4553
className,
4654
variant = 'outline',
4755
size = 'icon',
4856
isActive,
4957
...props
50-
}: { isActive?: boolean } & React.ComponentProps<typeof Button>) {
58+
}: PaginationItemProps) {
5159
return (
5260
<Slot
5361
{...props}

0 commit comments

Comments
 (0)