@uplink-protocol/calendar-controller
Version:
Flexible calendar API supporting both calendar and date-picker integrations for any JavaScript framework or library
105 lines (104 loc) • 2.8 kB
TypeScript
import { CalendarDate } from './calendar.interfaces';
/**
* Calendar service interface
* Responsible for calendar generation and navigation functions
*/
export interface ICalendarService {
/**
* Generate calendar data for a specific month/year
*/
generateCalendarDays(year: number, month: number, options: CalendarGenerationOptions): CalendarDate[];
/**
* Get month name from month index
*/
getMonthName(month: number): string;
/**
* Get weekday names starting from the specified first day
*/
getWeekdayNames(firstDayOfWeek: number, short?: boolean): string[];
/**
* Navigate to next month from current date
*/
getNextMonth(currentDate: Date): Date;
/**
* Navigate to previous month from current date
*/
getPreviousMonth(currentDate: Date): Date;
/**
* Navigate to next year from current date
*/
getNextYear(currentDate: Date): Date;
/**
* Navigate to previous year from current date
*/
getPreviousYear(currentDate: Date): Date;
/**
* Set the localization service
*/
setLocalizationService(service: any): void;
/**
* Get the localization service
*/
getLocalizationService(): any | null;
/**
* Check if a date is today
*/
isToday(date: Date): boolean;
/**
* Get the ISO week number for a date
*/
getWeekNumber(date: Date): number;
}
/**
* Options for calendar generation
*/
export interface CalendarGenerationOptions {
selectedDate: Date | null;
selectedDateRange: {
startDate?: Date | null;
endDate?: Date | null;
start?: Date | null;
end?: Date | null;
};
focusedDate: Date | null;
firstDayOfWeek: number;
minDate: Date | null;
maxDate: Date | null;
disabledDates: Date[];
disabledDaysOfWeek: number[];
isRangeSelection: boolean;
isDateDisabledFn: (date: Date) => boolean;
hideOtherMonthDays: boolean;
locale?: string;
weekNumbers?: boolean;
fullWeekdays?: boolean;
}
/**
* Options for month view generation
*/
export interface MonthViewGenerationOptions {
selectedDateRange: any;
isRangeSelection: any;
selectedDate: Date | null;
currentDate: Date;
minDate: Date | null;
maxDate: Date | null;
isMonthDisabledFn?: (year: number, month: number) => boolean;
}
/**
* Options for year view generation
*/
export interface YearViewGenerationOptions {
selectedDateRange: any;
isRangeSelection: any;
selectedDate: Date | null;
currentDate: Date;
minDate: Date | null;
maxDate: Date | null;
isYearDisabledFn?: (year: number) => boolean;
yearRangeSize?: number;
selectedYearRange?: {
startYear: number;
endYear: number;
};
}