UNPKG

whensday-calendar-lib

Version:

A flexible calendar library with Whensday/Gregorian calendar systems, event management, and customizable UI components

187 lines (184 loc) 5.03 kB
import React from 'react'; interface WhensdayDate { year: number; month: number; day: number; monthName: string; isWeensday?: boolean; isWhensday?: boolean; } interface DayInGrid { year: number; month: number; day: number; monthName: string; isWhensdayLeapDay?: boolean; } interface CalendarDay { date: DayInGrid; isToday: boolean; isCurrentMonth: boolean; } type CalendarSystem = 'whensday' | 'gregorian'; type CalendarView = 'month' | 'week' | 'day'; interface Layer { id: string; name: string; color: string; isVisible: boolean; parentId?: string; } type EventType = 'event' | 'deadline' | 'task' | 'birthday'; type DuePeriod = 'morning' | 'afternoon' | 'evening'; interface LocationDetails { name: string; placeId: string; } interface Event { id: string; name: string; layerId: string | null; color?: string; startDate: number; endDate?: number; eventType: EventType; isAllDay: boolean; location?: LocationDetails | null; startLocation?: LocationDetails | null; endLocation?: LocationDetails | null; isCompleted?: boolean; tags?: string[]; startTime?: string; endTime?: string; travelTimeBefore?: number; travelTimeAfter?: number; doByDate?: number; doByTime?: string; dueTime?: string; duePeriod?: DuePeriod; isRecurring?: boolean; naturalLanguageRule?: string; recurrenceRule?: string; } interface SchedulePattern { on: number; off: number; } interface HolidaySettings { enabled: boolean; onDays: number; holidays: number; bonusDayRate: number; } interface ScheduleExemption { id: string; startDate: number; endDate: number; resumeAfter: number; } interface Schedule { id: string; name: string; layerId: string | null; color: string | null; startDate: number; endDate?: number; pattern: SchedulePattern; isVisible: boolean; initialHolidayBalance?: number; bookedHolidays?: number[]; completedDays?: number[]; holidaySettings?: HolidaySettings; exemptions?: ScheduleExemption[]; bonusDays?: number[]; } interface DragState { eventId: string; offsetY: number; ghostHeightPercent: number; layer: Layer; event: Event; } interface UserSettings { homeAddress: LocationDetails | null; } interface CalendarState { view: CalendarView; system: CalendarSystem; displayDate: DayInGrid; calendarGrid: CalendarDay[]; currentMonthName: string; currentYear: number; hourHeight: number; } interface CalendarEventHandlers { onEventClick?: (event: Event) => void; onEventAdd?: (date: DayInGrid, time?: string) => void; onEventUpdate?: (event: Event) => void; onEventDelete?: (eventId: string) => void; onEventMove?: (eventId: string, newDayTimestamp: number, newStartTime?: string) => void; onDateClick?: (date: DayInGrid) => void; onViewChange?: (view: CalendarView) => void; onSystemChange?: (system: CalendarSystem) => void; } interface CalendarTheme { colors: { primary: string; secondary: string; accent: string; background: string; surface: string; text: string; textSecondary: string; border: string; today: string; whensdayLeap: string; }; fonts: { primary: string; secondary: string; }; spacing: { xs: string; sm: string; md: string; lg: string; xl: string; }; borderRadius: { sm: string; md: string; lg: string; }; } interface CalendarProps { events?: Event[]; layers?: Layer[]; schedules?: Schedule[]; view?: CalendarView; system?: CalendarSystem; displayDate?: DayInGrid; onEventClick?: (event: Event) => void; onEventAdd?: (date: DayInGrid, time?: string) => void; onEventUpdate?: (event: Event) => void; onEventDelete?: (eventId: string) => void; onEventMove?: (eventId: string, newDayTimestamp: number, newStartTime?: string) => void; onDateClick?: (date: DayInGrid) => void; onViewChange?: (view: CalendarView) => void; onSystemChange?: (system: CalendarSystem) => void; theme?: Partial<CalendarTheme>; className?: string; style?: React.CSSProperties; enableDragAndDrop?: boolean; enableScheduleManagement?: boolean; enableHolidayBooking?: boolean; enableTravelTime?: boolean; enableRecurringEvents?: boolean; showWeekNumbers?: boolean; showTodayIndicator?: boolean; showHolidayIndicators?: boolean; showScheduleIndicators?: boolean; locale?: string; weekStart?: 0 | 1; } export { CalendarDay, CalendarEventHandlers, CalendarProps, CalendarState, CalendarSystem, CalendarTheme, CalendarView, DayInGrid, DragState, DuePeriod, Event, EventType, HolidaySettings, Layer, LocationDetails, Schedule, ScheduleExemption, SchedulePattern, UserSettings, WhensdayDate };