/** * React hook for drag-to-corner functionality. * * Wraps the framework-agnostic utilities from @c15t/ui with React state management. * * @packageDocumentation */ import { type CornerPosition } from '@c15t/ui/utils/trigger-utils'; /** * Options for the useDraggable hook. */ export interface UseDraggableOptions { /** * Default corner position. * @default 'bottom-right' */ defaultPosition?: CornerPosition; /** * Whether to persist position to localStorage. * @default true */ persistPosition?: boolean; /** * Callback when position changes. */ onPositionChange?: (position: CornerPosition) => void; } /** * Return type for the useDraggable hook. */ export interface UseDraggableReturn { /** Current corner position */ corner: CornerPosition; /** Whether currently dragging */ isDragging: boolean; /** Whether transitioning to a new corner (for animation) */ isSnapping: boolean; /** Whether the last interaction was a drag (moved more than threshold) */ wasDragged: () => boolean; /** Event handlers to attach to the draggable element */ handlers: { onPointerDown: (e: React.PointerEvent) => void; onPointerMove: (e: React.PointerEvent) => void; onPointerUp: (e: React.PointerEvent) => void; onPointerCancel: (e: React.PointerEvent) => void; }; /** Current transform style for drag offset */ dragStyle: React.CSSProperties; } /** * Hook for making an element draggable between viewport corners. * * @param options - Configuration options * @returns Object with corner position, drag state, event handlers, and styles * * @example * ```tsx * function DraggableButton() { * const { corner, isDragging, handlers, dragStyle } = useDraggable({ * defaultPosition: 'bottom-right', * persistPosition: true, * }); * * return ( * * ); * } * ``` */ export declare function useDraggable(options?: UseDraggableOptions): UseDraggableReturn;