rc-upload
Advanced tools
Comparing version 2.3.4 to 2.3.5
# History | ||
---- | ||
### 2.3.5 / 2017-05-01 | ||
- Fix prop-types and create-react-class warning [!67](https://github.com/react-component/upload/pull/67) | ||
### 2.3.4 / 2017-03-10 | ||
@@ -5,0 +9,0 @@ |
@@ -15,2 +15,14 @@ 'use strict'; | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
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'); | ||
@@ -20,2 +32,6 @@ | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _classnames = require('classnames'); | ||
@@ -35,63 +51,51 @@ | ||
/* eslint react/no-is-mounted:0*/ | ||
var AjaxUploader = function (_Component) { | ||
(0, _inherits3["default"])(AjaxUploader, _Component); | ||
var AjaxUploader = _react2["default"].createClass({ | ||
displayName: 'AjaxUploader', | ||
function AjaxUploader() { | ||
var _temp, _this, _ret; | ||
propTypes: { | ||
component: _react.PropTypes.string, | ||
style: _react.PropTypes.object, | ||
prefixCls: _react.PropTypes.string, | ||
className: _react.PropTypes.string, | ||
multiple: _react.PropTypes.bool, | ||
disabled: _react.PropTypes.bool, | ||
accept: _react.PropTypes.string, | ||
children: _react.PropTypes.any, | ||
onStart: _react.PropTypes.func, | ||
data: _react.PropTypes.oneOfType([_react.PropTypes.object, _react.PropTypes.func]), | ||
headers: _react.PropTypes.object, | ||
beforeUpload: _react.PropTypes.func, | ||
customRequest: _react.PropTypes.func, | ||
onProgress: _react.PropTypes.func, | ||
withCredentials: _react.PropTypes.bool | ||
}, | ||
(0, _classCallCheck3["default"])(this, AjaxUploader); | ||
getInitialState: function getInitialState() { | ||
this.reqs = {}; | ||
return { | ||
uid: (0, _uid2["default"])() | ||
}; | ||
}, | ||
componentWillUnmount: function componentWillUnmount() { | ||
this.abort(); | ||
}, | ||
onChange: function onChange(e) { | ||
var files = e.target.files; | ||
this.uploadFiles(files); | ||
this.reset(); | ||
}, | ||
onClick: function onClick() { | ||
var el = this.refs.file; | ||
if (!el) { | ||
return; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
el.click(); | ||
}, | ||
onKeyDown: function onKeyDown(e) { | ||
if (e.key === 'Enter') { | ||
this.onClick(); | ||
} | ||
}, | ||
onFileDrop: function onFileDrop(e) { | ||
if (e.type === 'dragover') { | ||
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3["default"])(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = { uid: (0, _uid2["default"])() }, _this.reqs = {}, _this.onChange = function (e) { | ||
var files = e.target.files; | ||
_this.uploadFiles(files); | ||
_this.reset(); | ||
}, _this.onClick = function () { | ||
var el = _this.refs.file; | ||
if (!el) { | ||
return; | ||
} | ||
el.click(); | ||
}, _this.onKeyDown = function (e) { | ||
if (e.key === 'Enter') { | ||
_this.onClick(); | ||
} | ||
}, _this.onFileDrop = function (e) { | ||
if (e.type === 'dragover') { | ||
e.preventDefault(); | ||
return; | ||
} | ||
var files = e.dataTransfer.files; | ||
_this.uploadFiles(files); | ||
e.preventDefault(); | ||
return; | ||
} | ||
}, _temp), (0, _possibleConstructorReturn3["default"])(_this, _ret); | ||
} | ||
var files = e.dataTransfer.files; | ||
this.uploadFiles(files); | ||
AjaxUploader.prototype.componentDidMount = function componentDidMount() { | ||
this._isMounted = true; | ||
}; | ||
e.preventDefault(); | ||
}, | ||
uploadFiles: function uploadFiles(files) { | ||
AjaxUploader.prototype.componentWillUnmount = function componentWillUnmount() { | ||
this._isMounted = false; | ||
this.abort(); | ||
}; | ||
AjaxUploader.prototype.uploadFiles = function uploadFiles(files) { | ||
var postFiles = Array.prototype.slice.call(files); | ||
@@ -104,6 +108,7 @@ var len = postFiles.length; | ||
} | ||
}, | ||
upload: function upload(file, fileList) { | ||
var _this = this; | ||
}; | ||
AjaxUploader.prototype.upload = function upload(file, fileList) { | ||
var _this2 = this; | ||
var props = this.props; | ||
@@ -114,3 +119,3 @@ | ||
return setTimeout(function () { | ||
return _this.post(file); | ||
return _this2.post(file); | ||
}, 0); | ||
@@ -124,5 +129,5 @@ } | ||
if (processedFileType === '[object File]' || processedFileType === '[object Blob]') { | ||
_this.post(processedFile); | ||
_this2.post(processedFile); | ||
} else { | ||
_this.post(file); | ||
_this2.post(file); | ||
} | ||
@@ -134,10 +139,11 @@ })["catch"](function (e) { | ||
setTimeout(function () { | ||
return _this.post(file); | ||
return _this2.post(file); | ||
}, 0); | ||
} | ||
}, | ||
post: function post(file) { | ||
var _this2 = this; | ||
}; | ||
if (!this.isMounted()) { | ||
AjaxUploader.prototype.post = function post(file) { | ||
var _this3 = this; | ||
if (!this._isMounted) { | ||
return; | ||
@@ -167,7 +173,7 @@ } | ||
onSuccess: function onSuccess(ret) { | ||
delete _this2.reqs[uid]; | ||
delete _this3.reqs[uid]; | ||
props.onSuccess(ret, file); | ||
}, | ||
onError: function onError(err, ret) { | ||
delete _this2.reqs[uid]; | ||
delete _this3.reqs[uid]; | ||
props.onError(err, ret, file); | ||
@@ -177,9 +183,11 @@ } | ||
onStart(file); | ||
}, | ||
reset: function reset() { | ||
}; | ||
AjaxUploader.prototype.reset = function reset() { | ||
this.setState({ | ||
uid: (0, _uid2["default"])() | ||
}); | ||
}, | ||
abort: function abort(file) { | ||
}; | ||
AjaxUploader.prototype.abort = function abort(file) { | ||
var reqs = this.reqs; | ||
@@ -205,4 +213,5 @@ | ||
} | ||
}, | ||
render: function render() { | ||
}; | ||
AjaxUploader.prototype.render = function render() { | ||
var _classNames; | ||
@@ -246,6 +255,25 @@ | ||
); | ||
} | ||
}); | ||
}; | ||
return AjaxUploader; | ||
}(_react.Component); /* eslint react/no-is-mounted:0 react/sort-comp:0 */ | ||
AjaxUploader.propTypes = { | ||
component: _propTypes2["default"].string, | ||
style: _propTypes2["default"].object, | ||
prefixCls: _propTypes2["default"].string, | ||
className: _propTypes2["default"].string, | ||
multiple: _propTypes2["default"].bool, | ||
disabled: _propTypes2["default"].bool, | ||
accept: _propTypes2["default"].string, | ||
children: _propTypes2["default"].any, | ||
onStart: _propTypes2["default"].func, | ||
data: _propTypes2["default"].oneOfType([_propTypes2["default"].object, _propTypes2["default"].func]), | ||
headers: _propTypes2["default"].object, | ||
beforeUpload: _propTypes2["default"].func, | ||
customRequest: _propTypes2["default"].func, | ||
onProgress: _propTypes2["default"].func, | ||
withCredentials: _propTypes2["default"].bool | ||
}; | ||
exports["default"] = AjaxUploader; | ||
module.exports = exports['default']; |
@@ -15,2 +15,14 @@ 'use strict'; | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
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'); | ||
@@ -20,2 +32,6 @@ | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _reactDom = require('react-dom'); | ||
@@ -39,2 +55,3 @@ | ||
/* eslint react/sort-comp:0 */ | ||
var IFRAME_STYLE = { | ||
@@ -50,104 +67,102 @@ position: 'absolute', | ||
// diferent from AjaxUpload, can only upload on at one time, serial seriously | ||
var IframeUploader = _react2["default"].createClass({ | ||
displayName: 'IframeUploader', | ||
propTypes: { | ||
component: _react.PropTypes.string, | ||
style: _react.PropTypes.object, | ||
disabled: _react.PropTypes.bool, | ||
prefixCls: _react.PropTypes.string, | ||
className: _react.PropTypes.string, | ||
accept: _react.PropTypes.string, | ||
onStart: _react.PropTypes.func, | ||
multiple: _react.PropTypes.bool, | ||
children: _react.PropTypes.any, | ||
data: _react.PropTypes.oneOfType([_react.PropTypes.object, _react.PropTypes.func]), | ||
action: _react.PropTypes.string, | ||
name: _react.PropTypes.string | ||
}, | ||
var IframeUploader = function (_Component) { | ||
(0, _inherits3["default"])(IframeUploader, _Component); | ||
getInitialState: function getInitialState() { | ||
this.file = {}; | ||
return { | ||
uploading: false | ||
}; | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
this.updateIframeWH(); | ||
this.initIframe(); | ||
}, | ||
componentDidUpdate: function componentDidUpdate() { | ||
this.updateIframeWH(); | ||
}, | ||
onLoad: function onLoad() { | ||
if (!this.state.uploading) { | ||
return; | ||
function IframeUploader() { | ||
var _temp, _this, _ret; | ||
(0, _classCallCheck3["default"])(this, IframeUploader); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var props = this.props, | ||
file = this.file; | ||
var response = void 0; | ||
try { | ||
var doc = this.getIframeDocument(); | ||
var script = doc.getElementsByTagName('script')[0]; | ||
if (script && script.parentNode === doc.body) { | ||
doc.body.removeChild(script); | ||
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3["default"])(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = { uploading: false }, _this.file = {}, _this.onLoad = function () { | ||
if (!_this.state.uploading) { | ||
return; | ||
} | ||
response = doc.body.innerHTML; | ||
props.onSuccess(response, file); | ||
} catch (err) { | ||
(0, _warning2["default"])(false, 'cross domain error for Upload. Maybe server should return document.domain script. see Note from https://github.com/react-component/upload'); | ||
response = 'cross-domain'; | ||
props.onError(err, null, file); | ||
} | ||
this.endUpload(); | ||
}, | ||
onChange: function onChange() { | ||
var _this = this; | ||
var _this2 = _this, | ||
props = _this2.props, | ||
file = _this2.file; | ||
var target = this.getFormInputNode(); | ||
// ie8/9 don't support FileList Object | ||
// http://stackoverflow.com/questions/12830058/ie8-input-type-file-get-files | ||
var file = this.file = { | ||
uid: (0, _uid2["default"])(), | ||
name: target.value | ||
}; | ||
this.startUpload(); | ||
var props = this.props; | ||
var response = void 0; | ||
try { | ||
var doc = _this.getIframeDocument(); | ||
var script = doc.getElementsByTagName('script')[0]; | ||
if (script && script.parentNode === doc.body) { | ||
doc.body.removeChild(script); | ||
} | ||
response = doc.body.innerHTML; | ||
props.onSuccess(response, file); | ||
} catch (err) { | ||
(0, _warning2["default"])(false, 'cross domain error for Upload. Maybe server should return document.domain script. see Note from https://github.com/react-component/upload'); | ||
response = 'cross-domain'; | ||
props.onError(err, null, file); | ||
} | ||
_this.endUpload(); | ||
}, _this.onChange = function () { | ||
var target = _this.getFormInputNode(); | ||
// ie8/9 don't support FileList Object | ||
// http://stackoverflow.com/questions/12830058/ie8-input-type-file-get-files | ||
var file = _this.file = { | ||
uid: (0, _uid2["default"])(), | ||
name: target.value | ||
}; | ||
_this.startUpload(); | ||
var _this3 = _this, | ||
props = _this3.props; | ||
if (!props.beforeUpload) { | ||
return this.post(file); | ||
} | ||
var before = props.beforeUpload(file); | ||
if (before && before.then) { | ||
before.then(function () { | ||
if (!props.beforeUpload) { | ||
return _this.post(file); | ||
} | ||
var before = props.beforeUpload(file); | ||
if (before && before.then) { | ||
before.then(function () { | ||
_this.post(file); | ||
}, function () { | ||
_this.endUpload(); | ||
}); | ||
} else if (before !== false) { | ||
_this.post(file); | ||
}, function () { | ||
} else { | ||
_this.endUpload(); | ||
}); | ||
} else if (before !== false) { | ||
this.post(file); | ||
} else { | ||
this.endUpload(); | ||
} | ||
}, | ||
getIframeNode: function getIframeNode() { | ||
} | ||
}, _temp), (0, _possibleConstructorReturn3["default"])(_this, _ret); | ||
} | ||
IframeUploader.prototype.componentDidMount = function componentDidMount() { | ||
this.updateIframeWH(); | ||
this.initIframe(); | ||
}; | ||
IframeUploader.prototype.componentDidUpdate = function componentDidUpdate() { | ||
this.updateIframeWH(); | ||
}; | ||
IframeUploader.prototype.getIframeNode = function getIframeNode() { | ||
return this.refs.iframe; | ||
}, | ||
getIframeDocument: function getIframeDocument() { | ||
}; | ||
IframeUploader.prototype.getIframeDocument = function getIframeDocument() { | ||
return this.getIframeNode().contentDocument; | ||
}, | ||
getFormNode: function getFormNode() { | ||
}; | ||
IframeUploader.prototype.getFormNode = function getFormNode() { | ||
return this.getIframeDocument().getElementById('form'); | ||
}, | ||
getFormInputNode: function getFormInputNode() { | ||
}; | ||
IframeUploader.prototype.getFormInputNode = function getFormInputNode() { | ||
return this.getIframeDocument().getElementById('input'); | ||
}, | ||
getFormDataNode: function getFormDataNode() { | ||
}; | ||
IframeUploader.prototype.getFormDataNode = function getFormDataNode() { | ||
return this.getIframeDocument().getElementById('data'); | ||
}, | ||
getFileForMultiple: function getFileForMultiple(file) { | ||
}; | ||
IframeUploader.prototype.getFileForMultiple = function getFileForMultiple(file) { | ||
return this.props.multiple ? [file] : file; | ||
}, | ||
getIframeHTML: function getIframeHTML(domain) { | ||
}; | ||
IframeUploader.prototype.getIframeHTML = function getIframeHTML(domain) { | ||
var domainScript = ''; | ||
@@ -161,9 +176,11 @@ var domainInput = ''; | ||
return '\n <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv="X-UA-Compatible" content="IE=edge" />\n <style>\n body,html {padding:0;margin:0;border:0;overflow:hidden;}\n </style>\n ' + domainScript + '\n </head>\n <body>\n <form method="post"\n encType="multipart/form-data"\n action="' + this.props.action + '" id="form"\n style="display:block;height:9999px;position:relative;overflow:hidden;">\n <input id="input" type="file"\n name="' + this.props.name + '"\n style="position:absolute;top:0;right:0;height:9999px;font-size:9999px;cursor:pointer;"/>\n ' + domainInput + '\n <span id="data"></span>\n </form>\n </body>\n </html>\n '; | ||
}, | ||
initIframeSrc: function initIframeSrc() { | ||
}; | ||
IframeUploader.prototype.initIframeSrc = function initIframeSrc() { | ||
if (this.domain) { | ||
this.getIframeNode().src = 'javascript:void((function(){\n var d = document;\n d.open();\n d.domain=\'' + this.domain + '\';\n d.write(\'\');\n d.close();\n })())'; | ||
} | ||
}, | ||
initIframe: function initIframe() { | ||
}; | ||
IframeUploader.prototype.initIframe = function initIframe() { | ||
var iframeNode = this.getIframeNode(); | ||
@@ -186,4 +203,5 @@ var win = iframeNode.contentWindow; | ||
this.getFormInputNode().onchange = this.onChange; | ||
}, | ||
endUpload: function endUpload() { | ||
}; | ||
IframeUploader.prototype.endUpload = function endUpload() { | ||
if (this.state.uploading) { | ||
@@ -198,4 +216,5 @@ this.file = {}; | ||
} | ||
}, | ||
startUpload: function startUpload() { | ||
}; | ||
IframeUploader.prototype.startUpload = function startUpload() { | ||
if (!this.state.uploading) { | ||
@@ -207,4 +226,5 @@ this.state.uploading = true; | ||
} | ||
}, | ||
updateIframeWH: function updateIframeWH() { | ||
}; | ||
IframeUploader.prototype.updateIframeWH = function updateIframeWH() { | ||
var rootNode = _reactDom2["default"].findDOMNode(this); | ||
@@ -214,4 +234,5 @@ var iframeNode = this.getIframeNode(); | ||
iframeNode.style.width = rootNode.offsetWidth + 'px'; | ||
}, | ||
abort: function abort(file) { | ||
}; | ||
IframeUploader.prototype.abort = function abort(file) { | ||
if (file) { | ||
@@ -228,4 +249,5 @@ var uid = file; | ||
} | ||
}, | ||
post: function post(file) { | ||
}; | ||
IframeUploader.prototype.post = function post(file) { | ||
var formNode = this.getFormNode(); | ||
@@ -249,4 +271,5 @@ var dataSpan = this.getFormDataNode(); | ||
onStart(file); | ||
}, | ||
render: function render() { | ||
}; | ||
IframeUploader.prototype.render = function render() { | ||
var _classNames; | ||
@@ -279,6 +302,22 @@ | ||
); | ||
} | ||
}); | ||
}; | ||
return IframeUploader; | ||
}(_react.Component); | ||
IframeUploader.propTypes = { | ||
component: _propTypes2["default"].string, | ||
style: _propTypes2["default"].object, | ||
disabled: _propTypes2["default"].bool, | ||
prefixCls: _propTypes2["default"].string, | ||
className: _propTypes2["default"].string, | ||
accept: _propTypes2["default"].string, | ||
onStart: _propTypes2["default"].func, | ||
multiple: _propTypes2["default"].bool, | ||
children: _propTypes2["default"].any, | ||
data: _propTypes2["default"].oneOfType([_propTypes2["default"].object, _propTypes2["default"].func]), | ||
action: _propTypes2["default"].string, | ||
name: _propTypes2["default"].string | ||
}; | ||
exports["default"] = IframeUploader; | ||
module.exports = exports['default']; |
'use strict'; | ||
// export this package's api | ||
module.exports = require('./Upload'); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _Upload = require('./Upload'); | ||
var _Upload2 = _interopRequireDefault(_Upload); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
exports["default"] = _Upload2["default"]; // export this package's api | ||
module.exports = exports['default']; |
@@ -11,2 +11,14 @@ 'use strict'; | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
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'); | ||
@@ -16,2 +28,6 @@ | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _AjaxUploader = require('./AjaxUploader'); | ||
@@ -29,53 +45,20 @@ | ||
var Upload = _react2["default"].createClass({ | ||
displayName: 'Upload', | ||
var Upload = function (_Component) { | ||
(0, _inherits3["default"])(Upload, _Component); | ||
propTypes: { | ||
component: _react.PropTypes.string, | ||
style: _react.PropTypes.object, | ||
prefixCls: _react.PropTypes.string, | ||
action: _react.PropTypes.string, | ||
name: _react.PropTypes.string, | ||
multipart: _react.PropTypes.bool, | ||
onError: _react.PropTypes.func, | ||
onSuccess: _react.PropTypes.func, | ||
onProgress: _react.PropTypes.func, | ||
onStart: _react.PropTypes.func, | ||
data: _react.PropTypes.oneOfType([_react.PropTypes.object, _react.PropTypes.func]), | ||
headers: _react.PropTypes.object, | ||
accept: _react.PropTypes.string, | ||
multiple: _react.PropTypes.bool, | ||
disabled: _react.PropTypes.bool, | ||
beforeUpload: _react.PropTypes.func, | ||
customRequest: _react.PropTypes.func, | ||
onReady: _react.PropTypes.func, | ||
withCredentials: _react.PropTypes.bool, | ||
supportServerRender: _react.PropTypes.bool | ||
}, | ||
function Upload() { | ||
var _temp, _this, _ret; | ||
getDefaultProps: function getDefaultProps() { | ||
return { | ||
component: 'span', | ||
prefixCls: 'rc-upload', | ||
data: {}, | ||
headers: {}, | ||
name: 'file', | ||
multipart: false, | ||
onReady: empty, | ||
onStart: empty, | ||
onError: empty, | ||
onSuccess: empty, | ||
supportServerRender: false, | ||
multiple: false, | ||
beforeUpload: null, | ||
customRequest: null, | ||
withCredentials: false | ||
}; | ||
}, | ||
getInitialState: function getInitialState() { | ||
return { | ||
(0, _classCallCheck3["default"])(this, Upload); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3["default"])(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = { | ||
Component: null | ||
}; | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
}, _temp), (0, _possibleConstructorReturn3["default"])(_this, _ret); | ||
} | ||
Upload.prototype.componentDidMount = function componentDidMount() { | ||
if (this.props.supportServerRender) { | ||
@@ -87,24 +70,67 @@ /* eslint react/no-did-mount-set-state:0 */ | ||
} | ||
}, | ||
getComponent: function getComponent() { | ||
}; | ||
Upload.prototype.getComponent = function getComponent() { | ||
return typeof FormData !== 'undefined' ? _AjaxUploader2["default"] : _IframeUploader2["default"]; | ||
}, | ||
abort: function abort(file) { | ||
}; | ||
Upload.prototype.abort = function abort(file) { | ||
this.refs.inner.abort(file); | ||
}, | ||
render: function render() { | ||
}; | ||
Upload.prototype.render = function render() { | ||
if (this.props.supportServerRender) { | ||
var _Component = this.state.Component; | ||
if (_Component) { | ||
return _react2["default"].createElement(_Component, (0, _extends3["default"])({}, this.props, { ref: 'inner' })); | ||
var _ComponentUploader = this.state.Component; | ||
if (_ComponentUploader) { | ||
return _react2["default"].createElement(_ComponentUploader, (0, _extends3["default"])({}, this.props, { ref: 'inner' })); | ||
} | ||
return null; | ||
} | ||
var Component = this.getComponent(); | ||
return _react2["default"].createElement(Component, (0, _extends3["default"])({}, this.props, { ref: 'inner' })); | ||
} | ||
}); | ||
var ComponentUploader = this.getComponent(); | ||
return _react2["default"].createElement(ComponentUploader, (0, _extends3["default"])({}, this.props, { ref: 'inner' })); | ||
}; | ||
return Upload; | ||
}(_react.Component); | ||
Upload.propTypes = { | ||
component: _propTypes2["default"].string, | ||
style: _propTypes2["default"].object, | ||
prefixCls: _propTypes2["default"].string, | ||
action: _propTypes2["default"].string, | ||
name: _propTypes2["default"].string, | ||
multipart: _propTypes2["default"].bool, | ||
onError: _propTypes2["default"].func, | ||
onSuccess: _propTypes2["default"].func, | ||
onProgress: _propTypes2["default"].func, | ||
onStart: _propTypes2["default"].func, | ||
data: _propTypes2["default"].oneOfType([_propTypes2["default"].object, _propTypes2["default"].func]), | ||
headers: _propTypes2["default"].object, | ||
accept: _propTypes2["default"].string, | ||
multiple: _propTypes2["default"].bool, | ||
disabled: _propTypes2["default"].bool, | ||
beforeUpload: _propTypes2["default"].func, | ||
customRequest: _propTypes2["default"].func, | ||
onReady: _propTypes2["default"].func, | ||
withCredentials: _propTypes2["default"].bool, | ||
supportServerRender: _propTypes2["default"].bool | ||
}; | ||
Upload.defaultProps = { | ||
component: 'span', | ||
prefixCls: 'rc-upload', | ||
data: {}, | ||
headers: {}, | ||
name: 'file', | ||
multipart: false, | ||
onReady: empty, | ||
onStart: empty, | ||
onError: empty, | ||
onSuccess: empty, | ||
supportServerRender: false, | ||
multiple: false, | ||
beforeUpload: null, | ||
customRequest: null, | ||
withCredentials: false | ||
}; | ||
exports["default"] = Upload; | ||
module.exports = exports['default']; |
{ | ||
"name": "rc-upload", | ||
"version": "2.3.4", | ||
"version": "2.3.5", | ||
"description": "upload ui component for react", | ||
@@ -55,4 +55,5 @@ "keywords": [ | ||
"classnames": "^2.2.5", | ||
"warning": "2.x" | ||
"warning": "2.x", | ||
"prop-types": "^15.5.7" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33504
682
4
+ Addedprop-types@^15.5.7
+ Addedobject-assign@4.1.1(transitive)
+ Addedprop-types@15.8.1(transitive)
+ Addedreact-is@16.13.1(transitive)