Rename File interface to UploadFile (#7183)

* Fix doc missing info

* Rename File interface to UploadFile
This commit is contained in:
Zheeeng 2017-08-12 13:56:57 +08:00 committed by 偏右
parent 1e80254059
commit 754966991b
2 changed files with 16 additions and 16 deletions

View File

@ -4,10 +4,10 @@ import Icon from '../icon';
import Tooltip from '../tooltip';
import Progress from '../progress';
import classNames from 'classnames';
import { UploadListProps } from './interface';
import { UploadListProps, UploadFile } from './interface';
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL
const previewFile = (file, callback) => {
const previewFile = (file: File, callback: Function) => {
const reader = new FileReader();
reader.onloadend = () => callback(reader.result);
reader.readAsDataURL(file);
@ -25,14 +25,14 @@ export default class UploadList extends React.Component<UploadListProps, any> {
showPreviewIcon: true,
};
handleClose = (file) => {
handleClose = (file: UploadFile) => {
const onRemove = this.props.onRemove;
if (onRemove) {
onRemove(file);
}
}
handlePreview = (file, e) => {
handlePreview = (file: UploadFile, e) => {
const { onPreview } = this.props;
if (!onPreview) {
return;

View File

@ -6,7 +6,7 @@ export interface HttpRequestHeader {
[key: string]: string;
}
export interface File {
export interface UploadFile {
uid: number;
size: number;
name: string;
@ -21,8 +21,8 @@ export interface File {
}
export interface UploadChangeParam {
file: File;
fileList: Array<File>;
file: UploadFile;
fileList: Array<UploadFile>;
event?: { percent: number };
}
@ -41,20 +41,20 @@ export interface UploadLocale {
export interface UploadProps {
type?: 'drag' | 'select';
name?: string;
defaultFileList?: Array<File>;
fileList?: Array<File>;
defaultFileList?: Array<UploadFile>;
fileList?: Array<UploadFile>;
action?: string;
data?: Object | ((file: File) => any);
data?: Object | ((file: UploadFile) => any);
headers?: HttpRequestHeader;
showUploadList?: boolean | ShowUploadListInterface;
multiple?: boolean;
accept?: string;
beforeUpload?: (file: File, FileList: File[]) => boolean | PromiseLike<any>;
beforeUpload?: (file: UploadFile, FileList: UploadFile[]) => boolean | PromiseLike<any>;
onChange?: (info: UploadChangeParam) => void;
listType?: 'text' | 'picture' | 'picture-card';
className?: string;
onPreview?: (file: File) => void;
onRemove?: (file: File) => void | boolean;
onPreview?: (file: UploadFile) => void;
onRemove?: (file: UploadFile) => void | boolean;
supportServerRender?: boolean;
style?: React.CSSProperties;
disabled?: boolean;
@ -66,9 +66,9 @@ export interface UploadProps {
export interface UploadListProps {
listType?: 'text' | 'picture' | 'picture-card';
onPreview?: (file: File) => void;
onRemove?: (file: File) => void | boolean;
items?: Array<File>;
onPreview?: (file: UploadFile) => void;
onRemove?: (file: UploadFile) => void | boolean;
items?: Array<UploadFile>;
progressAttr?: Object;
prefixCls?: string;
showRemoveIcon?: boolean;