@@ -5,6 +5,8 @@ import style from './style';
55
66class Month extends React . Component {
77 static propTypes = {
8+ maxDate : React . PropTypes . object ,
9+ minDate : React . PropTypes . object ,
810 onDayClick : React . PropTypes . func ,
911 selectedDate : React . PropTypes . object ,
1012 viewDate : React . PropTypes . object
@@ -22,11 +24,21 @@ class Month extends React.Component {
2224
2325 renderDays ( ) {
2426 return utils . range ( 1 , utils . time . getDaysInMonth ( this . props . viewDate ) + 1 ) . map ( i => {
27+ let active = true ;
28+
29+ if ( this . props . minDate || this . props . maxDate ) {
30+ const date = new Date ( this . props . viewDate . getFullYear ( ) , this . props . viewDate . getMonth ( ) , i ) ;
31+ if ( this . props . minDate && ! ( date >= this . props . minDate ) ) active = false ;
32+ if ( this . props . maxDate && ! ( date <= this . props . maxDate ) ) active = false ;
33+ console . log ( 'day' , i , date , this . props . minDate , active ) ;
34+ }
35+
2536 return (
2637 < Day
2738 key = { i }
2839 day = { i }
29- onClick = { this . handleDayClick . bind ( this , i ) }
40+ disabled = { ! active }
41+ onClick = { active ? this . handleDayClick . bind ( this , i ) : null }
3042 selectedDate = { this . props . selectedDate }
3143 viewDate = { this . props . viewDate }
3244 />
@@ -35,6 +47,7 @@ class Month extends React.Component {
3547 }
3648
3749 render ( ) {
50+ console . info ( 'max/min' , this . props . maxDate , this . props . minDate ) ;
3851 return (
3952 < div className = { style . month } >
4053 < span className = { style . title } >
0 commit comments