Skip to content

Commit

Permalink
Datepicker: Add inValidDay support (#12962)
Browse files Browse the repository at this point in the history
  • Loading branch information
psealock authored and youknowriad committed Mar 6, 2019
1 parent 410f531 commit 34842b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### New Feature

- `Dropdown` now has a `focusOnMount` prop which is passed directly to the contained `Popover`.
- `DatePicker` has new prop `isInvalidDate` exposing react-dates' `isOutsideRange`.

## 7.0.5 (2019-01-03)

Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/date-time/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,10 @@ Whether we use a 12-hour clock. With a 12-hour clock, an AM/PM widget is display

- Type: `bool`
- Required: No

### isInvalidDate

A callback function which receives a Date object representing a day as an argument, and should return a Boolean to signify if the day is valid or not.

- Type: `Function`
- Required: No
5 changes: 4 additions & 1 deletion packages/components/src/date-time/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DatePicker extends Component {
}

render() {
const { currentDate } = this.props;
const { currentDate, isInvalidDate } = this.props;

const momentDate = currentDate ? moment( currentDate ) : moment();

Expand All @@ -56,6 +56,9 @@ class DatePicker extends Component {
transitionDuration={ 0 }
weekDayFormat="ddd"
isRTL={ isRTL() }
isOutsideRange={ ( date ) => {
return isInvalidDate && isInvalidDate( date.toDate() );
} }
/>
</div>
);
Expand Down

0 comments on commit 34842b4

Please sign in to comment.