Fix code style

This commit is contained in:
afc163 2015-11-19 19:09:51 +08:00
commit ceb4761555
14 changed files with 61 additions and 21 deletions

View File

@ -13,7 +13,7 @@ function createPicker(TheCalendar) {
getDefaultProps() {
return {
format: 'yyyy-MM-dd',
placeholder: '请选择日期',
placeholder: '',
transitionName: 'slide-up',
popupStyle: {},
onSelect: null, //
@ -80,7 +80,10 @@ function createPicker(TheCalendar) {
const timeValue = value ? new Date(value.getTime()) : null;
// onSelect .
if (this.props.onSelect) {
require('util-deprecate')(this.props.onSelect, 'onSelect property of Datepicker is deprecated, use onChange instead')(timeValue);
require('util-deprecate')(
this.props.onSelect,
'onSelect property of Datepicker is deprecated, use onChange instead'
)(timeValue);
}
this.props.onChange(timeValue);
},
@ -90,12 +93,14 @@ function createPicker(TheCalendar) {
//
let defaultCalendarValue = new GregorianCalendar(this.getLocale());
defaultCalendarValue.setTime(Date.now());
const placeholder = this.props.placeholder || this.getLocale().lang.placeholder;
const calendar = (
<TheCalendar
disabledDate={this.props.disabledDate}
locale={this.getLocale().lang}
defaultValue={defaultCalendarValue}
dateInputPlaceholder={this.props.placeholder}
dateInputPlaceholder={placeholder}
showTime={this.props.showTime}
prefixCls="ant-calendar"
showOk={this.props.showTime}
@ -133,7 +138,7 @@ function createPicker(TheCalendar) {
<input disabled={this.props.disabled}
onChange={this.handleInputChange}
value={value && this.getFormatter().format(value)}
placeholder={this.props.placeholder}
placeholder={placeholder}
className={'ant-calendar-picker-input ant-input' + sizeClass}/>
<span className="ant-calendar-picker-icon"/>
</span>

View File

@ -4,7 +4,9 @@ import CalendarLocale from 'rc-calendar/lib/locale/en_US';
// 统一合并为完整的 Locale
let locale = objectAssign({}, GregorianCalendarLocale);
locale.lang = objectAssign({}, CalendarLocale);
locale.lang = objectAssign({
placeholder: 'Please select a date'
}, CalendarLocale);
// All settings at:
// https://github.com/ant-design/ant-design/issues/424

View File

@ -4,7 +4,9 @@ import CalendarLocale from 'rc-calendar/lib/locale/zh_CN';
// 统一合并为完整的 Locale
let locale = objectAssign({}, GregorianCalendarLocale);
locale.lang = objectAssign({}, CalendarLocale);
locale.lang = objectAssign({
placeholder: '请选择日期'
}, CalendarLocale);
// All settings at:
// https://github.com/ant-design/ant-design/issues/424

View File

@ -32,7 +32,7 @@ const Test = React.createClass({
});
},
render() {
// filterOption 需要设置为 false数据是动态设置的
// filterOption 需要设置为 false数据是动态设置的
return <Select combobox
style={{width:200}}
onChange={this.handleChange}

View File

@ -2,7 +2,7 @@
- order: 3
使用 `marks` 属性标注分段式滑块,使用 `value` / `defaultValue` 指定滑块位置。可以结合 `step` `included` 使用
使用 `marks` 属性标注分段式滑块,使用 `value` / `defaultValue` 指定滑块位置。`included=false` 时,表明不同标记间为并列关系。当 `step=null`Slider 的可选值仅有 `marks` 标出来的部分
---
@ -25,6 +25,8 @@ ReactDOM.render(
<Slider marks={marks} included={false} defaultValue={37} />
<p>结合 step</p>
<Slider marks={marks} step={10} defaultValue={37} />
<p>`step=null`</p>
<Slider marks={marks} step={null} defaultValue={37} />
</div>
, document.getElementById('components-slider-demo-mark'));
````

View File

@ -18,10 +18,10 @@
|------------|----------------|-------------|--------------|
| min | Number | 0 | 最小值
| max | Number | 100 | 最大值
| step | Number | 1 | 步长,取值必须大于 0并且可被 (max - min) 整除
| step | Number or null | 1 | 步长,取值必须大于 0并且可被 (max - min) 整除。当 `marks` 不为空对象时,可以设置 `step``null`,此时 Slider 的可选值仅有 marks 标出来的部分。
| marks | Object {Number: String} | {} | 分段标记key 的类型必须为 `Number` 且取值在闭区间 [min, max] 内
| value | Number or [Number, Number]| | 设置当前取值。当 `range``false` 时,使用 `Number`,否则用 `[Number, Number]`
| defaultValue | Number or [Number, Number]| 0 or [0, 0] | 设置初始取值。当 `range``false` 时,使用 `Number`,否则用 `[Number, Number]`
| marks | Object {Number: String} | {} | 分段标记key 的类型必须为 `Number` 且取值在闭区间 [min, max] 内
| included | Boolean | true | `marks` 不为空对象时有效,值为 true 时表示值为包含关系false 表示并列
| disabled | Boolean | false | 值为 `true` 时,滑块为禁用状态
| onChange | Function | NOOP | 当 Slider 的值发生改变时,会触发 onChange 事件,并把改变后的值作为参数传入。

View File

@ -77,7 +77,7 @@ let FilterMenu = React.createClass({
pointerEvents: 'visible'
}}
onClick={this.handleClearFilters}>
清空
重置
</a>
</Menu.Item>
</Menu>;

View File

@ -1,9 +1,8 @@
import React from 'react';
import DateTimeFormat from 'gregorian-calendar-format';
import TimePicker from 'rc-time-picker/lib/TimePicker';
// import defaultLocale from './locale';
import TimePickerLocale from 'rc-time-picker/lib/locale/zh_CN';
import objectAssign from 'object-assign';
import defaultLocale from './locale/zh_CN';
const AntTimepicker = React.createClass({
getDefaultProps() {
@ -47,7 +46,7 @@ const AntTimepicker = React.createClass({
const defaultValue = this.props.defaultValue;
if (defaultValue) {
return formatter.parse(defaultValue, {
locale: defaultValue.locale,
locale: this.getLocale(),
obeyCount: true,
});
}
@ -58,14 +57,20 @@ const AntTimepicker = React.createClass({
this.props.onChange(new Date(value.getTime()));
},
getLocale() {
// Locale
let locale = objectAssign({}, defaultLocale, this.props.locale);
locale.lang = objectAssign({}, defaultLocale.lang, this.props.locale.lang);
return locale;
},
render() {
const { format } = this.props;
const formatter = new DateTimeFormat(format);
return (
<TimePicker
{...this.props}
locale={TimePickerLocale}
inputClassName={`ant-input ${this.getSizeClass()}`}
formatter={formatter}
defaultValue={this.getDefaultValue(formatter)}

View File

@ -24,7 +24,7 @@ API
|-----------------|-----|-----|-------|
| defaultValue | 默认时间 | string | 无 |
| placeholder | 没有值的时候显示的内容 | string | "请选择时间" |
| onChange | 日期发生变化的回调,发生在用户选择日期时 | function(Date value) | 无 |
| onChange | 时间发生变化的回调 | function(Date value) | 无 |
| format | 展示的时间格式 | string | "HH:mm:ss"、"HH:mm"、"mm:ss" |
| disabled | 禁用 | bool | false |
| hourOptions | 特定可选择的小时 | array | 0 到 24 组成的数组 |

View File

@ -0,0 +1,12 @@
import objectAssign from 'object-assign';
import GregorianCalendarLocale from 'gregorian-calendar/lib/locale/en_US';
import TimepickerLocale from 'rc-time-picker/lib/locale/en_US';
// 统一合并为完整的 Locale
let locale = objectAssign({}, GregorianCalendarLocale);
locale.lang = objectAssign({}, TimepickerLocale);
// All settings at:
// https://github.com/ant-design/ant-design/issues/424
export default locale;

View File

@ -0,0 +1,12 @@
import objectAssign from 'object-assign';
import GregorianCalendarLocale from 'gregorian-calendar/lib/locale/zh_CN';
import TimepickerLocale from 'rc-time-picker/lib/locale/zh_CN';
// 统一合并为完整的 Locale
let locale = objectAssign({}, GregorianCalendarLocale);
locale.lang = objectAssign({}, TimepickerLocale);
// All settings at:
// https://github.com/ant-design/ant-design/issues/424
export default locale;

View File

@ -52,7 +52,7 @@
"rc-queue-anim": "~0.11.2",
"rc-radio": "~2.0.0",
"rc-select": "~5.1.2",
"rc-slider": "~3.0.0",
"rc-slider": "~3.1.0",
"rc-steps": "~1.4.1",
"rc-switch": "~1.3.1",
"rc-table": "~3.6.1",

View File

@ -101,7 +101,7 @@
text-overflow: ellipsis;
white-space: nowrap;
padding-left: 10px;
padding-right: 20px;
padding-right: 24px;
line-height: 26px;
}

View File

@ -37,7 +37,7 @@
content: "\e631";
font-family: "anticon";
font-size: 12px;
color: #ccc;
color: #aaa;
display: inline-block;
line-height: 1;
width: 20px;