react-dropzone Updated typings for latest version

This commit is contained in:
Juraj Husar
2017-12-18 15:05:05 +01:00
parent 6d9978eb72
commit 02da1ce3f8
2 changed files with 35 additions and 39 deletions
+34 -37
View File
@@ -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 <https://github.com/matdube>,
// Ivo Jesus <https://github.com/LynxEyes>,
// Luís Rodrigues <https://github.com/goblindegook>,
// Ben Bayard <https://github.com/benbayard>,
// Karol Janyst <https://github.com/LKay>,
// Andris Causs <https://github.com/codeaid>
// Andris Causs <https://github.com/codeaid>,
// Juraj Husar <https://github.com/jurosh>
// 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<HTMLDivElement>) => void;
export type DropFilesEventHandler = (accepted: ImageFile[], rejected: ImageFile[], event: DragEvent<HTMLDivElement>) => void;
type PickedAttributes = "accept" | "className" | "multiple" | "name" | "onClick" | "onDragStart" | "onDragEnter" | "onDragOver" | "onDragLeave" | "style";
export interface DropzoneProps extends Pick<InputHTMLAttributes<HTMLDivElement>, PickedAttributes> {
disableClick?: boolean;
disabled?: boolean;
disablePreview?: boolean;
preventDropOnDocument?: boolean;
inputProps?: InputHTMLAttributes<HTMLInputElement>;
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<Dropzone.DropzoneProps> {
export type DropFileEventHandler = (acceptedOrRejected: ImageFile[], event: DragEvent<HTMLDivElement>) => void;
export type DropFilesEventHandler = (accepted: ImageFile[], rejected: ImageFile[], event: DragEvent<HTMLDivElement>) => void;
type PickedAttributes = "accept" | "className" | "multiple" | "name" | "onClick" | "onDragStart" | "onDragEnter" | "onDragOver" | "onDragLeave" | "style";
export interface DropzoneProps extends Pick<InputHTMLAttributes<HTMLDivElement>, PickedAttributes> {
disableClick?: boolean;
disabled?: boolean;
disablePreview?: boolean;
preventDropOnDocument?: boolean;
inputProps?: InputHTMLAttributes<HTMLInputElement>;
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<DropzoneProps> {
open(): void;
}
export = Dropzone;
@@ -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 {