Skip to content

Commit

Permalink
fix: should support DatePicker|RangePicker[showTime.defaultValue], (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
benjycui authored May 18, 2017
1 parent 8703145 commit 361df26
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
10 changes: 7 additions & 3 deletions components/date-picker/demo/disabled-date.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ title:
Disabled part of dates and time by `disabledDate` and `disabledTime` respectively, and `disabledTime` only works with `showTime`.

````jsx
import moment from 'moment';
import { DatePicker } from 'antd';
const { MonthPicker, RangePicker } = DatePicker;

Expand All @@ -26,7 +27,7 @@ function range(start, end) {
}

function disabledDate(current) {
// can not select days before today and today
// Can not select days before today and today
return current && current.valueOf() < Date.now();
}

Expand Down Expand Up @@ -59,15 +60,18 @@ ReactDOM.render(
format="YYYY-MM-DD HH:mm:ss"
disabledDate={disabledDate}
disabledTime={disabledDateTime}
showTime
showTime={{ defaultValue: moment('00:00:00', 'HH:mm:ss') }}
/>
<br />
<MonthPicker disabledDate={disabledDate} placeholder="Select month" />
<br />
<RangePicker
disabledDate={disabledDate}
disabledTime={disabledRangeTime}
showTime={{ hideDisabledOptions: true }}
showTime={{
hideDisabledOptions: true,
defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('11:59:59', 'HH:mm:ss')],
}}
format="YYYY-MM-DD HH:mm:ss"
/>
</div>,
Expand Down
2 changes: 2 additions & 0 deletions components/date-picker/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ The following APIs are shared by DatePicker, MonthPicker, RangePicker.
| format | to set the date format, refer to [moment.js](http://momentjs.com/) | string | "YYYY-MM-DD" |
| onChange | a callback function, can be executed when the selected time is changing | function(date: moment, dateString: string) | - |
| showTime | to provide an additional time selection | object\|boolean | [TimePicker Options](/components/time-picker/#API) |
| showTime.defaultValue | to set default time of selected date, [demo](https://ant.design/components/date-picker/#components-date-picker-demo-disabled-date) | [moment](http://momentjs.com/) | moment() |
| showToday | whether to show "Today" button | boolean | true |
| disabledTime | to specify the time that cannot be selected | function(date) | - |
| onOk | callback when click ok button | function() | - |
Expand All @@ -80,6 +81,7 @@ The following APIs are shared by DatePicker, MonthPicker, RangePicker.
| format | to set the date format | string | "YYYY-MM-DD HH:mm:ss" |
| onChange | a callback function, can be executed when the selected time is changing | function(dates: [moment, moment], dateStrings: [string, string]) | - |
| showTime | to provide an additional time selection | object\|boolean | [TimePicker Options](/components/time-picker/#API) |
| showTime.defaultValue | to set default time of selected date, [demo](https://ant.design/components/date-picker/#components-date-picker-demo-disabled-date) | [moment](http://momentjs.com/)[] | [moment(), moment()] |
| disabledTime | to specify the time that cannot be selected | function(dates: [moment, moment], partial: `'start'|'end'`) | - |
| ranges | preseted ranges for quick selection | { [range: string]: [moment](http://momentjs.com/)[] } | - |
| onOk | callback when click ok button | function() | - |
Expand Down
2 changes: 2 additions & 0 deletions components/date-picker/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ moment.locale('zh-cn');
| format | 展示的日期格式,配置参考 [moment.js](http://momentjs.com/) | string | "YYYY-MM-DD" |
| onChange | 时间发生变化的回调 | function(date: moment, dateString: string) ||
| showTime | 增加时间选择功能 | Object\|boolean | [TimePicker Options](/components/time-picker/#API) |
| showTime.defaultValue | 设置用户选择日期时默认的时分秒,[例子](https://ant.design/components/date-picker/#components-date-picker-demo-disabled-date) | [moment](http://momentjs.com/) | moment() |
| showToday | 是否展示“今天”按钮 | boolean | true |
| disabledTime | 不可选择的时间 | function(date) ||
| onOk | 点击确定按钮的回调 | function() | - |
Expand All @@ -81,6 +82,7 @@ moment.locale('zh-cn');
| format | 展示的日期格式 | string | "YYYY-MM-DD HH:mm:ss" |
| onChange | 时间发生变化的回调,发生在用户选择时间时 | function(dates: [moment, moment], dateStrings: [string, string]) ||
| showTime | 增加时间选择功能 | Object\|boolean | [TimePicker Options](/components/time-picker/#API) |
| showTime.defaultValue | 设置用户选择日期时默认的时分秒,[例子](https://ant.design/components/date-picker/#components-date-picker-demo-disabled-date) | [moment](http://momentjs.com/)[] | [moment(), moment()] |
| disabledTime | 不可选择的时间 | function(dates: [moment, moment], partial: `'start'|'end'`) ||
| ranges       | 预设时间范围快捷选择 | { [range: string]: [moment](http://momentjs.com/)[] } ||
| onOk | 点击确定按钮的回调 | function() | - |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"omit.js": "^0.1.0",
"prop-types": "^15.5.7",
"rc-animate": "~2.3.0",
"rc-calendar": "~8.1.0",
"rc-calendar": "~8.2.0",
"rc-cascader": "~0.11.0",
"rc-checkbox": "~2.0.0",
"rc-collapse": "~1.7.0",
Expand Down

0 comments on commit 361df26

Please sign in to comment.