Socket
Socket
Sign inDemoInstall

react-infinite-calendar-with-range

Package Overview
Dependencies
38
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-infinite-calendar-with-range

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


Version published
Weekly downloads
358
increased by22.6%
Maintainers
1
Install size
13.2 MB
Created
Weekly downloads
 

Readme

Source

React Infinite Calendar

npm version downloads build coverage bitHound Overall Score 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 plaît!
  • Customizeable – Customize and theme to your heart's content.
  • Year selection – For rapidly jumping from year to year
  • Keyboard support – ⬆️ ⬇️ ⬆️ ⬇️ ⬅️ ➡️ ⬅️ ➡️ ↩️
  • Events and callbacks – beforeSelect, onSelect, onScroll, yadda yadda yadda.
  • Mobile-friendly – Silky smooth scrolling on mobile

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>
<script>
var InfiniteCalendar = window.InfiniteCalendar.default;
...
</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*1000) * 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

PropertyTypeDefaultDescription
selectedDateDate or Booleannew Date()Value of the date that appears to be selected. Supports any input format supported by moment.js. Set to false if you don't wish to have a date initially selected.
minDatenew Date(1980,0,1)The minimum month that can be scrolled to. Supports any input format supported by moment.js
maxDatenew Date(2050,11,31)The maximum month that can be scrolled to. Supports any input format supported by moment.js
minDateDatenew Date(1980,0,1)The minimum date that is selectable. Supports any input format supported by moment.js
maxDateDatenew Date(2050,11,31)The maximum date that is selectable. Supports any input format supported by moment.js
displayString'days'Whether to display the years or days view.
localeObjectSee default localeBy 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
themeObjectSee default themeBasic customization of the colors
widthNumber or String400Width of the calendar. Use number for pixel width, string for percentage, for example: width={400} or width={'80%'}
heightNumber600Height of the calendar
rowHeightNumber56Height of each row in the calendar (each week is considered a row)
classNameStringOptional CSS class name to append to the root InfiniteCalendar element.
overscanMonthCountNumber4Number of months to render above/below the visible months. Tweaking this can help reduce flickering during scrolling on certain browers/devices.
todayHelperRowOffsetNumber4This controls the number of rows to scroll past before the Today helper appears
disabledDaysArray of NumbersArray of days of the week that should be disabled. For example, to disable Monday and Sunday: [0, 6]
disabledDatesArray of DatesArray 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}]
beforeSelectFunctionCallback 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; }
onSelectFunctionCallback invoked after beforeSelect() returns true, but before the state of the calendar updates
afterSelectFunctionCallback invoked after the state of the calendar has sucessfully been updated
onScrollFunctionCallback invoked when the scroll offset changes. function (scrollTop: number) {}
onScrollEndFunctionCallback invoked 150ms after the last onScroll event is triggered. function (scrollTop: number) {}
keyboardSupportBooleantrueKeyboard support (left, right, up, down, enter)
autoFocusBooleantrueWhether 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)
tabIndexNumber1Tab-index of the calendar
layoutString'portrait'Layout of the calendar. Should be one of 'portrait' or 'landscape'
showHeaderBooleantrueShow/hide the header
shouldHeaderAnimateBooleantrueEnable/Disable the header animation
showOverlayBooleantrueShow/hide the month overlay when scrolling
showTodayHelperBooleantrueShow/hide the floating back to Today helper
hideYearsOnSelectBooleantrueWhether to automatically hide the years view on select.

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.

Reporting Issues

If you find an issue, please report it along with any relevant details to reproduce it. The easiest way to do so is to fork this jsfiddle.

Contributions

Yes please! Feature requests / pull requests are welcome. Have a suggestion or just want to say hello? Come chat on gitter!

Made with ❤︎ in the heart of Montreal.

Keywords

FAQs

Last updated on 07 Sep 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc