react-dropzone
Advanced tools
Comparing version 0.2.0 to 0.3.0
42
index.js
@@ -29,2 +29,30 @@ /** | ||
handleClick: function(e) { | ||
e.preventDefault(); | ||
var event = new MouseEvent('click', { | ||
'view': window, | ||
'bubbles': true, | ||
'cancelable': false | ||
}); | ||
var node = e.target.getElementsByTagName('input')[0]; | ||
if (node) { | ||
node.dispatchEvent(event); | ||
} | ||
}, | ||
handleChange: function(e) { | ||
e.preventDefault(); | ||
this.setState({ | ||
isDragActive: false | ||
}); | ||
if (this.props.handler) { | ||
var file = e.target && e.target.files && e.target.files[0]; | ||
this.props.handler(file); | ||
} else { | ||
console.error('No handler specified to accept the file.'); | ||
} | ||
}, | ||
handleDrop: function(e) { | ||
@@ -55,3 +83,5 @@ e.preventDefault(); | ||
}; | ||
dropzoneStyle.overflow = "hidden"; | ||
dropzoneStyle.cursor = "pointer"; | ||
var messageStyle = { | ||
@@ -68,6 +98,12 @@ display: "table-cell", | ||
var inputStyle = { | ||
position: "absolute", | ||
top: "-100px" | ||
}; | ||
return ( | ||
<div className="dropzone" style={dropzoneStyle} onDragLeave={this.handleDragLeave} onDragOver={this.handleDragOver} onDrop={this.handleDrop}> | ||
<form className="dropzone" style={dropzoneStyle} onClick={this.handleClick} onChange={this.handleChange} onDragLeave={this.handleDragLeave} onDragOver={this.handleDragOver} onDrop={this.handleDrop}> | ||
<input type="file" style={inputStyle}/> | ||
{this.props.children || <span style={messageStyle}>{this.props.message || "Drop Here"}</span>} | ||
</div> | ||
</form> | ||
); | ||
@@ -74,0 +110,0 @@ } |
{ | ||
"name": "react-dropzone", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Simple HTML5 drag-drop zone in React", | ||
"main": "index.js", | ||
"main": "index.jsx", | ||
"keywords": [ | ||
@@ -7,0 +7,0 @@ "react-component", |
@@ -31,3 +31,3 @@ react-dropzone | ||
<div> | ||
<Dropzone handler={this.fileHandler} size=200 message="Drag and drop a file here"/> | ||
<Dropzone handler={this.fileHandler} size={200} message="Drag and drop a file here"/> | ||
</div> | ||
@@ -34,0 +34,0 @@ ); |
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
18498
7
153