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

rc-upload

Package Overview
Dependencies
Maintainers
5
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-upload - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

28

es/AjaxUploader.js

@@ -1,9 +0,17 @@

import _extends from 'babel-runtime/helpers/extends';
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import _slicedToArray from 'babel-runtime/helpers/slicedToArray';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/* eslint react/no-is-mounted:0,react/sort-comp:0,react/prop-types:0 */

@@ -132,3 +140,4 @@ import React, { Component } from 'react';

})['catch'](function (e) {
console && console.log(e); // eslint-disable-line
// eslint-disable-next-line no-console
console.log(e);
});

@@ -140,2 +149,3 @@ } else if (before !== false) {

}
return undefined;
}

@@ -142,0 +152,0 @@ }, {

@@ -35,2 +35,3 @@ function getError(option, xhr) {

export default function upload(option) {
// eslint-disable-next-line no-undef
var xhr = new XMLHttpRequest();

@@ -47,2 +48,3 @@

// eslint-disable-next-line no-undef
var formData = new FormData();

@@ -67,2 +69,3 @@

// eslint-disable-next-line no-undef
if (option.file instanceof Blob) {

@@ -85,3 +88,3 @@ formData.append(option.filename, option.file, option.file.name);

option.onSuccess(getBody(xhr), xhr);
return option.onSuccess(getBody(xhr), xhr);
};

@@ -104,7 +107,8 @@

for (var h in headers) {
if (headers.hasOwnProperty(h) && headers[h] !== null) {
Object.keys(headers).forEach(function (h) {
if (headers[h] !== null) {
xhr.setRequestHeader(h, headers[h]);
}
}
});
xhr.send(formData);

@@ -111,0 +115,0 @@

@@ -55,28 +55,7 @@ function loopFiles(item, callback) {

};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var file = _step.value;
_traverseFileTree(file.webkitGetAsEntry());
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator['return']) {
_iterator['return']();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
files.forEach(function (file) {
_traverseFileTree(file.webkitGetAsEntry());
});
};
export default traverseFileTree;

@@ -1,6 +0,11 @@

import _extends from 'babel-runtime/helpers/extends';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/* eslint react/prop-types:0 */

@@ -7,0 +12,0 @@ import React, { Component } from 'react';

@@ -7,34 +7,8 @@ 'use strict';

var _extends2 = require('babel-runtime/helpers/extends');
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _extends3 = _interopRequireDefault(_extends2);
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = require('react');

@@ -66,3 +40,13 @@

/* eslint react/no-is-mounted:0,react/sort-comp:0,react/prop-types:0 */
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint react/no-is-mounted:0,react/sort-comp:0,react/prop-types:0 */
var dataOrAriaAttributeProps = function dataOrAriaAttributeProps(props) {

@@ -78,3 +62,3 @@ return Object.keys(props).reduce(function (acc, key) {

var AjaxUploader = function (_Component) {
(0, _inherits3['default'])(AjaxUploader, _Component);
_inherits(AjaxUploader, _Component);

@@ -86,3 +70,3 @@ function AjaxUploader() {

(0, _classCallCheck3['default'])(this, AjaxUploader);
_classCallCheck(this, AjaxUploader);

@@ -93,3 +77,3 @@ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {

return _ret = (_temp = (_this = (0, _possibleConstructorReturn3['default'])(this, (_ref = AjaxUploader.__proto__ || Object.getPrototypeOf(AjaxUploader)).call.apply(_ref, [this].concat(args))), _this), _this.state = { uid: (0, _uid2['default'])() }, _this.reqs = {}, _this.onChange = function (e) {
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = AjaxUploader.__proto__ || Object.getPrototypeOf(AjaxUploader)).call.apply(_ref, [this].concat(args))), _this), _this.state = { uid: (0, _uid2['default'])() }, _this.reqs = {}, _this.onChange = function (e) {
var files = e.target.files;

@@ -149,6 +133,6 @@ _this.uploadFiles(files);

_this.fileInput = node;
}, _temp), (0, _possibleConstructorReturn3['default'])(_this, _ret);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
(0, _createClass3['default'])(AjaxUploader, [{
_createClass(AjaxUploader, [{
key: 'componentDidMount',

@@ -187,3 +171,4 @@ value: function componentDidMount() {

})['catch'](function (e) {
console && console.log(e); // eslint-disable-line
// eslint-disable-next-line no-console
console.log(e);
});

@@ -195,2 +180,3 @@ } else if (before !== false) {

}
return undefined;
}

@@ -226,3 +212,3 @@ }, {

}).then(function (_ref2) {
var _ref3 = (0, _slicedToArray3['default'])(_ref2, 2),
var _ref3 = _slicedToArray(_ref2, 2),
action = _ref3[0],

@@ -311,5 +297,5 @@ data = _ref3[1];

openFileDialogOnClick = _props.openFileDialogOnClick,
otherProps = (0, _objectWithoutProperties3['default'])(_props, ['component', 'prefixCls', 'className', 'disabled', 'id', 'style', 'multiple', 'accept', 'children', 'directory', 'openFileDialogOnClick']);
otherProps = _objectWithoutProperties(_props, ['component', 'prefixCls', 'className', 'disabled', 'id', 'style', 'multiple', 'accept', 'children', 'directory', 'openFileDialogOnClick']);
var cls = (0, _classnames2['default'])((_classNames = {}, (0, _defineProperty3['default'])(_classNames, prefixCls, true), (0, _defineProperty3['default'])(_classNames, prefixCls + '-disabled', disabled), (0, _defineProperty3['default'])(_classNames, className, className), _classNames));
var cls = (0, _classnames2['default'])((_classNames = {}, _defineProperty(_classNames, prefixCls, true), _defineProperty(_classNames, prefixCls + '-disabled', disabled), _defineProperty(_classNames, className, className), _classNames));
var events = disabled ? {} : {

@@ -324,3 +310,3 @@ onClick: openFileDialogOnClick ? this.onClick : function () {},

Tag,
(0, _extends3['default'])({}, events, {
_extends({}, events, {
className: cls,

@@ -330,3 +316,3 @@ role: 'button',

}),
_react2['default'].createElement('input', (0, _extends3['default'])({}, dataOrAriaAttributeProps(otherProps), {
_react2['default'].createElement('input', _extends({}, dataOrAriaAttributeProps(otherProps), {
id: id,

@@ -350,2 +336,3 @@ type: 'file',

}]);
return AjaxUploader;

@@ -352,0 +339,0 @@ }(_react.Component);

@@ -41,2 +41,3 @@ 'use strict';

function upload(option) {
// eslint-disable-next-line no-undef
var xhr = new XMLHttpRequest();

@@ -53,2 +54,3 @@

// eslint-disable-next-line no-undef
var formData = new FormData();

@@ -73,2 +75,3 @@

// eslint-disable-next-line no-undef
if (option.file instanceof Blob) {

@@ -91,3 +94,3 @@ formData.append(option.filename, option.file, option.file.name);

option.onSuccess(getBody(xhr), xhr);
return option.onSuccess(getBody(xhr), xhr);
};

@@ -110,7 +113,8 @@

for (var h in headers) {
if (headers.hasOwnProperty(h) && headers[h] !== null) {
Object.keys(headers).forEach(function (h) {
if (headers[h] !== null) {
xhr.setRequestHeader(h, headers[h]);
}
}
});
xhr.send(formData);

@@ -117,0 +121,0 @@

@@ -60,26 +60,5 @@ 'use strict';

};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var file = _step.value;
_traverseFileTree(file.webkitGetAsEntry());
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator['return']) {
_iterator['return']();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
files.forEach(function (file) {
_traverseFileTree(file.webkitGetAsEntry());
});
};

@@ -86,0 +65,0 @@

@@ -7,22 +7,6 @@ 'use strict';

var _extends2 = require('babel-runtime/helpers/extends');
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _extends3 = _interopRequireDefault(_extends2);
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _react = require('react');

@@ -38,7 +22,13 @@

/* eslint react/prop-types:0 */
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint react/prop-types:0 */
function empty() {}
var Upload = function (_Component) {
(0, _inherits3['default'])(Upload, _Component);
_inherits(Upload, _Component);

@@ -50,3 +40,3 @@ function Upload() {

(0, _classCallCheck3['default'])(this, Upload);
_classCallCheck(this, Upload);

@@ -57,8 +47,8 @@ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {

return _ret = (_temp = (_this = (0, _possibleConstructorReturn3['default'])(this, (_ref = Upload.__proto__ || Object.getPrototypeOf(Upload)).call.apply(_ref, [this].concat(args))), _this), _this.saveUploader = function (node) {
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Upload.__proto__ || Object.getPrototypeOf(Upload)).call.apply(_ref, [this].concat(args))), _this), _this.saveUploader = function (node) {
_this.uploader = node;
}, _temp), (0, _possibleConstructorReturn3['default'])(_this, _ret);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
(0, _createClass3['default'])(Upload, [{
_createClass(Upload, [{
key: 'abort',

@@ -71,5 +61,6 @@ value: function abort(file) {

value: function render() {
return _react2['default'].createElement(_AjaxUploader2['default'], (0, _extends3['default'])({}, this.props, { ref: this.saveUploader }));
return _react2['default'].createElement(_AjaxUploader2['default'], _extends({}, this.props, { ref: this.saveUploader }));
}
}]);
return Upload;

@@ -76,0 +67,0 @@ }(_react.Component);

{
"name": "rc-upload",
"version": "3.1.0",
"version": "3.1.1",
"description": "upload ui component for react",

@@ -33,4 +33,4 @@ "keywords": [

"start": "node server",
"compile": "rc-tools run compile --babel-runtime",
"pub": "rc-tools run pub --babel-runtime",
"compile": "rc-tools run compile",
"pub": "rc-tools run pub",
"lint": "rc-tools run lint",

@@ -50,6 +50,6 @@ "test": "jest --setupTestFrameworkScriptFile=raf/polyfill",

"raf": "^3.4.0",
"rc-tools": "6.x",
"rc-tools": "8.x",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"sinon": "8.1.1",
"sinon": "^9.0.2",
"vinyl-fs": "^3.0.3"

@@ -61,3 +61,2 @@ },

"dependencies": {
"babel-runtime": "6.x",
"classnames": "^2.2.5"

@@ -64,0 +63,0 @@ },

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