Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-dropzone

Package Overview
Dependencies
Maintainers
2
Versions
189
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dropzone - npm Package Compare versions

Comparing version 3.7.3 to 3.7.4

.codeclimate.yml

141

dist/index.js

@@ -10,3 +10,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

root["Dropzone"] = factory(root["react"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_2__) {
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {
return /******/ (function(modules) { // webpackBootstrap

@@ -68,9 +68,13 @@ /******/ // The module cache

var _attrAccept = __webpack_require__(1);
var _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
var _attrAccept = __webpack_require__(2);
var _attrAccept2 = _interopRequireDefault(_attrAccept);
var _react = __webpack_require__(2);
var _getDataTransferItems = __webpack_require__(3);
var _react2 = _interopRequireDefault(_react);
var _getDataTransferItems2 = _interopRequireDefault(_getDataTransferItems);

@@ -87,2 +91,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var supportMultiple = typeof document !== 'undefined' && document && document.createElement ? 'multiple' in document.createElement('input') : true;

@@ -141,9 +146,4 @@

// This is tricky. During the drag even the dataTransfer.files is null
// But Chrome implements some drag store, which is accesible via dataTransfer.items
var dataTransferItems = e.dataTransfer && e.dataTransfer.items ? e.dataTransfer.items : [];
var allFilesAccepted = this.allFilesAccepted((0, _getDataTransferItems2.default)(e, this.props.multiple));
// Now we need to convert the DataTransferList to Array
var allFilesAccepted = this.allFilesAccepted(Array.prototype.slice.call(dataTransferItems));
this.setState({

@@ -161,2 +161,3 @@ isDragActive: allFilesAccepted,

value: function onDragOver(e) {
// eslint-disable-line class-methods-use-this
e.preventDefault();

@@ -193,2 +194,16 @@ e.stopPropagation();

value: function onDrop(e) {
var _this2 = this;
var _props = this.props,
onDrop = _props.onDrop,
onDropAccepted = _props.onDropAccepted,
onDropRejected = _props.onDropRejected,
multiple = _props.multiple,
disablePreview = _props.disablePreview;
var fileList = (0, _getDataTransferItems2.default)(e, multiple);
var acceptedFiles = [];
var rejectedFiles = [];
// Stop default browser behavior
e.preventDefault();

@@ -198,21 +213,10 @@

this.enterCounter = 0;
this.isFileDialogActive = false;
this.setState({
isDragActive: false,
isDragReject: false
});
var droppedFiles = e.dataTransfer ? e.dataTransfer.files : e.target.files;
var max = this.props.multiple ? droppedFiles.length : Math.min(droppedFiles.length, 1);
var acceptedFiles = [];
var rejectedFiles = [];
for (var i = 0; i < max; i++) {
var file = droppedFiles[i];
// We might want to disable the preview creation to support big files
if (!this.props.disablePreview) {
file.preview = window.URL.createObjectURL(file);
fileList.forEach(function (file) {
if (!disablePreview && (0, _attrAccept2.default)(file, 'image/*')) {
file.preview = window.URL.createObjectURL(file); // eslint-disable-line no-param-reassign
}
if (this.fileAccepted(file) && this.fileMatchSize(file)) {
if (_this2.fileAccepted(file) && _this2.fileMatchSize(file)) {
acceptedFiles.push(file);

@@ -222,18 +226,21 @@ } else {

}
});
if (onDrop) {
onDrop.call(this, acceptedFiles, rejectedFiles, e);
}
if (this.props.onDrop) {
this.props.onDrop.call(this, acceptedFiles, rejectedFiles, e);
if (rejectedFiles.length > 0 && onDropRejected) {
onDropRejected.call(this, rejectedFiles, e);
}
if (rejectedFiles.length > 0) {
if (this.props.onDropRejected) {
this.props.onDropRejected.call(this, rejectedFiles, e);
}
} else if (acceptedFiles.length > 0) {
if (this.props.onDropAccepted) {
this.props.onDropAccepted.call(this, acceptedFiles, e);
}
if (acceptedFiles.length > 0 && onDropAccepted) {
onDropAccepted.call(this, acceptedFiles, e);
}
this.isFileDialogActive = false;
// Reset drag state
this.setState({
isDragActive: false,
isDragReject: false
});
}

@@ -293,12 +300,12 @@ }, {

value: function render() {
var _this2 = this;
var _this3 = this;
var _props = this.props,
accept = _props.accept,
activeClassName = _props.activeClassName,
inputProps = _props.inputProps,
multiple = _props.multiple,
name = _props.name,
rejectClassName = _props.rejectClassName,
rest = _objectWithoutProperties(_props, ['accept', 'activeClassName', 'inputProps', 'multiple', 'name', 'rejectClassName']);
var _props2 = this.props,
accept = _props2.accept,
activeClassName = _props2.activeClassName,
inputProps = _props2.inputProps,
multiple = _props2.multiple,
name = _props2.name,
rejectClassName = _props2.rejectClassName,
rest = _objectWithoutProperties(_props2, ['accept', 'activeClassName', 'inputProps', 'multiple', 'name', 'rejectClassName']);

@@ -359,3 +366,3 @@ var activeStyle = rest.activeStyle,

ref: function ref(el) {
return _this2.fileInputEl = el;
return _this3.fileInputEl = el;
}, // eslint-disable-line

@@ -444,3 +451,3 @@ onChange: this.onDrop

module.exports=function(t){function n(e){if(r[e])return r[e].exports;var o=r[e]={exports:{},id:e,loaded:!1};return t[e].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var r={};return n.m=t,n.c=r,n.p="",n(0)}([function(t,n,r){"use strict";n.__esModule=!0,r(8),r(9),n["default"]=function(t,n){if(t&&n){var r=function(){var r=n.split(","),e=t.name||"",o=t.type||"",i=o.replace(/\/.*$/,"");return{v:r.some(function(t){var n=t.trim();return"."===n.charAt(0)?e.toLowerCase().endsWith(n.toLowerCase()):/\/\*$/.test(n)?i===n.replace(/\/.*$/,""):o===n})}}();if("object"==typeof r)return r.v}return!0},t.exports=n["default"]},function(t,n){var r=t.exports={version:"1.2.2"};"number"==typeof __e&&(__e=r)},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n,r){var e=r(2),o=r(1),i=r(4),u=r(19),c="prototype",f=function(t,n){return function(){return t.apply(n,arguments)}},s=function(t,n,r){var a,p,l,d,y=t&s.G,h=t&s.P,v=y?e:t&s.S?e[n]||(e[n]={}):(e[n]||{})[c],x=y?o:o[n]||(o[n]={});y&&(r=n);for(a in r)p=!(t&s.F)&&v&&a in v,l=(p?v:r)[a],d=t&s.B&&p?f(l,e):h&&"function"==typeof l?f(Function.call,l):l,v&&!p&&u(v,a,l),x[a]!=l&&i(x,a,d),h&&((x[c]||(x[c]={}))[a]=l)};e.core=o,s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,t.exports=s},function(t,n,r){var e=r(5),o=r(18);t.exports=r(22)?function(t,n,r){return e.setDesc(t,n,o(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n){var r=Object;t.exports={create:r.create,getProto:r.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:r.getOwnPropertyDescriptor,setDesc:r.defineProperty,setDescs:r.defineProperties,getKeys:r.keys,getNames:r.getOwnPropertyNames,getSymbols:r.getOwnPropertySymbols,each:[].forEach}},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n,r){var e=r(20)("wks"),o=r(2).Symbol;t.exports=function(t){return e[t]||(e[t]=o&&o[t]||(o||r(6))("Symbol."+t))}},function(t,n,r){r(26),t.exports=r(1).Array.some},function(t,n,r){r(25),t.exports=r(1).String.endsWith},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n,r){var e=r(10);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,o){return t.call(n,r,e,o)}}return function(){return t.apply(n,arguments)}}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,n,r){t.exports=function(t){var n=/./;try{"/./"[t](n)}catch(e){try{return n[r(7)("match")]=!1,!"/./"[t](n)}catch(o){}}return!0}},function(t,n){t.exports=function(t){try{return!!t()}catch(n){return!0}}},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,r){var e=r(16),o=r(11),i=r(7)("match");t.exports=function(t){var n;return e(t)&&(void 0!==(n=t[i])?!!n:"RegExp"==o(t))}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n,r){var e=r(2),o=r(4),i=r(6)("src"),u="toString",c=Function[u],f=(""+c).split(u);r(1).inspectSource=function(t){return c.call(t)},(t.exports=function(t,n,r,u){"function"==typeof r&&(o(r,i,t[n]?""+t[n]:f.join(String(n))),"name"in r||(r.name=n)),t===e?t[n]=r:(u||delete t[n],o(t,n,r))})(Function.prototype,u,function(){return"function"==typeof this&&this[i]||c.call(this)})},function(t,n,r){var e=r(2),o="__core-js_shared__",i=e[o]||(e[o]={});t.exports=function(t){return i[t]||(i[t]={})}},function(t,n,r){var e=r(17),o=r(13);t.exports=function(t,n,r){if(e(n))throw TypeError("String#"+r+" doesn't accept regex!");return String(o(t))}},function(t,n,r){t.exports=!r(15)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n,r){var e=r(23),o=Math.min;t.exports=function(t){return t>0?o(e(t),9007199254740991):0}},function(t,n,r){"use strict";var e=r(3),o=r(24),i=r(21),u="endsWith",c=""[u];e(e.P+e.F*r(14)(u),"String",{endsWith:function(t){var n=i(this,t,u),r=arguments,e=r.length>1?r[1]:void 0,f=o(n.length),s=void 0===e?f:Math.min(o(e),f),a=String(t);return c?c.call(n,a,s):n.slice(s-a.length,s)===a}})},function(t,n,r){var e=r(5),o=r(3),i=r(1).Array||Array,u={},c=function(t,n){e.each.call(t.split(","),function(t){void 0==n&&t in i?u[t]=i[t]:t in[]&&(u[t]=r(12)(Function.call,[][t],n))})};c("pop,reverse,shift,keys,values,entries",1),c("indexOf,every,some,forEach,map,filter,find,findIndex,includes",3),c("join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill"),o(o.S,"Array",u)}]);
module.exports = __WEBPACK_EXTERNAL_MODULE_1__;

@@ -451,4 +458,40 @@ /***/ },

module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
module.exports=function(t){function n(e){if(r[e])return r[e].exports;var o=r[e]={exports:{},id:e,loaded:!1};return t[e].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var r={};return n.m=t,n.c=r,n.p="",n(0)}([function(t,n,r){"use strict";n.__esModule=!0,r(8),r(9),n["default"]=function(t,n){if(t&&n){var r=function(){var r=Array.isArray(n)?n:n.split(","),e=t.name||"",o=t.type||"",i=o.replace(/\/.*$/,"");return{v:r.some(function(t){var n=t.trim();return"."===n.charAt(0)?e.toLowerCase().endsWith(n.toLowerCase()):/\/\*$/.test(n)?i===n.replace(/\/.*$/,""):o===n})}}();if("object"==typeof r)return r.v}return!0},t.exports=n["default"]},function(t,n){var r=t.exports={version:"1.2.2"};"number"==typeof __e&&(__e=r)},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n,r){var e=r(2),o=r(1),i=r(4),u=r(19),c="prototype",f=function(t,n){return function(){return t.apply(n,arguments)}},s=function(t,n,r){var a,p,l,y,d=t&s.G,h=t&s.P,v=d?e:t&s.S?e[n]||(e[n]={}):(e[n]||{})[c],x=d?o:o[n]||(o[n]={});d&&(r=n);for(a in r)p=!(t&s.F)&&v&&a in v,l=(p?v:r)[a],y=t&s.B&&p?f(l,e):h&&"function"==typeof l?f(Function.call,l):l,v&&!p&&u(v,a,l),x[a]!=l&&i(x,a,y),h&&((x[c]||(x[c]={}))[a]=l)};e.core=o,s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,t.exports=s},function(t,n,r){var e=r(5),o=r(18);t.exports=r(22)?function(t,n,r){return e.setDesc(t,n,o(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n){var r=Object;t.exports={create:r.create,getProto:r.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:r.getOwnPropertyDescriptor,setDesc:r.defineProperty,setDescs:r.defineProperties,getKeys:r.keys,getNames:r.getOwnPropertyNames,getSymbols:r.getOwnPropertySymbols,each:[].forEach}},function(t,n){var r=0,e=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+e).toString(36))}},function(t,n,r){var e=r(20)("wks"),o=r(2).Symbol;t.exports=function(t){return e[t]||(e[t]=o&&o[t]||(o||r(6))("Symbol."+t))}},function(t,n,r){r(26),t.exports=r(1).Array.some},function(t,n,r){r(25),t.exports=r(1).String.endsWith},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n,r){var e=r(10);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,o){return t.call(n,r,e,o)}}return function(){return t.apply(n,arguments)}}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,n,r){t.exports=function(t){var n=/./;try{"/./"[t](n)}catch(e){try{return n[r(7)("match")]=!1,!"/./"[t](n)}catch(o){}}return!0}},function(t,n){t.exports=function(t){try{return!!t()}catch(n){return!0}}},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,r){var e=r(16),o=r(11),i=r(7)("match");t.exports=function(t){var n;return e(t)&&(void 0!==(n=t[i])?!!n:"RegExp"==o(t))}},function(t,n){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},function(t,n,r){var e=r(2),o=r(4),i=r(6)("src"),u="toString",c=Function[u],f=(""+c).split(u);r(1).inspectSource=function(t){return c.call(t)},(t.exports=function(t,n,r,u){"function"==typeof r&&(o(r,i,t[n]?""+t[n]:f.join(String(n))),"name"in r||(r.name=n)),t===e?t[n]=r:(u||delete t[n],o(t,n,r))})(Function.prototype,u,function(){return"function"==typeof this&&this[i]||c.call(this)})},function(t,n,r){var e=r(2),o="__core-js_shared__",i=e[o]||(e[o]={});t.exports=function(t){return i[t]||(i[t]={})}},function(t,n,r){var e=r(17),o=r(13);t.exports=function(t,n,r){if(e(n))throw TypeError("String#"+r+" doesn't accept regex!");return String(o(t))}},function(t,n,r){t.exports=!r(15)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n){var r=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:r)(t)}},function(t,n,r){var e=r(23),o=Math.min;t.exports=function(t){return t>0?o(e(t),9007199254740991):0}},function(t,n,r){"use strict";var e=r(3),o=r(24),i=r(21),u="endsWith",c=""[u];e(e.P+e.F*r(14)(u),"String",{endsWith:function(t){var n=i(this,t,u),r=arguments,e=r.length>1?r[1]:void 0,f=o(n.length),s=void 0===e?f:Math.min(o(e),f),a=String(t);return c?c.call(n,a,s):n.slice(s-a.length,s)===a}})},function(t,n,r){var e=r(5),o=r(3),i=r(1).Array||Array,u={},c=function(t,n){e.each.call(t.split(","),function(t){void 0==n&&t in i?u[t]=i[t]:t in[]&&(u[t]=r(12)(Function.call,[][t],n))})};c("pop,reverse,shift,keys,values,entries",1),c("indexOf,every,some,forEach,map,filter,find,findIndex,includes",3),c("join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill"),o(o.S,"Array",u)}]);
/***/ },
/* 3 */
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getDataTransferFiles;
function getDataTransferFiles(event) {
var isMultipleAllowed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var dataTransferItemsList = [];
if (event.hasOwnProperty('dataTransfer')) {
var dt = event.dataTransfer;
if (dt.hasOwnProperty('files')) {
dataTransferItemsList = dt.files;
} else if (dt.hasOwnProperty('items')) {
// During the drag even the dataTransfer.files is null
// but Chrome implements some drag store, which is accesible via dataTransfer.items
dataTransferItemsList = dt.items;
}
} else if (event.hasOwnProperty('target')) {
dataTransferItemsList = event.target.files;
}
if (dataTransferItemsList.length > 0) {
dataTransferItemsList = isMultipleAllowed ? dataTransferItemsList : [dataTransferItemsList[0]];
}
// Convert from DataTransferItemsList to the native Array
return Array.prototype.slice.call(dataTransferItemsList);
}
module.exports = exports['default'];
/***/ }

@@ -455,0 +498,0 @@ /******/ ])

@@ -7,5 +7,7 @@ {

"clean": "rimraf ./dist",
"test": "npm run eslint:src && jest --coverage",
"build": "npm run clean && webpack",
"prepublish": "npm run build",
"test": "npm run eslint:src && mocha --require ./mocha-environment.js ./src/test.js",
"prepublish": "NODE_ENV=production npm run build && jest",
"release": "sr-changelog && sr-changelog commit",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"eslint:src": "eslint ./src ./*.js",

@@ -16,5 +18,9 @@ "eslint:fix": "eslint --fix",

"deps": "npm-check -s",
"deps:update": "npm-check -u",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
"deps:update": "npm-check -u"
},
"release": {
"analyzeCommits": "semantic-release-tamia/analyzeCommits",
"generateNotes": "semantic-release-tamia/generateNotes",
"verifyRelease": "semantic-release-tamia/verifyRelease"
},
"lint-staged": {

@@ -29,2 +35,5 @@ "*.js": [

],
"jest": {
"setupTestFrameworkScriptFile": "<rootDir>/testSetup.js"
},
"keywords": [

@@ -60,3 +69,4 @@ "react-component",

"babel-core": "^6.9.1",
"babel-eslint": "^6.0.4",
"babel-eslint": "^7.1.1",
"babel-jest": "^18.0.0",
"babel-loader": "^6.2.2",

@@ -68,30 +78,22 @@ "babel-plugin-add-module-exports": "^0.2.1",

"babel-register": "^6.9.0",
"chai": "^3.4.1",
"cz-conventional-changelog": "^1.2.0",
"eslint": "^2.11.0",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.8.1",
"eslint-plugin-jsx-a11y": "^1.2.2",
"eslint-plugin-react": "^5.1.1",
"jsdom": "^9.2.1",
"enzyme": "^2.6.0",
"eslint": "^3.11.0",
"eslint-config-airbnb": "^13.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.7.1",
"jest": "^18.0.0",
"lint-staged": "^3.2.1",
"mocha": "^2.5.3",
"npm-check": "^5.2.1",
"pre-commit": "^1.1.3",
"react": "^15.2.0",
"react-addons-test-utils": "^15.0.1",
"react-dom": "^15.2.0",
"react-testutils-additions": "^15.0.0",
"react": "^15.4.1",
"react-addons-test-utils": "^15.4.1",
"react-dom": "^15.4.1",
"rimraf": "^2.5.2",
"semantic-release": "^4.3.5",
"semver": "^5.3.0",
"semantic-release": "^6.3.2",
"semantic-release-tamia": "github:okonet/semantic-release-tamia",
"sinon": "^1.17.4",
"webpack": "^1.13.1"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"version": "3.7.3"
"version": "3.7.4"
}

@@ -1,2 +0,3 @@

react-dropzone [![Build Status](https://travis-ci.org/okonet/react-dropzone.svg)](https://travis-ci.org/okonet/react-dropzone) [![npm version](https://badge.fury.io/js/react-dropzone.svg)](https://badge.fury.io/js/react-dropzone)
react-dropzone [![Build Status](https://travis-ci.org/okonet/react-dropzone.svg?branch=master)](https://travis-ci.org/okonet/react-dropzone) [![npm version](https://badge.fury.io/js/react-dropzone.svg)](https://badge.fury.io/js/react-dropzone) [![codecov](https://codecov.io/gh/okonet/react-dropzone/branch/master/graph/badge.svg)](https://codecov.io/gh/okonet/react-dropzone)
==============

@@ -3,0 +4,0 @@

/* eslint prefer-template: 0 */
import React from 'react';
import accepts from 'attr-accept';
import React from 'react';
import getDataTransferItems from './getDataTransferItems';

@@ -50,9 +50,4 @@ const supportMultiple = (typeof document !== 'undefined' && document && document.createElement) ?

// This is tricky. During the drag even the dataTransfer.files is null
// But Chrome implements some drag store, which is accesible via dataTransfer.items
const dataTransferItems = e.dataTransfer && e.dataTransfer.items ? e.dataTransfer.items : [];
const allFilesAccepted = this.allFilesAccepted(getDataTransferItems(e, this.props.multiple));
// Now we need to convert the DataTransferList to Array
const allFilesAccepted = this.allFilesAccepted(Array.prototype.slice.call(dataTransferItems));
this.setState({

@@ -68,3 +63,3 @@ isDragActive: allFilesAccepted,

onDragOver(e) {
onDragOver(e) { // eslint-disable-line class-methods-use-this
e.preventDefault();

@@ -99,2 +94,8 @@ e.stopPropagation();

onDrop(e) {
const { onDrop, onDropAccepted, onDropRejected, multiple, disablePreview } = this.props;
const fileList = getDataTransferItems(e, multiple);
const acceptedFiles = [];
const rejectedFiles = [];
// Stop default browser behavior
e.preventDefault();

@@ -104,18 +105,7 @@

this.enterCounter = 0;
this.isFileDialogActive = false;
this.setState({
isDragActive: false,
isDragReject: false
});
const droppedFiles = e.dataTransfer ? e.dataTransfer.files : e.target.files;
const max = this.props.multiple ? droppedFiles.length : Math.min(droppedFiles.length, 1);
const acceptedFiles = [];
const rejectedFiles = [];
for (let i = 0; i < max; i++) {
const file = droppedFiles[i];
// We might want to disable the preview creation to support big files
if (!this.props.disablePreview) {
file.preview = window.URL.createObjectURL(file);
fileList.forEach((file) => {
if (!disablePreview && accepts(file, 'image/*')) {
file.preview = window.URL.createObjectURL(file); // eslint-disable-line no-param-reassign
}

@@ -128,18 +118,21 @@

}
});
if (onDrop) {
onDrop.call(this, acceptedFiles, rejectedFiles, e);
}
if (this.props.onDrop) {
this.props.onDrop.call(this, acceptedFiles, rejectedFiles, e);
if (rejectedFiles.length > 0 && onDropRejected) {
onDropRejected.call(this, rejectedFiles, e);
}
if (rejectedFiles.length > 0) {
if (this.props.onDropRejected) {
this.props.onDropRejected.call(this, rejectedFiles, e);
}
} else if (acceptedFiles.length > 0) {
if (this.props.onDropAccepted) {
this.props.onDropAccepted.call(this, acceptedFiles, e);
}
if (acceptedFiles.length > 0 && onDropAccepted) {
onDropAccepted.call(this, acceptedFiles, e);
}
this.isFileDialogActive = false;
// Reset drag state
this.setState({
isDragActive: false,
isDragReject: false
});
}

@@ -146,0 +139,0 @@

@@ -10,3 +10,3 @@ /* eslint prefer-template: 0 */

output: {
path: __dirname + '/dist/',
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',

@@ -13,0 +13,0 @@ libraryTarget: 'umd',

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc