"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useDnD = void 0;
const react_1 = require("react");
const useDnD = ({ isDisabled, onChange }) => {
    const [isDragActive, setDragActive] = (0, react_1.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,
    };
};
exports.useDnD = useDnD;
