Skip to content

Commit 12add8e

Browse files
committed
Version 2.14.0
1 parent db7315a commit 12add8e

File tree

5 files changed

+34
-19
lines changed

5 files changed

+34
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Changelog
22
=========
3+
## 2.14.0
4+
* Make `viewDate` dynamic
5+
36
## 2.13.0
47
* Use more appropriate cursor for empty space in time picker and in day texts
58
* Add `viewDate` prop that sets a value when opening the calendar when there is no selected date
@@ -22,8 +25,8 @@ Changelog
2225
* Add renderInput prop which let's the consumer of the component render their own HTML input element
2326

2427
## 2.10.3
25-
* Update react-onclickoutside dependancy
26-
* Remove isValidDate check before rendering as implementation was causing crashes in some ednge cases.
28+
* Update react-onclickoutside dependency
29+
* Remove isValidDate check before rendering as implementation was causing crashes in some edge cases.
2730

2831
## 2.10.2
2932
* Move @types/react back to devDependencies

dist/react-datetime.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
react-datetime v2.12.0
2+
react-datetime v2.14.0
33
https://github.com/YouCanBookMe/react-datetime
44
MIT: 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(/[lLD]/) ) {
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 ) {

dist/react-datetime.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-datetime.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-datetime",
3-
"version": "2.13.0",
4-
"description": "A lightweight but complete datetime picker React.js component.",
3+
"version": "2.14.0",
4+
"description": "A lightweight but complete datetime picker React.js component",
55
"homepage": "https://github.com/YouCanBookMe/react-datetime",
66
"repository": {
77
"type": "git",

0 commit comments

Comments
 (0)