Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

calijs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calijs

Build simple, lightweight React calendars & datepickers with a single hook

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

CaliJS :palm_tree:

Build simple, lightweight React calendars & datepickers with a single hook

Installation

This module is distributed via [npm][npm] which is bundled with [node][node] and should be installed as one of your project's dependencies:

npm install --save calijs

This package also depends on react and dayjs. Please make sure you have them installed as well. 👍

Usage

Try it out in the browser

const {
  date,
  selectedDate,
  nextMonth,
  previousMonth,
  nextYear,
  previousYear,
  selectDay,
  getMonthDays,
  setMonth,
  setYear,
} = useCali();

The useCali() hook returns the hook object based on now as the initial date. Pass a different date to the hook such as useCali("12-19-1989"); to start at a different date.

The hook

date

dayjs()

The current date as a dayjs object

selectedDate

dayjs()

The selected date as a dayjs object

nextMonth()

function()

Sets the date one month ahead

previousMonth()

function()

Sets the date one month before

nextYear()

function()

Sets the current date one year ahead

previousYear()

function()

Sets the current date one year before

selectDay(date)

function(date)

Call with a date to set the selectedDate

getMonthDays()

function()

When called it turns a 42 item array of day objects ({ date: dayjs(), inMonth: boolean, isSelected: boolean }) to be used in 6 x 7 grid for calendars and datepickers

setYear(year)

function(year) | year: string || number | optional

Sets the current year to the passed year. Year parameter can be a string or a number. If year is not valid it throws an invalid year error

setMonth(month)

function(month) | month: string || number | optional

Sets the current month to the passed month. Month parameter can be a string or a number from 0 - 11. If range is exceeded, it will be bubbled up to the year. If month is not valid it throws an invalid month error.

LISENCE

MIT

Keywords

FAQs

Package last updated on 10 May 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc