diff --git a/types/react-dropzone/index.d.ts b/types/react-dropzone/index.d.ts index 3ea828f350..423ce38462 100644 --- a/types/react-dropzone/index.d.ts +++ b/types/react-dropzone/index.d.ts @@ -1,51 +1,48 @@ -// Type definitions for react-dropzone 4.1.3 +// Type definitions for react-dropzone 4.2.3 // Project: https://github.com/okonet/react-dropzone // Definitions by: Mathieu Larouche Dube , // Ivo Jesus , // Luís Rodrigues , // Ben Bayard , // Karol Janyst , -// Andris Causs +// Andris Causs , +// Juraj Husar // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.6 import { CSSProperties, Component, DragEvent, InputHTMLAttributes } from "react"; -declare namespace Dropzone { - export interface ImageFile extends File { - preview?: string; - } - - export type DropFileEventHandler = (acceptedOrRejected: ImageFile[], event: DragEvent) => void; - export type DropFilesEventHandler = (accepted: ImageFile[], rejected: ImageFile[], event: DragEvent) => void; - - type PickedAttributes = "accept" | "className" | "multiple" | "name" | "onClick" | "onDragStart" | "onDragEnter" | "onDragOver" | "onDragLeave" | "style"; - - export interface DropzoneProps extends Pick, PickedAttributes> { - disableClick?: boolean; - disabled?: boolean; - disablePreview?: boolean; - preventDropOnDocument?: boolean; - inputProps?: InputHTMLAttributes; - maxSize?: number; - minSize?: number; - activeClassName?: string; - acceptClassName?: string; - rejectClassName?: string; - disabledClassName?: string; - activeStyle?: CSSProperties; - acceptStyle?: CSSProperties; - rejectStyle?: CSSProperties; - disabledStyle?: CSSProperties; - onDrop?: DropFilesEventHandler; - onDropAccepted?: DropFileEventHandler; - onDropRejected?: DropFileEventHandler; - onFileDialogCancel?: () => void; - } +export interface ImageFile extends File { + preview?: string; } -declare class Dropzone extends Component { +export type DropFileEventHandler = (acceptedOrRejected: ImageFile[], event: DragEvent) => void; +export type DropFilesEventHandler = (accepted: ImageFile[], rejected: ImageFile[], event: DragEvent) => void; + +type PickedAttributes = "accept" | "className" | "multiple" | "name" | "onClick" | "onDragStart" | "onDragEnter" | "onDragOver" | "onDragLeave" | "style"; + +export interface DropzoneProps extends Pick, PickedAttributes> { + disableClick?: boolean; + disabled?: boolean; + disablePreview?: boolean; + preventDropOnDocument?: boolean; + inputProps?: InputHTMLAttributes; + maxSize?: number; + minSize?: number; + activeClassName?: string; + acceptClassName?: string; + rejectClassName?: string; + disabledClassName?: string; + activeStyle?: CSSProperties; + acceptStyle?: CSSProperties; + rejectStyle?: CSSProperties; + disabledStyle?: CSSProperties; + onDrop?: DropFilesEventHandler; + onDropAccepted?: DropFileEventHandler; + onDropRejected?: DropFileEventHandler; + onFileDialogCancel?: () => void; +} + +export default class Dropzone extends Component { open(): void; } - -export = Dropzone; diff --git a/types/react-dropzone/react-dropzone-tests.tsx b/types/react-dropzone/react-dropzone-tests.tsx index 8fcb16311a..67fa8eadb3 100644 --- a/types/react-dropzone/react-dropzone-tests.tsx +++ b/types/react-dropzone/react-dropzone-tests.tsx @@ -1,7 +1,6 @@ import * as React from "react"; import { DragEvent, SyntheticEvent } from "react"; -import Dropzone = require("react-dropzone"); -import { ImageFile } from "react-dropzone"; +import Dropzone, { ImageFile } from "react-dropzone"; class Test extends React.Component {