import { CalendarApi } from './CalendarApi' ; import { ViewApi } from './ViewApi' ; import { Theme } from './theme/Theme' ; import { DateEnv } from './datelib/env' ; import { PluginHooks } from './plugin-system-struct' ; import { createContext , Context } from './vdom' ; import { ScrollResponder , ScrollRequestHandler } from './ScrollResponder' ; import { DateProfileGenerator } from './DateProfileGenerator' ; import { ViewSpec } from './structs/view-spec' ; import { CalendarData } from './reducers/data-types' ; import { Action } from './reducers/Action' ; import { Emitter } from './common/Emitter' ; import { InteractionSettingsInput } from './interactions/interaction' ; import { DateComponent } from './component/DateComponent' ; import { CalendarContext } from './CalendarContext' ; import { createDuration } from './datelib/duration' ; import { ViewOptionsRefined , CalendarListeners } from './options' ; export const ViewContextType = createContext < ViewContext > ( { } as any ) ; export type ResizeHandler = ( force : boolean ) => void ; export interface ViewContext extends CalendarContext { options : ViewOptionsRefined ; theme : Theme ; isRtl : boolean ; dateProfileGenerator : DateProfileGenerator ; viewSpec : ViewSpec ; viewApi : ViewApi ; addResizeHandler : ( handler : ResizeHandler ) => void ; removeResizeHandler : ( handler : ResizeHandler ) => void ; createScrollResponder : ( execFunc : ScrollRequestHandler ) => ScrollResponder ; registerInteractiveComponent : ( component : DateComponent < any > , settingsInput : InteractionSettingsInput ) => void ; unregisterInteractiveComponent : ( component : DateComponent < any > ) => void ; } export function buildViewContext ( viewSpec , viewApi , viewOptions , dateProfileGenerator , dateEnv , theme , pluginHooks , dispatch , getCurrentData , emitter , calendarApi , registerInteractiveComponent , unregisterInteractiveComponent ) { return { dateEnv , options : viewOptions , pluginHooks , emitter , dispatch , getCurrentData , calendarApi , viewSpec , viewApi , dateProfileGenerator , theme , isRtl : viewOptions . direction === 'rtl' , addResizeHandler ( handler ) { emitter . on ( '_resize' , handler ) ; } , removeResizeHandler ( handler ) { emitter . off ( '_resize' , handler ) ; } , createScrollResponder ( execFunc ) { return new ScrollResponder ( execFunc , emitter , createDuration ( viewOptions . scrollTime ) , viewOptions . scrollTimeReset ) ; } , registerInteractiveComponent , unregisterInteractiveComponent , } ; }