update DatePicker doc and demo

pull/3831/head
afc163 8 years ago
parent 1850e4b7cf
commit 82fa3ed2a5

@ -26,7 +26,6 @@ ReactDOM.render(
<DatePicker onChange={onChange} /><br />
<MonthPicker onChange={onChange} /><br />
<RangePicker onChange={onChange} />
</div>,
mountNode
);
</div>
, mountNode);
````

@ -25,7 +25,6 @@ function range(start, end) {
return result;
}
function disabledDate(current) {
// can not select days before today and today
return current && current.valueOf() < Date.now();
@ -33,51 +32,32 @@ function disabledDate(current) {
function disabledDateTime() {
return {
disabledHours() {
return range(0, 60).splice(4, 20);
},
disabledMinutes() {
return range(30, 60);
},
disabledSeconds() {
return [55, 56];
},
disabledHours: () => range(0, 60).splice(4, 20),
disabledMinutes: () => range(30, 60),
disabledSeconds: () => [55, 56],
};
}
function disabledRangeTime(_, type) {
if (type === 'start') {
return {
disabledHours() {
return range(0, 60).splice(4, 20);
},
disabledMinutes() {
return range(30, 60);
},
disabledSeconds() {
return [55, 56];
},
disabledHours: () => range(0, 60).splice(4, 20),
disabledMinutes: () => range(30, 60),
disabledSeconds: () => [55, 56],
};
}
return {
disabledHours() {
return range(0, 60).splice(20, 4);
},
disabledMinutes() {
return range(0, 31);
},
disabledSeconds() {
return [55, 56];
},
disabledHours: () => range(0, 60).splice(20, 4),
disabledMinutes: () => range(0, 31),
disabledSeconds: () => [55, 56],
};
}
ReactDOM.render(
<div>
<DatePicker disabledDate={disabledDate} disabledTime={disabledDateTime} showTime />
<DatePicker format="YYYY-MM-DD HH:mm:ss" disabledDate={disabledDate} disabledTime={disabledDateTime} showTime />
<br />
<RangePicker disabledDate={disabledDate} disabledTime={disabledRangeTime} showTime />
</div>,
mountNode
);
<RangePicker format="YYYY-MM-DD HH:mm:ss" disabledDate={disabledDate} disabledTime={disabledRangeTime} showTime />
</div>
, mountNode);
````

@ -21,13 +21,14 @@ const { MonthPicker, RangePicker } = DatePicker;
const dateFormat = 'YYYY-MM-DD';
ReactDOM.render(
<div>
<DatePicker defaultValue={moment('2015-06-06', dateFormat)} disabled /><br />
<MonthPicker defaultValue={moment('2015-06', 'YYYY-MM')} disabled /><br />
<DatePicker defaultValue={moment('2015-06-06', dateFormat)} disabled />
<br />
<MonthPicker defaultValue={moment('2015-06', 'YYYY-MM')} disabled />
<br />
<RangePicker
defaultValue={[moment('2015-06-06', dateFormat), moment('2015-06-06', dateFormat)]}
disabled
/>
</div>,
mountNode
);
</div>
, mountNode);
````

@ -22,13 +22,14 @@ const dateFormat = 'YYYY/MM/DD';
const monthFormat = 'YYYY/MM';
ReactDOM.render(
<div>
<DatePicker defaultValue={moment('2015/01/01', dateFormat)} format={dateFormat} /><br />
<MonthPicker defaultValue={moment('2015/01', monthFormat)} format={monthFormat} /><br />
<DatePicker defaultValue={moment('2015/01/01', dateFormat)} format={dateFormat} />
<br />
<MonthPicker defaultValue={moment('2015/01', monthFormat)} format={monthFormat} />
<br />
<RangePicker
defaultValue={[moment('2015/01/01', dateFormat), moment('2015/01/01', dateFormat)]}
format={dateFormat}
/><br />
</div>,
mountNode
);
/>
</div>
, mountNode);
````

@ -39,7 +39,6 @@ ReactDOM.render(
locale={enUS}
showTime
onChange={log}
/>,
mountNode
);
/>
, mountNode);
````

@ -35,9 +35,12 @@ class PickerSizesDemo extends React.Component {
<Radio.Button value="large">Large</Radio.Button>
<Radio.Button value="default">Default</Radio.Button>
<Radio.Button value="small">Small</Radio.Button>
</Radio.Group><br /><br />
<DatePicker size={size} /><br />
<MonthPicker size={size} /><br />
</Radio.Group>
<br /><br />
<DatePicker size={size} />
<br />
<MonthPicker size={size} />
<br />
<RangePicker size={size} />
</div>
);

@ -25,14 +25,18 @@ function onChange(value, dateString) {
ReactDOM.render(
<div>
<DatePicker
showTime={{ format: 'HH:mm' }} format="YYYY-MM-DD HH:mm"
placeholder="Select Time" onChange={onChange}
/><br />
showTime
format="YYYY-MM-DD HH:mm:ss"
placeholder="Select Time"
onChange={onChange}
/>
<br />
<RangePicker
showTime={{ format: 'HH:mm' }} format="YYYY-MM-DD HH:mm"
placeholder={['Start Time', 'End Time']} onChange={onChange}
showTime
format="YYYY-MM-DD HH:mm:ss"
placeholder={['Start Time', 'End Time']}
onChange={onChange}
/>
</div>,
mountNode
);
</div>
, mountNode);
````

@ -4,10 +4,7 @@ type: Data Entry
title: DatePicker
---
To select or input a date. There are three kinds of picker:
* DatePicker
* MonthPicker
* RangePicker
To select or input a date.
## When To Use
@ -15,6 +12,12 @@ By clicking the input box, you can select a date from a popup calendar.
## API
There are three kinds of picker:
* DatePicker
* MonthPicker
* RangePicker
**Note:** Part of locale of DatePicker, MonthPicker, RangePicker is read from value. So, please set the locale of moment correctly.
```jsx

@ -5,10 +5,7 @@ title: DatePicker
subtitle: 日期选择框
---
输入或选择日期的控件,包括以下三种形式。
* DatePicker
* MonthPicker
* RangePicker
输入或选择日期的控件。
## 何时使用
@ -16,6 +13,12 @@ subtitle: 日期选择框
## API
日期类组件包括以下三种形式。
* DatePicker
* MonthPicker
* RangePicker
**注意:**DatePicker、MonthPicker、RangePicker 部分 locale 是从 value 中读取,所以请先正确设置 moment 的 locale。
```jsx

Loading…
Cancel
Save