Merge pull request #1292 from waywardmonkeys/static-members

Use static class members for propTypes and friends.
This commit is contained in:
yiminghe 2016-03-29 16:36:30 +08:00
commit 55f23c9d34
33 changed files with 487 additions and 463 deletions

View File

@ -7,6 +7,24 @@ function getNumberArray(num) {
}
export default class ScrollNumber extends React.Component {
static defaultProps = {
prefixCls: 'ant-scroll-number',
count: null,
component: 'sup',
onAnimated() {},
height: 18,
}
static propTypes = {
count: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number
]),
component: React.PropTypes.string,
onAnimated: React.PropTypes.func,
height: React.PropTypes.number,
}
constructor(props) {
super(props);
this.state = {
@ -112,21 +130,3 @@ export default class ScrollNumber extends React.Component {
);
}
}
ScrollNumber.defaultProps = {
prefixCls: 'ant-scroll-number',
count: null,
component: 'sup',
onAnimated() {},
height: 18,
};
ScrollNumber.propTypes = {
count: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number
]),
component: React.PropTypes.string,
onAnimated: React.PropTypes.func,
height: React.PropTypes.number,
};

View File

@ -4,6 +4,22 @@ import ScrollNumber from './ScrollNumber';
import classNames from 'classnames';
export default class Badge extends React.Component {
static defaultProps = {
prefixCls: 'ant-badge',
count: null,
dot: false,
overflowCount: 99,
}
static propTypes = {
count: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number
]),
dot: React.PropTypes.bool,
overflowCount: React.PropTypes.number,
}
render() {
let { count, prefixCls, overflowCount, className, style, children } = this.props;
const dot = this.props.dot;
@ -41,19 +57,3 @@ export default class Badge extends React.Component {
);
}
}
Badge.defaultProps = {
prefixCls: 'ant-badge',
count: null,
dot: false,
overflowCount: 99,
};
Badge.propTypes = {
count: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number
]),
dot: React.PropTypes.bool,
overflowCount: React.PropTypes.number,
};

View File

@ -2,6 +2,20 @@ import React, { cloneElement } from 'react';
/* Exported as Breadcrumb.Item */
class BreadcrumbItem extends React.Component {
static defaultProps = {
prefixCls: 'ant-breadcrumb',
separator: '/',
}
static propTypes = {
prefixCls: React.PropTypes.string,
separator: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.element,
]),
href: React.PropTypes.string,
}
render() {
const { prefixCls, separator, children } = this.props;
let link = <a className={`${prefixCls}-link`} {...this.props}>{children}</a>;
@ -17,21 +31,25 @@ class BreadcrumbItem extends React.Component {
}
}
BreadcrumbItem.defaultProps = {
export default class Breadcrumb extends React.Component {
static Item = BreadcrumbItem;
static defaultProps = {
prefixCls: 'ant-breadcrumb',
separator: '/',
};
linkRender: (href, name) => <a href={`#${href}`}>{name}</a>,
}
BreadcrumbItem.propTypes = {
static propTypes = {
prefixCls: React.PropTypes.string,
separator: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.element,
]),
href: React.PropTypes.string,
};
routes: React.PropTypes.array,
params: React.PropTypes.object,
}
export default class Breadcrumb extends React.Component {
render() {
let crumbs;
const { separator, prefixCls, routes, params, children, linkRender } = this.props;
@ -76,21 +94,3 @@ export default class Breadcrumb extends React.Component {
);
}
}
Breadcrumb.defaultProps = {
prefixCls: 'ant-breadcrumb',
separator: '/',
linkRender: (href, name) => <a href={`#${href}`}>{name}</a>,
};
Breadcrumb.propTypes = {
prefixCls: React.PropTypes.string,
separator: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.element,
]),
routes: React.PropTypes.array,
params: React.PropTypes.object,
};
Breadcrumb.Item = BreadcrumbItem;

View File

@ -4,6 +4,10 @@ import classNames from 'classnames';
const prefix = 'ant-btn-group-';
export default class ButtonGroup extends React.Component {
static propTypes = {
size: React.PropTypes.oneOf(['large', 'small']),
}
render() {
const { size, className, ...others } = this.props;
@ -23,6 +27,3 @@ export default class ButtonGroup extends React.Component {
return <div {...others} className={classes} />;
}
}
ButtonGroup.propTypes = {
size: React.PropTypes.oneOf(['large', 'small']),
};

View File

@ -30,6 +30,21 @@ function clearButton(button) {
}
export default class Button extends React.Component {
static defaultProps = {
onClick() {},
}
static propTypes = {
type: React.PropTypes.oneOf(['primary', 'ghost', 'dashed']),
shape: React.PropTypes.oneOf(['circle', 'circle-outline']),
size: React.PropTypes.oneOf(['large', 'small']),
htmlType: React.PropTypes.oneOf(['submit', 'button', 'reset']),
onClick: React.PropTypes.func,
loading: React.PropTypes.bool,
className: React.PropTypes.string,
icon: React.PropTypes.string,
}
handleClick = (...args) => {
// Add click effect
const buttonNode = findDOMNode(this);
@ -40,6 +55,7 @@ export default class Button extends React.Component {
this.props.onClick(...args);
}
render() {
const props = this.props;
const { type, shape, size, className, htmlType, children, icon, ...others } = props;
@ -72,18 +88,3 @@ export default class Button extends React.Component {
);
}
}
Button.propTypes = {
type: React.PropTypes.oneOf(['primary', 'ghost', 'dashed']),
shape: React.PropTypes.oneOf(['circle', 'circle-outline']),
size: React.PropTypes.oneOf(['large', 'small']),
htmlType: React.PropTypes.oneOf(['submit', 'button', 'reset']),
onClick: React.PropTypes.func,
loading: React.PropTypes.bool,
className: React.PropTypes.string,
icon: React.PropTypes.string,
};
Button.defaultProps = {
onClick() {},
};

View File

@ -6,6 +6,26 @@ import { Group, Button } from '../radio';
function noop() {}
export default class Header extends React.Component {
static defaultProps = {
prefixCls: `${PREFIX_CLS}-header`,
yearSelectOffset: 10,
yearSelectTotal: 20,
onValueChange: noop,
onTypeChange: noop,
}
static propTypes = {
value: PropTypes.object,
locale: PropTypes.object,
yearSelectOffset: PropTypes.number,
yearSelectTotal: PropTypes.number,
onValueChange: PropTypes.func,
onTypeChange: PropTypes.func,
prefixCls: PropTypes.string,
selectPrefixCls: PropTypes.string,
type: PropTypes.string,
}
getYearSelectElement(year) {
const { yearSelectOffset, yearSelectTotal, locale, prefixCls, fullscreen } = this.props;
const start = year - yearSelectOffset;
@ -29,6 +49,7 @@ export default class Header extends React.Component {
</Select>
);
}
getMonthSelectElement(month) {
const props = this.props;
const months = props.locale.format.months;
@ -52,6 +73,7 @@ export default class Header extends React.Component {
</Select>
);
}
onYearChange = (year) => {
const newValue = this.props.value.clone();
newValue.setYear(parseInt(year, 10));
@ -63,9 +85,11 @@ export default class Header extends React.Component {
newValue.setMonth(parseInt(month, 10));
this.props.onValueChange(newValue);
}
onTypeChange = (e) => {
this.props.onTypeChange(e.target.value);
}
render() {
const { type, value, prefixCls, locale } = this.props;
const yearSelect = this.getYearSelectElement(value.getYear());
@ -86,23 +110,3 @@ export default class Header extends React.Component {
);
}
}
Header.propTypes = {
value: PropTypes.object,
locale: PropTypes.object,
yearSelectOffset: PropTypes.number,
yearSelectTotal: PropTypes.number,
onValueChange: PropTypes.func,
onTypeChange: PropTypes.func,
prefixCls: PropTypes.string,
selectPrefixCls: PropTypes.string,
type: PropTypes.string,
};
Header.defaultProps = {
prefixCls: `${PREFIX_CLS}-header`,
yearSelectOffset: 10,
yearSelectTotal: 20,
onValueChange: noop,
onTypeChange: noop,
};

View File

@ -13,6 +13,28 @@ function zerofixed(v) {
}
export default class Calendar extends React.Component {
static defaultProps = {
monthCellRender: noop,
dateCellRender: noop,
locale: zhCN,
fullscreen: true,
prefixCls: PREFIX_CLS,
onPanelChange: noop,
mode: 'month',
}
static propTypes = {
monthCellRender: PropTypes.func,
dateCellRender: PropTypes.func,
fullscreen: PropTypes.bool,
locale: PropTypes.object,
prefixCls: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
onPanelChange: PropTypes.func,
value: PropTypes.instanceOf(Date),
}
constructor(props) {
super(props);
this.state = {
@ -20,11 +42,13 @@ export default class Calendar extends React.Component {
mode: props.mode,
};
}
parseDateFromValue(value) {
const date = new GregorianCalendar(this.props.locale);
date.setTime(+value);
return date;
}
componentWillReceiveProps(nextProps) {
if ('value' in nextProps) {
this.setState({
@ -32,6 +56,7 @@ export default class Calendar extends React.Component {
});
}
}
monthCellRender = (value, locale) => {
const prefixCls = this.props.prefixCls;
const month = value.getMonth();
@ -46,6 +71,7 @@ export default class Calendar extends React.Component {
</div>
);
}
dateCellRender = (value) => {
const prefixCls = this.props.prefixCls;
return (
@ -59,12 +85,14 @@ export default class Calendar extends React.Component {
</div>
);
}
setValue = (value) => {
if (!('value' in this.props) && this.state.value !== value) {
this.setState({ value });
}
this.props.onPanelChange(value, this.state.mode);
}
setType = (type) => {
const mode = (type === 'date') ? 'month' : 'year';
if (this.state.mode !== mode) {
@ -72,6 +100,7 @@ export default class Calendar extends React.Component {
this.props.onPanelChange(this.state.value, mode);
}
}
render() {
const props = this.props;
const { value, mode } = this.state;
@ -107,25 +136,3 @@ export default class Calendar extends React.Component {
);
}
}
Calendar.propTypes = {
monthCellRender: PropTypes.func,
dateCellRender: PropTypes.func,
fullscreen: PropTypes.bool,
locale: PropTypes.object,
prefixCls: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
onPanelChange: PropTypes.func,
value: PropTypes.instanceOf(Date),
};
Calendar.defaultProps = {
monthCellRender: noop,
dateCellRender: noop,
locale: zhCN,
fullscreen: true,
prefixCls: PREFIX_CLS,
onPanelChange: noop,
mode: 'month',
};

View File

@ -17,6 +17,11 @@ import SlickCarousel from 'react-slick';
import React from 'react';
export default class Carousel extends React.Component {
static defaultProps = {
dots: true,
arrows: false,
}
render() {
let props = { ...this.props };
@ -37,8 +42,3 @@ export default class Carousel extends React.Component {
);
}
}
Carousel.defaultProps = {
dots: true,
arrows: false,
};

View File

@ -6,6 +6,21 @@ import arrayTreeFilter from 'array-tree-filter';
import classNames from 'classnames';
export default class Cascader extends React.Component {
static defaultProps = {
prefixCls: 'ant-cascader',
placeholder: '请选择',
transitionName: 'slide-up',
popupPlacement: 'bottomLeft',
onChange() {},
options: [],
displayRender(label) {
return label.join(' / ');
},
disabled: false,
allowClear: true,
onPopupVisibleChange() {},
}
constructor(props) {
super(props);
this.state = {
@ -13,36 +28,43 @@ export default class Cascader extends React.Component {
popupVisible: false,
};
}
componentWillReceiveProps(nextProps) {
if ('value' in nextProps) {
this.setState({ value: nextProps.value || [] });
}
}
handleChange = (value, selectedOptions) => {
this.setValue(value, selectedOptions);
}
handlePopupVisibleChange = (popupVisible) => {
this.setState({ popupVisible });
this.props.onPopupVisibleChange(popupVisible);
}
setValue = (value, selectedOptions = []) => {
if (!('value' in this.props)) {
this.setState({ value });
}
this.props.onChange(value, selectedOptions);
}
getLabel() {
const { options, displayRender } = this.props;
const label = arrayTreeFilter(options, (o, level) => o.value === this.state.value[level])
.map(o => o.label);
return displayRender(label);
}
clearSelection = (e) => {
e.preventDefault();
e.stopPropagation();
this.setValue([]);
this.setState({ popupVisible: false });
}
render() {
const { prefixCls, children, placeholder, size, disabled,
className, style, allowClear, ...otherProps } = this.props;
@ -92,18 +114,3 @@ export default class Cascader extends React.Component {
);
}
}
Cascader.defaultProps = {
prefixCls: 'ant-cascader',
placeholder: '请选择',
transitionName: 'slide-up',
popupPlacement: 'bottomLeft',
onChange() {},
options: [],
displayRender(label) {
return label.join(' / ');
},
disabled: false,
allowClear: true,
onPopupVisibleChange() {},
};

View File

@ -2,13 +2,13 @@ import RcCollapse from 'rc-collapse';
import React from 'react';
export default class Collapse extends React.Component {
static Panel = RcCollapse.Panel;
static defaultProps = {
prefixCls: 'ant-collapse',
}
render() {
return <RcCollapse {...this.props} />;
}
}
Collapse.defaultProps = {
prefixCls: 'ant-collapse',
};
Collapse.Panel = RcCollapse.Panel;

View File

@ -6,6 +6,19 @@ const ButtonGroup = Button.Group;
import classNames from 'classnames';
export default class DropdownButton extends React.Component {
static defaultProps = {
align: {
points: ['tr', 'br'],
overlay: {
adjustX: 1,
adjustY: 1,
},
offset: [0, 4],
targetOffset: [0, 0],
},
type: 'default',
}
render() {
const { type, overlay, trigger, align, children, className, ...restProps } = this.props;
const cls = classNames({
@ -24,16 +37,3 @@ export default class DropdownButton extends React.Component {
);
}
}
DropdownButton.defaultProps = {
align: {
points: ['tr', 'br'],
overlay: {
adjustX: 1,
adjustY: 1,
},
offset: [0, 4],
targetOffset: [0, 0],
},
type: 'default',
};

View File

@ -2,6 +2,13 @@ import React from 'react';
import RcDropdown from 'rc-dropdown';
export default class Dropdown extends React.Component {
static defaultProps = {
transitionName: 'slide-up',
prefixCls: 'ant-dropdown',
mouseEnterDelay: 0.15,
mouseLeaveDelay: 0.1,
}
render() {
const { overlay, ...otherProps } = this.props;
const menu = React.cloneElement(overlay, {
@ -12,10 +19,3 @@ export default class Dropdown extends React.Component {
);
}
}
Dropdown.defaultProps = {
transitionName: 'slide-up',
prefixCls: 'ant-dropdown',
mouseEnterDelay: 0.15,
mouseLeaveDelay: 0.1,
};

View File

@ -2,6 +2,26 @@ import React from 'react';
import classNames from 'classnames';
export default class Form extends React.Component {
static defaultProps = {
prefixCls: 'ant-form',
onSubmit(e) {
e.preventDefault();
},
}
static propTypes = {
prefixCls: React.PropTypes.string,
horizontal: React.PropTypes.bool,
inline: React.PropTypes.bool,
form: React.PropTypes.object,
children: React.PropTypes.any,
onSubmit: React.PropTypes.func,
}
static childContextTypes = {
form: React.PropTypes.object,
}
getChildContext() {
return {
form: this.props.form,
@ -23,23 +43,3 @@ export default class Form extends React.Component {
);
}
}
Form.propTypes = {
prefixCls: React.PropTypes.string,
horizontal: React.PropTypes.bool,
inline: React.PropTypes.bool,
form: React.PropTypes.object,
children: React.PropTypes.any,
onSubmit: React.PropTypes.func,
};
Form.defaultProps = {
prefixCls: 'ant-form',
onSubmit(e) {
e.preventDefault();
},
};
Form.childContextTypes = {
form: React.PropTypes.object,
};

View File

@ -8,6 +8,28 @@ function prefixClsFn(prefixCls, ...args) {
}
export default class FormItem extends React.Component {
static defaultProps = {
hasFeedback: false,
prefixCls: 'ant-form',
}
static propTypes = {
prefixCls: React.PropTypes.string,
label: React.PropTypes.node,
labelCol: React.PropTypes.object,
help: React.PropTypes.oneOfType([React.PropTypes.node, React.PropTypes.bool]),
validateStatus: React.PropTypes.oneOf(['', 'success', 'warning', 'error', 'validating']),
hasFeedback: React.PropTypes.bool,
wrapperCol: React.PropTypes.object,
className: React.PropTypes.string,
id: React.PropTypes.string,
children: React.PropTypes.node,
}
static contextTypes = {
form: React.PropTypes.object,
}
_getLayoutClass(colDef) {
if (!colDef) {
return '';
@ -183,25 +205,3 @@ export default class FormItem extends React.Component {
return this.renderFormItem(children);
}
}
FormItem.propTypes = {
prefixCls: React.PropTypes.string,
label: React.PropTypes.node,
labelCol: React.PropTypes.object,
help: React.PropTypes.oneOfType([React.PropTypes.node, React.PropTypes.bool]),
validateStatus: React.PropTypes.oneOf(['', 'success', 'warning', 'error', 'validating']),
hasFeedback: React.PropTypes.bool,
wrapperCol: React.PropTypes.object,
className: React.PropTypes.string,
id: React.PropTypes.string,
children: React.PropTypes.node,
};
FormItem.defaultProps = {
hasFeedback: false,
prefixCls: 'ant-form',
};
FormItem.contextTypes = {
form: React.PropTypes.object,
};

View File

@ -3,6 +3,11 @@ import classNames from 'classnames';
import RcInputNumber from 'rc-input-number';
export default class InputNumber extends React.Component {
static defaultProps = {
prefixCls: 'ant-input-number',
step: 1,
}
render() {
const { className, size, ...other } = this.props;
const inputNumberClass = classNames({
@ -14,8 +19,3 @@ export default class InputNumber extends React.Component {
return <RcInputNumber className={inputNumberClass} {...other} />;
}
}
InputNumber.defaultProps = {
prefixCls: 'ant-input-number',
step: 1,
};

View File

@ -17,6 +17,10 @@ function fixControlledValue(value) {
}
class Group extends React.Component {
static propTypes = {
children: React.PropTypes.any,
}
render() {
const className = classNames({
'ant-input-group': true,
@ -30,11 +34,32 @@ class Group extends React.Component {
}
}
Group.propTypes = {
children: React.PropTypes.any,
};
export default class Input extends React.Component {
static Group = Group;
static defaultProps = {
defaultValue: '',
disabled: false,
prefixCls: 'ant-input',
type: 'text',
}
static propTypes = {
type: React.PropTypes.string,
id: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number,
]),
size: React.PropTypes.oneOf(['small', 'default', 'large']),
disabled: React.PropTypes.bool,
value: React.PropTypes.any,
defaultValue: React.PropTypes.any,
className: React.PropTypes.string,
addonBefore: React.PropTypes.node,
addonAfter: React.PropTypes.node,
prefixCls: React.PropTypes.string,
}
class Input extends React.Component {
renderLabledInput(children) {
const props = this.props;
const wrapperClassName = `${props.prefixCls}-group`;
@ -98,29 +123,3 @@ class Input extends React.Component {
return this.renderLabledInput(this.renderInput());
}
}
Input.propTypes = {
type: React.PropTypes.string,
id: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number,
]),
size: React.PropTypes.oneOf(['small', 'default', 'large']),
disabled: React.PropTypes.bool,
value: React.PropTypes.any,
defaultValue: React.PropTypes.any,
className: React.PropTypes.string,
addonBefore: React.PropTypes.node,
addonAfter: React.PropTypes.node,
prefixCls: React.PropTypes.string,
};
Input.defaultProps = {
defaultValue: '',
disabled: false,
prefixCls: 'ant-input',
type: 'text',
};
Input.Group = Group;
export default Input;

View File

@ -2,30 +2,34 @@ import React from 'react';
import { changeConfirmLocale } from '../modal/confirm';
export default class LocaleProvider extends React.Component {
static propTypes = {
locale: React.PropTypes.object,
}
static childContextTypes = {
antLocale: React.PropTypes.object,
}
getChildContext() {
return {
antLocale: this.props.locale,
};
}
componentDidMount() {
this.componentDidUpdate();
}
componentDidUpdate() {
const { locale } = this.props;
changeConfirmLocale(locale && locale.Modal);
}
componentWillUnMount() {
changeConfirmLocale();
}
render() {
return React.Children.only(this.props.children);
}
}
LocaleProvider.childContextTypes = {
antLocale: React.PropTypes.object,
};
LocaleProvider.propTypes = {
locale: React.PropTypes.object,
};

View File

@ -4,14 +4,24 @@ import Select from '../select';
import zhCN from './locale/zh_CN';
class MiniSelect extends React.Component {
static Option = Select.Option;
render() {
return <Select size="small" {...this.props} />;
}
}
MiniSelect.Option = Select.Option;
export default class Pagination extends React.Component {
static defaultProps = {
locale: zhCN,
className: '',
prefixCls: 'ant-pagination',
}
static contextTypes = {
antLocale: React.PropTypes.object,
}
render() {
let className = this.props.className;
let selectComponentClass = Select;
@ -37,13 +47,3 @@ export default class Pagination extends React.Component {
);
}
}
Pagination.defaultProps = {
locale: zhCN,
className: '',
prefixCls: 'ant-pagination',
};
Pagination.contextTypes = {
antLocale: React.PropTypes.object,
};

View File

@ -6,6 +6,15 @@ const placements = getPlacements();
const prefixCls = 'ant-popover';
export default class Popover extends React.Component {
static defaultProps = {
prefixCls,
placement: 'top',
trigger: 'hover',
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
overlayStyle: {}
}
render() {
const transitionName = ({
top: 'zoom-down',
@ -48,12 +57,3 @@ export default class Popover extends React.Component {
);
}
}
Popover.defaultProps = {
prefixCls,
placement: 'top',
trigger: 'hover',
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
overlayStyle: {}
};

View File

@ -3,6 +3,17 @@ import RcSelect, { Option, OptGroup } from 'rc-select';
import classNames from 'classnames';
export default class Select extends React.Component {
static Option = Option;
static OptGroup = OptGroup;
static defaultProps = {
prefixCls: 'ant-select',
transitionName: 'slide-up',
optionLabelProp: 'children',
choiceTransitionName: 'zoom',
showSearch: false,
}
render() {
let {
size, className, combobox, notFoundContent
@ -25,14 +36,3 @@ export default class Select extends React.Component {
);
}
}
Select.defaultProps = {
prefixCls: 'ant-select',
transitionName: 'slide-up',
optionLabelProp: 'children',
choiceTransitionName: 'zoom',
showSearch: false,
};
Select.Option = Option;
Select.OptGroup = OptGroup;

View File

@ -2,6 +2,11 @@ import React from 'react';
import RcSlider from 'rc-slider';
export default class Slider extends React.Component {
static defaultProps = {
prefixCls: 'ant-slider',
tipTransitionName: 'zoom-down'
}
render() {
const { isIncluded, marks, index, defaultIndex, ...rest } = this.props;
@ -34,8 +39,3 @@ export default class Slider extends React.Component {
return <RcSlider {...rest} />;
}
}
Slider.defaultProps = {
prefixCls: 'ant-slider',
tipTransitionName: 'zoom-down'
};

View File

@ -3,6 +3,16 @@ import classNames from 'classnames';
import { isCssAnimationSupported } from 'css-animation';
export default class Spin extends React.Component {
static defaultProps = {
prefixCls: 'ant-spin',
spining: true,
}
static propTypes = {
className: React.PropTypes.string,
size: React.PropTypes.oneOf(['small', 'default', 'large']),
}
isNestedPattern() {
return !!(this.props && this.props.children);
}
@ -45,13 +55,3 @@ export default class Spin extends React.Component {
return spinElement;
}
}
Spin.defaultProps = {
prefixCls: 'ant-spin',
spining: true,
};
Spin.propTypes = {
className: React.PropTypes.string,
size: React.PropTypes.oneOf(['small', 'default', 'large']),
};

View File

@ -2,6 +2,15 @@ import React from 'react';
import RcSteps from 'rc-steps';
export default class Steps extends React.Component {
static Step = RcSteps.Step;
static defaultProps = {
prefixCls: 'ant-steps',
iconPrefix: 'ant',
maxDescriptionWidth: 100,
current: 0
}
render() {
let maxDescriptionWidth = this.props.maxDescriptionWidth;
if (this.props.direction === 'vertical') {
@ -19,12 +28,3 @@ export default class Steps extends React.Component {
);
}
}
Steps.defaultProps = {
prefixCls: 'ant-steps',
iconPrefix: 'ant',
maxDescriptionWidth: 100,
current: 0
};
Steps.Step = RcSteps.Step;

View File

@ -3,6 +3,10 @@ import React from 'react';
import classNames from 'classnames';
export default class Switch extends React.Component {
static defaultProps = {
prefixCls: 'ant-switch',
}
render() {
const { prefixCls, size, className } = this.props;
const cls = classNames({
@ -12,7 +16,3 @@ export default class Switch extends React.Component {
return <RcSwitch className={cls} {...this.props} />;
}
}
Switch.defaultProps = {
prefixCls: 'ant-switch',
};

View File

@ -4,9 +4,20 @@ import classNames from 'classnames';
import Icon from '../icon';
export default class Tabs extends React.Component {
static TabPane = RcTabs.TabPane;
static defaultProps = {
prefixCls: 'ant-tabs',
animation: 'slide-horizontal',
type: 'line', // or 'card' 'editable-card'
onChange() {},
onEdit() {},
}
createNewTab = (targetKey) => {
this.props.onEdit(targetKey, 'add');
}
removeTab = (targetKey, e) => {
e.stopPropagation();
if (!targetKey) {
@ -14,9 +25,11 @@ export default class Tabs extends React.Component {
}
this.props.onEdit(targetKey, 'remove');
}
handleChange = (activeKey) => {
this.props.onChange(activeKey);
}
render() {
let { prefixCls, size, tabPosition, animation, type,
children, tabBarExtraContent } = this.props;
@ -65,13 +78,3 @@ export default class Tabs extends React.Component {
);
}
}
Tabs.defaultProps = {
prefixCls: 'ant-tabs',
animation: 'slide-horizontal',
type: 'line', // or 'card' 'editable-card'
onChange() {},
onEdit() {},
};
Tabs.TabPane = RcTabs.TabPane;

View File

@ -5,6 +5,13 @@ import Icon from '../icon';
import classNames from 'classnames';
export default class Tag extends React.Component {
static defaultProps = {
prefixCls: 'ant-tag',
closable: false,
onClose() {},
afterClose() {},
}
constructor(props) {
super(props);
@ -61,10 +68,3 @@ export default class Tag extends React.Component {
);
}
}
Tag.defaultProps = {
prefixCls: 'ant-tag',
closable: false,
onClose() {},
afterClose() {},
};

View File

@ -3,6 +3,13 @@ import classNames from 'classnames';
/* Exported as Timeline.Item */
class TimelineItem extends React.Component {
static defaultProps = {
prefixCls: 'ant-timeline',
color: 'blue',
last: false,
pending: false,
}
render() {
const { prefixCls, color, last, children, pending } = this.props;
const itemClassName = classNames({
@ -20,14 +27,13 @@ class TimelineItem extends React.Component {
}
}
TimelineItem.defaultProps = {
prefixCls: 'ant-timeline',
color: 'blue',
last: false,
pending: false,
};
export default class Timeline extends React.Component {
static Item = TimelineItem;
static defaultProps = {
prefixCls: 'ant-timeline',
}
render() {
const { prefixCls, children, pending } = this.props;
const pendingNode = typeof pending === 'boolean' ? null : pending;
@ -51,9 +57,3 @@ export default class Timeline extends React.Component {
);
}
}
Timeline.defaultProps = {
prefixCls: 'ant-timeline',
};
Timeline.Item = TimelineItem;

View File

@ -8,6 +8,40 @@ function noop() {
}
export default class Transfer extends React.Component {
static List = List;
static Operation = Operation;
static Search = Search;
static defaultProps = {
prefixCls: 'ant-transfer',
dataSource: [],
render: noop,
targetKeys: [],
onChange: noop,
titles: ['源列表', '目的列表'],
operations: [],
showSearch: false,
body: noop,
footer: noop,
}
static propTypes = {
prefixCls: PropTypes.string,
dataSource: PropTypes.array,
render: PropTypes.func,
targetKeys: PropTypes.array,
onChange: PropTypes.func,
height: PropTypes.number,
listStyle: PropTypes.object,
className: PropTypes.string,
titles: PropTypes.array,
operations: PropTypes.array,
showSearch: PropTypes.bool,
searchPlaceholder: PropTypes.string,
notFoundContent: PropTypes.node,
body: PropTypes.func,
footer: PropTypes.func,
}
constructor(props) {
super(props);
@ -213,38 +247,3 @@ export default class Transfer extends React.Component {
);
}
}
Transfer.defaultProps = {
prefixCls: 'ant-transfer',
dataSource: [],
render: noop,
targetKeys: [],
onChange: noop,
titles: ['源列表', '目的列表'],
operations: [],
showSearch: false,
body: noop,
footer: noop,
};
Transfer.propTypes = {
prefixCls: PropTypes.string,
dataSource: PropTypes.array,
render: PropTypes.func,
targetKeys: PropTypes.array,
onChange: PropTypes.func,
height: PropTypes.number,
listStyle: PropTypes.object,
className: PropTypes.string,
titles: PropTypes.array,
operations: PropTypes.array,
showSearch: PropTypes.bool,
searchPlaceholder: PropTypes.string,
notFoundContent: PropTypes.node,
body: PropTypes.func,
footer: PropTypes.func,
};
Transfer.List = List;
Transfer.Operation = Operation;
Transfer.Search = Search;

View File

@ -8,6 +8,37 @@ function noop() {
}
export default class TransferList extends React.Component {
static defaultProps = {
dataSource: [],
titleText: '',
showSearch: false,
handleFilter: noop,
handleSelect: noop,
handleSelectAll: noop,
render: noop,
// advanced
body: noop,
footer: noop,
}
static propTypes = {
prefixCls: PropTypes.string,
dataSource: PropTypes.array,
showSearch: PropTypes.bool,
searchPlaceholder: PropTypes.string,
titleText: PropTypes.string,
style: PropTypes.object,
handleFilter: PropTypes.func,
handleSelect: PropTypes.func,
handleSelectAll: PropTypes.func,
render: PropTypes.func,
body: PropTypes.func,
footer: PropTypes.func,
}
static contextTypes = {
antLocale: React.PropTypes.object,
}
constructor(props) {
super(props);
@ -151,35 +182,3 @@ export default class TransferList extends React.Component {
);
}
}
TransferList.defaultProps = {
dataSource: [],
titleText: '',
showSearch: false,
handleFilter: noop,
handleSelect: noop,
handleSelectAll: noop,
render: noop,
// advanced
body: noop,
footer: noop,
};
TransferList.propTypes = {
prefixCls: PropTypes.string,
dataSource: PropTypes.array,
showSearch: PropTypes.bool,
searchPlaceholder: PropTypes.string,
titleText: PropTypes.string,
style: PropTypes.object,
handleFilter: PropTypes.func,
handleSelect: PropTypes.func,
handleSelectAll: PropTypes.func,
render: PropTypes.func,
body: PropTypes.func,
footer: PropTypes.func,
};
TransferList.contextTypes = {
antLocale: React.PropTypes.object,
};

View File

@ -6,6 +6,21 @@ function noop() {
}
export default class TransferOperation extends React.Component {
static defaultProps = {
leftArrowText: '',
rightArrowText: '',
moveToLeft: noop,
moveToRight: noop,
}
static propTypes = {
className: PropTypes.string,
leftArrowText: PropTypes.string,
rightArrowText: PropTypes.string,
moveToLeft: PropTypes.func,
moveToRight: PropTypes.func,
}
render() {
const {
moveToLeft,
@ -35,18 +50,3 @@ export default class TransferOperation extends React.Component {
);
}
}
TransferOperation.defaultProps = {
leftArrowText: '',
rightArrowText: '',
moveToLeft: noop,
moveToRight: noop,
};
TransferOperation.propTypes = {
className: PropTypes.string,
leftArrowText: PropTypes.string,
rightArrowText: PropTypes.string,
moveToLeft: PropTypes.func,
moveToRight: PropTypes.func,
};

View File

@ -4,6 +4,19 @@ function noop() {
}
export default class Search extends React.Component {
static defaultProps = {
placeholder: '',
onChange: noop,
handleClear: noop,
}
static propTypes = {
prefixCls: PropTypes.string,
placeholder: PropTypes.string,
onChange: PropTypes.func,
handleClear: PropTypes.func,
}
handleChange = (e) => {
this.props.onChange(e);
}
@ -29,16 +42,3 @@ export default class Search extends React.Component {
);
}
}
Search.defaultProps = {
placeholder: '',
onChange: noop,
handleClear: noop,
};
Search.propTypes = {
prefixCls: PropTypes.string,
placeholder: PropTypes.string,
onChange: PropTypes.func,
handleClear: PropTypes.func,
};

View File

@ -3,6 +3,18 @@ import RcTreeSelect, { TreeNode, SHOW_ALL, SHOW_PARENT, SHOW_CHILD } from 'rc-tr
import classNames from 'classnames';
export default class TreeSelect extends React.Component {
static TreeNode = TreeNode;
static SHOW_ALL = SHOW_ALL;
static SHOW_PARENT = SHOW_PARENT;
static SHOW_CHILD = SHOW_CHILD;
static defaultProps = {
prefixCls: 'ant-select',
transitionName: 'slide-up',
choiceTransitionName: 'zoom',
showSearch: false,
}
render() {
const props = this.props;
let {
@ -32,15 +44,3 @@ export default class TreeSelect extends React.Component {
);
}
}
TreeSelect.defaultProps = {
prefixCls: 'ant-select',
transitionName: 'slide-up',
choiceTransitionName: 'zoom',
showSearch: false,
};
TreeSelect.TreeNode = TreeNode;
TreeSelect.SHOW_ALL = SHOW_ALL;
TreeSelect.SHOW_PARENT = SHOW_PARENT;
TreeSelect.SHOW_CHILD = SHOW_CHILD;

View File

@ -3,6 +3,15 @@ import RcTree from 'rc-tree';
import animation from '../common/openAnimation';
export default class Tree extends React.Component {
static TreeNode = RcTree.TreeNode;
static defaultProps = {
prefixCls: 'ant-tree',
checkable: false,
showIcon: false,
openAnimation: animation,
}
render() {
const props = this.props;
let checkable = props.checkable;
@ -16,12 +25,3 @@ export default class Tree extends React.Component {
);
}
}
Tree.defaultProps = {
prefixCls: 'ant-tree',
checkable: false,
showIcon: false,
openAnimation: animation,
};
Tree.TreeNode = RcTree.TreeNode;