'use client' import * as React from 'react' import { Drawer as DrawerPrimitive } from '@base-ui/react/drawer' import { cn } from '@/lib/utils' type DrawerContextProps = { hasSnapPoints: boolean modal: DrawerPrimitive.Root.Props['modal'] showSwipeHandle: boolean swipeDirection: NonNullable } type DrawerProps = DrawerPrimitive.Root.Props & { showSwipeHandle?: boolean } const DrawerContext = React.createContext(null) const useDrawer = () => { const context = React.useContext(DrawerContext) if (!context) { throw new Error('useDrawer must be used within a Drawer.') } return context } const Drawer = ({ modal = true, showSwipeHandle = false, snapPoints, swipeDirection = 'down', ...props }: DrawerProps) => { const hasSnapPoints = snapPoints != null && snapPoints.length > 0 const contextValue = React.useMemo( () => ({ hasSnapPoints, modal, showSwipeHandle, swipeDirection }), [hasSnapPoints, modal, showSwipeHandle, swipeDirection], ) return ( ) } const DrawerTrigger = ({ ...props }: DrawerPrimitive.Trigger.Props) => ( ) const DrawerPortal = ({ ...props }: DrawerPrimitive.Portal.Props) => ( ) const DrawerClose = ({ ...props }: DrawerPrimitive.Close.Props) => ( ) const DrawerOverlay = ({ className, ...props }: DrawerPrimitive.Backdrop.Props) => ( ) const DrawerSwipeHandle = ({ className, ...props }: React.ComponentProps<'div'>) => (