1
- import Calendar from ' ./calendar' ;
2
- import React from ' react' ;
3
- import PropTypes from ' prop-types' ;
4
- import PopperComponent , { popperPlacementPositions } from ' ./popper_component' ;
5
- import classnames from ' classnames' ;
1
+ import Calendar from " ./calendar" ;
2
+ import React from " react" ;
3
+ import PropTypes from " prop-types" ;
4
+ import PopperComponent , { popperPlacementPositions } from " ./popper_component" ;
5
+ import classnames from " classnames" ;
6
6
import {
7
7
newDate ,
8
8
now ,
@@ -34,13 +34,13 @@ import {
34
34
safeDateFormat ,
35
35
getHightLightDaysMap ,
36
36
getYear ,
37
- getMonth ,
38
- } from ' ./date_utils' ;
39
- import onClickOutside from ' react-onclickoutside' ;
37
+ getMonth
38
+ } from " ./date_utils" ;
39
+ import onClickOutside from " react-onclickoutside" ;
40
40
41
- export { default as CalendarContainer } from ' ./calendar_container' ;
41
+ export { default as CalendarContainer } from " ./calendar_container" ;
42
42
43
- const outsideClickIgnoreClass = ' react-datepicker-ignore-onclickoutside' ;
43
+ const outsideClickIgnoreClass = " react-datepicker-ignore-onclickoutside" ;
44
44
const WrappedCalendar = onClickOutside ( Calendar ) ;
45
45
46
46
// Compares dates year+month combinations
@@ -65,7 +65,7 @@ function hasSelectionChanged(date1, date2) {
65
65
/**
66
66
* General datepicker component.
67
67
*/
68
- const INPUT_ERR_1 = ' Date input not valid.' ;
68
+ const INPUT_ERR_1 = " Date input not valid." ;
69
69
70
70
export default class DatePicker extends React . Component {
71
71
static propTypes = {
@@ -85,7 +85,7 @@ export default class DatePicker extends React.Component {
85
85
dayClassName : PropTypes . func ,
86
86
disabled : PropTypes . bool ,
87
87
disabledKeyboardNavigation : PropTypes . bool ,
88
- dropdownMode : PropTypes . oneOf ( [ ' scroll' , ' select' ] ) . isRequired ,
88
+ dropdownMode : PropTypes . oneOf ( [ " scroll" , " select" ] ) . isRequired ,
89
89
endDate : PropTypes . object ,
90
90
excludeDates : PropTypes . array ,
91
91
filterDate : PropTypes . func ,
@@ -123,6 +123,7 @@ export default class DatePicker extends React.Component {
123
123
popperClassName : PropTypes . string , // <PopperComponent/> props
124
124
popperModifiers : PropTypes . object , // <PopperComponent/> props
125
125
popperPlacement : PropTypes . oneOf ( popperPlacementPositions ) , // <PopperComponent/> props
126
+ popperProps : PropTypes . object ,
126
127
preventOpenOnFocus : PropTypes . bool ,
127
128
readOnly : PropTypes . bool ,
128
129
required : PropTypes . bool ,
@@ -168,12 +169,12 @@ export default class DatePicker extends React.Component {
168
169
static get defaultProps ( ) {
169
170
return {
170
171
allowSameDay : false ,
171
- dateFormat : 'L' ,
172
- dateFormatCalendar : ' MMMM YYYY' ,
172
+ dateFormat : "L" ,
173
+ dateFormatCalendar : " MMMM YYYY" ,
173
174
onChange ( ) { } ,
174
175
disabled : false ,
175
176
disabledKeyboardNavigation : false ,
176
- dropdownMode : ' scroll' ,
177
+ dropdownMode : " scroll" ,
177
178
onFocus ( ) { } ,
178
179
onBlur ( ) { } ,
179
180
onKeyDown ( ) { } ,
@@ -190,9 +191,9 @@ export default class DatePicker extends React.Component {
190
191
shouldCloseOnSelect : true ,
191
192
showTimeSelect : false ,
192
193
timeIntervals : 30 ,
193
- timeCaption : ' Time' ,
194
- previousMonthButtonLabel : ' Previous Month' ,
195
- nextMonthButtonLabel : ' Next month' ,
194
+ timeCaption : " Time" ,
195
+ previousMonthButtonLabel : " Previous Month" ,
196
+ nextMonthButtonLabel : " Next month"
196
197
} ;
197
198
}
198
199
@@ -210,7 +211,7 @@ export default class DatePicker extends React.Component {
210
211
}
211
212
if ( prevProps . highlightDates !== this . props . highlightDates ) {
212
213
this . setState ( {
213
- highlightDates : getHightLightDaysMap ( this . props . highlightDates ) ,
214
+ highlightDates : getHightLightDaysMap ( this . props . highlightDates )
214
215
} ) ;
215
216
}
216
217
if (
@@ -253,7 +254,7 @@ export default class DatePicker extends React.Component {
253
254
// transforming highlighted days (perhaps nested array)
254
255
// to flat Map for faster access in day.jsx
255
256
highlightDates : getHightLightDaysMap ( this . props . highlightDates ) ,
256
- focused : false ,
257
+ focused : false
257
258
} ;
258
259
} ;
259
260
@@ -276,7 +277,7 @@ export default class DatePicker extends React.Component {
276
277
open && this . state . open
277
278
? this . state . preSelection
278
279
: this . calcInitialState ( ) . preSelection ,
279
- lastPreSelectChange : PRESELECT_CHANGE_VIA_NAVIGATE ,
280
+ lastPreSelectChange : PRESELECT_CHANGE_VIA_NAVIGATE
280
281
} ) ;
281
282
} ;
282
283
inputOk = ( ) =>
@@ -335,15 +336,15 @@ export default class DatePicker extends React.Component {
335
336
if ( this . props . onChangeRaw ) {
336
337
this . props . onChangeRaw . apply ( this , allArgs ) ;
337
338
if (
338
- typeof event . isDefaultPrevented !== ' function' ||
339
+ typeof event . isDefaultPrevented !== " function" ||
339
340
event . isDefaultPrevented ( )
340
341
) {
341
342
return ;
342
343
}
343
344
}
344
345
this . setState ( {
345
346
inputValue : event . target . value ,
346
- lastPreSelectChange : PRESELECT_CHANGE_VIA_INPUT ,
347
+ lastPreSelectChange : PRESELECT_CHANGE_VIA_INPUT
347
348
} ) ;
348
349
const date = parseDate ( event . target . value , this . props ) ;
349
350
if ( date || ! event . target . value ) {
@@ -357,7 +358,7 @@ export default class DatePicker extends React.Component {
357
358
this . setState ( { preventFocus : true } , ( ) => {
358
359
this . preventFocusTimeout = setTimeout (
359
360
( ) => this . setState ( { preventFocus : false } ) ,
360
- 50 ,
361
+ 50
361
362
) ;
362
363
return this . preventFocusTimeout ;
363
364
} ) ;
@@ -396,12 +397,12 @@ export default class DatePicker extends React.Component {
396
397
changedDate = setTime ( newDate ( changedDate ) , {
397
398
hour : getHour ( selected ) ,
398
399
minute : getMinute ( selected ) ,
399
- second : getSecond ( selected ) ,
400
+ second : getSecond ( selected )
400
401
} ) ;
401
402
}
402
403
if ( ! this . props . inline ) {
403
404
this . setState ( {
404
- preSelection : changedDate ,
405
+ preSelection : changedDate
405
406
} ) ;
406
407
}
407
408
}
@@ -417,15 +418,15 @@ export default class DatePicker extends React.Component {
417
418
418
419
setPreSelection = date => {
419
420
const isDateRangePresent =
420
- typeof this . props . minDate !== ' undefined' &&
421
- typeof this . props . maxDate !== ' undefined' ;
421
+ typeof this . props . minDate !== " undefined" &&
422
+ typeof this . props . maxDate !== " undefined" ;
422
423
const isValidDateSelection =
423
424
isDateRangePresent && date
424
425
? isDayInRange ( date , this . props . minDate , this . props . maxDate )
425
426
: true ;
426
427
if ( isValidDateSelection ) {
427
428
this . setState ( {
428
- preSelection : date ,
429
+ preSelection : date
429
430
} ) ;
430
431
}
431
432
} ;
@@ -436,11 +437,11 @@ export default class DatePicker extends React.Component {
436
437
: this . getPreSelection ( ) ;
437
438
let changedDate = setTime ( cloneDate ( selected ) , {
438
439
hour : getHour ( time ) ,
439
- minute : getMinute ( time ) ,
440
+ minute : getMinute ( time )
440
441
} ) ;
441
442
442
443
this . setState ( {
443
- preSelection : changedDate ,
444
+ preSelection : changedDate
444
445
} ) ;
445
446
446
447
this . props . onChange ( changedDate ) ;
@@ -464,13 +465,13 @@ export default class DatePicker extends React.Component {
464
465
! this . props . inline &&
465
466
! this . props . preventOpenOnFocus
466
467
) {
467
- if ( eventKey === ' ArrowDown' || eventKey === ' ArrowUp' ) {
468
+ if ( eventKey === " ArrowDown" || eventKey === " ArrowUp" ) {
468
469
this . onInputClick ( ) ;
469
470
}
470
471
return ;
471
472
}
472
473
const copy = newDate ( this . state . preSelection ) ;
473
- if ( eventKey === ' Enter' ) {
474
+ if ( eventKey === " Enter" ) {
474
475
event . preventDefault ( ) ;
475
476
if (
476
477
this . inputOk ( ) &&
@@ -485,7 +486,7 @@ export default class DatePicker extends React.Component {
485
486
486
487
this . setOpen ( false ) ;
487
488
}
488
- } else if ( eventKey === ' Escape' ) {
489
+ } else if ( eventKey === " Escape" ) {
489
490
event . preventDefault ( ) ;
490
491
491
492
this . input . blur ( ) ;
@@ -496,33 +497,33 @@ export default class DatePicker extends React.Component {
496
497
if ( ! this . inputOk ( ) ) {
497
498
this . props . onInputError ( { code : 1 , msg : INPUT_ERR_1 } ) ;
498
499
}
499
- } else if ( eventKey === ' Tab' ) {
500
+ } else if ( eventKey === " Tab" ) {
500
501
this . setOpen ( false ) ;
501
502
} else if ( ! this . props . disabledKeyboardNavigation ) {
502
503
let newSelection ;
503
504
switch ( eventKey ) {
504
- case ' ArrowLeft' :
505
+ case " ArrowLeft" :
505
506
newSelection = subtractDays ( copy , 1 ) ;
506
507
break ;
507
- case ' ArrowRight' :
508
+ case " ArrowRight" :
508
509
newSelection = addDays ( copy , 1 ) ;
509
510
break ;
510
- case ' ArrowUp' :
511
+ case " ArrowUp" :
511
512
newSelection = subtractWeeks ( copy , 1 ) ;
512
513
break ;
513
- case ' ArrowDown' :
514
+ case " ArrowDown" :
514
515
newSelection = addWeeks ( copy , 1 ) ;
515
516
break ;
516
- case ' PageUp' :
517
+ case " PageUp" :
517
518
newSelection = subtractMonths ( copy , 1 ) ;
518
519
break ;
519
- case ' PageDown' :
520
+ case " PageDown" :
520
521
newSelection = addMonths ( copy , 1 ) ;
521
522
break ;
522
- case ' Home' :
523
+ case " Home" :
523
524
newSelection = subtractYears ( copy , 1 ) ;
524
525
break ;
525
- case ' End' :
526
+ case " End" :
526
527
newSelection = addYears ( copy , 1 ) ;
527
528
break ;
528
529
}
@@ -628,6 +629,7 @@ export default class DatePicker extends React.Component {
628
629
nextMonthButtonLabel = { this . props . nextMonthButtonLabel }
629
630
disabledKeyboardNavigation = { this . props . disabledKeyboardNavigation }
630
631
renderCustomHeader = { this . props . renderCustomHeader }
632
+ popperProps = { this . props . popperProps }
631
633
>
632
634
{ this . props . children }
633
635
</ WrappedCalendar >
@@ -640,11 +642,11 @@ export default class DatePicker extends React.Component {
640
642
} ) ;
641
643
642
644
const customInput = this . props . customInput || < input type = "text" /> ;
643
- const customInputRef = this . props . customInputRef || ' ref' ;
645
+ const customInputRef = this . props . customInputRef || " ref" ;
644
646
const inputValue =
645
- typeof this . props . value === ' string'
647
+ typeof this . props . value === " string"
646
648
? this . props . value
647
- : typeof this . state . inputValue === ' string'
649
+ : typeof this . state . inputValue === " string"
648
650
? this . state . inputValue
649
651
: safeDateFormat ( this . props . selected , this . props ) ;
650
652
@@ -668,7 +670,7 @@ export default class DatePicker extends React.Component {
668
670
title : this . props . title ,
669
671
readOnly : this . props . readOnly ,
670
672
required : this . props . required ,
671
- tabIndex : this . props . tabIndex ,
673
+ tabIndex : this . props . tabIndex
672
674
} ) ;
673
675
} ;
674
676
@@ -725,10 +727,11 @@ export default class DatePicker extends React.Component {
725
727
popperContainer = { this . props . popperContainer }
726
728
popperComponent = { calendar }
727
729
popperPlacement = { this . props . popperPlacement }
730
+ popperProps = { this . props . popperProps }
728
731
/>
729
732
) ;
730
733
}
731
734
}
732
735
733
- const PRESELECT_CHANGE_VIA_INPUT = ' input' ;
734
- const PRESELECT_CHANGE_VIA_NAVIGATE = ' navigate' ;
736
+ const PRESELECT_CHANGE_VIA_INPUT = " input" ;
737
+ const PRESELECT_CHANGE_VIA_NAVIGATE = " navigate" ;
0 commit comments