Calendar/src/types/CalendarTypes.ts
Janus C. H. Knudsen e838719d46 Cleanup
2025-10-06 21:55:52 +02:00

100 lines
No EOL
2.4 KiB
TypeScript

// Calendar type definitions
// Time period view types (how much time to display)
export type ViewPeriod = 'day' | 'week' | 'month';
// Calendar mode types (how to organize the data)
export type CalendarMode = 'date' | 'resource';
// Type aliases
export type CalendarView = ViewPeriod;
export type SyncStatus = 'synced' | 'pending' | 'error';
export interface Resource {
name: string;
displayName: string;
avatarUrl: string;
employeeId: string;
events: CalendarEvent[];
}
export interface ResourceCalendarData {
date: string;
resources: Resource[];
}
export interface RenderContext {
container: HTMLElement;
startDate: Date;
endDate: Date;
}
export interface CalendarEvent {
id: string;
title: string;
start: Date;
end: Date;
type: string; // Flexible event type - can be any string value
allDay: boolean;
syncStatus: SyncStatus;
// Resource information (only present in resource calendar mode)
resource?: {
name: string;
displayName: string;
employeeId: string;
};
recurringId?: string;
metadata?: Record<string, any>;
}
export interface CalendarConfig {
// 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: unknown;
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?: unknown): boolean;
getEventLog(eventType?: string): EventLogEntry[];
setDebug(enabled: boolean): void;
}