Skip to content

Commit

Permalink
Fix disabledDate of Calendar, close ant-design#6074
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed May 23, 2017
1 parent b83529d commit f414398
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions components/calendar/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ moment.locale('zh-cn');
| locale | set locale | object | [default](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) |
| onPanelChange| callback when panel change | function(date: moment, mode: string) | - |
| onSelect | callback when select date | function(date: moment) | - |
| disabledDate | specify the date that cannot be selected | (currentDate: moment) => boolean ||
1 change: 1 addition & 0 deletions components/calendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface CalendarProps {
style?: React.CSSProperties;
onPanelChange?: (date?: moment.Moment, mode?: CalendarMode) => void;
onSelect?: (date?: moment.Moment) => void;
disabledDate?: (current: moment.Moment) => boolean;
}

export interface CalendarState {
Expand Down
1 change: 1 addition & 0 deletions components/calendar/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ moment.locale('zh-cn');
| locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) |
| onPanelChange| 日期面板变化回调 | function(date: moment, mode: string) ||
| onSelect | 点击选择日期回调 | function(date: moment) ||
| disabledDate | 不可选择的日期 | (currentDate: moment) => boolean ||
33 changes: 21 additions & 12 deletions components/calendar/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,6 @@
color: #fff;
}

&-disabled-cell &-value {
cursor: not-allowed;
color: @disabled-color;
background: @disabled-bg;
border-radius: 0;
width: auto;

&:hover {
background: @disabled-bg;
}
}

&-disabled-cell-first-of-row &-value {
border-top-left-radius: @border-radius-base;
border-bottom-left-radius: @border-radius-base;
Expand Down Expand Up @@ -254,4 +242,25 @@
left: auto;
bottom: auto;
}

&-disabled-cell &-date {
&,
&:hover {
cursor: not-allowed;
}
}

&-disabled-cell:not(&-today) &-date {
&,
&:hover {
background: transparent;
}
}

&-disabled-cell &-value {
color: @disabled-color;
border-radius: 0;
width: auto;
cursor: not-allowed;
}
}
2 changes: 1 addition & 1 deletion components/date-picker/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The following APIs are shared by DatePicker, MonthPicker, RangePicker.
| popupStyle | to customize the style of the popup calendar | object | {} |
| size | determine the size of the input box, the height of `large` and `small`, are 32px and 22px respectively, while default size is 28px | string | - |
| locale | localization configuration | object | [default](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) |
| disabledDate | to specify the date that cannot be selected | function | - |
| disabledDate | specify the date that cannot be selected | (currentDate: moment) => boolean | - |
| getCalendarContainer | to set the container of the floating layer, while the default is to create a `div` element in `body` | function(trigger) | - |
| open | open state of picker | boolean | - |
| onOpenChange | a callback function, can be executed whether the popup calendar is popped up or closed | function(status) | - |
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ moment.locale('zh-cn');
| popupStyle | 格外的弹出日历样式 | object | {} |
| size | 输入框大小,`large` 高度为 32px,`small` 为 22px,默认是 28px | string ||
| locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) |
| disabledDate | 不可选择的日期 | function ||
| disabledDate | 不可选择的日期 | (currentDate: moment) => boolean ||
| getCalendarContainer | 定义浮层的容器,默认为 body 上新建 div | function(trigger) ||
| open | 控制弹层是否展开 | boolean | - |
| onOpenChange | 弹出日历和关闭日历的回调 | function(status) ||
Expand Down

0 comments on commit f414398

Please sign in to comment.