mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-18 11:18:14 +08:00
* fix #2571 #2518 use rc-upload@2.x abort fix #2645 add `disabled` * fix
This commit is contained in:
parent
7bbb26d441
commit
a5585bff77
@ -72,6 +72,7 @@ export default class Upload extends React.Component {
|
|||||||
showUploadList: true,
|
showUploadList: true,
|
||||||
listType: 'text', // or pictrue
|
listType: 'text', // or pictrue
|
||||||
className: '',
|
className: '',
|
||||||
|
disabled: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -197,6 +198,7 @@ export default class Upload extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleManualRemove = (file) => {
|
handleManualRemove = (file) => {
|
||||||
|
this.refs.upload.abort(file);
|
||||||
/*eslint-disable */
|
/*eslint-disable */
|
||||||
file.status = 'removed';
|
file.status = 'removed';
|
||||||
/*eslint-enable */
|
/*eslint-enable */
|
||||||
@ -253,18 +255,21 @@ export default class Upload extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (type === 'drag') {
|
if (type === 'drag') {
|
||||||
let dragUploadingClass = this.state.fileList.some(file => file.status === 'uploading')
|
const dragCls = classNames({
|
||||||
? `${prefixCls}-drag-uploading` : '';
|
[prefixCls]: true,
|
||||||
let draggingClass = this.state.dragState === 'dragover'
|
[`${prefixCls}-drag`]: true,
|
||||||
? `${prefixCls}-drag-hover` : '';
|
[`${prefixCls}-drag-uploading`]: this.state.fileList.some(file => file.status === 'uploading'),
|
||||||
|
[`${prefixCls}-drag-hover`]: this.state.dragState === 'dragover',
|
||||||
|
[`${prefixCls}-disabled`]: this.props.disabled,
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<span className={this.props.className}>
|
<span className={this.props.className}>
|
||||||
<div className={`${prefixCls} ${prefixCls}-drag ${dragUploadingClass} ${draggingClass}`}
|
<div className={dragCls}
|
||||||
onDrop={this.onFileDrop}
|
onDrop={this.onFileDrop}
|
||||||
onDragOver={this.onFileDrop}
|
onDragOver={this.onFileDrop}
|
||||||
onDragLeave={this.onFileDrop}
|
onDragLeave={this.onFileDrop}
|
||||||
>
|
>
|
||||||
<RcUpload {...props}>
|
<RcUpload {...props} ref="upload">
|
||||||
<div className={`${prefixCls}-drag-container`}>
|
<div className={`${prefixCls}-drag-container`}>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</div>
|
</div>
|
||||||
@ -279,10 +284,11 @@ export default class Upload extends React.Component {
|
|||||||
[prefixCls]: true,
|
[prefixCls]: true,
|
||||||
[`${prefixCls}-select`]: true,
|
[`${prefixCls}-select`]: true,
|
||||||
[`${prefixCls}-select-${this.props.listType}`]: true,
|
[`${prefixCls}-select-${this.props.listType}`]: true,
|
||||||
|
[`${prefixCls}-disabled`]: this.props.disabled,
|
||||||
});
|
});
|
||||||
|
|
||||||
const uploadButton = this.props.children
|
const uploadButton = this.props.children
|
||||||
? <div className={uploadButtonCls}><RcUpload {...props} /></div>
|
? <div className={uploadButtonCls}><RcUpload {...props} ref="upload" /></div>
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (this.props.listType === 'picture-card') {
|
if (this.props.listType === 'picture-card') {
|
||||||
|
@ -34,6 +34,7 @@ english: Upload
|
|||||||
| onPreview | 点击文件链接时的回调 | Function(file) | 无 |
|
| onPreview | 点击文件链接时的回调 | Function(file) | 无 |
|
||||||
| onRemove | 点击移除文件时的回调 | Function(file) | 无 |
|
| onRemove | 点击移除文件时的回调 | Function(file) | 无 |
|
||||||
| supportServerRender | 服务端渲染时需要打开这个 | Boolean | false |
|
| supportServerRender | 服务端渲染时需要打开这个 | Boolean | false |
|
||||||
|
| disabled | 是否禁用 | Boolean | false |
|
||||||
|
|
||||||
### onChange
|
### onChange
|
||||||
|
|
||||||
|
@ -52,10 +52,14 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
&.@{upload-prefix-cls}-drag-hover {
|
&.@{upload-prefix-cls}-drag-hover:not(.@{upload-prefix-cls}-disabled) {
|
||||||
border: 2px dashed tint(@primary-color, 20%);
|
border: 2px dashed tint(@primary-color, 20%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.@{upload-prefix-cls}-disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
> span {
|
> span {
|
||||||
display: table;
|
display: table;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -66,7 +70,7 @@
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:not(.@{upload-prefix-cls}-disabled):hover {
|
||||||
border-color: tint(@primary-color, 20%);
|
border-color: tint(@primary-color, 20%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
"rc-tooltip": "~3.4.2",
|
"rc-tooltip": "~3.4.2",
|
||||||
"rc-tree": "~1.3.6",
|
"rc-tree": "~1.3.6",
|
||||||
"rc-tree-select": "~1.8.0",
|
"rc-tree-select": "~1.8.0",
|
||||||
"rc-upload": "~1.13.3",
|
"rc-upload": "~2.0.3",
|
||||||
"rc-util": "~3.3.0",
|
"rc-util": "~3.3.0",
|
||||||
"react-addons-pure-render-mixin": "^15.0.0",
|
"react-addons-pure-render-mixin": "^15.0.0",
|
||||||
"react-slick": "~0.12.0",
|
"react-slick": "~0.12.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user