Socket
Socket
Sign inDemoInstall

rc-upload

Package Overview
Dependencies
Maintainers
3
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 1.12.0 to 1.13.0

5

HISTORY.md
# History
----
### 1.13.0 / 2016-06-02
- add disabled state
- https://github.com/react-component/upload/issues/37
### 1.12.0 2016-05-10

@@ -5,0 +10,0 @@

57

lib/AjaxUploader.js

@@ -21,2 +21,6 @@ 'use strict';

function preventDefault(e) {
e.preventDefault();
}
var AjaxUploader = _react2['default'].createClass({

@@ -26,2 +30,3 @@ displayName: 'AjaxUploader',

propTypes: {
prefixCls: _react.PropTypes.string,
multiple: _react.PropTypes.bool,

@@ -35,3 +40,13 @@ onStart: _react.PropTypes.func,

getInitialState: function getInitialState() {
return { disabled: false };
},
onChange: function onChange(e) {
if (this.state.disabled) {
return;
}
this.setState({
disabled: true
});
var files = e.target.files;

@@ -47,3 +62,2 @@ this.uploadFiles(files);

el.click();
el.value = '';
},

@@ -59,5 +73,10 @@

if (e.type === 'dragover') {
return e.preventDefault();
e.preventDefault();
return;
}
if (this.state.disabled) {
return;
}
var files = e.dataTransfer.files;

@@ -104,2 +123,4 @@ this.uploadFiles(files);

post: function post(file) {
var _this2 = this;
var props = this.props;

@@ -123,5 +144,7 @@ var data = props.data;

props.onSuccess(ret, file);
_this2._reset();
},
onError: function onError(err, ret) {
props.onError(err, ret, file);
_this2._reset();
}

@@ -131,4 +154,10 @@ });

_reset: function _reset() {
this.refs.form.reset();
this.setState({
disabled: false
});
},
render: function render() {
var hidden = { display: 'none' };
var props = this.props;

@@ -143,10 +172,18 @@ return _react2['default'].createElement(

role: 'button',
tabIndex: '0'
tabIndex: '0',
className: this.state.disabled ? this.props.prefixCls + ' ' + props.prefixCls + '-disabled' : '' + this.props.prefixCls
},
_react2['default'].createElement('input', { type: 'file',
ref: 'file',
style: hidden,
accept: props.accept,
multiple: this.props.multiple,
onChange: this.onChange }),
_react2['default'].createElement(
'form',
{ ref: 'form', onSubmit: preventDefault },
_react2['default'].createElement('input', {
type: 'file',
ref: 'file',
disabled: this.state.disabled,
style: { display: 'none' },
accept: props.accept,
multiple: this.props.multiple,
onChange: this.onChange
})
),
props.children

@@ -153,0 +190,0 @@ );

37

lib/IframeUploader.js

@@ -7,2 +7,4 @@ 'use strict';

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; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

@@ -38,2 +40,3 @@

propTypes: {
prefixCls: _react.PropTypes.string,
onStart: _react.PropTypes.func,

@@ -47,2 +50,6 @@ multiple: _react.PropTypes.bool,

getInitialState: function getInitialState() {
return { disabled: false };
},
componentDidMount: function componentDidMount() {

@@ -58,3 +65,3 @@ this.updateIframeWH();

onLoad: function onLoad() {
if (!this.loading) {
if (this.state.disabled) {
return;

@@ -170,9 +177,15 @@ }

enableIframe: function enableIframe() {
this.loading = false;
this.getIframeNode().style.display = '';
if (this.state.disabled) {
this.setState({
disabled: false
});
}
},
disabledIframe: function disabledIframe() {
this.loading = true;
this.getIframeNode().style.display = 'none';
if (!this.state.disabled) {
this.setState({
disabled: true
});
}
},

@@ -188,8 +201,16 @@

render: function render() {
var style = _extends({}, iframeStyle, {
display: this.state.disabled ? 'none' : ''
});
return _react2['default'].createElement(
'span',
{ style: { position: 'relative', zIndex: 0 } },
_react2['default'].createElement('iframe', { ref: 'iframe',
{
className: this.state.disabled ? this.props.prefixCls + ' ' + this.props.prefixCls + '-disabled' : '' + this.props.prefixCls,
style: { position: 'relative', zIndex: 0 }
},
_react2['default'].createElement('iframe', {
ref: 'iframe',
onLoad: this.onLoad,
style: iframeStyle }),
style: style
}),
this.props.children

@@ -196,0 +217,0 @@ );

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

propTypes: {
prefixCls: _react.PropTypes.string,
action: _react.PropTypes.string,

@@ -47,2 +48,3 @@ name: _react.PropTypes.string,

return {
prefixCls: 'rc-upload',
data: {},

@@ -49,0 +51,0 @@ headers: {},

{
"name": "rc-upload",
"version": "1.12.0",
"version": "1.13.0",
"description": "upload ui component for react",

@@ -5,0 +5,0 @@ "keywords": [

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