Socket
Socket
Sign inDemoInstall

@joakim_sm/react-infinite-calendar

Package Overview
Dependencies
35
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@joakim_sm/react-infinite-calendar

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


Version published
Maintainers
1
Weekly downloads
6
decreased by-50%

Weekly downloads

Readme

Source

React Infinite Calendar

Currently looking for maintainers to help maintain this project, please reach out if you would be interested

npm version downloads license 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.
  • Extensible – Add date range-selection, multiple date selection, or create your own HOC!
  • 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, etc.
  • Mobile-friendly – Silky smooth scrolling on mobile

Getting Started

Using npm:

npm install react-infinite-calendar --save

ES6, CommonJS, and UMD builds are available with each distribution. For example:

import InfiniteCalendar from 'react-infinite-calendar';
import 'react-infinite-calendar/styles.css'; // Make sure to import the default stylesheet

You can also use a global-friendly UMD build:

<link rel="stylesheet" href="react-infinite-calendar/styles.css">
<script src="react-infinite-calendar/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 lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7);

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

For more usage examples, see http://clauderic.github.io/react-infinite-calendar/ or check out some code examples.

Prop Types

PropertyTypeDefaultDescription
selectedDate or Booleannew Date()Value of the date that appears to be selected. Set to false if you don't wish to have a date initially selected.
widthNumber400Width of the calendar, in pixels
heightNumber600Height of the calendar, in pixels
minDatenew Date(1980, 0, 1)The minimum month that can be scrolled to.
maxDatenew Date(2050, 11, 31)The maximum month that can be scrolled to.
minDateDatenew Date(1980, 0, 1)The minimum date that is selectable.
maxDateDatenew Date(2050, 11, 31)The maximum date that is selectable.
disabledDaysArrayArray of days of the week that should be disabled. For example, to disable Monday and Sunday: [0, 6]
disabledDatesArrayArray of dates that should be disabled. For example: [new Date(2017, 1, 8), new Date(), new Date(2017, 5, 17)]
displayString'days'Whether to display the years or days view.
displayOptionsObjectSee default displayOptionsSee display options section for more details.
localeObjectSee default localeBy default, React Infinite Calendar comes with the English locale. You can use this to change the language, or change the first day of the week. See date-fns documentation for more details
themeObjectSee default themeBasic customization of the colors
classNameStringOptional CSS class name to append to the root InfiniteCalendar element.
onSelectFunctionCallback invoked after beforeSelect() returns true, but before the state of the calendar updates
onScrollFunctionCallback invoked when the scroll offset changes. function (scrollTop: number) {}
onScrollEndFunctionCallback invoked 150ms after the last onScroll event is triggered. function (scrollTop: number) {}
rowHeightNumber56Height of each row in the calendar (each week is considered a row)
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

Display Options

PropertyTypeDefaultDescription
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
showWeekdaysBooleantrueShow/hide the weekdays in the header
hideYearsOnSelectBooleantrueWhether to automatically hide the years view on select.
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

Example usage of display options:

<InfiniteCalendar
  displayOptions={{
    layout: 'landscape',
    showOverlay: false,
    shouldHeaderAnimate: false
  }}
/>

Dependencies

React Infinite Calendar has very few dependencies. It relies on react-tiny-virtual-list for virtualization and date-fns for handling date manipulation. It also uses recompose for extending the default functionality. It also has the following peerDependencies: react, and react-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 sandbox on CodeSandbox.

Contributions

Yes please! Feature requests / pull requests are welcome. Learn how to contribute

Have a suggestion or just want to say hello? Come chat on Gitter!

License

react-infinite-calendar is available under the MIT License.

Keywords

FAQs

Last updated on 30 Jun 2020

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