React-Bootstrap based date picker.
npm install react-16-bootstrap-date-picker




See the demo at pushtell.github.io/react-bootstrap-date-picker.

Please ★ on GitHub!
Using this module in production? We'd love to hear about it.
- Installation
- Usage
- API Reference
-
- Tests
- Browser Coverage
- Running Tests
react-bootstrap-date-picker is compatible with React 0.14.x and 0.15.x.
``bash`
npm install react-bootstrap-date-picker
`js
var DatePicker = require("react-bootstrap-date-picker");
var App = React.createClass({
getInitialState: function(){
var value = new Date().toISOString();
return {
value: value
}
},
handleChange: function(value, formattedValue) {
this.setState({
value: value, // ISO String, ex: "2016-11-19T12:00:00.000Z"
formattedValue: formattedValue // Formatted String, ex: "11/19/2016"
});
},
componentDidUpdate: function(){
// Access ISO String and formatted values from the DOM.
var hiddenInputElement = document.getElementById("example-datepicker");
console.log(hiddenInputElement.value); // ISO String, ex: "2016-11-19T12:00:00.000Z"
console.log(hiddenInputElement.getAttribute('data-formattedvalue')) // Formatted String, ex: "11/19/2016"
},
render: function(){
return
}
});
`
DatePicker component. Renders as a React-Bootstrap InputGroup.
InputGroup properties are passed through to the input group.
* Properties:
* value - ISO date string representing the current value.string
* Optional
* Type: "2016-05-19T12:00:00.000Z"
* Example: defaultValue
* - ISO date string representing the default value. Cannot be set with 'value'.string
* Optional
* Type: "2016-05-19T12:00:00.000Z"
* Example: minDate
* - ISO date string to set the lowest allowable date value.string
* Optional
* Type: "2016-05-19T12:00:00.000Z"
* Example: maxDate
* - ISO date string to set the highest allowable date value.string
* Optional
* Type: "2016-05-19T12:00:00.000Z"
* Example: style
* - Style object passed to the FormControl input element.object
* Optional
* Type: {width: "100%"}
* Example: className
* - Class name passed to the FormControl input element.string
* Optional
* Type: example-class
* Example: autoComplete
* - autoComplete attribute passed to the FormControl input element.string
* Optional
* Type: off
* Example: autoFocus
* - Whether or not component starts with focus.bool
* Optional
* Type: false
* Example: disabled
* - Whether or not component is disabled.bool
* Optional
* Type: false
* Example: onChange
* - Focus callback function.function
* Optional
* Type: value
* Callback Arguments:
* - ISO date string representing the selected value.String
* Type: "2016-05-19T12:00:00.000Z"
* Example: formattedValue
* - String representing the formatted value as defined by the dateFormat property.String
* Type: "05/19/2016"
* Example: onFocus
* - Focus callback function.function
* Optional
* Type: event
* Callback Arguments:
* - Focus event.Event
* Type: onBlur
* - Blur callback function.function
* Optional
* Type: event
* Callback Arguments:
* - Blur event.Event
* Type: dateFormat
* - Date format. Any combination of DD, MM, YYYY and separator.string
* Optional
* Type: "MM/DD/YYYY"
* Examples: , "YYYY/MM/DD", "MM-DD-YYYY", or "DD MM YYYY"clearButtonElement
* - Character or component to use for the clear button.string
* Optional
* Type: or ReactClass"×"
* Example: showClearButton
* - Toggles the visibility of the clearButtonbool
* Optional
* Type: false
* Example: onClear
* - Defines what happens when clear button is clicked.function
* Optional
* Type: previousButtonElement
* - Character or component to use for the calendar's previous button.string
* Optional
* Type: or ReactClass"<"
* Example: nextButtonElement
* - Character or component to use for the calendar's next button.string
* Optional
* Type: or ReactClass">"
* Example: cellPadding
* - CSS padding value for calendar date cells.string
* Optional
* Type: "2px"
* Example: dayLabels
* - Array of day names to use in the calendar. Starting on Sunday.array
* Optional
* Type: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
* Example: monthLabels
* - Array of month names to use in the calendar.array
* Optional
* Type: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
* Example: calendarPlacement
* - Overlay placement for the popover calendar.string
* Optional
* Type: or function"top"
* Example: calendarContainer
* - Overlay container for the popover calendar. When placing the date-picker in a scrolling container, set this prop to some ancestor of the scrolling container.document.body
* Optional
* Type: A DOM element or a component
* Example: weekStartsOnMonday
* - OBSOLETE use weekStartsOnweekStartsOn
* - Makes the calendar's week to start on a specified day. 0 = Sunday, 1 = Monday, etc.number
* Optional
* Type: 4
* Example: showTodayButton
* - Toggles the visibility of the today-button.boolean
* Optional
* Type: false
* Example: todayButtonLabel
* - Label for the today-buttonstring
* Optional
* Type: "Today"
* Example: customControl
* - Overwrite the default FormControl component with your own component.React.Component
* Optional
* Type:
* Example:
* Methods:
Karma tests are performed on Browserstack in the following browsers:
* IE 9, Windows 7
* IE 10, Windows 7
* IE 11, Windows 7
* Opera (latest version), Windows 7
* Firefox (latest version), Windows 7
* Chrome (latest version), Windows 7
* Safari (latest version), OSX Yosemite
* Mobile Safari (latest version), iPhone 6, iOS 8.3
Please let us know if a different configuration should be included here.
Locally:
`bash
npm test
`
On Browserstack:
`bash
BROWSERSTACK_USERNAME=YOUR_USERNAME BROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY npm test
``