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