-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(root): Release 2024-10-10 08:05 (#6671)
- Loading branch information
Showing
58 changed files
with
1,808 additions
and
759 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -651,6 +651,7 @@ | |
"unarchived", | ||
"Unarchived", | ||
"Unfetch", | ||
"unplugin", | ||
"Unpromoted", | ||
"unpublish", | ||
"unsub", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { | ||
Pagination, | ||
PaginationContent, | ||
PaginationItem, | ||
PaginationStart, | ||
PaginationPrevious, | ||
PaginationLink, | ||
PaginationEllipsis, | ||
PaginationNext, | ||
PaginationEnd, | ||
} from '@/components/primitives/pagination'; | ||
|
||
type DefaultPaginationProps = { | ||
offset: number; | ||
limit: number; | ||
totalCount: number; | ||
hrefFromOffset: (offset: number) => string; | ||
}; | ||
|
||
export const DefaultPagination = (props: DefaultPaginationProps) => { | ||
const { hrefFromOffset, offset, limit, totalCount } = props; | ||
const currentPage = Math.floor(offset / limit) + 1; | ||
const totalPages = Math.ceil(totalCount / limit); | ||
const startPage = Math.max(1, currentPage - 2); | ||
const endPage = Math.min(totalPages, currentPage + 2); | ||
|
||
return ( | ||
<Pagination> | ||
<PaginationContent> | ||
<PaginationItem> | ||
<PaginationStart to={hrefFromOffset(0)} /> | ||
</PaginationItem> | ||
<PaginationItem> | ||
<PaginationPrevious to={hrefFromOffset(Math.max(0, offset - limit))} isDisabled={currentPage === 1} /> | ||
</PaginationItem> | ||
{(() => { | ||
const pageItems = []; | ||
|
||
if (startPage > 1) { | ||
pageItems.push( | ||
<PaginationItem key={1}> | ||
<PaginationLink to={hrefFromOffset(0)}>1</PaginationLink> | ||
</PaginationItem> | ||
); | ||
|
||
if (startPage > 2) { | ||
pageItems.push( | ||
<PaginationItem key="ellipsis"> | ||
<PaginationEllipsis /> | ||
</PaginationItem> | ||
); | ||
} | ||
} | ||
|
||
for (let i = startPage; i <= endPage; i++) { | ||
pageItems.push( | ||
<PaginationItem key={i}> | ||
<PaginationLink to={hrefFromOffset((i - 1) * limit)} isActive={i === currentPage}> | ||
{i} | ||
</PaginationLink> | ||
</PaginationItem> | ||
); | ||
} | ||
|
||
if (endPage < totalPages) { | ||
if (endPage < totalPages - 1) { | ||
pageItems.push( | ||
<PaginationItem key="ellipsis-end"> | ||
<PaginationEllipsis /> | ||
</PaginationItem> | ||
); | ||
} | ||
|
||
pageItems.push( | ||
<PaginationItem key={totalPages}> | ||
<PaginationLink to={hrefFromOffset((totalPages - 1) * limit)}>{totalPages}</PaginationLink> | ||
</PaginationItem> | ||
); | ||
} | ||
|
||
pageItems.push( | ||
<PaginationItem key="next"> | ||
<PaginationNext | ||
to={hrefFromOffset(Math.min(offset + limit, (totalPages - 1) * limit))} | ||
isDisabled={currentPage === totalPages} | ||
/> | ||
</PaginationItem> | ||
); | ||
|
||
pageItems.push( | ||
<PaginationItem key="end"> | ||
<PaginationEnd to={hrefFromOffset((totalPages - 1) * limit)} isDisabled={currentPage === totalPages} /> | ||
</PaginationItem> | ||
); | ||
|
||
return pageItems; | ||
})()} | ||
</PaginationContent> | ||
</Pagination> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { cn } from '@/utils/ui'; | ||
|
||
function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) { | ||
return <div className={cn('bg-neutral-alpha-100 animate-pulse rounded-md', className)} {...props} />; | ||
} | ||
|
||
export { Skeleton }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/primitives/tooltip'; | ||
import { cn } from '@/utils/ui'; | ||
import { useCallback, useEffect, useRef, useState } from 'react'; | ||
|
||
interface TruncatedTextProps { | ||
text: string; | ||
className?: string; | ||
} | ||
|
||
export default function TruncatedText({ text, className = '' }: TruncatedTextProps) { | ||
const [isTruncated, setIsTruncated] = useState(false); | ||
const textRef = useRef<HTMLDivElement>(null); | ||
|
||
const checkTruncation = useCallback(() => { | ||
if (textRef.current) { | ||
const { scrollWidth, clientWidth } = textRef.current; | ||
setIsTruncated(scrollWidth > clientWidth); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
checkTruncation(); | ||
window.addEventListener('resize', checkTruncation); | ||
return () => window.removeEventListener('resize', checkTruncation); | ||
}, [checkTruncation]); | ||
|
||
return ( | ||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<span ref={textRef} className={cn('block truncate', className)}> | ||
{text} | ||
</span> | ||
</TooltipTrigger> | ||
{isTruncated && ( | ||
<TooltipContent> | ||
<p>{text}</p> | ||
</TooltipContent> | ||
)} | ||
</Tooltip> | ||
</TooltipProvider> | ||
); | ||
} |
Oops, something went wrong.