New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zan-upload

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zan-upload - npm Package Compare versions

Comparing version 5.0.0 to 5.0.1

86

lib/components/FileInput.js

@@ -6,4 +6,6 @@ 'use strict';

});
exports['default'] = FileInput;
exports['default'] = undefined;
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 _react = require('react');

@@ -13,2 +15,8 @@

var _toArray = require('lodash/toArray');
var _toArray2 = _interopRequireDefault(_toArray);
var _utils = require('../utils');
var _UploadLocal = require('./UploadLocal');

@@ -20,15 +28,67 @@

/**
* 上传图片输入框
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function FileInput(props) {
return _react2['default'].createElement('input', {
type: 'file',
placeholder: '\u6DFB\u52A0 +',
multiple: props.maxAmount !== 1,
accept: props.accept,
onChange: props.onChange || _UploadLocal2['default'].bind(this, props)
});
}
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; } /**
* 上传图片输入框
*/
var FileInput = function (_ref) {
_inherits(FileInput, _ref);
function FileInput() {
var _ref2;
var _temp, _this, _ret;
_classCallCheck(this, FileInput);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref2 = FileInput.__proto__ || Object.getPrototypeOf(FileInput)).call.apply(_ref2, [this].concat(args))), _this), _this.onFileChange = function (evt) {
var onChange = _this.props.onChange;
var files = (0, _toArray2['default'])(evt.target.files);
if (onChange) {
onChange.call(_this, evt);
} else {
(0, _UploadLocal2['default'])(_this.props, {
localFiles: files.map(function (f) {
return { file: f, src: (0, _utils.createObjectURL)(f) };
})
});
}
// 清楚当前的值,否则选同一张图片不会触发事件
evt.target.value = null;
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(FileInput, [{
key: 'render',
value: function render() {
var _props = this.props,
maxAmount = _props.maxAmount,
accept = _props.accept;
return _react2['default'].createElement('input', {
type: 'file',
placeholder: '\u6DFB\u52A0 +',
multiple: maxAmount !== 1,
accept: accept,
onChange: this.onFileChange
});
}
}]);
return FileInput;
}(_react.PureComponent || _react.Component);
exports['default'] = FileInput;
module.exports = exports['default'];

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

exports.base64ToArrayBuffer = base64ToArrayBuffer;
exports.createObjectURL = createObjectURL;

@@ -126,2 +127,6 @@ 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; }

return bytes.buffer;
}
function createObjectURL(object) {
return window.URL ? window.URL.createObjectURL(object) : window.webkitURL.createObjectURL(object);
}

2

package.json
{
"name": "zan-upload",
"version": "5.0.0",
"version": "5.0.1",
"description": "这是一个React组件",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -284,1 +284,5 @@ ## zan-upload

- 将 tokenUrl 和 fetchUrl 两个属性的默认值设置为'',非必填
#### 5.0.1 (2017-11-20)
- 修复无法上传同一张图片的bug

Sorry, the diff of this file is too big to display

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