react-dropzone 11.5.3 → 12.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/.eslintignore +1 -3
- package/.eslintrc +2 -4
- package/.husky/commit-msg +5 -0
- package/.husky/pre-commit +5 -0
- package/.nvmrc +1 -1
- package/README.md +78 -29
- package/commitlint.config.js +1 -1
- package/dist/es/index.js +195 -151
- package/dist/es/utils/index.js +53 -17
- package/dist/index.js +16 -2
- package/examples/events/README.md +3 -1
- package/examples/no-jsx/README.md +32 -0
- package/package.json +80 -76
- package/rollup.config.js +22 -19
- package/src/.eslintrc +7 -4
- package/src/__snapshots__/index.spec.js.snap +1 -1
- package/src/index.js +372 -288
- package/src/index.spec.js +1837 -1369
- package/src/utils/index.js +117 -56
- package/src/utils/index.spec.js +414 -254
- package/styleguide.config.js +57 -50
- package/testSetup.js +1 -1
- package/typings/.eslintrc +28 -0
- package/typings/react-dropzone.d.ts +24 -14
- package/typings/tests/accept.tsx +10 -9
- package/typings/tests/all.tsx +6 -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/tslint.json +0 -101
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
If you'd like to use [react without JSX](https://reactjs.org/docs/react-without-jsx.html) you can:
|
|
2
|
+
|
|
3
|
+
```js harmony
|
|
4
|
+
import React, {useCallback, useState} from 'react';
|
|
5
|
+
import {useDropzone} from 'react-dropzone';
|
|
6
|
+
|
|
7
|
+
const e = React.createElement
|
|
8
|
+
|
|
9
|
+
function Basic () {
|
|
10
|
+
const [files, setFiles] = useState([]);
|
|
11
|
+
const onDrop = useCallback(files => setFiles(files), [setFiles]);
|
|
12
|
+
|
|
13
|
+
const {getRootProps, getInputProps} = useDropzone({onDrop});
|
|
14
|
+
|
|
15
|
+
const fileList = files.map(
|
|
16
|
+
file => React.createElement('li', {key: file.name}, `${file.name} - ${file.size} bytes`)
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
return e('section', {className: 'container'}, [
|
|
20
|
+
e('div', getRootProps({className: 'dropzone', key: 'dropzone'}), [
|
|
21
|
+
e('input', getInputProps({key: 'input'})),
|
|
22
|
+
e('p', {key: 'desc'}, "Drag 'n' drop some files here, or click to select files")
|
|
23
|
+
]),
|
|
24
|
+
e('aside', {key: 'filesContainer'}, [
|
|
25
|
+
e('h4', {key: 'title'}, 'Files'),
|
|
26
|
+
e('ul', {key: 'fileList'}, fileList)
|
|
27
|
+
])
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Basic()
|
|
32
|
+
```
|
package/package.json
CHANGED
|
@@ -5,19 +5,22 @@
|
|
|
5
5
|
"module": "dist/es/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"scripts": {
|
|
8
|
-
"
|
|
8
|
+
"cz": "git-cz",
|
|
9
9
|
"clean": "rimraf ./dist",
|
|
10
|
-
"build": "
|
|
10
|
+
"build": "yarn clean && yarn build:umd && yarn build:es",
|
|
11
11
|
"build:umd": "cross-env NODE_ENV=es rollup -c",
|
|
12
12
|
"build:es": "cross-env BABEL_ENV=es babel ./src --out-dir ./dist/es --ignore '**/*.spec.js'",
|
|
13
13
|
"start": "styleguidist server",
|
|
14
14
|
"styleguide": "styleguidist build",
|
|
15
|
-
"test": "cross-env NODE_ENV=test
|
|
15
|
+
"test": "cross-env NODE_ENV=test yarn lint && jest --coverage && yarn typescript",
|
|
16
16
|
"test:watch": "cross-env NODE_ENV=test jest --watch",
|
|
17
|
-
"
|
|
17
|
+
"lint": "eslint .",
|
|
18
|
+
"lint:fix": "eslint . --fix",
|
|
18
19
|
"commitmsg": "commitlint -e",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
20
|
+
"prepublish": "yarn build && yarn size",
|
|
21
|
+
"_postinstall": "husky install",
|
|
22
|
+
"prepublishOnly": "pinst --disable",
|
|
23
|
+
"postpublish": "pinst --enable",
|
|
21
24
|
"logo": "cd logo && sketchtool export artboards logo.sketch",
|
|
22
25
|
"imagemin": "imagemin --out-dir=logo --plugin=pngquant --plugin=svgo",
|
|
23
26
|
"size": "size-limit",
|
|
@@ -36,18 +39,22 @@
|
|
|
36
39
|
],
|
|
37
40
|
"lint-staged": {
|
|
38
41
|
"*.js": [
|
|
39
|
-
"eslint --fix"
|
|
40
|
-
"git add"
|
|
42
|
+
"eslint . --fix"
|
|
41
43
|
],
|
|
42
44
|
"*.ts": [
|
|
43
|
-
"
|
|
45
|
+
"eslint ."
|
|
44
46
|
],
|
|
45
47
|
"*.{svg,png}": [
|
|
46
|
-
"imagemin"
|
|
47
|
-
"git add"
|
|
48
|
+
"imagemin"
|
|
48
49
|
]
|
|
49
50
|
},
|
|
51
|
+
"config": {
|
|
52
|
+
"commitizen": {
|
|
53
|
+
"path": "@commitlint/prompt"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
50
56
|
"jest": {
|
|
57
|
+
"testEnvironment": "jsdom",
|
|
51
58
|
"clearMocks": true,
|
|
52
59
|
"setupFilesAfterEnv": [
|
|
53
60
|
"<rootDir>/testSetup.js"
|
|
@@ -91,85 +98,82 @@
|
|
|
91
98
|
"react": ">= 16.8"
|
|
92
99
|
},
|
|
93
100
|
"dependencies": {
|
|
94
|
-
"attr-accept": "^2.2.
|
|
95
|
-
"file-selector": "^0.
|
|
96
|
-
"prop-types": "^15.
|
|
101
|
+
"attr-accept": "^2.2.2",
|
|
102
|
+
"file-selector": "^0.4.0",
|
|
103
|
+
"prop-types": "^15.8.1"
|
|
97
104
|
},
|
|
98
105
|
"devDependencies": {
|
|
99
|
-
"@babel/cli": "^7.
|
|
100
|
-
"@babel/core": "^7.
|
|
101
|
-
"@babel/
|
|
102
|
-
"@babel/plugin-
|
|
103
|
-
"@babel/plugin-proposal-
|
|
104
|
-
"@babel/plugin-proposal-
|
|
105
|
-
"@babel/plugin-proposal-
|
|
106
|
-
"@babel/plugin-proposal-
|
|
107
|
-
"@babel/plugin-proposal-
|
|
108
|
-
"@babel/plugin-
|
|
109
|
-
"@babel/
|
|
110
|
-
"@babel/preset-
|
|
111
|
-
"@babel/
|
|
112
|
-
"@
|
|
113
|
-
"@commitlint/
|
|
114
|
-
"@commitlint/
|
|
115
|
-
"@commitlint/prompt
|
|
116
|
-
"@
|
|
117
|
-
"@
|
|
118
|
-
"@
|
|
119
|
-
"@
|
|
120
|
-
"@
|
|
106
|
+
"@babel/cli": "^7.16.8",
|
|
107
|
+
"@babel/core": "^7.16.12",
|
|
108
|
+
"@babel/eslint-parser": "^7.16.5",
|
|
109
|
+
"@babel/plugin-external-helpers": "^7.16.7",
|
|
110
|
+
"@babel/plugin-proposal-do-expressions": "^7.16.7",
|
|
111
|
+
"@babel/plugin-proposal-export-default-from": "^7.16.7",
|
|
112
|
+
"@babel/plugin-proposal-logical-assignment-operators": "^7.16.7",
|
|
113
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
|
|
114
|
+
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
115
|
+
"@babel/plugin-proposal-pipeline-operator": "^7.16.7",
|
|
116
|
+
"@babel/plugin-transform-runtime": "^7.16.10",
|
|
117
|
+
"@babel/preset-env": "^7.16.11",
|
|
118
|
+
"@babel/preset-react": "^7.16.7",
|
|
119
|
+
"@babel/register": "^7.16.9",
|
|
120
|
+
"@commitlint/cli": "^16.1.0",
|
|
121
|
+
"@commitlint/config-angular": "^16.0.0",
|
|
122
|
+
"@commitlint/prompt": "^16.1.0",
|
|
123
|
+
"@commitlint/prompt-cli": "^16.1.0",
|
|
124
|
+
"@rollup/plugin-babel": "^5.3.0",
|
|
125
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
126
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
127
|
+
"@size-limit/preset-small-lib": "^7.0.5",
|
|
128
|
+
"@size-limit/webpack": "^7.0.5",
|
|
129
|
+
"@size-limit/webpack-why": "^7.0.5",
|
|
130
|
+
"@testing-library/dom": "^8.11.3",
|
|
131
|
+
"@testing-library/jest-dom": "^5.16.1",
|
|
132
|
+
"@testing-library/react": "^12.1.2",
|
|
133
|
+
"@testing-library/react-hooks": "^7.0.2",
|
|
121
134
|
"@types/react": "^17.0.0",
|
|
122
135
|
"@types/react-dom": "^17.0.0",
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
"babel-
|
|
136
|
+
"@typescript-eslint/eslint-plugin": "^5.10.1",
|
|
137
|
+
"@typescript-eslint/parser": "^5.10.1",
|
|
138
|
+
"babel-jest": "^27.4.6",
|
|
139
|
+
"babel-plugin-add-module-exports": "^1.0.4",
|
|
126
140
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
127
|
-
"commitizen": "^4.2.
|
|
128
|
-
"cross-env": "^7.0.
|
|
129
|
-
"eslint": "
|
|
130
|
-
"eslint-config-
|
|
131
|
-
"eslint-
|
|
132
|
-
"eslint-plugin-
|
|
133
|
-
"eslint-plugin-
|
|
134
|
-
"eslint-plugin-
|
|
135
|
-
"eslint-plugin-
|
|
136
|
-
"eslint-plugin-react": "
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"imagemin-
|
|
140
|
-
"
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"prettier": "
|
|
141
|
+
"commitizen": "^4.2.4",
|
|
142
|
+
"cross-env": "^7.0.3",
|
|
143
|
+
"eslint": "^8.8.0",
|
|
144
|
+
"eslint-config-prettier": "^8.3.0",
|
|
145
|
+
"eslint-plugin-import": "^2.25.4",
|
|
146
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
147
|
+
"eslint-plugin-node": "^11.1.0",
|
|
148
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
149
|
+
"eslint-plugin-react": "^7.28.0",
|
|
150
|
+
"eslint-plugin-react-hooks": "^4.3.0",
|
|
151
|
+
"husky": "^7.0.4",
|
|
152
|
+
"imagemin-cli": "^7.0.0",
|
|
153
|
+
"imagemin-pngquant": "^9.0.2",
|
|
154
|
+
"jest": "^27.4.7",
|
|
155
|
+
"lint-staged": "^12.3.2",
|
|
156
|
+
"markdownlint-cli": "^0.30.0",
|
|
157
|
+
"pinst": "^2.1.6",
|
|
158
|
+
"prettier": "^2.5.1",
|
|
145
159
|
"react": "^17.0.0",
|
|
146
160
|
"react-dom": "^17.0.0",
|
|
147
|
-
"react-styleguidist": "^11.0
|
|
161
|
+
"react-styleguidist": "^11.2.0",
|
|
148
162
|
"react-test-renderer": "^17.0.0",
|
|
149
163
|
"rimraf": "^3.0.2",
|
|
150
|
-
"rollup": "^2.
|
|
151
|
-
"rollup-plugin-
|
|
152
|
-
"
|
|
153
|
-
"
|
|
154
|
-
"
|
|
155
|
-
"sinon": "^9.0.3",
|
|
156
|
-
"size-limit": "^4.5.7",
|
|
157
|
-
"style-loader": "^1.2.1",
|
|
158
|
-
"styled-components": "^5.2.0",
|
|
159
|
-
"tslint": "^6.1.3",
|
|
164
|
+
"rollup": "^2.66.1",
|
|
165
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
166
|
+
"size-limit": "^7.0.5",
|
|
167
|
+
"style-loader": "^3.3.1",
|
|
168
|
+
"styled-components": "^5.3.3",
|
|
160
169
|
"typescript": "^4.0.2",
|
|
161
|
-
"webpack": "^
|
|
170
|
+
"webpack": "^5.67.0",
|
|
162
171
|
"webpack-blocks": "^2.1.0"
|
|
163
172
|
},
|
|
164
173
|
"typings": "typings/react-dropzone.d.ts",
|
|
165
|
-
"
|
|
166
|
-
"commitizen": {
|
|
167
|
-
"path": "@commitlint/prompt"
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
"version": "11.5.3",
|
|
174
|
+
"version": "12.0.0",
|
|
171
175
|
"engines": {
|
|
172
|
-
"node": ">= 10"
|
|
176
|
+
"node": ">= 10.13"
|
|
173
177
|
},
|
|
174
178
|
"browserslist": [
|
|
175
179
|
"defaults"
|
package/rollup.config.js
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
const nodeResolve = require(
|
|
2
|
-
const commonjs = require(
|
|
3
|
-
const babel = require(
|
|
4
|
-
const {
|
|
1
|
+
const { nodeResolve } = require("@rollup/plugin-node-resolve");
|
|
2
|
+
const commonjs = require("@rollup/plugin-commonjs");
|
|
3
|
+
const { babel } = require("@rollup/plugin-babel");
|
|
4
|
+
const { terser } = require("rollup-plugin-terser");
|
|
5
5
|
|
|
6
6
|
const umdGlobals = {
|
|
7
|
-
react:
|
|
8
|
-
|
|
9
|
-
}
|
|
7
|
+
react: "React",
|
|
8
|
+
"prop-types": "PropTypes",
|
|
9
|
+
};
|
|
10
10
|
|
|
11
11
|
module.exports = [
|
|
12
12
|
{
|
|
13
|
-
input:
|
|
13
|
+
input: "./src/index.js",
|
|
14
14
|
output: {
|
|
15
|
-
file:
|
|
16
|
-
format:
|
|
17
|
-
name:
|
|
15
|
+
file: "dist/index.js",
|
|
16
|
+
format: "umd",
|
|
17
|
+
name: "reactDropzone",
|
|
18
18
|
globals: umdGlobals,
|
|
19
|
-
sourcemap:
|
|
20
|
-
exports:
|
|
19
|
+
sourcemap: "inline",
|
|
20
|
+
exports: "named",
|
|
21
21
|
},
|
|
22
22
|
external: Object.keys(umdGlobals),
|
|
23
23
|
plugins: [
|
|
24
24
|
nodeResolve(),
|
|
25
|
-
commonjs({ include:
|
|
26
|
-
babel({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
commonjs({ include: "**/node_modules/**" }),
|
|
26
|
+
babel({
|
|
27
|
+
exclude: "**/node_modules/**",
|
|
28
|
+
babelHelpers: "bundled",
|
|
29
|
+
}),
|
|
30
|
+
terser(),
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
];
|
package/src/.eslintrc
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"root": true,
|
|
3
|
-
"parser": "babel-
|
|
3
|
+
"parser": "@babel/eslint-parser",
|
|
4
4
|
"parserOptions": {
|
|
5
5
|
"ecmaVersion": 2017,
|
|
6
6
|
"sourceType": "module"
|
|
@@ -19,16 +19,19 @@
|
|
|
19
19
|
"react-hooks"
|
|
20
20
|
],
|
|
21
21
|
"extends": [
|
|
22
|
-
//"okonet/react",
|
|
23
22
|
"eslint:recommended",
|
|
24
23
|
"plugin:react/recommended",
|
|
25
24
|
"plugin:jsx-a11y/recommended",
|
|
26
|
-
"prettier"
|
|
27
|
-
"prettier/react"
|
|
25
|
+
"plugin:prettier/recommended"
|
|
28
26
|
],
|
|
29
27
|
"rules": {
|
|
30
28
|
"react-hooks/rules-of-hooks": 2,
|
|
31
29
|
"react/forbid-prop-types": 0,
|
|
32
30
|
"react/require-default-props": 0
|
|
31
|
+
},
|
|
32
|
+
"settings": {
|
|
33
|
+
"react": {
|
|
34
|
+
"version": "detect"
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
37
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`useDropzone() hook behavior renders the root and input nodes with the necessary props 1`] = `"<div tabindex=\\"0\\"><input multiple=\\"\\" type=\\"file\\" style=\\"display: none;\\" autocomplete=\\"off\\" tabindex=\\"-1\\"></div>"`;
|
|
3
|
+
exports[`useDropzone() hook behavior renders the root and input nodes with the necessary props 1`] = `"<div role=\\"button\\" tabindex=\\"0\\"><input multiple=\\"\\" type=\\"file\\" style=\\"display: none;\\" autocomplete=\\"off\\" tabindex=\\"-1\\"></div>"`;
|