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

@ -85,7 +85,10 @@ class Input extends React.Component {
}
switch (props.type) {
case 'textarea':
return <textarea {...props} placeholder={placeholder} className={inputClassName} ref="input" />;
return (
<textarea {...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 Row = React.createClass({
render() {
const { type, justify, align, className, ...others } = this.props;
const classes = classNames({
'row': true,
row: true,
['row-' + type]: type,
['row-' + type + '-' + justify]: justify,
['row-' + type + '-' + align]: align,

View File

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

View File

@ -3,8 +3,10 @@ import ReactDOM from 'react-dom';
import Dialog from './index';
import Icon from '../icon';
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');
document.body.appendChild(div);

View File

@ -1,6 +1,7 @@
import React from 'react';
import Dialog from 'rc-dialog';
import { Dom } from 'rc-util';
import objectAssign from 'object-assign';
import confirm from './confirm';
import Button from '../button';
@ -78,26 +79,34 @@ let AntModal = React.createClass({
});
AntModal.info = function (props) {
props.iconClassName = 'info-circle';
props.okCancel = false;
return confirm(props);
const config = objectAssign({}, props, {
iconClassName: 'info-circle',
okCancel: false,
});
return confirm(config);
};
AntModal.success = function (props) {
props.iconClassName = 'check-circle';
props.okCancel = false;
return confirm(props);
const config = objectAssign({}, props, {
iconClassName: 'check-circle',
okCancel: false,
});
return confirm(config);
};
AntModal.error = function (props) {
props.iconClassName = 'exclamation-circle';
props.okCancel = false;
return confirm(props);
const config = objectAssign({}, props, {
iconClassName: 'exclamation-circle',
okCancel: false,
});
return confirm(config);
};
AntModal.confirm = function (props) {
props.okCancel = true;
return confirm(props);
const config = objectAssign({}, props, {
okCancel: true,
});
return confirm(config);
};
export default AntModal;

View File

@ -13,7 +13,7 @@ function getNotificationInstance() {
notificationInstance = Notification.newInstance({
prefixCls: 'ant-notification',
style: {
top: top,
top,
right: 0
}
});
@ -56,7 +56,7 @@ function notice(args) {
<div className={prefixCls + 'description'}>{args.description}</div>
</div>,
duration: duration,
duration,
closable: true,
onClose: args.onClose,
key: args.key,
@ -71,7 +71,7 @@ function notice(args) {
<div className={prefixCls + 'description'}>{args.description}</div>
</div>,
duration: duration,
duration,
closable: true,
onClose: args.onClose,
key: args.key,
@ -87,7 +87,7 @@ function notice(args) {
{args.btn}
</span>
</div>,
duration: duration,
duration,
closable: true,
onClose: args.onClose,
key: args.key,

View File

@ -6,7 +6,7 @@ const prefixCls = 'ant-popover';
const Popover = React.createClass({
getDefaultProps() {
return {
prefixCls: prefixCls,
prefixCls,
placement: 'top',
trigger: 'hover',
mouseEnterDelay: 0.1,

View File

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

View File

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

View File

@ -20,12 +20,11 @@ let FilterMenu = React.createClass({
},
getDefaultProps() {
return {
handleFilter: function () {
},
handleFilter() {},
column: null
};
},
setSelectedKeys: function ({selectedKeys}) {
setSelectedKeys({ selectedKeys }) {
this.setState({ selectedKeys });
},
handleClearFilters() {
@ -41,7 +40,7 @@ let FilterMenu = React.createClass({
},
onVisibleChange(visible) {
this.setState({
visible: visible
visible,
});
if (!visible) {
this.props.confirmFilter(this.props.column, this.state.selectedKeys);

View File

@ -144,7 +144,9 @@ let AntTable = React.createClass({
sorter
};
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) {
@ -164,7 +166,9 @@ let AntTable = React.createClass({
};
this.setState(newState);
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) {
@ -192,7 +196,7 @@ let AntTable = React.createClass({
}
},
handleRadioSelect: function (record, rowIndex, e) {
handleRadioSelect(record, rowIndex, e) {
const checked = e.target.checked;
const defaultSelection = this.state.selectionDirty ? [] : this.getDefaultSelection();
let selectedRowKeys = this.state.selectedRowKeys.concat(defaultSelection);
@ -259,10 +263,12 @@ let AntTable = React.createClass({
};
this.setState(newState);
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({
radioIndex: ev.target.value
});
@ -282,7 +288,8 @@ let AntTable = React.createClass({
this.getDefaultSelection().indexOf(rowIndex) >= 0);
}
return (
<Radio disabled={props.disabled} onChange={this.handleRadioSelect.bind(this, record, rowIndex)}
<Radio disabled={props.disabled}
onChange={this.handleRadioSelect.bind(this, record, rowIndex)}
value={rowIndex} checked={checked}/>
);
},
@ -438,7 +445,7 @@ let AntTable = React.createClass({
}
let nextPagination = objectAssign(pagination, {
pageSize: pageSize
pageSize,
});
this.setState({ pagination: nextPagination });
},
@ -450,7 +457,7 @@ let AntTable = React.createClass({
}
let classString = classNames({
'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;
const pageSize = this.state.pagination.pageSize;
@ -551,8 +558,9 @@ let AntTable = React.createClass({
columns = this.renderColumnsDropdown(columns);
columns = columns.map((column, i) => {
column.key = column.key || column.dataIndex || i;
return column;
const newColumn = objectAssign({}, column);
newColumn.key = newColumn.key || newColumn.dataIndex || i;
return newColumn;
});
let emptyText;
let emptyClass = '';
@ -576,7 +584,8 @@ let AntTable = React.createClass({
</div>
);
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)
? 'ant-table-with-pagination'
: 'ant-table-without-pagination';

View File

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

View File

@ -37,7 +37,9 @@ Timeline.Item = React.createClass({
let pending = props.pending;
let timelineLast = props.timelineLast;
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';
return (

View File

@ -38,8 +38,8 @@ class Transfer extends Component {
}
return {
leftDataSource: leftDataSource,
rightDataSource: rightDataSource,
leftDataSource,
rightDataSource,
};
}
@ -49,7 +49,9 @@ class Transfer extends Component {
// move items to target box
const newTargetKeys = direction === 'right' ?
leftCheckedKeys.concat(targetKeys) :
targetKeys.filter((targetKey) => !rightCheckedKeys.some((checkedKey) => targetKey === checkedKey));
targetKeys.filter((targetKey) => {
return !rightCheckedKeys.some((checkedKey) => targetKey === checkedKey);
});
// empty checked keys
this.setState({

View File

@ -69,7 +69,8 @@ class TransferList extends Component {
}
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
const footerDom = footer({ ...this.props });
@ -88,13 +89,27 @@ class TransferList extends Component {
checked: checkStatus === 'all',
checkPart: checkStatus === 'part',
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>
{ 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`}>
<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 }
<Animate component="ul"
transitionName={this.state.mounted ? `${prefixCls}-highlight` : ''}
@ -109,7 +124,8 @@ class TransferList extends Component {
if (filterResult) {
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)} />
{renderedText}
</li>

View File

@ -16,10 +16,12 @@ class Search extends Component {
const { placeholder, value, prefixCls } = this.props;
return (
<div>
<input placeholder={placeholder} className={ prefixCls + ' ant-input' } value={ value } ref="input"
<input placeholder={placeholder} className={ prefixCls + ' ant-input' }
value={ value } ref="input"
onChange={this.handleChange.bind(this)}/>
{ 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" />
</a>
: <span className={ prefixCls + '-action' }><Icon type="search" /></span>

View File

@ -125,7 +125,7 @@ const AntUpload = React.createClass({
targetItem.response = response;
this.onChange({
file: targetItem,
fileList: fileList
fileList
});
}
},
@ -136,7 +136,7 @@ const AntUpload = React.createClass({
targetItem.percent = e.percent;
this.onChange({
event: e,
file: file,
file,
fileList: this.state.fileList
});
},
@ -157,8 +157,8 @@ const AntUpload = React.createClass({
let fileList = this.removeFile(file);
if (fileList) {
this.onChange({
file: file,
fileList: fileList
file,
fileList,
});
}
},

View File

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

View File

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