Skip to content

Commit

Permalink
publish 2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchch6 committed Oct 11, 2019
1 parent 3a7b519 commit 78054ea
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 43 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<a name="2.0.4"></a>
## [2.0.4](https://github.com/tinper-bee/upload/compare/v2.0.3...v2.0.4) (2019-10-11)



<a name="2.0.3"></a>
## [2.0.3](https://github.com/tinper-bee/upload/compare/v2.0.2...v2.0.3) (2019-09-24)

Expand Down
8 changes: 4 additions & 4 deletions build/Upload.css
Original file line number Diff line number Diff line change
Expand Up @@ -2435,7 +2435,7 @@
margin-right: 4px;
font-size: 12px;
color: #999; }
.u-upload-list .u-upload-list-item-info .uf-del {
.u-upload-list .u-upload-list-item-info .uf-close {
display: inline-block;
font-size: 12px;
font-size: 10px \9;
Expand Down Expand Up @@ -2464,13 +2464,13 @@
-webkit-transition: all 0.3s ease;
transition: all 0.3s ease;
opacity: 0; }
.u-upload-list .u-upload-list-item-info .uf-del:hover {
color: white; }
.u-upload-list .u-upload-list-item-info .uf-close:hover {
color: #666; }
.u-upload-list .u-upload-list-item-info .uf-eye-o:hover {
color: white; }
.u-upload-list .u-upload-list-item-error .anticon-paper-clip {
color: #f50; }
.u-upload-list .u-upload-list-item-error .uf-del {
.u-upload-list .u-upload-list-item-error .uf-close {
opacity: 1; }
.u-upload-list .u-upload-list-item-progress {
padding: 0 8px 0 20px;
Expand Down
42 changes: 33 additions & 9 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,41 @@ var Upload = function (_Component) {
};

Upload.prototype.handleRemove = function handleRemove(file) {
var _this3 = this;

var onRemove = this.props.onRemove;
if (onRemove) {
onRemove(file);
}
var fileList = this.removeFile(file);
if (fileList) {
this.onChange({
file: file,
fileList: fileList
});
var fileList = this.state.fileList;
var status = file.status;


file.status = 'removed'; // eslint-disable-line

Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(function (ret) {
// Prevent removing file
if (ret === false) {
file.status = status;
return;
}

var removedFileList = _this3.removeFileItem(file, fileList);
if (removedFileList) {
_this3.onChange({
file: file,
fileList: removedFileList
});
}
});
};

Upload.prototype.removeFileItem = function removeFileItem(file, fileList) {
var matchKey = file.uid !== undefined ? 'uid' : 'name';
var removed = fileList.filter(function (item) {
return item[matchKey] !== file[matchKey];
});
if (removed.length === fileList.length) {
return null;
}
return removed;
};

Upload.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
Expand Down
8 changes: 4 additions & 4 deletions dist/demo.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/demo.css.map

Large diffs are not rendered by default.

42 changes: 33 additions & 9 deletions dist/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -36833,17 +36833,41 @@
};

Upload.prototype.handleRemove = function handleRemove(file) {
var _this3 = this;

var onRemove = this.props.onRemove;
if (onRemove) {
onRemove(file);
}
var fileList = this.removeFile(file);
if (fileList) {
this.onChange({
file: file,
fileList: fileList
});
var fileList = this.state.fileList;
var status = file.status;


file.status = 'removed'; // eslint-disable-line

Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(function (ret) {
// Prevent removing file
if (ret === false) {
file.status = status;
return;
}

var removedFileList = _this3.removeFileItem(file, fileList);
if (removedFileList) {
_this3.onChange({
file: file,
fileList: removedFileList
});
}
});
};

Upload.prototype.removeFileItem = function removeFileItem(file, fileList) {
var matchKey = file.uid !== undefined ? 'uid' : 'name';
var removed = fileList.filter(function (item) {
return item[matchKey] !== file[matchKey];
});
if (removed.length === fileList.length) {
return null;
}
return removed;
};

Upload.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
Expand Down
2 changes: 1 addition & 1 deletion dist/demo.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bee-upload",
"version": "2.0.3",
"version": "2.0.4",
"description": "upload ui component for react",
"keywords": [
"react",
Expand Down
8 changes: 4 additions & 4 deletions src/Upload.scss
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
font-size: 12px;
color: #999;
}
.uf-del {
.uf-close {
display: inline-block;
font-size: 12px;
font-size: 10px \9;
Expand Down Expand Up @@ -199,8 +199,8 @@
transition: all 0.3s ease;
opacity: 0;
}
.uf-del:hover {
color: white;
.uf-close:hover {
color: #666;
}
.uf-eye-o:hover{
color: white;
Expand All @@ -209,7 +209,7 @@
.u-upload-list-item-error .anticon-paper-clip {
color: $upload-list-error-color;
}
.u-upload-list-item-error .uf-del {
.u-upload-list-item-error .uf-close {
opacity: 1;
}
.u-upload-list-item-progress {
Expand Down
39 changes: 29 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,36 @@ class Upload extends Component {
}

handleRemove(file) {
const onRemove = this.props.onRemove;
if (onRemove) {
onRemove(file);
}
let fileList = this.removeFile(file);
if (fileList) {
this.onChange({
file,
fileList,
});
const { onRemove } = this.props;
const { fileList } = this.state;
const { status } = file;

file.status = 'removed'; // eslint-disable-line

Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(ret => {
// Prevent removing file
if (ret === false) {
file.status = status;
return;
}

const removedFileList = this.removeFileItem(file, fileList);
if (removedFileList) {
this.onChange({
file,
fileList: removedFileList,
});
}
});
}

removeFileItem(file, fileList) {
const matchKey = file.uid !== undefined ? 'uid' : 'name';
const removed = fileList.filter(item => item[matchKey] !== file[matchKey]);
if (removed.length === fileList.length) {
return null;
}
return removed;
}

handleManualRemove = (file) => {
Expand Down

0 comments on commit 78054ea

Please sign in to comment.