@@ -12,25 +12,7 @@ var _reactDom = require('react-dom');
12
12
13
13
var _reactDom2 = _interopRequireDefault ( _reactDom ) ;
14
14
15
- var _FormControl = require ( 'react-bootstrap/lib/FormControl' ) ;
16
-
17
- var _FormControl2 = _interopRequireDefault ( _FormControl ) ;
18
-
19
- var _InputGroup = require ( 'react-bootstrap/lib/InputGroup' ) ;
20
-
21
- var _InputGroup2 = _interopRequireDefault ( _InputGroup ) ;
22
-
23
- var _Popover = require ( 'react-bootstrap/lib/Popover' ) ;
24
-
25
- var _Popover2 = _interopRequireDefault ( _Popover ) ;
26
-
27
- var _Button = require ( 'react-bootstrap/lib/Button' ) ;
28
-
29
- var _Button2 = _interopRequireDefault ( _Button ) ;
30
-
31
- var _Overlay = require ( 'react-bootstrap/lib/Overlay' ) ;
32
-
33
- var _Overlay2 = _interopRequireDefault ( _Overlay ) ;
15
+ var _reactBootstrap = require ( 'react-bootstrap' ) ;
34
16
35
17
function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
36
18
@@ -87,7 +69,8 @@ var Calendar = _react2.default.createClass({
87
69
displayDate : _react2 . default . PropTypes . object . isRequired ,
88
70
onChange : _react2 . default . PropTypes . func . isRequired ,
89
71
dayLabels : _react2 . default . PropTypes . array . isRequired ,
90
- cellPadding : _react2 . default . PropTypes . string . isRequired
72
+ cellPadding : _react2 . default . PropTypes . string . isRequired ,
73
+ weekStartsOnMonday : _react2 . default . PropTypes . bool
91
74
} ,
92
75
handleClick : function handleClick ( day ) {
93
76
var newSelectedDate = new Date ( this . props . displayDate ) ;
@@ -111,7 +94,7 @@ var Calendar = _react2.default.createClass({
111
94
var year = this . props . displayDate . getFullYear ( ) ;
112
95
var month = this . props . displayDate . getMonth ( ) ;
113
96
var firstDay = new Date ( year , month , 1 ) ;
114
- var startingDay = firstDay . getDay ( ) ;
97
+ var startingDay = this . props . weekStartsOnMonday ? firstDay . getDay ( ) - 1 : firstDay . getDay ( ) ;
115
98
var monthLength = daysInMonth [ month ] ;
116
99
if ( month == 1 ) {
117
100
if ( year % 4 == 0 && year % 100 != 0 || year % 400 == 0 ) {
@@ -186,6 +169,7 @@ exports.default = _react2.default.createClass({
186
169
monthLabels : _react2 . default . PropTypes . array ,
187
170
onChange : _react2 . default . PropTypes . func ,
188
171
onClear : _react2 . default . PropTypes . func ,
172
+ weekStartsOnMonday : _react2 . default . PropTypes . bool ,
189
173
clearButtonElement : _react2 . default . PropTypes . oneOfType ( [ _react2 . default . PropTypes . string , _react2 . default . PropTypes . object ] ) ,
190
174
previousButtonElement : _react2 . default . PropTypes . oneOfType ( [ _react2 . default . PropTypes . string , _react2 . default . PropTypes . object ] ) ,
191
175
nextButtonElement : _react2 . default . PropTypes . oneOfType ( [ _react2 . default . PropTypes . string , _react2 . default . PropTypes . object ] ) ,
@@ -208,6 +192,11 @@ exports.default = _react2.default.createClass({
208
192
} ,
209
193
getInitialState : function getInitialState ( ) {
210
194
var state = this . makeDateValues ( this . props . value ) ;
195
+ if ( this . props . weekStartsOnMonday ) {
196
+ state . dayLabels = this . props . dayLabels . slice ( 1 ) . concat ( this . props . dayLabels . slice ( 0 , 1 ) ) ;
197
+ } else {
198
+ state . dayLabels = this . props . dayLabels ;
199
+ }
211
200
state . focused = false ;
212
201
state . inputFocused = false ;
213
202
state . placeholder = this . props . placeholder || this . props . dateFormat ;
@@ -433,24 +422,24 @@ exports.default = _react2.default.createClass({
433
422
monthLabels : this . props . monthLabels ,
434
423
dateFormat : this . props . dateFormat } ) ;
435
424
return _react2 . default . createElement (
436
- _InputGroup2 . default ,
425
+ _reactBootstrap . InputGroup ,
437
426
{ ref : 'inputGroup' , bsClass : this . props . bsClass , bsSize : this . props . bsSize , id : this . props . id ? this . props . id + "_group" : null } ,
438
427
_react2 . default . createElement (
439
- _Overlay2 . default ,
428
+ _reactBootstrap . Overlay ,
440
429
{ rootClose : true , onHide : this . handleHide , show : this . state . focused , container : function container ( ) {
441
430
return _reactDom2 . default . findDOMNode ( _this2 . refs . overlayContainer ) ;
442
431
} , target : function target ( ) {
443
432
return _reactDom2 . default . findDOMNode ( _this2 . refs . input ) ;
444
433
} , placement : this . props . calendarPlacement , delayHide : 200 } ,
445
434
_react2 . default . createElement (
446
- _Popover2 . default ,
435
+ _reactBootstrap . Popover ,
447
436
{ id : 'calendar' , title : calendarHeader } ,
448
- _react2 . default . createElement ( Calendar , { cellPadding : this . props . cellPadding , selectedDate : this . state . selectedDate , displayDate : this . state . displayDate , onChange : this . onChangeDate , dayLabels : this . props . dayLabels } )
437
+ _react2 . default . createElement ( Calendar , { cellPadding : this . props . cellPadding , selectedDate : this . state . selectedDate , displayDate : this . state . displayDate , onChange : this . onChangeDate , dayLabels : this . state . dayLabels , weekStartsOnMonday : this . props . weekStartsOnMonday } )
449
438
)
450
439
) ,
451
440
_react2 . default . createElement ( 'div' , { ref : 'overlayContainer' } ) ,
452
441
_react2 . default . createElement ( 'input' , { ref : 'hiddenInput' , type : 'hidden' , id : this . props . id , name : this . props . name , value : this . state . value || '' } ) ,
453
- _react2 . default . createElement ( _FormControl2 . default , {
442
+ _react2 . default . createElement ( _reactBootstrap . FormControl , {
454
443
onKeyDown : this . handleKeyDown ,
455
444
value : this . state . inputValue || '' ,
456
445
ref : 'input' ,
@@ -461,7 +450,7 @@ exports.default = _react2.default.createClass({
461
450
onChange : this . handleInputChange
462
451
} ) ,
463
452
_react2 . default . createElement (
464
- _InputGroup2 . default . Addon ,
453
+ _reactBootstrap . InputGroup . Addon ,
465
454
{ onClick : this . clear , style : { cursor : this . state . inputValue ? "pointer" : "not-allowed" } } ,
466
455
this . props . clearButtonElement
467
456
)
0 commit comments