JSPM

  • Created
  • Published
  • Downloads 10112
  • Score
    100M100P100Q134276F
  • License MIT

Infinite scrolling date-picker built with React, with localization, themes, keyboard support, and more.

Package Exports

  • react-infinite-calendar
  • react-infinite-calendar/styles.css

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-infinite-calendar) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React Infinite Calendar

npm version build coverage license XO code style Gitter

Examples available here: http://clauderic.github.io/react-infinite-calendar/

Features

  • Infinite scroll – Just keep scrollin', just keep scrollin'
  • Flexible – Min/max date, disabled dates, disabled days, etc.
  • Localization and translation – En français, s'il vous plait!
  • Customizeable – Customize and theme to your heart's content.
  • Keyboard support – ⬆️ ⬇️ ⬆️ ⬇️ ⬅️ ➡️ ⬅️ ➡️ ↩️
  • Events and callbacks – beforeSelect, onSelect, onScroll, yadda yadda yadda.

And mucho, mucho mas 🎉

Installation

Using npm:

$ npm install react-infinite-calendar --save

Then, using a module bundler that supports either CommonJS or ES2015 modules, such as webpack:

// Using an ES6 transpiler like Babel
import InfiniteCalendar from 'react-infinite-calendar';
import 'react-infinite-calendar/styles.css'; // Make sure to import the default stylesheet

// Not using an ES6 transpiler
var InfiniteCalendar = require('react-infinite-calendar');
require('react-infinite-calendar/styles.css');

Alternatively, an UMD build is also available:

<link rel="stylesheet" href="react-infinite-calendar/styles.css">
<script src="react-infinite-calendar/dist/umd/react-infinite-calendar.js"></script>

Usage

Basic Example

import React from 'react';
import { render } from 'react-dom';
import InfiniteCalendar from 'react-infinite-calendar';
import 'react-infinite-calendar/styles.css'; // only needs to be imported once

// Render the Calendar
var today = new Date();
var minDate = Number(new Date()) - (24*60*60) * 7; // One week before today

render(
  <InfiniteCalendar
    width={400}
    height={600}
    selectedDate={today}
    disabledDays={[0,6]}
    minDate={minDate}
    keyboardSupport={true}
  />,
  document.getElementById('root')
);

For more usage examples, see http://clauderic.github.io/react-infinite-calendar/

Prop Types

Property Type Default Description
selectedDate Valid Date new Date() Value of the date that appears to be selected. Supports any input format supported by moment.js
min Valid Date {year: 1980, month: 0, day: 0} The minimum month that can be scrolled to. Supports any input format supported by moment.js
max Valid Date {year: 2050, month: 11, day: 31} The maximum month that can be scrolled to. Supports any input format supported by moment.js
minDate Valid Date {year: 1980, month: 0, day: 0} The minimum date that is selectable. Supports any input format supported by moment.js
maxDate Valid Date {year: 2050, month: 11, day: 31} The maximum date that is selectable. Supports any input format supported by moment.js
locale Object See locale.js By default, React Infinite Calendar comes with the English locale strings. You can use this to change the language, or change the first day of the week. See moment.js documentation for more details
theme Object See theme.js Basic customization of the colors
width Number 400 Width of the calendar
height Number 600 Height of the calendar
rowHeight Number 56 Height of each row in the calendar (each week is considered a row)
className String Optional CSS class name to append to the root InfiniteCalendar element.
overscanMonthCount Number 4 Number of months to render above/below the visible months. Tweaking this can help reduce flickering during scrolling on certain browers/devices.
disabledDays Array of Numbers Array of days of the week that should be disabled. For example, to disable Monday and Sunday: [0, 6]
disabledDates Array of Valid Dates Array of arbitrary dates that should be disabled. Supports any input format supported by moment.js. For example: ['2016-01-08', new Date(), '20160520', {year: 2015, month: 03, day: 15}]
beforeSelect Function Callback invoked before the state is mutated. Can be used to prevent the state from being changed by returning false. Example: function(date) { return true / false; }
onSelect Function Callback invoked after beforeSelect() returns true, but before the state of the calendar updates
afterSelect Function Callback invoked after the state of the calendar has sucessfully been updated
onScroll Function Callback invoked when the scroll offset changes. function (scrollTop: number) {}
onScrollEnd Function Callback invoked 150ms after the last onScroll event is triggered. function (scrollTop: number) {}
keyboardSupport Boolean true Keyboard support (left, right, up, down)
autoFocus Boolean true Whether the Calendar root should be auto-focused when it mounts. This is useful when keyboardSupport is enabled (the calendar must be focused to listen for keyboard events)
tabIndex Number 1 Tab-index of the calendar
layout String 'portrait' Layout of the calendar. Should be one of 'portrait' or 'landscape'
showHeader Boolean true Show/hide the header
shouldHeaderAnimate Boolean true Enable/Disable the header animation
showOverlay Boolean true Show/hide the month overlay when scrolling
showTodayHelper Boolean true Show/hide the floating back to Today helper

Dependencies

React Infinite Calendar has few dependencies. It relies on the great work done by react-virtualized/VirtualScroll for handling virtual scrolling logic and Moment.js for handling date manipulation. It also has the following peer dependencies: react, react-dom, react-addons-shallow-compare, and react-addons-css-transition-group.

Contributions

Yes please! Feature requests / pull requests are welcome.

Made with ❤︎ in the heart of Montreal by Claudéric Demers.