UNPKG

@fremtind/jkl-datepicker-react

Version:
60 lines (59 loc) 1.92 kB
import React from "react"; import { DateInfo, CalendarMonth } from "./utils"; type GetDateProps = { onClick?: React.MouseEventHandler; dateObj: DateInfo; }; type GetDatePropsResult = { onClick: React.MouseEventHandler; disabled: boolean; "aria-pressed": boolean; role: "button"; }; type GetBackProps = { onClick?: React.MouseEventHandler; offset?: number; calendars: CalendarMonth[]; }; type GetBackPropsResult = { onClick: React.MouseEventHandler; disabled: boolean; "aria-label": string; title: string; }; type GetForwardProps = { onClick?: React.MouseEventHandler; offset?: number; calendars: CalendarMonth[]; }; type GetForwardPropsResult = { onClick: React.MouseEventHandler; disabled: boolean; "aria-label": string; title: string; }; export interface UseCalendarProps { date?: Date; maxDate?: Date; minDate?: Date; monthsToDisplay?: number; firstDayOfWeek?: number; showOutsideDays?: boolean; offset: number; onDateSelected: (dateObj: DateInfo, event: React.MouseEvent) => void; onOffsetChanged: (newOffset: number) => void; selected?: Date | Date[]; } export type GetDatePropsFunc = (props: GetDateProps) => GetDatePropsResult; export type GetBackPropsFunc = (props: GetBackProps) => GetBackPropsResult; export type GetForwardPropsFunc = (props: GetForwardProps) => GetForwardPropsResult; export type HandleOffsetFunc = (newOffset: number) => void; export type UseCalendarResult = { calendars: CalendarMonth[]; getDateProps: GetDatePropsFunc; getBackProps: GetBackPropsFunc; getForwardProps: GetForwardPropsFunc; handleOffsetChanged: HandleOffsetFunc; }; export declare function useCalendar({ date, maxDate, minDate, monthsToDisplay, firstDayOfWeek, showOutsideDays, offset, onDateSelected, onOffsetChanged, selected, }: UseCalendarProps): UseCalendarResult; export {};