'use client' import { Drawer as DrawerPrimitive } from '@base-ui/react' import * as React from 'react' import { Button } from '@/components/ui/button' 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 DrawerPortal = ({ ...props }: DrawerPrimitive.Portal.Props) => ( ) const DrawerClose = ({ ...props }: DrawerPrimitive.Close.Props) => ( ) /** Styled close control — uses a render callback so prod bundles never hit base-ui's element `render` prop. */ const DrawerCloseButton = ({ className, children, onClick, ...props }: React.ComponentProps) => ( (