| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 1 | import * as React from "react"; |
| 2 | import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"; |
| gio | 5f2f100 | 2025-03-20 18:38:48 +0400 | [diff] [blame] | 3 | |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 4 | import { cn } from "@/lib/utils"; |
| gio | 5f2f100 | 2025-03-20 18:38:48 +0400 | [diff] [blame] | 5 | |
| 6 | const ScrollArea = React.forwardRef< |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 7 | React.ElementRef<typeof ScrollAreaPrimitive.Root>, |
| 8 | React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> |
| gio | 5f2f100 | 2025-03-20 18:38:48 +0400 | [diff] [blame] | 9 | >(({ className, children, ...props }, ref) => ( |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 10 | <ScrollAreaPrimitive.Root ref={ref} className={cn("relative overflow-hidden", className)} {...props}> |
| 11 | <ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]"> |
| 12 | {children} |
| 13 | </ScrollAreaPrimitive.Viewport> |
| 14 | <ScrollBar /> |
| 15 | <ScrollAreaPrimitive.Corner /> |
| 16 | </ScrollAreaPrimitive.Root> |
| 17 | )); |
| 18 | ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName; |
| gio | 5f2f100 | 2025-03-20 18:38:48 +0400 | [diff] [blame] | 19 | |
| 20 | const ScrollBar = React.forwardRef< |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 21 | React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>, |
| 22 | React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar> |
| gio | 5f2f100 | 2025-03-20 18:38:48 +0400 | [diff] [blame] | 23 | >(({ className, orientation = "vertical", ...props }, ref) => ( |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 24 | <ScrollAreaPrimitive.ScrollAreaScrollbar |
| 25 | ref={ref} |
| 26 | orientation={orientation} |
| 27 | className={cn( |
| 28 | "flex touch-none select-none transition-colors", |
| 29 | orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]", |
| 30 | orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]", |
| 31 | className, |
| 32 | )} |
| 33 | {...props} |
| 34 | > |
| 35 | <ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" /> |
| 36 | </ScrollAreaPrimitive.ScrollAreaScrollbar> |
| 37 | )); |
| 38 | ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName; |
| gio | 5f2f100 | 2025-03-20 18:38:48 +0400 | [diff] [blame] | 39 | |
| gio | d002661 | 2025-05-08 13:00:36 +0000 | [diff] [blame] | 40 | export { ScrollArea, ScrollBar }; |