1.0.2 • Published 6 years ago

use-calendar-hook v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

use-calendar-hook

React Hook for creating a custom calendar

Installation

npm install use-calendar-hook --save

Demo

Edit use-calendar-hook

Usage

import useCalendar from 'use-calendar-hook';

const {
  days,
  weeks,
  month,
  year,
  prevMonth,
  nextMonth,
  prevYear,
  nextYear
} = useCalendar({
  startDate: new Date('2019-8-20'),
  disabledDates: [new Date('2019-8-5'), new Date('2019-8-6')],
  disabledDays: ['Sa', 'Su']
});

API

Parameters

FieldTypeDescription
datedateCurrent date
daynumberCurrent number of day
monthstringCurrent month
yearstringCurrent year
days[Object]Days of current month
months[Object]Months of current year
weeksArray"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"
nextDayFunctionChange current day on next
prevDayFunctionChange current day on previous
nextMonthFunctionChange current month on next
prevMonthFunctionChange current month on previous
nextYearFunctionChange current year on next
prevYearFunctionChange current year on previous
setDateFunctionSet new day
setMonthFunctionSet new month
setYearFunctionSet new year

config

KeyTypeDescription
startDatedateStart date
endDatedateEnd date
maxDatedateOption specifies the maximum/latest date (inclusively) allowed for selection
minDatedateOption specifies the minimum/earliest date (inclusively) allowed for selection
disabledDays[date]Inaccessible days of the week for selection
disabledDates[date]Inaccessible dates for selection

License

The files included in this repository are licensed under the MIT license.

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago