fix tslint problems (#2360)

This commit is contained in:
偏右 2016-07-13 11:14:24 +08:00 committed by GitHub
parent 5e5bd6af9e
commit de359d2cf7
60 changed files with 376 additions and 383 deletions

View File

@ -1,7 +1,7 @@
export default function splitObject(obj, parts) : Array<any>{
export default function splitObject(obj, parts): Array<any> {
let left = {};
let right = {};
Object.keys(obj).forEach((k)=> {
Object.keys(obj).forEach((k) => {
if (parts.indexOf(k) !== -1) {
left[k] = obj[k];
} else {

View File

@ -40,11 +40,11 @@ export interface AffixProps {
/**
*
*/
offsetTop?: number,
offset?: number,
offsetBottom?: number,
style?: React.CSSProperties,
onChange?: (affixed?: boolean) => any,
offsetTop?: number;
offset?: number;
offsetBottom?: number;
style?: React.CSSProperties;
onChange?: (affixed?: boolean) => any;
}
export default class Affix extends React.Component<AffixProps, any> {
@ -52,16 +52,16 @@ export default class Affix extends React.Component<AffixProps, any> {
resizeEvent: any;
refs: {
fixedNode: any;
}
};
static propTypes = {
offsetTop: React.PropTypes.number,
offsetBottom: React.PropTypes.number,
}
};
static defaultProps = {
onChange() {},
}
};
constructor(props) {
super(props);

View File

@ -10,7 +10,7 @@ export default class Alert extends React.Component {
showIcon: false,
onClose() {},
type: 'info',
}
};
constructor(props) {
super(props);
this.state = {

View File

@ -20,7 +20,7 @@ export default class ScrollNumber extends React.Component {
onAnimated() {
},
height: 18,
}
};
static propTypes = {
count: React.PropTypes.oneOfType([
@ -30,7 +30,7 @@ export default class ScrollNumber extends React.Component {
component: React.PropTypes.string,
onAnimated: React.PropTypes.func,
height: React.PropTypes.number,
}
};
constructor(props) {
super(props);

View File

@ -9,7 +9,7 @@ export default class Badge extends React.Component {
count: null,
dot: false,
overflowCount: 99,
}
};
static propTypes = {
count: React.PropTypes.oneOfType([
@ -18,7 +18,7 @@ export default class Badge extends React.Component {
]),
dot: React.PropTypes.bool,
overflowCount: React.PropTypes.number,
}
};
render() {
let { count, prefixCls, overflowCount, className, style, children, dot } = this.props;

View File

@ -19,7 +19,7 @@ export default class Breadcrumb extends React.Component {
separator: '/',
linkRender: (href, name) => <a href={`#${href}`}>{name}</a>,
nameRender: defaultNameRender,
}
};
static propTypes = {
prefixCls: React.PropTypes.string,
@ -31,7 +31,7 @@ export default class Breadcrumb extends React.Component {
params: React.PropTypes.object,
linkRender: React.PropTypes.func,
nameRender: React.PropTypes.func,
}
};
render() {
let crumbs;

View File

@ -5,7 +5,7 @@ export default class BreadcrumbItem extends React.Component {
static defaultProps = {
prefixCls: 'ant-breadcrumb',
separator: '/',
}
};
static propTypes = {
prefixCls: React.PropTypes.string,
@ -14,10 +14,10 @@ export default class BreadcrumbItem extends React.Component {
React.PropTypes.element,
]),
href: React.PropTypes.string,
}
};
render() {
const [{prefixCls, separator, children},restProps] = splitObject(this.props, ['prefixCls', 'separator', 'children']);
const [{ prefixCls, separator, children }, restProps] = splitObject(this.props, ['prefixCls', 'separator', 'children']);
let link;
if ('href' in this.props) {
link = <a className={`${prefixCls}-link`} {...restProps}>{children}</a>;

View File

@ -5,7 +5,7 @@ import splitObject from '../_util/splitObject';
const prefix = 'ant-btn-group-';
export default function ButtonGroup(props) {
const [{size, className},others] = splitObject(props, ['size', 'className']);
const [{ size, className }, others] = splitObject(props, ['size', 'className']);
// large => lg
// small => sm

View File

@ -29,7 +29,7 @@ export default class Button extends React.Component {
prefixCls: 'ant-btn',
onClick() {},
loading: false,
}
};
static propTypes = {
type: React.PropTypes.string,
@ -40,7 +40,7 @@ export default class Button extends React.Component {
loading: React.PropTypes.bool,
className: React.PropTypes.string,
icon: React.PropTypes.string,
}
};
componentWillUnmount() {
if (this.clickedTimeout) {
@ -76,8 +76,8 @@ export default class Button extends React.Component {
render() {
const props = this.props;
const [{type, shape, size, className, htmlType, children, icon, loading, prefixCls}, others] = splitObject(props,
['type', 'shape','size', 'className','htmlType', 'children','icon','loading','prefixCls']);
const [{ type, shape, size, className, htmlType, children, icon, loading, prefixCls }, others] = splitObject(props,
['type', 'shape', 'size', 'className', 'htmlType', 'children', 'icon', 'loading', 'prefixCls']);
// large => lg
// small => sm

View File

@ -14,7 +14,7 @@ export default class Header extends React.Component {
yearSelectTotal: 20,
onValueChange: noop,
onTypeChange: noop,
}
};
static propTypes = {
value: PropTypes.object,
@ -26,7 +26,7 @@ export default class Header extends React.Component {
prefixCls: PropTypes.string,
selectPrefixCls: PropTypes.string,
type: PropTypes.string,
}
};
getYearSelectElement(year) {
const { yearSelectOffset, yearSelectTotal, locale, prefixCls, fullscreen } = this.props;

View File

@ -10,7 +10,9 @@ import assign from 'object-assign';
function noop() { return null; }
function zerofixed(v) {
if (v < 10) return `0${v}`;
if (v < 10) {
return `0${v}`;
}
return `${v}`;
}
@ -23,7 +25,7 @@ export default class Calendar extends React.Component {
prefixCls: PREFIX_CLS,
onPanelChange: noop,
mode: 'month',
}
};
static propTypes = {
monthCellRender: PropTypes.func,
@ -35,11 +37,11 @@ export default class Calendar extends React.Component {
style: PropTypes.object,
onPanelChange: PropTypes.func,
value: PropTypes.instanceOf(Date),
}
};
static contextTypes = {
antLocale: PropTypes.object,
}
};
constructor(props) {
super(props);
@ -72,7 +74,7 @@ export default class Calendar extends React.Component {
}
// 统一合并为完整的 Locale
const result = assign({}, locale, props.locale);
result.lang = assign({}, locale.lang,props.locale.lang);
result.lang = assign({}, locale.lang, props.locale.lang);
return result;
}

View File

@ -20,29 +20,29 @@ import * as React from 'react';
export type CarouselEffect = 'scrollx' | 'fade'
// Carousel
export interface CarouselProps {
/** 动画效果函数,可取 scrollx, fade*/
effect?:CarouselEffect,
/** 是否显示面板指示点*/
dots?:boolean,
/** 垂直显示*/
vertical?:boolean,
/** 是否自动切换*/
autoplay?:boolean,
/** 动画效果*/
easing?:string,
/** 切换面板的回调*/
beforeChange?:(from:number, to:number) => void,
/** 切换面板的回调*/
afterChange?:(current:number) => void,
/** 动画效果函数,可取 scrollx, fade */
effect?: CarouselEffect;
/** 是否显示面板指示点 */
dots?: SlickCarouselboolean;
/** 垂直显示 */
vertical?: boolean;
/** 是否自动切换 */
autoplay?: boolean;
/** 动画效果 */
easing?: string;
/** 切换面板的回调 */
beforeChange?: (from: number, to: number) => void;
/** 切换面板的回调 */
afterChange?: (current:number) => void;
/** 行内样式 */
style?:React.CSSProperties
style?: React.CSSProperties;
}
export default class Carousel extends React.Component<CarouselProps, any> {
static defaultProps = {
dots: true,
arrows: false,
}
};
render() {
let props = assign({}, this.props);

View File

@ -8,47 +8,46 @@ import splitObject from '../_util/splitObject';
import omit from 'object.omit';
export interface CascaderOptionType {
value:string,
label:string,
disabled?:boolean,
children?:Array<CascaderOptionType>
value: string;
label: string;
disabled?: boolean;
children?: Array<CascaderOptionType>;
}
export type CascaderExpandTrigger = 'click' | 'hover'
export interface CascaderProps {
/** 可选项数据源*/
options:Array<CascaderOptionType>,
/** 默认的选中项*/
defaultValue?:Array<CascaderOptionType>,
/** 指定选中项*/
value?:Array<CascaderOptionType>,
/** 选择完成后的回调*/
onChange?:(value:string, selectedOptions?:Array<CascaderOptionType>) => void,
/** 选择后展示的渲染函数*/
displayRender?:(label:Array<string>, selectedOptions?:Array<CascaderOptionType>) => React.ReactNode,
/** 自定义样式*/
style?:React.CSSProperties,
/** 自定义类名*/
className?:string,
/** 自定义浮层类名*/
popupClassName?:string,
/** 可选项数据源 */
options: Array<CascaderOptionType>;
/** 默认的选中项 */
defaultValue?: Array<CascaderOptionType>;
/** 指定选中项 */
value?: Array<CascaderOptionType>;
/** 选择完成后的回调 */
onChange?: (value:string, selectedOptions?:Array<CascaderOptionType>) => void;
/** 选择后展示的渲染函数 */
displayRender?: (label:Array<string>, selectedOptions?:Array<CascaderOptionType>) => React.ReactNode;
/** 自定义样式 */
style?: React.CSSProperties;
/** 自定义类名 */
className?: string;
/** 自定义浮层类名 */
popupClassName?: string;
/** 浮层预设位置:`bottomLeft` `bottomRight` `topLeft` `topRight` */
popupPlacement?:string,
popupPlacement?: string;
/** 输入框占位文本*/
placeholder?:string,
placeholder?: string;
/** 输入框大小,可选 `large` `default` `small` */
size?:string,
size?: string;
/** 禁用*/
disabled?:boolean,
disabled?: boolean;
/** 是否支持清除*/
allowClear?:boolean,
allowClear?: boolean;
/** 次级菜单的展开方式,可选 'click' 和 'hover' */
expandTrigger?:CascaderExpandTrigger,
expandTrigger?: CascaderExpandTrigger;
/** 当此项为 true 时,点选每级菜单选项值都会发生变化 */
changeOnSelect?:boolean,
changeOnSelect?: boolean;
/** 浮层可见变化时回调 */
onPopupVisibleChange?: (popupVisible: boolean) => void
onPopupVisibleChange?: (popupVisible: boolean) => void;
}
export default class Cascader extends React.Component<CascaderProps, any> {
@ -63,7 +62,7 @@ export default class Cascader extends React.Component<CascaderProps, any> {
disabled: false,
allowClear: true,
onPopupVisibleChange() {},
}
};
constructor(props) {
super(props);
@ -117,9 +116,9 @@ export default class Cascader extends React.Component<CascaderProps, any> {
render() {
const props = this.props;
const [{prefixCls, children, placeholder, size, disabled,
className, style, allowClear}, otherProps] = splitObject(props,
['prefixCls', 'children','placeholder', 'size','disabled', 'className','style','allowClear']);
const [{ prefixCls, children, placeholder, size, disabled,
className, style, allowClear }, otherProps] = splitObject(props,
['prefixCls', 'children', 'placeholder', 'size', 'disabled', 'className', 'style', 'allowClear']);
const sizeCls = classNames({
'ant-input-lg': size === 'large',

View File

@ -4,24 +4,22 @@ import PureRenderMixin from 'react-addons-pure-render-mixin';
import assign from 'object-assign';
export interface CheckboxOptionType {
label:string,
value:string,
disabled?:boolean
label: string;
value: string;
disabled?: boolean;
}
export interface CheckboxGroupProps {
/** 默认选中的选项*/
defaultValue?:Array<string>,
/** 指定选中的选项*/
value?:Array<string>,
/** 指定可选项*/
options?:Array<CheckboxOptionType> | Array<string>,
/** 变化时回调函数*/
onChange?:(checkedValue:Array<string>) => void,
disabled?:boolean,
style?:React.CSSProperties
/** 默认选中的选项 */
defaultValue?: Array<string>;
/** 指定选中的选项 */
value?: Array<string>;
/** 指定可选项 */
options?: Array<CheckboxOptionType> | Array<string>;
/** 变化时回调函数 */
onChange?: (checkedValue: Array<string>) => void;
disabled?: boolean;
style?: React.CSSProperties;
}
export interface CheckboxGroupState {
@ -33,13 +31,13 @@ export default class CheckboxGroup extends React.Component<CheckboxGroupProps, C
options: [],
defaultValue: [],
onChange() {},
}
};
static propTypes = {
defaultValue: React.PropTypes.array,
value: React.PropTypes.array,
options: React.PropTypes.array.isRequired,
onChange: React.PropTypes.func,
}
};
constructor(props) {
super(props);
let value;

View File

@ -6,30 +6,27 @@ import PureRenderMixin from 'react-addons-pure-render-mixin';
import splitObject from '../_util/splitObject';
export interface CheckboxProps {
/** 指定当前是否选中*/
checked?:boolean,
/** 初始是否选中*/
defaultChecked?:boolean,
/** 变化时回调函数*/
onChange?:React.FormEventHandler,
style?:React.CSSProperties,
disabled?: boolean,
className?: string,
/** 指定当前是否选中 */
checked?: boolean;
/** 初始是否选中 */
defaultChecked?: boolean;
/** 变化时回调函数 */
onChange?: React.FormEventHandler;
style?: React.CSSProperties;
disabled?: boolean;
className?: string;
}
export default class Checkbox extends React.Component<CheckboxProps, any> {
static Group = CheckboxGroup;
static defaultProps = {
prefixCls: 'ant-checkbox',
}
};
shouldComponentUpdate(...args) {
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
}
render() {
const [{ prefixCls, style, children, className },restProps] = splitObject(this.props, ['prefixCls', 'style', 'children', 'className']);
const [{ prefixCls, style, children, className }, restProps] = splitObject(this.props, ['prefixCls', 'style', 'children', 'className']);
const classString = classNames({
[className]: !!className,
[`${prefixCls}-wrapper`]: true,

View File

@ -2,24 +2,22 @@ import RcCollapse from 'rc-collapse';
import * as React from 'react';
export interface CollapseProps {
activeKey?:Array<string> | string,
activeKey?: Array<string> | string;
/** 初始化选中面板的key */
defaultActiveKey?:Array<string>,
defaultActiveKey?: Array<string>;
/** accordion 为 true 的时候,一次只可以打开一个面板 */
accordion?:boolean,
/** 切换面板的回调*/
onChange?:(key:string) => void,
style?:React.CSSProperties
accordion?:boolean;
/** 切换面板的回调 */
onChange?: (key:string) => void;
style?: React.CSSProperties;
}
export interface CollapsePanelProps {
/** 对应 activeKey */
key:string,
/** 面板头内容*/
header:React.ReactNode,
style?:React.CSSProperties
key: string;
/** 面板头内容 */
header: React.ReactNode;
style?: React.CSSProperties;
}
export class CollapsePanel extends React.Component<CollapsePanelProps, {}> {
@ -31,7 +29,7 @@ export default class Collapse extends React.Component<CollapseProps, any> {
static defaultProps = {
prefixCls: 'ant-collapse',
}
};
render() {
return <RcCollapse {...this.props} />;

View File

@ -6,7 +6,7 @@ export default class Calendar extends React.Component {
static defaultProps = {
locale: CalendarLocale,
prefixCls: 'ant-calendar',
}
};
render() {
return <RcCalendar {...this.props} />;

View File

@ -8,7 +8,7 @@ import Icon from '../icon';
export default class RangePicker extends React.Component {
static defaultProps = {
defaultValue: [],
}
};
constructor(props) {
super(props);

View File

@ -7,7 +7,7 @@ const locale = assign({}, GregorianCalendarLocale);
locale.lang = assign({
placeholder: 'Select date',
rangePlaceholder: ['Start date', 'End date'],
},CalendarLocale);
}, CalendarLocale);
locale.timePickerLocale = assign({}, TimePickerLocale);

View File

@ -10,7 +10,7 @@ const locale = assign({}, GregorianCalendarLocale);
locale.lang = assign({
placeholder: 'Выберите дату',
rangePlaceholder: ['Начальная дата', 'Конечная дата'],
},CalendarLocale);
}, CalendarLocale);
locale.timePickerLocale = assign({}, TimePickerLocale);

View File

@ -17,10 +17,10 @@ export default class DropdownButton extends React.Component {
targetOffset: [0, 0],
},
type: 'default',
}
};
render() {
const [{ type, overlay, trigger, align, children, className, onClick },restProps] = splitObject(this.props,
const [{ type, overlay, trigger, align, children, className, onClick }, restProps] = splitObject(this.props,
['type', 'overlay', 'trigger', 'align', 'children', 'className', 'onClick']);
const cls = classNames({
'ant-dropdown-button': true,

View File

@ -8,12 +8,10 @@ export default class Dropdown extends React.Component {
prefixCls: 'ant-dropdown',
mouseEnterDelay: 0.15,
mouseLeaveDelay: 0.1,
}
};
render() {
const [{overlay}, others] = splitObject(this.props,
['overlay']);
const [{ overlay }, others] = splitObject(this.props, ['overlay']);
const menu = React.cloneElement(overlay, {
openTransitionName: 'zoom-big',
});

View File

@ -9,7 +9,7 @@ export default class Form extends React.Component {
onSubmit(e) {
e.preventDefault();
},
}
};
static propTypes = {
prefixCls: React.PropTypes.string,
@ -18,11 +18,11 @@ export default class Form extends React.Component {
form: React.PropTypes.object,
children: React.PropTypes.any,
onSubmit: React.PropTypes.func,
}
};
static childContextTypes = {
form: React.PropTypes.object,
}
};
shouldComponentUpdate(...args) {
return PureRenderMixin.shouldComponentUpdate.apply(this, args);

View File

@ -9,7 +9,7 @@ export default class FormItem extends React.Component {
static defaultProps = {
hasFeedback: false,
prefixCls: 'ant-form',
}
};
static propTypes = {
prefixCls: React.PropTypes.string,
@ -23,11 +23,11 @@ export default class FormItem extends React.Component {
id: React.PropTypes.string,
children: React.PropTypes.node,
colon: React.PropTypes.bool
}
};
static contextTypes = {
form: React.PropTypes.object,
}
};
shouldComponentUpdate(...args) {
return PureRenderMixin.shouldComponentUpdate.apply(this, args);

View File

@ -2,5 +2,5 @@ import * as React from 'react';
export default props => {
const { type, className = '' } = props;
return <i {...props} className={`${className} anticon anticon-${type}`.trim()} />
return <i {...props} className={`${className} anticon anticon-${type}`.trim()} />;
};

View File

@ -7,11 +7,11 @@ export default class InputNumber extends React.Component {
static defaultProps = {
prefixCls: 'ant-input-number',
step: 1,
}
};
render() {
const [{className, size}, others] = splitObject(this.props,
['size','className']);
const [{ className, size }, others] = splitObject(this.props,
['size', 'className']);
const inputNumberClass = classNames({
[`${this.props.prefixCls}-lg`]: size === 'large',
[`${this.props.prefixCls}-sm`]: size === 'small',

View File

@ -35,7 +35,7 @@ export default class Input extends Component {
onPressEnter() {},
onKeyDown() {},
autosize: false,
}
};
static propTypes = {
type: PropTypes.string,
@ -54,7 +54,7 @@ export default class Input extends Component {
autosize: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
onPressEnter: PropTypes.func,
onKeyDown: PropTypes.func,
}
};
constructor(props) {
super(props);

View File

@ -5,9 +5,10 @@ import assign from 'object-assign';
const stringOrNumber = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
const objectOrNumber = PropTypes.oneOfType([PropTypes.object, PropTypes.number]);
import splitObject from '../_util/splitObject';
export default function Col(props) {
const [{span, order, offset, push, pull, className, children}, others] = splitObject(props,
['span', 'order','offset', 'push','pull', 'className','children']);
const [{ span, order, offset, push, pull, className, children }, others] = splitObject(props,
['span', 'order', 'offset', 'push', 'pull', 'className', 'children']);
let sizeClassObj = {};
['xs', 'sm', 'md', 'lg'].forEach(size => {
let sizeProps = {};
@ -34,7 +35,7 @@ export default function Col(props) {
[`ant-col-push-${push}`]: push,
[`ant-col-pull-${pull}`]: pull,
[className]: !!className,
},sizeClassObj));
}, sizeClassObj));
return <div {...others} className={classes}>{children}</div>;
}

View File

@ -5,7 +5,7 @@ import splitObject from '../_util/splitObject';
export default class Row extends React.Component {
static defaultProps = {
gutter: 0,
}
};
static propTypes = {
type: React.PropTypes.string,
align: React.PropTypes.string,
@ -13,10 +13,10 @@ export default class Row extends React.Component {
className: React.PropTypes.string,
children: React.PropTypes.node,
gutter: React.PropTypes.number,
}
};
render() {
const [{type, justify, align, className, gutter, style, children}, others] = splitObject(this.props,
['type', 'justify','align', 'className','gutter', 'style','children']);
const [{ type, justify, align, className, gutter, style, children }, others] = splitObject(this.props,
['type', 'justify', 'align', 'className', 'gutter', 'style', 'children']);
const classes = classNames({
'ant-row': !type,
[`ant-row-${type}`]: type,
@ -27,9 +27,11 @@ export default class Row extends React.Component {
const rowStyle = gutter > 0 ? assign({}, {
marginLeft: gutter / -2,
marginRight: gutter / -2,
},style) : style;
}, style) : style;
const cols = Children.map(children, col => {
if (!col) return null;
if (!col) {
return null;
}
return cloneElement(col, {
style: gutter > 0 ? assign({}, {

View File

@ -4,11 +4,11 @@ import { changeConfirmLocale } from '../modal/locale';
export default class LocaleProvider extends React.Component {
static propTypes = {
locale: React.PropTypes.object,
}
};
static childContextTypes = {
antLocale: React.PropTypes.object,
}
};
getChildContext() {
return {

View File

@ -17,7 +17,7 @@ export default class Menu extends React.Component {
onClose: noop,
className: '',
theme: 'light', // or dark
}
};
constructor(props) {
super(props);
this.state = {

View File

@ -19,7 +19,7 @@ export default class Modal extends React.Component {
maskTransitionName: 'fade',
confirmLoading: false,
visible: false,
}
};
static propTypes = {
prefixCls: PropTypes.string,
@ -34,11 +34,11 @@ export default class Modal extends React.Component {
footer: PropTypes.node,
title: PropTypes.node,
closable: PropTypes.bool,
}
};
static contextTypes = {
antLocale: React.PropTypes.object,
}
};
handleCancel = (e) => {
this.props.onCancel(e);

View File

@ -91,7 +91,7 @@ const api = {
};
['success', 'info', 'warning', 'error'].forEach((type) => {
api[type] = (args) => api.open(assign({}, args,{ icon: type }));
api[type] = (args) => api.open(assign({}, args, { icon: type }));
});
api.warn = api.warning;

View File

@ -9,11 +9,11 @@ export default class Pagination extends React.Component {
locale: zhCN,
className: '',
prefixCls: 'ant-pagination',
}
};
static contextTypes = {
antLocale: React.PropTypes.object,
}
};
render() {
let className = this.props.className;

View File

@ -17,11 +17,11 @@ export default class Popconfirm extends React.Component {
onConfirm: noop,
onCancel: noop,
onVisibleChange: noop,
}
};
static contextTypes = {
antLocale: React.PropTypes.object,
}
};
constructor(props) {
super(props);
@ -58,7 +58,7 @@ export default class Popconfirm extends React.Component {
}
render() {
const [{ title, placement, overlayStyle, trigger },restProps] = splitObject(this.props,
const [{ title, placement, overlayStyle, trigger }, restProps] = splitObject(this.props,
['title', 'placement', 'overlayStyle', 'trigger']);
let { okText, cancelText } = this.props;
if (this.context.antLocale && this.context.antLocale.Popconfirm) {

View File

@ -14,7 +14,7 @@ export default class Popover extends React.Component {
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
overlayStyle: {},
}
};
render() {
return (

View File

@ -17,7 +17,7 @@ export default class Line extends React.Component {
showInfo: true,
trailColor: '#f3f3f3',
prefixCls: 'ant-progress',
}
};
static propTypes = {
status: PropTypes.oneOf(['normal', 'exception', 'active', 'success']),
@ -28,13 +28,13 @@ export default class Line extends React.Component {
strokeWidth: PropTypes.number,
trailColor: PropTypes.string,
format: PropTypes.func,
}
};
render() {
const [{
prefixCls, status, format, percent, trailColor,
type, strokeWidth, width, className, showInfo
},restProps] = splitObject(this.props,
}, restProps] = splitObject(this.props,
['prefixCls', 'status', 'format', 'percent', 'trailColor', 'type', 'strokeWidth', 'width',
'className', 'showInfo']);
const progressStatus = (parseInt(percent, 10) >= 100 && !('status' in this.props))

View File

@ -22,7 +22,7 @@ export default class RadioGroup extends React.Component {
disabled: false,
onChange() {
},
}
};
constructor(props) {
super(props);
let value;

View File

@ -6,7 +6,7 @@ import PureRenderMixin from 'react-addons-pure-render-mixin';
export default class Radio extends React.Component {
static defaultProps = {
prefixCls: 'ant-radio',
}
};
shouldComponentUpdate(...args) {
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
}

View File

@ -4,7 +4,7 @@ import Radio from './radio';
export default class RadioButton extends React.Component {
static defaultProps = {
prefixCls: 'ant-radio-button',
}
};
render() {
return (
<Radio {...this.props} />

View File

@ -11,11 +11,11 @@ export default class Select extends React.Component {
transitionName: 'slide-up',
choiceTransitionName: 'zoom',
showSearch: false,
}
};
static contextTypes = {
antLocale: React.PropTypes.object,
}
};
render() {
let {

View File

@ -5,7 +5,7 @@ export default class Slider extends React.Component {
static defaultProps = {
prefixCls: 'ant-slider',
tipTransitionName: 'zoom-down',
}
};
render() {
const [{isIncluded, marks, index, defaultIndex}, others] = splitObject(this.props,

View File

@ -10,7 +10,7 @@ export default class Spin extends React.Component {
static defaultProps = {
prefixCls: 'ant-spin',
spinning: true,
}
};
constructor(props) {
super(props);
@ -23,7 +23,7 @@ export default class Spin extends React.Component {
static propTypes = {
className: React.PropTypes.string,
size: React.PropTypes.oneOf(['small', 'default', 'large']),
}
};
isNestedPattern() {
return !!(this.props && this.props.children);
@ -67,7 +67,7 @@ export default class Spin extends React.Component {
render() {
const [{
className, size, prefixCls, tip
},restProps] = splitObject(this.props,
}, restProps] = splitObject(this.props,
['className', 'size', 'prefixCls', 'tip']);
const { spinning } = this.state;

View File

@ -8,7 +8,7 @@ export default class Steps extends React.Component {
prefixCls: 'ant-steps',
iconPrefix: 'ant',
current: 0,
}
};
render() {
return (

View File

@ -5,7 +5,7 @@ import classNames from 'classnames';
export default class Switch extends React.Component {
static defaultProps = {
prefixCls: 'ant-switch',
}
};
render() {
const { prefixCls, size, className } = this.props;

View File

@ -44,7 +44,7 @@ export default class Table extends React.Component {
bordered: React.PropTypes.bool,
onChange: React.PropTypes.func,
locale: React.PropTypes.object,
}
};
static defaultProps = {
dataSource: [],
@ -58,11 +58,11 @@ export default class Table extends React.Component {
indentSize: 20,
onChange: noop,
locale: {},
}
};
static contextTypes = {
antLocale: React.PropTypes.object,
}
};
constructor(props) {
super(props);
@ -730,8 +730,7 @@ export default class Table extends React.Component {
render() {
const [{
style, className
},restProps] = splitObject(this.props,
['style', 'className']);
}, restProps] = splitObject(this.props, ['style', 'className']);
const data = this.getCurrentPageData();
let columns = this.renderRowSelection();
const expandIconAsCell = this.props.expandedRowRender && this.props.expandIconAsCell !== false;

View File

@ -9,7 +9,7 @@ export default class FilterMenu extends React.Component {
static defaultProps = {
handleFilter() {},
column: null,
}
};
constructor(props) {
super(props);

View File

@ -7,24 +7,24 @@ import splitObject from '../_util/splitObject';
import omit from 'object.omit';
export interface TagProps {
/** 标签是否可以关闭*/
closable?: boolean,
/** 关闭时的回调*/
onClose?: Function,
/** 动画关闭后的回调*/
afterClose?: Function,
/** 标签的色彩*/
color?: string,
style?: React.CSSProperties
/** 标签是否可以关闭 */
closable?: boolean;
/** 关闭时的回调 */
onClose?: Function;
/** 动画关闭后的回调 */
afterClose?: Function;
/** 标签的色彩 */
color?: string;
style?: React.CSSProperties;
}
export default class Tag extends React.Component<TagProps, any> {
static defaultProps = {
prefixCls: 'ant-tag',
closable: false,
onClose() { },
afterClose() { },
}
};
constructor(props) {
super(props);
@ -37,7 +37,9 @@ export default class Tag extends React.Component<TagProps, any> {
close = (e) => {
this.props.onClose(e);
if (e.defaultPrevented) return;
if (e.defaultPrevented) {
return;
}
const dom = ReactDOM.findDOMNode(this);
dom.style.width = `${dom.getBoundingClientRect().width}px`;
// It's Magic Code, don't know why
@ -62,7 +64,7 @@ export default class Tag extends React.Component<TagProps, any> {
prefixCls, closable, color, className, children
}, otherProps] = splitObject(
this.props,
['prefixCls', 'closable', 'color','className','children']
['prefixCls', 'closable', 'color', 'className', 'children']
);
const closeIcon = closable ? <Icon type="cross" onClick={this.close} /> : '';
const classString = classNames({

View File

@ -8,30 +8,30 @@ import assign from 'object-assign';
// TimePicker
export interface TimePickerProps {
/** 默认时间*/
value?: string | Date,
/** 初始默认时间*/
defaultValue?: string | Date,
/** 默认时间 */
value?: string | Date;
/** 初始默认时间 */
defaultValue?: string | Date;
/** 展示的时间格式 : "HH:mm:ss"、"HH:mm"、"mm:ss" */
format?: string,
/** 时间发生变化的回调*/
onChange?: (Date: Date) => void,
/** 禁用全部操作*/
disabled?: boolean,
/** 没有值的时候显示的内容*/
placeholder?: string,
/** 国际化配置*/
locale?: Object,
/** 隐藏禁止选择的选项*/
hideDisabledOptions?: boolean,
/** 禁止选择部分小时选项*/
disabledHours?: Function,
/** 禁止选择部分分钟选项*/
disabledMinutes?: Function,
/** 禁止选择部分秒选项*/
disabledSeconds?: Function,
format?: string;
/** 时间发生变化的回调 */
onChange?: (Date: Date) => void;
/** 禁用全部操作 */
disabled?: boolean;
/** 没有值的时候显示的内容 */
placeholder?: string;
/** 国际化配置 */
locale?: Object;
/** 隐藏禁止选择的选项 */
hideDisabledOptions?: boolean;
/** 禁止选择部分小时选项 */
disabledHours?: Function;
/** 禁止选择部分分钟选项 */
disabledMinutes?: Function;
/** 禁止选择部分秒选项 */
disabledSeconds?: Function;
style?: React.CSSProperties
style?: React.CSSProperties;
}
export default class TimePicker extends React.Component<TimePickerProps, any> {
static defaultProps = {
@ -50,11 +50,11 @@ export default class TimePicker extends React.Component<TimePickerProps, any> {
hideDisabledOptions: false,
placement: 'bottomLeft',
transitionName: 'slide-up',
}
};
static contextTypes = {
antLocale: React.PropTypes.object,
}
};
getFormatter() {
return new DateTimeFormat(this.props.format, this.getLocale().format);

View File

@ -4,15 +4,14 @@ import TimelineItem from './TimelineItem';
import splitObject from '../_util/splitObject';
export interface TimelineProps {
/** 指定最后一个幽灵节点是否存在或内容*/
pending?: boolean | React.ReactNode,
style?: React.CSSProperties
/** 指定最后一个幽灵节点是否存在或内容 */
pending?: boolean | React.ReactNode;
style?: React.CSSProperties;
}
export default class Timeline extends React.Component<TimelineProps, any> {
static defaultProps = {
prefixCls: 'ant-timeline',
}
};
render() {
const [{

View File

@ -4,18 +4,19 @@ import splitObject from '../_util/splitObject';
// Timeline
export interface TimeLineItemProps {
/** 指定圆圈颜色*/
color?: string,
dot?: React.ReactNode,
style?: React.CSSProperties
/** 指定圆圈颜色 */
color?: string;
dot?: React.ReactNode;
style?: React.CSSProperties;
}
export default class TimelineItem extends React.Component<TimeLineItemProps, any> {
static defaultProps = {
prefixCls: 'ant-timeline',
color: 'blue',
last: false,
pending: false,
}
};
render() {
const [{

View File

@ -6,17 +6,18 @@ import getPlacements from '../popover/placements';
const placements = getPlacements({
verticalArrowShift: 8,
});
type PopoverPlacement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom'
// Tooltip
export interface TooltipProps {
/** 气泡框位置,可选 `top` `left` `right` `bottom` `topLeft` `topRight` `bottomLeft` `bottomRight` `leftTop` `leftBottom` `rightTop` `rightBottom`*/
placement?: PopoverPlacement,
/** 提示文字*/
title?: string | React.ReactNode,
style?: React.CSSProperties
placement?: PopoverPlacement;
/** 提示文字 */
title?: string | React.ReactNode;
style?: React.CSSProperties;
}
export default class Tooltip extends React.Component<TooltipProps, any> {
static defaultProps = {
prefixCls: 'ant-tooltip',
@ -24,8 +25,8 @@ export default class Tooltip extends React.Component<TooltipProps, any> {
transitionName: 'zoom-big',
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
onVisibleChange() { },
}
onVisibleChange() {},
};
constructor(props) {
super(props);

View File

@ -3,46 +3,44 @@ import List from './list';
import Operation from './operation';
import Search from './search';
import classNames from 'classnames';
import assign from 'object-assign';
function noop() {
}
export interface TransferItem {
key:number | string,
title:string,
description?:string,
chosen:boolean,
key: number | string;
title: string;
description?: string;
chosen: boolean;
}
// Transfer
export interface TransferProps {
/** 数据源*/
dataSource:Array<TransferItem>,
/** 每行数据渲染函数*/
render?:(record:TransferItem) => any,
/** 显示在右侧框数据的key集合*/
targetKeys:Array<string>,
/** 变化时回调函数*/
onChange?:(targetKeys:Array<TransferItem>, direction:string, moveKeys:any) => void,
/** 两个穿梭框的自定义样式*/
listStyle?:React.CSSProperties,
/** 数据源 */
dataSource: Array<TransferItem>;
/** 每行数据渲染函数 */
render?: (record:TransferItem) => any;
/** 显示在右侧框数据的key集合 */
targetKeys: Array<string>;
/** 变化时回调函数 */
onChange?: (targetKeys:Array<TransferItem>, direction:string, moveKeys:any) => void;
/** 两个穿梭框的自定义样式 */
listStyle?: React.CSSProperties;
/** 自定义类*/
className?:string,
/** 标题集合,顺序从左至右*/
titles?:Array<string>,
/** 操作文案集合,顺序从上至下*/
operations?:Array<string>,
/** 是否显示搜索框*/
showSearch?:boolean,
/** 搜索框的默认值*/
searchPlaceholder?:string,
/** 当列表为空时显示的内容*/
notFoundContent?:React.ReactNode | string
/** 底部渲染函数*/
footer?:(props:any) => any,
style?:React.CSSProperties
className?: string;
/** 标题集合,顺序从左至右 */
titles?: Array<string>;
/** 操作文案集合,顺序从上至下 */
operations?: Array<string>;
/** 是否显示搜索框 */
showSearch?: boolean;
/** 搜索框的默认值 */
searchPlaceholder?: string;
/** 当列表为空时显示的内容 */
notFoundContent?: React.ReactNode | string;
/** 底部渲染函数 */
footer?: (props:any) => any;
style?: React.CSSProperties;
}
export default class Transfer extends React.Component<TransferProps, any> {

View File

@ -16,32 +16,32 @@ export function isRenderResultPlainObject(result) {
}
export interface TransferListProps {
prefixCls?: string,
prefixCls?: string;
/** 数据源 */
dataSource: Array<TransferItem>,
filter?: TransferItem,
dataSource: Array<TransferItem>;
filter?: TransferItem;
/** 是否显示搜索框 */
showSearch?: boolean,
showSearch?: boolean;
/** 搜索框的默认值 */
searchPlaceholder?: string,
searchPlaceholder?: string;
/** 标题 */
titleText?: string,
style?: React.CSSProperties,
handleFilter?: Function,
handleSelect?: Function,
handleSelectAll?: Function,
handleClear?: Function,
titleText?: string;
style?: React.CSSProperties;
handleFilter?: Function;
handleSelect?: Function;
handleSelectAll?: Function;
handleClear?: Function;
/** 每行渲染函数 */
render?: Function,
render?: Function;
/** 主体渲染函数 */
body?: Function,
body?: Function;
/** 底部渲染函数 */
footer?: Function,
footer?: Function;
/** 选中项 */
checkedKeys?: Array<TransferItem>;
checkStatus?: boolean,
position?: string,
notFoundContent?: React.ReactNode | string,
checkStatus?: boolean;
position?: string;
notFoundContent?: React.ReactNode | string;
}
export default class TransferList extends React.Component<TransferListProps, any> {

View File

@ -6,13 +6,13 @@ function noop() {
}
export interface TransferOperationProps {
className?: string,
leftArrowText?: string,
rightArrowText?: string,
moveToLeft?: Function,
moveToRight?: Function,
leftActive?: boolean,
rightActive?: boolean
className?: string;
leftArrowText?: string;
rightArrowText?: string;
moveToLeft?: Function;
moveToRight?: Function;
leftActive?: boolean;
rightActive?: boolean;
}
export default class TransferOperation extends React.Component<TransferOperationProps, any> {
@ -21,7 +21,7 @@ export default class TransferOperation extends React.Component<TransferOperation
rightArrowText: '',
moveToLeft: noop,
moveToRight: noop,
}
};
render() {
const {

View File

@ -4,10 +4,10 @@ function noop() {
}
export interface SearchProps {
prefixCls?: string,
placeholder?: string,
onChange?: (e: React.FormEvent) => void,
handleClear?: (e: React.MouseEvent) => void
prefixCls?: string;
placeholder?: string;
onChange?: (e: React.FormEvent) => void;
handleClear?: (e: React.MouseEvent) => void;
value?: any;
}
@ -16,7 +16,7 @@ export default class Search extends React.Component<SearchProps, any> {
placeholder: '',
onChange: noop,
handleClear: noop,
}
};
handleChange = (e) => {
this.props.onChange(e);

View File

@ -14,11 +14,11 @@ export default class TreeSelect extends React.Component {
choiceTransitionName: 'zoom',
showSearch: false,
dropdownClassName: 'ant-select-tree-dropdown',
}
};
static contextTypes = {
antLocale: React.PropTypes.object,
}
};
render() {
const props = this.props;

View File

@ -3,85 +3,81 @@ import RcTree from 'rc-tree';
import animation from '../_util/openAnimation';
export interface TreeNodeProps {
disabled?:boolean,
disableCheckbox?:boolean,
title?:string | React.ReactNode,
key?:string,
isLeaf?:boolean
disabled?: boolean;
disableCheckbox?: boolean;
title?: string | React.ReactNode;
key?: string;
isLeaf?: boolean;
}
export class TreeNode extends React.Component<TreeNodeProps, {}> {
}
export interface TreeNodeEvent {
event:'check' | 'select',
node:TreeNode,
checked?:boolean,
checkedNodes?:Array<TreeNode>,
selected?:boolean,
selectedNodes?:Array<TreeNode>,
event: 'check' | 'select';
node: TreeNode;
checked?: boolean;
checkedNodes?: Array<TreeNode>;
selected?: boolean;
selectedNodes?: Array<TreeNode>;
}
export interface TreeNodeMouseEvent {
node:TreeNode,
event:React.MouseEventHandler,
node: TreeNode;
event: React.MouseEventHandler;
}
export interface TreeProps {
showLine?:boolean,
className?:string,
/** 是否支持多选*/
multiple?:boolean,
showLine?: boolean;
className?:string;
/** 是否支持多选 */
multiple?:boolean;
/**是否自动展开父节点 */
autoExpandParent?:boolean,
autoExpandParent?: boolean;
/**checkable状态下节点选择完全受控父子节点选中状态不再关联*/
checkStrictly?:boolean,
/** 是否支持选中*/
checkable?:boolean,
/** 默认展开所有树节点*/
defaultExpandAll?:boolean,
/** 默认展开指定的树节点*/
defaultExpandedKeys?:Array<string>,
/** (受控)展开指定的树节点*/
expandedKeys?:Array<string>,
/** (受控)选中复选框的树节点*/
checkedKeys?:Array<string>,
/** 默认选中复选框的树节点*/
defaultCheckedKeys?:Array<string>,
/** (受控)设置选中的树节点*/
selectedKeys?:Array<string>,
/** 默认选中的树节点*/
defaultSelectedKeys?:Array<string>,
checkStrictly?: boolean;
/** 是否支持选中 */
checkable?: boolean;
/** 默认展开所有树节点 */
defaultExpandAll?: boolean;
/** 默认展开指定的树节点 */
defaultExpandedKeys?: Array<string>;
/** (受控)展开指定的树节点 */
expandedKeys?: Array<string>;
/** (受控)选中复选框的树节点 */
checkedKeys?: Array<string>;
/** 默认选中复选框的树节点 */
defaultCheckedKeys?: Array<string>;
/** (受控)设置选中的树节点 */
selectedKeys?: Array<string>;
/** 默认选中的树节点 */
defaultSelectedKeys?: Array<string>;
/** 展开/收起节点时触发 */
onExpand?:(expandedKeys:Array<string>, {node: TreeNode, expanded: boolean}) => void | PromiseLike<any>,
/** 点击复选框触发*/
onCheck?:(checkedKeys:Array<string>, e:TreeNodeEvent) => void,
/** 点击树节点触发*/
onSelect?:(selectedKeys:Array<string>, e:TreeNodeEvent) => void,
onExpand?: (expandedKeys: Array<string>, {node: TreeNode, expanded: boolean}) => void | PromiseLike<any>;
/** 点击复选框触发 */
onCheck?: (checkedKeys: Array<string>, e: TreeNodeEvent) => void;
/** 点击树节点触发 */
onSelect?: (selectedKeys: Array<string>, e: TreeNodeEvent) => void;
/** filter some treeNodes as you need. it should return true */
filterTreeNode?:(node:TreeNode) => boolean,
/** 异步加载数据*/
loadData?:(node:TreeNode) => PromiseLike<any>,
/** 响应右键点击*/
onRightClick?:(options:TreeNodeMouseEvent) => void,
filterTreeNode?: (node: TreeNode) => boolean;
/** 异步加载数据 */
loadData?: (node: TreeNode) => PromiseLike<any>;
/** 响应右键点击 */
onRightClick?: (options: TreeNodeMouseEvent) => void;
/** 设置节点可拖拽IE>8*/
draggable?:boolean,
/** 开始拖拽时调用*/
onDragStart?:(options:TreeNodeMouseEvent) => void,
/** dragenter 触发时调用*/
onDragEnter?:(options:TreeNodeMouseEvent) => void,
draggable?: boolean;
/** 开始拖拽时调用 */
onDragStart?: (options:TreeNodeMouseEvent) => void;
/** dragenter 触发时调用 */
onDragEnter?: (options:TreeNodeMouseEvent) => void;
/** dragover 触发时调用 */
onDragOver?:(options:TreeNodeMouseEvent) => void,
/** dragleave 触发时调用*/
onDragLeave?:(options:TreeNodeMouseEvent) => void,
/** drop 触发时调用*/
onDrop?:(options:TreeNodeMouseEvent) => void,
style?:React.CSSProperties,
prefixCls?: string
onDragOver?: (options:TreeNodeMouseEvent) => void;
/** dragleave 触发时调用 */
onDragLeave?: (options:TreeNodeMouseEvent) => void;
/** drop 触发时调用 */
onDrop?: (options:TreeNodeMouseEvent) => void;
style?: React.CSSProperties;
prefixCls?: string;
}
export default class Tree extends React.Component<TreeProps, any> {
@ -92,7 +88,7 @@ export default class Tree extends React.Component<TreeProps, any> {
checkable: false,
showIcon: false,
openAnimation: animation,
}
};
render() {
const props = this.props;

View File

@ -72,7 +72,7 @@ export default class Upload extends React.Component {
showUploadList: true,
listType: 'text', // or pictrue
className: '',
}
};
constructor(props) {
super(props);
@ -83,7 +83,9 @@ export default class Upload extends React.Component {
}
onStart = (file) => {
if (this.recentUploadStatus === false) return;
if (this.recentUploadStatus === false) {
return;
}
let targetItem;
let nextFileList = this.state.fileList.concat();

View File

@ -132,7 +132,7 @@
"pre-deploy": "mkdir -p _site && cp CNAME _site",
"deploy": "tnpm run clean && tnpm i && tnpm run just-deploy",
"just-deploy": "tnpm run pre-deploy && bisheng gh-pages -c ./site/bisheng.config.js",
"lint": "npm run srclint && npm run demolint && npm run lesshint",
"lint": "npm run ts-lint && npm run demolint && npm run lesshint",
"srclint": "RUN_ENV=SRC eslint test site scripts ./*.js --ext '.js,.jsx'",
"ts-lint": "antd-tools run ts-lint",
"demolint": "RUN_ENV=DEMO eslint components/*/demo/*.md --ext '.md'",