11/*
2- react-datetime v2.12 .0
2+ react-datetime v2.14 .0
33https://github.com/YouCanBookMe/react-datetime
44MIT: https://github.com/YouCanBookMe/react-datetime/raw/master/LICENSE
55*/
@@ -69,6 +69,13 @@ return /******/ (function(modules) { // webpackBootstrap
6969 CalendarContainer = __webpack_require__ ( 18 )
7070 ;
7171
72+ var viewModes = Object . freeze ( {
73+ YEARS : 'years' ,
74+ MONTHS : 'months' ,
75+ DAYS : 'days' ,
76+ TIME : 'time' ,
77+ } ) ;
78+
7279 var TYPES = PropTypes ;
7380 var Datetime = createClass ( {
7481 propTypes : {
@@ -86,7 +93,7 @@ return /******/ (function(modules) { // webpackBootstrap
8693 // timeFormat: TYPES.string | TYPES.bool,
8794 inputProps : TYPES . object ,
8895 timeConstraints : TYPES . object ,
89- viewMode : TYPES . oneOf ( [ 'years' , 'months' , 'days' , 'time' ] ) ,
96+ viewMode : TYPES . oneOf ( [ viewModes . YEARS , viewModes . MONTHS , viewModes . DAYS , viewModes . TIME ] ) ,
9097 isValidDate : TYPES . func ,
9198 open : TYPES . bool ,
9299 strictParsing : TYPES . bool ,
@@ -100,7 +107,8 @@ return /******/ (function(modules) { // webpackBootstrap
100107 if ( state . open === undefined )
101108 state . open = ! this . props . input ;
102109
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 ;
104112
105113 return state ;
106114 } ,
@@ -154,14 +162,14 @@ return /******/ (function(modules) { // webpackBootstrap
154162
155163 getUpdateOn : function ( formats ) {
156164 if ( formats . date . match ( / [ l L D ] / ) ) {
157- return 'days' ;
165+ return viewModes . DAYS ;
158166 } else if ( formats . date . indexOf ( 'M' ) !== - 1 ) {
159- return 'months' ;
167+ return viewModes . MONTHS ;
160168 } else if ( formats . date . indexOf ( 'Y' ) !== - 1 ) {
161- return 'years' ;
169+ return viewModes . YEARS ;
162170 }
163171
164- return 'days' ;
172+ return viewModes . DAYS ;
165173 } ,
166174
167175 getFormats : function ( props ) {
@@ -175,7 +183,7 @@ return /******/ (function(modules) { // webpackBootstrap
175183 if ( formats . date === true ) {
176184 formats . date = locale . longDateFormat ( 'L' ) ;
177185 }
178- else if ( this . getUpdateOn ( formats ) !== 'days' ) {
186+ else if ( this . getUpdateOn ( formats ) !== viewModes . DAYS ) {
179187 formats . time = '' ;
180188 }
181189
@@ -204,7 +212,7 @@ return /******/ (function(modules) { // webpackBootstrap
204212 if ( updatedState . open === undefined ) {
205213 if ( typeof nextProps . open !== 'undefined' ) {
206214 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 ) {
208216 updatedState . open = false ;
209217 } else {
210218 updatedState . open = this . state . open ;
@@ -244,6 +252,10 @@ return /******/ (function(modules) { // webpackBootstrap
244252 }
245253 }
246254 }
255+
256+ if ( nextProps . viewDate !== this . props . viewDate ) {
257+ updatedState . viewDate = moment ( nextProps . viewDate ) ;
258+ }
247259 //we should only show a valid date if we are provided a isValidDate function. Removed in 2.10.3
248260 /*if (this.props.isValidDate) {
249261 updatedState.viewDate = updatedState.viewDate || this.state.viewDate;
@@ -289,8 +301,8 @@ return /******/ (function(modules) { // webpackBootstrap
289301 setDate : function ( type ) {
290302 var me = this ,
291303 nextViews = {
292- month : 'days' ,
293- year : 'months'
304+ month : viewModes . DAYS ,
305+ year : viewModes . MONTHS ,
294306 }
295307 ;
296308 return function ( e ) {
0 commit comments