@@ -9,18 +9,27 @@ import type { StateRef } from '../useRefState/useRefState';
99import { useRefState } from '../useRefState/useRefState' ;
1010
1111type DragEventType = 'drop' | 'enter' | 'leave' | 'over' ;
12+ type DataTypes = ( ( types : string [ ] ) => boolean ) | string [ ] ;
1213
1314export interface UseDropZoneOptions {
14- dataTypes ?: ( ( types : string [ ] ) => boolean ) | string [ ] ;
15+ /** The data types for drop zone */
16+ dataTypes ?: DataTypes ;
17+ /** The multiple mode for drop zone */
1518 multiple ?: boolean ;
19+ /** The on drop callback */
1620 onDrop ?: ( files : File [ ] | null , event : DragEvent ) => void ;
21+ /** The on enter callback */
1722 onEnter ?: ( files : File [ ] | null , event : DragEvent ) => void ;
23+ /** The on leave callback */
1824 onLeave ?: ( files : File [ ] | null , event : DragEvent ) => void ;
25+ /** The on over callback */
1926 onOver ?: ( files : File [ ] | null , event : DragEvent ) => void ;
2027}
2128
22- interface UseDropZoneReturn {
29+ export interface UseDropZoneReturn {
30+ /** The files that was dropped in drop zone */
2331 files : File [ ] | null ;
32+ /** The boolean flag that indicate when drop zone is over */
2433 isOver : boolean ;
2534}
2635
@@ -52,12 +61,46 @@ export interface UseDropZone {
5261 * @description - Hook that provides drop zone functionality
5362 * @category Elements
5463 *
64+ * @overload
65+ * @template Target The target element
66+ * @param {Target } target The target element drop zone's
67+ * @param {DataTypes } [options.dataTypes] The data types
68+ * @param {boolean } [options.multiple] The multiple mode
69+ * @param {(files: File[] | null, event: DragEvent) => void } [options.onDrop] The on drop callback function
70+ * @param {(files: File[] | null, event: DragEvent) => void } [options.onEnter] The on enter callback function
71+ * @param {(files: File[] | null, event: DragEvent) => void } [options.onLeave] The on leave callback function
72+ * @param {(files: File[] | null, event: DragEvent) => void } [options.onOver] The on over callback function
73+ * @returns {[boolean, File[] | null] } The object with drop zone states
5574 *
5675 * @example
57- * const {ref, isOver} = useDropZone({onDrop})
76+ * const {isOver, files} = useDropZone(ref, options);
77+ *
78+ * @overload
79+ * @param {Target } target The target element drop zone's
80+ * @param {(files: File[] | null, event: DragEvent) => void } [callback] The callback function to be invoked on drop
81+ * @returns {[boolean, File[] | null] } The object with drop zone states
82+ *
83+ * @example
84+ * const {isOver, files} = useDropZone(ref, () => console.log('callback'));
85+ *
86+ * @overload
87+ * @param {DataTypes } [options.dataTypes] The data types
88+ * @param {boolean } [options.multiple] The multiple mode
89+ * @param {(files: File[] | null, event: DragEvent) => void } [options.onDrop] The on drop callback function
90+ * @param {(files: File[] | null, event: DragEvent) => void } [options.onEnter] The on enter callback function
91+ * @param {(files: File[] | null, event: DragEvent) => void } [options.onLeave] The on leave callback function
92+ * @param {(files: File[] | null, event: DragEvent) => void } [options.onOver] The on over callback function
93+ * @returns {[StateRef<Target>, boolean, File[] | null] } The object with drop zone states and ref
94+ *
95+ * @example
96+ * const { ref, isOver, files } = useDropZone(options);
97+ *
98+ * @overload
99+ * @param {(files: File[] | null, event: DragEvent) => void } [callback] The callback function to be invoked on drop
100+ * @returns {[StateRef<Target>, boolean, File[] | null] } The object with drop zone states and ref
58101 *
59102 * @example
60- * const { isOver } = useDropZone(ref, {onDrop} );
103+ * const { ref, isOver, files } = useDropZone(() => console.log('callback') );
61104 */
62105
63106export const useDropZone = ( ( ...params : any [ ] ) => {
0 commit comments