Merge 1.x-stable

This commit is contained in:
afc163 2016-07-15 16:42:58 +08:00
commit f0995bd1e3
8 changed files with 56 additions and 64 deletions

View File

@ -166,7 +166,7 @@ export default class Cascader extends React.Component<CascaderProps, any> {
>
<Input {...inputProps}
placeholder={this.state.value && this.state.value.length > 0 ? null : placeholder}
className={`${prefixCls}-input ant-input ${sizeCls}`}
className={`${prefixCls}-input ${sizeCls}`}
value=""
disabled={disabled}
readOnly

View File

@ -5,7 +5,7 @@
.@{cascader-prefix-cls} {
font-size: @font-size-base;
&-input {
&-input.ant-input {
display: block;
cursor: pointer;
width: 100%;

View File

@ -70,21 +70,15 @@ export default class RangePicker extends React.Component {
'ant-calendar-time': showTime,
});
// 需要选择时间时,点击 ok 时才触发 onChange
let pickerChangeHandler = {
onChange: this.handleChange,
};
let calendarHandler = {
onOk: this.handleChange,
};
if (props.timePicker) {
pickerChangeHandler.onChange = (value) => {
// Click clear button
if (value === null || value.length === 0) {
this.handleChange(value);
}
};
pickerChangeHandler = {};
} else {
calendarHandler = {};
}

View File

@ -59,6 +59,19 @@ export default function createPicker(TheCalendar) {
'ant-calendar-month': MonthCalendar === TheCalendar,
});
// 需要选择时间时,点击 ok 时才触发 onChange
let pickerChangeHandler = {
onChange: this.handleChange,
};
let calendarHandler = {
onOk: this.handleChange,
};
if (props.showTime) {
pickerChangeHandler = {};
} else {
calendarHandler = {};
}
const calendar = (
<TheCalendar
formatter={props.getFormatter()}
@ -70,6 +83,8 @@ export default function createPicker(TheCalendar) {
dateInputPlaceholder={placeholder}
prefixCls="ant-calendar"
className={calendarClassName}
onOk={props.onOk}
{...calendarHandler}
/>
);
@ -98,7 +113,7 @@ export default function createPicker(TheCalendar) {
open={props.open}
onOpen={props.toggleOpen}
onClose={props.toggleOpen}
onChange={this.handleChange}
{...pickerChangeHandler}
>
{
({ value }) => {

View File

@ -1,6 +1,6 @@
---
order: 4
title:
title:
zh-CN: 日期时间选择
en-US: To choose time
---

View File

@ -28,13 +28,12 @@ english: DatePicker
| defaultValue | 默认日期 | string or Date | 无 |
| format | 展示的日期格式,配置参考 [GregorianCalendarFormat](https://github.com/yiminghe/gregorian-calendar-format) | string | "yyyy-MM-dd" |
| disabledDate | 不可选择的日期 | function | 无 |
| onChange | 时间发生变化的回调,发生在用户选择时间时 | function(date, dateString) | 无 |
| onChange | 时间发生变化的回调 | function(date, dateString) | 无 |
| disabled | 禁用 | bool | false |
| style | 自定义输入框样式 | object | {} |
| popupStyle | 格外的弹出日历样式 | object | {} |
| size | 输入框大小,`large` 高度为 32px`small` 为 22px默认是 28px | string | 无 |
| locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/issues/424) |
| onOk | 点击确定按钮的回调 | function(Date value) | 无 |
| toggleOpen | 弹出日历和关闭日历的回调 | function(status) | 无 |
| getCalendarContainer | 定义浮层的容器,默认为 body 上新建 div | function(trigger) | 无 |
| showTime | 增加时间选择功能 | Object or Boolean | [TimePicker Options](http://ant.design/components/time-picker/#api) |

View File

@ -70,6 +70,7 @@ export default class Transfer extends React.Component<TransferProps, any> {
rightCheckedKeys: [],
};
}
componentWillReceiveProps(nextProps) {
const { leftCheckedKeys, rightCheckedKeys } = this.state;
if (nextProps.targetKeys !== this.props.targetKeys ||
@ -146,40 +147,16 @@ export default class Transfer extends React.Component<TransferProps, any> {
moveToLeft = () => this.moveTo('left')
moveToRight = () => this.moveTo('right')
getGlobalCheckStatus(direction) {
const { leftDataSource, rightDataSource } = this.splitDataSource(this.props);
const { leftCheckedKeys, rightCheckedKeys } = this.state;
const dataSource = direction === 'left' ? leftDataSource : rightDataSource;
const checkedKeys = direction === 'left' ? leftCheckedKeys : rightCheckedKeys;
let globalCheckStatus;
if (checkedKeys.length > 0) {
if (checkedKeys.length < dataSource.length) {
globalCheckStatus = 'part';
} else {
globalCheckStatus = 'all';
}
} else {
globalCheckStatus = 'none';
}
return globalCheckStatus;
}
handleSelectAll = (direction) => {
const { leftDataSource, rightDataSource } = this.splitDataSource(this.props);
const dataSource = direction === 'left' ? leftDataSource : rightDataSource;
const checkStatus = this.getGlobalCheckStatus(direction);
const holder = (checkStatus === 'all') ? [] : dataSource.map(item => item.key);
handleSelectAll = (direction, filteredDataSource, checkAll) => {
const holder = checkAll ? [] : filteredDataSource.map(item => item.key);
this.setState({
[`${direction}CheckedKeys`]: holder,
});
}
handleLeftSelectAll = () => this.handleSelectAll('left')
handleRightSelectAll = () => this.handleSelectAll('right')
handleLeftSelectAll = (...args) => this.handleSelectAll('left', ...args)
handleRightSelectAll = (...args) => this.handleSelectAll('right', ...args)
handleFilter = (direction, e) => {
this.setState({
@ -235,9 +212,6 @@ export default class Transfer extends React.Component<TransferProps, any> {
const leftActive = rightCheckedKeys.length > 0;
const rightActive = leftCheckedKeys.length > 0;
const leftCheckStatus = this.getGlobalCheckStatus('left');
const rightCheckStatus = this.getGlobalCheckStatus('right');
const cls = classNames({
[className]: !!className,
[prefixCls]: true,
@ -250,7 +224,6 @@ export default class Transfer extends React.Component<TransferProps, any> {
filter={leftFilter}
style={listStyle}
checkedKeys={leftCheckedKeys}
checkStatus={leftCheckStatus}
handleFilter={this.handleLeftFilter}
handleClear={this.handleLeftClear}
handleSelect={this.handleLeftSelect}
@ -276,7 +249,6 @@ export default class Transfer extends React.Component<TransferProps, any> {
filter={rightFilter}
style={listStyle}
checkedKeys={rightCheckedKeys}
checkStatus={rightCheckStatus}
handleFilter={this.handleRightFilter}
handleClear={this.handleRightClear}
handleSelect={this.handleRightSelect}

View File

@ -86,8 +86,14 @@ export default class TransferList extends React.Component<TransferListProps, any
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
}
handleSelectAll = () => {
this.props.handleSelectAll();
getCheckStatus(filteredDataSource) {
const { checkedKeys } = this.props;
if (checkedKeys.length === 0) {
return 'none';
} else if (filteredDataSource.every(item => checkedKeys.indexOf(item.key) >= 0)) {
return 'all';
}
return 'part';
}
handleSelect = (selectedItem) => {
@ -104,24 +110,23 @@ export default class TransferList extends React.Component<TransferListProps, any
this.props.handleClear();
}
renderCheckbox(props) {
const { prefixCls } = props;
renderCheckbox({ prefixCls, filteredDataSource, checked, checkPart, disabled, checkable }) {
const checkAll = (!checkPart) && checked;
const checkboxCls = classNames({
[`${prefixCls}-checkbox`]: true,
[`${prefixCls}-checkbox-indeterminate`]: props.checkPart,
[`${prefixCls}-checkbox-checked`]: (!props.checkPart) && props.checked,
[`${prefixCls}-checkbox-disabled`]: !!props.disabled,
[`${prefixCls}-checkbox-indeterminate`]: checkPart,
[`${prefixCls}-checkbox-checked`]: checkAll,
[`${prefixCls}-checkbox-disabled`]: disabled,
});
let customEle = null;
if (typeof props.checkable !== 'boolean') {
customEle = props.checkable;
}
return (
<span ref="checkbox"
<span
ref="checkbox"
className={checkboxCls}
onClick={(!props.disabled) && this.handleSelectAll}
onClick={() => this.props.handleSelectAll(filteredDataSource, checkAll)}
>
{customEle}
{(typeof checkable !== 'boolean') ? checkable : null}
</span>
);
}
@ -132,7 +137,7 @@ export default class TransferList extends React.Component<TransferListProps, any
render() {
const { prefixCls, dataSource, titleText, filter, checkedKeys,
checkStatus, body, footer, showSearch, render, style } = this.props;
body, footer, showSearch, render, style } = this.props;
let { searchPlaceholder, notFoundContent } = this.props;
@ -145,7 +150,9 @@ export default class TransferList extends React.Component<TransferListProps, any
[`${prefixCls}-with-footer`]: !!footerDom,
});
const showItems = dataSource.map((item) => {
const filteredDataSource = [];
const showItems = dataSource.map(item => {
const renderResult = render(item);
let renderedText;
let renderedEl;
@ -162,8 +169,10 @@ export default class TransferList extends React.Component<TransferListProps, any
return null;
}
filteredDataSource.push(item);
return (
<li onClick={() => { this.handleSelect(item); }} key={item.key} title={renderedText}>
<li onClick={() => this.handleSelect(item)} key={item.key} title={renderedText}>
<Checkbox checked={checkedKeys.some(key => key === item.key)} />
<span>{renderedEl}</span>
</li>
@ -182,6 +191,8 @@ export default class TransferList extends React.Component<TransferListProps, any
|| this.context.antLocale.Transfer.notFoundContent;
}
const checkStatus = this.getCheckStatus(filteredDataSource);
return (
<div className={listCls} style={style}>
<div className={`${prefixCls}-header`}>
@ -190,6 +201,7 @@ export default class TransferList extends React.Component<TransferListProps, any
checked: checkStatus === 'all',
checkPart: checkStatus === 'part',
checkable: <span className={'ant-transfer-checkbox-inner'}></span>,
filteredDataSource,
})}
<span className={`${prefixCls}-header-selected`}>
<span>