Skip to content

Commit c1a952d

Browse files
committed
Version 2.11.0
1 parent c30ce16 commit c1a952d

File tree

5 files changed

+43
-23
lines changed

5 files changed

+43
-23
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
Changelog
22
=========
3+
## 2.11.0
4+
* onFocus now receives the browser event
5+
* Do not open browser menu on right click of arrows in time view
6+
* Open calendar when onClick is triggered, before it would just react to onFocus
7+
* Update TypeScript definitions for value and defaultValue to comply with code
8+
* Fix bug where AM/PM would not sync between component value and input field value
9+
* Add renderInput prop which let's the consumer of the component render their own HTML input element
10+
311
## 2.10.3
412
* Update react-onclickoutside dependancy
513
* Remove isValidDate check before rendering as implementation was causing crashes in some ednge cases.

dist/react-datetime.js

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
react-datetime v2.10.3
2+
react-datetime v2.11.0
33
https://github.com/YouCanBookMe/react-datetime
44
MIT: https://github.com/YouCanBookMe/react-datetime/raw/master/LICENSE
55
*/
@@ -412,10 +412,10 @@ return /******/ (function(modules) { // webpackBootstrap
412412
this.props.onChange( date );
413413
},
414414

415-
openCalendar: function() {
416-
if (!this.state.open) {
415+
openCalendar: function( e ) {
416+
if ( !this.state.open ) {
417417
this.setState({ open: true }, function() {
418-
this.props.onFocus();
418+
this.props.onFocus( e );
419419
});
420420
}
421421
},
@@ -477,26 +477,31 @@ return /******/ (function(modules) { // webpackBootstrap
477477
children = [];
478478

479479
if ( this.props.input ) {
480-
children = [ React.createElement('input', assign({
481-
key: 'i',
480+
var finalInputProps = assign({
482481
type: 'text',
483482
className: 'form-control',
483+
onClick: this.openCalendar,
484484
onFocus: this.openCalendar,
485485
onChange: this.onInputChange,
486486
onKeyDown: this.onInputKey,
487-
value: this.state.inputValue
488-
}, this.props.inputProps ))];
487+
value: this.state.inputValue,
488+
}, this.props.inputProps);
489+
if ( this.props.renderInput ) {
490+
children = [ React.createElement('div', { key: 'i' }, this.props.renderInput( finalInputProps, this.openCalendar )) ];
491+
} else {
492+
children = [ React.createElement('input', assign({ key: 'i' }, finalInputProps ))];
493+
}
489494
} else {
490495
className += ' rdtStatic';
491496
}
492497

493498
if ( this.state.open )
494499
className += ' rdtOpen';
495500

496-
return React.createElement('div', {className: className}, children.concat(
497-
React.createElement('div',
501+
return React.createElement( 'div', { className: className }, children.concat(
502+
React.createElement( 'div',
498503
{ key: 'dt', className: 'rdtPicker' },
499-
React.createElement( CalendarContainer, {view: this.state.currentView, viewProps: this.getComponentProps(), onClickOutside: this.handleClickOutside })
504+
React.createElement( CalendarContainer, { view: this.state.currentView, viewProps: this.getComponentProps(), onClickOutside: this.handleClickOutside })
500505
)
501506
));
502507
}
@@ -3455,17 +3460,19 @@ return /******/ (function(modules) { // webpackBootstrap
34553460
}
34563461
}
34573462

3463+
var hours = date.format( 'H' );
3464+
34583465
var daypart = false;
34593466
if ( this.state !== null && this.props.timeFormat.toLowerCase().indexOf( ' a' ) !== -1 ) {
34603467
if ( this.props.timeFormat.indexOf( ' A' ) !== -1 ) {
3461-
daypart = ( this.state.hours >= 12 ) ? 'PM' : 'AM';
3468+
daypart = ( hours >= 12 ) ? 'PM' : 'AM';
34623469
} else {
3463-
daypart = ( this.state.hours >= 12 ) ? 'pm' : 'am';
3470+
daypart = ( hours >= 12 ) ? 'pm' : 'am';
34643471
}
34653472
}
34663473

34673474
return {
3468-
hours: date.format( 'H' ),
3475+
hours: hours,
34693476
minutes: date.format( 'mm' ),
34703477
seconds: date.format( 'ss' ),
34713478
milliseconds: date.format( 'SSS' ),
@@ -3485,19 +3492,19 @@ return /******/ (function(modules) { // webpackBootstrap
34853492
}
34863493
}
34873494
return React.createElement('div', { key: type, className: 'rdtCounter' }, [
3488-
React.createElement('span', { key: 'up', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'increase', type ) }, '▲' ),
3495+
React.createElement('span', { key: 'up', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'increase', type ), onContextMenu: this.disableContextMenu }, '▲' ),
34893496
React.createElement('div', { key: 'c', className: 'rdtCount' }, value ),
3490-
React.createElement('span', { key: 'do', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'decrease', type ) }, '▼' )
3497+
React.createElement('span', { key: 'do', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'decrease', type ), onContextMenu: this.disableContextMenu }, '▼' )
34913498
]);
34923499
}
34933500
return '';
34943501
},
34953502

34963503
renderDayPart: function() {
34973504
return React.createElement('div', { key: 'dayPart', className: 'rdtCounter' }, [
3498-
React.createElement('span', { key: 'up', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'toggleDayPart', 'hours') }, '▲' ),
3505+
React.createElement('span', { key: 'up', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'toggleDayPart', 'hours'), onContextMenu: this.disableContextMenu }, '▲' ),
34993506
React.createElement('div', { key: this.state.daypart, className: 'rdtCount' }, this.state.daypart ),
3500-
React.createElement('span', { key: 'do', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'toggleDayPart', 'hours') }, '▼' )
3507+
React.createElement('span', { key: 'do', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'toggleDayPart', 'hours'), onContextMenu: this.disableContextMenu }, '▼' )
35013508
]);
35023509
},
35033510

@@ -3613,6 +3620,11 @@ return /******/ (function(modules) { // webpackBootstrap
36133620
};
36143621
},
36153622

3623+
disableContextMenu: function( event ) {
3624+
event.preventDefault();
3625+
return false;
3626+
},
3627+
36163628
padValues: {
36173629
hours: 1,
36183630
minutes: 2,

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-datetime",
3-
"version": "2.10.3",
3+
"version": "2.11.0",
44
"description": "A lightweight but complete datetime picker React.js component.",
55
"homepage": "https://github.com/YouCanBookMe/react-datetime",
66
"repository": {

0 commit comments

Comments
 (0)