import React from 'react'; import { Views, ITaskRunner } from '@singularsystems/neo-core'; import { RouteParameterObject } from '../Routing/IRouteParameter'; import { TransformParamsType, IViewParameterList, IViewParameterListOfT } from '../Routing/ViewParameterList'; import { ViewState } from './ViewState'; import { BreadCrumbItem } from '../Routing/BreadCrumbItem'; import { IViewModel } from './IViewModel'; import EmptyViewModel from './EmptyViewModel'; import { IRouteChangedProps } from '../Routing/IRouteChangedProps'; import { valueOrLazy } from './ViewModelBase'; import { IMatchedRoute } from "../Routing/RouteProvider"; import { HeaderContributorContext, IHeaderContributorContextHost } from './HeaderPanel'; import ObservableElement from '../React/ObservableElement'; export interface IViewBase extends Views.IViewBase { readonly fullScreen: boolean; viewParams: IViewParameterList; updateViewParams(match: IMatchedRoute): void; getBreadCrumbList(): BreadCrumbItem[]; onLeave(): string | undefined; beforeRouteChanged(props: IRouteChangedProps): void; viewModel: IViewModel; } export interface IViewBaseConstructor { params?: RouteParameterObject; } export default abstract class ViewBase = {}> extends React.Component implements IViewBase, IHeaderContributorContextHost { viewName: string; /** Indicates that the view requests to be displayed full screen. Up to the main layout to accommodate this. */ fullScreen: boolean; /** Indicates that the VM has initialised, and viewParamsUpdated() has been called. */ hasInitialised: boolean; /** Context for the header panel contributors. */ headerContext: HeaderContributorContext; headerTriggerElement: ObservableElement; static get currentView(): IViewBase | null; private routingState; navigation: import("../Routing").INavigationHelper; private breadCrumbStartItems?; protected viewState: ViewState; /** If true, viewParamsUpdated() will be called on initialisation even if all parameters have default values. */ protected callViewParamsUpdatedOnInitialise: boolean; /** * Creates a view * @param props React props. * @param viewName Name of the view. * @param viewModel Instance of view model, or view model type, or callback which returns a view model. */ constructor(viewName: string, viewModel: valueOrLazy, props: any); get viewModel(): TViewModel; get taskRunner(): ITaskRunner; get viewParams(): IViewParameterListOfT & TransformParamsType; protected getStoredViewState(viewModel: valueOrLazy): ViewState; protected createViewState(viewModel: valueOrLazy): ViewState; componentDidMount(): Promise; componentWillUnmount(): void; updateViewParams(match: IMatchedRoute): void; /** * viewParamsUpdated() is called when the component is mounted, and whenever a route parameter or query parameter gets a changed value. */ protected viewParamsUpdated(): void | Promise; /** Gets the parent breadcrumbs, and the breadcrumb for this view. */ protected getBreadCrumbStart(): BreadCrumbItem[]; /** * Initialise is called from componentDidMount(). * Will only be called once per persistent view for the lifetime of the app. * If overridden, you must call super.initialise() to initialise the ViewModel. */ protected initialise(): void | Promise; protected disposeViewModel(): void; getBreadCrumbList(): BreadCrumbItem[]; /** * Called when the user navigates to a new view, or when exiting the site. * Return a string to show to the user in a dialog. */ onLeave(): string | undefined; /** * Called whenever the route changes. Including navigating to a new view, leaving the site, or changing a route parameter in this view. * Note: if props.leavePrompt is set, onLeave() will not be called. * @param props Set leavePrompt to `false`, a `string`, or a promise from a modal. */ beforeRouteChanged(props: IRouteChangedProps): void; }