1
1
/*
2
- react-datetime v2.12 .0
2
+ react-datetime v2.14 .0
3
3
https://github.com/YouCanBookMe/react-datetime
4
4
MIT: https://github.com/YouCanBookMe/react-datetime/raw/master/LICENSE
5
5
*/
@@ -69,6 +69,13 @@ return /******/ (function(modules) { // webpackBootstrap
69
69
CalendarContainer = __webpack_require__ ( 18 )
70
70
;
71
71
72
+ var viewModes = Object . freeze ( {
73
+ YEARS : 'years' ,
74
+ MONTHS : 'months' ,
75
+ DAYS : 'days' ,
76
+ TIME : 'time' ,
77
+ } ) ;
78
+
72
79
var TYPES = PropTypes ;
73
80
var Datetime = createClass ( {
74
81
propTypes : {
@@ -86,7 +93,7 @@ return /******/ (function(modules) { // webpackBootstrap
86
93
// timeFormat: TYPES.string | TYPES.bool,
87
94
inputProps : TYPES . object ,
88
95
timeConstraints : TYPES . object ,
89
- viewMode : TYPES . oneOf ( [ 'years' , 'months' , 'days' , 'time' ] ) ,
96
+ viewMode : TYPES . oneOf ( [ viewModes . YEARS , viewModes . MONTHS , viewModes . DAYS , viewModes . TIME ] ) ,
90
97
isValidDate : TYPES . func ,
91
98
open : TYPES . bool ,
92
99
strictParsing : TYPES . bool ,
@@ -100,7 +107,8 @@ return /******/ (function(modules) { // webpackBootstrap
100
107
if ( state . open === undefined )
101
108
state . open = ! this . props . input ;
102
109
103
- state . currentView = this . props . dateFormat ? ( this . props . viewMode || state . updateOn || 'days' ) : 'time' ;
110
+ state . currentView = this . props . dateFormat ?
111
+ ( this . props . viewMode || state . updateOn || viewModes . DAYS ) : viewModes . TIME ;
104
112
105
113
return state ;
106
114
} ,
@@ -154,14 +162,14 @@ return /******/ (function(modules) { // webpackBootstrap
154
162
155
163
getUpdateOn : function ( formats ) {
156
164
if ( formats . date . match ( / [ l L D ] / ) ) {
157
- return 'days' ;
165
+ return viewModes . DAYS ;
158
166
} else if ( formats . date . indexOf ( 'M' ) !== - 1 ) {
159
- return 'months' ;
167
+ return viewModes . MONTHS ;
160
168
} else if ( formats . date . indexOf ( 'Y' ) !== - 1 ) {
161
- return 'years' ;
169
+ return viewModes . YEARS ;
162
170
}
163
171
164
- return 'days' ;
172
+ return viewModes . DAYS ;
165
173
} ,
166
174
167
175
getFormats : function ( props ) {
@@ -175,7 +183,7 @@ return /******/ (function(modules) { // webpackBootstrap
175
183
if ( formats . date === true ) {
176
184
formats . date = locale . longDateFormat ( 'L' ) ;
177
185
}
178
- else if ( this . getUpdateOn ( formats ) !== 'days' ) {
186
+ else if ( this . getUpdateOn ( formats ) !== viewModes . DAYS ) {
179
187
formats . time = '' ;
180
188
}
181
189
@@ -204,7 +212,7 @@ return /******/ (function(modules) { // webpackBootstrap
204
212
if ( updatedState . open === undefined ) {
205
213
if ( typeof nextProps . open !== 'undefined' ) {
206
214
updatedState . open = nextProps . open ;
207
- } else if ( this . props . closeOnSelect && this . state . currentView !== 'time' ) {
215
+ } else if ( this . props . closeOnSelect && this . state . currentView !== viewModes . TIME ) {
208
216
updatedState . open = false ;
209
217
} else {
210
218
updatedState . open = this . state . open ;
@@ -244,6 +252,10 @@ return /******/ (function(modules) { // webpackBootstrap
244
252
}
245
253
}
246
254
}
255
+
256
+ if ( nextProps . viewDate !== this . props . viewDate ) {
257
+ updatedState . viewDate = moment ( nextProps . viewDate ) ;
258
+ }
247
259
//we should only show a valid date if we are provided a isValidDate function. Removed in 2.10.3
248
260
/*if (this.props.isValidDate) {
249
261
updatedState.viewDate = updatedState.viewDate || this.state.viewDate;
@@ -289,8 +301,8 @@ return /******/ (function(modules) { // webpackBootstrap
289
301
setDate : function ( type ) {
290
302
var me = this ,
291
303
nextViews = {
292
- month : 'days' ,
293
- year : 'months'
304
+ month : viewModes . DAYS ,
305
+ year : viewModes . MONTHS ,
294
306
}
295
307
;
296
308
return function ( e ) {
0 commit comments