mui2-file-dropzone
Version:
A Material-UI file-upload dropzone. Written in TypeScript.
51 lines • 1.93 kB
TypeScript
import React, { PureComponent } from "react";
import type { FileObject } from "../types";
import { DropzoneAreaBaseProps } from "./DropzoneAreaBase";
export type DropzoneAreaProps = Omit<DropzoneAreaBaseProps, "fileObjects" | "onAdd" | "onDelete"> & {
/** Clear uploaded files when component is unmounted. */
clearOnUnmount?: boolean;
/** List containing File objects or URL strings.
*
* **Note:** Please take care of CORS.
*/
initialFiles?: (File | string)[];
/**
* Fired when the files inside dropzone change.
*
* @param {File[]} loadedFiles All the files currently loaded into the dropzone.
*/
onChange?: (loadedFiles: File[]) => void;
/**
* Fired when a file is deleted from the previews panel.
*
* @param {File} deletedFile The file that was removed.
*/
onDelete?: (deletedFile: File) => void;
};
interface DropzoneAreaState {
fileObjects: FileObject[];
}
/**
* This components creates an uncontrolled Material-UI Dropzone, with previews and snackbar notifications.
*
* It supports all props of `DropzoneAreaBase` but keeps the files state internally.
*
* **Note** To listen to file changes use `onChange` event handler and notice that `onDelete` returns a `File` instance instead of `FileObject`.
*/
declare class DropzoneArea extends PureComponent<DropzoneAreaProps, DropzoneAreaState> {
static propTypes: any;
static defaultProps: {
clearOnUnmount: boolean;
initialFiles: NonNullable<DropzoneAreaProps["initialFiles"]>;
};
state: DropzoneAreaState;
componentDidMount(): void;
componentWillUnmount(): void;
notifyFileChange: () => void;
loadInitialFiles: () => Promise<void>;
addFiles: DropzoneAreaBaseProps["onAdd"];
deleteFile: DropzoneAreaBaseProps["onDelete"];
render(): React.JSX.Element;
}
export default DropzoneArea;
//# sourceMappingURL=DropzoneArea.d.ts.map