react-dropzone 11.6.0 → 12.0.1
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 +2 -1
- package/commitlint.config.js +1 -1
- package/dist/es/index.js +56 -44
- package/dist/es/utils/index.js +22 -22
- package/dist/index.js +2 -2
- package/examples/no-jsx/README.md +32 -0
- package/package.json +5 -4
- package/rollup.config.js +20 -20
- package/src/.eslintrc +1 -2
- package/src/__snapshots__/index.spec.js.snap +1 -1
- package/src/index.js +320 -275
- package/src/index.spec.js +1740 -1484
- package/src/utils/index.js +100 -73
- package/src/utils/index.spec.js +386 -289
- package/styleguide.config.js +57 -50
- package/testSetup.js +1 -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
|
@@ -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
|
@@ -12,9 +12,10 @@
|
|
|
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 yarn
|
|
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
|
"prepublish": "yarn build && yarn size",
|
|
20
21
|
"_postinstall": "husky install",
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
],
|
|
39
40
|
"lint-staged": {
|
|
40
41
|
"*.js": [
|
|
41
|
-
"eslint --fix"
|
|
42
|
+
"eslint . --fix"
|
|
42
43
|
],
|
|
43
44
|
"*.ts": [
|
|
44
45
|
"eslint ."
|
|
@@ -170,7 +171,7 @@
|
|
|
170
171
|
"webpack-blocks": "^2.1.0"
|
|
171
172
|
},
|
|
172
173
|
"typings": "typings/react-dropzone.d.ts",
|
|
173
|
-
"version": "
|
|
174
|
+
"version": "12.0.1",
|
|
174
175
|
"engines": {
|
|
175
176
|
"node": ">= 10.13"
|
|
176
177
|
},
|
package/rollup.config.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
const { nodeResolve } = require(
|
|
2
|
-
const commonjs = require(
|
|
3
|
-
const { babel } = require(
|
|
4
|
-
const { terser } = require(
|
|
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:
|
|
25
|
+
commonjs({ include: "**/node_modules/**" }),
|
|
26
26
|
babel({
|
|
27
|
-
exclude:
|
|
28
|
-
babelHelpers:
|
|
27
|
+
exclude: "**/node_modules/**",
|
|
28
|
+
babelHelpers: "bundled",
|
|
29
29
|
}),
|
|
30
|
-
terser()
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
]
|
|
30
|
+
terser(),
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
];
|
package/src/.eslintrc
CHANGED
|
@@ -19,11 +19,10 @@
|
|
|
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"
|
|
25
|
+
"plugin:prettier/recommended"
|
|
27
26
|
],
|
|
28
27
|
"rules": {
|
|
29
28
|
"react-hooks/rules-of-hooks": 2,
|
|
@@ -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>"`;
|