react-availability-calendar
Version:
A customizable React component for displaying booking availabilities on a calendar.
145 lines (144 loc) • 4.36 kB
TypeScript
import { MomentCtrFunc } from './moment-types/moment-subset';
import { createUtils } from './utils';
import { CSSProperties } from 'react';
export interface CalendarTheme {
dayClassBase: string;
dayClassSelected: string;
dayClassHasAvailability: string;
dayClassDefault: string;
slotsContainerStyleShow: CSSProperties;
slotsContainerStyleHide: CSSProperties;
slotContainerCloseClass: string;
slotButtonClass: string;
toolBarStyle: CSSProperties;
toolBarButtonsContainerClass: string;
toolBarButtonClass: string;
toolBarLabelClass: string;
requestAppointmentLabel: string;
}
export interface CalendarThemeProp {
dayClassBase?: string;
dayClassSelected?: string;
dayClassHasAvailability?: string;
dayClassDefault?: string;
slotsContainerStyleShow?: CSSProperties;
slotsContainerStyleHide?: CSSProperties;
slotContainerCloseClass?: string;
slotButtonClass?: string;
toolBarStyle?: CSSProperties;
toolBarButtonsContainerClass?: string;
toolBarButtonClass?: string;
toolBarLabelClass?: string;
requestAppointmentLabel?: string;
}
export declare const defaultTheme: CalendarTheme;
export interface AvailabilityEvent {
startDate: Date;
endDate: Date;
}
export interface Booking {
startDate: Date;
endDate: Date;
}
export declare type NavigateAction = 'PREV' | 'NEXT' | 'TODAY' | 'DATE';
export interface Navigate {
[key: string]: NavigateAction;
}
export interface ToolBarProps {
label: string;
onNavigate: (action: NavigateAction) => any;
localizer: {
messages: {
[key: string]: string;
};
};
}
export interface ToolBarButtonProps {
message: string;
onClicked: () => void;
}
declare type stringOrDate = string | Date;
export declare type Range = Date[] | {
start: stringOrDate;
end: stringOrDate;
};
export interface AvailabilityCalendarProps {
moment: MomentCtrFunc;
excludeWeekends?: boolean;
excludeFn?: (date: Date) => boolean;
theme?: CalendarThemeProp;
onCalRangeChange?: (range: Range) => any;
providerTimeZone: string;
bookings: Booking[];
avails?: AvailabilityEvent[];
initialDate: Date | null;
onAvailabilitySelected: (e: AvailabilityEvent) => any;
onDaySelected?: (d: Date | null) => any;
blockOutPeriods?: MsSinceMidnightRange[];
slotLengthMs?: number;
slotStepMs?: number;
}
export interface MonthlyAvailabilityCalendarProps {
availabilities: AvailabilityEvent[];
excludeWeekends?: boolean;
excludeFn?: (date: Date) => boolean;
date: Date;
style?: CSSProperties;
onDaySelected?: (d: Date | null) => any;
onAvailabilitySelected: (e: AvailabilityEvent) => any;
slotLengthMs?: number;
slotStepMs?: number;
}
export interface DayCellProps {
selectedDate: Date | null;
shouldDisplay: boolean;
date: Date;
dayIndexInWeek: number;
weekIndexInCalRange: number;
handleSelected: (d: Date) => any;
availsByIndex: HasAvail[];
moment: MomentCtrFunc;
utils: ReturnType<typeof createUtils>;
theme: CalendarTheme;
}
export interface DayCellsProps {
week: Date[];
date: Date;
selectedDate: Date | null;
weekIndexInCalRange: number;
handleSelected: (date: Date) => void;
availsByIndex: {
hasAvail: boolean;
}[];
moment: MomentCtrFunc;
utils: ReturnType<typeof createUtils>;
theme: CalendarTheme;
}
export interface AvailSlotsProps {
viewingDayAvailabilities: AvailabilityEvent[];
handleUnselect: () => any;
show: boolean;
onAvailabilitySelected: (e: AvailabilityEvent) => any;
slotLengthMs?: number;
slotStepMs?: number;
utils: ReturnType<typeof createUtils>;
theme: CalendarTheme;
}
export interface AvailSlotProps {
theme: CalendarTheme;
onAvailabilitySelected: (e: AvailabilityEvent) => any;
s: AvailabilityEvent;
formatAsDateJustTime: (date: Date) => string;
}
export interface HasAvail {
hasAvail: boolean;
}
export interface Booking {
id?: string;
startDate: Date;
endDate: Date;
isBlockout?: boolean;
resourceId?: number;
}
export declare type MsSinceMidnightRange = number[];
export {};