1
1
/*
2
- react-datetime v2.8.11
2
+ react-datetime v2.10.0
3
3
https://github.com/YouCanBookMe/react-datetime
4
4
MIT: https://github.com/YouCanBookMe/react-datetime/raw/master/LICENSE
5
5
*/
@@ -63,11 +63,11 @@ return /******/ (function(modules) { // webpackBootstrap
63
63
64
64
var assign = __webpack_require__ ( 1 ) ,
65
65
PropTypes = __webpack_require__ ( 2 ) ,
66
- createClass = __webpack_require__ ( 11 ) ,
66
+ createClass = __webpack_require__ ( 11 ) ,
67
67
moment = __webpack_require__ ( 16 ) ,
68
68
React = __webpack_require__ ( 12 ) ,
69
69
CalendarContainer = __webpack_require__ ( 17 )
70
- ;
70
+ ;
71
71
72
72
var TYPES = PropTypes ;
73
73
var Datetime = createClass ( {
@@ -129,7 +129,7 @@ return /******/ (function(modules) { // webpackBootstrap
129
129
var formats = this . getFormats ( props ) ,
130
130
date = props . value || props . defaultValue ,
131
131
selectedDate , viewDate , updateOn , inputValue
132
- ;
132
+ ;
133
133
134
134
if ( date && typeof date === 'string' )
135
135
selectedDate = this . localMoment ( date , formats . datetime ) ;
@@ -164,7 +164,7 @@ return /******/ (function(modules) { // webpackBootstrap
164
164
} ,
165
165
166
166
getUpdateOn : function ( formats ) {
167
- if ( formats . date . match ( / [ l L D ] / ) ) {
167
+ if ( formats . date . match ( / [ l L D ] / ) ) {
168
168
return 'days' ;
169
169
} else if ( formats . date . indexOf ( 'M' ) !== - 1 ) {
170
170
return 'months' ;
@@ -181,7 +181,7 @@ return /******/ (function(modules) { // webpackBootstrap
181
181
time : props . timeFormat || ''
182
182
} ,
183
183
locale = this . localMoment ( props . date , null , props ) . localeData ( )
184
- ;
184
+ ;
185
185
186
186
if ( formats . date === true ) {
187
187
formats . date = locale . longDateFormat ( 'L' ) ;
@@ -253,15 +253,21 @@ return /******/ (function(modules) { // webpackBootstrap
253
253
}
254
254
}
255
255
}
256
-
256
+ //we should only show a valid date if we are provided a isValidDate function.
257
+ if ( this . props . isValidDate ) {
258
+ updatedState . viewDate = updatedState . viewDate || this . state . viewDate ;
259
+ while ( ! this . props . isValidDate ( updatedState . viewDate ) ) {
260
+ updatedState . viewDate = updatedState . viewDate . add ( 1 , 'day' ) ;
261
+ }
262
+ }
257
263
this . setState ( updatedState ) ;
258
264
} ,
259
265
260
266
onInputChange : function ( e ) {
261
267
var value = e . target === null ? e : e . target . value ,
262
268
localMoment = this . localMoment ( value , this . state . inputFormat ) ,
263
269
update = { inputValue : value }
264
- ;
270
+ ;
265
271
266
272
if ( localMoment . isValid ( ) && ! this . props . value ) {
267
273
update . selectedDate = localMoment ;
@@ -333,7 +339,7 @@ return /******/ (function(modules) { // webpackBootstrap
333
339
state = this . state ,
334
340
date = ( state . selectedDate || state . viewDate ) . clone ( ) ,
335
341
nextType
336
- ;
342
+ ;
337
343
338
344
// It is needed to set all the time properties
339
345
// to not to reset the time
@@ -358,7 +364,7 @@ return /******/ (function(modules) { // webpackBootstrap
358
364
viewDate = this . state . viewDate ,
359
365
currentDate = this . state . selectedDate || viewDate ,
360
366
date
361
- ;
367
+ ;
362
368
363
369
if ( target . className . indexOf ( 'rdtDay' ) !== - 1 ) {
364
370
if ( target . className . indexOf ( 'rdtNew' ) !== - 1 )
@@ -447,7 +453,7 @@ return /******/ (function(modules) { // webpackBootstrap
447
453
var me = this ,
448
454
formats = this . getFormats ( this . props ) ,
449
455
props = { dateFormat : formats . date , timeFormat : formats . time }
450
- ;
456
+ ;
451
457
452
458
this . componentProps . fromProps . forEach ( function ( name ) {
453
459
props [ name ] = me . props [ name ] ;
@@ -463,11 +469,12 @@ return /******/ (function(modules) { // webpackBootstrap
463
469
} ,
464
470
465
471
render : function ( ) {
472
+ // TODO: Make a function or clean up this code,
473
+ // logic right now is really hard to follow
466
474
var className = 'rdt' + ( this . props . className ?
467
475
( Array . isArray ( this . props . className ) ?
468
476
' ' + this . props . className . join ( ' ' ) : ' ' + this . props . className ) : '' ) ,
469
- children = [ ]
470
- ;
477
+ children = [ ] ;
471
478
472
479
if ( this . props . input ) {
473
480
children = [ React . createElement ( 'input' , assign ( {
@@ -2674,12 +2681,12 @@ return /******/ (function(modules) { // webpackBootstrap
2674
2681
'use strict' ;
2675
2682
2676
2683
var React = __webpack_require__ ( 12 ) ,
2677
- createClass = __webpack_require__ ( 11 ) ,
2678
- DaysView = __webpack_require__ ( 18 ) ,
2679
- MonthsView = __webpack_require__ ( 21 ) ,
2680
- YearsView = __webpack_require__ ( 22 ) ,
2681
- TimeView = __webpack_require__ ( 23 )
2682
- ;
2684
+ createClass = __webpack_require__ ( 11 ) ,
2685
+ DaysView = __webpack_require__ ( 18 ) ,
2686
+ MonthsView = __webpack_require__ ( 21 ) ,
2687
+ YearsView = __webpack_require__ ( 22 ) ,
2688
+ TimeView = __webpack_require__ ( 23 )
2689
+ ;
2683
2690
2684
2691
var CalendarContainer = createClass ( {
2685
2692
viewComponents : {
@@ -2689,9 +2696,9 @@ return /******/ (function(modules) { // webpackBootstrap
2689
2696
time : TimeView
2690
2697
} ,
2691
2698
2692
- render : function ( ) {
2693
- return React . createElement ( this . viewComponents [ this . props . view ] , this . props . viewProps ) ;
2694
- }
2699
+ render : function ( ) {
2700
+ return React . createElement ( this . viewComponents [ this . props . view ] , this . props . viewProps ) ;
2701
+ }
2695
2702
} ) ;
2696
2703
2697
2704
module . exports = CalendarContainer ;
@@ -2704,18 +2711,18 @@ return /******/ (function(modules) { // webpackBootstrap
2704
2711
'use strict' ;
2705
2712
2706
2713
var React = __webpack_require__ ( 12 ) ,
2707
- createClass = __webpack_require__ ( 11 ) ,
2714
+ createClass = __webpack_require__ ( 11 ) ,
2708
2715
moment = __webpack_require__ ( 16 ) ,
2709
2716
onClickOutside = __webpack_require__ ( 19 )
2710
- ;
2717
+ ;
2711
2718
2712
2719
var DateTimePickerDays = onClickOutside ( createClass ( {
2713
2720
render : function ( ) {
2714
2721
var footer = this . renderFooter ( ) ,
2715
2722
date = this . props . viewDate ,
2716
2723
locale = date . localeData ( ) ,
2717
2724
tableChildren
2718
- ;
2725
+ ;
2719
2726
2720
2727
tableChildren = [
2721
2728
React . createElement ( 'thead' , { key : 'th' } , [
@@ -2747,7 +2754,7 @@ return /******/ (function(modules) { // webpackBootstrap
2747
2754
first = locale . firstDayOfWeek ( ) ,
2748
2755
dow = [ ] ,
2749
2756
i = 0
2750
- ;
2757
+ ;
2751
2758
2752
2759
days . forEach ( function ( day ) {
2753
2760
dow [ ( 7 + ( i ++ ) - first ) % 7 ] = day ;
@@ -2767,7 +2774,7 @@ return /******/ (function(modules) { // webpackBootstrap
2767
2774
renderer = this . props . renderDay || this . renderDay ,
2768
2775
isValid = this . props . isValidDate || this . alwaysValidDate ,
2769
2776
classes , isDisabled , dayProps , currentDate
2770
- ;
2777
+ ;
2771
2778
2772
2779
// Go to the last week of the previous month
2773
2780
prevMonth . date ( prevMonth . daysInMonth ( ) ) . startOf ( 'week' ) ;
@@ -2839,9 +2846,9 @@ return /******/ (function(modules) { // webpackBootstrap
2839
2846
return 1 ;
2840
2847
} ,
2841
2848
2842
- handleClickOutside : function ( ) {
2843
- this . props . handleClickOutside ( ) ;
2844
- }
2849
+ handleClickOutside : function ( ) {
2850
+ this . props . handleClickOutside ( ) ;
2851
+ }
2845
2852
} ) ) ;
2846
2853
2847
2854
module . exports = DateTimePickerDays ;
@@ -3175,9 +3182,9 @@ return /******/ (function(modules) { // webpackBootstrap
3175
3182
'use strict' ;
3176
3183
3177
3184
var React = __webpack_require__ ( 12 ) ,
3178
- createClass = __webpack_require__ ( 11 ) ,
3185
+ createClass = __webpack_require__ ( 11 ) ,
3179
3186
onClickOutside = __webpack_require__ ( 19 )
3180
- ;
3187
+ ;
3181
3188
3182
3189
var DateTimePickerMonths = onClickOutside ( createClass ( {
3183
3190
render : function ( ) {
@@ -3203,7 +3210,7 @@ return /******/ (function(modules) { // webpackBootstrap
3203
3210
classes , props , currentMonth , isDisabled , noOfDaysInMonth , daysInMonth , validDay ,
3204
3211
// Date is irrelevant because we're only interested in month
3205
3212
irrelevantDate = 1
3206
- ;
3213
+ ;
3207
3214
3208
3215
while ( i < 12 ) {
3209
3216
classes = 'rdtMonth' ;
@@ -3269,9 +3276,9 @@ return /******/ (function(modules) { // webpackBootstrap
3269
3276
return 1 ;
3270
3277
} ,
3271
3278
3272
- handleClickOutside : function ( ) {
3273
- this . props . handleClickOutside ( ) ;
3274
- }
3279
+ handleClickOutside : function ( ) {
3280
+ this . props . handleClickOutside ( ) ;
3281
+ }
3275
3282
} ) ) ;
3276
3283
3277
3284
function capitalize ( str ) {
@@ -3288,9 +3295,9 @@ return /******/ (function(modules) { // webpackBootstrap
3288
3295
'use strict' ;
3289
3296
3290
3297
var React = __webpack_require__ ( 12 ) ,
3291
- createClass = __webpack_require__ ( 11 ) ,
3298
+ createClass = __webpack_require__ ( 11 ) ,
3292
3299
onClickOutside = __webpack_require__ ( 19 )
3293
- ;
3300
+ ;
3294
3301
3295
3302
var DateTimePickerYears = onClickOutside ( createClass ( {
3296
3303
render : function ( ) {
@@ -3301,7 +3308,7 @@ return /******/ (function(modules) { // webpackBootstrap
3301
3308
React . createElement ( 'th' , { key : 'prev' , className : 'rdtPrev' , onClick : this . props . subtractTime ( 10 , 'years' ) } , React . createElement ( 'span' , { } , '‹' ) ) ,
3302
3309
React . createElement ( 'th' , { key : 'year' , className : 'rdtSwitch' , onClick : this . props . showView ( 'years' ) , colSpan : 2 } , year + '-' + ( year + 9 ) ) ,
3303
3310
React . createElement ( 'th' , { key : 'next' , className : 'rdtNext' , onClick : this . props . addTime ( 10 , 'years' ) } , React . createElement ( 'span' , { } , '›' ) )
3304
- ] ) ) ) ,
3311
+ ] ) ) ) ,
3305
3312
React . createElement ( 'table' , { key : 'years' } , React . createElement ( 'tbody' , { } , this . renderYears ( year ) ) )
3306
3313
] ) ;
3307
3314
} ,
@@ -3318,7 +3325,7 @@ return /******/ (function(modules) { // webpackBootstrap
3318
3325
// we're only interested in the year
3319
3326
irrelevantMonth = 0 ,
3320
3327
irrelevantDate = 1
3321
- ;
3328
+ ;
3322
3329
3323
3330
year -- ;
3324
3331
while ( i < 11 ) {
@@ -3384,9 +3391,9 @@ return /******/ (function(modules) { // webpackBootstrap
3384
3391
return 1 ;
3385
3392
} ,
3386
3393
3387
- handleClickOutside : function ( ) {
3388
- this . props . handleClickOutside ( ) ;
3389
- }
3394
+ handleClickOutside : function ( ) {
3395
+ this . props . handleClickOutside ( ) ;
3396
+ }
3390
3397
} ) ) ;
3391
3398
3392
3399
module . exports = DateTimePickerYears ;
@@ -3399,10 +3406,10 @@ return /******/ (function(modules) { // webpackBootstrap
3399
3406
'use strict' ;
3400
3407
3401
3408
var React = __webpack_require__ ( 12 ) ,
3402
- createClass = __webpack_require__ ( 11 ) ,
3409
+ createClass = __webpack_require__ ( 11 ) ,
3403
3410
assign = __webpack_require__ ( 1 ) ,
3404
- onClickOutside = __webpack_require__ ( 19 )
3405
- ;
3411
+ onClickOutside = __webpack_require__ ( 19 )
3412
+ ;
3406
3413
3407
3414
var DateTimePickerTime = onClickOutside ( createClass ( {
3408
3415
getInitialState : function ( ) {
@@ -3413,7 +3420,7 @@ return /******/ (function(modules) { // webpackBootstrap
3413
3420
var date = props . selectedDate || props . viewDate ,
3414
3421
format = props . timeFormat ,
3415
3422
counters = [ ]
3416
- ;
3423
+ ;
3417
3424
3418
3425
if ( format . toLowerCase ( ) . indexOf ( 'h' ) !== - 1 ) {
3419
3426
counters . push ( 'hours' ) ;
@@ -3618,9 +3625,9 @@ return /******/ (function(modules) { // webpackBootstrap
3618
3625
return str ;
3619
3626
} ,
3620
3627
3621
- handleClickOutside : function ( ) {
3622
- this . props . handleClickOutside ( ) ;
3623
- }
3628
+ handleClickOutside : function ( ) {
3629
+ this . props . handleClickOutside ( ) ;
3630
+ }
3624
3631
} ) ) ;
3625
3632
3626
3633
module . exports = DateTimePickerTime ;
0 commit comments