Skip to content

Commit 14e6b67

Browse files
Roland Grozarolandjitsu
authored andcommitted
fix: fix types for getDataTransferItems()
1 parent 4578f1b commit 14e6b67

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

typings/react-dropzone.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export type DropzoneProps = Omit<React.HTMLProps<HTMLDivElement>, "onDrop" | "re
4848
onDropAccepted?: DropFileEventHandler;
4949
onDropRejected?: DropFileEventHandler;
5050
onFileDialogCancel?(): void;
51-
getDataTransferItems?(event: React.DragEvent<HTMLDivElement> | DragEvent): Promise<Array<File | DataTransferItem>>;
51+
getDataTransferItems?(event: React.DragEvent<HTMLDivElement> | DragEvent | React.ChangeEvent<HTMLInputElement> | Event): Promise<Array<File | DataTransferItem>>;
5252
children?: React.ReactNode | DropzoneRenderFunction;
5353
ref?: React.Ref<Dropzone>;
5454
};

typings/tests/plugin.tsx

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {Component} from "react";
22
import Dropzone from "../../";
33

4-
export class TestReactEvt extends Component {
4+
export class TestReactDragEvt extends Component {
55
getFiles = async (evt: React.DragEvent<HTMLDivElement>) => {
66
const files = Array.from(evt.dataTransfer.files);
77
return files;
@@ -35,7 +35,7 @@ export class TestDataTransferItems extends Component {
3535
}
3636
}
3737

38-
export class TestNativeEvt extends Component {
38+
export class TestNativeDragEventEvt extends Component {
3939
getFiles = async (evt: DragEvent) => {
4040
const files = Array.from(evt.dataTransfer.files);
4141
return files;
@@ -51,3 +51,38 @@ export class TestNativeEvt extends Component {
5151
);
5252
}
5353
}
54+
55+
export class TestChangeEvt extends Component {
56+
getFiles = async (evt: React.ChangeEvent<HTMLInputElement>) => {
57+
const files = Array.from(evt.target.files);
58+
return files;
59+
}
60+
61+
render() {
62+
return (
63+
<div>
64+
<Dropzone getDataTransferItems={this.getFiles}>
65+
Hi
66+
</Dropzone>
67+
</div>
68+
);
69+
}
70+
}
71+
72+
73+
export class TestNativeEvt extends Component {
74+
getFiles = async (evt: Event) => {
75+
const files = Array.from((evt.target as HTMLInputElement).files);
76+
return files;
77+
}
78+
79+
render() {
80+
return (
81+
<div>
82+
<Dropzone getDataTransferItems={this.getFiles}>
83+
Hi
84+
</Dropzone>
85+
</div>
86+
);
87+
}
88+
}

0 commit comments

Comments
 (0)