Giter Site home page Giter Site logo

jackpilowsky / react-bootstrap-datetimerangepicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from luqin/react-bootstrap-datetimerangepicker

0.0 1.0 0.0 1003 KB

React date & time range picker component base on bootstrap-daterangepicker. This date range picker component for Bootstrap creates a dropdown menu from which a user can select a range of dates. Features include limiting the selectable date range, localizable strings and date formats, a single date picker mode, optional time picker (for e.g. making appointments or reservations), and styles that match the default Bootstrap 3 theme.

Home Page: https://luqin.github.io/react-bootstrap-datetimerangepicker

JavaScript 100.00%

react-bootstrap-datetimerangepicker's Introduction

React Date&Time Range Picker for Bootstrap

NPM version Build Status

Dependency Status devDependency Status peerDependency Status

Improvely.com

This date range picker component for Bootstrap creates a dropdown menu from which a user can select a range of dates.

Base on bootstrap-daterangepicker

Online demo: http://luqin.github.io/react-bootstrap-datetimerangepicker

Features

  • limiting the selectable date range
  • localizable strings and date formats
  • a single date picker mode
  • optional time picker (for e.g. making appointments or reservations)
  • styles that match the default Bootstrap 3 theme

Upgrade guide

<2.0 to 2.x

Using official bootstrap-daterangepicker

# <2.0
npm install react-bootstrap-datetimerangepicker onefe-bootstrap-daterangepicker --save

# 2.x
npm install react-bootstrap-datetimerangepicker bootstrap-daterangepicker --save
// <2.0
import 'bootstrap/dist/css/bootstrap.css';
import 'onefe-bootstrap-daterangepicker/daterangepicker.css';

// 2.x
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap-daterangepicker/daterangepicker.css';

Installation

npm install react-bootstrap-datetimerangepicker bootstrap-daterangepicker --save

Usage

Date Range Picker relies on Bootstrap, jQuery and Moment.js. Include the required stylesheet in your page:

import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap-daterangepicker/daterangepicker.css';
import DatetimeRangePicker from 'react-bootstrap-datetimerangepicker';

<DatetimeRangePicker
    startDate={this.state.startDate}
    endDate={this.state.endDate}
    onApply={this.handleApply}
>
    <input type="text" value={label}/>
</DatetimeRangePicker>

<DatetimeRangePicker
    timePicker
    timePicker24Hour
    showDropdowns
    timePickerSeconds
    locale={locale}
    startDate={this.state.startDate}
    endDate={this.state.endDate}
    onApply={this.handleApply}
>
    <Button>
        <i className="fa fa-calendar"/> &nbsp;
        <span>{label}</span>
        <i className="fa fa-angle-down"/>
    </Button>
</DatetimeRangePicker>

More examples: Online demo, Source

Documentation

For in depth documentation, see the original bootstrap-daterangepicker project page.

Options

  • startDate: (Date object, moment object or string) The start of the initially selected date range
  • endDate: (Date object, moment object or string) The end of the initially selected date range
  • minDate: (Date object, moment object or string) The earliest date a user may select
  • maxDate: (Date object, moment object or string) The latest date a user may select
  • dateLimit: (object) The maximum span between the selected start and end dates. Can have any property you can add to a moment object (i.e. days, months)
  • showDropdowns: (boolean) Show year and month select boxes above calendars to jump to a specific month and year
  • showWeekNumbers: (boolean) Show week numbers at the start of each week on the calendars
  • timePicker: (boolean) Allow selection of dates with times, not just dates
  • timePickerIncrement: (number) Increment of the minutes selection list for times (i.e. 30 to allow only selection of times ending in 0 or 30)
  • timePicker24Hour: (boolean) Use 24-hour instead of 12-hour times, removing the AM/PM selection
  • timePickerSeconds: (boolean) Show seconds in the timePicker
  • ranges: (object) Set predefined date ranges the user can select from. Each key is the label for the range, and its value an array with two dates representing the bounds of the range
  • opens: (string: 'left'/'right'/'center') Whether the picker appears aligned to the left, to the right, or centered under the HTML element it's attached to
  • drops: (string: 'down' or 'up') Whether the picker appears below (default) or above the HTML element it's attached to
  • buttonClasses: (array) CSS class names that will be added to all buttons in the picker
  • applyClass: (string) CSS class string that will be added to the apply button
  • cancelClass: (string) CSS class string that will be added to the cancel button
  • locale: (object) Allows you to provide localized strings for buttons and labels, customize the date display format, and change the first day of week for the calendars
  • singleDatePicker: (boolean) Show only a single calendar to choose one date, instead of a range picker with two calendars; the start and end dates provided to your callback will be the same single date chosen
  • autoApply: (boolean) Hide the apply and cancel buttons, and automatically apply a new date range as soon as two dates or a predefined range is selected
  • linkedCalendars: (boolean) When enabled, the two calendars displayed will always be for two sequential months (i.e. January and February), and both will be advanced when clicking the left or right arrows above the calendars. When disabled, the two calendars can be individually advanced and display any month/year.
  • parentEl: (string) jQuery selector of the parent element that the date range picker will be added to, if not provided this will be 'body'
  • isInvalidDate: (function) A function that is passed each date in the two calendars before they are displayed, and may return true or false to indicate whether that date should be available for selection or not.
  • autoUpdateInput: (boolean) Indicates whether the date range picker should automatically update the value of an element it's attached to at initialization and when the selected dates change.

Events

  • onShow: Triggered when the picker is shown
  • onHide: Triggered when the picker is hidden
  • onHideCalendar: Triggered when the calendar(s) are shown
  • onApply: Triggered when the calendar(s) are hidden
  • onCancel: Triggered when the apply button is clicked, or when a predefined range is clicked
  • onEvent: Triggered when the cancel button is clicked

All of the events above should take a handler that is passed 2 arguments: event and picker

Example event handler:

var SomeReactComponent = React.createClass({
    handleEvent: function (event, picker) {
        console.log(picker.startDate);
    },
    render: function () {
        return (
            <DatetimeRangePicker onEvent={this.handleEvent} />
        );
    }
});

Browser support

  • Google Chrome
  • Firefox (2+)
  • IE (9+)
  • Opera (11.6+)
  • Safari (6+)

Local Setup

  • Install the dependencies with npm install
  • Run the docs site in development mode with npm start. This will watch for file changes as you work. And auto refresh the page to see the updates.

react-bootstrap-datetimerangepicker's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.