Skip to content

Commit

Permalink
latest build + updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Bojan Todorovic committed Dec 15, 2017
1 parent ab6f566 commit 3e69426
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 50 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ render: function() {
| **closeOnTab** | `boolean` | `true` | When `true` and the input is focused, pressing the `tab` key will close the datepicker.
| **timeConstraints** | `object` | `null` | Add some constraints to the timepicker. It accepts an `object` with the format `{ hours: { min: 9, max: 15, step: 2 }}`, this example means the hours can't be lower than `9` and higher than `15`, and it will change adding or subtracting `2` hours everytime the buttons are clicked. The constraints can be added to the `hours`, `minutes`, `seconds` and `milliseconds`.
| **disableOnClickOutside** | `boolean` | `false` | When `true`, keep the datepicker open when click event is triggered outside of component. When `false`, close it.
**showTodayButton** | `boolean` | `false` | When true, adds a 'Today' button at the bottom of the date picker.

## i18n
Different language and date formats are supported by react-datetime. React uses [Moment.js](http://momentjs.com/) to format the dates, and the easiest way of changing the language of the calendar is [changing the Moment.js locale](http://momentjs.com/docs/#/i18n/changing-locale/).
Expand Down
85 changes: 40 additions & 45 deletions dist/react-datetime.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
react-datetime v2.11.0
react-datetime v2.11.1
https://github.com/YouCanBookMe/react-datetime
MIT: https://github.com/YouCanBookMe/react-datetime/raw/master/LICENSE
*/
Expand Down Expand Up @@ -385,16 +385,16 @@ return /******/ (function(modules) { // webpackBootstrap
.date( currentDate.date() )
.year( parseInt( target.getAttribute('data-value'), 10 ) );
} else if (target.className.indexOf('rdtTodayButton') !== -1) {
var now = moment(new Date());
date = viewDate.clone()
.month( now.month() )
.date( now.date() )
.year( now.year() );

this.setState({
currentView: 'days'
});
}
var now = moment(new Date());
date = viewDate.clone()
.month( now.month() )
.date( now.date() )
.year( now.year() );

this.setState({
currentView: 'days'
});
}

date.hours( currentDate.hours() )
.minutes( currentDate.minutes() )
Expand Down Expand Up @@ -453,17 +453,32 @@ return /******/ (function(modules) { // webpackBootstrap
return m;
},

goToToday: function (e) {
this.updateSelectedDate(e);
},
goToToday: function (e) {
this.updateSelectedDate(e);
},

renderTodayButton: function (key) {
return React.createElement(
'button',
{key: key, className: 'rdtTodayButton', onClick: this.goToToday, 'data-value': '10'},
'Today'
);
},
alwaysValidDate: function () {
return true;
},

renderTodayButton: function (key) {
var now = moment(new Date());
var date = this.state.viewDate.clone()
.month( now.month() )
.date( now.date() )
.year( now.year() );

var isValidDate = this.props.isValidDate || this.alwaysValidDate;

var isValid = date.isValid && isValidDate(date);
var classes = isValid ? 'rdtTodayButton' : 'rdtTodayButton rdtDisabled';

return this.props.showTodayButton ? React.createElement(
'button',
{key: key, className: classes, onClick: isValid ? this.goToToday : undefined},
'Today'
) : undefined;
},

componentProps: {
fromProps: ['value', 'isValidDate', 'renderDay', 'renderMonth', 'renderYear', 'timeConstraints'],
Expand Down Expand Up @@ -494,8 +509,7 @@ return /******/ (function(modules) { // webpackBootstrap
// TODO: Make a function or clean up this code,
// logic right now is really hard to follow
var className = 'rdt' + (this.props.className ?
( Array.isArray( this.props.className ) ?
' ' + this.props.className.join( ' ' ) : ' ' + this.props.className) : ''),
( Array.isArray( this.props.className ) ? ' ' + this.props.className.join( ' ' ) : ' ' + this.props.className) : ''),
children = [];

if ( this.props.input ) {
Expand Down Expand Up @@ -2819,8 +2833,7 @@ return /******/ (function(modules) { // webpackBootstrap
DaysView = __webpack_require__(19),
MonthsView = __webpack_require__(22),
YearsView = __webpack_require__(23),
TimeView = __webpack_require__(24),
TodayButton = __webpack_require__(25);
TimeView = __webpack_require__(24)
;

var CalendarContainer = createClass({
Expand Down Expand Up @@ -3364,7 +3377,7 @@ return /******/ (function(modules) { // webpackBootstrap
React.createElement('th', { key: 'next', className: 'rdtNext', onClick: this.props.addTime( 1, 'years' )}, React.createElement('span', {}, '›' ))
]))),
React.createElement('table', { key: 'months' }, React.createElement('tbody', { key: 'b' }, this.renderMonths())),
this.props.renderTodayButton('todayMonths')
this.props.renderTodayButton('todayMonths')
]);
},

Expand Down Expand Up @@ -3480,7 +3493,7 @@ return /******/ (function(modules) { // webpackBootstrap
React.createElement('th', { key: 'next', className: 'rdtNext', onClick: this.props.addTime( 10, 'years' )}, React.createElement('span', {}, '›' ))
]))),
React.createElement('table', { key: 'years' }, React.createElement('tbody', {}, this.renderYears( year ))),
this.props.renderTodayButton('todayYears')
this.props.renderTodayButton('todayYears')
]);
},

Expand Down Expand Up @@ -3811,24 +3824,6 @@ return /******/ (function(modules) { // webpackBootstrap
module.exports = DateTimePickerTime;


/***/ }),
/* 25 */
/***/ (function(module, exports, __webpack_require__) {

'use strict';

var React = __webpack_require__(13),
createClass = __webpack_require__(12);

var TodayButton = createClass({
render: function() {
return React.createElement( 'button', {className: 'rdtTodayButton'}, 'Today' );
}
});

module.exports = TodayButton;


/***/ })
/******/ ])
});
Expand Down
6 changes: 3 additions & 3 deletions dist/react-datetime.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react-datetime.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-datetime",
"version": "2.11.0",
"version": "2.11.1",
"description": "A lightweight but complete datetime picker React.js component.",
"homepage": "https://github.com/YouCanBookMe/react-datetime",
"repository": {
Expand Down

0 comments on commit 3e69426

Please sign in to comment.