-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add possibility to define disabled days #62
Conversation
handleDayClick = (value, modifiers) => { | ||
if (!modifiers.disabled) { | ||
this.handleDateChange(value); | ||
this.setState({ showPicker: false }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better be this.hidePicker();
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
locale={'de'} | ||
onChange={_scope.handleChange1.bind(_scope)} | ||
value={_scope.state.value1} | ||
disabledDays={{ after: new Date() }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Props reference and example don't match: modifiers
vs. disabledDays
.
@@ -32,7 +32,17 @@ See react-day-picker [methods reference](http://react-day-picker.js.org/APIMetho | |||
<DayPicker | |||
dayPickerRef={ref => (window.picker = ref)} | |||
onChange={ day => console.log('day:', day) } | |||
locale="de" | |||
locale="en" | |||
disabledDays={{ after: new Date() }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong naming? No such prop in prop types neither in component's code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
Changed to modifiers: { disabled: ... }
Fixed.
import './DayPicker.less'; | ||
window.dayjs = dayjs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obsolete.
showPicker: false | ||
}); | ||
handleDayClick = (dayValue, modifiers) => { | ||
if (!modifiers.disabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better
if (modifiers.disabled) {
return
}
... code
API changes
Added new property
modifiers
.Implemented default
disabled
modifier.Disabled days validation and display for
DateInput
andDateRangeInput
components can be implemented by validation at parent component level and passing validation result toisValid
property.For validation use
import { ModifiersUtils } from @opuscapita/react-dates
.See component documentation for details.