react-dropzone 5.0.0 → 5.1.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/package.json CHANGED
@@ -7,21 +7,20 @@
7
7
  "ci": "git-cz",
8
8
  "clean": "rimraf ./dist",
9
9
  "build": "npm run clean && npm run build:umd && npm run build:es",
10
- "build:umd": "cross-env NODE_ENV=production webpack -p",
10
+ "build:umd": "cross-env NODE_ENV=es rollup -c",
11
11
  "build:es": "cross-env BABEL_ENV=es babel ./src --out-dir ./dist/es --ignore spec.js",
12
12
  "start": "styleguidist server",
13
13
  "styleguide": "styleguidist build",
14
- "test": "npm run eslint:src && jest --coverage && npm run size",
15
- "test:es": "cross-env JEST_TARGET=../dist/es/index jest --coverage",
16
- "test:umd": "cross-env JEST_TARGET=../dist/index jest --coverage",
17
- "eslint:src": "eslint ./src ./examples ./*.js",
14
+ "test": "npm run eslint:src && jest --coverage",
15
+ "eslint:src": "eslint .",
18
16
  "commitmsg": "commitlint -e",
19
17
  "precommit": "lint-staged",
20
- "prepublish": "npm run build && npm run test:umd && npm run test:es",
18
+ "prepublish": "npm run build && npm run size",
21
19
  "logo": "cd logo && sketchtool export artboards logo.sketch",
22
20
  "imagemin": "imagemin --out-dir=logo --plugin=pngquant --plugin=svgo",
23
21
  "size": "size-limit",
24
- "size:why": "size-limit --why"
22
+ "size:why": "size-limit --why",
23
+ "typescript": "tsc --project ./typings/tests"
25
24
  },
26
25
  "size-limit": [
27
26
  {
@@ -30,7 +29,7 @@
30
29
  },
31
30
  {
32
31
  "path": "dist/es/index.js",
33
- "limit": "4 KB"
32
+ "limit": "6 KB"
34
33
  }
35
34
  ],
36
35
  "lint-staged": {
@@ -38,13 +37,17 @@
38
37
  "eslint --fix",
39
38
  "git add"
40
39
  ],
40
+ "*.ts": [
41
+ "tslint"
42
+ ],
41
43
  "*.{svg,png}": [
42
44
  "imagemin",
43
45
  "git add"
44
46
  ]
45
47
  },
46
48
  "jest": {
47
- "setupTestFrameworkScriptFile": "<rootDir>/testSetup.js"
49
+ "setupTestFrameworkScriptFile": "<rootDir>/testSetup.js",
50
+ "clearMocks": true
48
51
  },
49
52
  "keywords": [
50
53
  "react-component",
@@ -75,53 +78,72 @@
75
78
  },
76
79
  "dependencies": {
77
80
  "attr-accept": "^1.1.3",
78
- "prop-types": "^15.5.7"
81
+ "prop-types": "^15.6.2"
79
82
  },
80
83
  "devDependencies": {
81
- "@commitlint/cli": "^3.2.0",
82
- "@commitlint/config-angular": "^3.0.3",
83
- "@commitlint/prompt": "^3.2.0",
84
- "@commitlint/prompt-cli": "^3.2.0",
84
+ "@commitlint/cli": "^7.0.0",
85
+ "@commitlint/config-angular": "^7.0.1",
86
+ "@commitlint/prompt": "^7.0.0",
87
+ "@commitlint/prompt-cli": "^7.0.0",
88
+ "@types/react": "^16.3.2",
89
+ "@types/react-dom": "^16.0.4",
85
90
  "babel-cli": "^6.9.0",
86
- "babel-core": "^6.9.1",
87
- "babel-eslint": "^7.1.1",
88
- "babel-jest": "^21.0.0",
89
- "babel-loader": "^7.1.2",
91
+ "babel-core": "^6.26.3",
92
+ "babel-eslint": "*",
93
+ "babel-jest": "^23.4.2",
90
94
  "babel-plugin-add-module-exports": "^0.2.1",
91
- "babel-preset-env": "^1.6.0",
95
+ "babel-plugin-external-helpers": "^6.22.0",
96
+ "babel-preset-env": "^1.7.0",
92
97
  "babel-preset-react": "^6.3.13",
93
98
  "babel-preset-stage-1": "^6.24.1",
94
99
  "babel-register": "^6.9.0",
95
- "commitizen": "^2.9.6",
96
- "cross-env": "^5.1.3",
97
- "css-loader": "^0.28.7",
98
- "enzyme": "^2.6.0",
99
- "eslint": "^4.6.1",
100
- "eslint-config-okonet": "^5.0.1",
101
- "eslint-config-prettier": "^2.4.0",
102
- "eslint-plugin-prettier": "^2.2.0",
100
+ "commitizen": "^2.10.1",
101
+ "cross-env": "^5.2.0",
102
+ "enzyme": "^3.4.4",
103
+ "enzyme-adapter-react-16": "^1.2.0",
104
+ "eslint": "4.x",
105
+ "eslint-config-okonet": "^7.0.2",
106
+ "eslint-config-prettier": "2.x",
107
+ "eslint-plugin-flowtype": "2.x",
108
+ "eslint-plugin-import": "2.x",
109
+ "eslint-plugin-jsx-a11y": "5.x",
110
+ "eslint-plugin-node": "5.x",
111
+ "eslint-plugin-prettier": "2.x",
112
+ "eslint-plugin-react": "7.x",
103
113
  "husky": "^0.14.3",
104
114
  "imagemin-cli": "^3.0.0",
105
- "imagemin-pngquant": "^5.0.0",
106
- "jest": "^21.0.1",
107
- "jest-enzyme": "^3.8.2",
108
- "lint-staged": "^4.1.0",
109
- "markdownlint-cli": "^0.3.1",
110
- "prettier": "^1.6.1",
111
- "react": "^15.4.1",
112
- "react-dom": "^15.4.1",
113
- "react-styleguidist": "^6.0.23",
114
- "react-test-renderer": "^15.6.1",
115
+ "imagemin-pngquant": "^6.0.0",
116
+ "jest": "^23.5.0",
117
+ "jest-enzyme": "^6.0.3",
118
+ "lint-staged": "^7.2.2",
119
+ "markdownlint-cli": "^0.13.0",
120
+ "prettier": "*",
121
+ "react": "^16.4.2",
122
+ "react-dom": "^16.4.2",
123
+ "react-styleguidist": "^7.2.3",
124
+ "react-test-renderer": "^16.4.2",
115
125
  "rimraf": "^2.5.2",
126
+ "rollup": "^0.58.2",
127
+ "rollup-plugin-babel": "^3.0.4",
128
+ "rollup-plugin-commonjs": "^9.1.3",
129
+ "rollup-plugin-node-resolve": "^3.3.0",
130
+ "rollup-plugin-uglify": "^3.0.0",
131
+ "size-limit": "^0.19.2",
132
+ "webpack-blocks": "^1.0.0",
116
133
  "sinon": "^3.2.1",
117
- "size-limit": "^0.11.0",
118
134
  "style-loader": "^0.18.2",
135
+ "tslint": "^5.9.1",
136
+ "typescript": "^2.8.1",
119
137
  "webpack": "^3.5.5"
120
138
  },
139
+ "typings": "typings/react-dropzone.d.ts",
121
140
  "config": {
122
141
  "commitizen": {
123
142
  "path": "@commitlint/prompt"
124
143
  }
125
144
  },
126
- "version": "5.0.0"
145
+ "version": "5.1.1",
146
+ "engines": {
147
+ "node": ">= 6"
148
+ }
127
149
  }
@@ -0,0 +1,29 @@
1
+ const nodeResolve = require('rollup-plugin-node-resolve')
2
+ const commonjs = require('rollup-plugin-commonjs')
3
+ const babel = require('rollup-plugin-babel')
4
+ const uglify = require('rollup-plugin-uglify')
5
+
6
+ const umdGlobals = {
7
+ react: 'React',
8
+ 'prop-types': 'PropTypes'
9
+ }
10
+
11
+ module.exports = [
12
+ {
13
+ input: './src/index.js',
14
+ output: {
15
+ file: 'dist/index.js',
16
+ format: 'umd',
17
+ name: 'Dropzone',
18
+ globals: umdGlobals,
19
+ sourcemap: 'inline'
20
+ },
21
+ external: Object.keys(umdGlobals),
22
+ plugins: [
23
+ nodeResolve(),
24
+ commonjs({ include: '**/node_modules/**' }),
25
+ babel({ exclude: '**/node_modules/**', plugins: ['external-helpers'] }),
26
+ uglify()
27
+ ]
28
+ }
29
+ ]
package/src/.eslintrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "root": true,
3
+ "extends": ["okonet/react"],
4
+ "rules": {
5
+ "react/require-default-props": 0,
6
+ "react/forbid-prop-types": 0
7
+ }
8
+ }
@@ -1,7 +1,7 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Dropzone basics should render children 1`] = `"<div class=\\"\\" aria-disabled=\\"false\\" style=\\"position: relative; width: 200px; height: 200px; border-width: 2px; border-color: #666; border-style: dashed; border-radius: 5px;\\"><p>some content</p><input type=\\"file\\" multiple=\\"\\" autocomplete=\\"off\\" style=\\"position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; opacity: 0.00001; pointer-events: none;\\"></div>"`;
4
-
5
- exports[`Dropzone document drop protection does not prevent stray drops when preventDropOnDocument is false 1`] = `"<div class=\\"\\" aria-disabled=\\"false\\" style=\\"position: relative; width: 200px; height: 200px; border-width: 2px; border-color: #666; border-style: dashed; border-radius: 5px;\\"><input type=\\"file\\" multiple=\\"\\" autocomplete=\\"off\\" style=\\"position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; opacity: 0.00001; pointer-events: none;\\"></div>"`;
6
-
7
- exports[`Dropzone document drop protection installs hooks to prevent stray drops from taking over the browser window 1`] = `"<div class=\\"\\" aria-disabled=\\"false\\" style=\\"position: relative; width: 200px; height: 200px; border-width: 2px; border-color: #666; border-style: dashed; border-radius: 5px;\\"><p>Content</p><input type=\\"file\\" multiple=\\"\\" autocomplete=\\"off\\" style=\\"position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; opacity: 0.00001; pointer-events: none;\\"></div>"`;
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Dropzone basics should render children 1`] = `"<div class=\\"\\" style=\\"position: relative; width: 200px; height: 200px; border-width: 2px; border-color: #666; border-style: dashed; border-radius: 5px;\\" aria-disabled=\\"false\\"><p>some content</p><input type=\\"file\\" style=\\"position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; opacity: 0.00001; pointer-events: none;\\" multiple=\\"\\" autocomplete=\\"off\\"></div>"`;
4
+
5
+ exports[`Dropzone document drop protection does not prevent stray drops when preventDropOnDocument is false 1`] = `"<div class=\\"\\" style=\\"position: relative; width: 200px; height: 200px; border-width: 2px; border-color: #666; border-style: dashed; border-radius: 5px;\\" aria-disabled=\\"false\\"><input type=\\"file\\" style=\\"position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; opacity: 0.00001; pointer-events: none;\\" multiple=\\"\\" autocomplete=\\"off\\"></div>"`;
6
+
7
+ exports[`Dropzone document drop protection installs hooks to prevent stray drops from taking over the browser window 1`] = `"<div class=\\"\\" style=\\"position: relative; width: 200px; height: 200px; border-width: 2px; border-color: #666; border-style: dashed; border-radius: 5px;\\" aria-disabled=\\"false\\"><p>Content</p><input type=\\"file\\" style=\\"position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; opacity: 0.00001; pointer-events: none;\\" multiple=\\"\\" autocomplete=\\"off\\"></div>"`;
package/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* global process */
1
2
  /* eslint prefer-template: 0 */
2
3
 
3
4
  import React from 'react'
@@ -47,7 +48,9 @@ class Dropzone extends React.Component {
47
48
  document.addEventListener('dragover', onDocumentDragOver, false)
48
49
  document.addEventListener('drop', this.onDocumentDrop, false)
49
50
  }
50
- this.fileInputEl.addEventListener('click', this.onInputElementClick, false)
51
+ if (this.fileInputEl != null) {
52
+ this.fileInputEl.addEventListener('click', this.onInputElementClick, false)
53
+ }
51
54
  window.addEventListener('focus', this.onFileDialogCancel, false)
52
55
  }
53
56
 
@@ -94,6 +97,8 @@ class Dropzone extends React.Component {
94
97
  this.dragTargets.push(evt.target)
95
98
  }
96
99
 
100
+ evt.persist()
101
+
97
102
  Promise.resolve(this.props.getDataTransferItems(evt)).then(draggedFiles => {
98
103
  this.setState({
99
104
  isDragActive: true, // Do not rely on files for the drag state. It doesn't work in Safari.
@@ -158,6 +163,9 @@ class Dropzone extends React.Component {
158
163
  // Stop default browser behavior
159
164
  evt.preventDefault()
160
165
 
166
+ // Persist event for later usage
167
+ evt.persist()
168
+
161
169
  // Reset the counter along with the drag on a drop.
162
170
  this.dragTargets = []
163
171
  this.isFileDialogActive = false
@@ -213,6 +221,11 @@ class Dropzone extends React.Component {
213
221
  if (acceptedFiles.length > 0 && onDropAccepted) {
214
222
  onDropAccepted.call(this, acceptedFiles, evt)
215
223
  }
224
+
225
+ // Update `acceptedFiles` and `rejectedFiles` state
226
+ // This will make children render functions receive the appropriate
227
+ // values
228
+ this.setState({ acceptedFiles, rejectedFiles })
216
229
  })
217
230
  }
218
231
 
@@ -400,6 +413,7 @@ class Dropzone extends React.Component {
400
413
  }
401
414
 
402
415
  // Destructure custom props away from props used for the div element
416
+ /* eslint-disable no-unused-vars */
403
417
  const {
404
418
  acceptedFiles,
405
419
  preventDropOnDocument,
@@ -413,12 +427,17 @@ class Dropzone extends React.Component {
413
427
  getDataTransferItems,
414
428
  ...divProps
415
429
  } = props
430
+ /* eslint-enable no-unused-vars */
416
431
 
432
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
433
+ /* eslint-disable jsx-a11y/click-events-have-key-events */
417
434
  return (
418
435
  <div
419
436
  className={className}
420
437
  style={appliedStyle}
421
- {...divProps /* expand user provided props first so event handlers are never overridden */}
438
+ {
439
+ ...divProps /* expand user provided props first so event handlers are never overridden */
440
+ }
422
441
  onClick={this.composeHandlers(this.onClick)}
423
442
  onDragStart={this.composeHandlers(this.onDragStart)}
424
443
  onDragEnter={this.composeHandlers(this.onDragEnter)}
@@ -430,7 +449,9 @@ class Dropzone extends React.Component {
430
449
  >
431
450
  {this.renderChildren(children, isDragActive, isDragAccept, isDragReject)}
432
451
  <input
433
- {...inputProps /* expand user provided inputProps first so inputAttributes override them */}
452
+ {
453
+ ...inputProps /* expand user provided inputProps first so inputAttributes override them */
454
+ }
434
455
  {...inputAttributes}
435
456
  />
436
457
  </div>