@mirawision/reactive-hooks
Version:
A comprehensive collection of 50+ React hooks for state management, UI interactions, device APIs, async operations, drag & drop, audio/speech, and more. Full TypeScript support with SSR safety.
24 lines (23 loc) • 788 B
TypeScript
import { RefObject } from 'react';
export interface DragEventHandlers {
onDragStart?: (e: DragEvent) => void;
onDragEnd?: (e: DragEvent) => void;
onDragOver?: (e: DragEvent) => void;
onDrop?: (e: DragEvent) => void;
}
/**
* A hook that provides custom drag event handlers for an element.
* @param ref React ref object for the element
* @param handlers Object containing drag event handlers
*
* @example
* const ref = useRef(null);
* useDragEvents(ref, {
* onDragStart: (e) => console.log('Drag started'),
* onDrop: (e) => {
* const data = e.dataTransfer.getData('application/json');
* console.log('Dropped:', JSON.parse(data));
* }
* });
*/
export declare function useDragEvents(ref: RefObject<HTMLElement>, handlers: DragEventHandlers): void;