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.
@@ -7,7 +7,14 @@ The value must be a comma-separated list of unique content type specifiers:
7
7
  * video/* representing video files.
8
8
  * image/* representing image files.
9
9
 
10
- For more information see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input
10
+ For more information see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input.
11
+
12
+ **IMPORTANT** As of [v12.0.0](https://github.com/react-dropzone/react-dropzone/releases/tag/v12.0.0), there has been some changes that affect how `accept` works.
13
+ See [file dialog cancel callback](../../README.md#file-dialog-cancel-callback) to read more about why this change was introduced. In summary:
14
+ 1. In browsers that **do not support** the FS access API, the `accept` attr works exactly the same as in previous versions of react-dropozone, for both file picker and dag 'n' drop
15
+ 2. In browsers that **support** the FS access API, when passing file extensions to `accept` (e.g `".jpg,.png"`), the file picker will not apply those filters, but drag 'n' drop will - though, the [browser limitations](#browser-limitations) described in this document still apply
16
+ 3. If you want the same behaviour in all browsers, regardless of using the FS access API or not, you need to use MIME types - [browser limitations](#browser-limitations) still apply
17
+ 4. The use of FS access API can be turned off via `useDropzone({useFsAccessApi: false})`
11
18
 
12
19
  ```jsx harmony
13
20
  import React from 'react';
@@ -20,7 +27,7 @@ function Accept(props) {
20
27
  getRootProps,
21
28
  getInputProps
22
29
  } = useDropzone({
23
- accept: 'image/jpeg, image/png'
30
+ accept: 'image/jpeg,image/png'
24
31
  });
25
32
 
26
33
  const acceptedFileItems = acceptedFiles.map(file => (
@@ -110,7 +117,7 @@ function Accept(props) {
110
117
  isDragAccept,
111
118
  isDragReject
112
119
  } = useDropzone({
113
- accept: 'image/jpeg, image/png'
120
+ accept: 'image/jpeg,image/png'
114
121
  });
115
122
 
116
123
  return (
@@ -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 eslint:src && jest --coverage && yarn typescript",
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
- "eslint:src": "eslint .",
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",
@@ -29,16 +30,16 @@
29
30
  "size-limit": [
30
31
  {
31
32
  "path": "dist/index.js",
32
- "limit": "7 KB"
33
+ "limit": "7.5 KB"
33
34
  },
34
35
  {
35
36
  "path": "dist/es/index.js",
36
- "limit": "7 KB"
37
+ "limit": "7.5 KB"
37
38
  }
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": "11.7.0",
174
+ "version": "12.0.2",
174
175
  "engines": {
175
176
  "node": ">= 10.13"
176
177
  },
package/rollup.config.js CHANGED
@@ -1,33 +1,33 @@
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')
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: 'React',
8
- 'prop-types': 'PropTypes'
9
- }
7
+ react: "React",
8
+ "prop-types": "PropTypes",
9
+ };
10
10
 
11
11
  module.exports = [
12
12
  {
13
- input: './src/index.js',
13
+ input: "./src/index.js",
14
14
  output: {
15
- file: 'dist/index.js',
16
- format: 'umd',
17
- name: 'reactDropzone',
15
+ file: "dist/index.js",
16
+ format: "umd",
17
+ name: "reactDropzone",
18
18
  globals: umdGlobals,
19
- sourcemap: 'inline',
20
- exports: 'named'
19
+ sourcemap: "inline",
20
+ exports: "named",
21
21
  },
22
22
  external: Object.keys(umdGlobals),
23
23
  plugins: [
24
24
  nodeResolve(),
25
- commonjs({ include: '**/node_modules/**' }),
25
+ commonjs({ include: "**/node_modules/**" }),
26
26
  babel({
27
- exclude: '**/node_modules/**',
28
- babelHelpers: 'bundled',
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,