import { useState } from 'react';
export const useDnD = ({ isDisabled, onChange }) => {
    const [isDragActive, setDragActive] = useState(false);
    const onDragLeave = (event) => {
        if (isDisabled) {
            return;
        }
        event.preventDefault();
        setDragActive(false);
    };
    const onDragOver = (event) => {
        if (isDisabled) {
            return;
        }
        event.preventDefault();
        setDragActive(true);
    };
    const onDrop = (event) => {
        if (isDisabled) {
            return;
        }
        event.preventDefault();
        const droppedFiles = event.dataTransfer.files;
        onChange(droppedFiles);
        setDragActive(false);
    };
    return {
        isDragActive,
        onDragLeave,
        onDragOver,
        onDrop,
    };
};
