@@ -31,18 +31,6 @@ import coreStyles from '../../styles';
3131class Calendar extends PureComponent {
3232 constructor ( props , context ) {
3333 super ( props , context ) ;
34- this . changeShownDate = this . changeShownDate . bind ( this ) ;
35- this . focusToDate = this . focusToDate . bind ( this ) ;
36- this . updateShownDate = this . updateShownDate . bind ( this ) ;
37- this . handleRangeFocusChange = this . handleRangeFocusChange . bind ( this ) ;
38- this . renderDateDisplay = this . renderDateDisplay . bind ( this ) ;
39- this . onDragSelectionStart = this . onDragSelectionStart . bind ( this ) ;
40- this . onDragSelectionEnd = this . onDragSelectionEnd . bind ( this ) ;
41- this . onDragSelectionMove = this . onDragSelectionMove . bind ( this ) ;
42- this . renderMonthAndYear = this . renderMonthAndYear . bind ( this ) ;
43- this . updatePreview = this . updatePreview . bind ( this ) ;
44- this . estimateMonthSize = this . estimateMonthSize . bind ( this ) ;
45- this . handleScroll = this . handleScroll . bind ( this ) ;
4634 this . dateOptions = { locale : props . locale } ;
4735 if ( this . props . weekStartsOn !== undefined )
4836 this . dateOptions . weekStartsOn = this . props . weekStartsOn ;
@@ -82,7 +70,7 @@ class Calendar extends PureComponent {
8270 calendarHeight : longMonthHeight || 300 ,
8371 } ;
8472 }
85- focusToDate ( date , props = this . props , preventUnnecessary = true ) {
73+ focusToDate = ( date , props = this . props , preventUnnecessary = true ) => {
8674 if ( ! props . scroll . enabled ) {
8775 this . setState ( { focusedDate : date } ) ;
8876 return ;
@@ -93,8 +81,8 @@ class Calendar extends PureComponent {
9381 this . isFirstRender = true ;
9482 this . list . scrollTo ( targetMonthIndex ) ;
9583 this . setState ( { focusedDate : date } ) ;
96- }
97- updateShownDate ( props = this . props ) {
84+ } ;
85+ updateShownDate = ( props = this . props ) => {
9886 const newProps = props . scroll . enabled
9987 ? {
10088 ...props ,
@@ -103,8 +91,8 @@ class Calendar extends PureComponent {
10391 : props ;
10492 const newFocus = calcFocusDate ( this . state . focusedDate , newProps ) ;
10593 this . focusToDate ( newFocus , newProps ) ;
106- }
107- updatePreview ( val ) {
94+ } ;
95+ updatePreview = val => {
10896 if ( ! val ) {
10997 this . setState ( { preview : null } ) ;
11098 return ;
@@ -115,7 +103,7 @@ class Calendar extends PureComponent {
115103 color : this . props . color ,
116104 } ;
117105 this . setState ( { preview } ) ;
118- }
106+ } ;
119107 componentDidMount ( ) {
120108 if ( this . props . scroll . enabled ) {
121109 // prevent react-list's initial render focus problem
@@ -150,7 +138,7 @@ class Calendar extends PureComponent {
150138 }
151139 }
152140
153- changeShownDate ( value , mode = 'set' ) {
141+ changeShownDate = ( value , mode = 'set' ) => {
154142 const { focusedDate } = this . state ;
155143 const { onShownDateChange, minDate, maxDate } = this . props ;
156144 const modeMapper = {
@@ -163,11 +151,11 @@ class Calendar extends PureComponent {
163151 const newDate = min ( [ max ( [ modeMapper [ mode ] ( ) , minDate ] ) , maxDate ] ) ;
164152 this . focusToDate ( newDate , this . props , false ) ;
165153 onShownDateChange && onShownDateChange ( newDate ) ;
166- }
167- handleRangeFocusChange ( rangesIndex , rangeItemIndex ) {
154+ } ;
155+ handleRangeFocusChange = ( rangesIndex , rangeItemIndex ) => {
168156 this . props . onRangeFocusChange && this . props . onRangeFocusChange ( [ rangesIndex , rangeItemIndex ] ) ;
169- }
170- handleScroll ( ) {
157+ } ;
158+ handleScroll = ( ) => {
171159 const { onShownDateChange, minDate } = this . props ;
172160 const { focusedDate } = this . state ;
173161 const { isFirstRender } = this ;
@@ -182,8 +170,8 @@ class Calendar extends PureComponent {
182170 onShownDateChange && onShownDateChange ( visibleMonth ) ;
183171 }
184172 this . isFirstRender = false ;
185- }
186- renderMonthAndYear ( focusedDate , changeShownDate , props ) {
173+ } ;
174+ renderMonthAndYear = ( focusedDate , changeShownDate , props ) => {
187175 const { showMonthArrow, minDate, maxDate, showMonthAndYearPickers } = props ;
188176 const upperYearLimit = ( maxDate || Calendar . defaultProps . maxDate ) . getFullYear ( ) ;
189177 const lowerYearLimit = ( minDate || Calendar . defaultProps . minDate ) . getFullYear ( ) ;
@@ -244,7 +232,7 @@ class Calendar extends PureComponent {
244232 ) : null }
245233 </ div >
246234 ) ;
247- }
235+ } ;
248236 renderWeekdays ( ) {
249237 const now = new Date ( ) ;
250238 return (
@@ -260,7 +248,7 @@ class Calendar extends PureComponent {
260248 </ div >
261249 ) ;
262250 }
263- renderDateDisplay ( ) {
251+ renderDateDisplay = ( ) => {
264252 const {
265253 focusedRange,
266254 color,
@@ -316,8 +304,8 @@ class Calendar extends PureComponent {
316304 } ) }
317305 </ div >
318306 ) ;
319- }
320- onDragSelectionStart ( date ) {
307+ } ;
308+ onDragSelectionStart = date => {
321309 const { onChange, dragSelectionEnabled } = this . props ;
322310
323311 if ( dragSelectionEnabled ) {
@@ -331,9 +319,9 @@ class Calendar extends PureComponent {
331319 } else {
332320 onChange && onChange ( date ) ;
333321 }
334- }
322+ } ;
335323
336- onDragSelectionEnd ( date ) {
324+ onDragSelectionEnd = date => {
337325 const { updateRange, displayMode, onChange, dragSelectionEnabled } = this . props ;
338326
339327 if ( ! dragSelectionEnabled ) return ;
@@ -353,8 +341,8 @@ class Calendar extends PureComponent {
353341 updateRange && updateRange ( newRange ) ;
354342 } ) ;
355343 }
356- }
357- onDragSelectionMove ( date ) {
344+ } ;
345+ onDragSelectionMove = date => {
358346 const { drag } = this . state ;
359347 if ( ! drag . status || ! this . props . dragSelectionEnabled ) return ;
360348 this . setState ( {
@@ -364,9 +352,9 @@ class Calendar extends PureComponent {
364352 disablePreview : true ,
365353 } ,
366354 } ) ;
367- }
355+ } ;
368356
369- estimateMonthSize ( index , cache ) {
357+ estimateMonthSize = ( index , cache ) => {
370358 const { direction, minDate } = this . props ;
371359 const { scrollArea } = this . state ;
372360 if ( cache ) {
@@ -378,7 +366,7 @@ class Calendar extends PureComponent {
378366 const { start, end } = getMonthDisplayRange ( monthStep , this . dateOptions ) ;
379367 const isLongMonth = differenceInDays ( end , start , this . dateOptions ) + 1 > 7 * 5 ;
380368 return isLongMonth ? scrollArea . longMonthHeight : scrollArea . monthHeight ;
381- }
369+ } ;
382370 render ( ) {
383371 const {
384372 showDateDisplay,
0 commit comments