npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@_--/react-calendar

v0.0.0-alpha.9

Published

zero-dependency calendar component for react

Downloads

6

Readme

@_--/react-calendar

a zero-dependency calendar component for react.

many parts still incomplete/todo, and shoddy coding style oops.

features

  • single, multi, and range selection of dates; multi selection also supports drag-and-hold to (un)select multiple dates at once.
  • keyboard navigation; unfortunately not aria-compliant grid, but supports...
    • arrow keys to navigate along tiles with wrapping,
    • tab to toggle between nav and tiles
    • shift + tab from nav to escape focus from calendar; shift+tab again after that to go to the previos element
    • home/end) to go to the start (end) of the row
    • shift + home/end to go to the first (last) tile
    • esc to unselect partial range dates, or otherwise escape focus from the calendar; tab after that to go to the next element
  • highlight/disable dates
  • hide dates before/after/outside the current month
  • set which day of the week the calendar begins on
  • set which days of the week are "weekends" to highlight
  • customize how dates/months/years/decades are displayed
  • calendar view locking
  • separate css for core styles, default styles, and useful/common add-ons, all using low-precedence selectors and css custom properties

installation

# npm
npm install @_--/react-calendar

# yarn
yarn add @_--/react-calendar

usage

import React, { useState } from 'react';
import { Calendar } from '@_--/react-calendar';

const App = () => {
  const [selectedDates, setSelectedDates] = useState([]);
  return (
      <Calendar
        onChangeSelectedDates={(newState, oldState) => { setSelectedDates(newState); }}
      />
  )
}

styling

import the main stylesheet to make a minimally unstyled calendar

import '@_--/react-calendar/dist/styles/index.css';

you can separately use or build upon the default styles

import '@_--/react-calendar/dist/styles/default.css';

a preset is also provided to force calendar tiles in the month view to be square

import '@_--/react-calendar/dist/styles/preset/square-tiles.css';

the component is styled using css custom properties, making them easy to re-style and customize

calendar props

types

| name | type | :-- | :-- DayOfWeek | 0 <= x < 7

props

| prop | description | type | default | :-- | :-- | :-- | :-- className | classname to add to the calendar container element | string | selectMode | how dates are to be "selected". | "single" | "multi" | "range" | "single" weekStart | which day of the week occupies the leftmost column of the calendar, where 0=Sunday, 1=Monday, ... | DayOfWeek | 0 weekendDays | which days of the week constitute as "weekends". weekends can be styled differently. | DayOfWeek[] | [0, 6] initialDate | the date the calendar will initialize its displayed dates with | Date | new Date() initialView | what "view" the calendar should begin with | "month" | "year" | "decade" | "month" hideAdjacentMonthsDates | whether dates from the adjacent months should be hidden in the "month" view (ie the 30th of the previous month, or the 1st of the next month). true hides both | boolean | "prev" | "next" lockView | whether the calendar view cannot be changed from its initial view of decade, year, or month | boolean | false lockTiles | whether the calendar view and tiles should be locked. | boolean | false disabledDates | function describing which dates should be disabled. disabled dates cannot be selected. | (Date) => boolean | "past" | "today" | "future" | highlightedDates | function describing which dates should be highlighted. highlighted dates can be styled differently | (Date) => boolean | "today" | "today" prevButtonIcon | icon for the previous button for calendar navigation within a view | string \| JSX.element | "←" nextButtonIcon | icon for the next button for calendar navigation within a view | string \| JSX.element | "→" formatDecade | how to format the decade view heading, given the first year of the decade | (default formatter; ie "2000 - 2009") formatYear | how to format the year view heading and decade view tiles | (default formatter; ie "2000") formatMonthYear | how to format the month view heading | (Date) => string | (default formatter; ie "January 2000") formatMonth | how to format the year view tile labels | (Date) => string | (default formatter; ie "January") formatDayOfMonth | how to format the month view tiles | (Date) => string | (default formatter; ie "1") formatDayOfWeek | how to format the day of week labels | (DayOfWeek) => string | (default formatter; ie "Mon") onChangeView | function called whenever the calendar view is changed | (newView, oldView) => unknown | onChangeSelectMode | function called whenever the select mode is changed | (newSelectMode, oldSelectMode) => unknown | (default callback: if switching from range to multi select mode, selects all dates in the range; otherwise, clears selected dates) onChangeSelectedDates | function called whenever the selected dates change | (newSelectedDates, oldSelectedDates) => unknown | onChangePartialRangeDates | function called whenever the partial range dates, used for "soft highlighting" while in range select or drag-and-holding in multi select | (newPartialRangeDates, oldPartialRangeDates) => unknown |