2
2
3
3
import React from 'react' ;
4
4
import ReactDOM from 'react-dom' ;
5
- import FormControl from 'react-bootstrap/lib/FormControl' ;
6
- import InputGroup from 'react-bootstrap/lib/InputGroup' ;
7
- import Popover from 'react-bootstrap/lib/Popover' ;
8
- import Button from 'react-bootstrap/lib/Button' ;
9
- import Overlay from 'react-bootstrap/lib/Overlay' ;
5
+ import { Button , FormControl , InputGroup , Overlay , Popover } from 'react-bootstrap' ;
10
6
11
7
const CalendarHeader = React . createClass ( {
12
8
displayName : "DatePickerHeader" ,
@@ -51,7 +47,8 @@ const Calendar = React.createClass({
51
47
displayDate : React . PropTypes . object . isRequired ,
52
48
onChange : React . PropTypes . func . isRequired ,
53
49
dayLabels : React . PropTypes . array . isRequired ,
54
- cellPadding : React . PropTypes . string . isRequired
50
+ cellPadding : React . PropTypes . string . isRequired ,
51
+ weekStartsOnMonday : React . PropTypes . bool
55
52
} ,
56
53
handleClick ( day ) {
57
54
const newSelectedDate = new Date ( this . props . displayDate ) ;
@@ -73,7 +70,7 @@ const Calendar = React.createClass({
73
70
const year = this . props . displayDate . getFullYear ( ) ;
74
71
const month = this . props . displayDate . getMonth ( ) ;
75
72
const firstDay = new Date ( year , month , 1 ) ;
76
- const startingDay = firstDay . getDay ( ) ;
73
+ const startingDay = this . props . weekStartsOnMonday ? ( firstDay . getDay ( ) + 1 ) : firstDay . getDay ( ) ;
77
74
let monthLength = daysInMonth [ month ] ;
78
75
if ( month == 1 ) {
79
76
if ( ( year % 4 == 0 && year % 100 != 0 ) || year % 400 == 0 ) {
@@ -126,6 +123,7 @@ export default React.createClass({
126
123
monthLabels : React . PropTypes . array ,
127
124
onChange : React . PropTypes . func ,
128
125
onClear : React . PropTypes . func ,
126
+ weekStartsOnMonday : React . PropTypes . bool ,
129
127
clearButtonElement : React . PropTypes . oneOfType ( [
130
128
React . PropTypes . string ,
131
129
React . PropTypes . object
@@ -144,9 +142,10 @@ export default React.createClass({
144
142
getDefaultProps ( ) {
145
143
const language = typeof window !== "undefined" && window . navigator ? ( window . navigator . userLanguage || window . navigator . language || '' ) . toLowerCase ( ) : '' ;
146
144
const dateFormat = ! language || language === "en-us" ? 'MM/DD/YYYY' : 'DD/MM/YYYY' ;
145
+ const dayLabels = this . props . weekStartsOnMonday ? [ 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' , 'Sun' ] : [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ;
147
146
return {
148
147
cellPadding : "5px" ,
149
- dayLabels : [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ,
148
+ dayLabels,
150
149
monthLabels : [ 'January' , 'February' , 'March' , 'April' ,
151
150
'May' , 'June' , 'July' , 'August' , 'September' ,
152
151
'October' , 'November' , 'December' ] ,
@@ -383,7 +382,7 @@ export default React.createClass({
383
382
return < InputGroup ref = "inputGroup" bsClass = { this . props . bsClass } bsSize = { this . props . bsSize } id = { this . props . id ? this . props . id + "_group" : null } >
384
383
< Overlay rootClose = { true } onHide = { this . handleHide } show = { this . state . focused } container = { ( ) => ReactDOM . findDOMNode ( this . refs . overlayContainer ) } target = { ( ) => ReactDOM . findDOMNode ( this . refs . input ) } placement = { this . props . calendarPlacement } delayHide = { 200 } >
385
384
< Popover id = "calendar" title = { calendarHeader } >
386
- < Calendar cellPadding = { this . props . cellPadding } selectedDate = { this . state . selectedDate } displayDate = { this . state . displayDate } onChange = { this . onChangeDate } dayLabels = { this . props . dayLabels } />
385
+ < Calendar cellPadding = { this . props . cellPadding } selectedDate = { this . state . selectedDate } displayDate = { this . state . displayDate } onChange = { this . onChangeDate } dayLabels = { this . props . dayLabels } weekStartsOnMonday = { this . props . weekStartsOnMonday } />
387
386
</ Popover >
388
387
</ Overlay >
389
388
< div ref = "overlayContainer" />
0 commit comments