1.0.2 • Published 6 years ago
use-calendar-hook v1.0.2
use-calendar-hook
React Hook for creating a custom calendar
Installation
npm install use-calendar-hook --save
Demo
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
Field | Type | Description |
---|---|---|
date | date | Current date |
day | number | Current number of day |
month | string | Current month |
year | string | Current year |
days | [Object] | Days of current month |
months | [Object] | Months of current year |
weeks | Array | "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su" |
nextDay | Function | Change current day on next |
prevDay | Function | Change current day on previous |
nextMonth | Function | Change current month on next |
prevMonth | Function | Change current month on previous |
nextYear | Function | Change current year on next |
prevYear | Function | Change current year on previous |
setDate | Function | Set new day |
setMonth | Function | Set new month |
setYear | Function | Set new year |
config
Key | Type | Description |
---|---|---|
startDate | date | Start date |
endDate | date | End date |
maxDate | date | Option specifies the maximum/latest date (inclusively) allowed for selection |
minDate | date | Option 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.