Merge branch 'master' of github.com:ant-design/ant-design

This commit is contained in:
afc163
2016-09-28 13:49:52 +08:00
24 changed files with 385 additions and 108 deletions
+6 -16
View File
@@ -45,10 +45,7 @@ export default class RangePicker extends React.Component<any, any> {
render() {
const props = this.props;
const locale = props.locale;
const { disabledDate, showTime, getCalendarContainer, prefixCls,
transitionName, disabled, popupStyle, align, style, onOk } = this.props;
const { disabledDate, showTime, prefixCls, popupStyle, style, onOk, locale } = props;
const state = this.state;
const calendarClassName = classNames({
@@ -63,9 +60,7 @@ export default class RangePicker extends React.Component<any, any> {
onOk: this.handleChange,
};
if (props.timePicker) {
pickerChangeHandler.onChange = (value) => {
this.handleChange(value);
};
pickerChangeHandler.onChange = value => this.handleChange(value);
} else {
calendarHandler = {};
}
@@ -98,26 +93,21 @@ export default class RangePicker extends React.Component<any, any> {
return (<span className={props.pickerClass} style={style}>
<RcDatePicker
{...props}
{...pickerChangeHandler}
transitionName={transitionName}
disabled={disabled}
calendar={calendar}
value={state.value}
prefixCls={`${prefixCls}-picker-container`}
style={popupStyle}
align={align}
getCalendarContainer={getCalendarContainer}
onOpen={props.toggleOpen}
onClose={props.toggleOpen}
>
{
({ value }) => {
const start = value[0];
const end = value[1];
return (
<span className={props.pickerInputClass} disabled={disabled}>
<span className={props.pickerInputClass} disabled={props.disabled}>
<input
disabled={disabled}
disabled={props.disabled}
readOnly
value={(start && start.format(props.format)) || ''}
placeholder={startPlaceholder}
@@ -125,7 +115,7 @@ export default class RangePicker extends React.Component<any, any> {
/>
<span className={`${prefixCls}-range-picker-separator`}> ~ </span>
<input
disabled={disabled}
disabled={props.disabled}
readOnly
value={(end && end.format(props.format)) || ''}
placeholder={endPlaceholder}
+2 -12
View File
@@ -72,11 +72,7 @@ export default function createPicker(TheCalendar) {
let calendarHandler: Object = {
onOk: this.handleChange,
// fix https://github.com/ant-design/ant-design/issues/1902
onSelect: (value, cause) => {
if (cause && cause.source === 'todayButton') {
this.handleChange(value);
}
},
onSelect: value => this.handleChange(value),
};
if (props.showTime) {
pickerChangeHandler = {};
@@ -113,18 +109,12 @@ export default function createPicker(TheCalendar) {
return (
<span className={props.pickerClass} style={assign({}, pickerStyle, props.style)}>
<RcDatePicker
{...props}
{...pickerChangeHandler}
transitionName={props.transitionName}
disabled={props.disabled}
calendar={calendar}
value={this.state.value}
prefixCls={`${prefixCls}-picker-container`}
style={props.popupStyle}
align={props.align}
getCalendarContainer={props.getCalendarContainer}
open={props.open}
onOpen={props.toggleOpen}
onClose={props.toggleOpen}
>
{
({ value }) => {
+4 -4
View File
@@ -48,12 +48,12 @@ const DateRange = React.createClass({
onEndChange(value) {
this.onChange('endValue', value);
},
handleStartToggle({ open }) {
handleStartOpenChange(open) {
if (!open) {
this.setState({ endOpen: true });
}
},
handleEndToggle({ open }) {
handleEndOpenChange(open) {
this.setState({ endOpen: open });
},
render() {
@@ -66,7 +66,7 @@ const DateRange = React.createClass({
value={this.state.startValue}
placeholder="开始日期"
onChange={this.onStartChange}
toggleOpen={this.handleStartToggle}
onOpenChange={this.handleStartOpenChange}
/>
<DatePicker
disabledDate={this.disabledEndDate}
@@ -76,7 +76,7 @@ const DateRange = React.createClass({
placeholder="结束日期"
onChange={this.onEndChange}
open={this.state.endOpen}
toggleOpen={this.handleEndToggle}
onOpenChange={this.handleEndOpenChange}
/>
</div>
);
+1 -1
View File
@@ -41,7 +41,7 @@ moment.tz.setDefault('Asia/Shanghai')
| locale | localization configuration | Object | [default](https://github.com/ant-design/ant-design/issues/424) |
| onOk | a callback function, can be executed when OK-button is clicked | function(Date value) | - |
| open | open state of picker | bool | - |
| toggleOpen | a callback function, can be executed whether the popup calendar is popped up or closed | function(open) | - |
| onOpenChange | a callback function, can be executed whether the popup calendar is popped up or closed | function(status) | - |
| getCalendarContainer | to set the container of the floating layer, while the default is to create a `div` element in `body` | function(trigger) | - |
| showTime | to provide an additional time selection | Object/Boolean | [TimePicker Options](http://ant.design/components/time-picker/#api) |
+1 -1
View File
@@ -41,7 +41,7 @@ moment.tz.setDefault('Asia/Shanghai')
| size | 输入框大小,`large` 高度为 32px`small` 为 22px,默认是 28px | string | 无 |
| locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/issues/424) |
| open | 控制弹层是否展开 | bool | - |
| toggleOpen | 弹出日历和关闭日历的回调 | function(open) | 无 |
| onOpenChange | 弹出日历和关闭日历的回调 | function(status) | 无 |
| getCalendarContainer | 定义浮层的容器,默认为 body 上新建 div | function(trigger) | 无 |
| showTime | 增加时间选择功能 | Object or Boolean | [TimePicker Options](http://ant.design/components/time-picker/#api) |
@@ -24,6 +24,21 @@
overflow: hidden;
}
&-1-column,
&-1-column &-select {
width: 100%;
}
&-2-columns &-select {
width: 115px;
}
&-1-column &-select,
&-2-columns &-select {
li {
padding: 0;
text-align: center;
}
}
&-input {
margin: 0;
padding: 0;
+24 -8
View File
@@ -4,6 +4,7 @@ import TimePickerPanel from 'rc-time-picker/lib/Panel';
import classNames from 'classnames';
import defaultLocale from './locale/zh_CN';
import assign from 'object-assign';
import warning from 'warning';
export default function wrapPicker(Picker, defaultFormat?) {
const PickerWrapper = React.createClass({
@@ -16,7 +17,7 @@ export default function wrapPicker(Picker, defaultFormat?) {
},
onOk() {
},
toggleOpen() {
onOpenChange() {
},
locale: {},
align: {
@@ -44,8 +45,18 @@ export default function wrapPicker(Picker, defaultFormat?) {
return result;
},
toggleOpen ({open}) {
this.props.toggleOpen({open});
handleOpenChange(open) {
const { onOpenChange, toggleOpen } = this.props;
onOpenChange(open);
if (toggleOpen) {
warning(
false,
'`toggleOpen` is deprecated and will be removed in the future, ' +
'please use `onOpenChange` instead'
);
toggleOpen({open});
}
},
render() {
@@ -63,17 +74,22 @@ export default function wrapPicker(Picker, defaultFormat?) {
const locale = this.getLocale();
const timeFormat = props.showTime && props.showTime.format;
const timeFormat = (props.showTime && props.showTime.format) || 'HH:mm:ss';
const rcTimePickerProps = {
format: timeFormat || 'HH:mm:ss',
showSecond: timeFormat && timeFormat.indexOf('ss') >= 0,
showHour: timeFormat && timeFormat.indexOf('HH') >= 0,
format: timeFormat,
showSecond: timeFormat.indexOf('ss') >= 0,
showHour: timeFormat.indexOf('HH') >= 0,
};
const timePickerCls = classNames({
[`${prefixCls}-time-picker-1-column`]: !(rcTimePickerProps.showSecond || rcTimePickerProps.showHour),
[`${prefixCls}-time-picker-2-columns`]: rcTimePickerProps.showSecond !== rcTimePickerProps.showHour,
});
const timePicker = props.showTime ? (
<TimePickerPanel
{...rcTimePickerProps}
{...props.showTime}
prefixCls={`${prefixCls}-time-picker`}
className={timePickerCls}
placeholder={locale.timePickerLocale.placeholder}
transitionName="slide-up"
/>
@@ -86,7 +102,7 @@ export default function wrapPicker(Picker, defaultFormat?) {
pickerInputClass={pickerInputClass}
locale={locale}
timePicker={timePicker}
toggleOpen={this.toggleOpen}
onOpenChange={this.handleOpenChange}
/>
);
},
+1
View File
@@ -52,6 +52,7 @@ export interface InputProps {
onBlur?: React.FormEventHandler;
autosize?: boolean | AutoSizeType;
autoComplete?: 'on' | 'off';
style?: React.CSSProperties;
}
export default class Input extends Component<InputProps, any> {
+1 -1
View File
@@ -42,4 +42,4 @@ title: Steps
| status | 指定状态。当不配置该属性时,会使用 Steps 的 `current` 来自动指定状态。可选:`wait` `process` `finish` `error` | String | wait |
| title | 标题 | React.Element | - |
| description | 步骤的详情描述,可选 | React.Element | - |
| icon | 步骤图标,可选 | React.Element | - |
| icon | 步骤图标的类型,可选 | string | - |
+5 -1
View File
@@ -562,7 +562,11 @@ export default class Table extends React.Component<TableProps, any> {
if (typeof rowKey === 'function') {
return rowKey(record, index);
}
return record[rowKey as string] || index;
let recordKey = record[rowKey as string] !== undefined ? record[rowKey as string] : index;
warning(recordKey !== undefined,
'Each record in table should have a unique `key` prop, or set `rowKey` to an unique primary key.'
);
return recordKey;
}
checkSelection(data, type, byDefaultChecked) {
+1 -1
View File
@@ -31,7 +31,7 @@ export interface TooltipProps {
overlay?: React.ReactNode;
openClassName?: string;
arrowPointAtCenter?: boolean;
getTooltipContainer: (triggerNode: React.ReactNode) => HTMLElement;
getTooltipContainer?: (triggerNode: React.ReactNode) => HTMLElement;
}
export default class Tooltip extends React.Component<TooltipProps, any> {