Calendar/src/types/CalendarTypes.ts

111 lines
2.8 KiB
TypeScript
Raw Normal View History

// Calendar type definitions
export type ViewType = 'day' | 'week' | 'month';
export type CalendarView = ViewType; // Alias for compatibility
export type EventType = 'meeting' | 'meal' | 'work' | 'milestone';
export type SyncStatus = 'synced' | 'pending' | 'error';
export interface CalendarEvent {
id: string;
title: string;
start: string; // ISO 8601
end: string; // ISO 8601
type: EventType;
allDay: boolean;
syncStatus: SyncStatus;
recurringId?: string;
resources?: string[];
metadata?: Record<string, any>;
}
export interface CalendarConfig {
// View settings
view: ViewType;
weekDays: number; // 4-7 days for week view
firstDayOfWeek: number; // 0 = Sunday, 1 = Monday
// Time settings
dayStartHour: number; // Calendar starts at hour
dayEndHour: number; // Calendar ends at hour
workStartHour: number; // Work hours start
workEndHour: number; // Work hours end
snapInterval: number; // Minutes: 5, 10, 15, 30, 60
// Display settings
hourHeight: number; // Pixels per hour
showCurrentTime: boolean;
showWorkHours: boolean;
2025-08-05 21:56:06 +02:00
fitToWidth: boolean; // Fit columns to calendar width vs horizontal scroll
// Scrollbar styling
scrollbarWidth: number; // Width of scrollbar in pixels
scrollbarColor: string; // Scrollbar thumb color
scrollbarTrackColor: string; // Scrollbar track color
scrollbarHoverColor: string; // Scrollbar thumb hover color
scrollbarBorderRadius: number; // Border radius for scrollbar thumb
// Interaction settings
allowDrag: boolean;
allowResize: boolean;
allowCreate: boolean;
// API settings
apiEndpoint: string;
dateFormat: string;
timeFormat: string;
// Feature flags
enableSearch: boolean;
enableTouch: boolean;
// Event defaults
defaultEventDuration: number; // Minutes
minEventDuration: number; // Minutes
maxEventDuration: number; // Minutes
}
export interface EventLogEntry {
type: string;
detail: any;
timestamp: number;
}
export interface ListenerEntry {
eventType: string;
handler: EventListener;
options?: AddEventListenerOptions;
}
export interface IEventBus {
on(eventType: string, handler: EventListener, options?: AddEventListenerOptions): () => void;
once(eventType: string, handler: EventListener): () => void;
off(eventType: string, handler: EventListener): void;
emit(eventType: string, detail?: any): boolean;
getEventLog(eventType?: string): EventLogEntry[];
setDebug(enabled: boolean): void;
destroy(): void;
}
export interface GridPosition {
minutes: number;
time: string;
y: number;
}
export interface Period {
start: string;
end: string;
view: ViewType;
}
export interface EventData {
events: CalendarEvent[];
meta: {
start: string;
end: string;
view: ViewType;
total: number;
};
}