* Fix types

Fix https://github.com/ant-design/ant-design/issues/8796

* Fix exported types
This commit is contained in:
Ed Moore 2018-04-16 12:58:17 +10:00 committed by Wei Zhu
parent e1efa990ca
commit 31e50e50b6
6 changed files with 34 additions and 16 deletions

View File

@ -17,8 +17,10 @@ export interface FormCreateOption<T> {
withRef?: boolean;
}
export type FormLayout = 'horizontal' | 'inline' | 'vertical';
export interface FormProps {
layout?: 'horizontal' | 'inline' | 'vertical';
layout?: FormLayout;
form?: WrappedFormUtils;
onSubmit?: React.FormEventHandler<any>;
style?: React.CSSProperties;
@ -123,7 +125,7 @@ export interface ComponentDecorator {
export default class Form extends React.Component<FormProps, any> {
static defaultProps = {
prefixCls: 'ant-form',
layout: 'horizontal',
layout: 'horizontal' as FormLayout,
hideRequiredMark: false,
onSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault();

View File

@ -10,10 +10,13 @@ const statusColorMap = {
success: '#87d068',
};
export type ProgressType = 'line' | 'circle' | 'dashboard';
export type ProgressSize = 'default' | 'small';
export interface ProgressProps {
prefixCls?: string;
className?: string;
type?: 'line' | 'circle' | 'dashboard';
type?: ProgressType;
percent?: number;
successPercent?: number;
format?: (percent: number) => string;
@ -25,7 +28,7 @@ export interface ProgressProps {
style?: React.CSSProperties;
gapDegree?: number;
gapPosition?: 'top' | 'bottom' | 'left' | 'right';
size?: 'default' | 'small';
size?: ProgressSize;
}
export default class Progress extends React.Component<ProgressProps, {}> {
@ -33,12 +36,12 @@ export default class Progress extends React.Component<ProgressProps, {}> {
static Circle: any;
static defaultProps = {
type: 'line',
type: 'line' as ProgressType,
percent: 0,
showInfo: true,
trailColor: '#f3f3f3',
prefixCls: 'ant-progress',
size: 'default',
size: 'default' as ProgressSize,
};
static propTypes = {

View File

@ -7,12 +7,14 @@ import omit from 'omit.js';
export type SpinIndicator = React.ReactElement<any>;
export type SpinSize = 'small' | 'default' | 'large';
export interface SpinProps {
prefixCls?: string;
className?: string;
spinning?: boolean;
style?: React.CSSProperties;
size?: 'small' | 'default' | 'large';
size?: SpinSize;
tip?: string;
delay?: number;
wrapperClassName?: string;
@ -28,7 +30,7 @@ export default class Spin extends React.Component<SpinProps, SpinState> {
static defaultProps = {
prefixCls: 'ant-spin',
spinning: true,
size: 'default',
size: 'default' as SpinSize,
wrapperClassName: '',
};

View File

@ -6,7 +6,15 @@ import LocaleReceiver from '../locale-provider/LocaleReceiver';
import defaultLocale from '../locale-provider/default';
import Dragger from './Dragger';
import UploadList from './UploadList';
import { UploadProps, UploadState, UploadFile, UploadLocale, UploadChangeParam } from './interface';
import {
UploadProps,
UploadState,
UploadFile,
UploadLocale,
UploadChangeParam,
UploadType,
UploadListType,
} from './interface';
import { T, fileToObject, genPercentAdd, getFileItem, removeFileItem } from './utils';
export { UploadProps };
@ -16,14 +24,14 @@ export default class Upload extends React.Component<UploadProps, UploadState> {
static defaultProps = {
prefixCls: 'ant-upload',
type: 'select',
type: 'select' as UploadType,
multiple: false,
action: '',
data: {},
accept: '',
beforeUpload: T,
showUploadList: true,
listType: 'text', // or pictrue
listType: 'text' as UploadListType, // or pictrue
className: '',
disabled: false,
supportServerRender: true,

View File

@ -4,7 +4,7 @@ import Icon from '../icon';
import Tooltip from '../tooltip';
import Progress from '../progress';
import classNames from 'classnames';
import { UploadListProps, UploadFile } from './interface';
import { UploadListProps, UploadFile, UploadListType } from './interface';
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL
const previewFile = (file: File, callback: Function) => {
@ -35,7 +35,7 @@ const isImageUrl = (url: string): boolean => {
export default class UploadList extends React.Component<UploadListProps, any> {
static defaultProps = {
listType: 'text', // or picture
listType: 'text' as UploadListType, // or picture
progressAttr: {
strokeWidth: 2,
showInfo: false,

View File

@ -43,8 +43,11 @@ export interface UploadLocale {
previewFile?: string;
}
export type UploadType = 'drag' | 'select';
export type UploadListType = 'text' | 'picture' | 'picture-card';
export interface UploadProps {
type?: 'drag' | 'select';
type?: UploadType;
name?: string;
defaultFileList?: Array<UploadFile>;
fileList?: Array<UploadFile>;
@ -56,7 +59,7 @@ export interface UploadProps {
accept?: string;
beforeUpload?: (file: UploadFile, FileList: UploadFile[]) => boolean | PromiseLike<any>;
onChange?: (info: UploadChangeParam) => void;
listType?: 'text' | 'picture' | 'picture-card';
listType?: UploadListType;
className?: string;
onPreview?: (file: UploadFile) => void;
onRemove?: (file: UploadFile) => void | boolean;
@ -75,7 +78,7 @@ export interface UploadState {
}
export interface UploadListProps {
listType?: 'text' | 'picture' | 'picture-card';
listType?: UploadListType;
onPreview?: (file: UploadFile) => void;
onRemove?: (file: UploadFile) => void | boolean;
items?: Array<UploadFile>;