2015-08-09 18:00:20 +08:00
|
|
|
import React from 'react';
|
2015-08-21 17:12:42 +08:00
|
|
|
import Animate from 'rc-animate';
|
2015-10-02 16:52:34 +08:00
|
|
|
import Icon from '../iconfont';
|
|
|
|
const prefixCls = 'ant-upload';
|
2015-11-04 12:00:49 +08:00
|
|
|
import { Line } from '../progress';
|
2015-10-02 16:52:34 +08:00
|
|
|
|
2015-08-09 18:00:20 +08:00
|
|
|
export default React.createClass({
|
|
|
|
getDefaultProps() {
|
|
|
|
return {
|
2015-10-31 13:27:58 +08:00
|
|
|
items: [],
|
|
|
|
progressAttr: {
|
|
|
|
strokeWidth: 3,
|
|
|
|
showInfo: false
|
|
|
|
}
|
2015-08-09 18:00:20 +08:00
|
|
|
};
|
|
|
|
},
|
2015-08-09 18:23:18 +08:00
|
|
|
handleClose(file) {
|
2015-09-01 00:52:34 +08:00
|
|
|
this.props.onRemove(file);
|
2015-08-09 18:00:20 +08:00
|
|
|
},
|
|
|
|
render() {
|
2015-10-29 00:06:39 +08:00
|
|
|
let list = this.props.items.map((file) => {
|
2015-10-31 13:27:58 +08:00
|
|
|
let progress;
|
|
|
|
let infoUploadingClass = '';
|
|
|
|
if (file.status === 'uploading') {
|
|
|
|
progress = <div className={prefixCls + '-list-item-progress'}>
|
|
|
|
<Line {...this.props.progressAttr} percent={file.percent} />
|
|
|
|
</div>;
|
|
|
|
infoUploadingClass = ' ' + prefixCls + '-list-item-uploading';
|
|
|
|
}
|
2015-08-09 18:00:20 +08:00
|
|
|
return (
|
2015-10-31 13:27:58 +08:00
|
|
|
<div className={prefixCls + '-list-item' + infoUploadingClass} key={file.uid}>
|
|
|
|
<div className={prefixCls + '-list-item-info'}>
|
|
|
|
<Icon type="paper-clip" />
|
|
|
|
<span className="ant-upload-item-name">{file.name}</span>
|
|
|
|
<Icon type="cross" ref="theCloseBtn"
|
|
|
|
onClick={this.handleClose.bind(this, file)} />
|
|
|
|
</div>
|
|
|
|
{ progress }
|
2015-08-09 18:00:20 +08:00
|
|
|
</div>
|
|
|
|
);
|
2015-08-31 18:13:16 +08:00
|
|
|
});
|
2015-09-01 00:52:34 +08:00
|
|
|
return <div className={prefixCls + '-list'}>
|
2015-08-21 17:37:54 +08:00
|
|
|
<Animate transitionName={prefixCls + '-margin-top'}>
|
2015-08-31 18:13:16 +08:00
|
|
|
{list}
|
2015-08-21 17:12:42 +08:00
|
|
|
</Animate>
|
2015-09-01 00:52:34 +08:00
|
|
|
</div>;
|
2015-08-09 18:00:20 +08:00
|
|
|
}
|
|
|
|
});
|