import { ReactNode, MouseEvent } from 'react'; import { EventModel } from '../types/scheduler-types'; import { ProcessedEventsData } from '../types/internal-interface'; /** * Interface for useEventRendering hook parameters (day-event variant). */ interface DayEventRenderingProps { /** Discriminator to select day-event rendering logic. */ variant: 'day'; /** The event model to render. */ event: EventModel; /** Number of segments if the event is spanned. */ totalSegments?: number; /** Whether the event overflows to the left. */ isOverflowLeft?: boolean; /** Whether the event overflows to the right. */ isOverflowRight?: boolean; } /** * Interface for useEventRendering hook parameters (time-slot variant). * Does not accept per-event data — the returned functions accept eventInfo * as a parameter, allowing a single hook call to serve all events in a loop. * Also exposes timeline-specific content getters bound from the same context. */ interface TimeSlotEventRenderingProps { /** Discriminator to select time-slot rendering logic. */ variant: 'timeSlot'; } interface UseEventRenderingHook { (props: DayEventRenderingProps): DayEventRenderingResult; (props: TimeSlotEventRenderingProps): TimeSlotEventRenderingResult; (): CommonEventHandlers; } /** * Common click/double-click handler signatures shared by both variants. * Accepts a flat `event` model and an `isBlocked` flag so the same * handler works for day-events (where `isBlockedEvent` is a prop) and * time-slot events (where `event.isBlock` is the flag). */ interface CommonEventHandlers { /** * Handles a click on an event element. * Early-exits for blocked events; calls `clearAndSelectAppointment` * and fires the `onEventClick` callback otherwise. */ handleClick: (e: MouseEvent, event: EventModel, isBlocked: boolean) => void; /** * Handles a double-click on an event element. * Early-exits for readonly / blocked events; hides the quick popup * and fires the `onEventDoubleClick` callback otherwise. */ handleDoubleClick: (e: MouseEvent, event: EventModel, isBlocked: boolean) => void; } /** * Result shape for the 'day' variant — rendering functions are zero-argument * because event data is bound at hook-call time. * Handlers accept the event and isBlocked flag per call. */ interface DayEventRenderingResult extends CommonEventHandlers { /** * Returns the resolved day/all-day event content based on event type. */ getEventContent: () => ReactNode; } /** * Result shape for the 'timeSlot' variant — all rendering functions accept * eventInfo as a parameter so a single hook call serves all events in a loop. * Handlers accept the event and isBlocked flag per call. */ interface TimeSlotEventRenderingResult extends CommonEventHandlers { /** Returns the resolved vertical time-slot content for the given event. */ getEventContent: (eventInfo: ProcessedEventsData) => ReactNode; /** * Returns timeline (horizontal) time-slot content for the given event. * Bound with the same locale/timeFormat/template/renderDates context. */ getTimelineTimeSlotEventContent: (eventInfo: ProcessedEventsData) => ReactNode; } /** * Custom hook that provides memoized rendering methods for scheduler events. * * Supports two variants via the `variant` discriminator: * - `'day'` → DayEvent / DayEventClone: zero-arg functions, event bound at hook-call time. * - `'timeSlot'` → Appointment / TimeSlotEventClone: functions accept `eventInfo` per call. * Exposes getEventContent (vertical) and getTimelineTimeSlotEventContent (timeline). * - `undefined` → Only returns event handlers (handleClick, handleDoubleClick). * * Internally reads locale, timeFormat, eventTemplate and timescale settings once from context, * and delegates to pure utility functions in event-render. Callers should not re-read those * props just to build event content — use the bound getters returned by this hook. * * @param {UseEventRenderingProps} [props] - Rendering parameters for the selected variant. * @returns {DayEventRenderingResult|TimeSlotEventRenderingResult|CommonEventHandlers} Memoized rendering functions or handlers. * @private */ export declare const useEventRendering: UseEventRenderingHook; export default useEventRendering;