import React from 'react'; import type { DrawerDirection } from './types'; interface DrawerContextValue { drawerRef: React.RefObject; overlayRef: React.RefObject; onPress: (event: React.PointerEvent) => void; onRelease: (event: React.PointerEvent | null) => void; onDrag: (event: React.PointerEvent) => void; onNestedDrag: (event: React.PointerEvent, percentageDragged: number) => void; onNestedOpenChange: (o: boolean) => void; onNestedRelease: (event: React.PointerEvent, open: boolean) => void; dismissible: boolean; isOpen: boolean; isDragging: boolean; keyboardIsOpen: React.MutableRefObject; snapPointsOffset: number[] | null; snapPoints?: (number | string)[] | null; activeSnapPointIndex?: number | null; fadeFromIndex?: number; modal: boolean; shouldFade: boolean; activeSnapPoint?: number | string | null; setActiveSnapPoint: (o: number | string | null) => void; closeDrawer: () => void; openProp?: boolean; onOpenChange?: (o: boolean) => void; direction: DrawerDirection; shouldScaleBackground: boolean; setBackgroundColorOnScale: boolean; noBodyStyles: boolean; handleOnly?: boolean; container?: HTMLElement | null; autoFocus?: boolean; shouldAnimate?: React.RefObject; onPositionChangeRef: React.RefObject<((position: number) => void) | undefined>; setContentHeight: (height: number) => void; detached: boolean; detachedOffset: number; detachedRadius: number; detachedWrapperStyle?: React.CSSProperties; } export const DrawerContext = React.createContext({ drawerRef: { current: null }, overlayRef: { current: null }, onPress: () => {}, onRelease: () => {}, onDrag: () => {}, onNestedDrag: () => {}, onNestedOpenChange: () => {}, onNestedRelease: () => {}, openProp: undefined, dismissible: false, isOpen: false, isDragging: false, keyboardIsOpen: { current: false }, snapPointsOffset: null, snapPoints: null, handleOnly: false, modal: false, shouldFade: false, activeSnapPoint: null, onOpenChange: () => {}, setActiveSnapPoint: () => {}, closeDrawer: () => {}, direction: 'bottom', shouldAnimate: { current: true }, shouldScaleBackground: false, setBackgroundColorOnScale: true, noBodyStyles: false, container: null, autoFocus: false, onPositionChangeRef: { current: undefined }, setContentHeight: () => {}, detached: false, detachedOffset: 0, detachedRadius: 0, }); export const useDrawerContext = () => { const context = React.useContext(DrawerContext); if (!context) { throw new Error('useDrawerContext must be used within a Drawer.Root'); } return context; };