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