Introduces a polymorphic `createClone` method on base event elements to customize clone generation. Adds a `replaceClone` delegate to drag event payloads, enabling subscribers to dynamically swap the active dragged clone. This supports scenarios like converting a standard event clone to an all-day event clone when dragging to the all-day header.
112 lines
No EOL
2.6 KiB
TypeScript
112 lines
No EOL
2.6 KiB
TypeScript
/**
|
|
* Type definitions for calendar events
|
|
*/
|
|
|
|
import { ColumnBounds } from "../utils/ColumnDetectionUtils";
|
|
import { CalendarEvent } from "./CalendarTypes";
|
|
|
|
export interface AllDayEvent {
|
|
id: string;
|
|
title: string;
|
|
start: Date | string;
|
|
end: Date | string;
|
|
allDay: true;
|
|
color?: string;
|
|
metadata?: {
|
|
color?: string;
|
|
category?: string;
|
|
location?: string;
|
|
};
|
|
}
|
|
|
|
export interface TimeEvent {
|
|
id: string;
|
|
title: string;
|
|
start: Date | string;
|
|
end: Date | string;
|
|
allDay?: false;
|
|
color?: string;
|
|
metadata?: {
|
|
color?: string;
|
|
category?: string;
|
|
location?: string;
|
|
};
|
|
}
|
|
|
|
export type CalendarEventData = AllDayEvent | TimeEvent;
|
|
|
|
/**
|
|
* Drag Event Payload Interfaces
|
|
* Type-safe interfaces for drag and drop events
|
|
*/
|
|
|
|
// Common position interface
|
|
export interface MousePosition {
|
|
x: number;
|
|
y: number;
|
|
}
|
|
|
|
// Drag start event payload
|
|
export interface DragStartEventPayload {
|
|
draggedElement: HTMLElement;
|
|
draggedClone: HTMLElement | null;
|
|
mousePosition: MousePosition;
|
|
mouseOffset: MousePosition;
|
|
columnBounds: ColumnBounds | null;
|
|
}
|
|
|
|
// Drag move event payload
|
|
export interface DragMoveEventPayload {
|
|
draggedElement: HTMLElement;
|
|
draggedClone: HTMLElement;
|
|
mousePosition: MousePosition;
|
|
mouseOffset: MousePosition;
|
|
columnBounds: ColumnBounds | null;
|
|
snappedY: number;
|
|
}
|
|
|
|
// Drag end event payload
|
|
export interface DragEndEventPayload {
|
|
originalElement: HTMLElement;
|
|
draggedClone: HTMLElement | null;
|
|
mousePosition: MousePosition;
|
|
finalPosition: {
|
|
column: ColumnBounds | null;
|
|
snappedY: number;
|
|
};
|
|
target: 'swp-day-column' | 'swp-day-header' | null;
|
|
}
|
|
|
|
// Drag mouse enter header event payload
|
|
export interface DragMouseEnterHeaderEventPayload {
|
|
targetColumn: ColumnBounds;
|
|
mousePosition: MousePosition;
|
|
originalElement: HTMLElement | null;
|
|
draggedClone: HTMLElement;
|
|
calendarEvent: CalendarEvent;
|
|
// Delegate pattern - allows subscriber to replace the dragged clone
|
|
replaceClone: (newClone: HTMLElement) => void;
|
|
}
|
|
|
|
// Drag mouse leave header event payload
|
|
export interface DragMouseLeaveHeaderEventPayload {
|
|
targetDate: string | null;
|
|
mousePosition: MousePosition;
|
|
originalElement: HTMLElement| null;
|
|
draggedClone: HTMLElement| null;
|
|
}
|
|
|
|
// Drag column change event payload
|
|
export interface DragColumnChangeEventPayload {
|
|
originalElement: HTMLElement;
|
|
draggedClone: HTMLElement | null;
|
|
previousColumn: ColumnBounds | null;
|
|
newColumn: ColumnBounds;
|
|
mousePosition: MousePosition;
|
|
}
|
|
|
|
// Header ready event payload
|
|
export interface HeaderReadyEventPayload {
|
|
headerElements: ColumnBounds[];
|
|
|
|
} |