react-dropzone 15.0.0 → 17.0.0
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/README.md +129 -114
- package/dist/index.cjs +685 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +117 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.js +656 -2
- package/dist/index.js.map +1 -0
- package/package.json +76 -177
- package/src/index.tsx +774 -0
- package/src/utils/index.ts +305 -0
- package/.babelrc.js +0 -28
- package/.codeclimate.yml +0 -15
- package/.editorconfig +0 -13
- package/.eslintignore +0 -3
- package/.eslintrc +0 -37
- package/.gitpod.yml +0 -6
- package/.husky/commit-msg +0 -5
- package/.husky/pre-commit +0 -5
- package/.nvmrc +0 -1
- package/.releaserc.json +0 -27
- package/CHANGELOG.md +0 -9
- package/commitlint.config.js +0 -1
- package/dist/es/index.js +0 -1051
- package/dist/es/package.json +0 -1
- package/dist/es/utils/index.js +0 -366
- package/examples/.eslintrc +0 -5
- package/examples/accept/README.md +0 -144
- package/examples/basic/README.md +0 -70
- package/examples/class-component/README.md +0 -45
- package/examples/drag-overlay/README.md +0 -132
- package/examples/events/README.md +0 -164
- package/examples/file-dialog/README.md +0 -90
- package/examples/forms/README.md +0 -69
- package/examples/maxFiles/README.md +0 -58
- package/examples/no-jsx/README.md +0 -32
- package/examples/pintura/README.md +0 -146
- package/examples/plugins/README.md +0 -55
- package/examples/previews/README.md +0 -86
- package/examples/styling/README.md +0 -126
- package/examples/theme.css +0 -37
- package/examples/validator/README.md +0 -68
- package/rollup.config.js +0 -33
- package/src/.eslintrc +0 -37
- package/src/__snapshots__/index.spec.js.snap +0 -3
- package/src/index.js +0 -1103
- package/src/index.spec.js +0 -3838
- package/src/utils/index.js +0 -362
- package/src/utils/index.spec.js +0 -625
- package/styleguide.config.js +0 -107
- package/testSetup.js +0 -8
- package/typings/.eslintrc +0 -28
- package/typings/react-dropzone.d.ts +0 -102
- package/typings/tests/accept.tsx +0 -54
- package/typings/tests/all.tsx +0 -46
- package/typings/tests/basic.tsx +0 -53
- package/typings/tests/events.tsx +0 -31
- package/typings/tests/file-dialog.tsx +0 -20
- package/typings/tests/hook.tsx +0 -15
- package/typings/tests/plugin.tsx +0 -87
- package/typings/tests/refs.tsx +0 -18
- package/typings/tests/tsconfig.json +0 -22
package/styleguide.config.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/* eslint import/no-extraneous-dependencies: 0 */
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const { createConfig, babel, css, devServer } = require("webpack-blocks");
|
|
4
|
-
|
|
5
|
-
// https://react-styleguidist.js.org/docs/configuration.html
|
|
6
|
-
module.exports = {
|
|
7
|
-
title: "react-dropzone",
|
|
8
|
-
styleguideDir: path.join(__dirname, "styleguide"),
|
|
9
|
-
template: {
|
|
10
|
-
favicon:
|
|
11
|
-
"https://github.com/react-dropzone/react-dropzone/raw/master/logo/logo.png",
|
|
12
|
-
},
|
|
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",
|
|
23
|
-
showSidebar: true,
|
|
24
|
-
serverPort: 8080,
|
|
25
|
-
moduleAliases: {
|
|
26
|
-
"react-dropzone": path.resolve(__dirname, "./src"),
|
|
27
|
-
},
|
|
28
|
-
require: [path.join(__dirname, "examples/theme.css")],
|
|
29
|
-
sections: [
|
|
30
|
-
{
|
|
31
|
-
name: "",
|
|
32
|
-
content: "README.md",
|
|
33
|
-
},
|
|
34
|
-
// TODO: Figure out how to document the hook
|
|
35
|
-
// See https://github.com/reactjs/react-docgen/issues/332
|
|
36
|
-
{
|
|
37
|
-
name: "Components",
|
|
38
|
-
components: "./src/index.js",
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: "Examples",
|
|
42
|
-
sections: [
|
|
43
|
-
{
|
|
44
|
-
name: "Basic example",
|
|
45
|
-
content: "examples/basic/README.md",
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: "Event Propagation",
|
|
49
|
-
content: "examples/events/README.md",
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: "Forms",
|
|
53
|
-
content: "examples/forms/README.md",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: "Styling Dropzone",
|
|
57
|
-
content: "examples/styling/README.md",
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: "Drag Overlay",
|
|
61
|
-
content: "examples/drag-overlay/README.md",
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: "Accepting specific file types",
|
|
65
|
-
content: "examples/accept/README.md",
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: "Accepting specific number of files",
|
|
69
|
-
content: "examples/maxFiles/README.md",
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: "Custom validation",
|
|
73
|
-
content: "examples/validator/README.md",
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: "Opening File Dialog Programmatically",
|
|
77
|
-
content: "examples/file-dialog/README.md",
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: "Previews",
|
|
81
|
-
content: "examples/previews/README.md",
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: "Class Components",
|
|
85
|
-
content: "examples/class-component/README.md",
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
name: "No JSX",
|
|
89
|
-
content: "examples/no-jsx/README.md",
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
name: "Extending Dropzone",
|
|
93
|
-
content: "examples/plugins/README.md",
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: "Integrations",
|
|
99
|
-
sections: [
|
|
100
|
-
{
|
|
101
|
-
name: "Pintura",
|
|
102
|
-
content: "examples/pintura/README.md",
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
};
|
package/testSetup.js
DELETED
package/typings/.eslintrc
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"parser": "@typescript-eslint/parser",
|
|
4
|
-
"env": {
|
|
5
|
-
"es6": true,
|
|
6
|
-
"browser": true
|
|
7
|
-
},
|
|
8
|
-
"plugins": [
|
|
9
|
-
"import",
|
|
10
|
-
"prettier",
|
|
11
|
-
"react",
|
|
12
|
-
"react-hooks",
|
|
13
|
-
"@typescript-eslint"
|
|
14
|
-
],
|
|
15
|
-
"extends": [
|
|
16
|
-
"eslint:recommended",
|
|
17
|
-
"plugin:@typescript-eslint/recommended",
|
|
18
|
-
"plugin:prettier/recommended"
|
|
19
|
-
],
|
|
20
|
-
"settings": {
|
|
21
|
-
"react": {
|
|
22
|
-
"version": "detect"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"rules": {
|
|
26
|
-
"@typescript-eslint/no-explicit-any": "off"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import { FileWithPath } from "file-selector";
|
|
4
|
-
export { FileWithPath };
|
|
5
|
-
export default function Dropzone(
|
|
6
|
-
props: DropzoneProps & React.RefAttributes<DropzoneRef>
|
|
7
|
-
): React.ReactElement;
|
|
8
|
-
export function useDropzone(options?: DropzoneOptions): DropzoneState;
|
|
9
|
-
|
|
10
|
-
export interface DropzoneProps extends DropzoneOptions {
|
|
11
|
-
children?(state: DropzoneState): React.ReactElement;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export enum ErrorCode {
|
|
15
|
-
FileInvalidType = "file-invalid-type",
|
|
16
|
-
FileTooLarge = "file-too-large",
|
|
17
|
-
FileTooSmall = "file-too-small",
|
|
18
|
-
TooManyFiles = "too-many-files",
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface FileError {
|
|
22
|
-
message: string;
|
|
23
|
-
code: ErrorCode | string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface FileRejection {
|
|
27
|
-
file: FileWithPath;
|
|
28
|
-
errors: readonly FileError[];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type DropzoneOptions = Pick<React.HTMLProps<HTMLElement>, PropTypes> & {
|
|
32
|
-
accept?: Accept;
|
|
33
|
-
minSize?: number;
|
|
34
|
-
maxSize?: number;
|
|
35
|
-
maxFiles?: number;
|
|
36
|
-
preventDropOnDocument?: boolean;
|
|
37
|
-
noClick?: boolean;
|
|
38
|
-
noKeyboard?: boolean;
|
|
39
|
-
noDrag?: boolean;
|
|
40
|
-
noDragEventsBubbling?: boolean;
|
|
41
|
-
disabled?: boolean;
|
|
42
|
-
onDrop?: <T extends File>(
|
|
43
|
-
acceptedFiles: T[],
|
|
44
|
-
fileRejections: FileRejection[],
|
|
45
|
-
event: DropEvent
|
|
46
|
-
) => void;
|
|
47
|
-
onDropAccepted?: <T extends File>(files: T[], event: DropEvent) => void;
|
|
48
|
-
onDropRejected?: (fileRejections: FileRejection[], event: DropEvent) => void;
|
|
49
|
-
getFilesFromEvent?: (
|
|
50
|
-
event: DropEvent
|
|
51
|
-
) => Promise<Array<File | DataTransferItem>>;
|
|
52
|
-
onFileDialogCancel?: () => void;
|
|
53
|
-
onFileDialogOpen?: () => void;
|
|
54
|
-
onError?: (err: Error) => void;
|
|
55
|
-
validator?: <T extends File>(
|
|
56
|
-
file: T
|
|
57
|
-
) => FileError | readonly FileError[] | null;
|
|
58
|
-
useFsAccessApi?: boolean;
|
|
59
|
-
autoFocus?: boolean;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export type DropEvent =
|
|
63
|
-
| React.DragEvent<HTMLElement>
|
|
64
|
-
| React.ChangeEvent<HTMLInputElement>
|
|
65
|
-
| DragEvent
|
|
66
|
-
| Event
|
|
67
|
-
| Array<FileSystemFileHandle>;
|
|
68
|
-
|
|
69
|
-
export type DropzoneState = DropzoneRef & {
|
|
70
|
-
isFocused: boolean;
|
|
71
|
-
isDragActive: boolean;
|
|
72
|
-
isDragAccept: boolean;
|
|
73
|
-
isDragReject: boolean;
|
|
74
|
-
isDragGlobal: boolean;
|
|
75
|
-
isFileDialogActive: boolean;
|
|
76
|
-
acceptedFiles: readonly FileWithPath[];
|
|
77
|
-
fileRejections: readonly FileRejection[];
|
|
78
|
-
rootRef: React.RefObject<HTMLElement>;
|
|
79
|
-
inputRef: React.RefObject<HTMLInputElement>;
|
|
80
|
-
getRootProps: <T extends DropzoneRootProps>(props?: T) => T;
|
|
81
|
-
getInputProps: <T extends DropzoneInputProps>(props?: T) => T;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export interface DropzoneRef {
|
|
85
|
-
open: () => void;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface DropzoneRootProps extends React.HTMLAttributes<HTMLElement> {
|
|
89
|
-
refKey?: string;
|
|
90
|
-
[key: string]: any;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface DropzoneInputProps
|
|
94
|
-
extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
95
|
-
refKey?: string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
type PropTypes = "multiple" | "onDragEnter" | "onDragOver" | "onDragLeave";
|
|
99
|
-
|
|
100
|
-
export interface Accept {
|
|
101
|
-
[key: string]: readonly string[];
|
|
102
|
-
}
|
package/typings/tests/accept.tsx
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Dropzone from "../../";
|
|
3
|
-
|
|
4
|
-
export default class Accept extends React.Component {
|
|
5
|
-
state = {
|
|
6
|
-
accepted: [],
|
|
7
|
-
rejected: [],
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
render() {
|
|
11
|
-
return (
|
|
12
|
-
<section>
|
|
13
|
-
<div className="dropzone">
|
|
14
|
-
<Dropzone
|
|
15
|
-
accept={{
|
|
16
|
-
"image/*": [".jpeg", ".png"],
|
|
17
|
-
}}
|
|
18
|
-
onDrop={(accepted, rejected) => {
|
|
19
|
-
this.setState({ accepted, rejected });
|
|
20
|
-
}}
|
|
21
|
-
>
|
|
22
|
-
{({ getRootProps }) => (
|
|
23
|
-
<div {...getRootProps()}>
|
|
24
|
-
<p>
|
|
25
|
-
Try dropping some files here, or click to select files to
|
|
26
|
-
upload.
|
|
27
|
-
</p>
|
|
28
|
-
<p>Only *.jpeg and *.png images will be accepted</p>
|
|
29
|
-
</div>
|
|
30
|
-
)}
|
|
31
|
-
</Dropzone>
|
|
32
|
-
</div>
|
|
33
|
-
<aside>
|
|
34
|
-
<h2>Accepted files</h2>
|
|
35
|
-
<ul>
|
|
36
|
-
{this.state.accepted.map((f) => (
|
|
37
|
-
<li key={f.name}>
|
|
38
|
-
{f.name} - {f.size} bytes
|
|
39
|
-
</li>
|
|
40
|
-
))}
|
|
41
|
-
</ul>
|
|
42
|
-
<h2>Rejected files</h2>
|
|
43
|
-
<ul>
|
|
44
|
-
{this.state.rejected.map((f) => (
|
|
45
|
-
<li key={f.name}>
|
|
46
|
-
{f.name} - {f.size} bytes
|
|
47
|
-
</li>
|
|
48
|
-
))}
|
|
49
|
-
</ul>
|
|
50
|
-
</aside>
|
|
51
|
-
</section>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
}
|
package/typings/tests/all.tsx
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Dropzone from "../../";
|
|
3
|
-
|
|
4
|
-
export default class Test extends React.Component {
|
|
5
|
-
render() {
|
|
6
|
-
return (
|
|
7
|
-
<div>
|
|
8
|
-
<Dropzone
|
|
9
|
-
onDrop={(acceptedFiles, fileRejections, event) =>
|
|
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)}
|
|
15
|
-
onDropAccepted={(files, event) => console.log(files, event)}
|
|
16
|
-
onDropRejected={(files, event) => console.log(files, event)}
|
|
17
|
-
onFileDialogCancel={() => console.log("onFileDialogCancel invoked")}
|
|
18
|
-
onFileDialogOpen={() => console.log("onFileDialogOpen invoked")}
|
|
19
|
-
onError={(e) => console.log(e)}
|
|
20
|
-
validator={(f) => ({ message: f.name, code: "" })}
|
|
21
|
-
minSize={2000}
|
|
22
|
-
maxSize={Infinity}
|
|
23
|
-
maxFiles={100}
|
|
24
|
-
preventDropOnDocument
|
|
25
|
-
noClick={false}
|
|
26
|
-
noKeyboard={false}
|
|
27
|
-
noDrag={false}
|
|
28
|
-
noDragEventsBubbling={false}
|
|
29
|
-
disabled
|
|
30
|
-
multiple={false}
|
|
31
|
-
accept={{
|
|
32
|
-
"image/*": [".png"],
|
|
33
|
-
}}
|
|
34
|
-
useFsAccessApi={false}
|
|
35
|
-
autoFocus
|
|
36
|
-
>
|
|
37
|
-
{({ getRootProps, getInputProps }) => (
|
|
38
|
-
<div {...getRootProps()}>
|
|
39
|
-
<input {...getInputProps()} />
|
|
40
|
-
</div>
|
|
41
|
-
)}
|
|
42
|
-
</Dropzone>
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
}
|
package/typings/tests/basic.tsx
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Dropzone from "../../";
|
|
3
|
-
import { FileWithPath } from "file-selector";
|
|
4
|
-
|
|
5
|
-
export default class Basic extends React.Component {
|
|
6
|
-
state = { files: [] };
|
|
7
|
-
|
|
8
|
-
onDrop = (files: FileWithPath[]) => {
|
|
9
|
-
this.setState({
|
|
10
|
-
files,
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
render() {
|
|
15
|
-
return (
|
|
16
|
-
<section>
|
|
17
|
-
<div className="dropzone">
|
|
18
|
-
<Dropzone onDrop={this.onDrop}>
|
|
19
|
-
{({ getRootProps, getInputProps }) => (
|
|
20
|
-
<div {...getRootProps()}>
|
|
21
|
-
<input {...getInputProps()} />
|
|
22
|
-
<p>
|
|
23
|
-
Try dropping some files here, or click to select files to
|
|
24
|
-
upload.
|
|
25
|
-
</p>
|
|
26
|
-
</div>
|
|
27
|
-
)}
|
|
28
|
-
</Dropzone>
|
|
29
|
-
</div>
|
|
30
|
-
<aside>
|
|
31
|
-
<h2>Dropped files</h2>
|
|
32
|
-
<ul>
|
|
33
|
-
{this.state.files.map((f) => (
|
|
34
|
-
<li key={f.name}>
|
|
35
|
-
{f.name} - {f.size} bytes
|
|
36
|
-
</li>
|
|
37
|
-
))}
|
|
38
|
-
</ul>
|
|
39
|
-
</aside>
|
|
40
|
-
</section>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const optional = (
|
|
46
|
-
<Dropzone>
|
|
47
|
-
{({ getRootProps, getInputProps }) => (
|
|
48
|
-
<div {...getRootProps()}>
|
|
49
|
-
<input {...getInputProps()} />
|
|
50
|
-
</div>
|
|
51
|
-
)}
|
|
52
|
-
</Dropzone>
|
|
53
|
-
);
|
package/typings/tests/events.tsx
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Dropzone from "../../";
|
|
3
|
-
|
|
4
|
-
export class Events extends React.Component {
|
|
5
|
-
render() {
|
|
6
|
-
return (
|
|
7
|
-
<section>
|
|
8
|
-
<div className="dropzone">
|
|
9
|
-
<Dropzone
|
|
10
|
-
onDrop={(acceptedFiles, fileRejections, event) =>
|
|
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)}
|
|
16
|
-
>
|
|
17
|
-
{({ getRootProps, getInputProps }) => (
|
|
18
|
-
<div {...getRootProps()}>
|
|
19
|
-
<input {...getInputProps()} />
|
|
20
|
-
<p>
|
|
21
|
-
Try dropping some files here, or click to select files to
|
|
22
|
-
upload.
|
|
23
|
-
</p>
|
|
24
|
-
</div>
|
|
25
|
-
)}
|
|
26
|
-
</Dropzone>
|
|
27
|
-
</div>
|
|
28
|
-
</section>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Dropzone from "../../";
|
|
3
|
-
|
|
4
|
-
export const dropzone = (
|
|
5
|
-
<Dropzone
|
|
6
|
-
onDrop={(files) => console.log(files)}
|
|
7
|
-
onFileDialogCancel={() => console.log("onFileDialogCancel invoked")}
|
|
8
|
-
onFileDialogOpen={() => console.log("onFileDialogOpen invoked")}
|
|
9
|
-
>
|
|
10
|
-
{({ getRootProps, getInputProps, open }) => (
|
|
11
|
-
<div {...getRootProps()}>
|
|
12
|
-
<input {...getInputProps()} />
|
|
13
|
-
<p>Drop some files here.</p>
|
|
14
|
-
<button type="button" onClick={open}>
|
|
15
|
-
Open file dialog
|
|
16
|
-
</button>
|
|
17
|
-
</div>
|
|
18
|
-
)}
|
|
19
|
-
</Dropzone>
|
|
20
|
-
);
|
package/typings/tests/hook.tsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useDropzone, DropzoneProps } from "../../";
|
|
3
|
-
|
|
4
|
-
export const Dropzone = ({ children, ...opts }: DropzoneProps) => {
|
|
5
|
-
const { ...state } = useDropzone(opts);
|
|
6
|
-
return children(state);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
<Dropzone>
|
|
10
|
-
{({ getRootProps, getInputProps }) => (
|
|
11
|
-
<div {...getRootProps()}>
|
|
12
|
-
<input {...getInputProps()} />
|
|
13
|
-
</div>
|
|
14
|
-
)}
|
|
15
|
-
</Dropzone>;
|
package/typings/tests/plugin.tsx
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import React, { Component } from "react";
|
|
2
|
-
import Dropzone from "../../";
|
|
3
|
-
|
|
4
|
-
export class TestReactDragEvt extends Component {
|
|
5
|
-
getFiles = async (event: React.DragEvent<HTMLDivElement>) => {
|
|
6
|
-
const files = Array.from(event.dataTransfer.files);
|
|
7
|
-
return files;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
render() {
|
|
11
|
-
return (
|
|
12
|
-
<div>
|
|
13
|
-
<Dropzone getFilesFromEvent={this.getFiles}>
|
|
14
|
-
{({ getRootProps }) => <div {...getRootProps()} />}
|
|
15
|
-
</Dropzone>
|
|
16
|
-
</div>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class TestDataTransferItems extends Component {
|
|
22
|
-
getFiles = async (event: React.DragEvent<HTMLDivElement>) => {
|
|
23
|
-
const items = Array.from(event.dataTransfer.items);
|
|
24
|
-
return items;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
render() {
|
|
28
|
-
return (
|
|
29
|
-
<div>
|
|
30
|
-
<Dropzone getFilesFromEvent={this.getFiles}>
|
|
31
|
-
{({ getRootProps }) => <div {...getRootProps()} />}
|
|
32
|
-
</Dropzone>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export class TestNativeDragEventEvt extends Component {
|
|
39
|
-
getFiles = async (event: DragEvent) => {
|
|
40
|
-
const files = Array.from(event.dataTransfer.files);
|
|
41
|
-
return files;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
render() {
|
|
45
|
-
return (
|
|
46
|
-
<div>
|
|
47
|
-
<Dropzone getFilesFromEvent={this.getFiles}>
|
|
48
|
-
{({ getRootProps }) => <div {...getRootProps()} />}
|
|
49
|
-
</Dropzone>
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export class TestChangeEvt extends Component {
|
|
56
|
-
getFiles = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
57
|
-
const files = Array.from(event.target.files);
|
|
58
|
-
return files;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
render() {
|
|
62
|
-
return (
|
|
63
|
-
<div>
|
|
64
|
-
<Dropzone getFilesFromEvent={this.getFiles}>
|
|
65
|
-
{({ getRootProps }) => <div {...getRootProps()} />}
|
|
66
|
-
</Dropzone>
|
|
67
|
-
</div>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export class TestNativeEvt extends Component {
|
|
73
|
-
getFiles = async (event: Event) => {
|
|
74
|
-
const files = Array.from((event.target as HTMLInputElement).files);
|
|
75
|
-
return files;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
render() {
|
|
79
|
-
return (
|
|
80
|
-
<div>
|
|
81
|
-
<Dropzone getFilesFromEvent={this.getFiles}>
|
|
82
|
-
{({ getRootProps }) => <div {...getRootProps()} />}
|
|
83
|
-
</Dropzone>
|
|
84
|
-
</div>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
}
|
package/typings/tests/refs.tsx
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React, { createRef } from "react";
|
|
2
|
-
import Dropzone, { DropzoneRef } from "../../";
|
|
3
|
-
|
|
4
|
-
const ref = createRef<DropzoneRef>();
|
|
5
|
-
|
|
6
|
-
export const dropzone = (
|
|
7
|
-
<Dropzone ref={ref}>
|
|
8
|
-
{({ getRootProps, getInputProps }) => (
|
|
9
|
-
<div {...getRootProps()}>
|
|
10
|
-
<input {...getInputProps()} />
|
|
11
|
-
<p>Drop some files here.</p>
|
|
12
|
-
<button type="button" onClick={ref.current.open}>
|
|
13
|
-
Open file dialog
|
|
14
|
-
</button>
|
|
15
|
-
</div>
|
|
16
|
-
)}
|
|
17
|
-
</Dropzone>
|
|
18
|
-
);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"baseUrl": ".",
|
|
4
|
-
"allowSyntheticDefaultImports": true,
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"noEmit": true,
|
|
7
|
-
"jsx": "react",
|
|
8
|
-
"moduleResolution": "node",
|
|
9
|
-
"module": "es2015",
|
|
10
|
-
"target": "esnext",
|
|
11
|
-
"typeRoots": [
|
|
12
|
-
"node_modules/@types"
|
|
13
|
-
],
|
|
14
|
-
"lib": [
|
|
15
|
-
"es2015",
|
|
16
|
-
"dom"
|
|
17
|
-
]
|
|
18
|
-
},
|
|
19
|
-
"include": [
|
|
20
|
-
"./*.tsx"
|
|
21
|
-
]
|
|
22
|
-
}
|