import React, { useRef } from 'react';
import { dataHooks } from './FileUpload.constants';
const FileUpload = ({ dataHook, className, children, multiple = false, accept = '', capture, name, onChange = () => { }, }) => {
    const inputRef = useRef(null);
    const openFileUploadDialog = (event) => {
        inputRef.current?.click();
        event.preventDefault();
    };
    return (React.createElement("label", { className: className, "data-hook": dataHook },
        children({
            openFileUploadDialog,
        }),
        React.createElement("input", { type: "file", "data-hook": dataHooks.input, style: { display: 'none' }, ref: inputRef, multiple: multiple, accept: accept, capture: capture === 'none' ? undefined : capture, name: name, onChange: e => {
                onChange(e.target.files);
                // reset the input value to allow re-uploading the same file
                e.target.value = '';
            } })));
};
FileUpload.displayName = 'FileUpload';
export default FileUpload;
//# sourceMappingURL=FileUpload.js.map