rc-upload
Advanced tools
Comparing version 2.0.0 to 2.0.1
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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 _extends2 = require('babel-runtime/helpers/extends'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
@@ -23,3 +23,5 @@ var _request = require('./request'); | ||
var AjaxUploader = _react2['default'].createClass({ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var AjaxUploader = _react2["default"].createClass({ | ||
displayName: 'AjaxUploader', | ||
@@ -45,6 +47,5 @@ | ||
return { | ||
uid: (0, _uid2['default'])() | ||
uid: (0, _uid2["default"])() | ||
}; | ||
}, | ||
onChange: function onChange(e) { | ||
@@ -55,3 +56,2 @@ var files = e.target.files; | ||
}, | ||
onClick: function onClick() { | ||
@@ -64,3 +64,2 @@ var el = this.refs.file; | ||
}, | ||
onKeyDown: function onKeyDown(e) { | ||
@@ -71,3 +70,2 @@ if (e.key === 'Enter') { | ||
}, | ||
onFileDrop: function onFileDrop(e) { | ||
@@ -84,3 +82,2 @@ if (e.type === 'dragover') { | ||
}, | ||
uploadFiles: function uploadFiles(files) { | ||
@@ -91,7 +88,6 @@ var postFiles = Array.prototype.slice.call(files); | ||
var file = postFiles[i]; | ||
file.uid = (0, _uid2['default'])(); | ||
file.uid = (0, _uid2["default"])(); | ||
this.upload(file); | ||
} | ||
}, | ||
upload: function upload(file) { | ||
@@ -119,3 +115,2 @@ var _this = this; | ||
}, | ||
post: function post(file) { | ||
@@ -133,3 +128,3 @@ var _this2 = this; | ||
this.reqs[uid] = (0, _request2['default'])({ | ||
this.reqs[uid] = (0, _request2["default"])({ | ||
action: props.action, | ||
@@ -155,9 +150,7 @@ filename: props.name, | ||
}, | ||
reset: function reset() { | ||
this.setState({ | ||
uid: (0, _uid2['default'])() | ||
uid: (0, _uid2["default"])() | ||
}); | ||
}, | ||
abort: function abort(file) { | ||
@@ -182,3 +175,2 @@ var reqs = this.reqs; | ||
}, | ||
render: function render() { | ||
@@ -204,9 +196,9 @@ var _props = this.props; | ||
}; | ||
return _react2['default'].createElement( | ||
return _react2["default"].createElement( | ||
Tag, | ||
_extends({}, events, { | ||
(0, _extends3["default"])({}, events, { | ||
role: 'button', | ||
style: style | ||
}), | ||
_react2['default'].createElement('input', { | ||
_react2["default"].createElement('input', { | ||
type: 'file', | ||
@@ -225,3 +217,3 @@ ref: 'file', | ||
exports['default'] = AjaxUploader; | ||
exports["default"] = AjaxUploader; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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 _extends2 = require('babel-runtime/helpers/extends'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
@@ -27,2 +27,4 @@ var _react = require('react'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var IFRAME_STYLE = { | ||
@@ -38,3 +40,3 @@ position: 'absolute', | ||
// diferent from AjaxUpload, can only upload on at one time, serial seriously | ||
var IframeUploader = _react2['default'].createClass({ | ||
var IframeUploader = _react2["default"].createClass({ | ||
displayName: 'IframeUploader', | ||
@@ -62,3 +64,2 @@ | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
@@ -68,7 +69,5 @@ this.updateIframeWH(); | ||
}, | ||
componentDidUpdate: function componentDidUpdate() { | ||
this.updateIframeWH(); | ||
}, | ||
onLoad: function onLoad() { | ||
@@ -81,3 +80,3 @@ if (!this.state.uploading) { | ||
var response = undefined; | ||
var response = void 0; | ||
try { | ||
@@ -92,3 +91,3 @@ var doc = this.getIframeDocument(); | ||
} 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'); | ||
(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'; | ||
@@ -99,3 +98,2 @@ props.onError(err, null, file); | ||
}, | ||
onChange: function onChange() { | ||
@@ -108,3 +106,3 @@ var _this = this; | ||
var file = this.file = { | ||
uid: (0, _uid2['default'])(), | ||
uid: (0, _uid2["default"])(), | ||
name: target.value | ||
@@ -131,27 +129,20 @@ }; | ||
}, | ||
getIframeNode: function getIframeNode() { | ||
return this.refs.iframe; | ||
}, | ||
getIframeDocument: function getIframeDocument() { | ||
return this.getIframeNode().contentDocument; | ||
}, | ||
getFormNode: function getFormNode() { | ||
return this.getIframeDocument().getElementById('form'); | ||
}, | ||
getFormInputNode: function getFormInputNode() { | ||
return this.getIframeDocument().getElementById('input'); | ||
}, | ||
getFormDataNode: function getFormDataNode() { | ||
return this.getIframeDocument().getElementById('data'); | ||
}, | ||
getFileForMultiple: function getFileForMultiple(file) { | ||
return this.props.multiple ? [file] : file; | ||
}, | ||
getIframeHTML: function getIframeHTML(domain) { | ||
@@ -164,5 +155,4 @@ var domainScript = ''; | ||
} | ||
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" 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 '; | ||
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() { | ||
@@ -173,7 +163,6 @@ if (this.domain) { | ||
}, | ||
initIframe: function initIframe() { | ||
var iframeNode = this.getIframeNode(); | ||
var win = iframeNode.contentWindow; | ||
var doc = undefined; | ||
var doc = void 0; | ||
this.domain = this.domain || ''; | ||
@@ -194,3 +183,2 @@ this.initIframeSrc(); | ||
}, | ||
endUpload: function endUpload() { | ||
@@ -207,3 +195,2 @@ if (this.state.uploading) { | ||
}, | ||
startUpload: function startUpload() { | ||
@@ -217,5 +204,4 @@ if (!this.state.uploading) { | ||
}, | ||
updateIframeWH: function updateIframeWH() { | ||
var rootNode = _reactDom2['default'].findDOMNode(this); | ||
var rootNode = _reactDom2["default"].findDOMNode(this); | ||
var iframeNode = this.getIframeNode(); | ||
@@ -225,3 +211,2 @@ iframeNode.style.height = rootNode.offsetHeight + 'px'; | ||
}, | ||
abort: function abort(file) { | ||
@@ -240,3 +225,2 @@ if (file) { | ||
}, | ||
post: function post(file) { | ||
@@ -262,3 +246,2 @@ var formNode = this.getFormNode(); | ||
}, | ||
render: function render() { | ||
@@ -272,13 +255,13 @@ var _props = this.props; | ||
var iframeStyle = _extends({}, IFRAME_STYLE, { | ||
var iframeStyle = (0, _extends3["default"])({}, IFRAME_STYLE, { | ||
display: this.state.uploading || disabled ? 'none' : '' | ||
}); | ||
return _react2['default'].createElement( | ||
return _react2["default"].createElement( | ||
Tag, | ||
{ | ||
className: disabled ? prefixCls + ' ' + prefixCls + '-disabled' : '' + prefixCls, | ||
style: _extends({ position: 'relative', zIndex: 0 }, style) | ||
style: (0, _extends3["default"])({ position: 'relative', zIndex: 0 }, style) | ||
}, | ||
_react2['default'].createElement('iframe', { | ||
_react2["default"].createElement('iframe', { | ||
ref: 'iframe', | ||
@@ -293,3 +276,3 @@ onLoad: this.onLoad, | ||
exports['default'] = IframeUploader; | ||
exports["default"] = IframeUploader; | ||
module.exports = exports['default']; |
@@ -1,4 +0,4 @@ | ||
// export this package's api | ||
'use strict'; | ||
// export this package's api | ||
module.exports = require('./Upload'); |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports['default'] = upload; | ||
exports["default"] = upload; | ||
function getError(option, xhr) { | ||
@@ -40,3 +40,2 @@ var msg = 'cannot post ' + option.action + ' ' + xhr.status + '\''; | ||
// } | ||
function upload(option) { | ||
@@ -105,3 +104,2 @@ var xhr = new XMLHttpRequest(); | ||
} | ||
module.exports = exports['default']; |
@@ -1,7 +0,7 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports['default'] = uid; | ||
exports["default"] = uid; | ||
var now = +new Date(); | ||
@@ -11,5 +11,4 @@ var index = 0; | ||
function uid() { | ||
return 'rc-upload-' + now + '-' + ++index; | ||
return "rc-upload-" + now + "-" + ++index; | ||
} | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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 _extends2 = require('babel-runtime/helpers/extends'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
@@ -23,5 +23,7 @@ var _react = require('react'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function empty() {} | ||
var Upload = _react2['default'].createClass({ | ||
var Upload = _react2["default"].createClass({ | ||
displayName: 'Upload', | ||
@@ -70,3 +72,2 @@ | ||
}, | ||
getInitialState: function getInitialState() { | ||
@@ -77,3 +78,2 @@ return { | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
@@ -88,9 +88,7 @@ if (this.props.supportServerRender) { | ||
getComponent: function getComponent() { | ||
return typeof FormData !== 'undefined' ? _AjaxUploader2['default'] : _IframeUploader2['default']; | ||
return typeof FormData !== 'undefined' ? _AjaxUploader2["default"] : _IframeUploader2["default"]; | ||
}, | ||
abort: function abort(file) { | ||
this.refs.inner.abort(file); | ||
}, | ||
render: function render() { | ||
@@ -101,3 +99,3 @@ if (this.props.supportServerRender) { | ||
if (_Component) { | ||
return _react2['default'].createElement(_Component, _extends({}, this.props, { ref: 'inner' })); | ||
return _react2["default"].createElement(_Component, (0, _extends3["default"])({}, this.props, { ref: 'inner' })); | ||
} | ||
@@ -107,7 +105,7 @@ return null; | ||
var Component = this.getComponent(); | ||
return _react2['default'].createElement(Component, _extends({}, this.props, { ref: 'inner' })); | ||
return _react2["default"].createElement(Component, (0, _extends3["default"])({}, this.props, { ref: 'inner' })); | ||
} | ||
}); | ||
exports['default'] = Upload; | ||
exports["default"] = Upload; | ||
module.exports = exports['default']; |
{ | ||
"name": "rc-upload", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "upload ui component for react", | ||
@@ -34,9 +34,10 @@ "keywords": [ | ||
"gh-pages": "rc-tools run gh-pages", | ||
"start": "node tests/starter", | ||
"pub": "rc-tools run pub", | ||
"start": "node server", | ||
"pub": "rc-tools run pub --babel-runtime", | ||
"lint": "rc-tools run lint", | ||
"karma": "rc-tools run karma", | ||
"saucelabs": "rc-tools run saucelabs", | ||
"browser-test": "rc-tools run browser-test", | ||
"browser-test-cover": "rc-tools run browser-test-cover" | ||
"test": "rc-tools run test", | ||
"chrome-test": "rc-tools run chrome-test", | ||
"coverage": "rc-tools run coverage" | ||
}, | ||
@@ -47,8 +48,7 @@ "devDependencies": { | ||
"pre-commit": "1.x", | ||
"rc-server": "3.x", | ||
"rc-tools": "4.x", | ||
"react": "0.14.x", | ||
"react-addons-test-utils": "~0.14.0", | ||
"react-dom": "0.14.x", | ||
"sinon": "^1.17.3" | ||
"rc-tools": "5.x", | ||
"react": "15.x", | ||
"react-addons-test-utils": "15.x", | ||
"react-dom": "15.x", | ||
"sinon": "2.0.0-pre.2" | ||
}, | ||
@@ -59,4 +59,5 @@ "pre-commit": [ | ||
"dependencies": { | ||
"babel-runtime": "6.x", | ||
"warning": "2.x" | ||
} | ||
} |
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
8
604
25292
2
+ Addedbabel-runtime@6.x
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)