style: update code style to please the fucking lint

This commit is contained in:
Benjy Cui 2016-01-07 17:46:46 +08:00
parent 209170e813
commit b72d18fd44
30 changed files with 330 additions and 277 deletions

View File

@ -44,20 +44,20 @@ export default React.createClass({
let iconType = ''; let iconType = '';
switch (type) { switch (type) {
case 'success': case 'success':
iconType = 'check-circle'; iconType = 'check-circle';
break; break;
case 'info': case 'info':
iconType = 'info-circle'; iconType = 'info-circle';
break; break;
case 'error': case 'error':
iconType = 'exclamation-circle'; iconType = 'exclamation-circle';
break; break;
case 'warn': case 'warn':
iconType = 'exclamation-circle'; iconType = 'exclamation-circle';
break; break;
default: default:
iconType = 'default'; iconType = 'default';
} }
// use outline icon in alert with description // use outline icon in alert with description

View File

@ -78,13 +78,13 @@ export default React.createClass({
const calendar = ( const calendar = (
<RangeCalendar prefixCls="ant-calendar" <RangeCalendar prefixCls="ant-calendar"
className={calendarClassName} className={calendarClassName}
timePicker={timePicker} timePicker={timePicker}
disabledDate={disabledDate} disabledDate={disabledDate}
dateInputPlaceholder={[startPlaceholder, endPlaceholder]} dateInputPlaceholder={[startPlaceholder, endPlaceholder]}
locale={locale.lang} locale={locale.lang}
defaultValue={defaultCalendarValue} defaultValue={defaultCalendarValue}
showClear /> showClear />
); );
const pickerClass = classNames({ const pickerClass = classNames({

View File

@ -94,25 +94,25 @@ function createPicker(TheCalendar, defaultFormat) {
return ( return (
<span className={pickerClass}> <span className={pickerClass}>
<DatePicker transitionName={this.props.transitionName} <DatePicker transitionName={this.props.transitionName}
disabled={this.props.disabled} disabled={this.props.disabled}
calendar={calendar} calendar={calendar}
value={this.state.value} value={this.state.value}
prefixCls="ant-calendar-picker-container" prefixCls="ant-calendar-picker-container"
style={this.props.popupStyle} style={this.props.popupStyle}
align={this.props.align} align={this.props.align}
onOpen={this.toggleOpen} onOpen={this.toggleOpen}
onClose={this.toggleOpen} onClose={this.toggleOpen}
onChange={this.handleChange}> onChange={this.handleChange}>
{ {
({ value }) => { ({ value }) => {
return ( return (
<span> <span>
<input disabled={this.props.disabled} <input disabled={this.props.disabled}
onChange={this.handleInputChange} onChange={this.handleInputChange}
value={value && this.getFormatter().format(value)} value={value && this.getFormatter().format(value)}
placeholder={placeholder} placeholder={placeholder}
style={this.props.style} style={this.props.style}
className={'ant-calendar-picker-input ant-input' + sizeClass}/> className={'ant-calendar-picker-input ant-input' + sizeClass}/>
<span className="ant-calendar-picker-icon"/> <span className="ant-calendar-picker-icon"/>
</span> </span>
); );

View File

@ -72,9 +72,9 @@ class Input extends React.Component {
} }
switch (props.size) { switch (props.size) {
case 'small': inputClassName = prefixClsFn(prefixCls, 'input', 'input-sm'); break; case 'small': inputClassName = prefixClsFn(prefixCls, 'input', 'input-sm'); break;
case 'large': inputClassName = prefixClsFn(prefixCls, 'input', 'input-lg'); break; case 'large': inputClassName = prefixClsFn(prefixCls, 'input', 'input-lg'); break;
default: default:
} }
let placeholder = props.placeholder; let placeholder = props.placeholder;
if (placeholder && ieGT9()) { if (placeholder && ieGT9()) {
@ -84,11 +84,14 @@ class Input extends React.Component {
props.value = fixControlledValue(props.value); props.value = fixControlledValue(props.value);
} }
switch (props.type) { switch (props.type) {
case 'textarea': case 'textarea':
return <textarea {...props} placeholder={placeholder} className={inputClassName} ref="input" />; return (
default: <textarea {...props} placeholder={placeholder}
inputClassName = props.className ? props.className : inputClassName; className={inputClassName} ref="input" />
return <input {...props} placeholder={placeholder} className={inputClassName} ref="input"/>; );
default:
inputClassName = props.className ? props.className : inputClassName;
return <input {...props} placeholder={placeholder} className={inputClassName} ref="input"/>;
} }
} }

View File

@ -12,7 +12,7 @@ const Col = React.createClass({
children: React.PropTypes.node, children: React.PropTypes.node,
}, },
render() { render() {
const {span, order, offset, push, pull, className, ...others} = this.props; const { span, order, offset, push, pull, className, ...others } = this.props;
const classes = classNames({ const classes = classNames({
['col-' + span]: span, ['col-' + span]: span,
['col-order-' + order]: order, ['col-order-' + order]: order,

View File

@ -12,7 +12,7 @@ const Row = React.createClass({
render() { render() {
const { type, justify, align, className, ...others } = this.props; const { type, justify, align, className, ...others } = this.props;
const classes = classNames({ const classes = classNames({
'row': true, row: true,
['row-' + type]: type, ['row-' + type]: type,
['row-' + type + '-' + justify]: justify, ['row-' + type + '-' + justify]: justify,
['row-' + type + '-' + align]: align, ['row-' + type + '-' + align]: align,

View File

@ -43,16 +43,16 @@ const AntMenu = React.createClass({
let openAnimation = this.props.openAnimation || this.props.openTransitionName; let openAnimation = this.props.openAnimation || this.props.openTransitionName;
if (!openAnimation) { if (!openAnimation) {
switch (this.props.mode) { switch (this.props.mode) {
case 'horizontal': case 'horizontal':
openAnimation = 'slide-up'; openAnimation = 'slide-up';
break; break;
case 'vertical': case 'vertical':
openAnimation = 'zoom-big'; openAnimation = 'zoom-big';
break; break;
case 'inline': case 'inline':
openAnimation = animation; openAnimation = animation;
break; break;
default: default:
} }
} }

View File

@ -12,7 +12,7 @@ function getMessageInstance() {
prefixCls: 'ant-message', prefixCls: 'ant-message',
transitionName: 'move-up', transitionName: 'move-up',
style: { style: {
top: top top,
} // } //
}); });
return messageInstance; return messageInstance;
@ -20,31 +20,31 @@ function getMessageInstance() {
function notice(content, duration = defaultDuration, type, onClose) { function notice(content, duration = defaultDuration, type, onClose) {
let iconClass = ({ let iconClass = ({
'info': 'ant-message-info', info: 'ant-message-info',
'success': 'ant-message-success', success: 'ant-message-success',
'error': 'ant-message-error', error: 'ant-message-error',
'warn': 'ant-message-warn', warn: 'ant-message-warn',
'loading': 'ant-message-loading' loading: 'ant-message-loading'
})[type]; })[type];
let iconType = ({ let iconType = ({
'info': 'info-circle', info: 'info-circle',
'success': 'check-circle', success: 'check-circle',
'error': 'exclamation-circle', error: 'exclamation-circle',
'warn': 'exclamation-circle', warn: 'exclamation-circle',
'loading': 'loading' loading: 'loading'
})[type]; })[type];
let instance = getMessageInstance(); let instance = getMessageInstance();
instance.notice({ instance.notice({
key: key, key,
duration: duration, duration,
style: {}, style: {},
content: <div className={'ant-message-custom-content ' + iconClass}> content: <div className={'ant-message-custom-content ' + iconClass}>
<Icon className={iconClass} type={iconType} /> <Icon className={iconClass} type={iconType} />
<span>{content}</span> <span>{content}</span>
</div>, </div>,
onClose: onClose onClose
}); });
return (function() { return (function() {
let target = key++; let target = key++;

View File

@ -3,8 +3,10 @@ import ReactDOM from 'react-dom';
import Dialog from './index'; import Dialog from './index';
import Icon from '../icon'; import Icon from '../icon';
import Button from '../button'; import Button from '../button';
import objectAssign from 'object-assign';
export default function (props = {}) { export default function (config) {
const props = objectAssign({}, config || {});
let div = document.createElement('div'); let div = document.createElement('div');
document.body.appendChild(div); document.body.appendChild(div);
@ -110,7 +112,7 @@ export default function (props = {}) {
transitionName="zoom" transitionName="zoom"
footer="" footer=""
maskTransitionName="fade" width={width}> maskTransitionName="fade" width={width}>
<div style={{zoom: 1, overflow: 'hidden'}}>{body} {footer}</div> <div style={{ zoom: 1, overflow: 'hidden' }}>{body} {footer}</div>
</Dialog>, div, function () { </Dialog>, div, function () {
d = this; d = this;
}); });

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import Dialog from 'rc-dialog'; import Dialog from 'rc-dialog';
import { Dom } from 'rc-util'; import { Dom } from 'rc-util';
import objectAssign from 'object-assign';
import confirm from './confirm'; import confirm from './confirm';
import Button from '../button'; import Button from '../button';
@ -72,32 +73,40 @@ let AntModal = React.createClass({
let footer = props.footer || defaultFooter; let footer = props.footer || defaultFooter;
return ( return (
<Dialog onClose={this.handleCancel} footer={footer} {...props} <Dialog onClose={this.handleCancel} footer={footer} {...props}
visible={props.visible} mousePosition={mousePosition} /> visible={props.visible} mousePosition={mousePosition} />
); );
} }
}); });
AntModal.info = function (props) { AntModal.info = function (props) {
props.iconClassName = 'info-circle'; const config = objectAssign({}, props, {
props.okCancel = false; iconClassName: 'info-circle',
return confirm(props); okCancel: false,
});
return confirm(config);
}; };
AntModal.success = function (props) { AntModal.success = function (props) {
props.iconClassName = 'check-circle'; const config = objectAssign({}, props, {
props.okCancel = false; iconClassName: 'check-circle',
return confirm(props); okCancel: false,
});
return confirm(config);
}; };
AntModal.error = function (props) { AntModal.error = function (props) {
props.iconClassName = 'exclamation-circle'; const config = objectAssign({}, props, {
props.okCancel = false; iconClassName: 'exclamation-circle',
return confirm(props); okCancel: false,
});
return confirm(config);
}; };
AntModal.confirm = function (props) { AntModal.confirm = function (props) {
props.okCancel = true; const config = objectAssign({}, props, {
return confirm(props); okCancel: true,
});
return confirm(config);
}; };
export default AntModal; export default AntModal;

View File

@ -13,7 +13,7 @@ function getNotificationInstance() {
notificationInstance = Notification.newInstance({ notificationInstance = Notification.newInstance({
prefixCls: 'ant-notification', prefixCls: 'ant-notification',
style: { style: {
top: top, top,
right: 0 right: 0
} }
}); });
@ -32,20 +32,20 @@ function notice(args) {
let prefixCls = ' ant-notification-notice-content-icon-'; let prefixCls = ' ant-notification-notice-content-icon-';
let iconType = ''; let iconType = '';
switch (args.icon) { switch (args.icon) {
case 'success': case 'success':
iconType = 'check-circle-o'; iconType = 'check-circle-o';
break; break;
case 'info': case 'info':
iconType = 'info-circle-o'; iconType = 'info-circle-o';
break; break;
case 'error': case 'error':
iconType = 'exclamation-circle-o'; iconType = 'exclamation-circle-o';
break; break;
case 'warn': case 'warn':
iconType = 'question-circle-o'; iconType = 'question-circle-o';
break; break;
default: default:
iconType = 'info-circle'; iconType = 'info-circle';
} }
getNotificationInstance().notice({ getNotificationInstance().notice({
@ -56,7 +56,7 @@ function notice(args) {
<div className={prefixCls + 'description'}>{args.description}</div> <div className={prefixCls + 'description'}>{args.description}</div>
</div>, </div>,
duration: duration, duration,
closable: true, closable: true,
onClose: args.onClose, onClose: args.onClose,
key: args.key, key: args.key,
@ -71,7 +71,7 @@ function notice(args) {
<div className={prefixCls + 'description'}>{args.description}</div> <div className={prefixCls + 'description'}>{args.description}</div>
</div>, </div>,
duration: duration, duration,
closable: true, closable: true,
onClose: args.onClose, onClose: args.onClose,
key: args.key, key: args.key,
@ -87,7 +87,7 @@ function notice(args) {
{args.btn} {args.btn}
</span> </span>
</div>, </div>,
duration: duration, duration,
closable: true, closable: true,
onClose: args.onClose, onClose: args.onClose,
key: args.key, key: args.key,

View File

@ -23,9 +23,9 @@ class AntPagination extends React.Component {
return ( return (
<Pagination selectComponentClass={selectComponentClass} <Pagination selectComponentClass={selectComponentClass}
selectPrefixCls="ant-select" selectPrefixCls="ant-select"
{...this.props} {...this.props}
className={className} /> className={className} />
); );
} }
} }

View File

@ -62,7 +62,7 @@ export default React.createClass({
} }
}, },
render() { render() {
const {title, okText, cancelText, placement, overlayStyle, trigger} = this.props; const { title, okText, cancelText, placement, overlayStyle, trigger } = this.props;
const overlay = ( const overlay = (
<div> <div>
<div className={prefixCls + '-content'}> <div className={prefixCls + '-content'}>
@ -82,13 +82,13 @@ export default React.createClass({
return ( return (
<Tooltip placement={placement} <Tooltip placement={placement}
overlayStyle={overlayStyle} overlayStyle={overlayStyle}
prefixCls={prefixCls} prefixCls={prefixCls}
onVisibleChange={this.onVisibleChange} onVisibleChange={this.onVisibleChange}
transitionName={transitionName} transitionName={transitionName}
visible={this.state.visible} visible={this.state.visible}
trigger={trigger} trigger={trigger}
overlay={overlay}> overlay={overlay}>
{this.props.children} {this.props.children}
</Tooltip> </Tooltip>
); );

View File

@ -6,7 +6,7 @@ const prefixCls = 'ant-popover';
const Popover = React.createClass({ const Popover = React.createClass({
getDefaultProps() { getDefaultProps() {
return { return {
prefixCls: prefixCls, prefixCls,
placement: 'top', placement: 'top',
trigger: 'hover', trigger: 'hover',
mouseEnterDelay: 0.1, mouseEnterDelay: 0.1,
@ -33,9 +33,9 @@ const Popover = React.createClass({
return ( return (
<Tooltip transitionName={transitionName} <Tooltip transitionName={transitionName}
ref="tooltip" ref="tooltip"
{...this.props} {...this.props}
overlay={this.getOverlay()}> overlay={this.getOverlay()}>
{this.props.children} {this.props.children}
</Tooltip> </Tooltip>
); );

View File

@ -1,4 +1,4 @@
import {Circle as Progresscircle} from 'rc-progress'; import { Circle as Progresscircle } from 'rc-progress';
import React from 'react'; import React from 'react';
import assign from 'object-assign'; import assign from 'object-assign';
import Icon from '../icon'; import Icon from '../icon';
@ -6,9 +6,9 @@ import Icon from '../icon';
const prefixCls = 'ant-progress'; const prefixCls = 'ant-progress';
const statusColorMap = { const statusColorMap = {
'normal': '#2db7f5', normal: '#2db7f5',
'exception': '#ff6600', exception: '#ff6600',
'success': '#87d068' success: '#87d068'
}; };
let Line = React.createClass({ let Line = React.createClass({
@ -83,7 +83,7 @@ let Circle = React.createClass({
strokeWidth: React.PropTypes.number, strokeWidth: React.PropTypes.number,
width: React.PropTypes.number, width: React.PropTypes.number,
}, },
getDefaultProps: function () { getDefaultProps() {
return { return {
width: 132, width: 132,
percent: 0, percent: 0,
@ -100,9 +100,9 @@ let Circle = React.createClass({
} }
let style = { let style = {
'width': props.width, width: props.width,
'height': props.width, height: props.width,
'fontSize': props.width * 0.16 + 6 fontSize: props.width * 0.16 + 6
}; };
let progressInfo; let progressInfo;
const text = (typeof props.format === 'string') ? const text = (typeof props.format === 'string') ?
@ -136,6 +136,6 @@ let Circle = React.createClass({
}); });
export default { export default {
Line: Line, Line,
Circle: Circle Circle,
}; };

View File

@ -12,15 +12,15 @@ function getCheckedValue(children) {
} }
export default React.createClass({ export default React.createClass({
getDefaultProps: function () { getDefaultProps() {
return { return {
prefixCls: 'ant-radio-group', prefixCls: 'ant-radio-group',
disabled: false, disabled: false,
onChange: function () { onChange() {
} }
}; };
}, },
getInitialState: function () { getInitialState() {
let props = this.props; let props = this.props;
return { return {
value: props.value || props.defaultValue || getCheckedValue(props.children) value: props.value || props.defaultValue || getCheckedValue(props.children)
@ -33,16 +33,16 @@ export default React.createClass({
}); });
} }
}, },
render: function () { render() {
let props = this.props; let props = this.props;
let children = React.Children.map(props.children, (radio) => { let children = React.Children.map(props.children, (radio) => {
if (radio.props) { if (radio.props) {
return ( return (
<Radio key={radio.props.value} <Radio key={radio.props.value}
{...radio.props} {...radio.props}
onChange={this.onRadioChange} onChange={this.onRadioChange}
checked={this.state.value === radio.props.value} checked={this.state.value === radio.props.value}
disabled={radio.props.disabled || this.props.disabled}/> disabled={radio.props.disabled || this.props.disabled}/>
); );
} }
return radio; return radio;
@ -53,7 +53,7 @@ export default React.createClass({
</div> </div>
); );
}, },
onRadioChange: function (ev) { onRadioChange(ev) {
this.setState({ this.setState({
value: ev.target.value value: ev.target.value
}); });

View File

@ -9,7 +9,7 @@ export default React.createClass({
}; };
}, },
render() { render() {
const {isIncluded, marks, index, defaultIndex, ...rest} = this.props; const { isIncluded, marks, index, defaultIndex, ...rest } = this.props;
if (isIncluded !== undefined) { if (isIncluded !== undefined) {
// `isIncluded` // `isIncluded`

View File

@ -18,11 +18,11 @@ const AntSteps = React.createClass({
} }
return ( return (
<Steps size={this.props.size} <Steps size={this.props.size}
current={this.props.current} current={this.props.current}
direction={this.props.direction} direction={this.props.direction}
iconPrefix={this.props.iconPrefix} iconPrefix={this.props.iconPrefix}
maxDescriptionWidth={maxDescriptionWidth} maxDescriptionWidth={maxDescriptionWidth}
prefixCls={this.props.prefixCls}> prefixCls={this.props.prefixCls}>
{this.props.children} {this.props.children}
</Steps> </Steps>
); );

View File

@ -20,12 +20,11 @@ let FilterMenu = React.createClass({
}, },
getDefaultProps() { getDefaultProps() {
return { return {
handleFilter: function () { handleFilter() {},
},
column: null column: null
}; };
}, },
setSelectedKeys: function ({selectedKeys}) { setSelectedKeys({ selectedKeys }) {
this.setState({ selectedKeys }); this.setState({ selectedKeys });
}, },
handleClearFilters() { handleClearFilters() {
@ -41,7 +40,7 @@ let FilterMenu = React.createClass({
}, },
onVisibleChange(visible) { onVisibleChange(visible) {
this.setState({ this.setState({
visible: visible visible,
}); });
if (!visible) { if (!visible) {
this.props.confirmFilter(this.props.column, this.state.selectedKeys); this.props.confirmFilter(this.props.column, this.state.selectedKeys);
@ -89,7 +88,7 @@ let FilterMenu = React.createClass({
this.setState({ keyPathOfSelectedItem }); this.setState({ keyPathOfSelectedItem });
}, },
render() { render() {
let {column, locale} = this.props; let { column, locale } = this.props;
// default multiple selection in filter dropdown // default multiple selection in filter dropdown
let multiple = true; let multiple = true;
if ('filterMultiple' in column) { if ('filterMultiple' in column) {
@ -117,19 +116,19 @@ let FilterMenu = React.createClass({
let menus = ( let menus = (
<div className="ant-table-filter-dropdown"> <div className="ant-table-filter-dropdown">
<Menu multiple={multiple} <Menu multiple={multiple}
prefixCls="ant-dropdown-menu" prefixCls="ant-dropdown-menu"
onSelect={this.setSelectedKeys} onSelect={this.setSelectedKeys}
onDeselect={this.setSelectedKeys} onDeselect={this.setSelectedKeys}
selectedKeys={this.state.selectedKeys}> selectedKeys={this.state.selectedKeys}>
{this.renderMenus(column.filters)} {this.renderMenus(column.filters)}
</Menu> </Menu>
<div className="ant-table-filter-dropdown-btns"> <div className="ant-table-filter-dropdown-btns">
<a className="ant-table-filter-dropdown-link confirm" <a className="ant-table-filter-dropdown-link confirm"
onClick={this.handleConfirm}> onClick={this.handleConfirm}>
{locale.filterConfirm} {locale.filterConfirm}
</a> </a>
<a className="ant-table-filter-dropdown-link clear" <a className="ant-table-filter-dropdown-link clear"
onClick={this.handleClearFilters}> onClick={this.handleClearFilters}>
{locale.filterReset} {locale.filterReset}
</a> </a>
</div> </div>
@ -144,10 +143,10 @@ let FilterMenu = React.createClass({
return ( return (
<Dropdown trigger={['click']} <Dropdown trigger={['click']}
overlay={menus} overlay={menus}
visible={this.state.visible} visible={this.state.visible}
onVisibleChange={this.onVisibleChange} onVisibleChange={this.onVisibleChange}
closeOnSelect={false}> closeOnSelect={false}>
<Icon title={locale.filterTitle} type="filter" className={dropdownSelectedClass} /> <Icon title={locale.filterTitle} type="filter" className={dropdownSelectedClass} />
</Dropdown> </Dropdown>
); );

View File

@ -144,7 +144,9 @@ let AntTable = React.createClass({
sorter sorter
}; };
this.setState(newState); this.setState(newState);
this.props.onChange.apply(this, this.prepareParamsArguments(objectAssign({}, this.state, newState))); this.props.onChange.apply(this, this.prepareParamsArguments(
objectAssign({}, this.state, newState)
));
}, },
handleFilter(column, nextFilters) { handleFilter(column, nextFilters) {
@ -164,7 +166,9 @@ let AntTable = React.createClass({
}; };
this.setState(newState); this.setState(newState);
this.setSelectedRowKeys([]); this.setSelectedRowKeys([]);
this.props.onChange.apply(this, this.prepareParamsArguments(objectAssign({}, this.state, newState))); this.props.onChange.apply(this, this.prepareParamsArguments(
objectAssign({}, this.state, newState)
));
}, },
handleSelect(record, rowIndex, e) { handleSelect(record, rowIndex, e) {
@ -192,7 +196,7 @@ let AntTable = React.createClass({
} }
}, },
handleRadioSelect: function (record, rowIndex, e) { handleRadioSelect(record, rowIndex, e) {
const checked = e.target.checked; const checked = e.target.checked;
const defaultSelection = this.state.selectionDirty ? [] : this.getDefaultSelection(); const defaultSelection = this.state.selectionDirty ? [] : this.getDefaultSelection();
let selectedRowKeys = this.state.selectedRowKeys.concat(defaultSelection); let selectedRowKeys = this.state.selectedRowKeys.concat(defaultSelection);
@ -259,10 +263,12 @@ let AntTable = React.createClass({
}; };
this.setState(newState); this.setState(newState);
this.setSelectedRowKeys([]); this.setSelectedRowKeys([]);
this.props.onChange.apply(this, this.prepareParamsArguments(objectAssign({}, this.state, newState))); this.props.onChange.apply(this, this.prepareParamsArguments(
objectAssign({}, this.state, newState)
));
}, },
onRadioChange: function (ev) { onRadioChange(ev) {
this.setState({ this.setState({
radioIndex: ev.target.value radioIndex: ev.target.value
}); });
@ -282,8 +288,9 @@ let AntTable = React.createClass({
this.getDefaultSelection().indexOf(rowIndex) >= 0); this.getDefaultSelection().indexOf(rowIndex) >= 0);
} }
return ( return (
<Radio disabled={props.disabled} onChange={this.handleRadioSelect.bind(this, record, rowIndex)} <Radio disabled={props.disabled}
value={rowIndex} checked={checked}/> onChange={this.handleRadioSelect.bind(this, record, rowIndex)}
value={rowIndex} checked={checked}/>
); );
}, },
@ -302,7 +309,7 @@ let AntTable = React.createClass({
} }
return ( return (
<Checkbox checked={checked} disabled={props.disabled} <Checkbox checked={checked} disabled={props.disabled}
onChange={this.handleSelect.bind(this, record, rowIndex)}/> onChange={this.handleSelect.bind(this, record, rowIndex)}/>
); );
}, },
@ -346,8 +353,8 @@ let AntTable = React.createClass({
this.props.rowSelection.getCheckboxProps(item).disabled); this.props.rowSelection.getCheckboxProps(item).disabled);
const checkboxAll = ( const checkboxAll = (
<Checkbox checked={checked} <Checkbox checked={checked}
disabled={checkboxAllDisabled} disabled={checkboxAllDisabled}
onChange={this.handleSelectAllRow} /> onChange={this.handleSelectAllRow} />
); );
selectionColumn = { selectionColumn = {
key: 'selection-column', key: 'selection-column',
@ -390,8 +397,8 @@ let AntTable = React.createClass({
let colFilters = this.state.filters[key] || []; let colFilters = this.state.filters[key] || [];
filterDropdown = ( filterDropdown = (
<FilterDropdown locale={locale} column={column} <FilterDropdown locale={locale} column={column}
selectedKeys={colFilters} selectedKeys={colFilters}
confirmFilter={this.handleFilter}/> confirmFilter={this.handleFilter}/>
); );
} }
if (column.sorter) { if (column.sorter) {
@ -407,14 +414,14 @@ let AntTable = React.createClass({
<div className="ant-table-column-sorter"> <div className="ant-table-column-sorter">
<span className={'ant-table-column-sorter-up ' + <span className={'ant-table-column-sorter-up ' +
((isSortColumn && this.state.sortOrder === 'ascend') ? 'on' : 'off')} ((isSortColumn && this.state.sortOrder === 'ascend') ? 'on' : 'off')}
title="↑" title="↑"
onClick={this.toggleSortOrder.bind(this, 'ascend', column)}> onClick={this.toggleSortOrder.bind(this, 'ascend', column)}>
<Icon type="caret-up"/> <Icon type="caret-up"/>
</span> </span>
<span className={'ant-table-column-sorter-down ' + <span className={'ant-table-column-sorter-down ' +
((isSortColumn && this.state.sortOrder === 'descend') ? 'on' : 'off')} ((isSortColumn && this.state.sortOrder === 'descend') ? 'on' : 'off')}
title="↓" title="↓"
onClick={this.toggleSortOrder.bind(this, 'descend', column)}> onClick={this.toggleSortOrder.bind(this, 'descend', column)}>
<Icon type="caret-down"/> <Icon type="caret-down"/>
</span> </span>
</div> </div>
@ -438,7 +445,7 @@ let AntTable = React.createClass({
} }
let nextPagination = objectAssign(pagination, { let nextPagination = objectAssign(pagination, {
pageSize: pageSize pageSize,
}); });
this.setState({ pagination: nextPagination }); this.setState({ pagination: nextPagination });
}, },
@ -450,17 +457,17 @@ let AntTable = React.createClass({
} }
let classString = classNames({ let classString = classNames({
'ant-table-pagination': true, 'ant-table-pagination': true,
'mini': this.props.size === 'middle' || this.props.size === 'small', mini: this.props.size === 'middle' || this.props.size === 'small',
}); });
let total = this.state.pagination.total || this.getLocalData().length; let total = this.state.pagination.total || this.getLocalData().length;
const pageSize = this.state.pagination.pageSize; const pageSize = this.state.pagination.pageSize;
return (total > 0) ? return (total > 0) ?
<Pagination {...this.state.pagination} <Pagination {...this.state.pagination}
className={classString} className={classString}
onChange={this.handlePageChange} onChange={this.handlePageChange}
total={total} total={total}
pageSize={pageSize} pageSize={pageSize}
onShowSizeChange={this.handleShowSizeChange} /> : null; onShowSizeChange={this.handleShowSizeChange} /> : null;
}, },
prepareParamsArguments(state) { prepareParamsArguments(state) {
@ -551,8 +558,9 @@ let AntTable = React.createClass({
columns = this.renderColumnsDropdown(columns); columns = this.renderColumnsDropdown(columns);
columns = columns.map((column, i) => { columns = columns.map((column, i) => {
column.key = column.key || column.dataIndex || i; const newColumn = objectAssign({}, column);
return column; newColumn.key = newColumn.key || newColumn.dataIndex || i;
return newColumn;
}); });
let emptyText; let emptyText;
let emptyClass = ''; let emptyClass = '';
@ -568,15 +576,16 @@ let AntTable = React.createClass({
let table = ( let table = (
<div> <div>
<Table {...this.props} <Table {...this.props}
data={data} data={data}
columns={columns} columns={columns}
className={classString} className={classString}
expandIconAsCell={expandIconAsCell} /> expandIconAsCell={expandIconAsCell} />
{emptyText} {emptyText}
</div> </div>
); );
if (this.props.loading) { if (this.props.loading) {
// if there is no pagination or no data, the height of spin should decrease by half of pagination // if there is no pagination or no data,
// the height of spin should decrease by half of pagination
let paginationPatchClass = (this.hasPagination() && data && data.length !== 0) let paginationPatchClass = (this.hasPagination() && data && data.length !== 0)
? 'ant-table-with-pagination' ? 'ant-table-with-pagination'
: 'ant-table-without-pagination'; : 'ant-table-without-pagination';

View File

@ -66,10 +66,10 @@ class AntTabs extends React.Component {
); );
return ( return (
<Tabs {...this.props} <Tabs {...this.props}
className={className} className={className}
tabBarExtraContent={tabBarExtraContent} tabBarExtraContent={tabBarExtraContent}
onChange={this.handleChange} onChange={this.handleChange}
animation={animation}> animation={animation}>
{children} {children}
</Tabs> </Tabs>
); );

View File

@ -39,22 +39,25 @@ class AntTag extends React.Component {
className = this.state.closing ? className + ' ' + this.props.prefixCls + '-close' : className; className = this.state.closing ? className + ' ' + this.props.prefixCls + '-close' : className;
return this.state.closed ? null return this.state.closed ? null
: <Animate component="" : (
showProp="data-show" <Animate component=""
transitionName={this.props.prefixCls + '-zoom'} showProp="data-show"
onEnd={this.animationEnd.bind(this)}> transitionName={this.props.prefixCls + '-zoom'}
<div data-show={!this.state.closing} className={className}> onEnd={this.animationEnd.bind(this)}>
<a className={this.props.prefixCls + '-text'} {...this.props} /> <div data-show={!this.state.closing} className={className}>
{close} <a className={this.props.prefixCls + '-text'} {...this.props} />
</div> {close}
</Animate>; </div>
</Animate>
);
} }
} }
function NOOP() {}
AntTag.defaultProps = { AntTag.defaultProps = {
prefixCls: 'ant-tag', prefixCls: 'ant-tag',
closable: false, closable: false,
onClose: function() {} onClose: NOOP,
}; };
export default AntTag; export default AntTag;

View File

@ -37,12 +37,14 @@ Timeline.Item = React.createClass({
let pending = props.pending; let pending = props.pending;
let timelineLast = props.timelineLast; let timelineLast = props.timelineLast;
let endCls = pending && timelineLast ? prefixCls + '-item-last' : ''; let endCls = pending && timelineLast ? prefixCls + '-item-last' : '';
let last = pending && timelineLast ? <div className={prefixCls + '-item-head ' + prefixCls + '-item-head-end'}></div> : null; let last = pending && timelineLast ?
<div className={prefixCls + '-item-head ' + prefixCls + '-item-head-end'}></div> :
null;
let lastTailShow = (timelineLast && !pending) ? 'none' : 'block'; let lastTailShow = (timelineLast && !pending) ? 'none' : 'block';
return ( return (
<li className={prefixCls + '-item ' + endCls}> <li className={prefixCls + '-item ' + endCls}>
<div style={{display: lastTailShow}} className={prefixCls + '-item-tail'}></div> <div style={{ display: lastTailShow }} className={prefixCls + '-item-tail'}></div>
<div className={prefixCls + '-item-head ' + prefixCls + '-item-head-' + color}></div> <div className={prefixCls + '-item-head ' + prefixCls + '-item-head-' + color}></div>
<div className={prefixCls + '-item-content'}>{props.children}</div> <div className={prefixCls + '-item-content'}>{props.children}</div>
{last} {last}

View File

@ -41,7 +41,7 @@ export default React.createClass({
} }
return ( return (
<Tooltip transitionName={transitionName} <Tooltip transitionName={transitionName}
overlay={this.props.title} overlay={this.props.title}
visible={visible} visible={visible}
onVisibleChange={this.onVisibleChange} onVisibleChange={this.onVisibleChange}

View File

@ -26,10 +26,10 @@ class Transfer extends Component {
let leftDataSource = Object.assign([], dataSource); let leftDataSource = Object.assign([], dataSource);
let rightDataSource = []; let rightDataSource = [];
if ( targetKeys.length > 0 ) { if (targetKeys.length > 0) {
targetKeys.forEach((targetKey) => { targetKeys.forEach((targetKey) => {
rightDataSource.push(leftDataSource.find((data, index) => { rightDataSource.push(leftDataSource.find((data, index) => {
if ( data.key === targetKey ) { if (data.key === targetKey) {
leftDataSource.splice(index, 1); leftDataSource.splice(index, 1);
return true; return true;
} }
@ -38,8 +38,8 @@ class Transfer extends Component {
} }
return { return {
leftDataSource: leftDataSource, leftDataSource,
rightDataSource: rightDataSource, rightDataSource,
}; };
} }
@ -48,12 +48,14 @@ class Transfer extends Component {
const { leftCheckedKeys, rightCheckedKeys } = this.state; const { leftCheckedKeys, rightCheckedKeys } = this.state;
// move items to target box // move items to target box
const newTargetKeys = direction === 'right' ? const newTargetKeys = direction === 'right' ?
leftCheckedKeys.concat(targetKeys) : leftCheckedKeys.concat(targetKeys) :
targetKeys.filter((targetKey) => !rightCheckedKeys.some((checkedKey) => targetKey === checkedKey)); targetKeys.filter((targetKey) => {
return !rightCheckedKeys.some((checkedKey) => targetKey === checkedKey);
});
// empty checked keys // empty checked keys
this.setState({ this.setState({
[ direction === 'right' ? 'leftCheckedKeys' : 'rightCheckedKeys' ]: [], [direction === 'right' ? 'leftCheckedKeys' : 'rightCheckedKeys']: [],
}); });
this.props.onChange(newTargetKeys); this.props.onChange(newTargetKeys);
@ -70,8 +72,8 @@ class Transfer extends Component {
let globalCheckStatus; let globalCheckStatus;
if ( checkedKeys.length > 0 ) { if (checkedKeys.length > 0) {
if ( checkedKeys.length < filteredDataSource.length ) { if (checkedKeys.length < filteredDataSource.length) {
globalCheckStatus = 'part'; globalCheckStatus = 'part';
} else { } else {
globalCheckStatus = 'all'; globalCheckStatus = 'all';
@ -102,7 +104,7 @@ class Transfer extends Component {
const checkStatus = this.getGlobalCheckStatus(direction); const checkStatus = this.getGlobalCheckStatus(direction);
let holder = []; let holder = [];
if ( checkStatus === 'all' ) { if (checkStatus === 'all') {
holder = []; holder = [];
} else { } else {
holder = this.filterDataSource(dataSource, filter).map(item => item.key); holder = this.filterDataSource(dataSource, filter).map(item => item.key);
@ -132,10 +134,10 @@ class Transfer extends Component {
const { leftCheckedKeys, rightCheckedKeys } = this.state; const { leftCheckedKeys, rightCheckedKeys } = this.state;
const holder = direction === 'left' ? leftCheckedKeys : rightCheckedKeys; const holder = direction === 'left' ? leftCheckedKeys : rightCheckedKeys;
const index = holder.findIndex((key) => key === selectedItem.key); const index = holder.findIndex((key) => key === selectedItem.key);
if ( index > -1 ) { if (index > -1) {
holder.splice(index, 1); holder.splice(index, 1);
} }
if ( checked ) { if (checked) {
holder.push(selectedItem.key); holder.push(selectedItem.key);
} }
this.setState({ this.setState({
@ -165,46 +167,46 @@ class Transfer extends Component {
return ( return (
<div className={cls}> <div className={cls}>
<List titleText={titles[0]} <List titleText={titles[0]}
dataSource={leftDataSource} dataSource={leftDataSource}
filter={leftFilter} filter={leftFilter}
style={listStyle} style={listStyle}
checkedKeys={leftCheckedKeys} checkedKeys={leftCheckedKeys}
checkStatus={leftCheckStatus} checkStatus={leftCheckStatus}
handleFilter={this.handleFilter.bind(this, 'left')} handleFilter={this.handleFilter.bind(this, 'left')}
handleClear={this.handleClear.bind(this, 'left')} handleClear={this.handleClear.bind(this, 'left')}
handleSelect={this.handleSelect.bind(this, 'left')} handleSelect={this.handleSelect.bind(this, 'left')}
handleSelectAll={this.handleSelectAll.bind(this, 'left')} handleSelectAll={this.handleSelectAll.bind(this, 'left')}
position="left" position="left"
render={this.props.render} render={this.props.render}
showSearch={showSearch} showSearch={showSearch}
searchPlaceholder={searchPlaceholder} searchPlaceholder={searchPlaceholder}
body={body} body={body}
footer={footer} footer={footer}
prefixCls={prefixCls + '-list'}/> prefixCls={prefixCls + '-list'}/>
<Operation rightActive={rightActive} <Operation rightActive={rightActive}
rightArrowText={operations[0]} rightArrowText={operations[0]}
moveToRight={this.moveTo.bind(this, 'right')} moveToRight={this.moveTo.bind(this, 'right')}
leftActive={leftActive} leftActive={leftActive}
leftArrowText={operations[1]} leftArrowText={operations[1]}
moveToLeft={this.moveTo.bind(this, 'left')} moveToLeft={this.moveTo.bind(this, 'left')}
className={prefixCls + '-operation'}/> className={prefixCls + '-operation'}/>
<List titleText={titles[1]} <List titleText={titles[1]}
dataSource={rightDataSource} dataSource={rightDataSource}
filter={rightFilter} filter={rightFilter}
style={listStyle} style={listStyle}
checkedKeys={rightCheckedKeys} checkedKeys={rightCheckedKeys}
checkStatus={rightCheckStatus} checkStatus={rightCheckStatus}
handleFilter={this.handleFilter.bind(this, 'right')} handleFilter={this.handleFilter.bind(this, 'right')}
handleClear={this.handleClear.bind(this, 'right')} handleClear={this.handleClear.bind(this, 'right')}
handleSelect={this.handleSelect.bind(this, 'right')} handleSelect={this.handleSelect.bind(this, 'right')}
handleSelectAll={this.handleSelectAll.bind(this, 'right')} handleSelectAll={this.handleSelectAll.bind(this, 'right')}
position="right" position="right"
render={this.props.render} render={this.props.render}
showSearch={showSearch} showSearch={showSearch}
searchPlaceholder={searchPlaceholder} searchPlaceholder={searchPlaceholder}
body={body} body={body}
footer={footer} footer={footer}
prefixCls={prefixCls + '-list'}/> prefixCls={prefixCls + '-list'}/>
</div> </div>
); );
} }

View File

@ -56,8 +56,8 @@ class TransferList extends Component {
} }
return ( return (
<span ref="checkbox" <span ref="checkbox"
className={checkboxCls} className={checkboxCls}
onClick={(!props.disabled) && this.handleSelectALl.bind(this)}> onClick={(!props.disabled) && this.handleSelectALl.bind(this)}>
{customEle} {customEle}
</span> </span>
); );
@ -69,11 +69,12 @@ class TransferList extends Component {
} }
render() { render() {
const { prefixCls, dataSource, titleText, filter, checkedKeys, checkStatus, body, footer, showSearch } = this.props; const { prefixCls, dataSource, titleText, filter, checkedKeys,
checkStatus, body, footer, showSearch } = this.props;
// Custom Layout // Custom Layout
const footerDom = footer({...this.props}); const footerDom = footer({ ...this.props });
const bodyDom = body({...this.props}); const bodyDom = body({ ...this.props });
const listCls = classNames({ const listCls = classNames({
[prefixCls]: true, [prefixCls]: true,
@ -88,13 +89,27 @@ class TransferList extends Component {
checked: checkStatus === 'all', checked: checkStatus === 'all',
checkPart: checkStatus === 'part', checkPart: checkStatus === 'part',
checkable: <span className={`ant-transfer-checkbox-inner`}></span> checkable: <span className={`ant-transfer-checkbox-inner`}></span>
})}<span className={`${prefixCls}-header-selected`}><span>{(checkedKeys.length > 0 ? checkedKeys.length + '/' : '') + dataSource.length} </span> })}
<span className={`${prefixCls}-header-title`}>{titleText}</span></span> <span className={`${prefixCls}-header-selected`}>
<span>
{
(checkedKeys.length > 0 ? checkedKeys.length + '/' : '') + dataSource.length
}
</span>
<span className={`${prefixCls}-header-title`}>{titleText}</span>
</span>
</div> </div>
{ bodyDom ? bodyDom : { bodyDom ? bodyDom :
<div className={ showSearch ? `${prefixCls}-body ${prefixCls}-body-with-search` : `${prefixCls}-body`}> <div className={
showSearch ?
`${prefixCls}-body ${prefixCls}-body-with-search` :
`${prefixCls}-body`
}>
{ showSearch ? <div className={`${prefixCls}-body-search-wrapper`}> { showSearch ? <div className={`${prefixCls}-body-search-wrapper`}>
<Search prefixCls={`${prefixCls}-search`} onChange={this.handleFilter.bind(this)} handleClear={this.handleClear.bind(this)} value={filter} /> <Search prefixCls={`${prefixCls}-search`}
onChange={this.handleFilter.bind(this)}
handleClear={this.handleClear.bind(this)}
value={filter} />
</div> : null } </div> : null }
<Animate component="ul" <Animate component="ul"
transitionName={this.state.mounted ? `${prefixCls}-highlight` : ''} transitionName={this.state.mounted ? `${prefixCls}-highlight` : ''}
@ -109,7 +124,8 @@ class TransferList extends Component {
if (filterResult) { if (filterResult) {
return ( return (
<li onClick={this.handleSelect.bind(this, item)} key={item.key} title={renderedText}> <li onClick={this.handleSelect.bind(this, item)}
key={item.key} title={renderedText}>
<Checkbox checked={checkedKeys.some(key => key === item.key)} /> <Checkbox checked={checkedKeys.some(key => key === item.key)} />
{renderedText} {renderedText}
</li> </li>

View File

@ -13,13 +13,15 @@ class Search extends Component {
} }
render() { render() {
const {placeholder, value, prefixCls} = this.props; const { placeholder, value, prefixCls } = this.props;
return ( return (
<div> <div>
<input placeholder={placeholder} className={ prefixCls + ' ant-input' } value={ value } ref="input" <input placeholder={placeholder} className={ prefixCls + ' ant-input' }
onChange={this.handleChange.bind(this)}/> value={ value } ref="input"
onChange={this.handleChange.bind(this)}/>
{ value && value.length > 0 ? { value && value.length > 0 ?
<a href="javascirpt:;" className={ prefixCls + '-action' } onClick={this.props.handleClear}> <a href="javascirpt:;" className={ prefixCls + '-action' }
onClick={this.props.handleClear}>
<Icon type="cross-circle" /> <Icon type="cross-circle" />
</a> </a>
: <span className={ prefixCls + '-action' }><Icon type="search" /></span> : <span className={ prefixCls + '-action' }><Icon type="search" /></span>

View File

@ -125,7 +125,7 @@ const AntUpload = React.createClass({
targetItem.response = response; targetItem.response = response;
this.onChange({ this.onChange({
file: targetItem, file: targetItem,
fileList: fileList fileList
}); });
} }
}, },
@ -136,7 +136,7 @@ const AntUpload = React.createClass({
targetItem.percent = e.percent; targetItem.percent = e.percent;
this.onChange({ this.onChange({
event: e, event: e,
file: file, file,
fileList: this.state.fileList fileList: this.state.fileList
}); });
}, },
@ -157,8 +157,8 @@ const AntUpload = React.createClass({
let fileList = this.removeFile(file); let fileList = this.removeFile(file);
if (fileList) { if (fileList) {
this.onChange({ this.onChange({
file: file, file,
fileList: fileList fileList,
}); });
} }
}, },
@ -257,7 +257,7 @@ const AntUpload = React.createClass({
AntUpload.Dragger = React.createClass({ AntUpload.Dragger = React.createClass({
render() { render() {
return <AntUpload {...this.props} type="drag" style={{height: this.props.height}}/>; return <AntUpload {...this.props} type="drag" style={{ height: this.props.height }}/>;
} }
}); });

View File

@ -55,9 +55,11 @@ export default React.createClass({
if (this.props.listType === 'picture') { if (this.props.listType === 'picture') {
icon = (file.status === 'uploading' || (!file.thumbUrl && !file.url)) icon = (file.status === 'uploading' || (!file.thumbUrl && !file.url))
? <Icon className={prefixCls + '-list-item-thumbnail'} type="picture" /> ? <Icon className={prefixCls + '-list-item-thumbnail'} type="picture" />
: <a className={prefixCls + '-list-item-thumbnail'} : (
href={file.url} <a className={prefixCls + '-list-item-thumbnail'}
target="_blank"><img src={file.thumbUrl || file.url} alt={file.name} /></a>; href={file.url}
target="_blank"><img src={file.thumbUrl || file.url} alt={file.name} /></a>
);
} }
if (file.status === 'uploading') { if (file.status === 'uploading') {
progress = ( progress = (

View File

@ -54,8 +54,12 @@ if (process.env.NODE_ENV !== 'production') {
const warning = require('warning'); const warning = require('warning');
const semver = require('semver'); const semver = require('semver');
const reactVersionInDeps = require('./package.json').devDependencies.react; const reactVersionInDeps = require('./package.json').devDependencies.react;
warning(semver.satisfies(ReactVersion, reactVersionInDeps) || semver.gtr(ReactVersion, reactVersionInDeps), warning(
`antd@${antd.version} need react@${reactVersionInDeps} or higher, which is react@${ReactVersion} now.`); semver.satisfies(ReactVersion, reactVersionInDeps) ||
semver.gtr(ReactVersion, reactVersionInDeps),
`antd@${antd.version} need react@${reactVersionInDeps} or higher, ` +
`which is react@${ReactVersion} now.`
);
} }
module.exports = antd; module.exports = antd;