import * as React from "react"; import { cn } from "@/lib/utils"; const SheetContext = React.createContext<{ open: boolean; setOpen: (o: boolean) => void }>({ open: false, setOpen: () => {} }); export function Sheet({ open: controlled, onOpenChange, children }: { open?: boolean; onOpenChange?: (o: boolean) => void; children?: React.ReactNode }) { const [internal, setInternal] = React.useState(false); const open = controlled ?? internal; const setOpen = (o: boolean) => { setInternal(o); onOpenChange?.(o); }; return {children}; } export function SheetTrigger({ asChild, children, ...props }: React.ButtonHTMLAttributes & { asChild?: boolean }) { const ctx = React.useContext(SheetContext); if (asChild && React.isValidElement(children)) { return React.cloneElement(children as React.ReactElement, { onClick: () => ctx.setOpen(true) }); } return ; } export function SheetContent({ side = "right", className, children, ...props }: React.HTMLAttributes & { side?: "left" | "right" | "top" | "bottom" }) { const ctx = React.useContext(SheetContext); if (!ctx.open) return null; const pos = side === "left" ? "left-0 top-0 h-full w-72" : side === "right" ? "right-0 top-0 h-full w-72" : side === "top" ? "top-0 left-0 w-full" : "bottom-0 left-0 w-full"; return (
ctx.setOpen(false)} />
{children}
); } export function SheetHeader({ className, ...props }: React.HTMLAttributes) { return
; } export function SheetTitle({ className, ...props }: React.HTMLAttributes) { return

; } export function SheetDescription({ className, ...props }: React.HTMLAttributes) { return

; } export function SheetClose({ children, ...props }: React.ButtonHTMLAttributes) { const ctx = React.useContext(SheetContext); return ; } export default Sheet;