react-datetime
Advanced tools
Comparing version 2.6.2 to 2.7.0
Changelog | ||
========= | ||
## 2.7.0 | ||
* `isValidDate` now supports months and years. | ||
* `utc` prop was added, by setting it to `true` input time values will be interpreted as UTC (Zulu time). | ||
* Bug fix: The input value now updates when `dateFormat` changes. | ||
* Removed the source-map file because the commit it was introduced in was causing the minified file to be bigger than the non-minified. | ||
## 2.6.2 | ||
@@ -4,0 +10,0 @@ * Update file references in `package.json` |
@@ -30,2 +30,3 @@ 'use strict'; | ||
locale: TYPES.string, | ||
utc: TYPES.bool, | ||
input: TYPES.bool, | ||
@@ -59,3 +60,4 @@ // dateFormat: TYPES.string | TYPES.bool, | ||
closeOnSelect: false, | ||
closeOnTab: true | ||
closeOnTab: true, | ||
utc: false | ||
}; | ||
@@ -159,8 +161,6 @@ }, | ||
if ( nextProps.value !== this.props.value ){ | ||
update = this.getStateFromProps( nextProps ); | ||
if ( nextProps.value !== this.props.value || | ||
formats.datetime !== this.getFormats( this.props ).datetime ){ | ||
update = this.getStateFromProps( nextProps ); | ||
} | ||
if ( formats.datetime !== this.getFormats( this.props ).datetime ) { | ||
update.inputFormat = formats.datetime; | ||
} | ||
@@ -342,3 +342,4 @@ if ( update.open === undefined ){ | ||
localMoment: function( date, format ){ | ||
var m = moment( date, format, this.props.strictParsing ); | ||
var momentFn = this.props.utc ? moment.utc : moment; | ||
var m = momentFn( date, format, this.props.strictParsing ); | ||
if ( this.props.locale ) | ||
@@ -345,0 +346,0 @@ m.locale( this.props.locale ); |
{ | ||
"name": "react-datetime", | ||
"version": "2.6.2", | ||
"version": "2.7.0", | ||
"description": "A lightweight but complete datetime picker React.js component.", | ||
@@ -48,3 +48,2 @@ "homepage": "https://github.com/arqex/react-datetime", | ||
"gulp-webpack": "^1.5.0", | ||
"gulp-sourcemaps": "^1.6.0", | ||
"jsdom": "^7.0.2", | ||
@@ -51,0 +50,0 @@ "mocha": "^2.2.5", |
@@ -49,2 +49,6 @@ // Type definitions for react-datetime | ||
/* | ||
Whether to interpret input times as UTC or the user's local timezone. | ||
*/ | ||
utc?: boolean; | ||
/* | ||
Callback trigger when the date changes. The callback receives the selected `moment` object as | ||
@@ -117,3 +121,3 @@ only parameter, if the date in the input is valid. If the date in the input is not valid, the | ||
*/ | ||
timeConstraints?: Object; | ||
timeConstraints?: Object; | ||
/* | ||
@@ -120,0 +124,0 @@ When true, keep the picker open when click event is triggered outside of component. When false, |
@@ -45,2 +45,3 @@ # react-datetime | ||
| **locale** | `string` | `null` | Manually set the locale for the react-datetime instance. Moment.js locale needs to be loaded to be used, see [i18n docs](#i18n). | ||
| **utc** | `boolean` | `false` | When true, input time values will be interpreted as UTC (Zulu time) by Moment.js. Otherwise they will default to the user's local timezone. | ||
| **onChange** | `function` | empty function | Callback trigger when the date changes. The callback receives the selected `moment` object as only parameter, if the date in the input is valid. If the date in the input is not valid, the callback receives the value of the input (a string). | | ||
@@ -47,0 +48,0 @@ | **onFocus** | `function` | empty function | Callback trigger for when the user opens the datepicker. | |
@@ -26,7 +26,18 @@ 'use strict'; | ||
renderer = this.props.renderMonth || this.renderMonth, | ||
isValid = this.props.isValidDate || this.isValidDate, | ||
classes, props | ||
; | ||
var currentMonth, disabled, | ||
// Date is irrelevant because we're really only interested in month | ||
irrelevantDate = 1; | ||
while (i < 12) { | ||
classes = 'rdtMonth'; | ||
currentMonth = | ||
this.props.viewDate.clone().set({ year: year, month: i, date: irrelevantDate }); | ||
disabled = !isValid(currentMonth); | ||
if ( disabled ) | ||
classes += ' rdtDisabled'; | ||
if ( date && i === month && year === date.year() ) | ||
@@ -38,6 +49,9 @@ classes += ' rdtActive'; | ||
'data-value': i, | ||
className: classes, | ||
onClick: this.props.updateOn === 'months'? this.updateSelectedMonth : this.props.setDate('month') | ||
className: classes | ||
}; | ||
if ( !disabled ) | ||
props.onClick = (this.props.updateOn === 'months' ? | ||
this.updateSelectedMonth : this.props.setDate('month')); | ||
months.push( renderer( props, i, year, date && date.clone() )); | ||
@@ -66,2 +80,6 @@ | ||
); | ||
}, | ||
isValidDate: function(){ | ||
return 1; | ||
} | ||
@@ -68,0 +86,0 @@ }); |
@@ -26,2 +26,3 @@ 'use strict'; | ||
selectedDate = this.props.selectedDate, | ||
isValid = this.props.isValidDate || this.isValidDate, | ||
classes, props | ||
@@ -31,6 +32,18 @@ ; | ||
year--; | ||
var currentYear, disabled, | ||
// Month and date are irrelevant here because | ||
// we're only really interested in the year | ||
irrelevantMonth = 1, | ||
irrelevantDate = 1; | ||
while (i < 11) { | ||
classes = 'rdtYear'; | ||
currentYear = this.props.viewDate.clone().set( | ||
{ year: year, month: irrelevantMonth, date: irrelevantDate }); | ||
if ( i === -1 | i === 10 ) | ||
classes += ' rdtOld'; | ||
disabled = !isValid(currentYear); | ||
if ( disabled ) | ||
classes += ' rdtDisabled'; | ||
if ( selectedDate && selectedDate.year() === year ) | ||
@@ -42,6 +55,8 @@ classes += ' rdtActive'; | ||
'data-value': year, | ||
className: classes, | ||
onClick: this.props.updateOn === 'years' ? this.updateSelectedYear : this.props.setDate('year') | ||
className: classes | ||
}; | ||
if ( !disabled ) | ||
props.onClick = this.props.updateOn === 'years' ? this.updateSelectedYear : this.props.setDate('year'); | ||
years.push( renderer( props, year, selectedDate && selectedDate.clone() )); | ||
@@ -67,2 +82,6 @@ | ||
return DOM.td( props, year ); | ||
}, | ||
isValidDate: function(){ | ||
return 1; | ||
} | ||
@@ -69,0 +88,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15
139
148275
1409
6
11