UNPKG

@oslokommune/punkt-react

Version:

React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo

105 lines (104 loc) 3.28 kB
import { IDateConstraints, TDateRangeMap } from '../../shared-types/calendar'; export declare const DEFAULT_STRINGS: Required<IPktCalendarStrings>; export interface IPktCalendarStrings { month?: string; year?: string; days?: string[]; daysShort?: string[]; months?: string[]; week?: string; prevMonth?: string; nextMonth?: string; } export interface PktCalendarHandle { handleDateSelect: (selectedDate: Date | null) => void; addToSelected: (selectedDate: Date) => void; removeFromSelected: (selectedDate: Date) => void; toggleSelected: (selectedDate: Date) => void; focusOnCurrentDate: () => void; close: () => void; } export interface IPktCalendar { selected?: string[]; multiple?: boolean; maxMultiple?: number; range?: boolean; earliest?: string | null; latest?: string | null; excludedates?: Date[] | string[]; excludeweekdays?: string[]; weeknumbers?: boolean; withcontrols?: boolean; currentmonth?: Date | string | null; today?: string; strings?: IPktCalendarStrings; onDateSelected?: (selected: string[]) => void; onClose?: () => void; id?: string; className?: string; } export type TDayViewData = { currentDate: Date; currentDateISO: string; isToday: boolean; isSelected: boolean; isDisabled: boolean; ariaLabel: string; tabindex: string; }; export interface ICalendarState { componentId: string; strings: Required<IPktCalendarStrings>; year: number; month: number; activeSelected: string[]; _selected: Date[]; inRange: TDateRangeMap; rangeHovered: Date | null; focusedDate: string | null; todayDate: Date; range: boolean; multiple: boolean; weeknumbers: boolean; withcontrols: boolean; earliest: string | null; latest: string | null; excludedates: Date[]; excludeweekdays: string[]; className?: string; dateConstraints: IDateConstraints; calendarRef: React.RefObject<HTMLDivElement | null>; selectableDatesRef: React.MutableRefObject<{ currentDateISO: string; isDisabled: boolean; tabindex: string; }[]>; tabIndexSetRef: React.MutableRefObject<number>; prevMonth: () => void; nextMonth: () => void; changeMonth: (newYear: number, newMonth: number) => void; handleDateSelect: (selectedDate: Date | null) => void; addToSelected: (selectedDate: Date) => void; removeFromSelected: (selectedDate: Date) => void; toggleSelectedDate: (selectedDate: Date) => void; handleRangeHover: (date: Date) => void; isExcluded: (date: Date) => boolean; isDayDisabled: (date: Date, isSelected: boolean) => boolean; focusOnCurrentDate: () => void; handleKeydown: (e: React.KeyboardEvent) => void; handleFocusOut: (e: React.FocusEvent) => void; close: () => void; setFocusedDate: (date: string | null) => void; } export interface ICalendarNavProps { componentId: string; strings: Required<IPktCalendarStrings>; year: number; month: number; earliest: string | null; latest: string | null; withcontrols: boolean; prevMonth: () => void; nextMonth: () => void; changeMonth: (newYear: number, newMonth: number) => void; }