"use client"; import * as React from "react"; import { cn } from "../../lib/utils"; interface ScrollAreaProps extends React.HTMLAttributes { /** Reference to the viewport element */ viewportRef?: React.RefObject; /** Maximum height of the scroll area */ maxHeight?: string | number; /** Whether to show scrollbars */ showScrollbars?: boolean; /** Whether to allow scrolling */ scrollable?: boolean; /** The orientation of the scroll area */ orientation?: "vertical" | "horizontal" | "both"; /** Whether to smooth scroll */ smooth?: boolean; /** Theme for the scrollbar */ theme?: "default" | "minimal" | "none"; } const ScrollArea = React.forwardRef( ({ className, children, viewportRef, maxHeight, showScrollbars = true, scrollable = true, orientation = "vertical", smooth = false, theme = "default", ...props }, ref) => { const internalRef = React.useRef(null); const resolvedRef = viewportRef || internalRef; const style: React.CSSProperties = { maxHeight: maxHeight !== undefined ? (typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight) : undefined, ...props.style }; // Orientation scroll classes const orientationClasses = { vertical: "overflow-y-auto overflow-x-hidden", horizontal: "overflow-x-auto overflow-y-hidden", both: "overflow-auto" }; // Theme classes const themeClasses = { default: "themed-scrollbar", minimal: "minimal-scrollbar", none: "scrollbar-none" }; return (
{children}
); } ); ScrollArea.displayName = "ScrollArea"; interface ScrollBarProps extends React.HTMLAttributes { /** The orientation of the scrollbar */ orientation?: "vertical" | "horizontal"; /** Size of the scrollbar */ size?: "thin" | "default" | "thick"; /** Whether the scrollbar is visible */ visible?: boolean; } const ScrollBar = React.forwardRef( ({ className, orientation = "vertical", size = "default", visible = false, ...props }, ref) => { // Size classes const sizeClasses = { thin: orientation === "vertical" ? "w-1" : "h-1", default: orientation === "vertical" ? "w-1.5" : "h-1.5", thick: orientation === "vertical" ? "w-2" : "h-2" }; return (
); } ); ScrollBar.displayName = "ScrollBar"; export { ScrollArea, ScrollBar };