import { __assign } from 'tslib' ; import { PointerDragEvent } from './interactions/pointer' ; import { buildDateSpanApi , DateSpanApi , DatePointApi , DateSpan } from './structs/date-span' ; import { CalendarContext } from './CalendarContext' ; import { ViewApi } from './ViewApi' ; import { DateMarker , startOfDay } from './datelib/marker' ; export interface DateClickApi extends DatePointApi { dayEl : HTMLElement ; jsEvent : UIEvent ; view : ViewApi ; } export interface DateSelectionApi extends DateSpanApi { jsEvent : UIEvent ; view : ViewApi ; } export type DatePointTransform = ( dateSpan : DateSpan , context : CalendarContext ) => any ; export type DateSpanTransform = ( dateSpan : DateSpan , context : CalendarContext ) => any ; export type CalendarInteraction = { destroy : ( ) => void ; } ; export type CalendarInteractionClass = { new ( context ) : CalendarInteraction ; } ; export type OptionChangeHandler = ( propValue : any , context : CalendarContext ) => void ; export type OptionChangeHandlerMap = { [ propName ] : OptionChangeHandler ; } ; export interface DateSelectArg extends DateSpanApi { jsEvent : MouseEvent | null ; view : ViewApi ; } export function triggerDateSelect ( selection , pev , context ) { context . emitter . trigger ( 'select' , { ... buildDateSpanApiWithContext ( selection , context ) , jsEvent : pev ? pev . origEvent as MouseEvent : null , view : context . viewApi || context . calendarApi . view , } as DateSelectArg ) ; } export interface DateUnselectArg { jsEvent : MouseEvent ; view : ViewApi ; } export function triggerDateUnselect ( pev , context ) { context . emitter . trigger ( 'unselect' , { jsEvent : pev ? pev . origEvent : null , view : context . viewApi || context . calendarApi . view , } as DateUnselectArg ) ; } export function buildDateSpanApiWithContext ( dateSpan , context ) { let props = { } as DateSpanApi ; for ( let transform of context . pluginHooks . dateSpanTransforms ) { __assign ( props , transform ( dateSpan , context ) ) ; } __assign ( props , buildDateSpanApi ( dateSpan , context . dateEnv ) ) ; return props ; } export function getDefaultEventEnd ( allDay , marker , context ) { let { dateEnv , options } = context ; let end = marker ; if ( allDay ) { end = startOfDay ( end ) ; end = dateEnv . add ( end , options . defaultAllDayEventDuration ) ; } else { end = dateEnv . add ( end , options . defaultTimedEventDuration ) ; } return end ; }