2025-08-20 19:42:13 +02:00
|
|
|
/**
|
2025-10-06 21:55:52 +02:00
|
|
|
* Type definitions for calendar events and drag operations
|
2025-08-20 19:42:13 +02:00
|
|
|
*/
|
|
|
|
|
|
2025-09-28 13:25:09 +02:00
|
|
|
import { ColumnBounds } from "../utils/ColumnDetectionUtils";
|
2025-10-04 16:20:09 +02:00
|
|
|
import { CalendarEvent } from "./CalendarTypes";
|
2025-09-28 13:25:09 +02:00
|
|
|
|
2025-09-21 15:48:13 +02:00
|
|
|
/**
|
|
|
|
|
* 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;
|
2025-09-26 22:53:49 +02:00
|
|
|
draggedClone: HTMLElement | null;
|
2025-09-21 15:48:13 +02:00
|
|
|
mousePosition: MousePosition;
|
|
|
|
|
mouseOffset: MousePosition;
|
2025-09-28 13:25:09 +02:00
|
|
|
columnBounds: ColumnBounds | null;
|
2025-09-21 15:48:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Drag move event payload
|
|
|
|
|
export interface DragMoveEventPayload {
|
|
|
|
|
draggedElement: HTMLElement;
|
2025-09-30 00:13:52 +02:00
|
|
|
draggedClone: HTMLElement;
|
2025-09-21 15:48:13 +02:00
|
|
|
mousePosition: MousePosition;
|
|
|
|
|
mouseOffset: MousePosition;
|
2025-09-28 13:25:09 +02:00
|
|
|
columnBounds: ColumnBounds | null;
|
2025-09-21 15:48:13 +02:00
|
|
|
snappedY: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Drag end event payload
|
|
|
|
|
export interface DragEndEventPayload {
|
2025-09-30 00:13:52 +02:00
|
|
|
originalElement: HTMLElement;
|
2025-09-27 15:01:22 +02:00
|
|
|
draggedClone: HTMLElement | null;
|
2025-10-08 22:18:06 +02:00
|
|
|
sourceColumn: ColumnBounds | null; // Where drag started
|
2025-09-21 15:48:13 +02:00
|
|
|
mousePosition: MousePosition;
|
|
|
|
|
finalPosition: {
|
2025-10-08 22:18:06 +02:00
|
|
|
column: ColumnBounds | null; // Where drag ended
|
2025-09-21 15:48:13 +02:00
|
|
|
snappedY: number;
|
|
|
|
|
};
|
|
|
|
|
target: 'swp-day-column' | 'swp-day-header' | null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Drag mouse enter header event payload
|
|
|
|
|
export interface DragMouseEnterHeaderEventPayload {
|
2025-09-28 13:25:09 +02:00
|
|
|
targetColumn: ColumnBounds;
|
2025-09-21 15:48:13 +02:00
|
|
|
mousePosition: MousePosition;
|
|
|
|
|
originalElement: HTMLElement | null;
|
2025-09-30 00:13:52 +02:00
|
|
|
draggedClone: HTMLElement;
|
2025-10-04 16:20:09 +02:00
|
|
|
calendarEvent: CalendarEvent;
|
2025-10-04 23:10:09 +02:00
|
|
|
// Delegate pattern - allows subscriber to replace the dragged clone
|
|
|
|
|
replaceClone: (newClone: HTMLElement) => void;
|
2025-09-21 15:48:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Drag mouse leave header event payload
|
|
|
|
|
export interface DragMouseLeaveHeaderEventPayload {
|
|
|
|
|
targetDate: string | null;
|
|
|
|
|
mousePosition: MousePosition;
|
|
|
|
|
originalElement: HTMLElement| null;
|
2025-09-30 00:13:52 +02:00
|
|
|
draggedClone: HTMLElement| null;
|
2025-09-22 23:37:43 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-10 16:41:48 +02:00
|
|
|
// Drag mouse enter column event payload
|
|
|
|
|
export interface DragMouseEnterColumnEventPayload {
|
|
|
|
|
targetColumn: ColumnBounds;
|
|
|
|
|
mousePosition: MousePosition;
|
|
|
|
|
snappedY: number;
|
|
|
|
|
originalElement: HTMLElement | null;
|
|
|
|
|
draggedClone: HTMLElement;
|
|
|
|
|
calendarEvent: CalendarEvent;
|
|
|
|
|
// Delegate pattern - allows subscriber to replace the dragged clone
|
|
|
|
|
replaceClone: (newClone: HTMLElement) => void;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-26 22:11:57 +02:00
|
|
|
// Drag column change event payload
|
|
|
|
|
export interface DragColumnChangeEventPayload {
|
2025-09-30 00:13:52 +02:00
|
|
|
originalElement: HTMLElement;
|
2025-09-26 22:53:49 +02:00
|
|
|
draggedClone: HTMLElement | null;
|
2025-09-28 13:25:09 +02:00
|
|
|
previousColumn: ColumnBounds | null;
|
|
|
|
|
newColumn: ColumnBounds;
|
2025-09-26 22:11:57 +02:00
|
|
|
mousePosition: MousePosition;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-22 23:37:43 +02:00
|
|
|
// Header ready event payload
|
|
|
|
|
export interface HeaderReadyEventPayload {
|
2025-10-01 21:27:13 +02:00
|
|
|
headerElements: ColumnBounds[];
|
2025-10-08 22:18:06 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Resize end event payload
|
|
|
|
|
export interface ResizeEndEventPayload {
|
|
|
|
|
eventId: string;
|
|
|
|
|
element: HTMLElement;
|
|
|
|
|
finalHeight: number;
|
2025-09-21 15:48:13 +02:00
|
|
|
}
|