| 1 | import { GripVertical } from "lucide-react"; |
| 2 | import * as ResizablePrimitive from "react-resizable-panels"; |
| 3 | |
| 4 | import { cn } from "@/lib/utils"; |
| 5 | |
| 6 | const ResizablePanelGroup = ({ className, ...props }: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => ( |
| 7 | <ResizablePrimitive.PanelGroup |
| 8 | className={cn("flex h-full w-full data-[panel-group-direction=vertical]:flex-col", className)} |
| 9 | {...props} |
| 10 | /> |
| 11 | ); |
| 12 | |
| 13 | const ResizablePanel = ResizablePrimitive.Panel; |
| 14 | |
| 15 | const ResizableHandle = ({ |
| 16 | withHandle, |
| 17 | className, |
| 18 | ...props |
| 19 | }: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & { |
| 20 | withHandle?: boolean; |
| 21 | }) => ( |
| 22 | <ResizablePrimitive.PanelResizeHandle |
| 23 | className={cn( |
| 24 | "relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 [&[data-panel-group-direction=vertical]>div]:rotate-90", |
| 25 | className, |
| 26 | )} |
| 27 | {...props} |
| 28 | > |
| 29 | {withHandle && ( |
| 30 | <div className="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border"> |
| 31 | <GripVertical className="h-2.5 w-2.5" /> |
| 32 | </div> |
| 33 | )} |
| 34 | </ResizablePrimitive.PanelResizeHandle> |
| 35 | ); |
| 36 | |
| 37 | export { ResizablePanelGroup, ResizablePanel, ResizableHandle }; |