react-dropzone 11.7.0 → 12.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +1 -3
- package/README.md +6 -1
- package/commitlint.config.js +1 -1
- package/dist/es/index.js +55 -43
- package/dist/es/utils/index.js +22 -22
- package/dist/index.js +3 -3
- package/examples/accept/README.md +10 -3
- package/examples/no-jsx/README.md +32 -0
- package/package.json +7 -6
- package/rollup.config.js +20 -20
- package/src/.eslintrc +1 -2
- package/src/index.js +330 -277
- package/src/index.spec.js +1784 -1498
- package/src/utils/index.js +100 -73
- package/src/utils/index.spec.js +386 -289
- package/styleguide.config.js +57 -50
- package/testSetup.js +7 -1
- package/typings/.eslintrc +1 -1
- package/typings/react-dropzone.d.ts +25 -14
- package/typings/tests/accept.tsx +10 -9
- package/typings/tests/all.tsx +7 -5
- package/typings/tests/basic.tsx +8 -7
- package/typings/tests/events.tsx +8 -6
- package/typings/tests/file-dialog.tsx +4 -3
- package/typings/tests/hook.tsx +6 -6
- package/typings/tests/plugin.tsx +11 -22
- package/typings/tests/refs.tsx +4 -4
package/styleguide.config.js
CHANGED
|
@@ -1,92 +1,99 @@
|
|
|
1
1
|
/* eslint import/no-extraneous-dependencies: 0 */
|
|
2
|
-
const path = require(
|
|
3
|
-
const { createConfig, babel, css, devServer } = require(
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const { createConfig, babel, css, devServer } = require("webpack-blocks");
|
|
4
4
|
|
|
5
5
|
// https://react-styleguidist.js.org/docs/configuration.html
|
|
6
6
|
module.exports = {
|
|
7
|
-
title:
|
|
8
|
-
styleguideDir: path.join(__dirname,
|
|
7
|
+
title: "react-dropzone",
|
|
8
|
+
styleguideDir: path.join(__dirname, "styleguide"),
|
|
9
9
|
template: {
|
|
10
|
-
favicon:
|
|
10
|
+
favicon:
|
|
11
|
+
"https://github.com/react-dropzone/react-dropzone/raw/master/logo/logo.png",
|
|
11
12
|
},
|
|
12
|
-
webpackConfig: createConfig([
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
webpackConfig: createConfig([
|
|
14
|
+
babel(),
|
|
15
|
+
css(),
|
|
16
|
+
devServer({
|
|
17
|
+
disableHostCheck: true,
|
|
18
|
+
host: "0.0.0.0",
|
|
19
|
+
}),
|
|
20
|
+
]),
|
|
21
|
+
exampleMode: "expand",
|
|
22
|
+
usageMode: "expand",
|
|
18
23
|
showSidebar: true,
|
|
19
24
|
serverPort: 8080,
|
|
20
25
|
moduleAliases: {
|
|
21
|
-
|
|
26
|
+
"react-dropzone": path.resolve(__dirname, "./src"),
|
|
22
27
|
},
|
|
23
|
-
require: [
|
|
24
|
-
path.join(__dirname, 'examples/theme.css'),
|
|
25
|
-
],
|
|
28
|
+
require: [path.join(__dirname, "examples/theme.css")],
|
|
26
29
|
sections: [
|
|
27
30
|
{
|
|
28
|
-
name:
|
|
29
|
-
content:
|
|
31
|
+
name: "",
|
|
32
|
+
content: "README.md",
|
|
30
33
|
},
|
|
31
34
|
// TODO: Figure out how to document the hook
|
|
32
35
|
// See https://github.com/reactjs/react-docgen/issues/332
|
|
33
36
|
{
|
|
34
|
-
name:
|
|
35
|
-
components:
|
|
37
|
+
name: "Components",
|
|
38
|
+
components: "./src/index.js",
|
|
36
39
|
},
|
|
37
40
|
{
|
|
38
|
-
name:
|
|
41
|
+
name: "Examples",
|
|
39
42
|
sections: [
|
|
40
43
|
{
|
|
41
|
-
name:
|
|
42
|
-
content:
|
|
44
|
+
name: "Basic example",
|
|
45
|
+
content: "examples/basic/README.md",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "Event Propagation",
|
|
49
|
+
content: "examples/events/README.md",
|
|
43
50
|
},
|
|
44
51
|
{
|
|
45
|
-
name:
|
|
46
|
-
content:
|
|
52
|
+
name: "Styling Dropzone",
|
|
53
|
+
content: "examples/styling/README.md",
|
|
47
54
|
},
|
|
48
55
|
{
|
|
49
|
-
name:
|
|
50
|
-
content:
|
|
56
|
+
name: "Accepting specific file types",
|
|
57
|
+
content: "examples/accept/README.md",
|
|
51
58
|
},
|
|
52
59
|
{
|
|
53
|
-
name:
|
|
54
|
-
content:
|
|
60
|
+
name: "Accepting specific number of files",
|
|
61
|
+
content: "examples/maxFiles/README.md",
|
|
55
62
|
},
|
|
56
63
|
{
|
|
57
|
-
name:
|
|
58
|
-
content:
|
|
64
|
+
name: "Custom validation",
|
|
65
|
+
content: "examples/validator/README.md",
|
|
59
66
|
},
|
|
60
67
|
{
|
|
61
|
-
name:
|
|
62
|
-
content:
|
|
68
|
+
name: "Opening File Dialog Programmatically",
|
|
69
|
+
content: "examples/file-dialog/README.md",
|
|
63
70
|
},
|
|
64
71
|
{
|
|
65
|
-
name:
|
|
66
|
-
content:
|
|
72
|
+
name: "Previews",
|
|
73
|
+
content: "examples/previews/README.md",
|
|
67
74
|
},
|
|
68
75
|
{
|
|
69
|
-
name:
|
|
70
|
-
content:
|
|
76
|
+
name: "Class Components",
|
|
77
|
+
content: "examples/class-component/README.md",
|
|
71
78
|
},
|
|
72
79
|
{
|
|
73
|
-
name:
|
|
74
|
-
content:
|
|
80
|
+
name: "No JSX",
|
|
81
|
+
content: "examples/no-jsx/README.md",
|
|
75
82
|
},
|
|
76
83
|
{
|
|
77
|
-
name:
|
|
78
|
-
content:
|
|
79
|
-
}
|
|
80
|
-
]
|
|
84
|
+
name: "Extending Dropzone",
|
|
85
|
+
content: "examples/plugins/README.md",
|
|
86
|
+
},
|
|
87
|
+
],
|
|
81
88
|
},
|
|
82
89
|
{
|
|
83
|
-
name:
|
|
90
|
+
name: "Integrations",
|
|
84
91
|
sections: [
|
|
85
92
|
{
|
|
86
|
-
name:
|
|
87
|
-
content:
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
+
name: "Pintura",
|
|
94
|
+
content: "examples/pintura/README.md",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
};
|
package/testSetup.js
CHANGED
package/typings/.eslintrc
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
export { FileWithPath } from "file-selector";
|
|
4
|
-
export default function Dropzone(
|
|
4
|
+
export default function Dropzone(
|
|
5
|
+
props: DropzoneProps & React.RefAttributes<DropzoneRef>
|
|
6
|
+
): JSX.Element;
|
|
5
7
|
export function useDropzone(options?: DropzoneOptions): DropzoneState;
|
|
6
8
|
|
|
7
9
|
export interface DropzoneProps extends DropzoneOptions {
|
|
@@ -9,10 +11,10 @@ export interface DropzoneProps extends DropzoneOptions {
|
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export enum ErrorCode {
|
|
12
|
-
FileInvalidType =
|
|
13
|
-
FileTooLarge =
|
|
14
|
-
FileTooSmall =
|
|
15
|
-
TooManyFiles =
|
|
14
|
+
FileInvalidType = "file-invalid-type",
|
|
15
|
+
FileTooLarge = "file-too-large",
|
|
16
|
+
FileTooSmall = "file-too-small",
|
|
17
|
+
TooManyFiles = "too-many-files",
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export interface FileError {
|
|
@@ -36,16 +38,27 @@ export type DropzoneOptions = Pick<React.HTMLProps<HTMLElement>, PropTypes> & {
|
|
|
36
38
|
noDrag?: boolean;
|
|
37
39
|
noDragEventsBubbling?: boolean;
|
|
38
40
|
disabled?: boolean;
|
|
39
|
-
onDrop?: <T extends File>(
|
|
41
|
+
onDrop?: <T extends File>(
|
|
42
|
+
acceptedFiles: T[],
|
|
43
|
+
fileRejections: FileRejection[],
|
|
44
|
+
event: DropEvent
|
|
45
|
+
) => void;
|
|
40
46
|
onDropAccepted?: <T extends File>(files: T[], event: DropEvent) => void;
|
|
41
47
|
onDropRejected?: (fileRejections: FileRejection[], event: DropEvent) => void;
|
|
42
|
-
getFilesFromEvent?: (
|
|
48
|
+
getFilesFromEvent?: (
|
|
49
|
+
event: DropEvent
|
|
50
|
+
) => Promise<Array<File | DataTransferItem>>;
|
|
43
51
|
onFileDialogCancel?: () => void;
|
|
44
|
-
onFileDialogOpen?: ()=> void;
|
|
52
|
+
onFileDialogOpen?: () => void;
|
|
45
53
|
validator?: <T extends File>(file: T) => FileError | FileError[] | null;
|
|
54
|
+
useFsAccessApi?: boolean;
|
|
46
55
|
};
|
|
47
56
|
|
|
48
|
-
export type DropEvent =
|
|
57
|
+
export type DropEvent =
|
|
58
|
+
| React.DragEvent<HTMLElement>
|
|
59
|
+
| React.ChangeEvent<HTMLInputElement>
|
|
60
|
+
| DragEvent
|
|
61
|
+
| Event;
|
|
49
62
|
|
|
50
63
|
export type DropzoneState = DropzoneRef & {
|
|
51
64
|
isFocused: boolean;
|
|
@@ -71,11 +84,9 @@ export interface DropzoneRootProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
71
84
|
[key: string]: any;
|
|
72
85
|
}
|
|
73
86
|
|
|
74
|
-
export interface DropzoneInputProps
|
|
87
|
+
export interface DropzoneInputProps
|
|
88
|
+
extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
75
89
|
refKey?: string;
|
|
76
90
|
}
|
|
77
91
|
|
|
78
|
-
type PropTypes = "multiple"
|
|
79
|
-
| "onDragEnter"
|
|
80
|
-
| "onDragOver"
|
|
81
|
-
| "onDragLeave";
|
|
92
|
+
type PropTypes = "multiple" | "onDragEnter" | "onDragOver" | "onDragLeave";
|
package/typings/tests/accept.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import Dropzone from "../../";
|
|
|
4
4
|
export default class Accept extends React.Component {
|
|
5
5
|
state = {
|
|
6
6
|
accepted: [],
|
|
7
|
-
rejected: []
|
|
7
|
+
rejected: [],
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
render() {
|
|
@@ -17,10 +17,11 @@ export default class Accept extends React.Component {
|
|
|
17
17
|
this.setState({ accepted, rejected });
|
|
18
18
|
}}
|
|
19
19
|
>
|
|
20
|
-
{({getRootProps}) => (
|
|
20
|
+
{({ getRootProps }) => (
|
|
21
21
|
<div {...getRootProps()}>
|
|
22
22
|
<p>
|
|
23
|
-
Try dropping some files here, or click to select files to
|
|
23
|
+
Try dropping some files here, or click to select files to
|
|
24
|
+
upload.
|
|
24
25
|
</p>
|
|
25
26
|
<p>Only *.jpeg and *.png images will be accepted</p>
|
|
26
27
|
</div>
|
|
@@ -30,7 +31,7 @@ export default class Accept extends React.Component {
|
|
|
30
31
|
<aside>
|
|
31
32
|
<h2>Accepted files</h2>
|
|
32
33
|
<ul>
|
|
33
|
-
{this.state.accepted.map(f => (
|
|
34
|
+
{this.state.accepted.map((f) => (
|
|
34
35
|
<li key={f.name}>
|
|
35
36
|
{f.name} - {f.size} bytes
|
|
36
37
|
</li>
|
|
@@ -38,7 +39,7 @@ export default class Accept extends React.Component {
|
|
|
38
39
|
</ul>
|
|
39
40
|
<h2>Rejected files</h2>
|
|
40
41
|
<ul>
|
|
41
|
-
{this.state.rejected.map(f => (
|
|
42
|
+
{this.state.rejected.map((f) => (
|
|
42
43
|
<li key={f.name}>
|
|
43
44
|
{f.name} - {f.size} bytes
|
|
44
45
|
</li>
|
|
@@ -52,7 +53,7 @@ export default class Accept extends React.Component {
|
|
|
52
53
|
|
|
53
54
|
export const acceptExt = (
|
|
54
55
|
<Dropzone accept=".jpeg,.png">
|
|
55
|
-
{({getRootProps, isDragActive, isDragAccept, isDragReject}) => (
|
|
56
|
+
{({ getRootProps, isDragActive, isDragAccept, isDragReject }) => (
|
|
56
57
|
<div {...getRootProps()}>
|
|
57
58
|
{isDragAccept && "All files will be accepted"}
|
|
58
59
|
{isDragReject && "Some files will be rejected"}
|
|
@@ -64,7 +65,7 @@ export const acceptExt = (
|
|
|
64
65
|
|
|
65
66
|
export const acceptMime = (
|
|
66
67
|
<Dropzone accept="image/jpeg, image/png">
|
|
67
|
-
{({getRootProps, isDragActive, isDragAccept, isDragReject}) => (
|
|
68
|
+
{({ getRootProps, isDragActive, isDragAccept, isDragReject }) => (
|
|
68
69
|
<div {...getRootProps()}>
|
|
69
70
|
{isDragAccept && "All files will be accepted"}
|
|
70
71
|
{isDragReject && "Some files will be rejected"}
|
|
@@ -75,8 +76,8 @@ export const acceptMime = (
|
|
|
75
76
|
);
|
|
76
77
|
|
|
77
78
|
export const acceptArray = (
|
|
78
|
-
<Dropzone accept={[
|
|
79
|
-
{({getRootProps, isDragActive, isDragAccept, isDragReject}) => (
|
|
79
|
+
<Dropzone accept={["image/jpeg", "image/png"]}>
|
|
80
|
+
{({ getRootProps, isDragActive, isDragAccept, isDragReject }) => (
|
|
80
81
|
<div {...getRootProps()}>
|
|
81
82
|
{isDragAccept && "All files will be accepted"}
|
|
82
83
|
{isDragReject && "Some files will be rejected"}
|
package/typings/tests/all.tsx
CHANGED
|
@@ -7,10 +7,11 @@ export default class Test extends React.Component {
|
|
|
7
7
|
<div>
|
|
8
8
|
<Dropzone
|
|
9
9
|
onDrop={(acceptedFiles, fileRejections, event) =>
|
|
10
|
-
console.log(acceptedFiles, fileRejections, event)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
console.log(acceptedFiles, fileRejections, event)
|
|
11
|
+
}
|
|
12
|
+
onDragEnter={(event) => console.log(event)}
|
|
13
|
+
onDragOver={(event) => console.log(event)}
|
|
14
|
+
onDragLeave={(event) => console.log(event)}
|
|
14
15
|
onDropAccepted={(files, event) => console.log(files, event)}
|
|
15
16
|
onDropRejected={(files, event) => console.log(files, event)}
|
|
16
17
|
onFileDialogCancel={() => console.log("onFileDialogCancel invoked")}
|
|
@@ -25,8 +26,9 @@ export default class Test extends React.Component {
|
|
|
25
26
|
disabled
|
|
26
27
|
multiple={false}
|
|
27
28
|
accept="*.png"
|
|
29
|
+
useFsAccessApi={false}
|
|
28
30
|
>
|
|
29
|
-
{({getRootProps, getInputProps}) => (
|
|
31
|
+
{({ getRootProps, getInputProps }) => (
|
|
30
32
|
<div {...getRootProps()}>
|
|
31
33
|
<input {...getInputProps()} />
|
|
32
34
|
</div>
|
package/typings/tests/basic.tsx
CHANGED
|
@@ -7,20 +7,21 @@ export default class Basic extends React.Component {
|
|
|
7
7
|
|
|
8
8
|
onDrop = (files: FileWithPath[]) => {
|
|
9
9
|
this.setState({
|
|
10
|
-
files
|
|
10
|
+
files,
|
|
11
11
|
});
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
13
|
|
|
14
14
|
render() {
|
|
15
15
|
return (
|
|
16
16
|
<section>
|
|
17
17
|
<div className="dropzone">
|
|
18
18
|
<Dropzone onDrop={this.onDrop}>
|
|
19
|
-
{({getRootProps, getInputProps}) => (
|
|
19
|
+
{({ getRootProps, getInputProps }) => (
|
|
20
20
|
<div {...getRootProps()}>
|
|
21
21
|
<input {...getInputProps()} />
|
|
22
22
|
<p>
|
|
23
|
-
Try dropping some files here, or click to select files to
|
|
23
|
+
Try dropping some files here, or click to select files to
|
|
24
|
+
upload.
|
|
24
25
|
</p>
|
|
25
26
|
</div>
|
|
26
27
|
)}
|
|
@@ -29,7 +30,7 @@ export default class Basic extends React.Component {
|
|
|
29
30
|
<aside>
|
|
30
31
|
<h2>Dropped files</h2>
|
|
31
32
|
<ul>
|
|
32
|
-
{this.state.files.map(f => (
|
|
33
|
+
{this.state.files.map((f) => (
|
|
33
34
|
<li key={f.name}>
|
|
34
35
|
{f.name} - {f.size} bytes
|
|
35
36
|
</li>
|
|
@@ -43,10 +44,10 @@ export default class Basic extends React.Component {
|
|
|
43
44
|
|
|
44
45
|
export const optional = (
|
|
45
46
|
<Dropzone>
|
|
46
|
-
{({getRootProps, getInputProps}) => (
|
|
47
|
+
{({ getRootProps, getInputProps }) => (
|
|
47
48
|
<div {...getRootProps()}>
|
|
48
49
|
<input {...getInputProps()} />
|
|
49
50
|
</div>
|
|
50
51
|
)}
|
|
51
52
|
</Dropzone>
|
|
52
|
-
)
|
|
53
|
+
);
|
package/typings/tests/events.tsx
CHANGED
|
@@ -8,16 +8,18 @@ export class Events extends React.Component {
|
|
|
8
8
|
<div className="dropzone">
|
|
9
9
|
<Dropzone
|
|
10
10
|
onDrop={(acceptedFiles, fileRejections, event) =>
|
|
11
|
-
console.log(acceptedFiles, fileRejections, event)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
console.log(acceptedFiles, fileRejections, event)
|
|
12
|
+
}
|
|
13
|
+
onDragEnter={(event) => console.log(event)}
|
|
14
|
+
onDragOver={(event) => console.log(event)}
|
|
15
|
+
onDragLeave={(event) => console.log(event)}
|
|
15
16
|
>
|
|
16
|
-
{({getRootProps, getInputProps}) => (
|
|
17
|
+
{({ getRootProps, getInputProps }) => (
|
|
17
18
|
<div {...getRootProps()}>
|
|
18
19
|
<input {...getInputProps()} />
|
|
19
20
|
<p>
|
|
20
|
-
Try dropping some files here, or click to select files to
|
|
21
|
+
Try dropping some files here, or click to select files to
|
|
22
|
+
upload.
|
|
21
23
|
</p>
|
|
22
24
|
</div>
|
|
23
25
|
)}
|
|
@@ -3,10 +3,11 @@ import Dropzone from "../../";
|
|
|
3
3
|
|
|
4
4
|
export const dropzone = (
|
|
5
5
|
<Dropzone
|
|
6
|
-
onDrop={files => console.log(files)}
|
|
6
|
+
onDrop={(files) => console.log(files)}
|
|
7
7
|
onFileDialogCancel={() => console.log("onFileDialogCancel invoked")}
|
|
8
|
-
onFileDialogOpen={() => console.log("onFileDialogOpen invoked")}
|
|
9
|
-
|
|
8
|
+
onFileDialogOpen={() => console.log("onFileDialogOpen invoked")}
|
|
9
|
+
>
|
|
10
|
+
{({ getRootProps, getInputProps, open }) => (
|
|
10
11
|
<div {...getRootProps()}>
|
|
11
12
|
<input {...getInputProps()} />
|
|
12
13
|
<p>Drop some files here.</p>
|
package/typings/tests/hook.tsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {useDropzone, DropzoneProps} from "../../";
|
|
2
|
+
import { useDropzone, DropzoneProps } from "../../";
|
|
3
3
|
|
|
4
|
-
export const Dropzone = ({children, ...opts}: DropzoneProps) => {
|
|
5
|
-
const {...state} = useDropzone(opts);
|
|
4
|
+
export const Dropzone = ({ children, ...opts }: DropzoneProps) => {
|
|
5
|
+
const { ...state } = useDropzone(opts);
|
|
6
6
|
return children(state);
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
|
|
9
9
|
<Dropzone>
|
|
10
|
-
{({getRootProps, getInputProps}) => (
|
|
10
|
+
{({ getRootProps, getInputProps }) => (
|
|
11
11
|
<div {...getRootProps()}>
|
|
12
12
|
<input {...getInputProps()} />
|
|
13
13
|
</div>
|
|
14
14
|
)}
|
|
15
|
-
</Dropzone
|
|
15
|
+
</Dropzone>;
|
package/typings/tests/plugin.tsx
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import React, {Component} from "react";
|
|
1
|
+
import React, { Component } from "react";
|
|
2
2
|
import Dropzone from "../../";
|
|
3
3
|
|
|
4
4
|
export class TestReactDragEvt extends Component {
|
|
5
5
|
getFiles = async (event: React.DragEvent<HTMLDivElement>) => {
|
|
6
6
|
const files = Array.from(event.dataTransfer.files);
|
|
7
7
|
return files;
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
|
|
10
10
|
render() {
|
|
11
11
|
return (
|
|
12
12
|
<div>
|
|
13
13
|
<Dropzone getFilesFromEvent={this.getFiles}>
|
|
14
|
-
{({getRootProps}) => (
|
|
15
|
-
<div {...getRootProps()} />
|
|
16
|
-
)}
|
|
14
|
+
{({ getRootProps }) => <div {...getRootProps()} />}
|
|
17
15
|
</Dropzone>
|
|
18
16
|
</div>
|
|
19
17
|
);
|
|
@@ -24,15 +22,13 @@ export class TestDataTransferItems extends Component {
|
|
|
24
22
|
getFiles = async (event: React.DragEvent<HTMLDivElement>) => {
|
|
25
23
|
const items = Array.from(event.dataTransfer.items);
|
|
26
24
|
return items;
|
|
27
|
-
}
|
|
25
|
+
};
|
|
28
26
|
|
|
29
27
|
render() {
|
|
30
28
|
return (
|
|
31
29
|
<div>
|
|
32
30
|
<Dropzone getFilesFromEvent={this.getFiles}>
|
|
33
|
-
{({getRootProps}) => (
|
|
34
|
-
<div {...getRootProps()} />
|
|
35
|
-
)}
|
|
31
|
+
{({ getRootProps }) => <div {...getRootProps()} />}
|
|
36
32
|
</Dropzone>
|
|
37
33
|
</div>
|
|
38
34
|
);
|
|
@@ -43,15 +39,13 @@ export class TestNativeDragEventEvt extends Component {
|
|
|
43
39
|
getFiles = async (event: DragEvent) => {
|
|
44
40
|
const files = Array.from(event.dataTransfer.files);
|
|
45
41
|
return files;
|
|
46
|
-
}
|
|
42
|
+
};
|
|
47
43
|
|
|
48
44
|
render() {
|
|
49
45
|
return (
|
|
50
46
|
<div>
|
|
51
47
|
<Dropzone getFilesFromEvent={this.getFiles}>
|
|
52
|
-
{({getRootProps}) => (
|
|
53
|
-
<div {...getRootProps()} />
|
|
54
|
-
)}
|
|
48
|
+
{({ getRootProps }) => <div {...getRootProps()} />}
|
|
55
49
|
</Dropzone>
|
|
56
50
|
</div>
|
|
57
51
|
);
|
|
@@ -62,35 +56,30 @@ export class TestChangeEvt extends Component {
|
|
|
62
56
|
getFiles = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
63
57
|
const files = Array.from(event.target.files);
|
|
64
58
|
return files;
|
|
65
|
-
}
|
|
59
|
+
};
|
|
66
60
|
|
|
67
61
|
render() {
|
|
68
62
|
return (
|
|
69
63
|
<div>
|
|
70
64
|
<Dropzone getFilesFromEvent={this.getFiles}>
|
|
71
|
-
{({getRootProps}) => (
|
|
72
|
-
<div {...getRootProps()} />
|
|
73
|
-
)}
|
|
65
|
+
{({ getRootProps }) => <div {...getRootProps()} />}
|
|
74
66
|
</Dropzone>
|
|
75
67
|
</div>
|
|
76
68
|
);
|
|
77
69
|
}
|
|
78
70
|
}
|
|
79
71
|
|
|
80
|
-
|
|
81
72
|
export class TestNativeEvt extends Component {
|
|
82
73
|
getFiles = async (event: Event) => {
|
|
83
74
|
const files = Array.from((event.target as HTMLInputElement).files);
|
|
84
75
|
return files;
|
|
85
|
-
}
|
|
76
|
+
};
|
|
86
77
|
|
|
87
78
|
render() {
|
|
88
79
|
return (
|
|
89
80
|
<div>
|
|
90
81
|
<Dropzone getFilesFromEvent={this.getFiles}>
|
|
91
|
-
{({getRootProps}) => (
|
|
92
|
-
<div {...getRootProps()} />
|
|
93
|
-
)}
|
|
82
|
+
{({ getRootProps }) => <div {...getRootProps()} />}
|
|
94
83
|
</Dropzone>
|
|
95
84
|
</div>
|
|
96
85
|
);
|
package/typings/tests/refs.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React, {createRef} from "react";
|
|
2
|
-
import Dropzone, {DropzoneRef} from "../../";
|
|
1
|
+
import React, { createRef } from "react";
|
|
2
|
+
import Dropzone, { DropzoneRef } from "../../";
|
|
3
3
|
|
|
4
|
-
const ref = createRef<DropzoneRef>()
|
|
4
|
+
const ref = createRef<DropzoneRef>();
|
|
5
5
|
|
|
6
6
|
export const dropzone = (
|
|
7
7
|
<Dropzone ref={ref}>
|
|
8
|
-
{({getRootProps, getInputProps}) => (
|
|
8
|
+
{({ getRootProps, getInputProps }) => (
|
|
9
9
|
<div {...getRootProps()}>
|
|
10
10
|
<input {...getInputProps()} />
|
|
11
11
|
<p>Drop some files here.</p>
|