mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 12:09:14 +08:00
fix: should support DatePicker|RangePicker[showTime.defaultValue], (#6160)
close: #5691 #2375
This commit is contained in:
parent
8703145d70
commit
361df26f3a
@ -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;
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -59,7 +60,7 @@ 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" />
|
||||
@ -67,7 +68,10 @@ ReactDOM.render(
|
||||
<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>,
|
||||
|
@ -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() | - |
|
||||
@ -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() | - |
|
||||
|
@ -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() | - |
|
||||
@ -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() | - |
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user